--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>\r
+<projectDescription>\r
+ <name>sysdyn-installer</name>\r
+ <comment></comment>\r
+ <projects>\r
+ </projects>\r
+ <buildSpec>\r
+ </buildSpec>\r
+ <natures>\r
+ </natures>\r
+</projectDescription>\r
--- /dev/null
+;!@Install@!UTF-8!\r
+Title="Software 5.00"\r
+BeginPrompt="Do you want to install the Software 5.00?"\r
+RunProgram="7zr.exe"\r
+;!@InstallEnd@!\r
--- /dev/null
+del archive.7z\r
+del archive.exe\r
+..\7zr a archive.7z ..\7zr.exe -m0=BCJ2 -m1=LZMA:d25:fb255 -m2=LZMA:d19 -m3=LZMA:d19 -mb0:1 -mb0s1:2 -mb0s2:3 -mx\r
+copy /b ..\7zSD.sfx + config.txt + archive.7z archive.exe\r
--- /dev/null
+7-Zip for installers 4.65\r
+-------------------------\r
+\r
+7-Zip is a file archiver for Windows 98/ME/NT/2000/2003/XP. \r
+\r
+7-Zip Copyright (C) 1999-2009 Igor Pavlov.\r
+\r
+This library is free software; you can redistribute it and/or\r
+modify it under the terms of the GNU Lesser General Public\r
+License as published by the Free Software Foundation; either\r
+version 2.1 of the License, or (at your option) any later version.\r
+\r
+7zr.exe is reduced version of 7za.exe of 7-Zip.\r
+7zr.exe supports only 7z format with this codecs: LZMA, BCJ, BCJ2, Copy.\r
+\r
+Example of compressing command for installation packages:\r
+\r
+7zr a -t7z archive.7z * -m0=BCJ2 -m1=LZMA:d25:fb255 -m2=LZMA:d19 -m3=LZMA:d19 -mb0:1 -mb0s1:2 -mb0s2:3 -mx\r
+\r
+\r
+7zSD.sfx is SFX module for installers (it uses msvcrt.dll)\r
+\r
+SFX modules for installers (7zS.sfx and 7zSD.sfx) allow to create installation program. \r
+Such module extracts archive to temp folder and then runs specified program and removes \r
+temp files after program finishing. Self-extract archive for installers must be created \r
+as joining 3 files: SFX_Module, Installer_Config, 7z_Archive. \r
+Installer_Config is optional file. You can use the following command to create installer \r
+self-extract archive:\r
+\r
+copy /b 7zSD.sfx + config.txt + archive.7z archive.exe\r
+\r
+The smallest installation package size can be achivied, if installation files was \r
+uncompressed before including to 7z archive.\r
+\r
+-y switch for installer module (at runtime) specifies quiet mode for extracting.\r
+\r
+Installer Config file format\r
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~\r
+Config file contains commands for Installer. File begins from string \r
+;!@Install@!UTF-8! and ends with ;!@InstallEnd@!. File must be written \r
+in UTF-8 encoding. File contains string pairs: \r
+\r
+ID_String="Value"\r
+\r
+ID_String Description \r
+\r
+Title Title for messages \r
+BeginPrompt Begin Prompt message \r
+Progress Value can be "yes" or "no". Default value is "yes". \r
+RunProgram Command for executing. Default value is "setup.exe". \r
+ Substring %%T will be replaced with path to temporary \r
+ folder, where files were extracted \r
+Directory Directory prefix for "RunProgram". Default value is ".\\" \r
+ExecuteFile Name of file for executing \r
+ExecuteParameters Parameters for "ExecuteFile" \r
+\r
+\r
+You can omit any values.\r
+\r
+There are two ways to run program: RunProgram and ExecuteFile. \r
+Use RunProgram, if you want to run some program from .7z archive. \r
+Use ExecuteFile, if you want to open some document from .7z archive or \r
+if you want to execute some command from Windows.\r
+\r
+If you use RunProgram and if you specify empty directory prefix: Directory="", \r
+the system searches for the executable file in the following sequence:\r
+\r
+1. The directory from which the application (installer) loaded. \r
+2. The temporary folder, where files were extracted. \r
+3. The Windows system directory. \r
+\r
+\r
+Config file Examples\r
+~~~~~~~~~~~~~~~~~~~~\r
+\r
+;!@Install@!UTF-8!\r
+Title="7-Zip 4.00"\r
+BeginPrompt="Do you want to install the 7-Zip 4.00?"\r
+RunProgram="setup.exe"\r
+;!@InstallEnd@!\r
+\r
+\r
+\r
+;!@Install@!UTF-8!\r
+Title="7-Zip 4.00"\r
+BeginPrompt="Do you want to install the 7-Zip 4.00?"\r
+ExecuteFile="7zip.msi"\r
+;!@InstallEnd@!\r
+\r
+\r
+\r
+;!@Install@!UTF-8!\r
+Title="7-Zip 4.01 Update"\r
+BeginPrompt="Do you want to install the 7-Zip 4.01 Update?"\r
+ExecuteFile="msiexec.exe"\r
+ExecuteParameters="/i 7zip.msi REINSTALL=ALL REINSTALLMODE=vomus"\r
+;!@InstallEnd@!\r
+\r
--- /dev/null
+ GNU LESSER GENERAL PUBLIC LICENSE\r
+ Version 2.1, February 1999\r
+\r
+ Copyright (C) 1991, 1999 Free Software Foundation, Inc.\r
+ 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\r
+ Everyone is permitted to copy and distribute verbatim copies\r
+ of this license document, but changing it is not allowed.\r
+\r
+[This is the first released version of the Lesser GPL. It also counts\r
+ as the successor of the GNU Library Public License, version 2, hence\r
+ the version number 2.1.]\r
+\r
+ Preamble\r
+\r
+ The licenses for most software are designed to take away your\r
+freedom to share and change it. By contrast, the GNU General Public\r
+Licenses are intended to guarantee your freedom to share and change\r
+free software--to make sure the software is free for all its users.\r
+\r
+ This license, the Lesser General Public License, applies to some\r
+specially designated software packages--typically libraries--of the\r
+Free Software Foundation and other authors who decide to use it. You\r
+can use it too, but we suggest you first think carefully about whether\r
+this license or the ordinary General Public License is the better\r
+strategy to use in any particular case, based on the explanations below.\r
+\r
+ When we speak of free software, we are referring to freedom of use,\r
+not price. Our General Public Licenses are designed to make sure that\r
+you have the freedom to distribute copies of free software (and charge\r
+for this service if you wish); that you receive source code or can get\r
+it if you want it; that you can change the software and use pieces of\r
+it in new free programs; and that you are informed that you can do\r
+these things.\r
+\r
+ To protect your rights, we need to make restrictions that forbid\r
+distributors to deny you these rights or to ask you to surrender these\r
+rights. These restrictions translate to certain responsibilities for\r
+you if you distribute copies of the library or if you modify it.\r
+\r
+ For example, if you distribute copies of the library, whether gratis\r
+or for a fee, you must give the recipients all the rights that we gave\r
+you. You must make sure that they, too, receive or can get the source\r
+code. If you link other code with the library, you must provide\r
+complete object files to the recipients, so that they can relink them\r
+with the library after making changes to the library and recompiling\r
+it. And you must show them these terms so they know their rights.\r
+\r
+ We protect your rights with a two-step method: (1) we copyright the\r
+library, and (2) we offer you this license, which gives you legal\r
+permission to copy, distribute and/or modify the library.\r
+\r
+ To protect each distributor, we want to make it very clear that\r
+there is no warranty for the free library. Also, if the library is\r
+modified by someone else and passed on, the recipients should know\r
+that what they have is not the original version, so that the original\r
+author's reputation will not be affected by problems that might be\r
+introduced by others.\r
+\f\r
+ Finally, software patents pose a constant threat to the existence of\r
+any free program. We wish to make sure that a company cannot\r
+effectively restrict the users of a free program by obtaining a\r
+restrictive license from a patent holder. Therefore, we insist that\r
+any patent license obtained for a version of the library must be\r
+consistent with the full freedom of use specified in this license.\r
+\r
+ Most GNU software, including some libraries, is covered by the\r
+ordinary GNU General Public License. This license, the GNU Lesser\r
+General Public License, applies to certain designated libraries, and\r
+is quite different from the ordinary General Public License. We use\r
+this license for certain libraries in order to permit linking those\r
+libraries into non-free programs.\r
+\r
+ When a program is linked with a library, whether statically or using\r
+a shared library, the combination of the two is legally speaking a\r
+combined work, a derivative of the original library. The ordinary\r
+General Public License therefore permits such linking only if the\r
+entire combination fits its criteria of freedom. The Lesser General\r
+Public License permits more lax criteria for linking other code with\r
+the library.\r
+\r
+ We call this license the "Lesser" General Public License because it\r
+does Less to protect the user's freedom than the ordinary General\r
+Public License. It also provides other free software developers Less\r
+of an advantage over competing non-free programs. These disadvantages\r
+are the reason we use the ordinary General Public License for many\r
+libraries. However, the Lesser license provides advantages in certain\r
+special circumstances.\r
+\r
+ For example, on rare occasions, there may be a special need to\r
+encourage the widest possible use of a certain library, so that it becomes\r
+a de-facto standard. To achieve this, non-free programs must be\r
+allowed to use the library. A more frequent case is that a free\r
+library does the same job as widely used non-free libraries. In this\r
+case, there is little to gain by limiting the free library to free\r
+software only, so we use the Lesser General Public License.\r
+\r
+ In other cases, permission to use a particular library in non-free\r
+programs enables a greater number of people to use a large body of\r
+free software. For example, permission to use the GNU C Library in\r
+non-free programs enables many more people to use the whole GNU\r
+operating system, as well as its variant, the GNU/Linux operating\r
+system.\r
+\r
+ Although the Lesser General Public License is Less protective of the\r
+users' freedom, it does ensure that the user of a program that is\r
+linked with the Library has the freedom and the wherewithal to run\r
+that program using a modified version of the Library.\r
+\r
+ The precise terms and conditions for copying, distribution and\r
+modification follow. Pay close attention to the difference between a\r
+"work based on the library" and a "work that uses the library". The\r
+former contains code derived from the library, whereas the latter must\r
+be combined with the library in order to run.\r
+\f\r
+ GNU LESSER GENERAL PUBLIC LICENSE\r
+ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION\r
+\r
+ 0. This License Agreement applies to any software library or other\r
+program which contains a notice placed by the copyright holder or\r
+other authorized party saying it may be distributed under the terms of\r
+this Lesser General Public License (also called "this License").\r
+Each licensee is addressed as "you".\r
+\r
+ A "library" means a collection of software functions and/or data\r
+prepared so as to be conveniently linked with application programs\r
+(which use some of those functions and data) to form executables.\r
+\r
+ The "Library", below, refers to any such software library or work\r
+which has been distributed under these terms. A "work based on the\r
+Library" means either the Library or any derivative work under\r
+copyright law: that is to say, a work containing the Library or a\r
+portion of it, either verbatim or with modifications and/or translated\r
+straightforwardly into another language. (Hereinafter, translation is\r
+included without limitation in the term "modification".)\r
+\r
+ "Source code" for a work means the preferred form of the work for\r
+making modifications to it. For a library, complete source code means\r
+all the source code for all modules it contains, plus any associated\r
+interface definition files, plus the scripts used to control compilation\r
+and installation of the library.\r
+\r
+ Activities other than copying, distribution and modification are not\r
+covered by this License; they are outside its scope. The act of\r
+running a program using the Library is not restricted, and output from\r
+such a program is covered only if its contents constitute a work based\r
+on the Library (independent of the use of the Library in a tool for\r
+writing it). Whether that is true depends on what the Library does\r
+and what the program that uses the Library does.\r
+ \r
+ 1. You may copy and distribute verbatim copies of the Library's\r
+complete source code as you receive it, in any medium, provided that\r
+you conspicuously and appropriately publish on each copy an\r
+appropriate copyright notice and disclaimer of warranty; keep intact\r
+all the notices that refer to this License and to the absence of any\r
+warranty; and distribute a copy of this License along with the\r
+Library.\r
+\r
+ You may charge a fee for the physical act of transferring a copy,\r
+and you may at your option offer warranty protection in exchange for a\r
+fee.\r
+\f\r
+ 2. You may modify your copy or copies of the Library or any portion\r
+of it, thus forming a work based on the Library, and copy and\r
+distribute such modifications or work under the terms of Section 1\r
+above, provided that you also meet all of these conditions:\r
+\r
+ a) The modified work must itself be a software library.\r
+\r
+ b) You must cause the files modified to carry prominent notices\r
+ stating that you changed the files and the date of any change.\r
+\r
+ c) You must cause the whole of the work to be licensed at no\r
+ charge to all third parties under the terms of this License.\r
+\r
+ d) If a facility in the modified Library refers to a function or a\r
+ table of data to be supplied by an application program that uses\r
+ the facility, other than as an argument passed when the facility\r
+ is invoked, then you must make a good faith effort to ensure that,\r
+ in the event an application does not supply such function or\r
+ table, the facility still operates, and performs whatever part of\r
+ its purpose remains meaningful.\r
+\r
+ (For example, a function in a library to compute square roots has\r
+ a purpose that is entirely well-defined independent of the\r
+ application. Therefore, Subsection 2d requires that any\r
+ application-supplied function or table used by this function must\r
+ be optional: if the application does not supply it, the square\r
+ root function must still compute square roots.)\r
+\r
+These requirements apply to the modified work as a whole. If\r
+identifiable sections of that work are not derived from the Library,\r
+and can be reasonably considered independent and separate works in\r
+themselves, then this License, and its terms, do not apply to those\r
+sections when you distribute them as separate works. But when you\r
+distribute the same sections as part of a whole which is a work based\r
+on the Library, the distribution of the whole must be on the terms of\r
+this License, whose permissions for other licensees extend to the\r
+entire whole, and thus to each and every part regardless of who wrote\r
+it.\r
+\r
+Thus, it is not the intent of this section to claim rights or contest\r
+your rights to work written entirely by you; rather, the intent is to\r
+exercise the right to control the distribution of derivative or\r
+collective works based on the Library.\r
+\r
+In addition, mere aggregation of another work not based on the Library\r
+with the Library (or with a work based on the Library) on a volume of\r
+a storage or distribution medium does not bring the other work under\r
+the scope of this License.\r
+\r
+ 3. You may opt to apply the terms of the ordinary GNU General Public\r
+License instead of this License to a given copy of the Library. To do\r
+this, you must alter all the notices that refer to this License, so\r
+that they refer to the ordinary GNU General Public License, version 2,\r
+instead of to this License. (If a newer version than version 2 of the\r
+ordinary GNU General Public License has appeared, then you can specify\r
+that version instead if you wish.) Do not make any other change in\r
+these notices.\r
+\f\r
+ Once this change is made in a given copy, it is irreversible for\r
+that copy, so the ordinary GNU General Public License applies to all\r
+subsequent copies and derivative works made from that copy.\r
+\r
+ This option is useful when you wish to copy part of the code of\r
+the Library into a program that is not a library.\r
+\r
+ 4. You may copy and distribute the Library (or a portion or\r
+derivative of it, under Section 2) in object code or executable form\r
+under the terms of Sections 1 and 2 above provided that you accompany\r
+it with the complete corresponding machine-readable source code, which\r
+must be distributed under the terms of Sections 1 and 2 above on a\r
+medium customarily used for software interchange.\r
+\r
+ If distribution of object code is made by offering access to copy\r
+from a designated place, then offering equivalent access to copy the\r
+source code from the same place satisfies the requirement to\r
+distribute the source code, even though third parties are not\r
+compelled to copy the source along with the object code.\r
+\r
+ 5. A program that contains no derivative of any portion of the\r
+Library, but is designed to work with the Library by being compiled or\r
+linked with it, is called a "work that uses the Library". Such a\r
+work, in isolation, is not a derivative work of the Library, and\r
+therefore falls outside the scope of this License.\r
+\r
+ However, linking a "work that uses the Library" with the Library\r
+creates an executable that is a derivative of the Library (because it\r
+contains portions of the Library), rather than a "work that uses the\r
+library". The executable is therefore covered by this License.\r
+Section 6 states terms for distribution of such executables.\r
+\r
+ When a "work that uses the Library" uses material from a header file\r
+that is part of the Library, the object code for the work may be a\r
+derivative work of the Library even though the source code is not.\r
+Whether this is true is especially significant if the work can be\r
+linked without the Library, or if the work is itself a library. The\r
+threshold for this to be true is not precisely defined by law.\r
+\r
+ If such an object file uses only numerical parameters, data\r
+structure layouts and accessors, and small macros and small inline\r
+functions (ten lines or less in length), then the use of the object\r
+file is unrestricted, regardless of whether it is legally a derivative\r
+work. (Executables containing this object code plus portions of the\r
+Library will still fall under Section 6.)\r
+\r
+ Otherwise, if the work is a derivative of the Library, you may\r
+distribute the object code for the work under the terms of Section 6.\r
+Any executables containing that work also fall under Section 6,\r
+whether or not they are linked directly with the Library itself.\r
+\f\r
+ 6. As an exception to the Sections above, you may also combine or\r
+link a "work that uses the Library" with the Library to produce a\r
+work containing portions of the Library, and distribute that work\r
+under terms of your choice, provided that the terms permit\r
+modification of the work for the customer's own use and reverse\r
+engineering for debugging such modifications.\r
+\r
+ You must give prominent notice with each copy of the work that the\r
+Library is used in it and that the Library and its use are covered by\r
+this License. You must supply a copy of this License. If the work\r
+during execution displays copyright notices, you must include the\r
+copyright notice for the Library among them, as well as a reference\r
+directing the user to the copy of this License. Also, you must do one\r
+of these things:\r
+\r
+ a) Accompany the work with the complete corresponding\r
+ machine-readable source code for the Library including whatever\r
+ changes were used in the work (which must be distributed under\r
+ Sections 1 and 2 above); and, if the work is an executable linked\r
+ with the Library, with the complete machine-readable "work that\r
+ uses the Library", as object code and/or source code, so that the\r
+ user can modify the Library and then relink to produce a modified\r
+ executable containing the modified Library. (It is understood\r
+ that the user who changes the contents of definitions files in the\r
+ Library will not necessarily be able to recompile the application\r
+ to use the modified definitions.)\r
+\r
+ b) Use a suitable shared library mechanism for linking with the\r
+ Library. A suitable mechanism is one that (1) uses at run time a\r
+ copy of the library already present on the user's computer system,\r
+ rather than copying library functions into the executable, and (2)\r
+ will operate properly with a modified version of the library, if\r
+ the user installs one, as long as the modified version is\r
+ interface-compatible with the version that the work was made with.\r
+\r
+ c) Accompany the work with a written offer, valid for at\r
+ least three years, to give the same user the materials\r
+ specified in Subsection 6a, above, for a charge no more\r
+ than the cost of performing this distribution.\r
+\r
+ d) If distribution of the work is made by offering access to copy\r
+ from a designated place, offer equivalent access to copy the above\r
+ specified materials from the same place.\r
+\r
+ e) Verify that the user has already received a copy of these\r
+ materials or that you have already sent this user a copy.\r
+\r
+ For an executable, the required form of the "work that uses the\r
+Library" must include any data and utility programs needed for\r
+reproducing the executable from it. However, as a special exception,\r
+the materials to be distributed need not include anything that is\r
+normally distributed (in either source or binary form) with the major\r
+components (compiler, kernel, and so on) of the operating system on\r
+which the executable runs, unless that component itself accompanies\r
+the executable.\r
+\r
+ It may happen that this requirement contradicts the license\r
+restrictions of other proprietary libraries that do not normally\r
+accompany the operating system. Such a contradiction means you cannot\r
+use both them and the Library together in an executable that you\r
+distribute.\r
+\f\r
+ 7. You may place library facilities that are a work based on the\r
+Library side-by-side in a single library together with other library\r
+facilities not covered by this License, and distribute such a combined\r
+library, provided that the separate distribution of the work based on\r
+the Library and of the other library facilities is otherwise\r
+permitted, and provided that you do these two things:\r
+\r
+ a) Accompany the combined library with a copy of the same work\r
+ based on the Library, uncombined with any other library\r
+ facilities. This must be distributed under the terms of the\r
+ Sections above.\r
+\r
+ b) Give prominent notice with the combined library of the fact\r
+ that part of it is a work based on the Library, and explaining\r
+ where to find the accompanying uncombined form of the same work.\r
+\r
+ 8. You may not copy, modify, sublicense, link with, or distribute\r
+the Library except as expressly provided under this License. Any\r
+attempt otherwise to copy, modify, sublicense, link with, or\r
+distribute the Library is void, and will automatically terminate your\r
+rights under this License. However, parties who have received copies,\r
+or rights, from you under this License will not have their licenses\r
+terminated so long as such parties remain in full compliance.\r
+\r
+ 9. You are not required to accept this License, since you have not\r
+signed it. However, nothing else grants you permission to modify or\r
+distribute the Library or its derivative works. These actions are\r
+prohibited by law if you do not accept this License. Therefore, by\r
+modifying or distributing the Library (or any work based on the\r
+Library), you indicate your acceptance of this License to do so, and\r
+all its terms and conditions for copying, distributing or modifying\r
+the Library or works based on it.\r
+\r
+ 10. Each time you redistribute the Library (or any work based on the\r
+Library), the recipient automatically receives a license from the\r
+original licensor to copy, distribute, link with or modify the Library\r
+subject to these terms and conditions. You may not impose any further\r
+restrictions on the recipients' exercise of the rights granted herein.\r
+You are not responsible for enforcing compliance by third parties with\r
+this License.\r
+\f\r
+ 11. If, as a consequence of a court judgment or allegation of patent\r
+infringement or for any other reason (not limited to patent issues),\r
+conditions are imposed on you (whether by court order, agreement or\r
+otherwise) that contradict the conditions of this License, they do not\r
+excuse you from the conditions of this License. If you cannot\r
+distribute so as to satisfy simultaneously your obligations under this\r
+License and any other pertinent obligations, then as a consequence you\r
+may not distribute the Library at all. For example, if a patent\r
+license would not permit royalty-free redistribution of the Library by\r
+all those who receive copies directly or indirectly through you, then\r
+the only way you could satisfy both it and this License would be to\r
+refrain entirely from distribution of the Library.\r
+\r
+If any portion of this section is held invalid or unenforceable under any\r
+particular circumstance, the balance of the section is intended to apply,\r
+and the section as a whole is intended to apply in other circumstances.\r
+\r
+It is not the purpose of this section to induce you to infringe any\r
+patents or other property right claims or to contest validity of any\r
+such claims; this section has the sole purpose of protecting the\r
+integrity of the free software distribution system which is\r
+implemented by public license practices. Many people have made\r
+generous contributions to the wide range of software distributed\r
+through that system in reliance on consistent application of that\r
+system; it is up to the author/donor to decide if he or she is willing\r
+to distribute software through any other system and a licensee cannot\r
+impose that choice.\r
+\r
+This section is intended to make thoroughly clear what is believed to\r
+be a consequence of the rest of this License.\r
+\r
+ 12. If the distribution and/or use of the Library is restricted in\r
+certain countries either by patents or by copyrighted interfaces, the\r
+original copyright holder who places the Library under this License may add\r
+an explicit geographical distribution limitation excluding those countries,\r
+so that distribution is permitted only in or among countries not thus\r
+excluded. In such case, this License incorporates the limitation as if\r
+written in the body of this License.\r
+\r
+ 13. The Free Software Foundation may publish revised and/or new\r
+versions of the Lesser General Public License from time to time.\r
+Such new versions will be similar in spirit to the present version,\r
+but may differ in detail to address new problems or concerns.\r
+\r
+Each version is given a distinguishing version number. If the Library\r
+specifies a version number of this License which applies to it and\r
+"any later version", you have the option of following the terms and\r
+conditions either of that version or of any later version published by\r
+the Free Software Foundation. If the Library does not specify a\r
+license version number, you may choose any version ever published by\r
+the Free Software Foundation.\r
+\f\r
+ 14. If you wish to incorporate parts of the Library into other free\r
+programs whose distribution conditions are incompatible with these,\r
+write to the author to ask for permission. For software which is\r
+copyrighted by the Free Software Foundation, write to the Free\r
+Software Foundation; we sometimes make exceptions for this. Our\r
+decision will be guided by the two goals of preserving the free status\r
+of all derivatives of our free software and of promoting the sharing\r
+and reuse of software generally.\r
+\r
+ NO WARRANTY\r
+\r
+ 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO\r
+WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.\r
+EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR\r
+OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY\r
+KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE\r
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\r
+PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE\r
+LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME\r
+THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.\r
+\r
+ 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN\r
+WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY\r
+AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU\r
+FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR\r
+CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE\r
+LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING\r
+RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A\r
+FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF\r
+SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH\r
+DAMAGES.\r
+\r
+ END OF TERMS AND CONDITIONS\r
+\f\r
+ How to Apply These Terms to Your New Libraries\r
+\r
+ If you develop a new library, and you want it to be of the greatest\r
+possible use to the public, we recommend making it free software that\r
+everyone can redistribute and change. You can do so by permitting\r
+redistribution under these terms (or, alternatively, under the terms of the\r
+ordinary General Public License).\r
+\r
+ To apply these terms, attach the following notices to the library. It is\r
+safest to attach them to the start of each source file to most effectively\r
+convey the exclusion of warranty; and each file should have at least the\r
+"copyright" line and a pointer to where the full notice is found.\r
+\r
+ <one line to give the library's name and a brief idea of what it does.>\r
+ Copyright (C) <year> <name of author>\r
+\r
+ This library is free software; you can redistribute it and/or\r
+ modify it under the terms of the GNU Lesser General Public\r
+ License as published by the Free Software Foundation; either\r
+ version 2.1 of the License, or (at your option) any later version.\r
+\r
+ This library is distributed in the hope that it will be useful,\r
+ but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
+ Lesser General Public License for more details.\r
+\r
+ You should have received a copy of the GNU Lesser General Public\r
+ License along with this library; if not, write to the Free Software\r
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\r
+\r
+Also add information on how to contact you by electronic and paper mail.\r
+\r
+You should also get your employer (if you work as a programmer) or your\r
+school, if any, to sign a "copyright disclaimer" for the library, if\r
+necessary. Here is a sample; alter the names:\r
+\r
+ Yoyodyne, Inc., hereby disclaims all copyright interest in the\r
+ library `Frob' (a library for tweaking knobs) written by James Random Hacker.\r
+\r
+ <signature of Ty Coon>, 1 April 1990\r
+ Ty Coon, President of Vice\r
+\r
+That's all there is to it!\r
+\r
+\r
--- /dev/null
+7-Zip Extra history\r
+-------------------\r
+\r
+4.65 2009-02-03\r
+------------------------------\r
+ - Some bugs were fixed.\r
+\r
+\r
+4.38 beta 2006-04-13\r
+------------------------------\r
+ - SFX for installers now supports new properties in config file:\r
+ Progress, Directory, ExecuteFile, ExecuteParameters.\r
+\r
+\r
+4.34 beta 2006-02-27\r
+------------------------------\r
+ - ISetProperties::SetProperties:\r
+ it's possible to specify desirable number of CPU threads: \r
+ PROPVARIANT: name=L"mt", vt = VT_UI4, ulVal = NumberOfThreads\r
+ If "mt" is not defined, 7za.dll will check number of processors in system to set \r
+ number of desirable threads. \r
+ Now 7za.dll can use:\r
+ 2 threads for LZMA compressing\r
+ N threads for BZip2 compressing\r
+ 4 threads for BZip2 decompressing\r
+ Other codecs use only one thread. \r
+ Note: 7za.dll can use additional "small" threads with low CPU load.\r
+ - It's possible to call ISetProperties::SetProperties to specify "mt" property for decoder.\r
+\r
+\r
+4.33 beta 2006-02-05\r
+------------------------------\r
+ - Compressing speed and Memory requirements were increased.\r
+ Default dictionary size was increased: Fastest: 64 KB, Fast: 1 MB, \r
+ Normal: 4 MB, Max: 16 MB, Ultra: 64 MB.\r
+ - 7z/LZMA now can use only these match finders: HC4, BT2, BT3, BT4\r
+\r
+\r
+4.27 2005-09-21\r
+------------------------------\r
+ - Some GUIDs/interfaces were changed.\r
+ IStream.h:\r
+ ISequentialInStream::Read now works as old ReadPart\r
+ ISequentialOutStream::Write now works as old WritePart\r
--- /dev/null
+ 7-Zip Command line version\r
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~\r
+ License for use and distribution\r
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\r
+\r
+ 7-Zip Copyright (C) 1999-2009 Igor Pavlov.\r
+\r
+ 7za.exe is distributed under the GNU LGPL license\r
+\r
+ Notes: \r
+ You can use 7-Zip on any computer, including a computer in a commercial \r
+ organization. You don't need to register or pay for 7-Zip.\r
+\r
+\r
+ GNU LGPL information\r
+ --------------------\r
+\r
+ This library is free software; you can redistribute it and/or\r
+ modify it under the terms of the GNU Lesser General Public\r
+ License as published by the Free Software Foundation; either\r
+ version 2.1 of the License, or (at your option) any later version.\r
+\r
+ This library is distributed in the hope that it will be useful,\r
+ but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
+ Lesser General Public License for more details.\r
+\r
+ You should have received a copy of the GNU Lesser General Public\r
+ License along with this library; if not, write to the Free Software\r
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\r
--- /dev/null
+7-Zip Command line version 4.65\r
+-------------------------------\r
+\r
+7-Zip is a file archiver with high compression ratio.\r
+7za.exe is a standalone command line version of 7-Zip.\r
+\r
+7-Zip Copyright (C) 1999-2009 Igor Pavlov.\r
+\r
+Features of 7za.exe: \r
+ - High compression ratio in new 7z format\r
+ - Supported formats:\r
+ - Packing / unpacking: 7z, ZIP, GZIP, BZIP2 and TAR \r
+ - Unpacking only: Z\r
+ - Highest compression ratio for ZIP and GZIP formats.\r
+ - Fast compression and decompression\r
+ - Strong AES-256 encryption in 7z and ZIP formats.\r
+\r
+7za.exe is a free software distributed under the GNU LGPL.\r
+Read license.txt for more information.\r
+\r
+Source code of 7za.exe and 7-Zip can be found at\r
+http://www.7-zip.org/\r
+\r
+7za.exe can work in Windows 95/98/ME/NT/2000/XP/2003/Vista.\r
+\r
+There is also port of 7za.exe for POSIX systems like Unix (Linux, Solaris, OpenBSD, \r
+FreeBSD, Cygwin, AIX, ...), MacOS X and BeOS:\r
+\r
+http://p7zip.sourceforge.net/\r
+\r
+\r
+ This distributive packet contains the following files:\r
+\r
+ 7za.exe - 7-Zip standalone command line version.\r
+ readme.txt - This file.\r
+ copying.txt - GNU LGPL license.\r
+ license.txt - License information.\r
+ 7-zip.chm - User's Manual in HTML Help format.\r
+\r
+\r
+---\r
+End of document\r
--- /dev/null
+<?xml version="1.0" encoding="iso-8859-1" standalone="yes" ?>
+
+<!-- The English langpack -->
+
+<langpack>
+
+ <!-- NonBlankTargetPanel strings -->
+ <str id="NonBlankTargetPanel.noBlanks">
+ Sorry, the target directory cannot currently contain
+ spaces due to limitations imposed by the MinGW
+ C compiler used by OpenModelica.
+
+ For more information on the issue, see
+ http://www.mingw.org/wiki/Getting_Started.
+ </str>
+
+ <!-- SummaryPanel strings -->
+ <str id="NonBlankTargetPanel.summaryCaption" txt="Installation Path"/>
+
+</langpack>
--- /dev/null
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<!-- saved from url=(0041)http://www.eclipse.org/legal/epl-v10.html -->
+<HTML xmlns="http://www.w3.org/1999/xhtml"><HEAD><META http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
+
+<TITLE>Eclipse Public License - Version 1.0</TITLE>
+<STYLE type="text/css">
+ body {
+ size: 8.5in 11.0in;
+ margin: 0.25in 0.5in 0.25in 0.5in;
+ tab-interval: 0.5in;
+ }
+ p {
+ margin-left: auto;
+ margin-top: 0.5em;
+ margin-bottom: 0.5em;
+ }
+ p.list {
+ margin-left: 0.5in;
+ margin-top: 0.05em;
+ margin-bottom: 0.05em;
+ }
+ </STYLE>
+
+</HEAD><BODY lang="EN-US">
+
+<H2>Licenses</H2>
+
+<p><em>Simantics System Dynamics</em> product consists of two main components: <em>Simantics</em> and <em>Open Modelica</em>.</p>
+<p>Simantics is distributed under Eclipse Public License (EPL), see below.</p>
+<p>Open Modelica is distributed under Open Source Modelica Consortium Public License (OSMC-PL), see http://www.openmodelica.org/index.php/home/license/140.</p>
+<p>You are not allowed to redistribute OpenModelica integrated with Simantics, as in the System Dynamics Tool, without a membership in OSMC or without a separate contract with a level 2 member of OSMC.</p>
+
+<hr />
+
+<H2>Eclipse Public License - v 1.0</H2>
+
+<P>THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS ECLIPSE
+PUBLIC LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR
+DISTRIBUTION OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS
+AGREEMENT.</P>
+
+<P><B>1. DEFINITIONS</B></P>
+
+<P>"Contribution" means:</P>
+
+<P class="list">a) in the case of the initial Contributor, the initial
+code and documentation distributed under this Agreement, and</P>
+<P class="list">b) in the case of each subsequent Contributor:</P>
+<P class="list">i) changes to the Program, and</P>
+<P class="list">ii) additions to the Program;</P>
+<P class="list">where such changes and/or additions to the Program
+originate from and are distributed by that particular Contributor. A
+Contribution 'originates' from a Contributor if it was added to the
+Program by such Contributor itself or anyone acting on such
+Contributor's behalf. Contributions do not include additions to the
+Program which: (i) are separate modules of software distributed in
+conjunction with the Program under their own license agreement, and (ii)
+are not derivative works of the Program.</P>
+
+<P>"Contributor" means any person or entity that distributes
+the Program.</P>
+
+<P>"Licensed Patents" mean patent claims licensable by a
+Contributor which are necessarily infringed by the use or sale of its
+Contribution alone or when combined with the Program.</P>
+
+<P>"Program" means the Contributions distributed in accordance
+with this Agreement.</P>
+
+<P>"Recipient" means anyone who receives the Program under
+this Agreement, including all Contributors.</P>
+
+<P><B>2. GRANT OF RIGHTS</B></P>
+
+<P class="list">a) Subject to the terms of this Agreement, each
+Contributor hereby grants Recipient a non-exclusive, worldwide,
+royalty-free copyright license to reproduce, prepare derivative works
+of, publicly display, publicly perform, distribute and sublicense the
+Contribution of such Contributor, if any, and such derivative works, in
+source code and object code form.</P>
+
+<P class="list">b) Subject to the terms of this Agreement, each
+Contributor hereby grants Recipient a non-exclusive, worldwide,
+royalty-free patent license under Licensed Patents to make, use, sell,
+offer to sell, import and otherwise transfer the Contribution of such
+Contributor, if any, in source code and object code form. This patent
+license shall apply to the combination of the Contribution and the
+Program if, at the time the Contribution is added by the Contributor,
+such addition of the Contribution causes such combination to be covered
+by the Licensed Patents. The patent license shall not apply to any other
+combinations which include the Contribution. No hardware per se is
+licensed hereunder.</P>
+
+<P class="list">c) Recipient understands that although each Contributor
+grants the licenses to its Contributions set forth herein, no assurances
+are provided by any Contributor that the Program does not infringe the
+patent or other intellectual property rights of any other entity. Each
+Contributor disclaims any liability to Recipient for claims brought by
+any other entity based on infringement of intellectual property rights
+or otherwise. As a condition to exercising the rights and licenses
+granted hereunder, each Recipient hereby assumes sole responsibility to
+secure any other intellectual property rights needed, if any. For
+example, if a third party patent license is required to allow Recipient
+to distribute the Program, it is Recipient's responsibility to acquire
+that license before distributing the Program.</P>
+
+<P class="list">d) Each Contributor represents that to its knowledge it
+has sufficient copyright rights in its Contribution, if any, to grant
+the copyright license set forth in this Agreement.</P>
+
+<P><B>3. REQUIREMENTS</B></P>
+
+<P>A Contributor may choose to distribute the Program in object code
+form under its own license agreement, provided that:</P>
+
+<P class="list">a) it complies with the terms and conditions of this
+Agreement; and</P>
+
+<P class="list">b) its license agreement:</P>
+
+<P class="list">i) effectively disclaims on behalf of all Contributors
+all warranties and conditions, express and implied, including warranties
+or conditions of title and non-infringement, and implied warranties or
+conditions of merchantability and fitness for a particular purpose;</P>
+
+<P class="list">ii) effectively excludes on behalf of all Contributors
+all liability for damages, including direct, indirect, special,
+incidental and consequential damages, such as lost profits;</P>
+
+<P class="list">iii) states that any provisions which differ from this
+Agreement are offered by that Contributor alone and not by any other
+party; and</P>
+
+<P class="list">iv) states that source code for the Program is available
+from such Contributor, and informs licensees how to obtain it in a
+reasonable manner on or through a medium customarily used for software
+exchange.</P>
+
+<P>When the Program is made available in source code form:</P>
+
+<P class="list">a) it must be made available under this Agreement; and</P>
+
+<P class="list">b) a copy of this Agreement must be included with each
+copy of the Program.</P>
+
+<P>Contributors may not remove or alter any copyright notices contained
+within the Program.</P>
+
+<P>Each Contributor must identify itself as the originator of its
+Contribution, if any, in a manner that reasonably allows subsequent
+Recipients to identify the originator of the Contribution.</P>
+
+<P><B>4. COMMERCIAL DISTRIBUTION</B></P>
+
+<P>Commercial distributors of software may accept certain
+responsibilities with respect to end users, business partners and the
+like. While this license is intended to facilitate the commercial use of
+the Program, the Contributor who includes the Program in a commercial
+product offering should do so in a manner which does not create
+potential liability for other Contributors. Therefore, if a Contributor
+includes the Program in a commercial product offering, such Contributor
+("Commercial Contributor") hereby agrees to defend and
+indemnify every other Contributor ("Indemnified Contributor")
+against any losses, damages and costs (collectively "Losses")
+arising from claims, lawsuits and other legal actions brought by a third
+party against the Indemnified Contributor to the extent caused by the
+acts or omissions of such Commercial Contributor in connection with its
+distribution of the Program in a commercial product offering. The
+obligations in this section do not apply to any claims or Losses
+relating to any actual or alleged intellectual property infringement. In
+order to qualify, an Indemnified Contributor must: a) promptly notify
+the Commercial Contributor in writing of such claim, and b) allow the
+Commercial Contributor to control, and cooperate with the Commercial
+Contributor in, the defense and any related settlement negotiations. The
+Indemnified Contributor may participate in any such claim at its own
+expense.</P>
+
+<P>For example, a Contributor might include the Program in a commercial
+product offering, Product X. That Contributor is then a Commercial
+Contributor. If that Commercial Contributor then makes performance
+claims, or offers warranties related to Product X, those performance
+claims and warranties are such Commercial Contributor's responsibility
+alone. Under this section, the Commercial Contributor would have to
+defend claims against the other Contributors related to those
+performance claims and warranties, and if a court requires any other
+Contributor to pay any damages as a result, the Commercial Contributor
+must pay those damages.</P>
+
+<P><B>5. NO WARRANTY</B></P>
+
+<P>EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS
+PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS
+OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION,
+ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY
+OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is solely
+responsible for determining the appropriateness of using and
+distributing the Program and assumes all risks associated with its
+exercise of rights under this Agreement , including but not limited to
+the risks and costs of program errors, compliance with applicable laws,
+damage to or loss of data, programs or equipment, and unavailability or
+interruption of operations.</P>
+
+<P><B>6. DISCLAIMER OF LIABILITY</B></P>
+
+<P>EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT
+NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT,
+INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING
+WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF
+LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OR
+DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED
+HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.</P>
+
+<P><B>7. GENERAL</B></P>
+
+<P>If any provision of this Agreement is invalid or unenforceable under
+applicable law, it shall not affect the validity or enforceability of
+the remainder of the terms of this Agreement, and without further action
+by the parties hereto, such provision shall be reformed to the minimum
+extent necessary to make such provision valid and enforceable.</P>
+
+<P>If Recipient institutes patent litigation against any entity
+(including a cross-claim or counterclaim in a lawsuit) alleging that the
+Program itself (excluding combinations of the Program with other
+software or hardware) infringes such Recipient's patent(s), then such
+Recipient's rights granted under Section 2(b) shall terminate as of the
+date such litigation is filed.</P>
+
+<P>All Recipient's rights under this Agreement shall terminate if it
+fails to comply with any of the material terms or conditions of this
+Agreement and does not cure such failure in a reasonable period of time
+after becoming aware of such noncompliance. If all Recipient's rights
+under this Agreement terminate, Recipient agrees to cease use and
+distribution of the Program as soon as reasonably practicable. However,
+Recipient's obligations under this Agreement and any licenses granted by
+Recipient relating to the Program shall continue and survive.</P>
+
+<P>Everyone is permitted to copy and distribute copies of this
+Agreement, but in order to avoid inconsistency the Agreement is
+copyrighted and may only be modified in the following manner. The
+Agreement Steward reserves the right to publish new versions (including
+revisions) of this Agreement from time to time. No one other than the
+Agreement Steward has the right to modify this Agreement. The Eclipse
+Foundation is the initial Agreement Steward. The Eclipse Foundation may
+assign the responsibility to serve as the Agreement Steward to a
+suitable separate entity. Each new version of the Agreement will be
+given a distinguishing version number. The Program (including
+Contributions) may always be distributed subject to the version of the
+Agreement under which it was received. In addition, after a new version
+of the Agreement is published, Contributor may elect to distribute the
+Program (including its Contributions) under the new version. Except as
+expressly stated in Sections 2(a) and 2(b) above, Recipient receives no
+rights or licenses to the intellectual property of any Contributor under
+this Agreement, whether expressly, by implication, estoppel or
+otherwise. All rights in the Program not expressly granted under this
+Agreement are reserved.</P>
+
+<P>This Agreement is governed by the laws of the State of New York and
+the intellectual property laws of the United States of America. No party
+to this Agreement will bring a legal action under this Agreement more
+than one year after the cause of action arose. Each party waives its
+rights to a jury trial in any resulting litigation.</P>
+
+
+
+</BODY></HTML>
\ No newline at end of file
--- /dev/null
+${USER_HOME}/Simantics/Sysdyn/$APP_VER
\ No newline at end of file
--- /dev/null
+C:\Simantics\Sysdyn\$APP_VER
\ No newline at end of file
--- /dev/null
+izpack.home=/usr/local/izpack\r
+izpack.src=${izpack.home}/src\r
+izpack.compiler=${izpack.home}/bin/compile\r
+izpack2exe.home=${izpack.home}/utils/wrappers/izpack2exe\r
+izpack2exe=${izpack2exe.home}/izpack2exe.py\r
+sevenzip.executable=/usr/bin/7za\r
+upx.executable=/usr/bin/upx
\ No newline at end of file
--- /dev/null
+izpack.home=C:/Program Files/IzPack\r
+izpack.src=${izpack.home}/src\r
+izpack.compiler=${izpack.home}/bin/compile.bat\r
+izpack2exe.home=${izpack.home}/utils/wrappers/izpack2exe\r
+izpack2exe=${izpack2exe.home}/izpack2exe.exe\r
+sevenzip.executable=${basedir}\\7za\\7za.exe\r
+upx.executable=${basedir}\\7za\\upx.exe
\ No newline at end of file
--- /dev/null
+<project name="Installer" default="compile" basedir=".">
+
+ <property name="installer.file" value="installer.xml"/>
+
+ <condition property="is.windows">
+ <os family="windows"/>
+ </condition>
+ <condition property="is.unix">
+ <os family="unix"/>
+ </condition>
+
+ <target name="properties.windows" if="is.windows">
+ <property file="build.properties.windows"/>
+ </target>
+ <target name="properties.unix" if="is.unix">
+ <property file="build.properties.unix"/>
+ </target>
+
+ <target name="compile" depends="properties.unix,properties.windows">
+ <exec executable="${izpack.compiler}">
+ <arg value="${installer.file}"/>
+ <arg value="-o"/>
+ <arg value="${output}"/>
+ </exec>
+ <!--
+ <exec executable="${izpack2exe}" >
+ <arg value="- -file="${output}""/>
+ <arg value="- -output="${output}.exe""/>
+ <arg value="- -with-7z="${sevenzip.executable}""/>
+ <arg value="- -with-upx="${upx.executable}""/>
+ </exec>
+ -->
+ </target>
+
+</project>
--- /dev/null
+\r
+/*\r
+ * Created on 29.06.2005\r
+ *\r
+ * TODO To change the template for this generated file go to\r
+ * Window - Preferences - Java - Code Style - Code Templates\r
+ */\r
+package com.izforge.izpack.panels;\r
+\r
+import com.izforge.izpack.installer.InstallData;\r
+import com.izforge.izpack.installer.InstallerFrame;\r
+\r
+\r
+/**\r
+ * @author fabrice mirabile\r
+ */\r
+public class NonBlankTargetPanel extends TargetPanel\r
+{\r
+ private static final long serialVersionUID = 3248705610571943817L;\r
+\r
+ public NonBlankTargetPanel(InstallerFrame parent, InstallData idata)\r
+ {\r
+ super(parent, idata);\r
+ }\r
+\r
+ public boolean isValidated()\r
+ {\r
+ String chosenPath = pathSelectionPanel.getPath();\r
+ if(chosenPath == null || chosenPath.length() < 1 )\r
+ return( false );\r
+ if( chosenPath.indexOf(" ") >= 0 )\r
+ {\r
+ emitError(parent.langpack.getString("installer.error"),\r
+ parent.langpack.getString("NonBlankTargetPanel.noBlanks"));\r
+ return( false );\r
+ }\r
+ return(super.isValidated() );\r
+ }\r
+\r
+ public void panelActivate()\r
+ {\r
+ super.panelActivate();\r
+ String chosenPath = pathSelectionPanel.getPath();\r
+ if(chosenPath == null || chosenPath.length() < 1 )\r
+ return;\r
+ if( chosenPath.indexOf(" ") >= 0 )\r
+ pathSelectionPanel.setPath("");\r
+ }\r
+\r
+\r
+}
\ No newline at end of file
--- /dev/null
+<!-- INSTRUCTIONS TAKEN FROM: http://izpack.org/community/berlios-lists-archives/izpack-users/2006-March/000409.html -->
+<project name="Install Custom IzPack Panels" default="install" basedir="..">
+
+ <condition property="is.windows">
+ <os family="windows"/>
+ </condition>
+ <condition property="is.unix">
+ <os family="unix"/>
+ </condition>
+
+ <target name="properties.windows" if="is.windows">
+ <property file="build.properties.windows"/>
+ </target>
+ <target name="properties.unix" if="is.unix">
+ <property file="build.properties.unix"/>
+ </target>
+
+ <target name="install" depends="properties.windows,properties.unix">
+ <copy file="custom/izpack-src-build.xml" toFile="${izpack.src}/build.xml"/>
+ <copy file="custom/NonBlankTargetPanel.java" toDir="${izpack.src}/lib/com/izforge/izpack/panels"/>
+ <ant antfile="${izpack.src}/build.xml" target="all" dir="${izpack.home}" />
+ </target>
+
+</project>
--- /dev/null
+<project name="IzPack" default="all" basedir="..">
+ <!--
+ $Id$
+
+ build.xml first written by Pierre Dittgen (pierre.dittgen@criltelecom.com)
+ This file is intended to be used with ant (http://jakarta.apache.org/ant),
+ a java/xml makefile utility.
+
+ 14.8.2001: (by Pierre Dittgen)
+ Creation of the build.xml. It only compile all the src files.
+
+ 16.8.2001: (by Pierre Dittgen)
+ Added creation of compiler.jar, installer.jar and compilation of the
+ panels.
+
+ 28.8.2001: (by Pierre Dittgen)
+ Added compile.uninstaller and build.uninstaller targets to create the
+ uninstaller.jar jar file.
+
+ 02.9.2001: (by Julien Ponge)
+ Improved compilation options (optimizations, deprecation warnings) and
+ changed the build dir to src/build. Fixed the compiling/building of the
+ uninstaller.
+
+ 12.9.2001: (by Julien Ponge)
+ Added creation/compilation of the frontend and its associated jar file.
+
+ 22.9.2001: (by Julien Ponge)
+ Small fix in the all target that caused an error if the build dir was
+ not yet created.
+
+ 14.10.2001: (by Julien Ponge)
+ Added the XPanel compilation call.
+
+ 12.12.2001: (by Julien Ponge)
+ Removed the 'clean' dependency for the 'all' target.
+
+ 12.02.2002: (by Julien Ponge)
+ Moved the 'build' directory out of the src/ scope (usefull for my CVS
+ files moving scripts).
+ Added a markup to specify IBM Jikes as the compiler (just comment out to
+ use another one).
+
+ 21.02.2002: (by Paul Wilkinson)
+ Added tasks to compiler.compiler and build.compiler to build ant task class.
+
+ 02.03.2002: (by Julien Ponge)
+ Modified the building of the panels so that the inner classes can be copied
+ too.
+
+ 18.04.2002: (by Julien Ponge)
+ Added the new com.izforge.izpack.util & com.izforge.izpack.util.os
+ packages to the installer.jar build process.
+
+ 19.04.2002: (by Olexij Tkatchenko & Julien Ponge)
+ Added "dist" target for bootstrapped IzPack package creation.
+
+ 01.06.2002: (by Julien Ponge)
+ Changed the panels building process in order to enable the ShortcutData
+ classes to be move in the same directory as the ShortcutPanel classes.
+
+ 15.06.2002: (by Julien Ponge)
+ Added the ant-generated manifests in the clean target scope.
+
+ 03.07.2002: (by Julien Ponge)
+ Added a target to generate some javadoc.
+
+ 12.01.2003: (by Julien Ponge)
+ Separated the installer generation from the dist target so that it is
+ much cleaner.
+
+ 13.01.2003: (by Julien Ponge)
+ Enhanced the clean target.
+
+ 27.02.2003: (by Julien Ponge)
+ Fixed the UserInputPanel building process to include all the required
+ files.
+
+ 30.04.2003: (by Jonathan Halliday)
+ Change to panel compilation target, for panel automation
+ (silent install) support.
+
+ 05.07.2003: (by Julien Ponge)
+ Added a target to fix the files encoding and cr/lf (fix.crlf).
+
+ 10.09.2003: (by Julien Ponge)
+ Reformatting, 4 spaces tabs, got rid of residual hard tabs.
+
+ 19.09.2003: (by Julien Ponge)
+ Added a run.installer target to test an installer.
+
+ 06.12.2003: (by Julien Ponge)
+ Removed the frontend-related sections.
+
+ 16.12.2003: (by Julien Ponge)
+ Added the SudoPanel building call.
+
+ 18.02.2004: (by Julien Ponge)
+ New installer naming scheme (IzPack-install-{version}.jar).
+
+ 29.05.2004: (by Julien Ponge)
+ New SimpleFinishPanel.
+
+ 30.07.2004: (by Klaus Bartz)
+ Simple CustomAction stuff added.
+
+ 09.09.2004: (by Klaus Bartz)
+ Clean up of CustomActions added.
+ New uninstaller-ext.jar with native helper stuff for native libs
+ in uninstaller.
+
+ 14.10.2004: (by Klaus Bartz)
+ New izevent.jar with the base classes of the custom action stuff
+ to support creation of custom action jars without IzPack source tree
+
+ 25.10.2004: (by Klaus Bartz)
+ "Standard" CustomActions AntActionInstallerListener and
+ AntActionUninstallerListener added
+
+ 03.05.2005: (by Klaus Bartz)
+ Target generated.installer-reg added:
+ Creates an installer for IzPack with registry support
+
+ 09.05.2005: (by Marc Eppelman)
+ Target dist+run added:
+ convenient :) makes a complete dist an installer and run them
+
+ 11.05.2005: (by Fabrice Mirabile)
+ Target cleandistreg added:
+ Clean, Regenerate installer and installer with reg support. Avoid use of bad jars during installation.
+
+ 18.07.2005: (by Julien Ponge)
+ Enforce source / target compatibility, now 1.4 / 1.4.
+
+ 02.09.2005: (by Klaus Bartz)
+ Unicode support of ShellLink.
+
+ 09.09.2005: (Marc.Eppelmann)
+ Added start.sh to the shipped files in bin-folder.
+
+ 10.01.2006: (by Fabrice Mirabile)
+ Added the splashscreen to the cleandistreg target
+
+ 06.04.2006: (Marc Eppelmann)
+ Inserted the fix.crlf target in the depends-list of target "all" to prevent encoding problems.
+
+ 26.06.2006: (Marc Eppelmann)
+ Extracted / Reordered some dist related targets to prevent double copy actions.
+ Also fixed the fix.crlf basedir
+
+ 27.08.2006: (Marc Eppelmann)
+ Embedd ShortcutPanel*.java
+
+ 14.09.2006: (Marc Eppelmann)
+ Added target src.tar.gz and clean.src.tar.gz
+
+ 19.10.2006: (Fabrice Mirabile & Hal Vaughan)
+ Added DataCheckPanel
+
+ 10.10.2006: (Fabrice Mirabile)
+ Fixed target src.tar.gz and clean.src.tar.gz
+
+ 11.02.2007: (Ari Voutilainen)
+ Added 'preservelastmodified="true"' to all 'copy todir' commands to keep original file date
+ and time. This will effect in directory _dist. This won't effect to compiled files and
+ other files which are manipulated during the process.
+
+ 08.11.2007: (Julien Ponge)
+ Call the new docutils-based documentation build system.
+
+
+ Mini-HowTo:
+
+ To compile and package the compiler.jar jar file, type:
+ ant build.compiler
+
+ To compile and package the installer.jar jar file, type:
+ ant build.installer
+
+ To compile and package the uninstaller.jar jar file, type:
+ ant build.uninstaller
+
+ To compile the panels and put them in the bin/panels directory, type:
+ ant build.panels
+
+ To compile and package the frontend.jar jar file, type:
+ ant build.frontend
+
+ To make all, type:
+ ant all
+ or
+ ant
+ (this is the default target)
+
+ To compile and create IzPack distribution package type:
+ ant dist
+
+ To delete the classes directory after packaging, just type:
+ ant clean
+ -->
+
+ <!-- Compiler to use put your own here (jikes, modern, gcj, ...) -->
+ <!--<property name="build.compiler" value="jikes" />-->
+
+ <!-- Define directories -->
+ <property name="cwd" value="${basedir}"/>
+
+ <property file="src/ant.properties"/>
+ <property name="ver" value="4.3"/>
+ <property name="rel" value="3"/>
+ <property name="build.number" value="${ver}.${rel}"/>
+
+ <property name="src.dir" value="${basedir}/src/lib"/>
+ <property name="img.dir" value="${basedir}/src/img"/>
+ <property name="bin.dir" value="${basedir}/bin"/>
+ <property name="doc.dir" value="${basedir}/doc"/>
+
+ <property name="langpacks.subdir" value="langpacks"/>
+ <property name="langpacks.dir" value="${basedir}/bin/${langpacks.subdir}"/>
+
+ <property name="build.subdir" value="_build"/>
+ <property name="build.dir" value="${basedir}/${build.subdir}"/>
+
+ <property name="dist.subdir" value="_dist"/>
+ <property name="dist.dir" value="${basedir}/${dist.subdir}"/>
+ <property name="dist-files.dir" value="${basedir}/src/dist-files"/>
+
+ <!-- Define Main-Classes -->
+ <property name="compiler.class" value="com.izforge.izpack.compiler.Compiler"/>
+ <property name="installer.class" value="com.izforge.izpack.installer.Installer"/>
+ <property name="uninstaller.class" value="com.izforge.izpack.uninstaller.Uninstaller"/>
+
+ <!-- Define file paths -->
+ <property name="compiler.jar" value="${basedir}/lib/compiler.jar"/>
+ <property name="standalone-compiler.jar" value="${basedir}/lib/standalone-compiler.jar"/>
+ <property name="installer.jar" value="${basedir}/lib/installer.jar"/>
+ <property name="uninstaller.jar" value="${basedir}/lib/uninstaller.jar"/>
+ <property name="uninstaller-ext.jar" value="${basedir}/lib/uninstaller-ext.jar"/>
+ <property name="izevent.jar" value="${basedir}/lib/izevent.jar"/>
+
+ <!-- Compilation parameters -->
+ <property name="debug" value="off"/>
+ <property name="debuglevel" value=""/>
+ <!--<property name="debug" value="true"/>
+ <property name="debuglevel" value="lines,vars,source"/>-->
+ <property name="compat.source" value="1.5"/>
+ <property name="compat.target" value="1.5"/>
+
+
+ <!-- paths -->
+ <path id="classpath">
+ <fileset id="ext.libs" dir="${basedir}/lib">
+ <!-- older ant jar, which izpack distributes and uses for fileset behavior -->
+ <include name="ant.jar"/>
+ <include name="jakarta-regexp-1.3.jar"/>
+ </fileset>
+ <!-- current ant jar, for compiling IzPackTask which uses modern ant features -->
+ <fileset dir="${ant.home}/lib" includes="ant.jar"/>
+ </path>
+
+ <!-- Checking target -->
+ <target name="check">
+ <echo message="basedir=${basedir}"/>
+ <echo message="dist.dir=${dist.dir}"/>
+ <echo message="build.dir=${build.dir}"/>
+ <echo message="debug=${debug}"/>
+ </target>
+
+ <!-- Creates the classes directory -->
+ <target name="prepare" depends="time">
+ <mkdir dir="${build.dir}"/>
+ <mkdir dir="${basedir}/lib"/>
+ <mkdir dir="${dist.dir}"/>
+ </target>
+
+ <!-- Compiles the compiler src files -->
+ <target name="compile.compiler" depends="prepare">
+ <javac srcdir="${src.dir}"
+ classpath="${basedir}/lib/jakarta-regexp-1.3.jar"
+ destdir="${build.dir}"
+ optimize="on"
+ source="${compat.source}"
+ target="${compat.target}"
+ deprecation="on"
+ debug="${debug}"
+ debuglevel="${debuglevel}">
+ <include name="com/izforge/izpack/*.java"/>
+ <include name="com/izforge/izpack/io/*.java"/>
+ <include name="com/izforge/izpack/compiler/*.java"/>
+ <include name="com/izforge/izpack/compressor/*.java"/>
+ <include name="com/izforge/izpack/ant/*.java"/>
+ <include name="com/izforge/izpack/util/Debug.java"/>
+ <include name="com/izforge/izpack/util/OsConstraint.java"/>
+ <include name="com/izforge/izpack/util/JarOutputStream.java"/>
+ <include name="com/izforge/izpack/rules/*.java"/>
+ <!--<include name="net/n3/nanoxml/*.java"/>-->
+ <include name="com/izforge/izpack/adaptator/**/*.java"/>
+ <include name="com/izforge/izpack/adaptator/*.java"/>
+ </javac>
+ <copy todir="${build.dir}/com/izforge/izpack/ant/langpacks">
+ <fileset dir="${src.dir}/com/izforge/izpack/ant/langpacks"/>
+ </copy>
+ <copy todir="${build.dir}/com/izforge/izpack/adaptator">
+ <fileset dir="${src.dir}/com/izforge/izpack/adaptator"/>
+ </copy>
+ </target>
+
+ <!-- Package compiler.jar -->
+ <target name="build.compiler" depends="compile.compiler">
+ <jar jarfile="${compiler.jar}">
+ <manifest>
+ <attribute name="Built-By" value="IzPack"/>
+ <attribute name="Class-Path" value="ant.jar"/>
+ <attribute name="Main-Class" value="${compiler.class}"/>
+ </manifest>
+ <fileset dir="${build.dir}">
+ <include name="com/izforge/izpack/*.class"/>
+ <include name="com/izforge/izpack/io/*.class"/>
+ <include name="com/izforge/izpack/compiler/*.class"/>
+ <include name="com/izforge/izpack/compressor/*.class"/>
+ <include name="com/izforge/izpack/util/OsConstraint.class"/>
+ <include name="com/izforge/izpack/util/Debug.class"/>
+ <include name="com/izforge/izpack/util/*Validator.class"/>
+ <include name="com/izforge/izpack/util/*Processor.class"/>
+ <include name="com/izforge/izpack/util/VariableSubstitutor.class"/>
+ <include name="com/izforge/izpack/util/JarOutputStream.class"/>
+ <include name="com/izforge/izpack/util/FileUtil.class"/>
+ <include name="com/izforge/izpack/ant/*.class"/>
+ <include name="com/izforge/izpack/ant/langpacks/*.properties"/>
+ <include name="com/izforge/izpack/adaptator/*.xsl"/>
+ <include name="com/izforge/izpack/event/CompilerListener.class"/>
+ <include name="com/izforge/izpack/event/SimpleCompilerListener.class"/>
+ <include name="com/izforge/izpack/rules/*.class"/>
+ <include name="com/izforge/izpack/installer/*.class"/>
+ <include name="com/izforge/izpack/adaptator/**/*.class"/>
+ <include name="com/izforge/izpack/adaptator/*.class"/>
+ </fileset>
+ </jar>
+ </target>
+
+ <!-- Package standalone-compiler.jar -->
+ <target name="build.standalone-compiler"
+ depends="compile.compiler, build.installer, build.uninstaller, build.uninstaller-ext, build.panels, build.listeners">
+ <jar jarfile="${standalone-compiler.jar}" duplicate="preserve">
+ <manifest>
+ <attribute name="Built-By" value="IzPack"/>
+ <attribute name="Class-Path" value="ant.jar"/>
+ <attribute name="Main-Class" value="${compiler.class}"/>
+ </manifest>
+ <fileset dir="${build.dir}">
+ <include name="**/*.class"/>
+ </fileset>
+ <zipfileset src="lib/ant.jar"/>
+ <fileset dir="${basedir}">
+ <include name="bin/langpacks/flags/*"/>
+ <include name="bin/langpacks/installer/*"/>
+ <include name="bin/native/izpack/*"/>
+ <include name="bin/native/3rdparty/*"/>
+ <include name="bin/panels/*Panel.jar"/>
+ <include name="bin/customActions/*.jar"/>
+ <include name="lib/*.jar"/>
+ <exclude name="lib/standalone-compiler.jar"/>
+ </fileset>
+ <fileset dir="${src.dir}">
+ <include name="**/*"/>
+ <exclude name="**/*.java"/>
+ </fileset>
+ </jar>
+ </target>
+
+ <!-- Compiles the installer src files -->
+ <target name="compile.installer" depends="prepare">
+ <javac srcdir="${src.dir}"
+ classpath="${basedir}/lib/jakarta-regexp-1.3.jar"
+ destdir="${build.dir}"
+ optimize="on"
+ source="${compat.source}"
+ target="${compat.target}"
+ deprecation="on"
+ debug="${debug}"
+ debuglevel="${debuglevel}">
+ <include name="com/izforge/izpack/panels/PathSelectionPanel.java"/>
+ <include name="com/izforge/izpack/*.java"/>
+ <include name="com/izforge/izpack/gui/*.java"/>
+ <include name="com/izforge/izpack/io/*.java"/>
+ <include name="com/izforge/izpack/installer/*.java"/>
+ <include name="com/izforge/izpack/panels/NextMedia*.java"/>
+ <include name="com/izforge/izpack/util/*.java"/>
+ <include name="com/izforge/izpack/util/os/*.java"/>
+ <include name="com/izforge/izpack/rules/*.java"/>
+ <include name="com/izforge/izpack/uninstaller/SelfModifier*.java"/>
+ <include name="com/izforge/izpack/rules/*.java"/>
+ <include name="com/izforge/izpack/compiler/DynamicVariable.java"/>
+ <!--<include name="net/n3/nanoxml/*.java"/>-->
+ <include name="com/izforge/izpack/panels/HelpWindow.java" />
+ <include name="com/izforge/izpack/adaptator/**/*.java"/>
+ <include name="com/izforge/izpack/adaptator/*.java"/>
+ </javac>
+ </target>
+
+ <!-- Package installer.jar -->
+ <target name="build.installer" depends="compile.installer, build.listener-base">
+ <jar jarfile="${installer.jar}">
+ <manifest>
+ <attribute name="Built-By" value="IzPack"/>
+ <attribute name="Class-Path" value=""/>
+ <attribute name="Main-Class" value="${installer.class}"/>
+ </manifest>
+ <fileset dir="${build.dir}">
+ <include name="com/izforge/izpack/panels/PathSelectionPanel.class"/>
+ <include name="com/izforge/izpack/*.class"/>
+ <include name="com/izforge/izpack/gui/*.class"/>
+ <include name="com/izforge/izpack/io/*.class"/>
+ <include name="com/izforge/izpack/installer/*.class"/>
+ <include name="com/izforge/izpack/util/*.class"/>
+ <include name="com/izforge/izpack/util/**/*.class"/>
+ <include name="com/izforge/izpack/panels/NextMedia*.class"/>
+ <include name="com/izforge/izpack/rules/*.class"/>
+ <include name="com/izforge/izpack/uninstaller/SelfModifier*.class"/>
+ <include name="com/izforge/izpack/rules/*.class"/>
+ <include name="com/izforge/izpack/compiler/DynamicVariable.class"/>
+ <include name="com/izforge/izpack/compiler/CompilerException.class"/>
+ <include name="com/izforge/izpack/panels/Validator*.class"/>
+ <!--<include name="net/n3/nanoxml/*.class"/>-->
+ <include name="com/izforge/izpack/adaptator/**/*.class"/>
+ <include name="com/izforge/izpack/adaptator/*.class"/>
+ <include name="com/izforge/izpack/panels/HelpWindow.class" />
+ </fileset>
+ <zipfileset src="${basedir}/lib/jakarta-regexp-1.3.jar">
+ <include name="org/apache/regexp/*.class"/>
+ </zipfileset>
+ <fileset dir="${src.dir}">
+ <include name="com/izforge/izpack/installer/*.xml"/>
+ <include name="com/izforge/izpack/installer/*.properties"/>
+ <include name="com/izforge/izpack/installer/run-with-privileges-on-osx"/>
+ <include name="com/izforge/izpack/installer/elevate.js"/>
+ <include name="com/izforge/izpack/util/**/*.sh"/>
+ <include name="com/izforge/izpack/adaptator/styleSheet.xsl"/>
+ </fileset>
+ <fileset dir="${img.dir}/installer"/>
+ <zipfileset src="${izevent.jar}">
+ <include name="com/izforge/izpack/event/*InstallerListener.class"/>
+ </zipfileset>
+ </jar>
+ </target>
+
+ <!-- Compiles the uninstaller src files -->
+ <target name="compile.uninstaller" depends="prepare">
+ <javac srcdir="${src.dir}"
+ destdir="${build.dir}"
+ optimize="on"
+ source="${compat.source}"
+ target="${compat.target}"
+ deprecation="on"
+ debug="${debug}"
+ debuglevel="${debuglevel}">
+ <include name="com/izforge/izpack/LocaleDatabase.java"/>
+ <include name="com/izforge/izpack/gui/*.java"/>
+
+ <include name="com/izforge/izpack/util/*.java"/>
+ <include name="com/izforge/izpack/util/os/*.java"/>
+ <include name="com/izforge/izpack/util/os/unix/*.java"/>
+
+ <include name="com/izforge/izpack/uninstaller/*.java"/>
+ <exclude name="com/izforge/izpack/gui/IzPackKMetalTheme.java"/>
+ <!--<include name="net/n3/nanoxml/*.java"/>-->
+ <include name="com/izforge/izpack/adaptator/**/*.java"/>
+ <include name="com/izforge/izpack/adaptator/*.java"/>
+ </javac>
+ </target>
+
+ <!-- Package uninstaller.jar -->
+ <target name="build.uninstaller" depends="compile.uninstaller">
+ <jar jarfile="${uninstaller.jar}">
+ <manifest>
+ <attribute name="Built-By" value="IzPack"/>
+ <attribute name="Class-Path" value=""/>
+ <attribute name="Main-Class" value="${uninstaller.class}"/>
+ </manifest>
+ <fileset dir="${build.dir}">
+ <include name="com/izforge/izpack/LocaleDatabase.class"/>
+ <include name="com/izforge/izpack/gui/*.class"/>
+ <include name="com/izforge/izpack/uninstaller/*.class"/>
+ <include name="com/izforge/izpack/ExecutableFile.class"/>
+ <exclude name="com/izforge/izpack/gui/IzPackKMetalTheme.class"/>
+ <!--<include name="net/n3/nanoxml/*.class"/>-->
+ <include name="com/izforge/izpack/adaptator/**/*.class"/>
+ <include name="com/izforge/izpack/adaptator/*.class"/>
+ <include name="com/izforge/izpack/installer/PrivilegedRunner.class"/>
+ </fileset>
+ <fileset dir="${src.dir}">
+ <include name="com/izforge/izpack/installer/run-with-privileges-on-osx"/>
+ <include name="com/izforge/izpack/installer/elevate.js"/>
+ <include name="com/izforge/izpack/adaptator/styleSheet.xsl"/>
+ <include name="com/izforge/izpack/util/**/*.sh"/>
+ </fileset>
+ <fileset dir="${build.dir}">
+ <include name="com/izforge/izpack/util/**/*.class"/>
+ </fileset>
+ <fileset dir="${img.dir}/uninstaller">
+ <include name="**/*"/>
+ </fileset>
+ <zipfileset src="${izevent.jar}">
+ <include name="com/izforge/izpack/event/*UninstallerListener.class"/>
+ </zipfileset>
+ </jar>
+ </target>
+
+ <!-- Compiles the extended uninstaller src files -->
+ <target name="compile.uninstaller-ext" depends="prepare">
+ <javac srcdir="${src.dir}"
+ destdir="${build.dir}"
+ optimize="on"
+ source="${compat.source}"
+ target="${compat.target}"
+ deprecation="on"
+ debug="${debug}"
+ debuglevel="${debuglevel}">
+ <include name="com/izforge/izpack/util/*.java"/>
+ <include name="com/izforge/izpack/util/os/*.java"/>
+ <include name="com/izforge/izpack/util/os/unix/*.java"/>
+ <include name="com/izforge/izpack/util/xml/*.java"/>
+
+ <exclude name="com/izforge/izpack/gui/IzPackKMetalTheme.java"/>
+ <!--<include name="net/n3/nanoxml/*.java"/>-->
+ <include name="com/izforge/izpack/adaptator/**/*.java"/>
+ <include name="com/izforge/izpack/adaptator/*.java"/>
+ </javac>
+ </target>
+ <!-- Package extended uninstaller.jar used if one ore more native libs are
+ declared for uninstallation -->
+ <target name="build.uninstaller-ext" depends="compile.uninstaller-ext">
+ <jar jarfile="${uninstaller-ext.jar}">
+ <fileset dir="${build.dir}">
+ <include name="com/izforge/izpack/util/**/*.class"/>
+ </fileset>
+ </jar>
+ </target>
+
+ <!--
+ ======================================================================
+ Create Panel Modules
+ ======================================================================
+ -->
+
+ <!-- Macro to compile a panel's classes and create it's jar file -->
+ <macrodef name="build-panel">
+ <attribute name="name" description="The panels jar will get this name"/>
+ <attribute name="srcdir"
+ default="${src.dir}"
+ description="Source directory. Defaults to izpack src dir"/>
+ <element name="panel-fileset"
+ implicit="yes"
+ description="include and exclude elements indicating panel sources"/>
+ <sequential>
+ <echo message="build-panel: @{name}"/>
+ <mkdir dir="${bin.dir}/panels/@{name}"/>
+ <!-- sourcepath is cleared so there's no mistaking what goes into the Panel -->
+ <javac srcdir="@{srcdir}"
+ destdir="${bin.dir}/panels/@{name}"
+ classpath="${installer.jar}"
+ sourcepath=""
+ optimize="on"
+ deprecation="on"
+ debug="${debug}"
+ source="${compat.source}"
+ target="${compat.target}"
+ debuglevel="${debuglevel}">
+ <panel-fileset/>
+ </javac>
+ <jar jarfile="${bin.dir}/panels/@{name}.jar" basedir="${bin.dir}/panels/@{name}"/>
+ </sequential>
+ </macrodef>
+
+ <!-- Compile all panels and put them at the right location -->
+ <!--
+ If you add a another, and the build fails because it can't find a class,
+ be sure to explicitly include the .java file in the nested fileset.
+ This also acts as a check to help limit dependancies.
+ -->
+ <target name="build.panels" depends="build.installer">
+ <mkdir dir="${bin.dir}/panels"/>
+
+ <build-panel name="FinishPanel">
+ <include name="com/izforge/izpack/panels/FinishPanel.java"/>
+ <include name="com/izforge/izpack/panels/FinishPanelConsoleHelper.java" />
+ </build-panel>
+ <build-panel name="HelloPanel">
+ <include name="com/izforge/izpack/panels/HelloPanel.java"/>
+ <include name="com/izforge/izpack/panels/HelloPanelConsoleHelper.java" />
+ </build-panel>
+ <build-panel name="SelectPrinterPanel">
+ <include name="com/izforge/izpack/panels/SelectPrinterPanel.java"/>
+ </build-panel>
+ <build-panel name="DataCheckPanel">
+ <include name="com/izforge/izpack/panels/DataCheckPanel.java"/>
+ </build-panel>
+ <build-panel name="CheckedHelloPanel">
+ <include name="com/izforge/izpack/panels/CheckedHelloPanel.java"/>
+ <include name="com/izforge/izpack/panels/HelloPanel.java"/>
+ <include name="com/izforge/izpack/util/os/*RegistryHandler.java"/>
+ <include name="com/izforge/izpack/util/OSClassHelper.java"/>
+ <include name="com/izforge/izpack/util/os/WrappedNativeLibException.java"/>
+ <include name="com/coi/tools/os/win/*.java"/>
+ <include name="com/coi/tools/os/win/resources/NativeLibErr*.java"/>
+ <include name="com/coi/tools/os/izpack/Registry.java"/>
+ <include name="com/coi/tools/os/izpack/COIOSHelper.java"/>
+ </build-panel>
+ <build-panel name="InfoPanel">
+ <include name="com/izforge/izpack/panels/InfoPanel.java"/>
+ </build-panel>
+ <build-panel name="InstallPanel">
+ <include name="com/izforge/izpack/panels/InstallPanel.java"/>
+ <include name="com/izforge/izpack/panels/InstallPanelAutomationHelper.java"/>
+ <include name="com/izforge/izpack/panels/InstallPanelConsoleHelper.java" />
+ </build-panel>
+ <build-panel name="ExtendedInstallPanel">
+ <include name="com/izforge/izpack/panels/ExtendedInstallPanel.java"/>
+ <include name="com/izforge/izpack/panels/ExtendedInstallPanelAutomationHelper.java"/>
+ <include name="com/izforge/izpack/panels/InstallPanel.java"/>
+ </build-panel>
+ <build-panel name="LicencePanel">
+ <include name="com/izforge/izpack/panels/LicencePanel.java"/>
+ <include name="com/izforge/izpack/panels/LicencePanelConsoleHelper.java"/>
+ </build-panel>
+ <build-panel name="PacksPanel">
+ <include name="com/izforge/izpack/panels/ImgPacksPanelAutomationHelper.java"/>
+ <include name="com/izforge/izpack/panels/ImgPacksPanelBase.java"/>
+ <include name="com/izforge/izpack/panels/PacksModel.java"/>
+ <include name="com/izforge/izpack/panels/PacksPanel.java"/>
+ <include name="com/izforge/izpack/panels/PacksPanelAutomationHelper.java"/>
+ <include name="com/izforge/izpack/panels/PacksPanelBase.java"/>
+ <include name="com/izforge/izpack/panels/PacksPanelInterface.java"/>
+ </build-panel>
+ <build-panel name="ImgPacksPanel">
+ <include name="com/izforge/izpack/panels/ImgPacksPanel.java"/>
+ <include name="com/izforge/izpack/panels/ImgPacksPanelAutomationHelper.java"/>
+ <include name="com/izforge/izpack/panels/PacksModel.java"/>
+ <include name="com/izforge/izpack/panels/PacksPanelBase.java"/>
+ <include name="com/izforge/izpack/panels/PacksPanelInterface.java"/>
+ <include name="com/izforge/izpack/panels/PacksPanelAutomationHelper.java"/>
+ </build-panel>
+ <build-panel name="HTMLLicencePanel">
+ <include name="com/izforge/izpack/panels/HTMLLicencePanel.java"/>
+ <include name="com/izforge/izpack/panels/HTMLLicencePanelConsoleHelper.java"/>
+ </build-panel>
+ <build-panel name="HTMLInfoPanel">
+ <include name="com/izforge/izpack/panels/HTMLInfoPanel.java"/>
+ </build-panel>
+ <build-panel name="TargetPanel">
+ <include name="com/izforge/izpack/panels/PathInputPanel.java"/>
+ <include name="com/izforge/izpack/panels/PathSelectionPanel.java"/>
+ <include name="com/izforge/izpack/panels/TargetPanel.java"/>
+ <include name="com/izforge/izpack/panels/TargetPanelAutomationHelper.java"/>
+ <include name="com/izforge/izpack/panels/TargetPanelConsoleHelper.java" />
+ </build-panel>
+ <build-panel name="DefaultTargetPanel">
+ <include name="com/izforge/izpack/panels/PathInputPanel.java"/>
+ <include name="com/izforge/izpack/panels/PathSelectionPanel.java"/>
+ <include name="com/izforge/izpack/panels/DefaultTargetPanel.java"/>
+ <include name="com/izforge/izpack/panels/DefaultTargetPanelAutomationHelper.java"/>
+ </build-panel>
+ <build-panel name="JDKPathPanel">
+ <include name="com/izforge/izpack/panels/JDKPathPanel.java"/>
+ <include name="com/izforge/izpack/panels/PathInputPanel.java"/>
+ <include name="com/izforge/izpack/panels/PathSelectionPanel.java"/>
+ <include name="com/izforge/izpack/util/os/*RegistryHandler.java"/>
+ <include name="com/izforge/izpack/util/OSClassHelper.java"/>
+ <include name="com/izforge/izpack/util/os/WrappedNativeLibException.java"/>
+ <include name="com/coi/tools/os/win/*.java"/>
+ <include name="com/coi/tools/os/win/resources/NativeLibErr*.java"/>
+ <include name="com/coi/tools/os/izpack/Registry.java"/>
+ <include name="com/coi/tools/os/izpack/COIOSHelper.java"/>
+ </build-panel>
+ <build-panel name="XInfoPanel">
+ <include name="com/izforge/izpack/panels/XInfoPanel.java"/>
+ </build-panel>
+ <build-panel name="ShortcutPanel">
+ <include name="com/izforge/izpack/panels/ShortcutData.java"/>
+ <include name="com/izforge/izpack/panels/ShortcutPanel*.java"/>
+ <include name="com/izforge/izpack/util/xml/*.java"/>
+ </build-panel>
+ <build-panel name="UserInputPanel">
+ <include name="com/izforge/izpack/panels/PasswordGroup.java"/>
+ <include name="com/izforge/izpack/panels/ProcessingClient.java"/>
+ <include name="com/izforge/izpack/panels/StringInputProcessingClient.java"/>
+ <include name="com/izforge/izpack/panels/Processor.java"/>
+ <include name="com/izforge/izpack/panels/RuleInputField.java"/>
+ <include name="com/izforge/izpack/panels/RuleTextField.java"/>
+ <include name="com/izforge/izpack/panels/TextInputField.java"/>
+ <include name="com/izforge/izpack/panels/FileInputField.java"/>
+ <include name="com/izforge/izpack/panels/DirInputField.java"/>
+ <include name="com/izforge/izpack/panels/MultipleFileInputField.java"/>
+ <include name="com/izforge/izpack/panels/UserInputPanel.java"/>
+ <include name="com/izforge/izpack/panels/UserInputPanelAutomationHelper.java"/>
+ <include name="com/izforge/izpack/panels/Validator.java"/>
+ <include name="com/izforge/izpack/panels/ValidatorContainer.java"/>
+ <include name="com/izforge/izpack/panels/UIElementType.java"/>
+ <include name="com/izforge/izpack/panels/UIElement.java"/>
+ <include name="com/izforge/izpack/panels/RadioButtonUIElement.java"/>
+ <include name="com/izforge/izpack/panels/PasswordUIElement.java"/>
+ <include name="com/izforge/izpack/panels/UserInputPanelConsoleHelper.java" />
+ </build-panel>
+ <build-panel name="UserPathPanel">
+ <include name="com/izforge/izpack/panels/UserPathInputPanel.java"/>
+ <include name="com/izforge/izpack/panels/UserPathSelectionPanel.java"/>
+ <include name="com/izforge/izpack/panels/UserPathPanel.java"/>
+ <include name="com/izforge/izpack/panels/UserPathPanelAutomationHelper.java"/>
+ </build-panel>
+ <build-panel name="ConditionalUserInputPanel">
+ <include name="com/izforge/izpack/panels/ConditionalUserInputPanel.java"/>
+ <include name="com/izforge/izpack/panels/PasswordGroup.java"/>
+ <include name="com/izforge/izpack/panels/ProcessingClient.java"/>
+ <include name="com/izforge/izpack/panels/StringInputProcessingClient.java"/>
+ <include name="com/izforge/izpack/panels/Processor.java"/>
+ <include name="com/izforge/izpack/panels/RuleInputField.java"/>
+ <include name="com/izforge/izpack/panels/RuleTextField.java"/>
+ <include name="com/izforge/izpack/panels/FileInputField.java"/>
+ <include name="com/izforge/izpack/panels/DirInputField.java"/>
+ <include name="com/izforge/izpack/panels/MultipleFileInputField.java"/>
+ <include name="com/izforge/izpack/panels/TextInputField.java"/>
+ <include name="com/izforge/izpack/panels/UserInputPanel.java"/>
+ <include name="com/izforge/izpack/panels/UserInputPanelAutomationHelper.java"/>
+ <include name="com/izforge/izpack/panels/Validator.java"/>
+ <include name="com/izforge/izpack/panels/ValidatorContainer.java"/>
+ <include name="com/izforge/izpack/panels/UIElementType.java"/>
+ <include name="com/izforge/izpack/panels/UIElement.java"/>
+ <include name="com/izforge/izpack/panels/RadioButtonUIElement.java"/>
+ <include name="com/izforge/izpack/panels/PasswordUIElement.java"/>
+ </build-panel>
+ <build-panel name="CompilePanel">
+ <include name="com/izforge/izpack/panels/CompilePanel.java"/>
+ <include name="com/izforge/izpack/panels/CompilePanelAutomationHelper.java"/>
+ </build-panel>
+ <build-panel name="ProcessPanel">
+ <include name="com/izforge/izpack/panels/ProcessPanel.java"/>
+ <include name="com/izforge/izpack/panels/ProcessPanelAutomationHelper.java"/>
+ </build-panel>
+ <build-panel name="SudoPanel">
+ <include name="com/izforge/izpack/panels/SudoPanel.java"/>
+ </build-panel>
+ <build-panel name="SimpleFinishPanel">
+ <include name="com/izforge/izpack/panels/SimpleFinishPanel.java"/>
+ </build-panel>
+ <build-panel name="SummaryPanel">
+ <include name="com/izforge/izpack/panels/SummaryPanel.java"/>
+ </build-panel>
+ <build-panel name="InstallationGroupPanel">
+ <include name="com/izforge/izpack/panels/InstallationGroupPanel.java"/>
+ <include name="com/izforge/izpack/panels/InstallationGroupPanelAutomationHelper.java"/>
+ </build-panel>
+ <build-panel name="TreePacksPanel">
+ <include name="com/izforge/izpack/panels/TreePacksPanel.java"/>
+ <include name="com/izforge/izpack/panels/TreePacksPanelAutomationHelper.java"/>
+ <include name="com/izforge/izpack/panels/ImgPacksPanelAutomationHelper.java"/>
+ <include name="com/izforge/izpack/panels/ImgPacksPanelBase.java"/>
+ <include name="com/izforge/izpack/panels/PacksModel.java"/>
+ <include name="com/izforge/izpack/panels/PacksPanelAutomationHelper.java"/>
+ <include name="com/izforge/izpack/panels/PacksPanelBase.java"/>
+ <include name="com/izforge/izpack/panels/PacksPanelInterface.java"/>
+ </build-panel>
+ <build-panel name="InstallationTypePanel">
+ <include name="com/izforge/izpack/panels/InstallationTypePanel.java"/>
+ </build-panel>
+ <build-panel name="HTMLHelloPanel">
+ <include name="com/izforge/izpack/panels/HTMLHelloPanel.java"/>
+ <include name="com/izforge/izpack/panels/HTMLInfoPanel.java"/>
+ </build-panel>
+ <build-panel name="NonBlankTargetPanel">
+ <include name="com/izforge/izpack/panels/PathInputPanel.java"/>
+ <include name="com/izforge/izpack/panels/PathSelectionPanel.java"/>
+ <include name="com/izforge/izpack/panels/TargetPanel.java"/>
+ <include name="com/izforge/izpack/panels/TargetPanelAutomationHelper.java"/>
+ <include name="com/izforge/izpack/panels/NonBlankTargetPanel.java"/>
+ </build-panel>
+ </target>
+
+ <!--
+ ======================================================================
+ Create Listener Modules
+ ======================================================================
+ -->
+
+ <!-- Compiles the base custom action classes which should placed into
+ izevent.jar -->
+ <target name="compile.listener-base">
+ <javac srcdir="${src.dir}"
+ destdir="${build.dir}"
+ optimize="on"
+ source="${compat.source}"
+ target="${compat.target}"
+ deprecation="on"
+ debug="${debug}"
+ debuglevel="${debuglevel}"
+ classpath="${installer.jar};${compiler.jar}">
+ <include name="com/izforge/izpack/event/ActionBase.java"/>
+ <include name="com/izforge/izpack/event/Simple*nstallerListener.java"/>
+ <include name="com/izforge/izpack/event/SimpleCompilerListener.java"/>
+ <include name="com/izforge/izpack/event/InstallerListener.java"/>
+ <include name="com/izforge/izpack/event/ProgressBarInstallerListener.java"/>
+ <include name="com/izforge/izpack/event/CompilerListener.java"/>
+ <include name="com/izforge/izpack/event/UninstallerListener.java"/>
+ <include name="com/izforge/izpack/util/IoHelper.java"/>
+ </javac>
+ </target>
+ <!-- Package izevent.jar -->
+ <target name="build.listener-base" depends="compile.listener-base">
+ <jar jarfile="${izevent.jar}">
+ <fileset dir="${build.dir}">
+ <include name="com/izforge/izpack/event/*.class"/>
+ <include name="com/izforge/izpack/util/IoHelper.class"/>
+ </fileset>
+ </jar>
+ </target>
+
+
+ <!-- Macro to compile a listener's classes and create its jar file -->
+ <macrodef name="build-listener">
+ <attribute name="name" description="The listener jar will get this name"/>
+ <attribute name="classpath-ext" description="An extension of the classpath required to build the listener"
+ default=""/>
+ <attribute name="srcdir"
+ default="${src.dir}"
+ description="Source directory. Defaults to izpack src dir"/>
+ <attribute name="izeventExcludes"
+ description="excludes patter for files in the ${izevent.jar} file"/>
+ <element name="listener-fileset"
+ implicit="yes"
+ description="include and exclude elements indicating listener sources"/>
+ <sequential>
+ <echo message="build-listener: @{name}"/>
+ <mkdir dir="${bin.dir}/customActions/@{name}"/>
+ <!-- sourcepath is cleared so there's no mistaking what goes into the Listener -->
+ <javac srcdir="@{srcdir}"
+ destdir="${bin.dir}/customActions/@{name}"
+ classpath="${installer.jar};${compiler.jar};${izevent.jar};@{classpath-ext}"
+ sourcepath=""
+ optimize="on"
+ deprecation="on"
+ debug="${debug}"
+ source="${compat.source}"
+ target="${compat.target}"
+ debuglevel="${debuglevel}">
+ <listener-fileset/>
+ </javac>
+ <jar jarfile="${bin.dir}/customActions/@{name}.jar"
+ basedir="${bin.dir}/customActions/@{name}">
+ <!-- also include files from the previously built ${izevent.jar} -->
+ <zipfileset src="${izevent.jar}" excludes="@{izeventExcludes}"/>
+ </jar>
+ </sequential>
+ </macrodef>
+
+ <!-- Convenience macro to call build-listener for compiler listeners -->
+ <macrodef name="build-compiler-listener">
+ <attribute name="name"/>
+ <attribute name="srcdir" default="${src.dir}"/>
+ <element name="compiler-fileset"
+ implicit="yes"
+ description="include and exclude elements indicating listener sources"/>
+ <sequential>
+ <build-listener name="@{name}"
+ srcdir="@{srcdir}"
+ izeventExcludes="**/*Installer*,**/*Uninstaller*">
+ <compiler-fileset/>
+ </build-listener>
+ </sequential>
+ </macrodef>
+
+ <!-- Convenience macro to call build-listener for installer listeners -->
+ <macrodef name="build-installer-listener">
+ <attribute name="name"/>
+ <attribute name="classpath-ext" description="An extension of the classpath required to build the listener"
+ default=""/>
+ <attribute name="srcdir" default="${src.dir}"/>
+ <element name="installer-fileset"
+ implicit="yes"
+ description="include and exclude elements indicating listener sources"/>
+ <sequential>
+ <build-listener name="@{name}" srcdir="@{srcdir}" izeventExcludes="**/*Uninstaller*,**/*Compiler*"
+ classpath-ext="@{classpath-ext}">
+ <installer-fileset/>
+ </build-listener>
+ </sequential>
+ </macrodef>
+
+ <!-- Convenience macro to call build-listener for uninstaller listeners -->
+ <macrodef name="build-uninstaller-listener">
+ <attribute name="name"/>
+ <attribute name="srcdir" default="${src.dir}"/>
+ <attribute name="classpath-ext" description="An extension of the classpath required to build the listener"
+ default=""/>
+ <element name="uninstaller-fileset"
+ implicit="yes"
+ description="include and exclude elements indicating listener sources"/>
+ <sequential>
+ <build-listener name="@{name}" srcdir="@{srcdir}" izeventExcludes="**/*Installer*,**/*Compiler*"
+ classpath-ext="@{classpath-ext}">
+ <uninstaller-fileset/>
+ </build-listener>
+ </sequential>
+ </macrodef>
+
+ <!-- Compile all custom actions (listener) and put them at the right location -->
+ <!--
+ If you add a another, and the build fails because it can't find a class,
+ be sure to explicitly include the .java file in the nested fileset.
+ This also acts as a check to help limit dependancies.
+ -->
+ <target name="build.listeners" depends="build.compiler,build.installer,build.listener-base">
+ <!-- This dependency is mandatory -->
+ <build-installer-listener name="LateShortcutInstallListener"
+ classpath-ext="${bin.dir}/panels/ShortcutPanel.jar">
+ <include name="com/izforge/izpack/event/LateShortcutInstallListener.java"/>
+ </build-installer-listener>
+
+ <build-installer-listener name="AntActionInstallerListener">
+ <include name="com/izforge/izpack/event/AntActionInstallerListener.java"/>
+ <include name="com/izforge/izpack/event/AntAction.java"/>
+ </build-installer-listener>
+
+ <build-uninstaller-listener name="AntActionUninstallerListener">
+ <include name="com/izforge/izpack/event/AntActionUninstallerListener.java"/>
+ <include name="com/izforge/izpack/event/AntAction.java"/>
+ </build-uninstaller-listener>
+
+ <build-installer-listener name="SummaryLoggerInstallerListener">
+ <include name="com/izforge/izpack/event/SummaryLoggerInstallerListener.java"/>
+ </build-installer-listener>
+
+ <build-installer-listener name="RegistryInstallerListener">
+ <include name="com/izforge/izpack/event/RegistryInstallerListener.java"/>
+ <include name="com/izforge/izpack/event/NativeInstallerListener.java"/>
+ <include name="com/izforge/izpack/util/os/*RegistryHandler.java"/>
+ <include name="com/izforge/izpack/util/OSClassHelper.java"/>
+ <include name="com/izforge/izpack/util/os/WrappedNativeLibException.java"/>
+ <include name="com/coi/tools/os/win/*.java"/>
+ <include name="com/coi/tools/os/win/resources/NativeLibErr*.java"/>
+ <include name="com/coi/tools/os/izpack/Registry.java"/>
+ <include name="com/coi/tools/os/izpack/COIOSHelper.java"/>
+ </build-installer-listener>
+
+ <build-uninstaller-listener name="RegistryUninstallerListener">
+ <include name="com/izforge/izpack/event/RegistryUninstallerListener.java"/>
+ <include name="com/izforge/izpack/event/NativeUninstallerListener.java"/>
+ <include name="com/izforge/izpack/util/os/*RegistryHandler.java"/>
+ <include name="com/izforge/izpack/util/OSClassHelper.java"/>
+ <include name="com/izforge/izpack/util/os/WrappedNativeLibException.java"/>
+ <include name="com/coi/tools/os/win/*.java"/>
+ <include name="com/coi/tools/os/win/resources/NativeLibErr*.java"/>
+ <include name="com/coi/tools/os/izpack/Registry.java"/>
+ <include name="com/coi/tools/os/izpack/COIOSHelper.java"/>
+ </build-uninstaller-listener>
+
+ <build-installer-listener name="BSFInstallerListener" classpath-ext="$${basedir}/lib/bsf.jar">
+ <include name="com/izforge/izpack/event/BSFInstallerListener.java" />
+ <include name="com/izforge/izpack/event/BSFAction.java" />
+ </build-installer-listener>
+
+ <build-installer-listener name="ProgressBarInstallerListener">
+ <include name="com/izforge/izpack/event/ProgressBarInstallerListener.java"/>
+ </build-installer-listener>
+
+ <build-uninstaller-listener name="BSFUninstallerListener" classpath-ext="$${basedir}/lib/bsf.jar">
+ <include name="com/izforge/izpack/event/BSFUninstallerListener.java" />
+ <include name="com/izforge/izpack/event/BSFAction.java" />
+ </build-uninstaller-listener>
+
+ <!-- CUSTOM ACTION test START
+ <build-compiler-listener name="ChmodCompilerListener">
+ <include name="com/myCompany/tools/install/listener/ChmodCompilerListener.java"/>
+ </build-compiler-listener>
+
+ <build-installer-listener name="ChmodInstallerListener">
+ <include name="com/myCompany/tools/install/listener/ChmodInstallerListener.java"/>
+ </build-installer-listener>
+ COSTOM ACTION test END -->
+ </target>
+
+ <!-- ====================================================================== -->
+
+ <!-- Performs some cleanups -->
+ <target name="clean" description="cleans up the dist">
+ <echo message="Cleaning-up"/>
+ <delete includeEmptyDirs="true" quiet="true">
+ <fileset dir="${build.dir}"/>
+ <fileset dir="${dist.dir}"/>
+ <fileset dir="${basedir}/bin/panels/">
+ <include name="**/*"/>
+ </fileset>
+ <fileset dir="${basedir}/bin/customActions/">
+ <include name="**/*"/>
+ </fileset>
+ <fileset dir="${basedir}/lib/">
+ <include name="compiler.jar"/>
+ <include name="izevent.jar"/>
+ <include name="standalone-compiler.jar"/>
+ <include name="frontend.jar"/>
+ <include name="installer.jar"/>
+ <include name="uninstaller.jar"/>
+ <include name="uninstaller-ext.jar"/>
+ </fileset>
+ </delete>
+ <delete file="bin/native/3rdparty/COIOSHelper.dll"/>
+ <delete dir="${basedir}/bin/native/izpack"/>
+ <delete dir="${basedir}/src/doc-reST/html"/>
+ <delete dir="${basedir}/src/doc-reST/pdf"/>
+ <delete includeEmptyDirs="true" dir="${basedir}/doc/izpack"/>
+ <delete dir="${basedir}/_src${dist.subdir}"/>
+ </target>
+
+ <!-- Builds all compilation targets -->
+ <target name="all"
+ depends="splashscreen, copy.dist.natives,build.compiler, build.compiler, build.installer, build.uninstaller, build.uninstaller-ext, build.panels, build.listeners, build.standalone-compiler"
+ description="base: compiles a developer version"/>
+
+ <!-- Builds the Javadoc -->
+ <target name="build.javadoc" depends="prepare" description="Builds the javadoc">
+ <mkdir dir="${build.dir}/javadoc"/>
+ <javadoc destdir="${build.dir}/javadoc" access="private" classpathref="classpath">
+ <packageset dir="${src.dir}">
+ <exclude name="**/CVS"/>
+ </packageset>
+ </javadoc>
+ <copy todir="${doc.dir}/izpack/javadoc" preservelastmodified="true">
+ <fileset dir="${build.dir}/javadoc">
+ <include name="**/*"/>
+ </fileset>
+ </copy>
+ </target>
+
+ <target name="build.docu" description="Builds the customer documentation">
+ <exec executable="${basedir}/src/doc-reST/build.py" dir="${basedir}/src/doc-reST">
+ <arg value="build.py"/>
+ </exec>
+
+ <mkdir dir="${doc.dir}/izpack/html"/>
+ <copy todir="${doc.dir}/izpack/html" preservelastmodified="true">
+ <fileset dir="${basedir}/src/doc-reST/html">
+ <include name="**/*"/>
+ </fileset>
+ </copy>
+ <mkdir dir="${doc.dir}/izpack/pdf"/>
+ <copy todir="${doc.dir}/izpack/pdf" preservelastmodified="true">
+ <fileset dir="${basedir}/src/doc-reST/pdf">
+ <include name="manual.pdf"/>
+ </fileset>
+ </copy>
+
+ <delete file="${basedir}/src/texput.log"/>
+ <delete dir="${basedir}/src/doc-reST/html"/>
+ <delete dir="${basedir}/src/doc-reST/pdf"/>
+ </target>
+
+ <target name="create.docu"
+ depends="build.javadoc, build.docu"
+ description="Creates the javadoc-api and customer documentation">
+
+ </target>
+
+
+ <!-- - - - - - - - - - - - - - - - - -
+ target: taskdef
+ - - - - - - - - - - - - - - - - - -->
+ <target name="taskdef.dist">
+ <!-- Allows us to use the IzPack Ant task -->
+ <taskdef name="izpack"
+ classpath="${basedir}/lib/compiler.jar"
+ classname="com.izforge.izpack.ant.IzPackTask"/>
+ </target>
+
+
+ <!-- - - - - - - - - - - - - - - - - -
+ target: copy.natives
+ - - - - - - - - - - - - - - - - - -->
+ <target name="copy.dist.natives">
+ <echo message="Copies the recent changed native files to the ${basedir}/bin directory"/>
+
+ <mkdir dir="${basedir}/bin/native/izpack"/>
+ <copy todir="${basedir}/bin/native/izpack"
+ file="${basedir}/src/native/ShellLink/src/lib/ShellLink.dll"
+ verbose="true"
+ overwrite="yes"
+ preservelastmodified="true"/>
+ <copy todir="${basedir}/bin/native/izpack"
+ file="${basedir}/src/native/ShellLink/src/lib/ShellLink_x64.dll"
+ verbose="true"
+ overwrite="yes"
+ preservelastmodified="true"/>
+ <copy todir="${basedir}/bin/native/3rdparty"
+ file="${basedir}/src/native/COIOSHelper/src/lib/COIOSHelper.dll"
+ verbose="true"
+ overwrite="yes"
+ preservelastmodified="true"/>
+ <copy todir="${basedir}/bin/native/3rdparty"
+ file="${basedir}/src/native/COIOSHelper/src/lib/COIOSHelper_x64.dll"
+ verbose="true"
+ overwrite="yes"
+ preservelastmodified="true"/>
+ </target>
+
+
+ <!-- - - - - - - - - - - - - - - - - -
+ target: copy.distfiles
+ - - - - - - - - - - - - - - - - - -->
+ <target name="copy.dist.files">
+ <echo message="Copies the general files to the dist directory"/>
+ <copy todir="${dist.dir}" includeEmptyDirs="yes" preservelastmodified="true">
+ <fileset dir="${basedir}">
+ <include name="bin/**"/>
+ <include name="utils/**"/>
+ <include name="lib/*.jar"/>
+ <include name="doc/**"/>
+ <include name="legal/**"/>
+ <include name="src/**"/>
+ <include name="sample/**"/>
+ <include name="*.txt"/>
+ <include name="*.html"/>
+ </fileset>
+ </copy>
+ <echo message="Copies the langpacks to the dist directory"/>
+ <copy todir="${dist.dir}/bin" includeEmptyDirs="yes" preservelastmodified="true">
+ <fileset dir="${basedir}">
+ <include name="langpacks/**"/>
+ </fileset>
+ </copy>
+ <echo message="Copies the license images and specs to the dist directory"/>
+ <copy todir="${dist.dir}" includeEmptyDirs="yes" preservelastmodified="true">
+ <fileset dir="${dist-files.dir}">
+ <include name="useNativeLAF"/>
+ <include name="*.jpg"/>
+ <include name="*.png"/>
+ <include name="*.html"/>
+ <include name="Licence.txt"/>
+ <include name="IzPack-install*.xml"/>
+ <include name="shortcutSpec.xml"/>
+ <include name="Unix_shortcutSpec.xml"/>
+ <include name="RegistrySpec.xml"/>
+ <include name="conditions.xml"/>
+ </fileset>
+ </copy>
+ <echo message="Copies the bin files to the dist directory"/>
+ <copy todir="${dist.dir}/bin" includeEmptyDirs="yes" overwrite="yes" preservelastmodified="true">
+ <fileset dir="${dist-files.dir}">
+ <include name="compile*"/>
+ <include name="lcp.bat"/>
+ <include name="start.sh"/>
+ </fileset>
+ </copy>
+ </target>
+
+
+ <!-- - - - - - - - - - - - - - - - - -
+ target: replace.dist.buildnumber
+ - - - - - - - - - - - - - - - - - -->
+ <target name="replace.dist.buildnumber">
+ <replace file="${dist.dir}/shortcutSpec.xml"
+ token="@build.number@"
+ value="${build.number}"
+ summary="yes"/>
+ <replace file="${dist.dir}/shortcutSpec.xml" token="@ver@" value="${ver}" summary="yes"/>
+
+ <replace file="${dist.dir}/Unix_shortcutSpec.xml"
+ token="@build.number@"
+ value="${build.number}"
+ summary="yes"/>
+ <replace file="${dist.dir}/Unix_shortcutSpec.xml"
+ token="@ver@"
+ value="${ver}"
+ summary="yes"/>
+ </target>
+
+ <!-- Creates an installer for IzPack -->
+ <target name="exec.izpack.compiler">
+
+ <!-- We call IzPack -->
+ <echo message="Makes the installer using IzPack" level="verbose"/>
+ <izpack input="${dist.dir}/${installer.xmlfile}"
+ output="${dist.dir}/${installer.name}${ver}.${rel}.jar"
+ installerType="standard"
+ basedir="${dist.dir}"
+ izPackDir="${dist.dir}/"
+ compression="deflate"
+ compressionlevel="9"/>
+ <echo>
+ sucessfully created:
+ ${dist.dir}/${installer.name}${ver}.${rel}.jar
+ </echo>
+ </target>
+
+
+ <!-- - - - - - - - - - - - - - - - - -
+ target: prepare.install.dist
+ - - - - - - - - - - - - - - - - - -->
+ <target name="prepare.install.dist"
+ depends="taskdef.dist, copy.dist.natives, copy.dist.files, replace.dist.buildnumber, fix.crlf">
+
+ </target>
+
+ <!-- =================================
+ Creates a normal installer for IzPack
+ ================================= -->
+ <target name="generate.installer" depends="prepare.install.dist">
+ <antcall target="exec.izpack.compiler">
+ <param name="installer.xmlfile" value="IzPack-install.xml"/>
+ <param name="installer.name" value="${product}-install-"/>
+ </antcall>
+ </target>
+
+ <!--
+ Fixes CR/LF by applying the Unix convention (\n for endlines).
+ It also fixes the encoding problems by moving it to UTF-8.
+ -->
+ <target name="fix.crlf">
+ <property name="dist.src.dir" location="${dist.dir}/src"/>
+ <property name="dist.bin.dir" location="${dist.dir}/bin"/>
+ <echo>
+ Fixing linefeeds for several files in:
+ "${dist.src.dir}"
+ and
+ "${dist.bin.dir}"
+ </echo>
+ <fixcrlf srcDir="${dist.src.dir}" eol="lf" eof="remove" encoding="UTF-8">
+ <include name="**/*.java"/>
+ <include name="**/*.xml"/>
+ <include name="**/*.properties"/>
+ </fixcrlf>
+ <fixcrlf srcdir="${dist.dir}" eol="unix" eof="remove">
+ <include name="**/*.sh"/>
+ <include name="dist-files/compile"/>
+ </fixcrlf>
+ <fixcrlf srcdir="${dist.bin.dir}" eol="unix" eof="remove">
+ <include name="**/*.sh"/>
+ <include name="compile"/>
+ </fixcrlf>
+ <fixcrlf srcdir="${dist.dir}" eol="dos" eof="add">
+ <include name="**/*.bat"/>
+ </fixcrlf>
+ <fixcrlf srcdir="${dist.bin.dir}" eol="dos" eof="add">
+ <include name="**/*.bat"/>
+ </fixcrlf>
+ </target>
+
+ <!-- Runs a testing installer. -->
+ <target name="run.installer">
+ <java jar="${basedir}/_dist/IzPack-install-${build.number}.jar" fork="true"/>
+ </target>
+
+ <!-- Makes everything, from compilation to generating an installer. -->
+ <target name="quickdist"
+ depends="all, generate.installer"
+ description="makes a installer without docu"/>
+
+ <!-- Makes everything, from compilation, customer and javadoc to generating an installer. -->
+ <target name="dist"
+ depends="src.tar.gz, all, create.docu, generate.installer"
+ description="makes a complete installer"/>
+
+ <!-- Makes everything, from Cleaning to generating both installers: normal and reg support. -->
+ <target name="cleandistreg"
+ depends="clean, splashscreen, dist, generate.installer"
+ description="creates a full dist with Win32 uninstall registry support"/>
+
+ <!-- =================================
+ target: clean.src.tar.gz
+ ================================= -->
+ <target name="clean.src.tar.gz" depends="clean, src.tar.gz" description="--> creates a src.tar.gz after clean up">
+ </target>
+
+
+ <!-- =================================
+ target: src.tar.gz
+ ================================= -->
+ <target name="src.tar.gz" description="--> creates a src.tar.gz ">
+ <mkdir dir="${basedir}/_src${dist.subdir}"/>
+ <property name="src.tar.gz" value="${basedir}/_src${dist.subdir}/${product}-src-${ver}.${rel}.tar.gz"/>
+ <tar compression="gzip" destfile="${src.tar.gz}" basedir="${basedir}"
+ excludes="_src${dist.subdir}/**, _dist/**, _build/**, bin/panels/**, bin/customActions/**, doc/izpack/**, eclipse-bin/**, lib/standalone-compiler.jar, lib/izevent.jar, lib/uninstaller*, lib/installer.jar, lib/compiler.jar"/>
+ </target>
+
+
+ <!-- convenient :) makes a quick dist (w/o docu), an installer and run them. -->
+ <target name="quickdist+run"
+ depends="quickdist, run.installer"
+ description="makes a quickdist installer and runs them"/>
+
+ <!-- convenient :) makes a complete dist an installer and run them. -->
+ <target name="dist+run"
+ depends="dist, run.installer"
+ description="makes a complete installer and runs them"/>
+
+ <!-- ** splashscreen **
+ shows some ANT specific- and JAVA-
+ but Platform and Project-independed Properties.
+ ================================================================ -->
+ <target name="splashscreen"
+ depends="time"
+ description="shows the used environment and project settings">
+
+ <property name="console_line" value="**************************************************"/>
+ <echo message="${console_line}"/>
+ <echo message="* ${ant.version}"/>
+ <echo message="* Java JRE version ${ant.java.version} ${java.vm.vendor}"/>
+ <exec executable="${java.home}/bin/java">
+ <arg line="-version"/>
+ </exec>
+ <echo message="${console_line}"/>
+ <echo message="* processing file ....... '${ant.file}'"/>
+ <echo message="* in base-directory ..... '${basedir}'"/>
+ <echo message="* building project ...... '${ant.project.name}'"/>
+ <echo message="* working in directory .. '${cwd}'"/>
+ <echo message="${console_line}"/>
+ </target>
+
+
+ <!-- =================================
+ target: ShellLink.Javah
+ ================================= -->
+ <target name="ShellLink.Javah"
+ depends="compile.installer"
+ description="--> rebuilds the shelllink jni *.h header file">
+ <javah class="com.izforge.izpack.util.os.ShellLink"
+ destdir="${basedir}/src/native/ShellLink">
+ <classpath path="${build.dir}"/>
+ </javah>
+ </target>
+
+
+ <!-- =================================
+ target: time - takes a timestamp
+ ================================= -->
+ <target name="time">
+ <tstamp/>
+ </target>
+
+
+ <!-- =================================
+ target: dump.properties - dumps the curent properties into the $os_$timestamp.properties file
+ ================================= -->
+ <target name="dump.properties" depends="time" description="dump.environment (for debug)">
+ <echoproperties
+ destfile="${basedir}/ant_properties_at_${os.name}-${os.arch}-${os.version}_at_${DSTAMP}-${TSTAMP}.txt"/>
+ </target>
+
+
+</project>
--- /dev/null
+<?xml version="1.0" encoding="utf-8" standalone="yes"?>\r
+<shortcuts>\r
+\r
+ <programGroup defaultName="Simantics/System Dynamics" location="applications"/>\r
+\r
+ <shortcut\r
+ name="Start Simantics System Dynamics"\r
+ target="$INSTALL_PATH\simantics-sysdyn\Simantics-Sysdyn.exe"\r
+ commandLine=""\r
+ workingDirectory="$INSTALL_PATH\simantics-sysdyn"\r
+ description="Starts Simantics System Dynamics"\r
+ initialState="normal"\r
+ iconFile="$INSTALL_PATH\simantics-sysdyn\puzzle_green.ico"\r
+ iconIndex="0"\r
+ programGroup="yes"\r
+ desktop="yes"\r
+ applications="no"\r
+ startMenu="yes"\r
+ startup="no">\r
+ <createForPack name="Simantics System Dynamics"/>\r
+ </shortcut>\r
+\r
+ <shortcut\r
+ name="Simantics System Dynamics Documentation"\r
+ programGroup="yes"\r
+ desktop="no"\r
+ applications="no"\r
+ startMenu="yes"\r
+ startup="no"\r
+ target="explorer"\r
+ workingDirectory=""\r
+ commandLine=""\r
+ initialState="noShow"\r
+ iconFile="help"\r
+ iconIndex="0"\r
+ url="https://www.simantics.org/end_user_wiki/index.php/Simantics_System_Dynamics"\r
+ type="Link"\r
+ encoding="UTF-8"\r
+ description="User documentation">\r
+ <createForPack name="Simantics System Dynamics"/>\r
+ </shortcut>\r
+\r
+ <shortcut\r
+ name="Uninstall Simantics System Dynamics"\r
+ programGroup="yes"\r
+ desktop="yes"\r
+ applications="no"\r
+ startMenu="no"\r
+ startup="no"\r
+ target="java"\r
+ commandLine="-jar\r
+ "$INSTALL_PATH/Uninstaller/uninstaller.jar""\r
+ initialState="noShow"\r
+ iconFile="trashcan_full"\r
+ iconIndex="0"\r
+ workingDirectory=""\r
+ type="Application"\r
+ encoding="UTF-8"\r
+ description="Simantics System Dynamics Uninstaller">\r
+ <createForPack name="Simantics System Dynamics"/>\r
+ </shortcut>\r
+\r
+</shortcuts>
\ No newline at end of file
--- /dev/null
+#!/bin/bash
+
+pushd .
+cd `dirname $0`
+BUILD=$1
+
+rm -f files/dist.zip
+cp -v ~/.hudson/jobs/${BUILD} files/dist.zip || exit -1
+
+popd > /dev/null
--- /dev/null
+@echo off\r
+\r
+setlocal\r
+pushd .\r
+cd %~dp0\r
+set BUILD=%1\r
+set JOB_NAME=%2\r
+\r
+del /s /q dist\r
+wget -O dist.zip "http://www.simantics.org/hudson/job/%JOB_NAME%/%BUILD%/artifact/build/dist/*zip*/dist.zip"\r
+unzip -o dist.zip\r
+del files\dist.zip\r
+copy dist\*sdk*.zip files\dist.zip\r
+del /s /q dist.zip dist\r
+\r
+popd\r
+endlocal\r
--- /dev/null
+@echo off\r
+"%~dp0Microsoft.VC90.CRT.setup.exe" /q
\ No newline at end of file
--- /dev/null
+<?xml version="1.0" encoding="utf-8" standalone="yes"?>
+<installation version="1.0">
+ <info>
+ <appname>Simantics System Dynamics</appname>
+ <appsubpath>Sysdyn</appsubpath>
+ <appversion>1.2</appversion>
+ <authors>
+ <author email="simantics-developers@simantics.org" name="VTT Technical Research Centre of Finland"/>
+ </authors>
+ <url>http://www.simantics.org</url>
+ <uninstaller name="Uninstaller.jar" write="yes"/>
+ <javaversion>1.6</javaversion>
+ <requiresjdk>no</requiresjdk>
+ <writeinstallationinformation>yes</writeinstallationinformation>
+ </info>
+ <installerrequirements>
+ <installerrequirement condition="izpack.windowsinstall" message="This installer only supports Windows operating systems."/>
+ </installerrequirements>
+ <guiprefs width="640" height="570" resizable="yes">
+ <laf name="substance">
+ <param name="variant" value="business"/>
+ <os family="windows"/>
+ <os family="unix"/>
+ <os family="mac"/>
+ </laf>
+ <modifier key="langDisplayType" value="default"/>
+ <modifier key="useHeadingPanel" value="yes"/>
+ <modifier key="headingImageOnLeft" value="yes"/>
+ <modifier key="useFlags" value="yes"/>
+ <modifier key="labelGap" value="2"/>
+ <!--<modifier key="layoutAnchor" value="NORTHWEST"/>-->
+ <modifier key="useButtonIcons" value="no"/>
+ <modifier key="useLabelIcons" value="no"/>
+ <modifier key="useHeadingForSummary" value="yes"/>
+ <modifier key="headingLineCount" value="1"/>
+ <modifier key="headingFontSize" value="1.5"/>
+ <modifier key="headingBackgroundColor" value="0x00ffffff"/>
+ <modifier key="headingPanelCounter" value="progressbar"/>
+ <modifier key="headingPanelCounterPos" value="inNavigationPanel"/>
+ </guiprefs>
+ <locale>
+ <langpack iso3="eng"/>
+ </locale>
+ <resources>
+ <res id="HTMLLicencePanel.licence" parse="yes" src="EPL.html"/>
+ <res id="Installer.image" src="side.png"/>
+ <res id="userInputSpec.xml" src="userInputSpec.xml" />
+ <res id="TargetPanel.dir.windows" src="TargetDir.txt.windows" />
+ <res id="TargetPanel.dir.unix" src="TargetDir.txt.unix" />
+ <res id="CustomLangpack.xml_eng" src="CustomLangpack_eng.xml" />
+ <res id="shortcutSpec.xml" src="default_shortcut_specification.xml" />
+ </resources>
+ <panels>
+ <panel classname="CheckedHelloPanel"/>
+ <panel classname="HTMLLicencePanel"/>
+ <panel classname="PacksPanel"/>
+ <panel classname="NonBlankTargetPanel"/>
+ <panel classname="SummaryPanel"/>
+ <panel classname="InstallPanel"/>
+ <!--<panel classname="ShortcutPanel"/>-->
+ <panel classname="FinishPanel"/>
+ </panels>
+ <variables>
+ <variable name="DesktopShortcutCheckboxEnabled" value="true"/>
+ <variable name="InstallerFrame.logfilePath" value="default"/>
+ </variables>
+ <packs>
+ <pack name="Java Runtime Environment 6" preselected="no" required="no">
+ <os family="windows"/>
+ <description>Simantics SDK requires an up-to-date version of the Java Runtime Environment version 6.
+If your JRE is old, you can install JRE 6 update 22 by selecting this.
+NOTE: Installing this will require network access for downloading Java components.
+Other Java installers are available at http://www.java.com/en/download/manual.jsp.</description>
+ <file override="update"
+ src="files/jre-6u22-windows-i586-iftw-rv.exe" targetdir="$INSTALL_PATH"/>
+ <executable failure="ask" keep="false" stage="postinstall" targetfile="$INSTALL_PATH/jre-6u22-windows-i586-iftw-rv.exe">
+ <os family="windows"/>
+ </executable>
+ </pack>
+ <pack name="Microsoft Visual C++ Run-Time" preselected="yes" required="yes">
+ <os family="windows"/>
+ <description>Microsoft Visual C++ Run-Time 9.0 libraries.
+These are required by native Simantics components.
+Nothing is done if these are already installed on your system.</description>
+ <file override="update"
+ src="files/Microsoft.VC90.CRT.setup.exe" targetdir="$INSTALL_PATH/external"/>
+ <file override="update"
+ src="files/install_msvcrt.bat" targetdir="$INSTALL_PATH/external"/>
+ <executable failure="ask" keep="true" stage="postinstall" targetfile="$INSTALL_PATH/external/install_msvcrt.bat">
+ <os family="windows"/>
+ </executable>
+ </pack>
+ <pack name="Simantics System Dynamics" preselected="yes" required="yes">
+ <os family="windows"/>
+ <description>The Simantics System Dynamics application.</description>
+ <depends packname="Microsoft Visual C++ Run-Time"/>
+ <file override="true" unpack="true"
+ src="files/dist.zip" targetdir="$INSTALL_PATH"/>
+ </pack>
+ </packs>
+ <native type="izpack" name="ShellLink.dll">
+ <os family="windows"/>
+ </native>
+</installation>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Created with Inkscape (http://www.inkscape.org/) -->
+
+<svg
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+ xmlns:cc="http://creativecommons.org/ns#"
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:svg="http://www.w3.org/2000/svg"
+ xmlns="http://www.w3.org/2000/svg"
+ xmlns:xlink="http://www.w3.org/1999/xlink"
+ xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+ xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+ width="744.09448819"
+ height="1052.3622047"
+ id="svg2"
+ version="1.1"
+ inkscape:version="0.47 r22583"
+ sodipodi:docname="New document 1">
+ <defs
+ id="defs4">
+ <linearGradient
+ id="linearGradient5042">
+ <stop
+ style="stop-color:#000000;stop-opacity:1;"
+ offset="0"
+ id="stop5044" />
+ <stop
+ style="stop-color:#8caed8;stop-opacity:1"
+ offset="1"
+ id="stop5046" />
+ </linearGradient>
+ <inkscape:perspective
+ sodipodi:type="inkscape:persp3d"
+ inkscape:vp_x="0 : 526.18109 : 1"
+ inkscape:vp_y="0 : 1000 : 0"
+ inkscape:vp_z="744.09448 : 526.18109 : 1"
+ inkscape:persp3d-origin="372.04724 : 350.78739 : 1"
+ id="perspective10" />
+ <radialGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient5042"
+ id="radialGradient5048"
+ cx="-538.94128"
+ cy="344.05646"
+ fx="-538.94128"
+ fy="344.05646"
+ r="347.30859"
+ gradientTransform="matrix(1.578967,0.43290519,-0.11724864,0.42764955,352.36941,430.23135)"
+ gradientUnits="userSpaceOnUse" />
+ </defs>
+ <sodipodi:namedview
+ id="base"
+ pagecolor="#ffffff"
+ bordercolor="#666666"
+ borderopacity="1.0"
+ inkscape:pageopacity="0.0"
+ inkscape:pageshadow="2"
+ inkscape:zoom="0.35"
+ inkscape:cx="-70.714286"
+ inkscape:cy="520"
+ inkscape:document-units="px"
+ inkscape:current-layer="layer1"
+ showgrid="false"
+ inkscape:window-width="1051"
+ inkscape:window-height="790"
+ inkscape:window-x="89"
+ inkscape:window-y="115"
+ inkscape:window-maximized="0" />
+ <metadata
+ id="metadata7">
+ <rdf:RDF>
+ <cc:Work
+ rdf:about="">
+ <dc:format>image/svg+xml</dc:format>
+ <dc:type
+ rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
+ <dc:title></dc:title>
+ </cc:Work>
+ </rdf:RDF>
+ </metadata>
+ <g
+ inkscape:label="Layer 1"
+ inkscape:groupmode="layer"
+ id="layer1">
+ <text
+ xml:space="preserve"
+ style="font-size:144px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:100%;writing-mode:lr-tb;text-anchor:start;fill:url(#radialGradient5048);fill-opacity:1;stroke:none;font-family:Segoe Print;-inkscape-font-specification:Segoe Print"
+ x="-892.578"
+ y="399.04083"
+ id="text2816"
+ sodipodi:linespacing="100%"
+ transform="matrix(0,-1,1,0,0,0)"><tspan
+ sodipodi:role="line"
+ id="tspan2818"
+ x="-892.578"
+ y="399.04083"
+ style="fill-opacity:1;fill:url(#radialGradient5048)">Simantics</tspan></text>
+ </g>
+</svg>
--- /dev/null
+<?xml version="1.0" encoding="utf-8" standalone="yes"?>\r
+<userInput>\r
+ <!-- Install -->\r
+ <panel order="0" layout="center">\r
+ <createForPack name="Simantics System Dynamics" />\r
+ <field type="title" txt="Select Installation Target" bold="true" size="1" />\r
+ <field type="staticText" align="left" txt="Select the installation path:"/>\r
+ <field type="dir" align="left" variable="TargetPanel.dir">\r
+ <spec txt="" size="35" set="$INSTALL_PATH$FILE_SEPARATOR$APP_VER" mustExist="false" />\r
+ <validator\r
+ class="com.izforge.izpack.util.RegularExpressionValidator"\r
+ txt="Sorry, installation path cannot contain spaces. Limited by OpenModelica and MinGW compiler.">\r
+ <param\r
+ name="pattern"\r
+ value="^(.*?/|.*?\\)?([^\./|^\.\\]+)(?:\.([^\\]*)|)$"\r
+ />\r
+ </validator> \r
+ </field>\r
+ </panel>\r
+</userInput>
\ No newline at end of file
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>\r
+<classpath>\r
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>\r
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>\r
+ <classpathentry kind="src" path="src"/>\r
+ <classpathentry kind="output" path="bin"/>\r
+</classpath>\r
--- /dev/null
+syntax: regexp\r
+^bin/\r
+\r
+syntax: glob\r
+*.svn/*
\ No newline at end of file
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>\r
+<projectDescription>\r
+ <name>org.simantics.h2d</name>\r
+ <comment></comment>\r
+ <projects>\r
+ </projects>\r
+ <buildSpec>\r
+ <buildCommand>\r
+ <name>org.eclipse.jdt.core.javabuilder</name>\r
+ <arguments>\r
+ </arguments>\r
+ </buildCommand>\r
+ <buildCommand>\r
+ <name>org.eclipse.pde.ManifestBuilder</name>\r
+ <arguments>\r
+ </arguments>\r
+ </buildCommand>\r
+ <buildCommand>\r
+ <name>org.eclipse.pde.SchemaBuilder</name>\r
+ <arguments>\r
+ </arguments>\r
+ </buildCommand>\r
+ </buildSpec>\r
+ <natures>\r
+ <nature>org.eclipse.pde.PluginNature</nature>\r
+ <nature>org.eclipse.jdt.core.javanature</nature>\r
+ </natures>\r
+</projectDescription>\r
--- /dev/null
+#Sun Nov 08 17:02:25 EET 2009\r
+eclipse.preferences.version=1\r
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled\r
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6\r
+org.eclipse.jdt.core.compiler.compliance=1.6\r
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error\r
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error\r
+org.eclipse.jdt.core.compiler.source=1.6\r
--- /dev/null
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: H2d
+Bundle-SymbolicName: org.simantics.h2d
+Bundle-Version: 1.0.0.qualifier
+Bundle-RequiredExecutionEnvironment: JavaSE-1.6
+Require-Bundle: org.simantics.scenegraph;bundle-version="0.9.0",
+ gnu.trove2;bundle-version="2.0.4",
+ org.simantics.objmap;bundle-version="0.1.0"
+Export-Package: org.simantics.h2d.action,
+ org.simantics.h2d.canvas,
+ org.simantics.h2d.diagram,
+ org.simantics.h2d.editor,
+ org.simantics.h2d.editor.impl,
+ org.simantics.h2d.element,
+ org.simantics.h2d.element.handler,
+ org.simantics.h2d.event,
+ org.simantics.h2d.event.handler,
+ org.simantics.h2d.node
--- /dev/null
+###############################################################################\r
+# Copyright (c) 2007, 2010 Association for Decentralized Information Management\r
+# in Industry THTH ry.\r
+# All rights reserved. This program and the accompanying materials\r
+# are made available under the terms of the Eclipse Public License v1.0\r
+# which accompanies this distribution, and is available at\r
+# http://www.eclipse.org/legal/epl-v10.html\r
+#\r
+# Contributors:\r
+# VTT Technical Research Centre of Finland - initial API and implementation\r
+###############################################################################\r
+source.. = src/\r
+output.. = bin/\r
+bin.includes = META-INF/,\\r
+ .\r
+src.includes = doc/\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2010 Association for Decentralized Information Management\r
+ * in Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.h2d.action;\r
+\r
+import org.simantics.h2d.event.handler.IEventHandler;\r
+import org.simantics.scenegraph.g2d.G2DParentNode;\r
+\r
+/**\r
+ * Action is a non-instantenous user operation on diagram. \r
+ * @see org.simantics.h2d.editor.IDiagramEditor#addAction\r
+ * @author Hannu Niemistö\r
+ */\r
+public interface IAction extends IEventHandler {\r
+ void init(G2DParentNode parent);\r
+ void remove();\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2010 Association for Decentralized Information Management\r
+ * in Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.h2d.canvas;\r
+\r
+import java.awt.Canvas;\r
+import java.awt.Color;\r
+import java.awt.Dimension;\r
+import java.awt.Graphics;\r
+import java.awt.Graphics2D;\r
+import java.awt.RenderingHints;\r
+import java.awt.event.ComponentAdapter;\r
+import java.awt.event.ComponentEvent;\r
+import java.awt.event.KeyEvent;\r
+import java.awt.event.KeyListener;\r
+import java.awt.event.MouseEvent;\r
+import java.awt.event.MouseListener;\r
+import java.awt.event.MouseMotionListener;\r
+import java.awt.event.MouseWheelEvent;\r
+import java.awt.event.MouseWheelListener;\r
+import java.awt.geom.Point2D;\r
+import java.awt.image.VolatileImage;\r
+\r
+import org.simantics.h2d.editor.IDiagramEditor;\r
+import org.simantics.h2d.event.ClickEvent;\r
+import org.simantics.h2d.event.DragEvent;\r
+import org.simantics.h2d.event.DragEventPhase;\r
+import org.simantics.h2d.event.KeyboardEvent;\r
+import org.simantics.h2d.event.Modifiers;\r
+import org.simantics.h2d.event.ReleaseEvent;\r
+import org.simantics.h2d.event.WheelEvent;\r
+import org.simantics.scenegraph.g2d.G2DRenderingHints;\r
+\r
+\r
+public class EditorCanvas extends Canvas {\r
+\r
+ private static final long serialVersionUID = -387207508390377519L;\r
+\r
+ IDiagramEditor editor;\r
+ EventHandler eventHandler = new EventHandler();\r
+ //BufferedImage background;\r
+\r
+ public EditorCanvas(IDiagramEditor editor) {\r
+ this.editor = editor;\r
+ editor.setCanvas(this);\r
+ \r
+ /*G2DSceneGraph sceneGraph = editor.getSceneGraph();\r
+ addMouseListener(sceneGraph);\r
+ addMouseMotionListener(sceneGraph);\r
+ addMouseWheelListener(sceneGraph);\r
+ addKeyListener(sceneGraph);\r
+ */\r
+ addMouseListener(eventHandler);\r
+ addMouseMotionListener(eventHandler);\r
+ addMouseWheelListener(eventHandler);\r
+ addKeyListener(eventHandler);\r
+ \r
+ addComponentListener(new ComponentAdapter() {\r
+ @Override\r
+ public void componentResized(ComponentEvent e) {\r
+ repaint();\r
+ }\r
+ });\r
+ \r
+ /*try {\r
+ background = ImageIO.read(new File("c:/paper.png"));\r
+ } catch (IOException e1) {\r
+ // TODO Auto-generated catch block\r
+ e1.printStackTrace();\r
+ }*/\r
+ }\r
+ \r
+ @Override\r
+ public void update(Graphics g) {\r
+ paint(g);\r
+ }\r
+ \r
+ private VolatileImage doubleBuffer;\r
+ @Override\r
+ public void paint(Graphics _g) { \r
+ do {\r
+ if (doubleBuffer == null\r
+ || doubleBuffer.getWidth() != getWidth()\r
+ || doubleBuffer.getHeight() != getHeight()\r
+ || doubleBuffer.validate(getGraphicsConfiguration()) == VolatileImage.IMAGE_INCOMPATIBLE)\r
+ {\r
+ doubleBuffer = createVolatileImage(getWidth(), getHeight());\r
+ editor.setViewDimensions(new Dimension(getWidth(), getHeight()));\r
+ }\r
+\r
+ Graphics2D g = (Graphics2D)doubleBuffer.getGraphics();\r
+\r
+ g.setBackground(Color.WHITE);\r
+ g.setColor(Color.WHITE);\r
+ //g.setPaint(new GradientPaint(0.f, 0.f, Color.white, 2000.f, 1600.f, Color.BLUE, false));\r
+ //g.setPaint(new TexturePaint(background, getBounds()));\r
+ g.fillRect(0, 0, doubleBuffer.getWidth(), doubleBuffer.getHeight());\r
+\r
+ g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);\r
+ g.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);\r
+ g.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);\r
+ g.setRenderingHint(G2DRenderingHints.KEY_CONTROL_BOUNDS, getBounds());\r
+\r
+ g.setClip(0, 0, getWidth(), getHeight());\r
+\r
+ editor.getSceneGraph().render(g);\r
+ g.dispose();\r
+ } while (doubleBuffer.contentsLost());\r
+\r
+ _g.drawImage(doubleBuffer, 0, 0, this);\r
+ }\r
+ \r
+ class EventHandler implements MouseListener, MouseMotionListener, MouseWheelListener, KeyListener {\r
+\r
+ DragEvent dragEvent;\r
+ \r
+ @Override\r
+ public void mouseClicked(MouseEvent e) {\r
+ ClickEvent event = new ClickEvent(\r
+ Modifiers.modifierString(e.getButton(), e.isControlDown(), e.isAltDown(), e.isShiftDown()),\r
+ editor.screenToDiagram(e.getPoint()),\r
+ e.getLocationOnScreen()\r
+ );\r
+ event.pickedElements = dragEvent.pickedElements;\r
+ editor.handleEvent(event);\r
+ }\r
+\r
+ @Override\r
+ public void mouseEntered(MouseEvent e) {\r
+ // TODO Auto-generated method stub\r
+ \r
+ }\r
+\r
+ @Override\r
+ public void mouseExited(MouseEvent e) {\r
+ // TODO Auto-generated method stub\r
+ \r
+ }\r
+\r
+ @Override\r
+ public void mousePressed(MouseEvent e) {\r
+ editor.getSceneGraph().mousePressed(e);\r
+ if(e.isConsumed())\r
+ return;\r
+ dragEvent = new DragEvent(\r
+ Modifiers.modifierString(e.getButton(), e.isControlDown(), e.isAltDown(), e.isShiftDown()),\r
+ editor.screenToDiagram(e.getPoint())\r
+ );\r
+ dragEvent.pickedElements = editor.pickElements(dragEvent.start);\r
+ }\r
+\r
+ @Override\r
+ public void mouseReleased(MouseEvent e) {\r
+ editor.getSceneGraph().mouseReleased(e);\r
+ if(e.isConsumed())\r
+ return;\r
+ if(dragEvent != null && dragEvent.phase == DragEventPhase.dragUpdate) {\r
+ dragEvent.phase = DragEventPhase.dragEnd;\r
+ editor.handleEvent(dragEvent);\r
+ } \r
+ \r
+ if(dragEvent != null) {\r
+ ReleaseEvent event = new ReleaseEvent(\r
+ Modifiers.modifierString(e.getButton(), e.isControlDown(), e.isAltDown(), e.isShiftDown()),\r
+ editor.screenToDiagram(e.getPoint()),\r
+ e.getLocationOnScreen()\r
+ );\r
+ \r
+ event.pickedElements = dragEvent.pickedElements;\r
+ editor.handleEvent(event);\r
+ }\r
+ }\r
+\r
+ @Override\r
+ public void mouseDragged(MouseEvent e) {\r
+ editor.getSceneGraph().mouseDragged(e);\r
+ if(e.isConsumed())\r
+ return;\r
+ currentPosition = e.getPoint();\r
+ if(dragEvent != null) { // TODO why this is needed?\r
+ dragEvent.currentModifiers = \r
+ Modifiers.modifierString(e.getButton(), e.isControlDown(), e.isAltDown(), e.isShiftDown());\r
+ dragEvent.current = editor.screenToDiagram(e.getPoint());\r
+ }\r
+ editor.handleEvent(dragEvent);\r
+\r
+ if(dragEvent != null && dragEvent.phase == DragEventPhase.dragBegin) {\r
+ dragEvent.phase = DragEventPhase.dragUpdate;\r
+ editor.handleEvent(dragEvent);\r
+ }\r
+ }\r
+ \r
+ Point2D currentPosition = new Point2D.Double(0.0, 0.0);\r
+\r
+ @Override\r
+ public void mouseMoved(MouseEvent e) {\r
+ currentPosition = e.getPoint();\r
+ }\r
+\r
+ @Override\r
+ public void mouseWheelMoved(MouseWheelEvent e) {\r
+ editor.handleEvent(new WheelEvent(\r
+ Modifiers.modifierString(e.getButton(), e.isControlDown(), e.isAltDown(), e.isShiftDown()),\r
+ editor.screenToDiagram(e.getPoint()),\r
+ e.getWheelRotation()\r
+ ));\r
+ }\r
+\r
+ @Override\r
+ public void keyPressed(KeyEvent e) {\r
+ editor.getSceneGraph().keyPressed(e);\r
+ if(e.isConsumed())\r
+ return;\r
+ \r
+ String keyText = KeyEvent.getKeyText(e.getKeyCode());\r
+ if(e.getModifiers() != 0)\r
+ keyText = KeyEvent.getKeyModifiersText(e.getModifiers()) \r
+ + "+" + keyText;\r
+ KeyboardEvent event = new KeyboardEvent(\r
+ keyText,\r
+ editor.screenToDiagram(currentPosition)\r
+ );\r
+ event.pickedElements = editor.pickElements(event.point);\r
+ if(editor.handleEvent(event))\r
+ e.consume();\r
+ }\r
+\r
+ @Override\r
+ public void keyReleased(KeyEvent e) {\r
+ editor.getSceneGraph().keyReleased(e);\r
+ }\r
+\r
+ @Override\r
+ public void keyTyped(KeyEvent e) {\r
+ editor.getSceneGraph().keyTyped(e);\r
+ } \r
+ }\r
+\r
+ public IDiagramEditor getEditor() {\r
+ return editor;\r
+ }\r
+ \r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2010 Association for Decentralized Information Management\r
+ * in Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.h2d.diagram;\r
+\r
+import java.util.ArrayList;\r
+import java.util.List;\r
+import java.util.Vector;\r
+\r
+import org.simantics.h2d.element.IElement;\r
+import org.simantics.objmap.annotations.GraphType;\r
+import org.simantics.objmap.annotations.RelatedValue;\r
+\r
+@GraphType("http://www.simantics.org/Sysdyn-1.0/Configuration")\r
+public class Diagram implements IDiagram {\r
+\r
+ @RelatedValue("http://www.simantics.org/Layer0-1.0/ConsistsOf")\r
+ public List<IElement> elements = new Vector<IElement>();\r
+ ArrayList<IDiagramListener> listeners = new ArrayList<IDiagramListener>();\r
+ \r
+ @Override\r
+ public void addElement(IElement element) {\r
+ elements.add(element);\r
+ for(IDiagramListener listener : listeners)\r
+ listener.elementAdded(element);\r
+ }\r
+\r
+ @Override\r
+ public List<IElement> getElements() {\r
+ return elements;\r
+ }\r
+\r
+ @Override\r
+ public void addDiagramListener(IDiagramListener listener) {\r
+ listeners.add(listener);\r
+ }\r
+\r
+ @Override\r
+ public void removeElement(IElement element) {\r
+ elements.remove(element);\r
+ for(IDiagramListener listener : listeners)\r
+ listener.elementRemoved(element);\r
+ }\r
+\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2010 Association for Decentralized Information Management\r
+ * in Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.h2d.diagram;\r
+\r
+import java.util.List;\r
+\r
+import org.simantics.h2d.element.IElement;\r
+\r
+/**\r
+ * Diagram is the whole that is edited in a diagram editor.\r
+ * @author Hannu Niemistö\r
+ */\r
+public interface IDiagram {\r
+ List<IElement> getElements();\r
+ void addElement(IElement element);\r
+ void removeElement(IElement element);\r
+ void addDiagramListener(IDiagramListener listener); \r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2010 Association for Decentralized Information Management\r
+ * in Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.h2d.diagram;\r
+\r
+import org.simantics.h2d.element.IElement;\r
+\r
+public interface IDiagramListener {\r
+\r
+ void elementAdded(IElement element);\r
+ void elementRemoved(IElement element);\r
+ \r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2010 Association for Decentralized Information Management\r
+ * in Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.h2d.editor;\r
+\r
+import java.awt.Canvas;\r
+import java.awt.Dimension;\r
+import java.awt.geom.AffineTransform;\r
+import java.awt.geom.Dimension2D;\r
+import java.awt.geom.Point2D;\r
+import java.util.List;\r
+\r
+import org.simantics.h2d.action.IAction;\r
+import org.simantics.h2d.diagram.IDiagram;\r
+import org.simantics.h2d.element.IElement;\r
+import org.simantics.h2d.event.IEvent;\r
+import org.simantics.h2d.event.handler.IEventHandler;\r
+import org.simantics.scenegraph.g2d.G2DSceneGraph;\r
+\r
+public interface IDiagramEditor {\r
+\r
+ IDiagram getDiagram();\r
+ \r
+ /**\r
+ * Returns the root of the scenegraph that renders the diagram.\r
+ */\r
+ G2DSceneGraph getSceneGraph();\r
+ \r
+ /**\r
+ * Handles an external event. \r
+ * @return True if the event was consumed.\r
+ */\r
+ boolean handleEvent(IEvent event);\r
+ \r
+ /** \r
+ * Returns the current view transform (from diagram coordinates to screen coordinates) defined as:\r
+ * <pre>diagramToScreen(p) = (p - offset) / scale</pre>\r
+ */\r
+ AffineTransform getViewTransform();\r
+ \r
+ /**\r
+ * Returns the current view offset. That is the diagram coordinates of the top left point of the canvas.\r
+ */\r
+ Point2D getOffset();\r
+ \r
+ /**\r
+ * Returns the current view scale. That is <pre>lengthInDiagramCoordinates / lengthInScreenCoordinates</pre>.\r
+ */\r
+ double getScale();\r
+ \r
+ /**\r
+ * Maps a point from screen coordinates to diagram coordinates.\r
+ */\r
+ Point2D screenToDiagram(Point2D point);\r
+ \r
+ /**\r
+ * Sets a new view transform. \r
+ * @param offset New offset\r
+ * @param scale New scale\r
+ *\r
+ * @see #getOffset\r
+ * @see #getScale\r
+ */\r
+ void setViewTransform(Point2D offset, double scale);\r
+ \r
+ void setViewDimensions(Dimension2D dimension);\r
+ Dimension getViewDimension();\r
+ \r
+ // Events\r
+ void addEventHandler(int priority, String eventType, IEventHandler handler);\r
+ void addEventHandler(int priority, IEventHandler handler);\r
+ \r
+ void addAction(IAction action);\r
+ void removeAction(IAction action);\r
+ \r
+ void requestRepaint();\r
+ void setCanvas(Canvas canvas);\r
+ \r
+ /**\r
+ * Returns current selection\r
+ */\r
+ ISelection getSelection();\r
+\r
+ /**\r
+ * Returns all elements at the point. Pick uses a hard coded tolerance that is calculated in screen coordinates.\r
+ */\r
+ List<IElement> pickElements(Point2D point); \r
+ \r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2010 Association for Decentralized Information Management\r
+ * in Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.h2d.editor;\r
+\r
+import java.util.Collection;\r
+\r
+import org.simantics.h2d.element.IElement;\r
+\r
+public interface ISelection extends Iterable<IElement> {\r
+\r
+ boolean contains(IElement el);\r
+ boolean containsOneOf(Collection<IElement> els);\r
+ void clear();\r
+ void set(Collection<IElement> els);\r
+ void set(IElement el);\r
+ boolean add(IElement el);\r
+ boolean addAll(Collection<IElement> els);\r
+ boolean toggle(IElement el);\r
+ boolean remove(IElement el);\r
+ boolean isEmpty();\r
+ int size();\r
+ IElement getSingleElement();\r
+\r
+ void addSelectionListener(ISelectionListener listener);\r
+ void removeSelectionListener(ISelectionListener listener);\r
+ \r
+}
\ No newline at end of file
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2010 Association for Decentralized Information Management\r
+ * in Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.h2d.editor;\r
+\r
+public interface ISelectionListener {\r
+\r
+ void selectionChanged(ISelection selection);\r
+ \r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2010 Association for Decentralized Information Management\r
+ * in Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.h2d.editor.impl;\r
+\r
+import java.awt.Canvas;\r
+import java.awt.Dimension;\r
+import java.awt.geom.AffineTransform;\r
+import java.awt.geom.Dimension2D;\r
+import java.awt.geom.Point2D;\r
+import java.util.ArrayList;\r
+import java.util.List;\r
+\r
+import javax.swing.JComponent;\r
+\r
+import org.simantics.h2d.action.IAction;\r
+import org.simantics.h2d.diagram.IDiagram;\r
+import org.simantics.h2d.diagram.IDiagramListener;\r
+import org.simantics.h2d.editor.IDiagramEditor;\r
+import org.simantics.h2d.editor.ISelection;\r
+import org.simantics.h2d.element.IElement;\r
+import org.simantics.h2d.event.IEvent;\r
+import org.simantics.h2d.event.handler.IEventHandler;\r
+import org.simantics.scenegraph.g2d.G2DSceneGraph;\r
+\r
+public class DiagramEditor implements IDiagramEditor {\r
+\r
+ public static final double PICK_TOLERANCE = 5.0;\r
+\r
+ IDiagram diagram;\r
+ \r
+ // Viewpoint\r
+ Point2D offset;\r
+ double scale;\r
+ AffineTransform viewTransform = new AffineTransform();\r
+ Dimension dimension = new Dimension(800, 600);\r
+ \r
+ ISelection selection;\r
+ \r
+ ArrayList<IAction> actionStack = new ArrayList<IAction>(); \r
+ \r
+ SceneGraphManager sgManager;\r
+ EventHandlerManager eventHandlerManager = new EventHandlerManager();\r
+ \r
+ Canvas canvas;\r
+ \r
+ public void setCanvas(Canvas canvas) {\r
+ this.canvas = canvas;\r
+ }\r
+ \r
+ public DiagramEditor(JComponent rootPane, IDiagram diagram) {\r
+ this.diagram = diagram;\r
+ sgManager = new SceneGraphManager(rootPane); \r
+ \r
+ setViewTransform(new Point2D.Double(), 13.0 / 48.0);\r
+ sgManager.setViewTransform(viewTransform);\r
+ \r
+ selection = new Selection(sgManager.selectionNode);\r
+ \r
+ for(IElement element : diagram.getElements())\r
+ element.init(sgManager.elementsNode);\r
+ diagram.addDiagramListener(new IDiagramListener() {\r
+ \r
+ @Override\r
+ public void elementAdded(IElement element) {\r
+ element.init(sgManager.elementsNode);\r
+ }\r
+\r
+ @Override\r
+ public void elementRemoved(IElement element) {\r
+ element.remove();\r
+ }\r
+ \r
+ });\r
+ } \r
+ \r
+ @Override\r
+ public G2DSceneGraph getSceneGraph() {\r
+ return sgManager.sceneGraph;\r
+ }\r
+\r
+ @Override\r
+ public boolean handleEvent(IEvent event) {\r
+ for(int i=actionStack.size()-1;i>=0;--i)\r
+ if(actionStack.get(i).handle(this, event))\r
+ return true;\r
+ return eventHandlerManager.handle(this, event); \r
+ }\r
+\r
+ @Override\r
+ public void addEventHandler(int priority, String eventType, IEventHandler handler) {\r
+ eventHandlerManager.addEventHandler(priority, eventType, handler);\r
+ }\r
+\r
+ @Override\r
+ public void addEventHandler(int priority, IEventHandler handler) {\r
+ eventHandlerManager.addEventHandler(priority, handler);\r
+ }\r
+\r
+ @Override\r
+ public ISelection getSelection() {\r
+ return selection;\r
+ }\r
+\r
+ @Override\r
+ public Point2D getOffset() {\r
+ return offset;\r
+ }\r
+\r
+ @Override\r
+ public double getScale() {\r
+ return scale;\r
+ }\r
+\r
+ @Override\r
+ public AffineTransform getViewTransform() {\r
+ return viewTransform;\r
+ }\r
+ \r
+ @Override\r
+ public void setViewTransform(Point2D offset, double scale) {\r
+ this.offset = offset;\r
+ this.scale = scale;\r
+ viewTransform.setTransform(1.0/scale, 0.0, 0.0, 1.0/scale, \r
+ -offset.getX()/scale, -offset.getY()/scale);\r
+ }\r
+\r
+ @Override\r
+ public Point2D screenToDiagram(Point2D point) {\r
+ return new Point2D.Double(point.getX()*scale + offset.getX(), point.getY()*scale + offset.getY());\r
+ }\r
+\r
+ @Override\r
+ public IDiagram getDiagram() {\r
+ return diagram;\r
+ }\r
+\r
+ @Override\r
+ public List<IElement> pickElements(Point2D point) {\r
+ double tolerance = PICK_TOLERANCE*scale;\r
+ ArrayList<IElement> result = new ArrayList<IElement>();\r
+ for(IElement element : getDiagram().getElements()) { \r
+ if(element.hitTest(point.getX(), point.getY(), tolerance))\r
+ result.add(element);\r
+ }\r
+ return result;\r
+ }\r
+\r
+ @Override\r
+ public void addAction(IAction action) {\r
+ actionStack.add(action);\r
+ action.init(sgManager.actionNode);\r
+ requestRepaint();\r
+ }\r
+ \r
+ @Override\r
+ public void removeAction(IAction action) {\r
+ actionStack.remove(action);\r
+ action.remove();\r
+ requestRepaint();\r
+ }\r
+\r
+ @Override\r
+ public Dimension getViewDimension() {\r
+ return dimension;\r
+ }\r
+\r
+ @Override\r
+ public void setViewDimensions(Dimension2D dimension) {\r
+ this.dimension.setSize(dimension);\r
+ }\r
+\r
+ @Override\r
+ public void requestRepaint() {\r
+ canvas.repaint();\r
+ }\r
+ \r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2010 Association for Decentralized Information Management\r
+ * in Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.h2d.editor.impl;\r
+\r
+import gnu.trove.THashMap;\r
+\r
+import java.util.LinkedList;\r
+import java.util.ListIterator;\r
+\r
+import org.simantics.h2d.editor.IDiagramEditor;\r
+import org.simantics.h2d.event.IEvent;\r
+import org.simantics.h2d.event.handler.IEventHandler;\r
+\r
+class EventHandlerManager implements IEventHandler {\r
+ LinkedList<PrioritizedEventHandler> handlers = new LinkedList<PrioritizedEventHandler>();\r
+ \r
+ public void addEventHandler(int priority, String eventType, IEventHandler handler) {\r
+ ListIterator<PrioritizedEventHandler> it = handlers.listIterator();\r
+ while(it.hasNext()) {\r
+ PrioritizedEventHandler group = it.next();\r
+ if(group.priority == priority)\r
+ group.put(eventType, handler);\r
+ else if(group.priority < priority) {\r
+ it.previous();\r
+ break;\r
+ }\r
+ }\r
+ \r
+ // Add a new level\r
+ MapEventHandler map = new MapEventHandler(priority);\r
+ map.put(eventType, handler);\r
+ it.add(map);\r
+ }\r
+\r
+ public void addEventHandler(int priority, IEventHandler handler) {\r
+ ListIterator<PrioritizedEventHandler> it = handlers.listIterator();\r
+ while(it.hasNext()) {\r
+ PrioritizedEventHandler group = it.next();\r
+ if(group.priority == priority)\r
+ throw new IllegalArgumentException("Tried add an event handler of type of priority " + priority + \r
+ ", but this conflicts with an event handler(s) with the same priority.");\r
+ else if(group.priority < priority) {\r
+ it.previous();\r
+ break;\r
+ }\r
+ }\r
+ \r
+ // Add a new level\r
+ it.add(new SingletonEventHandler(priority, handler));\r
+ }\r
+ \r
+ static abstract class PrioritizedEventHandler {\r
+ public final int priority;\r
+\r
+ public PrioritizedEventHandler(int priority) { \r
+ this.priority = priority;\r
+ }\r
+\r
+ public abstract void put(String type, IEventHandler handler);\r
+ public abstract boolean handle(String type, IDiagramEditor editor, IEvent event);\r
+ \r
+ }\r
+ \r
+ static class SingletonEventHandler extends PrioritizedEventHandler {\r
+\r
+ IEventHandler handler;\r
+ \r
+ public SingletonEventHandler(int priority, IEventHandler handler) {\r
+ super(priority);\r
+ this.handler = handler;\r
+ }\r
+\r
+ @Override\r
+ public boolean handle(String type, IDiagramEditor editor, IEvent event) {\r
+ return handler.handle(editor, event);\r
+ }\r
+\r
+ @Override\r
+ public void put(String type, IEventHandler handler) {\r
+ throw new IllegalArgumentException("Tried add an event handler of type " + type + " and priority " + priority + \r
+ ", but this conflicts with an event handler with the same priority."); \r
+ }\r
+\r
+ }\r
+ \r
+ static class MapEventHandler extends PrioritizedEventHandler {\r
+\r
+ THashMap<String, IEventHandler> handlers = new THashMap<String, IEventHandler>();\r
+ public MapEventHandler(int priority) {\r
+ super(priority);\r
+ } \r
+ \r
+ @Override\r
+ public void put(String type, IEventHandler handler) {\r
+ if(handlers.contains(type))\r
+ throw new IllegalArgumentException("Tried add an event handler of type " + type + " and priority " + priority + \r
+ ", but this conflicts with an event handler with the same priority and type.");\r
+ handlers.put(type, handler);\r
+ }\r
+ \r
+ @Override\r
+ public boolean handle(String type, IDiagramEditor editor, IEvent event) {\r
+ IEventHandler handler = handlers.get(type);\r
+ return handler != null && handler.handle(editor, event);\r
+ }\r
+\r
+ }\r
+\r
+ @Override\r
+ public boolean handle(IDiagramEditor editor, IEvent event) {\r
+ String type = event.getType();\r
+ for(PrioritizedEventHandler level : handlers) {\r
+ if(level.handle(type, editor, event))\r
+ return true; \r
+ } \r
+ return false;\r
+ }\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2010 Association for Decentralized Information Management\r
+ * in Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.h2d.editor.impl;\r
+\r
+import java.awt.geom.AffineTransform;\r
+import java.awt.geom.Rectangle2D;\r
+\r
+import javax.swing.JComponent;\r
+\r
+import org.simantics.scenegraph.g2d.G2DParentNode;\r
+import org.simantics.scenegraph.g2d.G2DSceneGraph;\r
+import org.simantics.scenegraph.g2d.nodes.PageBorderNode;\r
+import org.simantics.scenegraph.g2d.nodes.TransformNode;\r
+\r
+class SceneGraphManager {\r
+ G2DSceneGraph sceneGraph;\r
+ TransformNode diagramCoordinatesNode;\r
+ G2DParentNode elementsNode;\r
+ G2DParentNode selectionNode;\r
+ G2DParentNode actionNode;\r
+\r
+ public SceneGraphManager(JComponent rootPane) {\r
+ sceneGraph = new G2DSceneGraph();\r
+ //sceneGraph.setRootPane(rootPane);\r
+ diagramCoordinatesNode = sceneGraph.addNode(TransformNode.class);\r
+\r
+ PageBorderNode border = diagramCoordinatesNode.addNode(PageBorderNode.class);\r
+ border.init(new Rectangle2D.Double(0.0, 0.0, 297.0, 210.0), new Rectangle2D.Double(10.0, 10.0, 277.0, 190.0), Boolean.TRUE);\r
+\r
+ elementsNode = diagramCoordinatesNode.addNode(G2DParentNode.class);\r
+ elementsNode.setZIndex(0);\r
+\r
+ selectionNode = diagramCoordinatesNode.addNode(G2DParentNode.class);\r
+ selectionNode.setZIndex(1);\r
+\r
+ actionNode = diagramCoordinatesNode.addNode(G2DParentNode.class);\r
+ actionNode.setZIndex(2);\r
+ }\r
+\r
+ void setViewTransform(AffineTransform viewTransform) {\r
+ diagramCoordinatesNode.setTransform(viewTransform);\r
+ }\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2010 Association for Decentralized Information Management\r
+ * in Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.h2d.editor.impl;\r
+\r
+import gnu.trove.THashSet;\r
+\r
+import java.awt.Color;\r
+import java.awt.geom.AffineTransform;\r
+import java.awt.geom.Rectangle2D;\r
+import java.util.ArrayList;\r
+import java.util.Collection;\r
+import java.util.Iterator;\r
+import java.util.concurrent.CopyOnWriteArrayList;\r
+\r
+import org.simantics.h2d.editor.ISelection;\r
+import org.simantics.h2d.editor.ISelectionListener;\r
+import org.simantics.h2d.element.IElement;\r
+import org.simantics.h2d.element.IElementListener;\r
+import org.simantics.scenegraph.g2d.G2DParentNode;\r
+import org.simantics.scenegraph.g2d.nodes.SelectionNode;\r
+\r
+class Selection implements ISelection {\r
+ static final AffineTransform IDENTITY = new AffineTransform();\r
+ \r
+ THashSet<IElement> elements = new THashSet<IElement>();\r
+ G2DParentNode selectionParentNode; \r
+ \r
+ CopyOnWriteArrayList<ISelectionListener> listeners = \r
+ new CopyOnWriteArrayList<ISelectionListener>();\r
+ \r
+ static class SelectionUpdater implements IElementListener {\r
+ SelectionNode node;\r
+ IElement element;\r
+ \r
+ public SelectionUpdater(SelectionNode node, IElement element) {\r
+ this.node = node;\r
+ this.element = element;\r
+ \r
+ elementUpdated(element); \r
+ element.addListener(this);\r
+ }\r
+\r
+ @Override\r
+ public void elementUpdated(IElement element) {\r
+ Rectangle2D bounds = new Rectangle2D.Double();\r
+ element.getBounds(bounds);\r
+ node.init(IDENTITY, bounds, Color.GRAY);\r
+ } \r
+ \r
+ public void remove() {\r
+ element.removeListener(this);\r
+ }\r
+\r
+ @Override\r
+ public void elementRemoved(IElement element) {\r
+ // TODO ?\r
+ }\r
+ \r
+ }\r
+ \r
+ ArrayList<SelectionUpdater> updaters = new ArrayList<SelectionUpdater>();\r
+ \r
+ public Selection(G2DParentNode selectionParentNode) {\r
+ this.selectionParentNode = selectionParentNode;\r
+ } \r
+ \r
+ private void updateSceneGraph() { \r
+ // Clear old selection\r
+ selectionParentNode.removeNodes();\r
+ for(SelectionUpdater updater : updaters)\r
+ updater.remove();\r
+ updaters.clear();\r
+ \r
+ // Create new selection\r
+ //System.out.println("selection: " + elements.size());\r
+ for(IElement element : elements)\r
+ updaters.add(new SelectionUpdater(selectionParentNode.addNode(SelectionNode.class), element));\r
+ \r
+ // Notify listeners\r
+ // TODO this is in wrong place\r
+ for(ISelectionListener listener : listeners)\r
+ listener.selectionChanged(this);\r
+ } \r
+\r
+ public boolean contains(IElement el) {\r
+ return elements.contains(el);\r
+ }\r
+ \r
+ public boolean containsOneOf(Collection<IElement> els) {\r
+ for(IElement el : els)\r
+ if(elements.contains(el))\r
+ return true;\r
+ return false;\r
+ }\r
+ \r
+ public void clear() {\r
+ if(!elements.isEmpty()) {\r
+ elements.clear();\r
+ updateSceneGraph();\r
+ }\r
+ }\r
+ \r
+ public void set(Collection<IElement> els) {\r
+ elements.clear();\r
+ elements.addAll(els);\r
+ updateSceneGraph();\r
+ }\r
+ \r
+ public void set(IElement el) {\r
+ elements.clear();\r
+ elements.add(el);\r
+ updateSceneGraph();\r
+ }\r
+ \r
+ public boolean add(IElement el) {\r
+ boolean result = elements.add(el);\r
+ updateSceneGraph();\r
+ return result;\r
+ }\r
+ \r
+ public boolean addAll(Collection<IElement> els) {\r
+ boolean result = elements.addAll(els);\r
+ updateSceneGraph();\r
+ return result;\r
+ }\r
+ \r
+ public boolean toggle(IElement el) {\r
+ if(elements.contains(el)) {\r
+ elements.remove(el);\r
+ updateSceneGraph();\r
+ return false;\r
+ }\r
+ else {\r
+ elements.add(el);\r
+ updateSceneGraph();\r
+ return true;\r
+ }\r
+ }\r
+ \r
+ public boolean remove(IElement el) {\r
+ boolean result = elements.remove(el);\r
+ updateSceneGraph();\r
+ return result;\r
+ }\r
+\r
+ @Override\r
+ public Iterator<IElement> iterator() {\r
+ return elements.iterator();\r
+ }\r
+\r
+ @Override\r
+ public boolean isEmpty() {\r
+ return elements.isEmpty();\r
+ }\r
+\r
+ @Override\r
+ public int size() {\r
+ return elements.size();\r
+ }\r
+\r
+ @Override\r
+ public IElement getSingleElement() {\r
+ for(IElement element : elements)\r
+ return element;\r
+ return null;\r
+ }\r
+\r
+ @Override\r
+ public void addSelectionListener(ISelectionListener listener) {\r
+ listeners.add(listener);\r
+ }\r
+\r
+ @Override\r
+ public void removeSelectionListener(ISelectionListener listener) {\r
+ listeners.remove(listener); \r
+ }\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2010 Association for Decentralized Information Management\r
+ * in Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.h2d.element;\r
+\r
+\r
+class ChainingElementListener implements IElementListener {\r
+ IElementListener listener1;\r
+ IElementListener listener2;\r
+ \r
+ ChainingElementListener(IElementListener listener1,\r
+ IElementListener listener2) {\r
+ this.listener1 = listener1;\r
+ this.listener2 = listener2;\r
+ }\r
+\r
+ @Override\r
+ public void elementUpdated(IElement element) {\r
+ listener1.elementUpdated(element);\r
+ listener2.elementUpdated(element); \r
+ }\r
+\r
+ @Override\r
+ public void elementRemoved(IElement element) {\r
+ listener1.elementRemoved(element);\r
+ listener2.elementRemoved(element); \r
+ }\r
+ \r
+ static IElementListener addListener(IElementListener currentListener, IElementListener newListener) {\r
+ if(currentListener == null)\r
+ return newListener;\r
+ else \r
+ return new ChainingElementListener(currentListener, newListener);\r
+ }\r
+ \r
+ static IElementListener removeListener(IElementListener currentListener, IElementListener listenerToRemove) {\r
+ if(currentListener == null || currentListener == listenerToRemove)\r
+ return null;\r
+ else if(currentListener instanceof ChainingElementListener) {\r
+ ChainingElementListener chain = (ChainingElementListener)currentListener;\r
+ if(chain.listener2 == listenerToRemove)\r
+ return chain.listener1;\r
+ else {\r
+ IElementListener l = removeListener(chain.listener1, listenerToRemove);\r
+ if(l == null)\r
+ return chain.listener2;\r
+ chain.listener1 = l;\r
+ }\r
+ }\r
+ return currentListener;\r
+ }\r
+ \r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2010 Association for Decentralized Information Management\r
+ * in Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.h2d.element;\r
+\r
+\r
+public abstract class Element implements IElement {\r
+\r
+ IElementListener listener;\r
+ \r
+ @SuppressWarnings("unchecked")\r
+ @Override\r
+ public <T> T getInterface(Class<T> clazz) {\r
+ if(clazz.isInstance(this))\r
+ return (T) this;\r
+ return null;\r
+ }\r
+ \r
+ protected void fireElementUpdated() {\r
+ if(listener != null)\r
+ listener.elementUpdated(this);\r
+ }\r
+\r
+ @Override\r
+ public void addListener(IElementListener listener) {\r
+ this.listener = ChainingElementListener.addListener(this.listener, listener);\r
+ }\r
+ \r
+ @Override\r
+ public void removeListener(IElementListener listener) {\r
+ this.listener = ChainingElementListener.removeListener(this.listener, listener);\r
+ }\r
+ \r
+ @Override\r
+ public void remove() {\r
+ if(listener != null)\r
+ listener.elementRemoved(this);\r
+ }\r
+\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2010 Association for Decentralized Information Management\r
+ * in Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.h2d.element;\r
+\r
+import java.awt.geom.Rectangle2D;\r
+\r
+import org.simantics.scenegraph.g2d.G2DParentNode;\r
+\r
+/**\r
+ * Element is a part of a diagram that has its own type and properties.\r
+ * @author Hannu Niemistö\r
+ */\r
+public interface IElement {\r
+ <T> T getInterface(Class<T> clazz);\r
+ \r
+ void init(G2DParentNode parent);\r
+ void remove();\r
+ \r
+ /**\r
+ * Updates the parameter <code>bounds</code> so that it contains \r
+ * the bounding box of the element. \r
+ */\r
+ void getBounds(Rectangle2D bounds);\r
+ \r
+ /**\r
+ * Returns true, if the interior of the element intersects\r
+ * a circle at <code>(x,y)</code> with radius <code>tolerance</code>.\r
+ * Returns false, if the element and a circle at <code>(x,y)</code> with \r
+ * radius <code>sqrt(2)*tolerance</code> are disjoint. Otherwise may return true\r
+ * or false depending on the implementation.\r
+ */\r
+ boolean hitTest(double x, double y, double tolerance);\r
+ \r
+ void addListener(IElementListener listener);\r
+ void removeListener(IElementListener listener);\r
+ \r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2010 Association for Decentralized Information Management\r
+ * in Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.h2d.element;\r
+\r
+\r
+public interface IElementListener {\r
+ /**\r
+ * Called when the publicy available properties of the elements are changed.\r
+ * @param element\r
+ */\r
+ public void elementUpdated(IElement element);\r
+ \r
+ public void elementRemoved(IElement element);\r
+ \r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2010 Association for Decentralized Information Management\r
+ * in Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.h2d.element.handler;\r
+\r
+import java.awt.geom.Point2D;\r
+import java.awt.geom.Rectangle2D;\r
+\r
+import org.simantics.h2d.element.IElement;\r
+\r
+\r
+\r
+public interface Connectable extends IElementHandler, IElement {\r
+\r
+ void getBounds(Rectangle2D bounds);\r
+ Point2D getOrigo();\r
+ \r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2010 Association for Decentralized Information Management\r
+ * in Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.h2d.element.handler;\r
+\r
+/**\r
+ * The base interface of all element handler interfaces. Needed only for\r
+ * documenting purposes.\r
+ * @author Hannu Niemistö\r
+ */\r
+public interface IElementHandler {\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2010 Association for Decentralized Information Management\r
+ * in Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.h2d.element.handler;\r
+\r
+\r
+\r
+public interface Movable extends IElementHandler {\r
+\r
+ /**\r
+ * Moves the element by the given delta.\r
+ */\r
+ void move(double deltaX, double deltaY);\r
+ \r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2010 Association for Decentralized Information Management\r
+ * in Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.h2d.element.handler;\r
+\r
+\r
+\r
+public interface Rotatable extends IElementHandler {\r
+\r
+ /**\r
+ * Rotates the element <code>amount</code> times 90 degrees clockwise.\r
+ */\r
+ void rotate(int amount);\r
+ \r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2010 Association for Decentralized Information Management\r
+ * in Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.h2d.element.handler;\r
+\r
+import java.awt.Graphics2D;\r
+import java.awt.geom.AffineTransform;\r
+\r
+public interface ShadowDrawable {\r
+ \r
+ /**\r
+ * Draws the shadow of the element.\r
+ */\r
+ void draw(Graphics2D g, AffineTransform transform);\r
+ \r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2010 Association for Decentralized Information Management\r
+ * in Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.h2d.event;\r
+\r
+import java.awt.geom.Point2D;\r
+import java.util.List;\r
+\r
+import org.simantics.h2d.element.IElement;\r
+\r
+\r
+public class ClickEvent implements ILocatableEvent { \r
+ final public String modifiers;\r
+\r
+ // Click location in diagram coordinates\r
+ final public Point2D point;\r
+ final public Point2D dispPoint;\r
+\r
+ public List<IElement> pickedElements;\r
+ \r
+ public ClickEvent(String modifiers, Point2D point, Point2D dispPoint) {\r
+ this.modifiers = modifiers;\r
+ this.dispPoint = dispPoint;\r
+ this.point = point;\r
+ }\r
+\r
+ @Override\r
+ public String getType() {\r
+ return getType(modifiers);\r
+ }\r
+ \r
+ public static String getType(String modifiers) {\r
+ return "click(" + modifiers + ")";\r
+ }\r
+ \r
+ @Override\r
+ public Point2D getLocation() {\r
+ return point;\r
+ }\r
+\r
+ @Override\r
+ public List<IElement> getPickedElements() {\r
+ return pickedElements;\r
+ }\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2010 Association for Decentralized Information Management\r
+ * in Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.h2d.event;\r
+\r
+import java.awt.geom.Point2D;\r
+import java.util.List;\r
+\r
+import org.simantics.h2d.element.IElement;\r
+\r
+\r
+public class DragEvent implements ILocatableEvent {\r
+ public DragEventPhase phase;\r
+ \r
+ public String startModifiers;\r
+ public String currentModifiers;\r
+ \r
+ public Point2D start;\r
+ public Point2D current;\r
+ \r
+ public List<IElement> pickedElements;\r
+\r
+ public DragEvent(String startModifiers, Point2D start) {\r
+ this.phase = DragEventPhase.dragBegin;\r
+ this.startModifiers = startModifiers;\r
+ this.currentModifiers = startModifiers;\r
+ this.start = start;\r
+ this.current = start;\r
+ }\r
+\r
+ @Override\r
+ public String getType() {\r
+ return getType(startModifiers);\r
+ }\r
+ \r
+ public static String getType(String modifiers) {\r
+ return "drag(" + modifiers + ")";\r
+ }\r
+\r
+ @Override\r
+ public Point2D getLocation() {\r
+ return start;\r
+ }\r
+\r
+ @Override\r
+ public List<IElement> getPickedElements() {\r
+ return pickedElements;\r
+ }\r
+ \r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2010 Association for Decentralized Information Management\r
+ * in Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.h2d.event;\r
+\r
+public enum DragEventPhase {\r
+ dragBegin, dragUpdate, dragEnd \r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2010 Association for Decentralized Information Management\r
+ * in Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.h2d.event;\r
+\r
+public interface IDragHandler {\r
+ public void handleMove();\r
+ public void handleRelease();\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2010 Association for Decentralized Information Management\r
+ * in Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.h2d.event;\r
+\r
+public interface IEvent {\r
+ String getType();\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2010 Association for Decentralized Information Management\r
+ * in Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.h2d.event;\r
+\r
+import java.awt.geom.Point2D;\r
+import java.util.List;\r
+\r
+import org.simantics.h2d.element.IElement;\r
+\r
+public interface ILocatableEvent extends IEvent {\r
+ Point2D getLocation();\r
+ List<IElement> getPickedElements();\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2010 Association for Decentralized Information Management\r
+ * in Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.h2d.event;\r
+\r
+import java.awt.geom.Point2D;\r
+import java.util.List;\r
+\r
+import org.simantics.h2d.element.IElement;\r
+\r
+\r
+public class KeyboardEvent implements ILocatableEvent { \r
+ final public String key;\r
+\r
+ // Click location in diagram coordinates\r
+ final public Point2D point;\r
+\r
+ public List<IElement> pickedElements;\r
+ \r
+\r
+ public KeyboardEvent(String key, Point2D point) {\r
+ this.key = key;\r
+ this.point = point;\r
+ }\r
+\r
+\r
+ @Override\r
+ public String getType() {\r
+ return getType(key);\r
+ }\r
+ \r
+ public static String getType(String key) {\r
+ return "key(" + key + ")";\r
+ }\r
+ \r
+ @Override\r
+ public Point2D getLocation() {\r
+ return point;\r
+ }\r
+\r
+ @Override\r
+ public List<IElement> getPickedElements() {\r
+ return pickedElements;\r
+ }\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2010 Association for Decentralized Information Management\r
+ * in Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.h2d.event;\r
+\r
+import java.awt.event.MouseEvent;\r
+\r
+public class Modifiers {\r
+\r
+ public static String modifierString(\r
+ int button,\r
+ boolean ctrl,\r
+ boolean alt,\r
+ boolean shift\r
+ ) {\r
+ StringBuilder b = new StringBuilder();\r
+ if(ctrl)\r
+ b.append("ctrl+");\r
+ if(alt)\r
+ b.append("alt+");\r
+ if(shift)\r
+ b.append("shift+");\r
+ if(button == MouseEvent.BUTTON1)\r
+ b.append("left");\r
+ else if(button == MouseEvent.BUTTON2)\r
+ b.append("middle");\r
+ else if(button == MouseEvent.BUTTON3)\r
+ b.append("right"); \r
+ return b.toString();\r
+ }\r
+ \r
+}\r
--- /dev/null
+package org.simantics.h2d.event;\r
+\r
+import java.awt.geom.Point2D;\r
+import java.util.List;\r
+\r
+import org.simantics.h2d.element.IElement;\r
+\r
+public class ReleaseEvent implements ILocatableEvent {\r
+ final public String modifiers;\r
+\r
+ // Release location in diagram coordinates\r
+ final public Point2D point;\r
+ final public Point2D dispPoint;\r
+\r
+ public List<IElement> pickedElements;\r
+\r
+ public ReleaseEvent(String modifiers, Point2D point, Point2D dispPoint) {\r
+ this.modifiers = modifiers;\r
+ this.dispPoint = dispPoint;\r
+ this.point = point;\r
+ }\r
+ \r
+ @Override\r
+ public Point2D getLocation() {\r
+ return point;\r
+ }\r
+\r
+ @Override\r
+ public List<IElement> getPickedElements() {\r
+ return pickedElements;\r
+ }\r
+\r
+ @Override\r
+ public String getType() {\r
+ return getType(modifiers);\r
+ }\r
+ \r
+ public static String getType(String modifiers) {\r
+ return "release(" + modifiers + ")";\r
+ }\r
+\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2010 Association for Decentralized Information Management\r
+ * in Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.h2d.event;\r
+\r
+import java.awt.geom.Point2D;\r
+\r
+\r
+public class WheelEvent implements IEvent { \r
+ final public String modifiers;\r
+\r
+ // Click location in diagram coordinates\r
+ final public Point2D point;\r
+ \r
+ final public int amount;\r
+\r
+ public WheelEvent(String modifiers, Point2D point, int amount) {\r
+ this.modifiers = modifiers;\r
+ this.point = point;\r
+ this.amount = amount;\r
+ }\r
+\r
+ @Override\r
+ public String getType() {\r
+ return getType(modifiers);\r
+ }\r
+ \r
+ public static String getType(String modifiers) {\r
+ return "wheel(" + modifiers + ")";\r
+ }\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2010 Association for Decentralized Information Management\r
+ * in Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.h2d.event.handler;\r
+\r
+import java.awt.geom.Rectangle2D;\r
+import java.util.ArrayList;\r
+import java.util.Collection;\r
+\r
+import org.simantics.h2d.editor.IDiagramEditor;\r
+import org.simantics.h2d.editor.ISelection;\r
+import org.simantics.h2d.element.IElement;\r
+import org.simantics.h2d.event.DragEvent;\r
+import org.simantics.h2d.node.RectangleNode;\r
+import org.simantics.scenegraph.g2d.G2DParentNode;\r
+\r
+public class BoxSelection extends DragEventHandler {\r
+\r
+ Rectangle2D rectangle = new Rectangle2D.Double();\r
+ RectangleNode selectionNode;\r
+ \r
+ @Override\r
+ protected void update(IDiagramEditor editor, DragEvent event) {\r
+ rectangle.setFrameFromDiagonal(event.start, event.current);\r
+ editor.requestRepaint();\r
+ }\r
+\r
+ @Override\r
+ protected void end(IDiagramEditor editor, DragEvent event) {\r
+ Rectangle2D.Double elementBounds = new Rectangle2D.Double();\r
+ ISelection selection = editor.getSelection();\r
+ System.out.println(event.currentModifiers);\r
+ \r
+ Collection<IElement> toBeSelected = new ArrayList<IElement>();\r
+ for(IElement element : editor.getDiagram().getElements()) {\r
+ element.getBounds(elementBounds);\r
+ if(rectangle.contains(elementBounds))\r
+ toBeSelected.add(element);\r
+ }\r
+ \r
+ if(event.currentModifiers.equals("ctrl+"))\r
+ selection.addAll(toBeSelected);\r
+ else\r
+ selection.set(toBeSelected);\r
+ editor.requestRepaint(); \r
+ }\r
+ \r
+ @Override\r
+ public void init(G2DParentNode parent) {\r
+ selectionNode = parent.addNode(RectangleNode.class);\r
+ selectionNode.init(rectangle);\r
+ }\r
+ \r
+ @Override\r
+ public void remove() { \r
+ selectionNode.remove();\r
+ selectionNode = null;\r
+ }\r
+\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2010 Association for Decentralized Information Management\r
+ * in Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.h2d.event.handler;\r
+\r
+import org.simantics.h2d.editor.IDiagramEditor;\r
+\r
+public class DefaultEventHandlers {\r
+\r
+ private DefaultEventHandlers() {}\r
+ \r
+ public static void configure(IDiagramEditor editor) {\r
+ editor.addEventHandler(1, "click(left)", new PickSelection());\r
+ editor.addEventHandler(1, "click(ctrl+left)", new ToggleSelection());\r
+ editor.addEventHandler(1, "drag(shift+left)", new Pan());\r
+ editor.addEventHandler(1, "drag(alt+shift+middle)", new Pan());\r
+ editor.addEventHandler(1, "drag(alt+middle)", new Pan());\r
+ editor.addEventHandler(1, "drag(shift+right)", new Pan());\r
+ editor.addEventHandler(1, "wheel()", new Zoom());\r
+ editor.addEventHandler(1, "key(1)", new ZoomToFit());\r
+ editor.addEventHandler(1, "key(Period)", new RotateCounterclockwise());\r
+ editor.addEventHandler(1, "key(Comma)", new RotateClockwise());\r
+ editor.addEventHandler(1, "key(Ctrl+D)", new Delete());\r
+ \r
+ editor.addEventHandler(0, new ElementEventDelegator());\r
+ \r
+ editor.addEventHandler(-1, "drag(left)", new MoveSelected());\r
+ editor.addEventHandler(-2, "drag(left)", new BoxSelection());\r
+ editor.addEventHandler(-2, "drag(ctrl+left)", new BoxSelection());\r
+ \r
+ // Prints all unhandled events\r
+ //editor.addEventHandler(-1000, new EventPrinter());\r
+ }\r
+ \r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2010 Association for Decentralized Information Management\r
+ * in Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.h2d.event.handler;\r
+\r
+import org.simantics.h2d.diagram.IDiagram;\r
+import org.simantics.h2d.editor.IDiagramEditor;\r
+import org.simantics.h2d.element.IElement;\r
+import org.simantics.h2d.event.IEvent;\r
+\r
+public class Delete implements IEventHandler {\r
+\r
+ @Override\r
+ public boolean handle(IDiagramEditor editor, IEvent event) {\r
+ IDiagram diagram = editor.getDiagram();\r
+ for(IElement element : editor.getSelection()) {\r
+ diagram.removeElement(element);\r
+ }\r
+ editor.getSelection().clear();\r
+ editor.requestRepaint();\r
+ return true;\r
+ }\r
+\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2010 Association for Decentralized Information Management\r
+ * in Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.h2d.event.handler;\r
+\r
+import org.simantics.h2d.action.IAction;\r
+import org.simantics.h2d.editor.IDiagramEditor;\r
+import org.simantics.h2d.event.DragEvent;\r
+import org.simantics.h2d.event.IEvent;\r
+import org.simantics.scenegraph.g2d.G2DParentNode;\r
+\r
+public abstract class DragEventHandler implements IAction {\r
+\r
+ boolean isActive = false;\r
+ \r
+ protected boolean begin(IDiagramEditor editor, DragEvent event) {\r
+ return true;\r
+ }\r
+ \r
+ protected void update(IDiagramEditor editor, DragEvent event) {\r
+ }\r
+ \r
+ protected void end(IDiagramEditor editor, DragEvent event) {\r
+ }\r
+ \r
+ @Override\r
+ public boolean handle(IDiagramEditor editor, IEvent _event) {\r
+ if(_event instanceof DragEvent) {\r
+ DragEvent event = (DragEvent)_event;\r
+ \r
+ switch(event.phase) {\r
+ case dragBegin:\r
+ if(isActive)\r
+ return true; \r
+ if(begin(editor, event)) {\r
+ isActive = true;\r
+ editor.addAction(this);\r
+ return true;\r
+ }\r
+ else\r
+ return false;\r
+ \r
+ case dragUpdate:\r
+ if(!isActive)\r
+ return false;\r
+ update(editor, event);\r
+ return true;\r
+ \r
+ case dragEnd:\r
+ if(!isActive)\r
+ return false;\r
+ isActive = false;\r
+ editor.removeAction(this);\r
+ end(editor, event);\r
+ return true;\r
+ } \r
+ \r
+ }\r
+ return false;\r
+ }\r
+\r
+ @Override\r
+ public void init(G2DParentNode parent) {\r
+ }\r
+\r
+ @Override\r
+ public void remove() {\r
+ }\r
+\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2010 Association for Decentralized Information Management\r
+ * in Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.h2d.event.handler;\r
+\r
+import org.simantics.h2d.editor.IDiagramEditor;\r
+import org.simantics.h2d.element.IElement;\r
+import org.simantics.h2d.event.IEvent;\r
+import org.simantics.h2d.event.ILocatableEvent;\r
+import org.simantics.h2d.event.KeyboardEvent;\r
+\r
+public class ElementEventDelegator implements IEventHandler {\r
+ \r
+ @Override\r
+ public boolean handle(IDiagramEditor editor, IEvent _event) {\r
+ if(_event instanceof KeyboardEvent) {\r
+ IEventHandler uniqueHandler = null;\r
+ for(IElement element : editor.getSelection()) {\r
+ IEventHandler handler = element.getInterface(IEventHandler.class);\r
+ if(handler != null) {\r
+ if(uniqueHandler != null)\r
+ return true; // nobody cannot consume the event\r
+ uniqueHandler = handler;\r
+ }\r
+ }\r
+ if(uniqueHandler != null)\r
+ return uniqueHandler.handle(editor, _event);\r
+ }\r
+ else if(_event instanceof ILocatableEvent) {\r
+ ILocatableEvent event = (ILocatableEvent)_event;\r
+ for(IElement element : event.getPickedElements()) {\r
+ IEventHandler handler = element.getInterface(IEventHandler.class);\r
+ if(handler != null && handler.handle(editor, event))\r
+ return true;\r
+ }\r
+ }\r
+ return false;\r
+ }\r
+\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2010 Association for Decentralized Information Management\r
+ * in Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.h2d.event.handler;\r
+\r
+import org.simantics.h2d.editor.IDiagramEditor;\r
+import org.simantics.h2d.event.IEvent;\r
+\r
+public class EventPrinter implements IEventHandler {\r
+\r
+ @Override\r
+ public boolean handle(IDiagramEditor editor, IEvent event) {\r
+ System.out.println(event.getType());\r
+ return false;\r
+ }\r
+\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2010 Association for Decentralized Information Management\r
+ * in Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.h2d.event.handler;\r
+\r
+import org.simantics.h2d.editor.IDiagramEditor;\r
+import org.simantics.h2d.event.IEvent;\r
+\r
+public interface IEventHandler {\r
+\r
+ boolean handle(IDiagramEditor editor, IEvent event);\r
+ \r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2010 Association for Decentralized Information Management\r
+ * in Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.h2d.event.handler;\r
+\r
+import java.awt.geom.AffineTransform;\r
+import java.awt.geom.Rectangle2D;\r
+import java.util.List;\r
+\r
+import org.simantics.h2d.editor.IDiagramEditor;\r
+import org.simantics.h2d.editor.ISelection;\r
+import org.simantics.h2d.element.IElement;\r
+import org.simantics.h2d.element.handler.Movable;\r
+import org.simantics.h2d.event.DragEvent;\r
+import org.simantics.h2d.node.RectangleNode;\r
+import org.simantics.scenegraph.g2d.G2DParentNode;\r
+import org.simantics.scenegraph.g2d.nodes.TransformNode;\r
+\r
+public class MoveSelected extends DragEventHandler {\r
+\r
+ double deltaX, deltaY; \r
+ TransformNode shadowNode;\r
+ ISelection selection;\r
+ \r
+ @Override\r
+ protected boolean begin(IDiagramEditor editor, DragEvent event) {\r
+ List<IElement> pick = event.pickedElements;\r
+ if(pick.isEmpty())\r
+ return false;\r
+ selection = editor.getSelection();\r
+ boolean pickContainsSelected = false;\r
+ for(IElement element : pick)\r
+ if(selection.contains(element)) {\r
+ pickContainsSelected = true;\r
+ break;\r
+ } \r
+ if(!pickContainsSelected) {\r
+ selection.clear();\r
+ selection.add(pick.get(0));\r
+ }\r
+ return true;\r
+ }\r
+ \r
+ @Override\r
+ protected void update(IDiagramEditor editor, DragEvent event) {\r
+ deltaX = event.current.getX() - event.start.getX();\r
+ deltaY = event.current.getY() - event.start.getY();\r
+ shadowNode.setTransform(new AffineTransform(1.0, 0.0, 0.0, 1.0, deltaX, deltaY));\r
+ editor.requestRepaint();\r
+ }\r
+ \r
+ @Override\r
+ protected void end(IDiagramEditor editor, DragEvent event) {\r
+ for(IElement element : selection)\r
+ if(element instanceof Movable) {\r
+ ((Movable)element).move(deltaX, deltaY);\r
+ }\r
+ selection = null;\r
+ editor.requestRepaint();\r
+ }\r
+ \r
+ @Override\r
+ public void init(G2DParentNode parent) {\r
+ shadowNode = parent.addNode(TransformNode.class);\r
+ \r
+ for(IElement element : selection) {\r
+ Rectangle2D elementBounds = new Rectangle2D.Double();\r
+ element.getBounds(elementBounds);\r
+ RectangleNode shadow = shadowNode.addNode(RectangleNode.class);\r
+ shadow.init(elementBounds);\r
+ }\r
+ }\r
+ \r
+ @Override\r
+ public void remove() {\r
+ shadowNode.remove();\r
+ shadowNode = null;\r
+ }\r
+\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2010 Association for Decentralized Information Management\r
+ * in Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.h2d.event.handler;\r
+\r
+import java.awt.geom.Point2D;\r
+\r
+import org.simantics.h2d.editor.IDiagramEditor;\r
+import org.simantics.h2d.event.DragEvent;\r
+\r
+public class Pan extends DragEventHandler {\r
+\r
+ @Override\r
+ protected void update(IDiagramEditor editor, DragEvent event) {\r
+ Point2D offset = editor.getOffset();\r
+ double scale = editor.getScale();\r
+ editor.setViewTransform(\r
+ new Point2D.Double(\r
+ offset.getX() + event.start.getX() - event.current.getX(),\r
+ offset.getY() + event.start.getY() - event.current.getY()\r
+ ), \r
+ scale);\r
+ editor.requestRepaint();\r
+ }\r
+ \r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2010 Association for Decentralized Information Management\r
+ * in Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.h2d.event.handler;\r
+\r
+import java.util.List;\r
+\r
+import org.simantics.h2d.editor.IDiagramEditor;\r
+import org.simantics.h2d.editor.ISelection;\r
+import org.simantics.h2d.element.IElement;\r
+import org.simantics.h2d.event.ClickEvent;\r
+import org.simantics.h2d.event.IEvent;\r
+\r
+public class PickSelection implements IEventHandler {\r
+\r
+ @Override\r
+ public boolean handle(IDiagramEditor editor, IEvent _event) {\r
+ ClickEvent event = (ClickEvent)_event; \r
+ List<IElement> pick = event.pickedElements;\r
+ ISelection selection = editor.getSelection();\r
+ if(pick.isEmpty()) {\r
+ selection.clear();\r
+ editor.requestRepaint();\r
+ }\r
+ else {\r
+ if(selection.containsOneOf(pick)) {\r
+ if(pick.size() > 1 && selection.size()==1) {\r
+ /*\r
+ * If there are multiple elements under mouse and the current\r
+ * selection is exactly one of them then rotate thru all one\r
+ * element selection possibilities.\r
+ */\r
+ IElement s = selection.getSingleElement();\r
+ for(int i=0;i<pick.size();++i) {\r
+ if(s.equals(pick.get(i))) {\r
+ if(i < pick.size()-1) {\r
+ selection.set(pick.get(i+1));\r
+ return true;\r
+ }\r
+ }\r
+ }\r
+ selection.set(pick.get(0));\r
+ editor.requestRepaint();\r
+ }\r
+ }\r
+ else {\r
+ selection.set(pick.get(0));\r
+ editor.requestRepaint();\r
+ }\r
+ } \r
+ return true;\r
+ }\r
+\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2010 Association for Decentralized Information Management\r
+ * in Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.h2d.event.handler;\r
+\r
+import org.simantics.h2d.editor.IDiagramEditor;\r
+import org.simantics.h2d.element.IElement;\r
+import org.simantics.h2d.element.handler.Rotatable;\r
+import org.simantics.h2d.event.IEvent;\r
+\r
+public class RotateClockwise implements IEventHandler {\r
+\r
+ @Override\r
+ public boolean handle(IDiagramEditor editor, IEvent event) {\r
+ for(IElement element : editor.getSelection()) {\r
+ Rotatable rotatable = element.getInterface(Rotatable.class);\r
+ rotatable.rotate(1);\r
+ }\r
+ editor.requestRepaint();\r
+ return true;\r
+ }\r
+\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2010 Association for Decentralized Information Management\r
+ * in Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.h2d.event.handler;\r
+\r
+import org.simantics.h2d.editor.IDiagramEditor;\r
+import org.simantics.h2d.element.IElement;\r
+import org.simantics.h2d.element.handler.Rotatable;\r
+import org.simantics.h2d.event.IEvent;\r
+\r
+public class RotateCounterclockwise implements IEventHandler {\r
+\r
+ @Override\r
+ public boolean handle(IDiagramEditor editor, IEvent event) {\r
+ for(IElement element : editor.getSelection()) {\r
+ Rotatable rotatable = element.getInterface(Rotatable.class);\r
+ rotatable.rotate(-1);\r
+ }\r
+ editor.requestRepaint();\r
+ return true;\r
+ }\r
+\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2010 Association for Decentralized Information Management\r
+ * in Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.h2d.event.handler;\r
+\r
+import java.util.List;\r
+\r
+import org.simantics.h2d.editor.IDiagramEditor;\r
+import org.simantics.h2d.element.IElement;\r
+import org.simantics.h2d.event.ClickEvent;\r
+import org.simantics.h2d.event.IEvent;\r
+\r
+public class ToggleSelection implements IEventHandler {\r
+\r
+ @Override\r
+ public boolean handle(IDiagramEditor editor, IEvent _event) {\r
+ ClickEvent event = (ClickEvent)_event; \r
+ List<IElement> pick = event.pickedElements; \r
+ if(!pick.isEmpty()) {\r
+ editor.getSelection().toggle(pick.get(0));\r
+ editor.requestRepaint();\r
+ }\r
+ return true;\r
+ }\r
+\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2010 Association for Decentralized Information Management\r
+ * in Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.h2d.event.handler;\r
+\r
+import java.awt.geom.Point2D;\r
+\r
+import org.simantics.h2d.editor.IDiagramEditor;\r
+import org.simantics.h2d.event.IEvent;\r
+import org.simantics.h2d.event.WheelEvent;\r
+\r
+public class Zoom implements IEventHandler {\r
+\r
+ public final static double ZOOM_PER_CLICK = 1.2;\r
+\r
+ @Override\r
+ public boolean handle(IDiagramEditor editor, IEvent _event) {\r
+ final WheelEvent event = (WheelEvent)_event;\r
+ Point2D offset = editor.getOffset();\r
+ double scale = editor.getScale();\r
+ double scaleRatio = Math.pow(ZOOM_PER_CLICK, event.amount);\r
+ \r
+ editor.setViewTransform(\r
+ new Point2D.Double(\r
+ offset.getX() * scaleRatio + event.point.getX() * (1.0 - scaleRatio),\r
+ offset.getY() * scaleRatio + event.point.getY() * (1.0 - scaleRatio)\r
+ ), \r
+ scale * scaleRatio);\r
+ editor.requestRepaint();\r
+ return true;\r
+ }\r
+\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2010 Association for Decentralized Information Management\r
+ * in Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.h2d.event.handler;\r
+\r
+import java.awt.Dimension;\r
+import java.awt.geom.Point2D;\r
+import java.awt.geom.Rectangle2D;\r
+\r
+import org.simantics.h2d.editor.IDiagramEditor;\r
+import org.simantics.h2d.element.IElement;\r
+import org.simantics.h2d.event.IEvent;\r
+\r
+public class ZoomToFit implements IEventHandler {\r
+\r
+ @Override\r
+ public boolean handle(IDiagramEditor editor, IEvent event) {\r
+ Rectangle2D diagramBounds = null;\r
+ Rectangle2D elementBounds = new Rectangle2D.Double();\r
+ for(IElement element : editor.getDiagram().getElements()) {\r
+ element.getBounds(elementBounds);\r
+ if(diagramBounds == null) {\r
+ diagramBounds = new Rectangle2D.Double();\r
+ diagramBounds.setFrame(elementBounds);\r
+ }\r
+ else {\r
+ Rectangle2D.union(diagramBounds, elementBounds, diagramBounds);\r
+ }\r
+ }\r
+ if(diagramBounds != null) {\r
+ Dimension dimension = editor.getViewDimension();\r
+ \r
+ double scale = Math.max(\r
+ diagramBounds.getWidth() / dimension.getWidth(),\r
+ diagramBounds.getHeight() / dimension.getHeight()\r
+ ); \r
+ \r
+ Point2D offset = new Point2D.Double(\r
+ diagramBounds.getCenterX() - dimension.getWidth() * scale * 0.5,\r
+ diagramBounds.getCenterY() - dimension.getHeight() * scale * 0.5\r
+ );\r
+ editor.setViewTransform(offset, scale);\r
+ }\r
+ editor.requestRepaint();\r
+ return true;\r
+ }\r
+\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2010 Association for Decentralized Information Management\r
+ * in Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.h2d.node;
+
+import java.awt.Color;
+import java.awt.Graphics2D;
+import java.awt.Shape;
+import java.awt.geom.Rectangle2D;
+
+import org.simantics.scenegraph.g2d.G2DNode;
+
+public class FilledShapeNode extends G2DNode {
+
+ private static final long serialVersionUID = -7540487222025677413L;
+
+ protected Shape shape = null;
+ protected Color color = Color.BLACK;
+
+ @SyncField("shape")
+ public void setShape(Shape shape) {
+ this.shape = shape;
+ }
+
+ @SyncField("color")
+ public void setColor(Color color) {
+ this.color = color;
+ }
+
+ @Override
+ public void render(Graphics2D g2d) {
+ if(shape == null) return;
+ if(color != null) g2d.setColor(color);
+
+ g2d.fill(shape);
+ }
+
+ @Override
+ public Rectangle2D getBoundsInLocal() {
+ if(shape == null)
+ return null;
+ return shape.getBounds2D();
+ }
+
+}
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2010 Association for Decentralized Information Management\r
+ * in Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.h2d.node;\r
+\r
+public interface ITextListener {\r
+\r
+ void textChanged();\r
+ \r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2010 Association for Decentralized Information Management\r
+ * in Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.h2d.node;\r
+\r
+import java.awt.BasicStroke;\r
+import java.awt.Color;\r
+import java.awt.Graphics2D;\r
+import java.awt.geom.Path2D;\r
+import java.awt.geom.Point2D;\r
+import java.awt.geom.Rectangle2D;\r
+\r
+import org.simantics.scenegraph.g2d.G2DNode;\r
+\r
+public class LineNode extends G2DNode {\r
+ \r
+ private static final long serialVersionUID = 654692698101485672L;\r
+\r
+ Point2D begin;\r
+ Point2D end;\r
+ protected Path2D path;\r
+\r
+ @SyncField({"begin","end"})\r
+ public void init(Point2D begin, Point2D end) {\r
+ this.begin = begin;\r
+ this.end = end;\r
+ update();\r
+ }\r
+ \r
+ protected void update() {\r
+ path = new Path2D.Double();\r
+ path.moveTo(begin.getX(), begin.getY());\r
+ path.lineTo(end.getX(), end.getY());\r
+ }\r
+\r
+ @Override\r
+ public void render(Graphics2D g) {\r
+ if(path == null) return;\r
+ g.setColor(Color.BLACK);\r
+ double scale = g.getTransform().getScaleX();\r
+ g.setStroke(new BasicStroke( (float)(1.0 / scale) ));\r
+ g.draw(path);\r
+ }\r
+\r
+ @Override\r
+ public Rectangle2D getBoundsInLocal() {\r
+ Rectangle2D bounds = new Rectangle2D.Double();\r
+ bounds.setFrameFromDiagonal(begin, end);\r
+ return bounds;\r
+ }\r
+ \r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2010 Association for Decentralized Information Management\r
+ * in Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.h2d.node;\r
+\r
+import java.awt.BasicStroke;\r
+import java.awt.Color;\r
+import java.awt.Graphics2D;\r
+import java.awt.geom.Rectangle2D;\r
+\r
+import org.simantics.scenegraph.g2d.G2DNode;\r
+\r
+public class RectangleNode extends G2DNode {\r
+ \r
+ private static final long serialVersionUID = 654692698101485672L;\r
+\r
+ protected Rectangle2D bounds = null;\r
+\r
+ @SyncField("bounds")\r
+ public void init(Rectangle2D bounds) {\r
+ this.bounds = bounds;\r
+ }\r
+\r
+ @Override\r
+ public void render(Graphics2D g) {\r
+ if(bounds == null) return;\r
+ g.transform(transform);\r
+ g.setColor(Color.BLACK);\r
+ double scale = g.getTransform().getScaleX();\r
+ g.setStroke(new BasicStroke( (float)(1.0 / scale) ));\r
+\r
+ g.draw(bounds);\r
+ }\r
+\r
+ @Override\r
+ public Rectangle2D getBoundsInLocal() {\r
+ return bounds;\r
+ }\r
+ \r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2010 Association for Decentralized Information Management\r
+ * in Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.h2d.node;
+
+import java.awt.BasicStroke;\r
+import java.awt.Color;\r
+import java.awt.Graphics2D;\r
+import java.awt.RenderingHints;\r
+import java.awt.Shape;\r
+import java.awt.Stroke;\r
+import java.awt.geom.Rectangle2D;\r
+\r
+import org.simantics.scenegraph.g2d.G2DNode;\r
+import org.simantics.scenegraph.utils.GeometryUtils;\r
+
+public class ShapeNode extends G2DNode {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = 8508750881358776559L;
+
+ protected Shape shape = null;
+ protected Stroke stroke = new BasicStroke(1);
+ protected Color color = Color.BLACK;
+ protected boolean fill = false;
+ protected boolean scaleStroke = false;
+ protected boolean scaleShape = false;
+
+ @SyncField("shape")
+ public void setShape(Shape shape) {
+ this.shape = shape;
+ repaint();
+ }
+
+ @SyncField("stroke")
+ public void setStroke(Stroke stroke) {
+ this.stroke = stroke;
+ }
+
+ @SyncField("color")
+ public void setColor(Color color) {
+ this.color = color;
+ }
+
+ @SyncField("fill")
+ public void setFill(boolean fill) {
+ this.fill = fill;
+ }
+
+ @SyncField("scaleStroke")
+ public void setScaleStroke(boolean scaleStroke) {
+ this.scaleStroke = scaleStroke;
+ }
+
+ @SyncField("scaleShape")
+ public void setScaleShape(boolean scaleShape) {
+ this.scaleShape = scaleShape;
+ }
+
+ @Override
+ public void render(Graphics2D g2d) {
+ if(shape == null) return;
+
+ g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); // FIXME
+ if(color != null) g2d.setColor(color);
+ if(stroke != null) {
+ if(scaleStroke && stroke instanceof BasicStroke) {
+ BasicStroke bs = GeometryUtils.scaleStroke(stroke, (float) (1.0 / GeometryUtils.getScale(g2d.getTransform())));
+ g2d.setStroke(bs);
+ } else {
+ g2d.setStroke(stroke);
+ }
+ }
+ if(scaleShape) {
+ double xs = g2d.getTransform().getScaleX();
+ double ys = g2d.getTransform().getScaleY();
+ g2d.scale(1/xs, 1/ys);
+ }
+
+ if(fill) {
+ g2d.fill(shape);
+ } else {
+ g2d.draw(shape);
+ }
+
+ }
+
+ @Override
+ public Rectangle2D getBoundsInLocal() {
+ return shape.getBounds2D();
+ }
+}
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2010 Association for Decentralized Information Management\r
+ * in Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.h2d.node;\r
+\r
+import java.awt.AWTEvent;\r
+import java.awt.Color;\r
+import java.awt.Font;\r
+import java.awt.Graphics2D;\r
+import java.awt.Toolkit;\r
+import java.awt.datatransfer.Clipboard;\r
+import java.awt.datatransfer.DataFlavor;\r
+import java.awt.datatransfer.StringSelection;\r
+import java.awt.datatransfer.Transferable;\r
+import java.awt.event.KeyEvent;\r
+import java.awt.event.MouseEvent;\r
+import java.awt.font.FontRenderContext;\r
+import java.awt.geom.Line2D;\r
+import java.awt.geom.Rectangle2D;\r
+\r
+import org.simantics.scenegraph.g2d.G2DNode;\r
+\r
+public class TextNode extends G2DNode {\r
+\r
+ //static final FontRenderContext FRC = new FontRenderContext(\r
+ // new AffineTransform(1.0,0.0,0.0,1.0,0.0,0.0), true, true);\r
+\r
+ private static final long serialVersionUID = 654692698101485672L;\r
+\r
+ protected String text = null;\r
+ protected Font font = null;\r
+ protected Color color = null;\r
+ protected double x;\r
+ protected double y;\r
+ protected double scale;\r
+\r
+ boolean editAllowed;\r
+ int caret = 0;\r
+ int selectionTail = 0;\r
+\r
+ ITextListener textListener;\r
+\r
+ /**\r
+ * Enables or disables edit mode. It also sets\r
+ * the caret at the end of text all selects the\r
+ * whole text (this is the usual convention when \r
+ * beginning to edit one line texts).\r
+ * @param editAllowed\r
+ */\r
+ public void setEditMode(boolean editAllowed) {\r
+ this.editAllowed = editAllowed;\r
+ caret = text.length();\r
+ selectionTail = 0;\r
+ }\r
+\r
+ @SyncField({"text", "font", "color", "x", "y", "scale"})\r
+ public void init(String text, Font font, Color color, double x, double y, double scale) {\r
+ this.text = text;\r
+ this.font = font;\r
+ this.color = color;\r
+ this.x = x;\r
+ this.y = y;\r
+ this.scale = scale;\r
+ }\r
+\r
+ @SyncField({"color"})\r
+ public void setColor(Color color) {\r
+ this.color = color;\r
+ }\r
+\r
+ public String getText() {\r
+ return text;\r
+ }\r
+\r
+ private double getLength(FontRenderContext frc, String str) {\r
+ Rectangle2D bounds = font.getStringBounds(str, frc);\r
+ return bounds.getWidth();\r
+ }\r
+\r
+ @Override\r
+ public void render(Graphics2D g) {\r
+ if(text == null || font == null || color == null) return;\r
+ g.setFont(font);\r
+ g.translate(x, y);\r
+ g.scale(scale, scale);\r
+\r
+ if(editAllowed) {\r
+ FontRenderContext frc = g.getFontRenderContext();\r
+\r
+ int selectionMin = Math.min(caret, selectionTail);\r
+ int selectionMax = Math.max(caret, selectionTail); \r
+ double selectionMinPos = getLength(frc, text.substring(0, selectionMin));\r
+ double selectionMaxPos = getLength(frc, text.substring(0, selectionMax));\r
+\r
+ // Selection background\r
+ g.setColor(new Color(0x316ac5));\r
+ g.fill(new Rectangle2D.Double(selectionMinPos, -12.0, \r
+ selectionMaxPos-selectionMinPos, 12.0));\r
+\r
+ // Text\r
+ g.setColor(color); \r
+ g.drawString(text.substring(0, selectionMin), 0f, 0f);\r
+ g.drawString(text.substring(selectionMax), (float)selectionMaxPos, 0f);\r
+\r
+ g.setColor(Color.WHITE);\r
+ g.drawString(text.substring(selectionMin, selectionMax), (float)selectionMinPos, 0f);\r
+\r
+ // Caret\r
+ double caretPos = getLength(frc, text.substring(0, caret));\r
+ //g.setXORMode(Color.BLACK);\r
+ g.setColor(Color.BLACK);\r
+ g.draw(new Line2D.Double(caretPos, 0, caretPos, -12.0)); \r
+ }\r
+ else {\r
+ g.setColor(color); \r
+ g.drawString(text, 0f, 0f);\r
+ } \r
+ }\r
+\r
+ /**\r
+ * Replaces the current selection with the content or inserts\r
+ * the content at caret. After the insertion the caret\r
+ * will be at the end of inserted text and selection will\r
+ * be empty.\r
+ * @param content\r
+ */\r
+ @SyncField("text")\r
+ protected void insert(String content) {\r
+ if(!content.contains(" ")) {\r
+ int selectionMin = Math.min(caret, selectionTail);\r
+ int selectionMax = Math.max(caret, selectionTail); \r
+\r
+ String begin = text.substring(0, selectionMin);\r
+ String end = text.substring(selectionMax);\r
+ text = begin + content + end;\r
+ caret = selectionMin + content.length();\r
+ selectionTail = caret;\r
+ }\r
+ }\r
+\r
+\r
+ @ServerSide\r
+ protected void fireTextChanged() {\r
+ if(textListener != null)\r
+ textListener.textChanged();\r
+ }\r
+\r
+ public void setTextListener(ITextListener listener) {\r
+ this.textListener = listener;\r
+ }\r
+\r
+ private void handleKeyPressed(KeyEvent event) {\r
+ char c = event.getKeyChar();\r
+ //System.out.println("Key pressed " + c + " " + event.getKeyCode());\r
+ if(event.isControlDown())\r
+ switch(event.getKeyCode()) {\r
+ case KeyEvent.VK_C:\r
+ if(caret != selectionTail) {\r
+ int selectionMin = Math.min(caret, selectionTail);\r
+ int selectionMax = Math.max(caret, selectionTail);\r
+ setCliboardContent(text.substring(selectionMin, selectionMax));\r
+ }\r
+ break;\r
+\r
+ case KeyEvent.VK_V: \r
+ {\r
+ String content = getCliboardContent();\r
+ if(content != null)\r
+ insert(content); \r
+ }\r
+ break;\r
+ default:\r
+ return;\r
+ } \r
+ else if(event.isAltDown())\r
+ return;\r
+ else\r
+ switch(event.getKeyCode()) {\r
+ case KeyEvent.VK_LEFT:\r
+ if(caret > 0) {\r
+ --caret;\r
+ if(!event.isShiftDown())\r
+ selectionTail = caret;\r
+ }\r
+ break;\r
+ case KeyEvent.VK_RIGHT:\r
+ if(caret < text.length()) {\r
+ ++caret;\r
+ if(!event.isShiftDown())\r
+ selectionTail = caret;\r
+ }\r
+ break;\r
+ case KeyEvent.VK_HOME:\r
+ caret = 0;\r
+ if(!event.isShiftDown())\r
+ selectionTail = caret;\r
+ break;\r
+ case KeyEvent.VK_END:\r
+ caret = text.length();\r
+ if(!event.isShiftDown())\r
+ selectionTail = caret;\r
+ break;\r
+\r
+ case KeyEvent.VK_BACK_SPACE:\r
+ if(caret == selectionTail && caret > 0)\r
+ --caret;\r
+ insert(""); \r
+ break;\r
+\r
+ case KeyEvent.VK_DELETE:\r
+ if(caret == selectionTail && caret < text.length())\r
+ ++caret;\r
+ insert(""); \r
+ break; \r
+\r
+ default:\r
+ if(c == 65535 || Character.getType(c) == Character.CONTROL)\r
+ return;\r
+ //System.out.println("Char " + (int)c + " " + Character.getType(c));\r
+ insert(new String(new char[] {c})); \r
+ }\r
+ // FIXME This is called even if just caret was moved.\r
+ // This is currently necessary for repaints.\r
+ fireTextChanged();\r
+ event.consume();\r
+ }\r
+\r
+ private void handleMousePressed(MouseEvent event) {\r
+ // TODO \r
+ }\r
+\r
+ @Override\r
+ public void handleEvent(AWTEvent event) {\r
+ if(editAllowed) {\r
+ if(caret > text.length())\r
+ caret = text.length();\r
+ switch(event.getID()) { \r
+ case KeyEvent.KEY_PRESSED: \r
+ handleKeyPressed((KeyEvent)event);\r
+ break;\r
+ case MouseEvent.MOUSE_PRESSED: \r
+ handleMousePressed((MouseEvent)event);\r
+ break;\r
+ }\r
+ }\r
+ }\r
+\r
+ @Override\r
+ public Rectangle2D getBoundsInLocal() {\r
+ return null;\r
+ }\r
+\r
+ public String getCliboardContent() {\r
+ Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();\r
+ Transferable clipData = clipboard.getContents(this);\r
+ try {\r
+ return (String) (clipData.getTransferData(DataFlavor.stringFlavor));\r
+ } catch (Exception ee) {\r
+ return null;\r
+ }\r
+ }\r
+\r
+ public void setCliboardContent(String content) {\r
+ Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();\r
+ StringSelection data = new StringSelection(content);\r
+ clipboard.setContents(data, data);\r
+ }\r
+}\r
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>\r
+<classpath>\r
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>\r
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>\r
+ <classpathentry kind="src" path="src"/>\r
+ <classpathentry kind="output" path="bin"/>\r
+</classpath>\r
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>\r
+<projectDescription>\r
+ <name>org.simantics.modelica</name>\r
+ <comment></comment>\r
+ <projects>\r
+ </projects>\r
+ <buildSpec>\r
+ <buildCommand>\r
+ <name>org.eclipse.jdt.core.javabuilder</name>\r
+ <arguments>\r
+ </arguments>\r
+ </buildCommand>\r
+ <buildCommand>\r
+ <name>org.eclipse.pde.ManifestBuilder</name>\r
+ <arguments>\r
+ </arguments>\r
+ </buildCommand>\r
+ <buildCommand>\r
+ <name>org.eclipse.pde.SchemaBuilder</name>\r
+ <arguments>\r
+ </arguments>\r
+ </buildCommand>\r
+ </buildSpec>\r
+ <natures>\r
+ <nature>org.eclipse.pde.PluginNature</nature>\r
+ <nature>org.eclipse.jdt.core.javanature</nature>\r
+ </natures>\r
+</projectDescription>\r
--- /dev/null
+#Tue Jan 26 16:43:56 EET 2010\r
+eclipse.preferences.version=1\r
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled\r
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6\r
+org.eclipse.jdt.core.compiler.compliance=1.6\r
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error\r
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error\r
+org.eclipse.jdt.core.compiler.source=1.6\r
--- /dev/null
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: Modelica
+Bundle-SymbolicName: org.simantics.modelica
+Bundle-Version: 1.0.0.qualifier
+Bundle-RequiredExecutionEnvironment: JavaSE-1.6
+Require-Bundle: gnu.trove2;bundle-version="2.0.4",
+ org.simantics.databoard;bundle-version="0.5.2",
+ org.eclipse.osgi;bundle-version="3.6.0",
+ org.eclipse.core.runtime;bundle-version="3.6.0"
+Export-Package: org.simantics.modelica,
+ org.simantics.modelica.data
+Bundle-Activator: org.simantics.modelica.Activator
+Bundle-ActivationPolicy: lazy
+Bundle-Vendor: VTT Technical Research Centre of Finland
--- /dev/null
+###############################################################################\r
+# Copyright (c) 2010 Association for Decentralized Information Management in\r
+# Industry THTH ry.\r
+# All rights reserved. This program and the accompanying materials\r
+# are made available under the terms of the Eclipse Public License v1.0\r
+# which accompanies this distribution, and is available at\r
+# http://www.eclipse.org/legal/epl-v10.html\r
+#\r
+# Contributors:\r
+# VTT Technical Research Centre of Finland - initial API and implementation\r
+###############################################################################\r
+source.. = src/\r
+output.. = bin/\r
+bin.includes = META-INF/,\\r
+ .\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2010 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.modelica;\r
+\r
+import org.osgi.framework.BundleActivator;\r
+import org.osgi.framework.BundleContext;\r
+\r
+public class Activator implements BundleActivator {\r
+\r
+ static BundleContext context;\r
+ \r
+ @Override\r
+ public void start(BundleContext context) throws Exception {\r
+ Activator.context = context;\r
+ }\r
+\r
+ @Override\r
+ public void stop(BundleContext context) throws Exception {\r
+ Activator.context = null;\r
+ }\r
+ \r
+ public static BundleContext getContext() {\r
+ return context;\r
+ }
+ \r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2010 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.modelica;\r
+\r
+public interface IModelicaMonitor {\r
+ public void message(String message);\r
+ public void clearConsole();\r
+ public void showConsole();\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2010 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.modelica;\r
+\r
+public class ModelicaException extends Exception {\r
+\r
+ private static final long serialVersionUID = 2712433918044442927L;\r
+ \r
+ public ModelicaException(String message) {\r
+ super(message);\r
+ }\r
+\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2010 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.modelica;\r
+\r
+import java.io.BufferedWriter;\r
+import java.io.File;\r
+import java.io.FileInputStream;\r
+import java.io.FileNotFoundException;\r
+import java.io.FileWriter;\r
+import java.io.IOException;\r
+import java.io.InputStream;\r
+import java.io.PrintStream;\r
+import java.net.URL;\r
+import java.net.URLDecoder;\r
+import java.util.HashMap;\r
+\r
+import org.eclipse.core.runtime.FileLocator;\r
+import org.eclipse.core.runtime.Platform;\r
+import org.osgi.framework.Bundle;\r
+\r
+public class ModelicaManager {\r
+\r
+ public enum OSType {\r
+ APPLE, LINUX, SUN, WINDOWS, UNKNOWN\r
+ }\r
+\r
+ public static OSType calculateOS() {\r
+ String osName = System.getProperty("os.name");\r
+ assert osName != null;\r
+ osName = osName.toLowerCase();\r
+ if (osName.startsWith("mac os x"))\r
+ return OSType.APPLE;\r
+ if (osName.startsWith("windows"))\r
+ return OSType.WINDOWS;\r
+ if (osName.startsWith("linux"))\r
+ return OSType.LINUX;\r
+ if (osName.startsWith("sun"))\r
+ return OSType.SUN;\r
+ return OSType.UNKNOWN;\r
+ }\r
+ \r
+ public static File getModelicaHome() {\r
+\r
+ String dir = System.getenv("OPENMODELICAHOME");\r
+ File omhome = null;\r
+\r
+ String osName = System.getProperty("os.name");\r
+ OSType os = calculateOS();\r
+\r
+ if (os == OSType.UNKNOWN)\r
+ throw new UnsatisfiedLinkError("unknown OS '" + osName + "' for running OpenModelica");\r
+ \r
+ // If OPENMODELICAHOME is found, try to return the folder.\r
+ if(dir != null) {\r
+ switch (os) {\r
+ case APPLE:\r
+ case LINUX:\r
+ case SUN:\r
+ omhome = new File(dir);\r
+ if(omhome.isDirectory())\r
+ return omhome;\r
+ else\r
+ break;\r
+ case WINDOWS:\r
+ omhome = new File(dir);\r
+ if(omhome.isDirectory())\r
+ return omhome;\r
+ else\r
+ break;\r
+ }\r
+ }\r
+\r
+ // OPENMODELICAHOMe was not found or the folder does not exist. Try built-in OpenModelica for windows\r
+ if(os.equals(OSType.WINDOWS)) {\r
+\r
+ Bundle bundle = Platform.getBundle("org.simantics.openmodelica.win32");\r
+ if (bundle != null) {\r
+ try{\r
+ URL entry = bundle.getEntry("/");\r
+ if(entry != null) {\r
+ URL fileURL = FileLocator.toFileURL(entry);\r
+ File root = new File( URLDecoder.decode(fileURL.getPath(), "UTF-8") );\r
+ File f = new File(root, "OpenModelica1.7.0");\r
+ return f;\r
+ }\r
+ }\r
+ catch (Exception e) {\r
+ e.printStackTrace();\r
+ }\r
+ }\r
+ }\r
+\r
+ // OS was not windows or built-in OpenModelica did not work\r
+ switch (os) {\r
+ case APPLE:\r
+ case LINUX:\r
+ case SUN:\r
+ return new File("/usr/bin/omc");\r
+ case WINDOWS:\r
+ return new File("c:/OpenModelica1.7.0");\r
+ default:\r
+ throw new UnsatisfiedLinkError("Unsupported operating system: " + os);\r
+ }\r
+ }\r
+\r
+ public static File getModelicaExecutable(File simulationDir) {\r
+\r
+ File modelicaHome = getModelicaHome();\r
+ \r
+ if(!modelicaHome.isDirectory())\r
+ throw new UnsatisfiedLinkError("OpenModelica probably not installed. Tried to find it from: " + modelicaHome.getAbsolutePath());\r
+ \r
+ try {\r
+ File omBat = new File(simulationDir, "om.bat");\r
+ FileWriter fw = new FileWriter(omBat);\r
+ BufferedWriter out = new BufferedWriter(fw);\r
+ out.write("@echo off");\r
+ out.newLine();\r
+ out.write("set OPENMODELICAHOME=" + modelicaHome.getAbsolutePath());\r
+ out.newLine();\r
+ out.write("set OPENMODELICALIBRARY=%OPENMODELICAHOME%\\lib\\omlibrary\\msl31");\r
+ out.newLine();\r
+ out.write("%OPENMODELICAHOME%\\bin\\omc.exe %*");\r
+ out.newLine();\r
+ out.close();\r
+ fw.close();\r
+ \r
+ return omBat;\r
+ } catch (IOException e) {\r
+ e.printStackTrace();\r
+ throw new UnsatisfiedLinkError("OpenModelica probably not installed. Tried to find it from: " + modelicaHome.getAbsolutePath());\r
+ }\r
+ }\r
+ \r
+ public static File getSimulationExecutableBat(File exeFile) {\r
+ \r
+ File modelicaHome = getModelicaHome();\r
+ \r
+ File folder = new File(exeFile.getParent());\r
+\r
+ try {\r
+ File exeBat = new File(folder, exeFile.getName() + ".bat");\r
+ FileWriter fw = new FileWriter(exeBat);\r
+ BufferedWriter out = new BufferedWriter(fw);\r
+ \r
+ out.write("@echo off");\r
+ out.newLine();\r
+ out.write("set OPENMODELICAHOME=" + modelicaHome.getAbsolutePath());\r
+ out.newLine();\r
+ out.write("set OPENMODELICALIBRARY=%OPENMODELICAHOME%\\lib\\omlibrary\\msl31");\r
+ out.newLine();\r
+ out.write("set OMPATH=%OPENMODELICAHOME%\\bin");\r
+ out.newLine();\r
+ out.write("echo %PATH%|findstr /i %OMPATH% >nul:");\r
+ out.newLine();\r
+ out.write("if %errorlevel%==1 set PATH=%PATH%;%OMPATH%");\r
+ out.newLine();\r
+ out.write(exeFile.getAbsolutePath() + " %*");\r
+ out.newLine();\r
+ \r
+ out.close();\r
+ fw.close();\r
+ return exeBat;\r
+ }\r
+ catch (IOException e) {\r
+ e.printStackTrace();\r
+ throw new UnsatisfiedLinkError("Creating bat for the exe failed");\r
+ }\r
+ }\r
+\r
+ protected static File createTempDirectory() throws IOException {\r
+ final File temp = File.createTempFile("temp", Long.toString(System.nanoTime()));\r
+ if(!(temp.delete()))\r
+ throw new IOException("Could not delete temp file: " + temp.getAbsolutePath());\r
+ if(!(temp.mkdir()))\r
+ throw new IOException("Could not create temp directory: " + temp.getAbsolutePath());\r
+ return (temp);\r
+ }\r
+\r
+ protected static boolean recursiveDelete(File fileOrDir) {\r
+ if(fileOrDir.isDirectory())\r
+ for(File innerFile: fileOrDir.listFiles())\r
+ if(!recursiveDelete(innerFile))\r
+ return false;\r
+ return fileOrDir.delete();\r
+ }\r
+\r
+ protected static String readFile(File file) throws IOException {\r
+ InputStream stream = new FileInputStream(file);\r
+ byte[] buffer = new byte[(int)file.length()];\r
+ stream.read(buffer);\r
+ stream.close();\r
+ return new String(buffer);\r
+ }\r
+\r
+ public static void printProcessOutput(final Process process, final IModelicaMonitor monitor) {\r
+ Thread thread = new Thread() {\r
+ @Override\r
+ public void run() {\r
+ InputStream stream = process.getInputStream();\r
+ StringBuilder b = new StringBuilder();\r
+ while(true) {\r
+ try {\r
+ int c;\r
+\r
+ c = stream.read();\r
+\r
+ if(c <= 0)\r
+ break;\r
+ if((char)c != '\n')\r
+ b.append((char)c);\r
+ else {\r
+ System.out.println("OMC output: " + b.toString());\r
+ String message = b.toString();\r
+ message = message.trim();\r
+ if(message.startsWith("\""))\r
+ message = message.substring(1);\r
+ monitor.message(message);\r
+ b.delete(0, b.length());\r
+ }\r
+ } catch (IOException e) {\r
+ System.err.println("Not able to read simulation output");\r
+ e.printStackTrace();\r
+ }\r
+ }\r
+ } \r
+ };\r
+ thread.run();\r
+\r
+ }\r
+\r
+ public static SimulationLocation createInputFiles(File simulationDir, String modelName, String modelText, HashMap<String, String> inits, String additionalScript) throws IOException {\r
+ System.out.println(simulationDir.getAbsolutePath());\r
+ modelName = modelName.replace(" ", "");\r
+ File modelFile = new File(simulationDir, modelName + ".mo");\r
+ File scriptFile = new File(simulationDir, modelName + ".mos");\r
+\r
+ {\r
+ PrintStream s = new PrintStream(modelFile);\r
+ s.print(modelText);\r
+ s.close();\r
+ }\r
+\r
+ {\r
+ PrintStream s = new PrintStream(scriptFile);\r
+ if(additionalScript != null)\r
+ s.println(additionalScript);\r
+ s.println("loadFile(\"" + modelName + ".mo\");");\r
+ s.print("buildModel("+modelName+\r
+ ",startTime="+inits.get("start value")+\r
+ ",stopTime="+inits.get("stop value")+\r
+ ",method="+inits.get("method")+\r
+ ",outputFormat=\"plt\""\r
+ );\r
+ if(inits.containsKey("tolerance")) {\r
+ s.print(",tolerance="+inits.get("tolerance"));\r
+ }\r
+ s.print(");\n");\r
+ s.println("getErrorString();");\r
+ s.close();\r
+ }\r
+\r
+ OSType os = calculateOS();\r
+ String suffix = OSType.WINDOWS.equals(os) ? ".exe" : "";\r
+\r
+ return new SimulationLocation(\r
+ simulationDir,\r
+ new File(simulationDir, modelName + ".mos"),\r
+ new File(simulationDir, modelName + "_res.plt"),\r
+ new File(simulationDir, modelName + "_init.txt"),\r
+ new File(simulationDir, modelName + suffix)\r
+ );\r
+ }\r
+\r
+ public static void buildModel(SimulationLocation simulationLocation, IModelicaMonitor monitor) throws ModelicaException {\r
+ try {\r
+ File omc = getModelicaExecutable(simulationLocation.simulationDir);\r
+ \r
+ if(omc == null) {\r
+ monitor.message("OpenModelica not found! Install it from www.openmodelica.org");\r
+ throw new ModelicaException("OpenModelica not found"); \r
+ }\r
+\r
+ Process process = new ProcessBuilder(\r
+ omc.getAbsolutePath(),\r
+ simulationLocation.inputFile.getAbsolutePath()\r
+ )\r
+ .directory(simulationLocation.simulationDir.getAbsoluteFile())\r
+ .redirectErrorStream(true)\r
+ .start();\r
+ printProcessOutput(process, monitor);\r
+\r
+ if(!simulationLocation.exeFile.isFile())\r
+ throw new ModelicaException(".exe file not created\nSee log at " + simulationLocation.simulationDir.getAbsolutePath()); \r
+\r
+ } catch(IOException e) {\r
+ e.printStackTrace();\r
+ }\r
+\r
+ }\r
+\r
+ public static Process runModelica(SimulationLocation simulationLocation, IModelicaMonitor monitor, HashMap<String, String> inits) throws IOException {\r
+\r
+ try {\r
+\r
+ writeInits(simulationLocation, inits);\r
+\r
+ Process process = new ProcessBuilder(\r
+ getSimulationExecutableBat(simulationLocation.exeFile).getAbsolutePath()\r
+ )\r
+ .directory(simulationLocation.simulationDir.getAbsoluteFile())\r
+ .redirectErrorStream(true)\r
+ .start();\r
+\r
+ return process;\r
+ } catch(IOException e) {\r
+ e.printStackTrace();\r
+ }\r
+ return null;\r
+ }\r
+\r
+ private static void writeInits(SimulationLocation simulationLocation, HashMap<String, String> inits) {\r
+\r
+ HashMap<String, String> initials = new HashMap<String, String>();\r
+ HashMap<Integer, String> order = new HashMap<Integer, String>();\r
+\r
+ InputStream is;\r
+ try {\r
+ is = new FileInputStream(simulationLocation.initFile);\r
+ int orderNumber = 0;\r
+ while(true) {\r
+ String line = getLine(is);\r
+ if(line == null)\r
+ return;\r
+ if(line.isEmpty())\r
+ break;\r
+ if(line.contains("//")) {\r
+ String[] nn = line.split("//", 2);\r
+ String key = nn[1].trim();\r
+ String value = nn[0].trim();\r
+ if(inits.containsKey(key)) {\r
+ value = inits.get(key);\r
+ }\r
+ initials.put(key, value);\r
+ order.put(orderNumber, key);\r
+ }\r
+ orderNumber++;\r
+ }\r
+ is.close();\r
+\r
+ PrintStream s = new PrintStream(simulationLocation.initFile);\r
+ for(int j = 0; j < orderNumber ; j++) {\r
+ String key = order.get(j);\r
+ if (key != null) {\r
+ s.println(initials.get(key) + " // " + key);\r
+ } else {\r
+ s.println("0.0");\r
+ }\r
+ }\r
+ s.close();\r
+\r
+ } catch (FileNotFoundException e) {\r
+ e.printStackTrace();\r
+ } catch (IOException e) {\r
+ e.printStackTrace();\r
+ }\r
+ }\r
+\r
+\r
+ private static String getLine(InputStream stream) {\r
+ if(stream == null)\r
+ return null;\r
+ StringBuilder b = new StringBuilder();\r
+ try {\r
+ while(true) {\r
+ int c = stream.read();\r
+ if(c == -1) {\r
+ stream = null;\r
+ return b.toString();\r
+ }\r
+ else if(c == '\n') \r
+ return b.toString();\r
+ else if(c == '\r')\r
+ ;\r
+ else\r
+ b.append((char)c);\r
+ }\r
+ } catch (IOException e) {\r
+ return null;\r
+ } \r
+\r
+ }\r
+\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2010 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.modelica;\r
+\r
+import java.io.File;\r
+\r
+public class SimulationLocation {\r
+ public File simulationDir;\r
+ public File inputFile;\r
+ public File outputFile;\r
+ public File initFile;\r
+ public File exeFile;\r
+ \r
+ public SimulationLocation(File simulationDir, File inputFile,\r
+ File outputFile, File initFile, File exeFile) {\r
+ this.simulationDir = simulationDir;\r
+ this.inputFile = inputFile;\r
+ this.outputFile = outputFile;\r
+ this.initFile = initFile;\r
+ this.exeFile = exeFile;\r
+ }\r
+}
\ No newline at end of file
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2010 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.modelica.data;\r
+\r
+import java.util.List;\r
+\r
+/**\r
+ * Simulation result for one variable.\r
+ * @author Hannu Niemistö\r
+ */\r
+public class DataSet {\r
+ public String name;\r
+ public List<Double> times;\r
+ public List<Double> values;\r
+ \r
+ public DataSet(String name, List<Double> times, List<Double> values) {\r
+ this.name = name;\r
+ this.times = times;\r
+ this.values = values;\r
+ } \r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2010 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.modelica.data;\r
+\r
+import java.io.File;\r
+import java.io.FileInputStream;\r
+import java.io.FileNotFoundException;\r
+import java.io.IOException;\r
+import java.io.InputStream;\r
+import java.util.ArrayList;\r
+import java.util.HashMap;\r
+import java.util.List;\r
+import java.util.regex.Matcher;\r
+import java.util.regex.Pattern;\r
+\r
+/**\r
+ * Class that reads OpenModelica result files.\r
+ * @author Hannu Niemistö\r
+ */\r
+public class SimulationResult { \r
+\r
+ List<DataSet> variables = new ArrayList<DataSet>();\r
+ List<DataSet> initials = new ArrayList<DataSet>();\r
+\r
+ static String getLine(InputStream stream) {\r
+ if(stream == null)\r
+ return null;\r
+ StringBuilder b = new StringBuilder();\r
+ try {\r
+ while(true) {\r
+ int c = stream.read();\r
+ if(c == -1) {\r
+ stream = null;\r
+ return b.toString();\r
+ }\r
+ else if(c == '\n') \r
+ return b.toString();\r
+ else if(c == '\r')\r
+ ;\r
+ else\r
+ b.append((char)c);\r
+ }\r
+ } catch (IOException e) {\r
+ return null;\r
+ } \r
+\r
+ }\r
+\r
+\r
+ public void readInits(File file) throws FileNotFoundException, IOException {\r
+ InputStream is = new FileInputStream(file);\r
+ readInits(is);\r
+ is.close();\r
+ }\r
+\r
+ public void readInits(InputStream stream) {\r
+ HashMap<String, Double> mappedInitials = new HashMap<String, Double>();\r
+ while(true) {\r
+ String line = getLine(stream);\r
+ if(line == null)\r
+ return;\r
+ if(line.isEmpty())\r
+ break;\r
+\r
+ if(line.contains("//")) {\r
+ String[] nn = line.split("//", 2);\r
+ try {\r
+ double value = Double.parseDouble(nn[0].trim());\r
+ String key = nn[1].trim();\r
+ mappedInitials.put(key, value);\r
+ } catch (NumberFormatException nfe) {\r
+ continue; // Not a valid double\r
+ }\r
+ \r
+ }\r
+\r
+ }\r
+ \r
+ double startTime = mappedInitials.get("start value");\r
+ double stopTime = mappedInitials.get("stop value");\r
+ List<Double> times = new ArrayList<Double>(2);\r
+ times.add(startTime);\r
+ times.add(stopTime);\r
+ \r
+ for(String key : mappedInitials.keySet()) {\r
+ List<Double> values = new ArrayList<Double>(2);\r
+ values.add(mappedInitials.get(key));\r
+ values.add(mappedInitials.get(key));\r
+ initials.add(new DataSet(key, times , values));\r
+ }\r
+ }\r
+\r
+\r
+ final static Pattern p1 = Pattern.compile("DataSet: ([^ ]*)");\r
+\r
+ public void read(File file) throws FileNotFoundException, IOException {\r
+ InputStream is = new FileInputStream(file);\r
+ read(is);\r
+ is.close();\r
+ }\r
+\r
+ public void read(InputStream stream) {\r
+ while(true) {\r
+ String line = getLine(stream);\r
+ if(line == null)\r
+ return;\r
+ if(line.isEmpty())\r
+ break;\r
+ }\r
+\r
+ // Data sets\r
+ while(true) { \r
+ Matcher matcher = p1.matcher(getLine(stream));\r
+ if(!matcher.matches())\r
+ return;\r
+ String name = matcher.group(1);\r
+\r
+ List<Double> times = new ArrayList<Double>();\r
+ List<Double> values = new ArrayList<Double>();\r
+ while(true) {\r
+ String line = getLine(stream);\r
+ if(line == null)\r
+ return;\r
+ if(line.isEmpty())\r
+ break;\r
+ String[] nn = line.split(", ", 2);\r
+ times.add(Double.parseDouble(nn[0]));\r
+ values.add(Double.parseDouble(nn[1]));\r
+ }\r
+\r
+ variables.add(new DataSet(name, times, values));\r
+ }\r
+ }\r
+\r
+ public void filter() {\r
+ ArrayList<DataSet> newVariables = new ArrayList<DataSet>();\r
+ for(DataSet dataSet : variables) {\r
+ if(!dataSet.name.contains("$") && !dataSet.name.contains("der("))\r
+ newVariables.add(dataSet);\r
+ }\r
+ variables = newVariables;\r
+ }\r
+\r
+ public List<DataSet> getVariableDataSets() {\r
+ return variables;\r
+ }\r
+\r
+ public List<DataSet> getInitialValueDataSets() {\r
+ return initials;\r
+ }\r
+ \r
+ /**\r
+ * Gets DataSet for variable. Loops first the variables and then initials. \r
+ * @param name the name of the variable\r
+ * @return DataSet for the variable or null if DataSet not found\r
+ */\r
+ public DataSet getDataSet(String name) {\r
+ for(DataSet set : variables)\r
+ if(set.name.equals(name))\r
+ return set;\r
+ for(DataSet set : initials)\r
+ if(set.name.equals(name))\r
+ return set;\r
+ return null;\r
+ }\r
+}\r
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>\r
+<classpath>\r
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>\r
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>\r
+ <classpathentry kind="src" path="src"/>\r
+ <classpathentry kind="src" path="examples"/>\r
+ <classpathentry kind="output" path="bin"/>\r
+</classpath>\r
--- /dev/null
+syntax: regexp\r
+^bin/\r
+\r
+syntax: glob\r
+*.svn/*
\ No newline at end of file
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>\r
+<projectDescription>\r
+ <name>org.simantics.objmap</name>\r
+ <comment></comment>\r
+ <projects>\r
+ </projects>\r
+ <buildSpec>\r
+ <buildCommand>\r
+ <name>org.eclipse.jdt.core.javabuilder</name>\r
+ <arguments>\r
+ </arguments>\r
+ </buildCommand>\r
+ <buildCommand>\r
+ <name>org.eclipse.pde.ManifestBuilder</name>\r
+ <arguments>\r
+ </arguments>\r
+ </buildCommand>\r
+ <buildCommand>\r
+ <name>org.eclipse.pde.SchemaBuilder</name>\r
+ <arguments>\r
+ </arguments>\r
+ </buildCommand>\r
+ </buildSpec>\r
+ <natures>\r
+ <nature>org.eclipse.pde.PluginNature</nature>\r
+ <nature>org.eclipse.jdt.core.javanature</nature>\r
+ </natures>\r
+</projectDescription>\r
--- /dev/null
+#Wed Nov 11 10:38:27 EET 2009\r
+eclipse.preferences.version=1\r
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled\r
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6\r
+org.eclipse.jdt.core.compiler.compliance=1.6\r
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error\r
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error\r
+org.eclipse.jdt.core.compiler.source=1.6\r
--- /dev/null
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: Objmap
+Bundle-SymbolicName: org.simantics.objmap
+Bundle-Version: 0.1.0
+Bundle-RequiredExecutionEnvironment: JavaSE-1.6
+Require-Bundle: gnu.trove2;bundle-version="2.0.4",
+ org.apache.log4j;bundle-version="1.2.15",
+ org.simantics.layer0;bundle-version="1.0.0",
+ org.simantics.db.common;bundle-version="1.1.0"
+Export-Package: org.simantics.objmap,
+ org.simantics.objmap.annotations,
+ org.simantics.objmap.annotations.meta,
+ org.simantics.objmap.rules,
+ org.simantics.objmap.rules.domain,
+ org.simantics.objmap.rules.factory,
+ org.simantics.objmap.rules.range,
+ org.simantics.objmap.schema
+Bundle-Vendor: VTT Technical Research Centre of Finland
--- /dev/null
+###############################################################################\r
+# Copyright (c) 2007, 2010 Association for Decentralized Information Management\r
+# in Industry THTH ry.\r
+# All rights reserved. This program and the accompanying materials\r
+# are made available under the terms of the Eclipse Public License v1.0\r
+# which accompanies this distribution, and is available at\r
+# http://www.eclipse.org/legal/epl-v10.html\r
+#\r
+# Contributors:\r
+# VTT Technical Research Centre of Finland - initial API and implementation\r
+###############################################################################\r
+source.. = src/\r
+output.. = bin/\r
+bin.includes = META-INF/,\\r
+ .\r
+src.includes = doc/,\\r
+ examples/\r
--- /dev/null
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>\r
+<graphml xmlns="http://graphml.graphdrawing.org/xmlns" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:y="http://www.yworks.com/xml/graphml" xsi:schemaLocation="http://graphml.graphdrawing.org/xmlns http://www.yworks.com/xml/schema/graphml/1.0/ygraphml.xsd">\r
+ <!--Created by yFiles for Java 2.7-->\r
+ <key for="graphml" id="d0" yfiles.type="resources"/>\r
+ <key attr.name="url" attr.type="string" for="node" id="d1"/>\r
+ <key attr.name="description" attr.type="string" for="node" id="d2">\r
+ <default/>\r
+ </key>\r
+ <key for="node" id="d3" yfiles.type="nodegraphics"/>\r
+ <key attr.name="url" attr.type="string" for="edge" id="d4"/>\r
+ <key attr.name="description" attr.type="string" for="edge" id="d5">\r
+ <default/>\r
+ </key>\r
+ <key for="edge" id="d6" yfiles.type="edgegraphics"/>\r
+ <graph edgedefault="directed" id="G">\r
+ <node id="n0">\r
+ <data key="d2"/>\r
+ <data key="d3">\r
+ <y:ShapeNode>\r
+ <y:Geometry height="30.0" width="127.0" x="186.0" y="200.0"/>\r
+ <y:Fill color="#FFFFFF" transparent="false"/>\r
+ <y:BorderStyle color="#000000" type="line" width="1.0"/>\r
+ <y:NodeLabel alignment="center" autoSizePolicy="content" fontFamily="Dialog" fontSize="12" fontStyle="plain" hasBackgroundColor="false" hasLineColor="false" height="18.701171875" modelName="internal" modelPosition="c" textColor="#000000" visible="true" width="106.720703125" x="10.1396484375" y="5.6494140625">Intermediate model</y:NodeLabel>\r
+ <y:Shape type="rectangle"/>\r
+ </y:ShapeNode>\r
+ </data>\r
+ </node>\r
+ <node id="n1">\r
+ <data key="d2"/>\r
+ <data key="d3">\r
+ <y:ShapeNode>\r
+ <y:Geometry height="30.0" width="103.0" x="-21.0" y="200.0"/>\r
+ <y:Fill color="#FFFFFF" transparent="false"/>\r
+ <y:BorderStyle color="#000000" type="line" width="1.0"/>\r
+ <y:NodeLabel alignment="center" autoSizePolicy="content" fontFamily="Dialog" fontSize="12" fontStyle="plain" hasBackgroundColor="false" hasLineColor="false" height="18.701171875" modelName="internal" modelPosition="c" textColor="#000000" visible="true" width="55.369140625" x="23.8154296875" y="5.6494140625">Database</y:NodeLabel>\r
+ <y:Shape type="rectangle"/>\r
+ </y:ShapeNode>\r
+ </data>\r
+ </node>\r
+ <node id="n2">\r
+ <data key="d2"/>\r
+ <data key="d3">\r
+ <y:ShapeNode>\r
+ <y:Geometry height="30.0" width="103.0" x="417.0" y="200.0"/>\r
+ <y:Fill color="#FFFFFF" transparent="false"/>\r
+ <y:BorderStyle color="#000000" type="line" width="1.0"/>\r
+ <y:NodeLabel alignment="center" autoSizePolicy="content" fontFamily="Dialog" fontSize="12" fontStyle="plain" hasBackgroundColor="false" hasLineColor="false" height="18.701171875" modelName="internal" modelPosition="c" textColor="#000000" visible="true" width="35.34765625" x="33.826171875" y="5.6494140625">Editor</y:NodeLabel>\r
+ <y:Shape type="rectangle"/>\r
+ </y:ShapeNode>\r
+ </data>\r
+ </node>\r
+ <edge id="e0" source="n1" target="n0">\r
+ <data key="d6">\r
+ <y:PolyLineEdge>\r
+ <y:Path sx="0.0" sy="0.0" tx="0.0" ty="0.0">\r
+ <y:Point x="134.75500000000028" y="185.0425000000001"/>\r
+ </y:Path>\r
+ <y:LineStyle color="#000000" type="line" width="1.0"/>\r
+ <y:Arrows source="none" target="standard"/>\r
+ <y:EdgeLabel alignment="center" distance="2.0" fontFamily="Dialog" fontSize="12" fontStyle="plain" hasBackgroundColor="false" hasLineColor="false" height="18.701171875" modelName="six_pos" modelPosition="head" preferredPlacement="anywhere" ratio="0.5" textColor="#000000" visible="true" width="34.017578125" x="13.93121093750014" y="-34.47918379864251">reads</y:EdgeLabel>\r
+ <y:BendStyle smoothed="false"/>\r
+ </y:PolyLineEdge>\r
+ </data>\r
+ </edge>\r
+ <edge id="e1" source="n0" target="n2">\r
+ <data key="d6">\r
+ <y:PolyLineEdge>\r
+ <y:Path sx="0.0" sy="0.0" tx="0.0" ty="0.0">\r
+ <y:Point x="363.0000000000002" y="190.6400000000001"/>\r
+ </y:Path>\r
+ <y:LineStyle color="#000000" type="line" width="1.0"/>\r
+ <y:Arrows source="none" target="standard"/>\r
+ <y:EdgeLabel alignment="center" distance="2.0" fontFamily="Dialog" fontSize="12" fontStyle="plain" hasBackgroundColor="false" hasLineColor="false" height="18.701171875" modelName="six_pos" modelPosition="shead" preferredPlacement="anywhere" ratio="0.5" textColor="#000000" visible="true" width="56.01953125" x="1.5527343750001137" y="-33.057650409984035">visualizes</y:EdgeLabel>\r
+ <y:BendStyle smoothed="false"/>\r
+ </y:PolyLineEdge>\r
+ </data>\r
+ </edge>\r
+ <edge id="e2" source="n2" target="n0">\r
+ <data key="d6">\r
+ <y:PolyLineEdge>\r
+ <y:Path sx="0.0" sy="0.0" tx="0.0" ty="0.0">\r
+ <y:Point x="365.0000000000002" y="237.3600000000001"/>\r
+ </y:Path>\r
+ <y:LineStyle color="#000000" type="line" width="1.0"/>\r
+ <y:Arrows source="none" target="standard"/>\r
+ <y:EdgeLabel alignment="center" distance="2.0" fontFamily="Dialog" fontSize="12" fontStyle="plain" hasBackgroundColor="false" hasLineColor="false" height="18.701171875" modelName="six_pos" modelPosition="stail" preferredPlacement="anywhere" ratio="0.5" textColor="#000000" visible="true" width="48.68359375" x="-54.904296874999886" y="13.861448547068562">modifies</y:EdgeLabel>\r
+ <y:BendStyle smoothed="false"/>\r
+ </y:PolyLineEdge>\r
+ </data>\r
+ </edge>\r
+ <edge id="e3" source="n0" target="n1">\r
+ <data key="d6">\r
+ <y:PolyLineEdge>\r
+ <y:Path sx="0.0" sy="0.0" tx="0.0" ty="0.0">\r
+ <y:Point x="133.78500000000014" y="234.19250000000017"/>\r
+ </y:Path>\r
+ <y:LineStyle color="#000000" type="line" width="1.0"/>\r
+ <y:Arrows source="none" target="standard"/>\r
+ <y:EdgeLabel alignment="center" distance="2.0" fontFamily="Dialog" fontSize="12" fontStyle="plain" hasBackgroundColor="false" hasLineColor="false" height="18.701171875" modelName="six_pos" modelPosition="tail" preferredPlacement="anywhere" ratio="0.5" textColor="#000000" visible="true" width="35.3359375" x="-48.33796874999993" y="10.017335507498103">writes</y:EdgeLabel>\r
+ <y:BendStyle smoothed="false"/>\r
+ </y:PolyLineEdge>\r
+ </data>\r
+ </edge>\r
+ </graph>\r
+ <data key="d0">\r
+ <y:Resources/>\r
+ </data>\r
+</graphml>\r
--- /dev/null
+'''org.simantics.objmap''' is a framework for bidirectional synchronization between Simantics database and Java objects. \r
+\r
+See [[org.simantics.template_Manual|Manual]] for details.\r
+\r
+= Dependencies=\r
+\r
+* [[org.simantics.db]]\r
+* gnu.trove2\r
+\r
+There is a plan to split the plugin into two plugins such that the other will be database-independent and contain all annotations.\r
+\r
+=Download=\r
+\r
+{| style="background-color: #e9e9e9; border: 1px solid #aaaaaa; width: 75%;"\r
+| '''Version'''\r
+| '''Date'''\r
+| '''Download'''\r
+|- style="background-color: #f9f9f9; " |\r
+| 0.1.0\r
+| 12.11.2009\r
+| [[Media:org.simantics.objmap-0.1.0.zip|org.simantics.objmap-0.1.0.zip]] \r
+|}\r
+\r
+=Current Development=\r
+The current version is released mostly for comments and is not yet ready for deployment. The development plan is at the end of the [[org.simantics.objmap_Manual#TODO|manual]]. \r
+\r
--- /dev/null
+= Introduction =\r
+\r
+When implementing an editor in Simantics platform, it is very common that the graph representation cannot be directly used, but the editor needs to create an intermediate model of the subgraph it edits. Some reasons for this:\r
+* Accessing the database directly is not fast enough.\r
+* An editor using the database directly holds frequently long read locks and cannot operate during write transactions.\r
+* The editor needs to store auxiliary objects attached to the model.\r
+* Editor modifies the intermediate model speculatively before the modification is committed to the database or canceled.\r
+* The modifications in database cannot be applied in the editor immediately (for example during rendering).\r
+* Third-party component requires certain classes to be used.\r
+* Editor needs to be backend agnostic and cannot directly use database api.\r
+\r
+There are two different approaches for implementing the intermediate model:\r
+; Triangle model\r
+: The editor modifies the database directly and the changes in the database are eventually propagated to the intermediate model. The editor doesn't change the intermediate model directly.\r
+[[Image:triangleModel.png]] \r
+; Bidirectional model\r
+: The editor operates only using the intermediate model and modifications are updated from intermediate model to the database and vice versa. \r
+[[Image:bidirectionalModel.png]] \r
+\r
+By experience, the triangle model is easier to implement correctly in particular when resources are linked to each other in complex fashion. The <code>org.simantics.objmap</code>-plugin tries to make the implementation of bidirectional model easier by providing a framework for defining declaratively the update procedure between database and intermediate model. It can also be used with triangle model only for one direction or with hybrid model where some operations are implemented using the intermediate model and other modifying the database directly.\r
+\r
+= Design principles =\r
+\r
+; Symmetric\r
+: For every operation from database to Java objects there is a corresponding operation from Java objects to database. This makes the framework easier to learn and undestand. \r
+; Non-intrusive\r
+: The Java objects used with the framework do not need to implement any specific interface or follow some specific naming convention. The mapping schema can be defined using annotations or separately from the class definition.\r
+; Support for different use scenarios\r
+:* bidirectional / unidirectional\r
+:* one shot / continuous\r
+:* automatic listening / manual updating\r
+; One-to-one\r
+: For every resource there is a single corresponding Java object and vise versa. This makes the framework easier to understand. It is not a transformation framework. \r
+\r
+= Concepts =\r
+\r
+''Mapping'' consists of a set of resources called a ''domain'', a set of Java objects called a ''range'' and a collection of ''links''. Each link is attached to exactly one domain and range element and each domain and range element has at most one link attached to it. Additionally the link has a ''link type'' that contains requirements for the domain and range elements in the same link.\r
+\r
+[[Image:objectMappingTerminology.png]]\r
+\r
+A mapping is ''up-to-date'' if every domain and range element has a link and all links satisfy the requirements of their link types. The links of up-to-date mapping form a bijection from domain to range.\r
+\r
+A ''mapping schema'' associates all domain and range elements with a link type. It is used to add new domain and range elements to the mapping.\r
+\r
+= Mapping interface =\r
+\r
+The plugin represents a mapping with interface <code>org.simantics.objmap.IMapping</code>. The interface is symmetric in the sense that every operation on the domain of the mapping has also a counterpart that operates on the range. Typically, if one of the operations requires a read graph, its counterpart requires a write graph. We will describe only the methods operating on the domain of the mapping:\r
+\r
+ Set<Resource> getDomain();\r
+ \r
+Returns the domain of the mapping. All set operations are supported. Adding a new domain element does not automatically create a link to it. Removal of a domain element removes also a link and the target element, but does not remove the element from the database. \r
+ \r
+ Collection<Resource> updateDomain(WriteGraph g) throws MappingException;\r
+ \r
+Updates all domain elements whose counterpart is modified and creates new domain elements for previously added range elements. Returns the collection of domain elements that were modified or created in the update process.\r
+\r
+ Object get(Resource domainElement);\r
+ \r
+Returns the counterpart of a domain element or null if the element does not belong to the domain or does not have a link. \r
+ \r
+ Object map(ReadGraph g, Resource domainElement) throws MappingException;\r
+\r
+A convenience method that adds a domain element to the mapping and immediately updates the mapping and returns the corresponding range element. \r
+\r
+ void domainModified(Resource domainElement);\r
+ \r
+Tells the mapping that the domain element has been modified. \r
+\r
+ boolean isDomainModified();\r
+ \r
+Tells if some domain elements have been modified or added. \r
+ \r
+ Collection<Resource> getConflictingDomainElements();\r
+\r
+Returns a collection of domain elements which have been modified and also their counterparts in the mapping are modified. These elements are in conflict in the sense that the updating domain and range in different orders may produce different results.\r
+\r
+ void addMappingListener(IMappingListener listener);\r
+ void removeMappingListener(IMappingListener listener);\r
+\r
+Adds or removes a listener for domain and range modifications.\r
+\r
+= Defining a mapping schema =\r
+\r
+The primary way for defining a mapping schema is to use Java annotations. The current annotation support is still lacking. Only the following annotations are supported:\r
+; GraphType(uri)\r
+: Specifies the domain type that the class corresponds to.\r
+; RelatedValue(uri)\r
+: Specifies a correspondence between a field and functional property.\r
+; RelatedElement(uri)\r
+: Specifies a correspondence between a field and functional relation\r
+; RelatedElements(uri)\r
+: Specifies a correspondence between a field and a relation. The type of the field has to be a collection.\r
+\r
+== Example ==\r
+ \r
+Suppose we have the following annotated classes:\r
+ @GraphType("http://www.simantics.org/Sysdyn#Configuration")\r
+ static class Configuration {\r
+ @RelatedElements("http://www.vtt.fi/Simantics/Layer0/1.0/Relations#ConsistsOf")\r
+ Collection<Component> components; \r
+ }\r
+ \r
+ static abstract class Component { \r
+ }\r
+ \r
+ @GraphType("http://www.simantics.org/Sysdyn#Dependency")\r
+ static class Dependency extends Component {\r
+ @RelatedElement("http://www.simantics.org/Sysdyn#HasTail")\r
+ Variable tail;\r
+ @RelatedElement("http://www.simantics.org/Sysdyn#HasHead")\r
+ Auxiliary head;\r
+ }\r
+ \r
+ static abstract class Variable extends Component {\r
+ @RelatedValue("http://www.vtt.fi/Simantics/Layer0/1.0/Relations#HasName")\r
+ String name;\r
+ }\r
+ \r
+ @GraphType("http://www.simantics.org/Sysdyn#Auxiliary")\r
+ static class Auxiliary extends Variable {\r
+ }\r
+\r
+Them the schema can be defined as follows:\r
+ SimpleSchema schema = new SimpleSchema();\r
+ schema.addLinkType(MappingSchemas.fromAnnotations(g, Configuration.class));\r
+ schema.addLinkType(MappingSchemas.fromAnnotations(g, Dependency.class));\r
+ schema.addLinkType(MappingSchemas.fromAnnotations(g, Auxiliary.class));\r
+\r
+= Using the mapping interface =\r
+\r
+Assume that a mapping scheme <code>scheme</code> has already been defined and <code>modelRoot</code> is the root resource of the model that the editor edits. Then the model is created as follows:\r
+ IMapping mapping = Mappings.create(scheme);\r
+ in read transaction {\r
+ MyModel model = (MyModel)mapping.map(graph, modelRoot);\r
+ } \r
+ \r
+There are different ways how the mapping can be updated. The following code forces update for all domain elements. \r
+ in read transaction {\r
+ for(Resource r : mapping.getDomain())\r
+ mapping.domainModified(r);\r
+ mapping.updateRange(graph);\r
+ }\r
+ \r
+If the range elements have some kind of "dirty" flags, the update can be optimized:\r
+ in write transaction {\r
+ for(Object obj : mapping.getRange())\r
+ if(obj implements MyObject && ((MyObject)obj).isDirty())\r
+ mapping.rangeModified(obj);\r
+ mapping.updateDomain(graph);\r
+ }\r
+ \r
+Often the editor has to update some auxiliary structures when the mapping modifies the range. This can be implemented for example as:\r
+ for(Object obj : mapping.updateRange(graph))\r
+ if(obj implements MyObject)\r
+ ((MyObject)obj).updateAuxiliary();\r
+\r
+The most convenient way for updating the target would be to add graph request listeners for each domain element in the mapping. This is not yet implemented although the current interface should support this without modifications. Currently the only way to listen the database changes is to listen the request that is used to call the updateRange-method.\r
+\r
+= Development plan =\r
+\r
+By priority:\r
+* Automatic listening of database changes: marks domain elements modified.\r
+* More complete annotations\r
+* Utilizing declarations in ontologies: for example full URIs of relations are not needed because relations are declared in types. Also the validity of annotation can be checked.\r
+* A separate plugin containing only mapping annotations so that the plugin can be used without introducing a dependency to org.simantics.db.\r
+* Composition annotation that can be used to remove elements whose parents are removed or update elements whose parents are marked modified. \r
+* Support for copy-paste and other extra mapping issues. \r
--- /dev/null
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>\r
+<graphml xmlns="http://graphml.graphdrawing.org/xmlns" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:y="http://www.yworks.com/xml/graphml" xsi:schemaLocation="http://graphml.graphdrawing.org/xmlns http://www.yworks.com/xml/schema/graphml/1.0/ygraphml.xsd">\r
+ <!--Created by yFiles for Java 2.7-->\r
+ <key for="graphml" id="d0" yfiles.type="resources"/>\r
+ <key attr.name="url" attr.type="string" for="node" id="d1"/>\r
+ <key attr.name="description" attr.type="string" for="node" id="d2">\r
+ <default/>\r
+ </key>\r
+ <key for="node" id="d3" yfiles.type="nodegraphics"/>\r
+ <key attr.name="url" attr.type="string" for="edge" id="d4"/>\r
+ <key attr.name="description" attr.type="string" for="edge" id="d5">\r
+ <default/>\r
+ </key>\r
+ <key for="edge" id="d6" yfiles.type="edgegraphics"/>\r
+ <graph edgedefault="directed" id="G">\r
+ <node id="n0" yfiles.foldertype="group">\r
+ <data key="d2"/>\r
+ <data key="d3">\r
+ <y:ProxyAutoBoundsNode>\r
+ <y:Realizers active="0">\r
+ <y:GroupNode>\r
+ <y:Geometry height="92.0" width="532.0" x="99.0" y="298.0"/>\r
+ <y:Fill color="#F5F5F5" transparent="false"/>\r
+ <y:BorderStyle color="#000000" type="line" width="1.0"/>\r
+ <y:NodeLabel alignment="center" autoSizePolicy="node_width" backgroundColor="#EBEBEB" borderDistance="0.0" fontFamily="Dialog" fontSize="15" fontStyle="plain" hasLineColor="false" height="22.37646484375" modelName="free" modelPosition="anywhere" textColor="#000000" visible="true" width="532.0" x="0.0" y="0.0">mapping</y:NodeLabel>\r
+ <y:Shape type="rectangle"/>\r
+ <y:State closed="false" innerGraphDisplayEnabled="false"/>\r
+ <y:Insets bottom="15" bottomF="15.0" left="15" leftF="15.0" right="15" rightF="15.0" top="15" topF="15.0"/>\r
+ <y:BorderInsets bottom="0" bottomF="0.0" left="0" leftF="0.0" right="0" rightF="0.0" top="20" topF="20.0"/>\r
+ </y:GroupNode>\r
+ <y:GroupNode>\r
+ <y:Geometry height="80.0" width="100.0" x="-50.0" y="-30.0"/>\r
+ <y:Fill color="#CAECFF84" transparent="false"/>\r
+ <y:BorderStyle color="#666699" type="dotted" width="1.0"/>\r
+ <y:NodeLabel alignment="right" autoSizePolicy="node_width" backgroundColor="#99CCFF" borderDistance="0.0" fontFamily="Dialog" fontSize="15" fontStyle="plain" hasLineColor="false" height="4.0" modelName="internal" modelPosition="t" textColor="#000000" visible="true" width="100.0" x="0.0" y="0.0"/>\r
+ <y:Shape type="roundrectangle"/>\r
+ <y:State closed="true" innerGraphDisplayEnabled="false"/>\r
+ <y:Insets bottom="15" bottomF="15.0" left="15" leftF="15.0" right="15" rightF="15.0" top="15" topF="15.0"/>\r
+ <y:BorderInsets bottom="0" bottomF="0.0" left="0" leftF="0.0" right="0" rightF="0.0" top="0" topF="0.0"/>\r
+ </y:GroupNode>\r
+ </y:Realizers>\r
+ </y:ProxyAutoBoundsNode>\r
+ </data>\r
+ <graph edgedefault="directed" id="n0:">\r
+ <node id="n0::n0">\r
+ <data key="d3">\r
+ <y:ShapeNode>\r
+ <y:Geometry height="30.0" width="103.0" x="513.0" y="333.0"/>\r
+ <y:Fill color="#FFFFFF" transparent="false"/>\r
+ <y:BorderStyle color="#000000" type="line" width="1.0"/>\r
+ <y:NodeLabel alignment="center" autoSizePolicy="content" fontFamily="Dialog" fontSize="12" fontStyle="plain" hasBackgroundColor="false" hasLineColor="false" height="4.0" modelName="internal" modelPosition="c" textColor="#000000" visible="true" width="4.0" x="49.5" y="13.0"/>\r
+ <y:Shape type="rectangle"/>\r
+ </y:ShapeNode>\r
+ </data>\r
+ </node>\r
+ <node id="n0::n1">\r
+ <data key="d3">\r
+ <y:ShapeNode>\r
+ <y:Geometry height="30.0" width="103.0" x="507.0" y="339.0"/>\r
+ <y:Fill color="#FFFFFF" transparent="false"/>\r
+ <y:BorderStyle color="#000000" type="line" width="1.0"/>\r
+ <y:NodeLabel alignment="center" autoSizePolicy="content" fontFamily="Dialog" fontSize="12" fontStyle="plain" hasBackgroundColor="false" hasLineColor="false" height="4.0" modelName="internal" modelPosition="c" textColor="#000000" visible="true" width="4.0" x="49.5" y="13.0"/>\r
+ <y:Shape type="rectangle"/>\r
+ </y:ShapeNode>\r
+ </data>\r
+ </node>\r
+ <node id="n0::n2">\r
+ <data key="d3">\r
+ <y:ShapeNode>\r
+ <y:Geometry height="30.0" width="103.0" x="319.5" y="333.0"/>\r
+ <y:Fill color="#FFFFFF" transparent="false"/>\r
+ <y:BorderStyle color="#000000" type="line" width="1.0"/>\r
+ <y:NodeLabel alignment="center" autoSizePolicy="content" fontFamily="Dialog" fontSize="12" fontStyle="plain" hasBackgroundColor="false" hasLineColor="false" height="4.0" modelName="internal" modelPosition="c" textColor="#000000" visible="true" width="4.0" x="49.5" y="13.0"/>\r
+ <y:Shape type="rectangle"/>\r
+ </y:ShapeNode>\r
+ </data>\r
+ </node>\r
+ <node id="n0::n3">\r
+ <data key="d3">\r
+ <y:ShapeNode>\r
+ <y:Geometry height="30.0" width="103.0" x="313.5" y="339.0"/>\r
+ <y:Fill color="#FFFFFF" transparent="false"/>\r
+ <y:BorderStyle color="#000000" type="line" width="1.0"/>\r
+ <y:NodeLabel alignment="center" autoSizePolicy="content" fontFamily="Dialog" fontSize="12" fontStyle="plain" hasBackgroundColor="false" hasLineColor="false" height="4.0" modelName="internal" modelPosition="c" textColor="#000000" visible="true" width="4.0" x="49.5" y="13.0"/>\r
+ <y:Shape type="rectangle"/>\r
+ </y:ShapeNode>\r
+ </data>\r
+ </node>\r
+ <node id="n0::n4">\r
+ <data key="d3">\r
+ <y:ShapeNode>\r
+ <y:Geometry height="30.0" width="103.0" x="126.0" y="333.0"/>\r
+ <y:Fill color="#FFFFFF" transparent="false"/>\r
+ <y:BorderStyle color="#000000" type="line" width="1.0"/>\r
+ <y:NodeLabel alignment="center" autoSizePolicy="content" fontFamily="Dialog" fontSize="12" fontStyle="plain" hasBackgroundColor="false" hasLineColor="false" height="4.0" modelName="internal" modelPosition="c" textColor="#000000" visible="true" width="4.0" x="49.5" y="13.0"/>\r
+ <y:Shape type="rectangle"/>\r
+ </y:ShapeNode>\r
+ </data>\r
+ </node>\r
+ <node id="n0::n5">\r
+ <data key="d3">\r
+ <y:ShapeNode>\r
+ <y:Geometry height="30.0" width="103.0" x="120.0" y="339.0"/>\r
+ <y:Fill color="#FFFFFF" transparent="false"/>\r
+ <y:BorderStyle color="#000000" type="line" width="1.0"/>\r
+ <y:NodeLabel alignment="center" autoSizePolicy="content" fontFamily="Dialog" fontSize="12" fontStyle="plain" hasBackgroundColor="false" hasLineColor="false" height="4.0" modelName="internal" modelPosition="c" textColor="#000000" visible="true" width="4.0" x="49.5" y="13.0"/>\r
+ <y:Shape type="rectangle"/>\r
+ </y:ShapeNode>\r
+ </data>\r
+ </node>\r
+ <node id="n0::n6">\r
+ <data key="d3">\r
+ <y:ShapeNode>\r
+ <y:Geometry height="30.0" width="103.0" x="114.0" y="345.0"/>\r
+ <y:Fill color="#FFFFFF" transparent="false"/>\r
+ <y:BorderStyle color="#000000" type="line" width="1.0"/>\r
+ <y:NodeLabel alignment="center" autoSizePolicy="content" fontFamily="Dialog" fontSize="12" fontStyle="plain" hasBackgroundColor="false" hasLineColor="false" height="18.701171875" modelName="internal" modelPosition="c" textColor="#000000" visible="true" width="89.3828125" x="6.80859375" y="5.6494140625">domain element</y:NodeLabel>\r
+ <y:Shape type="rectangle"/>\r
+ </y:ShapeNode>\r
+ </data>\r
+ </node>\r
+ <node id="n0::n7">\r
+ <data key="d3">\r
+ <y:ShapeNode>\r
+ <y:Geometry height="30.0" width="103.0" x="307.5" y="345.0"/>\r
+ <y:Fill color="#FFFFFF" transparent="false"/>\r
+ <y:BorderStyle color="#000000" type="line" width="1.0"/>\r
+ <y:NodeLabel alignment="center" autoSizePolicy="content" fontFamily="Dialog" fontSize="12" fontStyle="plain" hasBackgroundColor="false" hasLineColor="false" height="18.701171875" modelName="internal" modelPosition="c" textColor="#000000" visible="true" width="22.005859375" x="40.4970703125" y="5.6494140625">link</y:NodeLabel>\r
+ <y:Shape type="rectangle"/>\r
+ </y:ShapeNode>\r
+ </data>\r
+ </node>\r
+ <node id="n0::n8">\r
+ <data key="d3">\r
+ <y:ShapeNode>\r
+ <y:Geometry height="30.0" width="103.0" x="501.0" y="345.0"/>\r
+ <y:Fill color="#FFFFFF" transparent="false"/>\r
+ <y:BorderStyle color="#000000" type="line" width="1.0"/>\r
+ <y:NodeLabel alignment="center" autoSizePolicy="content" fontFamily="Dialog" fontSize="12" fontStyle="plain" hasBackgroundColor="false" hasLineColor="false" height="18.701171875" modelName="internal" modelPosition="c" textColor="#000000" visible="true" width="80.716796875" x="11.1416015625" y="5.6494140625">range element</y:NodeLabel>\r
+ <y:Shape type="rectangle"/>\r
+ </y:ShapeNode>\r
+ </data>\r
+ </node>\r
+ <edge id="n0::e0" source="n0::n7" target="n0::n8">\r
+ <data key="d6">\r
+ <y:PolyLineEdge>\r
+ <y:Path sx="0.0" sy="0.0" tx="0.0" ty="0.0"/>\r
+ <y:LineStyle color="#000000" type="line" width="1.0"/>\r
+ <y:Arrows source="none" target="standard"/>\r
+ <y:BendStyle smoothed="false"/>\r
+ </y:PolyLineEdge>\r
+ </data>\r
+ </edge>\r
+ <edge id="n0::e1" source="n0::n7" target="n0::n6">\r
+ <data key="d6">\r
+ <y:PolyLineEdge>\r
+ <y:Path sx="0.0" sy="0.0" tx="0.0" ty="0.0"/>\r
+ <y:LineStyle color="#000000" type="line" width="1.0"/>\r
+ <y:Arrows source="none" target="standard"/>\r
+ <y:BendStyle smoothed="false"/>\r
+ </y:PolyLineEdge>\r
+ </data>\r
+ </edge>\r
+ </graph>\r
+ </node>\r
+ <node id="n1">\r
+ <data key="d3">\r
+ <y:ShapeNode>\r
+ <y:Geometry height="30.0" width="103.0" x="313.5" y="426.58361904761904"/>\r
+ <y:Fill color="#FFFFFF" transparent="false"/>\r
+ <y:BorderStyle color="#000000" type="line" width="1.0"/>\r
+ <y:NodeLabel alignment="center" autoSizePolicy="content" fontFamily="Dialog" fontSize="12" fontStyle="plain" hasBackgroundColor="false" hasLineColor="false" height="4.0" modelName="internal" modelPosition="c" textColor="#000000" visible="true" width="4.0" x="49.5" y="13.0"/>\r
+ <y:Shape type="rectangle"/>\r
+ </y:ShapeNode>\r
+ </data>\r
+ </node>\r
+ <node id="n2">\r
+ <data key="d3">\r
+ <y:ShapeNode>\r
+ <y:Geometry height="30.0" width="103.0" x="307.5" y="433.9028571428571"/>\r
+ <y:Fill color="#FFFFFF" transparent="false"/>\r
+ <y:BorderStyle color="#000000" type="line" width="1.0"/>\r
+ <y:NodeLabel alignment="center" autoSizePolicy="content" fontFamily="Dialog" fontSize="12" fontStyle="plain" hasBackgroundColor="false" hasLineColor="false" height="18.701171875" modelName="internal" modelPosition="c" textColor="#000000" visible="true" width="48.021484375" x="27.4892578125" y="5.6494140625">link type</y:NodeLabel>\r
+ <y:Shape type="rectangle"/>\r
+ </y:ShapeNode>\r
+ </data>\r
+ </node>\r
+ <edge id="e0" source="n0::n7" target="n2">\r
+ <data key="d6">\r
+ <y:PolyLineEdge>\r
+ <y:Path sx="0.0" sy="0.0" tx="0.0" ty="0.0"/>\r
+ <y:LineStyle color="#000000" type="line" width="1.0"/>\r
+ <y:Arrows source="none" target="standard"/>\r
+ <y:BendStyle smoothed="false"/>\r
+ </y:PolyLineEdge>\r
+ </data>\r
+ </edge>\r
+ </graph>\r
+ <data key="d0">\r
+ <y:Resources/>\r
+ </data>\r
+</graphml>\r
--- /dev/null
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>\r
+<graphml xmlns="http://graphml.graphdrawing.org/xmlns" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:y="http://www.yworks.com/xml/graphml" xsi:schemaLocation="http://graphml.graphdrawing.org/xmlns http://www.yworks.com/xml/schema/graphml/1.0/ygraphml.xsd">\r
+ <!--Created by yFiles for Java 2.7-->\r
+ <key for="graphml" id="d0" yfiles.type="resources"/>\r
+ <key attr.name="url" attr.type="string" for="node" id="d1"/>\r
+ <key attr.name="description" attr.type="string" for="node" id="d2">\r
+ <default/>\r
+ </key>\r
+ <key for="node" id="d3" yfiles.type="nodegraphics"/>\r
+ <key attr.name="url" attr.type="string" for="edge" id="d4"/>\r
+ <key attr.name="description" attr.type="string" for="edge" id="d5">\r
+ <default/>\r
+ </key>\r
+ <key for="edge" id="d6" yfiles.type="edgegraphics"/>\r
+ <graph edgedefault="directed" id="G">\r
+ <node id="n0">\r
+ <data key="d2"/>\r
+ <data key="d3">\r
+ <y:ShapeNode>\r
+ <y:Geometry height="30.0" width="127.0" x="186.0" y="200.0"/>\r
+ <y:Fill color="#FFFFFF" transparent="false"/>\r
+ <y:BorderStyle color="#000000" type="line" width="1.0"/>\r
+ <y:NodeLabel alignment="center" autoSizePolicy="content" fontFamily="Dialog" fontSize="12" fontStyle="plain" hasBackgroundColor="false" hasLineColor="false" height="18.701171875" modelName="internal" modelPosition="c" textColor="#000000" visible="true" width="106.720703125" x="10.1396484375" y="5.6494140625">Intermediate model</y:NodeLabel>\r
+ <y:Shape type="rectangle"/>\r
+ </y:ShapeNode>\r
+ </data>\r
+ </node>\r
+ <node id="n1">\r
+ <data key="d2"/>\r
+ <data key="d3">\r
+ <y:ShapeNode>\r
+ <y:Geometry height="30.0" width="103.0" x="80.0" y="315.0"/>\r
+ <y:Fill color="#FFFFFF" transparent="false"/>\r
+ <y:BorderStyle color="#000000" type="line" width="1.0"/>\r
+ <y:NodeLabel alignment="center" autoSizePolicy="content" fontFamily="Dialog" fontSize="12" fontStyle="plain" hasBackgroundColor="false" hasLineColor="false" height="18.701171875" modelName="internal" modelPosition="c" textColor="#000000" visible="true" width="55.369140625" x="23.8154296875" y="5.6494140625">Database</y:NodeLabel>\r
+ <y:Shape type="rectangle"/>\r
+ </y:ShapeNode>\r
+ </data>\r
+ </node>\r
+ <node id="n2">\r
+ <data key="d2"/>\r
+ <data key="d3">\r
+ <y:ShapeNode>\r
+ <y:Geometry height="30.0" width="103.0" x="320.0" y="315.0"/>\r
+ <y:Fill color="#FFFFFF" transparent="false"/>\r
+ <y:BorderStyle color="#000000" type="line" width="1.0"/>\r
+ <y:NodeLabel alignment="center" autoSizePolicy="content" fontFamily="Dialog" fontSize="12" fontStyle="plain" hasBackgroundColor="false" hasLineColor="false" height="18.701171875" modelName="internal" modelPosition="c" textColor="#000000" visible="true" width="35.34765625" x="33.826171875" y="5.6494140625">Editor</y:NodeLabel>\r
+ <y:Shape type="rectangle"/>\r
+ </y:ShapeNode>\r
+ </data>\r
+ </node>\r
+ <edge id="e0" source="n1" target="n0">\r
+ <data key="d6">\r
+ <y:PolyLineEdge>\r
+ <y:Path sx="0.0" sy="0.0" tx="0.0" ty="0.0"/>\r
+ <y:LineStyle color="#000000" type="line" width="1.0"/>\r
+ <y:Arrows source="none" target="standard"/>\r
+ <y:EdgeLabel alignment="center" distance="2.0" fontFamily="Dialog" fontSize="12" fontStyle="plain" hasBackgroundColor="false" hasLineColor="false" height="18.701171875" modelName="six_pos" modelPosition="tail" preferredPlacement="anywhere" ratio="0.5" textColor="#000000" visible="true" width="34.017578125" x="55.20320262079653" y="-51.8505859375">reads</y:EdgeLabel>\r
+ <y:BendStyle smoothed="false"/>\r
+ </y:PolyLineEdge>\r
+ </data>\r
+ </edge>\r
+ <edge id="e1" source="n0" target="n2">\r
+ <data key="d6">\r
+ <y:PolyLineEdge>\r
+ <y:Path sx="0.0" sy="0.0" tx="0.0" ty="0.0"/>\r
+ <y:LineStyle color="#000000" type="line" width="1.0"/>\r
+ <y:Arrows source="none" target="standard"/>\r
+ <y:EdgeLabel alignment="center" distance="2.0" fontFamily="Dialog" fontSize="12" fontStyle="plain" hasBackgroundColor="false" hasLineColor="false" height="18.701171875" modelName="six_pos" modelPosition="tail" preferredPlacement="anywhere" ratio="0.5" textColor="#000000" visible="true" width="56.01953125" x="57.00669661812162" y="33.1494140625">visualizes</y:EdgeLabel>\r
+ <y:BendStyle smoothed="false"/>\r
+ </y:PolyLineEdge>\r
+ </data>\r
+ </edge>\r
+ <edge id="e2" source="n2" target="n1">\r
+ <data key="d6">\r
+ <y:PolyLineEdge>\r
+ <y:Path sx="0.0" sy="0.0" tx="0.0" ty="0.0"/>\r
+ <y:LineStyle color="#000000" type="line" width="1.0"/>\r
+ <y:Arrows source="none" target="standard"/>\r
+ <y:EdgeLabel alignment="center" distance="2.0" fontFamily="Dialog" fontSize="12" fontStyle="plain" hasBackgroundColor="false" hasLineColor="false" height="18.701171875" modelName="six_pos" modelPosition="tail" preferredPlacement="anywhere" ratio="0.5" textColor="#000000" visible="true" width="48.68359375" x="-92.841796875" y="2.0">modifies</y:EdgeLabel>\r
+ <y:BendStyle smoothed="false"/>\r
+ </y:PolyLineEdge>\r
+ </data>\r
+ </edge>\r
+ </graph>\r
+ <data key="d0">\r
+ <y:Resources/>\r
+ </data>\r
+</graphml>\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2010 Association for Decentralized Information Management\r
+ * in Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.objmap.examples;\r
+\r
+import java.util.Collection;\r
+\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.objmap.IMappingSchema;\r
+import org.simantics.objmap.annotations.GraphType;\r
+import org.simantics.objmap.annotations.RelatedElement;\r
+import org.simantics.objmap.annotations.RelatedElements;\r
+import org.simantics.objmap.annotations.RelatedValue;\r
+import org.simantics.objmap.schema.MappingSchemas;\r
+import org.simantics.objmap.schema.SimpleSchema;\r
+\r
+public class SysdynExample {\r
+\r
+ @GraphType("http://www.simantics.org/Sysdyn-1.0/Configuration")\r
+ static class Configuration {\r
+ @RelatedElements("http://www.simantics.org/Layer0-1.0/ConsistsOf")\r
+ Collection<Component> components;\r
+ }\r
+\r
+ static abstract class Component {\r
+ }\r
+\r
+ @GraphType("http://www.simantics.org/Sysdyn-1.0/Dependency")\r
+ static class Dependency extends Component {\r
+ @RelatedElement("http://www.simantics.org/Sysdyn-1.0/HasTail")\r
+ Variable tail;\r
+ @RelatedElement("http://www.simantics.org/Sysdyn-1.0/HasHead")\r
+ Auxiliary head;\r
+ }\r
+\r
+ static abstract class Variable extends Component {\r
+ @RelatedValue("http://www.simantics.org/Layer0-1.0/HasName")\r
+ String name;\r
+ }\r
+\r
+ @GraphType("http://www.simantics.org/Sysdyn-1.0/Auxiliary")\r
+ static class Auxiliary extends Variable {\r
+ }\r
+\r
+ public static IMappingSchema createSchema(ReadGraph g) throws DatabaseException, InstantiationException, IllegalAccessException {\r
+ SimpleSchema schema = new SimpleSchema();\r
+ schema.addLinkType(MappingSchemas.fromAnnotations(g, Configuration.class));\r
+ schema.addLinkType(MappingSchemas.fromAnnotations(g, Dependency.class));\r
+ schema.addLinkType(MappingSchemas.fromAnnotations(g, Auxiliary.class));\r
+ return schema;\r
+ }\r
+\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2010 Association for Decentralized Information Management\r
+ * in Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.objmap;\r
+\r
+/**\r
+ * A generic function object that throws MappingExceptions.\r
+ * \r
+ * @author Hannu Niemistö\r
+ *\r
+ * @param <D> Domain of the function\r
+ * @param <R> Range of the function\r
+ */\r
+public interface IFunction<D, R> {\r
+ R get(D element) throws MappingException;\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2010 Association for Decentralized Information Management\r
+ * in Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.objmap;\r
+\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.WriteGraph;\r
+\r
+/**\r
+ * Contains rules for how a link should be created and maintained.\r
+ * @author Hannu Niemistö\r
+ */\r
+public interface ILinkType extends IMappingRule {\r
+ /**\r
+ * Creates a domain element based on known range element.\r
+ */\r
+ Resource createDomainElement(WriteGraph g, Object rangeElement) throws MappingException;\r
+ \r
+ /**\r
+ * Creates a range element based on known domain element.\r
+ */\r
+ Object createRangeElement(ReadGraph g, Resource domainElement) throws MappingException;\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2010 Association for Decentralized Information Management\r
+ * in Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.objmap;\r
+\r
+import java.util.Collection;\r
+import java.util.Set;\r
+\r
+import org.simantics.db.Disposable;\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.WriteGraph;\r
+\r
+/**\r
+ * A mapping consists of domain (a set of resources), range (a set of Java objects) and\r
+ * a set of links relating them. The mapping is used to propagate modifications of\r
+ * domain elements to range and vice versa. \r
+ * \r
+ * @see <a href="http://www.simantics.org/wiki/index.php/org.simantics.objmap_Manual#Concepts">Manual</a>\r
+ * \r
+ * @author Hannu Niemistö\r
+ */\r
+public interface IMapping extends Disposable {\r
+\r
+ /**\r
+ * Returns the domain of the mapping. All set operations are supported.\r
+ * Adding a new domain element does not automatically create a link to it.\r
+ * Removal of a domain element removes also a link and the target element,\r
+ * but does not remove the element from the database.\r
+ */\r
+ Set<Resource> getDomain();\r
+\r
+ /**\r
+ * Returns the range of the mapping. All set operations are supported.\r
+ * Adding a new range element does not automatically create a link to it.\r
+ * Removal of a range element removes also a link and the domain element,\r
+ * but does not remove the domain element from the database.\r
+ */\r
+ Set<Object> getRange();\r
+\r
+ /**\r
+ * Updates all domain elements whose counterpart is modified and creates new\r
+ * domain elements for previously added range elements. Returns the\r
+ * collection of domain elements that were modified or created in the update\r
+ * process.\r
+ */\r
+ Collection<Resource> updateDomain(WriteGraph g) throws MappingException;\r
+\r
+ /**\r
+ * Updates all range elements whose counterpart is modified and creates new\r
+ * range elements for previously added domain elements. Returns the\r
+ * collection of range elements that were modified or created in the update\r
+ * process.\r
+ */\r
+ Collection<Object> updateRange(ReadGraph g) throws MappingException;\r
+\r
+ /**\r
+ * Returns the counterpart of a domain element or null if the element does\r
+ * not belong to the domain or does not have a link.\r
+ */\r
+ Object get(Resource domainElement);\r
+\r
+ /**\r
+ * Returns the counterpart of a range element or null if the element does\r
+ * not belong to the range or does not have a link.\r
+ */\r
+ Resource inverseGet(Object rangeElement);\r
+\r
+ /**\r
+ * A convenience method that adds a domain element to the mapping and\r
+ * immediately updates the mapping and returns the corresponding range\r
+ * element.\r
+ */\r
+ Object map(ReadGraph g, Resource domainElement) throws MappingException;\r
+\r
+ /**\r
+ * A convenience method that adds a range element to the mapping and\r
+ * immediately updates the mapping and returns the corresponding domain\r
+ * element.\r
+ */\r
+ Resource inverseMap(WriteGraph g, Object rangeElement)\r
+ throws MappingException;\r
+\r
+ /**\r
+ * Tells the mapping that the domain element has been modified.\r
+ */\r
+ void domainModified(Resource domainElement);\r
+\r
+ /**\r
+ * Tells the mapping that the range element has been modified.\r
+ */\r
+ void rangeModified(Object rangeElement);\r
+\r
+ /**\r
+ * Tells if some domain elements have been modified or added.\r
+ */\r
+ boolean isDomainModified();\r
+\r
+ /**\r
+ * Tells if some range elements have been modified or added.\r
+ */\r
+ boolean isRangeModified();\r
+\r
+ /**\r
+ * Returns a collection of domain elements which have been modified and also\r
+ * their counterparts in the mapping are modified. These elements are in\r
+ * conflict in the sense that the updating domain and range in different\r
+ * orders may produce different results.\r
+ */\r
+ Collection<Resource> getConflictingDomainElements();\r
+\r
+ /**\r
+ * Returns a collection of range elements which have been modified and also\r
+ * their counterparts in the mapping are modified. These elements are in\r
+ * conflict in the sense that the updating domain and range in different\r
+ * orders may produce different results.\r
+ */\r
+ Collection<Object> getConflictingRangeElements();\r
+\r
+ /**\r
+ * Adds a listener for domain and range modifications.\r
+ */\r
+ void addMappingListener(IMappingListener listener);\r
+\r
+ /**\r
+ * Removes a previously added listener.\r
+ */\r
+ void removeMappingListener(IMappingListener listener);\r
+\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2010 Association for Decentralized Information Management\r
+ * in Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.objmap;\r
+\r
+/**\r
+ * Listens modifications in a mapping.\r
+ * @author Hannu Niemistö\r
+ */\r
+public interface IMappingListener {\r
+ /**\r
+ * Called when some domain element is modified or created\r
+ * and the mapping was previously up to date.\r
+ */\r
+ void domainModified();\r
+ \r
+ /**\r
+ * Called when some range element is modified or created\r
+ * and the mapping was previously up to date.\r
+ */\r
+ void rangeModified();\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2010 Association for Decentralized Information Management\r
+ * in Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.objmap;\r
+\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.WriteGraph;\r
+\r
+/**\r
+ * A rule for how domain and range elements are related to each other. \r
+ * @author Hannu Niemistö\r
+ */\r
+public interface IMappingRule {\r
+ /**\r
+ * Modifies the domain element so that it corresponds to the range element.\r
+ * @param g write transaction\r
+ * @param map unidirectional view of the current mapping\r
+ * @param domainElement the domain element that is updated\r
+ * @param rangeElement the range element that corresponds to the domain element\r
+ * @return true if the rule made some modifications\r
+ * @throws MappingException \r
+ */ \r
+ boolean updateDomain(WriteGraph g, IFunction<Object, Resource> map, Resource domainElement, Object rangeElement) throws MappingException;\r
+\r
+ /**\r
+ * Modifies the range element so that it corresponds to the domain element.\r
+ * @param g read transaction\r
+ * @param map unidirectional view of the current mapping\r
+ * @param domainElement the domain element that corresponds to the range element\r
+ * @param rangeElement the range element that is updated\r
+ * @return true if the rule made some modifications\r
+ * @throws MappingException\r
+ */\r
+ boolean updateRange(ReadGraph g, IFunction<Resource, Object> map, Resource domainElement, Object rangeElement) throws MappingException;\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2010 Association for Decentralized Information Management\r
+ * in Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.objmap;\r
+\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.Resource;\r
+\r
+/**\r
+ * Specifies the link types of new elements added to a mapping.\r
+ * @author Hannu Niemistö\r
+ */\r
+public interface IMappingSchema {\r
+ /**\r
+ * @return Link type that should be used for the element.\r
+ */\r
+ ILinkType linkTypeOfDomainElement(ReadGraph g, Resource element) throws MappingException;\r
+ \r
+ /**\r
+ * @return Link type that should be used for the element.\r
+ */\r
+ ILinkType linkTypeOfRangeElement(Object element) throws MappingException;\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2010 Association for Decentralized Information Management\r
+ * in Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.objmap;\r
+\r
+import org.simantics.db.exception.DatabaseException;\r
+\r
+/**\r
+ * An exception thrown for any error during mapping methods.\r
+ * @author Hannu Niemistö\r
+ */\r
+public class MappingException extends DatabaseException {\r
+\r
+ private static final long serialVersionUID = -4026122899414272427L;\r
+\r
+ public MappingException() {\r
+ super();\r
+ }\r
+\r
+ public MappingException(String message, Throwable cause) {\r
+ super(message, cause);\r
+ }\r
+\r
+ public MappingException(String message) {\r
+ super(message);\r
+ }\r
+\r
+ public MappingException(Throwable cause) {\r
+ super(cause);\r
+ }\r
+ \r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2010 Association for Decentralized Information Management\r
+ * in Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.objmap;\r
+\r
+import org.simantics.objmap.impl.Mapping;\r
+import org.simantics.objmap.impl.UnidirectionalMapping;\r
+\r
+/**\r
+ * Static utility methods for mappings. \r
+ * @author Hannu Niemistö\r
+ */\r
+public class Mappings {\r
+ private Mappings() {}\r
+ \r
+ /**\r
+ * Creates a new mapping based on the given mapping schema. \r
+ * The created mapping is not thread-safe and will not\r
+ * listen database changes automatically.\r
+ */\r
+ public static IMapping createWithoutListening(IMappingSchema schema) {\r
+ return new Mapping(schema, false);\r
+ }\r
+ \r
+ /**\r
+ * Creates a new mapping based on the given mapping schema. \r
+ * The created mapping is not thread-safe. It listens database\r
+ * changes automatically.\r
+ */\r
+ public static IMapping createWithListening(IMappingSchema schema) {\r
+ return new Mapping(schema, true);\r
+ }\r
+ \r
+ /**\r
+ * Creates a mapping that supports only the direction from domain to range.\r
+ * Does not listen the database.\r
+ */\r
+ public static IMapping createUnidirectional(IMappingSchema schema) {\r
+ return new UnidirectionalMapping(schema);\r
+ }\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2010 Association for Decentralized Information Management\r
+ * in Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.objmap.annotations;\r
+\r
+import java.lang.annotation.ElementType;\r
+import java.lang.annotation.Retention;\r
+import java.lang.annotation.RetentionPolicy;\r
+import java.lang.annotation.Target;\r
+\r
+@Retention(RetentionPolicy.RUNTIME)\r
+@Target({ElementType.FIELD,ElementType.METHOD})\r
+public @interface Composition {\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2010 Association for Decentralized Information Management\r
+ * in Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.objmap.annotations;\r
+\r
+import java.lang.annotation.ElementType;\r
+import java.lang.annotation.Retention;\r
+import java.lang.annotation.RetentionPolicy;\r
+import java.lang.annotation.Target;\r
+\r
+/**\r
+ * Specifies the domain type that the class corresponds to. \r
+ * @author Hannu Niemistö\r
+ */\r
+@Retention(RetentionPolicy.RUNTIME)\r
+@Target(ElementType.TYPE) \r
+public @interface GraphType {\r
+ String value();\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2010 Association for Decentralized Information Management\r
+ * in Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.objmap.annotations;\r
+\r
+import java.lang.annotation.ElementType;\r
+import java.lang.annotation.Retention;\r
+import java.lang.annotation.RetentionPolicy;\r
+import java.lang.annotation.Target;\r
+\r
+import org.simantics.objmap.annotations.factories.OptionalRelatedElementsRuleFactory;\r
+import org.simantics.objmap.annotations.meta.HasFieldRuleFactory;\r
+\r
+@Retention(RetentionPolicy.RUNTIME)\r
+@Target(ElementType.FIELD)\r
+@HasFieldRuleFactory(OptionalRelatedElementsRuleFactory.class)\r
+public @interface OptionalRelatedElements {\r
+ String value();\r
+ boolean composition() default false;\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2010 Association for Decentralized Information Management\r
+ * in Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.objmap.annotations;\r
+\r
+import java.lang.annotation.ElementType;\r
+import java.lang.annotation.Retention;\r
+import java.lang.annotation.RetentionPolicy;\r
+import java.lang.annotation.Target;\r
+\r
+import org.simantics.objmap.annotations.factories.RelatedElementRuleFactory;\r
+import org.simantics.objmap.annotations.meta.HasFieldRuleFactory;\r
+\r
+@Retention(RetentionPolicy.RUNTIME)\r
+@Target(ElementType.FIELD)\r
+@HasFieldRuleFactory(RelatedElementRuleFactory.class)\r
+public @interface RelatedElement {\r
+ String value();\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2010 Association for Decentralized Information Management\r
+ * in Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.objmap.annotations;\r
+\r
+import java.lang.annotation.ElementType;\r
+import java.lang.annotation.Retention;\r
+import java.lang.annotation.RetentionPolicy;\r
+import java.lang.annotation.Target;\r
+\r
+import org.simantics.objmap.annotations.factories.RelatedElementsRuleFactory;\r
+import org.simantics.objmap.annotations.meta.HasFieldRuleFactory;\r
+\r
+@Retention(RetentionPolicy.RUNTIME)\r
+@Target(ElementType.FIELD)\r
+@HasFieldRuleFactory(RelatedElementsRuleFactory.class)\r
+public @interface RelatedElements {\r
+ String value();\r
+ boolean composition() default false;\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2010 Association for Decentralized Information Management\r
+ * in Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.objmap.annotations;\r
+\r
+import java.lang.annotation.ElementType;\r
+import java.lang.annotation.Retention;\r
+import java.lang.annotation.RetentionPolicy;\r
+import java.lang.annotation.Target;\r
+\r
+import org.simantics.objmap.annotations.factories.RelatedOrderedSetElementsRuleFactory;\r
+import org.simantics.objmap.annotations.meta.HasFieldRuleFactory;\r
+\r
+@Retention(RetentionPolicy.RUNTIME)\r
+@Target(ElementType.FIELD)\r
+@HasFieldRuleFactory(RelatedOrderedSetElementsRuleFactory.class)\r
+public @interface RelatedOrderedSetElements {\r
+ boolean composition() default false;\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2010 Association for Decentralized Information Management\r
+ * in Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.objmap.annotations;\r
+\r
+import java.lang.annotation.ElementType;\r
+import java.lang.annotation.Retention;\r
+import java.lang.annotation.RetentionPolicy;\r
+import java.lang.annotation.Target;\r
+\r
+import org.simantics.objmap.annotations.factories.RelatedValueRuleFactory;\r
+import org.simantics.objmap.annotations.meta.HasFieldRuleFactory;\r
+\r
+/**\r
+ * Specifies a correspondence between a field and \r
+ * functional property.\r
+ * @author Hannu Niemistö\r
+ */\r
+@Retention(RetentionPolicy.RUNTIME)\r
+@Target(ElementType.FIELD)\r
+@HasFieldRuleFactory(RelatedValueRuleFactory.class)\r
+public @interface RelatedValue {\r
+ String value();\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2010 Association for Decentralized Information Management\r
+ * in Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.objmap.annotations;\r
+\r
+import java.lang.annotation.ElementType;\r
+import java.lang.annotation.Retention;\r
+import java.lang.annotation.RetentionPolicy;\r
+import java.lang.annotation.Target;\r
+\r
+import org.simantics.objmap.annotations.factories.UpdateMethodFactory;\r
+import org.simantics.objmap.annotations.meta.HasMethodRuleFactory;\r
+\r
+/**\r
+ * Specifies that the annotated method should be called\r
+ * to update range object.\r
+ * @author Hannu Niemistö\r
+ */\r
+@Retention(RetentionPolicy.RUNTIME)\r
+@Target(ElementType.METHOD)\r
+@HasMethodRuleFactory(UpdateMethodFactory.class)\r
+public @interface UpdateMethod {\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2010 Association for Decentralized Information Management\r
+ * in Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.objmap.annotations.factories;\r
+\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.Resource;\r
+import org.simantics.layer0.Layer0;\r
+\r
+public class DataTypeUtils {\r
+ \r
+ public static Resource dataTypeOfClass(ReadGraph g, Class<?> clazz) {\r
+ Layer0 b = Layer0.getInstance(g);\r
+ if(clazz.equals(Double.class) || clazz.equals(double.class))\r
+ return b.Double;\r
+ else if(clazz.equals(String.class))\r
+ return b.String;\r
+ else if(clazz.equals(Integer.class) || clazz.equals(int.class))\r
+ return b.Integer;\r
+ else if(clazz.equals(Float.class) || clazz.equals(float.class))\r
+ return b.Float;\r
+ else if(clazz.equals(Boolean.class) || clazz.equals(boolean.class))\r
+ return b.Boolean;\r
+ else if(clazz.equals(Long.class) || clazz.equals(long.class))\r
+ return b.Long;\r
+ else if(clazz.equals(Byte.class) || clazz.equals(byte.class))\r
+ return b.Byte;\r
+ \r
+ else if(clazz.equals(double[].class))\r
+ return b.DoubleArray;\r
+ else if(clazz.equals(int[].class))\r
+ return b.IntegerArray;\r
+ else if(clazz.equals(byte[].class))\r
+ return b.ByteArray;\r
+ else if(clazz.equals(float[].class))\r
+ return b.FloatArray;\r
+ else if(clazz.equals(boolean[].class))\r
+ return b.BooleanArray;\r
+ else if(clazz.equals(String[].class))\r
+ return b.StringArray;\r
+ else if(clazz.equals(long[].class))\r
+ return b.LongArray;\r
+ else {\r
+ System.out.println("Couldn't find a data type for " + clazz);\r
+ return null;\r
+ }\r
+ }\r
+ \r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2010 Association for Decentralized Information Management\r
+ * in Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.objmap.annotations.factories;\r
+\r
+import java.lang.annotation.Annotation;\r
+import java.lang.reflect.Field;\r
+import java.util.Collection;\r
+import java.util.Collections;\r
+\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.exception.ResourceNotFoundException;\r
+import org.simantics.db.exception.ServiceException;\r
+import org.simantics.db.exception.ValidationException;\r
+import org.simantics.objmap.IMappingRule;\r
+import org.simantics.objmap.annotations.OptionalRelatedElements;\r
+import org.simantics.objmap.annotations.RelatedElements;\r
+import org.simantics.objmap.rules.MappedElementsRule;\r
+import org.simantics.objmap.rules.domain.RelatedObjectsAccessor;\r
+import org.simantics.objmap.rules.factory.IFieldRuleFactory;\r
+import org.simantics.objmap.rules.range.FieldAccessor;\r
+import org.simantics.objmap.rules.range.FieldAccessorWithDefault;\r
+\r
+public class OptionalRelatedElementsRuleFactory implements IFieldRuleFactory {\r
+\r
+ @Override\r
+ public IMappingRule create(ReadGraph g, Annotation _annotation, Field field) throws ResourceNotFoundException, ValidationException, ServiceException {\r
+ OptionalRelatedElements annotation = (OptionalRelatedElements)_annotation;\r
+ return new MappedElementsRule(\r
+ new RelatedObjectsAccessor(g.getResource(annotation.value()),\r
+ annotation.composition()),\r
+ new FieldAccessorWithDefault(field, Collections.emptyList())\r
+ );\r
+ }\r
+\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2010 Association for Decentralized Information Management\r
+ * in Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.objmap.annotations.factories;\r
+\r
+import java.lang.annotation.Annotation;\r
+import java.lang.reflect.Field;\r
+\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.exception.ResourceNotFoundException;\r
+import org.simantics.db.exception.ServiceException;\r
+import org.simantics.db.exception.ValidationException;\r
+import org.simantics.objmap.IMappingRule;\r
+import org.simantics.objmap.annotations.RelatedElement;\r
+import org.simantics.objmap.rules.MappedElementRule;\r
+import org.simantics.objmap.rules.domain.RelatedObjectAccessor;\r
+import org.simantics.objmap.rules.factory.IFieldRuleFactory;\r
+import org.simantics.objmap.rules.range.FieldAccessor;\r
+\r
+public class RelatedElementRuleFactory implements IFieldRuleFactory {\r
+\r
+ @Override\r
+ public IMappingRule create(ReadGraph g, Annotation _annotation, Field field) throws ResourceNotFoundException, ValidationException, ServiceException {\r
+ RelatedElement annotation = (RelatedElement)_annotation;\r
+ return new MappedElementRule(\r
+ new RelatedObjectAccessor(g.getResource(annotation.value())),\r
+ new FieldAccessor<Object>(field)\r
+ );\r
+ }\r
+\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2010 Association for Decentralized Information Management\r
+ * in Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.objmap.annotations.factories;\r
+\r
+import java.lang.annotation.Annotation;\r
+import java.lang.reflect.Field;\r
+import java.util.Collection;\r
+\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.exception.ResourceNotFoundException;\r
+import org.simantics.db.exception.ServiceException;\r
+import org.simantics.db.exception.ValidationException;\r
+import org.simantics.objmap.IMappingRule;\r
+import org.simantics.objmap.annotations.RelatedElements;\r
+import org.simantics.objmap.rules.MappedElementsRule;\r
+import org.simantics.objmap.rules.domain.RelatedObjectsAccessor;\r
+import org.simantics.objmap.rules.factory.IFieldRuleFactory;\r
+import org.simantics.objmap.rules.range.FieldAccessor;\r
+\r
+public class RelatedElementsRuleFactory implements IFieldRuleFactory {\r
+\r
+ @Override\r
+ public IMappingRule create(ReadGraph g, Annotation _annotation, Field field) throws ResourceNotFoundException, ValidationException, ServiceException {\r
+ RelatedElements annotation = (RelatedElements)_annotation;\r
+ return new MappedElementsRule(\r
+ new RelatedObjectsAccessor(g.getResource(annotation.value()),\r
+ annotation.composition()),\r
+ new FieldAccessor<Collection<Object>>(field)\r
+ );\r
+ }\r
+\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2010 Association for Decentralized Information Management\r
+ * in Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.objmap.annotations.factories;\r
+\r
+import java.lang.annotation.Annotation;\r
+import java.lang.reflect.Field;\r
+import java.util.Collection;\r
+\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.exception.ResourceNotFoundException;\r
+import org.simantics.db.exception.ServiceException;\r
+import org.simantics.db.exception.ValidationException;\r
+import org.simantics.objmap.IMappingRule;\r
+import org.simantics.objmap.annotations.RelatedOrderedSetElements;\r
+import org.simantics.objmap.rules.MappedElementsRule;\r
+import org.simantics.objmap.rules.domain.RelatedOrderedSetElementsAccessor;\r
+import org.simantics.objmap.rules.factory.IFieldRuleFactory;\r
+import org.simantics.objmap.rules.range.FieldAccessor;\r
+\r
+public class RelatedOrderedSetElementsRuleFactory implements IFieldRuleFactory {\r
+\r
+ @Override\r
+ public IMappingRule create(ReadGraph g, Annotation _annotation, Field field) throws ResourceNotFoundException, ValidationException, ServiceException {\r
+ RelatedOrderedSetElements annotation = (RelatedOrderedSetElements)_annotation;\r
+ return new MappedElementsRule(\r
+ new RelatedOrderedSetElementsAccessor(annotation.composition()),\r
+ new FieldAccessor<Collection<Object>>(field)\r
+ );\r
+ }\r
+\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2010 Association for Decentralized Information Management\r
+ * in Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.objmap.annotations.factories;\r
+\r
+import java.lang.annotation.Annotation;\r
+import java.lang.reflect.Field;\r
+\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.exception.ResourceNotFoundException;\r
+import org.simantics.db.exception.ServiceException;\r
+import org.simantics.db.exception.ValidationException;\r
+import org.simantics.objmap.IMappingRule;\r
+import org.simantics.objmap.annotations.RelatedValue;\r
+import org.simantics.objmap.rules.ValueRule;\r
+import org.simantics.objmap.rules.domain.RelatedValueAccessor;\r
+import org.simantics.objmap.rules.factory.IFieldRuleFactory;\r
+import org.simantics.objmap.rules.range.FieldAccessor;\r
+\r
+public class RelatedValueRuleFactory implements IFieldRuleFactory {\r
+\r
+ @Override\r
+ public IMappingRule create(ReadGraph g, Annotation _annotation, Field field) throws ResourceNotFoundException, ValidationException, ServiceException {\r
+ RelatedValue annotation = (RelatedValue)_annotation;\r
+ //Builtins b = g.getBuiltins();\r
+ return new ValueRule(\r
+ new RelatedValueAccessor(\r
+ g.getResource(annotation.value()), \r
+ DataTypeUtils.dataTypeOfClass(g, field.getType())\r
+ ),\r
+ new FieldAccessor<Object>(field)\r
+ );\r
+ }\r
+\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2010 Association for Decentralized Information Management\r
+ * in Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.objmap.annotations.factories;\r
+\r
+import java.lang.annotation.Annotation;\r
+import java.lang.reflect.Method;\r
+\r
+import org.apache.log4j.Logger;\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.WriteGraph;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.objmap.IFunction;\r
+import org.simantics.objmap.IMappingRule;\r
+import org.simantics.objmap.MappingException;\r
+import org.simantics.objmap.rules.factory.IMethodRuleFactory;\r
+\r
+public class UpdateMethodFactory implements IMethodRuleFactory {\r
+\r
+ static Logger LOGGER = Logger.getLogger("org.simantics.objmap");\r
+ \r
+ @Override\r
+ public IMappingRule create(ReadGraph g, \r
+ Annotation annotation, \r
+ final Method method)\r
+ throws DatabaseException {\r
+ method.setAccessible(true);\r
+ return new IMappingRule() {\r
+ \r
+ @Override\r
+ public boolean updateRange(ReadGraph g, IFunction<Resource, Object> map,\r
+ Resource domainElement, Object rangeElement)\r
+ throws MappingException {\r
+ LOGGER.info(" UpdateMethodFactory.updateRange"); \r
+ try {\r
+ return (Boolean)method.invoke(rangeElement, g, domainElement);\r
+ } catch (Exception e) {\r
+ // TODO Auto-generated catch block\r
+ e.printStackTrace();\r
+ }\r
+ return false;\r
+ }\r
+ \r
+ @Override\r
+ public boolean updateDomain(WriteGraph g, IFunction<Object, Resource> map,\r
+ Resource domainElement, Object rangeElement)\r
+ throws MappingException {\r
+ return false;\r
+ }\r
+ };\r
+ }\r
+\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2010 Association for Decentralized Information Management\r
+ * in Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.objmap.annotations.meta;\r
+\r
+import java.lang.annotation.ElementType;\r
+import java.lang.annotation.Retention;\r
+import java.lang.annotation.RetentionPolicy;\r
+import java.lang.annotation.Target;\r
+\r
+import org.simantics.objmap.rules.factory.IClassRuleFactory;\r
+\r
+@Retention(RetentionPolicy.RUNTIME)\r
+@Target(ElementType.ANNOTATION_TYPE) \r
+public @interface HasClassRuleFactory {\r
+ Class<? extends IClassRuleFactory> value();\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2010 Association for Decentralized Information Management\r
+ * in Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.objmap.annotations.meta;\r
+\r
+import java.lang.annotation.ElementType;\r
+import java.lang.annotation.Retention;\r
+import java.lang.annotation.RetentionPolicy;\r
+import java.lang.annotation.Target;\r
+\r
+import org.simantics.objmap.rules.factory.IFieldRuleFactory;\r
+\r
+@Retention(RetentionPolicy.RUNTIME)\r
+@Target(ElementType.ANNOTATION_TYPE) \r
+public @interface HasFieldRuleFactory {\r
+ Class<? extends IFieldRuleFactory> value();\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2010 Association for Decentralized Information Management\r
+ * in Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.objmap.annotations.meta;\r
+\r
+import java.lang.annotation.ElementType;\r
+import java.lang.annotation.Retention;\r
+import java.lang.annotation.RetentionPolicy;\r
+import java.lang.annotation.Target;\r
+\r
+import org.simantics.objmap.rules.factory.IMethodRuleFactory;\r
+\r
+@Retention(RetentionPolicy.RUNTIME)\r
+@Target(ElementType.ANNOTATION_TYPE) \r
+public @interface HasMethodRuleFactory {\r
+ Class<? extends IMethodRuleFactory> value();\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2010 Association for Decentralized Information Management\r
+ * in Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+/**\r
+ * \r
+ */\r
+package org.simantics.objmap.impl;\r
+\r
+import org.simantics.db.Resource;\r
+import org.simantics.objmap.ILinkType;\r
+\r
+/**\r
+ * An indication that the domain element corresponds to the range element\r
+ * in the mapping. The link type describes how source and target objects\r
+ * are updated. There are additionally flags for dirtiness of the link.\r
+ * @author Hannu Niemistö\r
+ */\r
+public class Link {\r
+ public ILinkType type;\r
+ public Resource domainElement;\r
+ public Object rangeElement;\r
+ \r
+ public boolean domainModified = false;\r
+ public boolean rangeModified = false;\r
+ public boolean removed = false;\r
+ \r
+ public Link(ILinkType type, Resource domainElement, Object rangeElement) {\r
+ this.type = type;\r
+ this.domainElement = domainElement;\r
+ this.rangeElement = rangeElement; \r
+ } \r
+}
\ No newline at end of file
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2010 Association for Decentralized Information Management\r
+ * in Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.objmap.impl;\r
+\r
+import gnu.trove.THashMap;\r
+import gnu.trove.TObjectIdentityHashingStrategy;\r
+\r
+import java.util.AbstractSet;\r
+import java.util.ArrayList;\r
+import java.util.Collection;\r
+import java.util.Iterator;\r
+import java.util.Set;\r
+\r
+import org.apache.log4j.Logger;\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.WriteGraph;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.objmap.IFunction;\r
+import org.simantics.objmap.ILinkType;\r
+import org.simantics.objmap.IMapping;\r
+import org.simantics.objmap.IMappingListener;\r
+import org.simantics.objmap.IMappingSchema;\r
+import org.simantics.objmap.MappingException;\r
+\r
+/**\r
+ * An implementation of IMapping. The class should not be created\r
+ * directly but using methods in Mappings.\r
+ * @see org.simantics.objmap.Mappings\r
+ * @author Hannu Niemistö\r
+ */\r
+public class Mapping implements IMapping {\r
+\r
+ static Logger LOGGER = Logger.getLogger("org.simantics.objmap");\r
+ \r
+ private static final TObjectIdentityHashingStrategy<Object> IDENTITY_HASHING =\r
+ new TObjectIdentityHashingStrategy<Object>();\r
+ \r
+ IMappingSchema schema;\r
+ \r
+ THashMap<Resource, Link> domain = new THashMap<Resource, Link>();\r
+ THashMap<Object, Link> range = new THashMap<Object, Link>(IDENTITY_HASHING);\r
+ ArrayList<IMappingListener> listeners = new ArrayList<IMappingListener>();\r
+ \r
+ ArrayList<Link> modifiedDomainLinks = new ArrayList<Link>();\r
+ ArrayList<Link> modifiedRangeLinks = new ArrayList<Link>();\r
+ boolean disposed = false;\r
+ \r
+ boolean listensDomain; \r
+ \r
+ public Mapping(IMappingSchema schema, boolean listensDomain) {\r
+ this.schema = schema;\r
+ this.listensDomain = listensDomain;\r
+ }\r
+\r
+ private void removeLink(Link link) {\r
+ if(link.domainModified)\r
+ modifiedDomainLinks.remove(link);\r
+ if(link.rangeModified)\r
+ modifiedRangeLinks.remove(link);\r
+ link.removed = true;\r
+ }\r
+ \r
+ private void createDomain(WriteGraph g, Link link) throws MappingException {\r
+ LOGGER.info(" createDomain for " + link.rangeElement);\r
+ ILinkType type = schema.linkTypeOfRangeElement(link.rangeElement);\r
+ Resource domainElement = type.createDomainElement(g, link.rangeElement);\r
+ \r
+ link.type = type;\r
+ link.domainElement = domainElement;\r
+ domain.put(domainElement, link);\r
+ \r
+ // TODO Should we do this only if the mapping is listening?\r
+ domainModified(link);\r
+ }\r
+ \r
+ private void createRange(ReadGraph g, Link link) throws MappingException {\r
+ ILinkType type = schema.linkTypeOfDomainElement(g, link.domainElement); \r
+ Object rangeElement = type.createRangeElement(g, link.domainElement);\r
+ \r
+ link.type = type;\r
+ link.rangeElement = rangeElement;\r
+ range.put(rangeElement, link);\r
+ }\r
+ \r
+ Set<Resource> domainSet = new AbstractSet<Resource>() {\r
+\r
+ public boolean add(Resource e) {\r
+ if(domain.containsKey(e))\r
+ return false;\r
+ Link link = new Link(null, e, null);\r
+ domain.put(e, link);\r
+ modifiedDomainLinks.add(link);\r
+ return true;\r
+ }\r
+ \r
+ public boolean contains(Object o) {\r
+ return domain.contains(o);\r
+ }\r
+ \r
+ public boolean remove(Object o) {\r
+ Link link = domain.remove(o); \r
+ if(link == null)\r
+ return false;\r
+ removeLink(link);\r
+ if(link.rangeElement != null)\r
+ range.remove(link.rangeElement);\r
+ return true; \r
+ }\r
+ \r
+ @Override\r
+ public Iterator<Resource> iterator() {\r
+ // FIXME does not implement Iterator.remove correctly\r
+ return domain.keySet().iterator();\r
+ }\r
+\r
+ @Override\r
+ public int size() {\r
+ return domain.size();\r
+ }\r
+ \r
+ };\r
+ \r
+ Set<Object> rangeSet = new AbstractSet<Object>() {\r
+\r
+ public boolean add(Object e) {\r
+ if(range.containsKey(e))\r
+ return false;\r
+ Link link = new Link(null, null, e);\r
+ range.put(e, link);\r
+ modifiedRangeLinks.add(link);\r
+ return true;\r
+ }\r
+ \r
+ public boolean contains(Object o) {\r
+ return range.contains(o);\r
+ }\r
+ \r
+ public boolean remove(Object o) {\r
+ Link link = range.remove(o); \r
+ if(link == null)\r
+ return false;\r
+ removeLink(link);\r
+ if(link.domainElement != null)\r
+ domain.remove(link.domainElement);\r
+ return true;\r
+ }\r
+ \r
+ @Override\r
+ public Iterator<Object> iterator() {\r
+ // FIXME does not implement Iterator.remove correctly\r
+ return range.keySet().iterator();\r
+ }\r
+\r
+ @Override\r
+ public int size() {\r
+ return range.size();\r
+ }\r
+ \r
+ };\r
+ \r
+ class DomainToRange implements IFunction<Resource, Object> {\r
+\r
+ ReadGraph g;\r
+ \r
+ public DomainToRange(ReadGraph g) {\r
+ this.g = g;\r
+ }\r
+\r
+ @Override\r
+ public Object get(Resource element) throws MappingException {\r
+ Link link = domain.get(element);\r
+ if(link == null) {\r
+ link = new Link(null, element, null);\r
+ link.domainModified = true;\r
+ modifiedDomainLinks.add(link);\r
+ domain.put(element, link); \r
+ createRange(g, link); \r
+ }\r
+ else if(link.type == null) \r
+ createRange(g, link);\r
+ return link.rangeElement;\r
+ }\r
+ \r
+ };\r
+ \r
+ class RangeToDomain implements IFunction<Object, Resource> {\r
+\r
+ WriteGraph g;\r
+ \r
+ public RangeToDomain(WriteGraph g) {\r
+ this.g = g;\r
+ }\r
+ \r
+ @Override\r
+ public Resource get(Object element) throws MappingException {\r
+ Link link = range.get(element);\r
+ if(link == null) {\r
+ link = new Link(null, null, element);\r
+ link.rangeModified = true;\r
+ modifiedRangeLinks.add(link);\r
+ range.put(element, link);\r
+ createDomain(g, link); \r
+ }\r
+ else if(link.type == null)\r
+ createDomain(g, link);\r
+ return link.domainElement;\r
+ }\r
+ \r
+ };\r
+ \r
+ @Override\r
+ public Set<Resource> getDomain() {\r
+ return domainSet;\r
+ }\r
+ \r
+ @Override\r
+ public Set<Object> getRange() {\r
+ return rangeSet;\r
+ }\r
+ \r
+ @Override\r
+ public synchronized Collection<Resource> updateDomain(WriteGraph g) throws MappingException {\r
+ LOGGER.info("Mapping.updateDomain");\r
+ RangeToDomain map = new RangeToDomain(g);\r
+ ArrayList<Resource> updated = new ArrayList<Resource>();\r
+ while(!modifiedRangeLinks.isEmpty()) {\r
+ LOGGER.info(" modifiedRangeLinks.size() = " + modifiedRangeLinks.size());\r
+ \r
+ Link link = modifiedRangeLinks.remove(modifiedRangeLinks.size()-1);\r
+ link.rangeModified = false;\r
+ /*if(link.domainModified) {\r
+ link.domainModified = false;\r
+ modifiedDomainLinks.remove(link);\r
+ }*/\r
+ \r
+ if(link.type == null) {\r
+ createDomain(g, link);\r
+ }\r
+ \r
+ if(link.type.updateDomain(g, map, link.domainElement, link.rangeElement))\r
+ updated.add(link.domainElement);\r
+ } \r
+ return updated;\r
+ }\r
+ \r
+ @Override\r
+ public synchronized Collection<Object> updateRange(ReadGraph g) throws MappingException {\r
+ LOGGER.info("Mapping.updateRange");\r
+ DomainToRange map = new DomainToRange(g);\r
+ ArrayList<Object> updated = new ArrayList<Object>();\r
+ while(!modifiedDomainLinks.isEmpty()) { \r
+ LOGGER.info(" modifiedDomainLinks.size() = " + modifiedDomainLinks.size());\r
+ \r
+ Link link = modifiedDomainLinks.remove(modifiedDomainLinks.size()-1);\r
+ link.domainModified = false;\r
+ /*if(link.rangeModified) {\r
+ link.rangeModified = false;\r
+ modifiedRangeLinks.remove(link);\r
+ }*/\r
+ \r
+ if(link.type == null) {\r
+ createRange(g, link);\r
+ }\r
+ \r
+ if(listensDomain) {\r
+ RangeUpdateRequest request = new RangeUpdateRequest(link, map, this);\r
+ try {\r
+ g.syncRequest(request, request);\r
+ } catch (DatabaseException e) {\r
+ throw new MappingException(e);\r
+ }\r
+ // TODO check if really modified\r
+ updated.add(link.rangeElement);\r
+ }\r
+ else\r
+ if(link.type.updateRange(g, map, link.domainElement, link.rangeElement))\r
+ updated.add(link.rangeElement);\r
+ } \r
+ return updated;\r
+ }\r
+\r
+ @Override\r
+ public Object get(Resource domainElement) {\r
+ Link link = domain.get(domainElement);\r
+ if(link == null)\r
+ return null;\r
+ return link.rangeElement;\r
+ }\r
+\r
+ @Override\r
+ public Resource inverseGet(Object rangeElement) {\r
+ Link link = range.get(rangeElement);\r
+ if(link == null)\r
+ return null;\r
+ return link.domainElement;\r
+ }\r
+\r
+ @Override\r
+ public Resource inverseMap(WriteGraph g, Object rangeElement) throws MappingException {\r
+ getRange().add(rangeElement);\r
+ updateDomain(g);\r
+ return inverseGet(rangeElement);\r
+ }\r
+\r
+ @Override\r
+ public Object map(ReadGraph g, Resource domainElement) throws MappingException {\r
+ getDomain().add(domainElement);\r
+ updateRange(g);\r
+ return get(domainElement);\r
+ }\r
+\r
+ void domainModified(Link link) {\r
+ if(!link.domainModified) { \r
+ synchronized(modifiedDomainLinks) {\r
+ LOGGER.info(" domainModified for " + link.rangeElement);\r
+ link.domainModified = true;\r
+ modifiedDomainLinks.add(link);\r
+ if(modifiedDomainLinks.size() == 1) {\r
+ for(IMappingListener listener : listeners)\r
+ listener.domainModified();\r
+ }\r
+ }\r
+ }\r
+ }\r
+ \r
+ @Override\r
+ public void domainModified(Resource domainElement) {\r
+ Link link = domain.get(domainElement);\r
+ if(link != null)\r
+ domainModified(link);\r
+ }\r
+\r
+ void rangeModified(Link link) {\r
+ if(!link.rangeModified) {\r
+ synchronized(modifiedRangeLinks) {\r
+ link.rangeModified = true;\r
+ modifiedRangeLinks.add(link);\r
+ if(modifiedRangeLinks.size() == 1) {\r
+ for(IMappingListener listener : listeners)\r
+ listener.rangeModified();\r
+ }\r
+ }\r
+ }\r
+ }\r
+ \r
+ @Override\r
+ public void rangeModified(Object rangeElement) {\r
+ Link link = range.get(rangeElement);\r
+ if(link != null)\r
+ rangeModified(link);\r
+ }\r
+\r
+ @Override\r
+ public boolean isDomainModified() {\r
+ return !modifiedDomainLinks.isEmpty();\r
+ }\r
+\r
+ @Override\r
+ public boolean isRangeModified() {\r
+ return !modifiedRangeLinks.isEmpty();\r
+ }\r
+\r
+ @Override\r
+ public void addMappingListener(IMappingListener listener) {\r
+ listeners.add(listener);\r
+ }\r
+\r
+ @Override\r
+ public void removeMappingListener(IMappingListener listener) {\r
+ listeners.remove(listener); \r
+ }\r
+\r
+ @Override\r
+ public Collection<Resource> getConflictingDomainElements() {\r
+ ArrayList<Resource> result = new ArrayList<Resource>();\r
+ if(modifiedDomainLinks.size() < modifiedRangeLinks.size()) {\r
+ for(Link link : modifiedDomainLinks)\r
+ if(link.rangeModified)\r
+ result.add(link.domainElement);\r
+ }\r
+ else {\r
+ for(Link link : modifiedRangeLinks)\r
+ if(link.domainModified)\r
+ result.add(link.domainElement);\r
+ }\r
+ return result;\r
+ }\r
+\r
+ @Override\r
+ public Collection<Object> getConflictingRangeElements() {\r
+ ArrayList<Object> result = new ArrayList<Object>();\r
+ if(modifiedDomainLinks.size() < modifiedRangeLinks.size()) {\r
+ for(Link link : modifiedDomainLinks)\r
+ if(link.rangeModified)\r
+ result.add(link.rangeElement);\r
+ }\r
+ else {\r
+ for(Link link : modifiedRangeLinks)\r
+ if(link.domainModified)\r
+ result.add(link.rangeElement);\r
+ }\r
+ return result;\r
+ }\r
+\r
+ @Override\r
+ public void dispose() {\r
+ disposed = true;\r
+ }\r
+ \r
+ public boolean isDisposed() {\r
+ return disposed;\r
+ }\r
+ \r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2010 Association for Decentralized Information Management\r
+ * in Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.objmap.impl;\r
+\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.db.procedure.SyncListener;\r
+import org.simantics.db.request.Read;\r
+import org.simantics.objmap.IFunction;\r
+import org.simantics.objmap.MappingException;\r
+\r
+public class RangeUpdateRequest implements Read<Boolean>, SyncListener<Boolean> {\r
+\r
+ Link link;\r
+ /*\r
+ * Note that this map uses a read request that it has got from caller and \r
+ * not the one that is used in updateRange. This is intentional.\r
+ */\r
+ IFunction<Resource, Object> map; // map==null is used to flag that request is performed once\r
+ Mapping mapping; // mapping==null is used as a flag the request disposed\r
+ \r
+ public RangeUpdateRequest(Link link, IFunction<Resource, Object> map, Mapping mapping) {\r
+ this.link = link;\r
+ this.map = map;\r
+ this.mapping = mapping;\r
+ }\r
+\r
+ @Override\r
+ public Boolean perform(ReadGraph g) throws DatabaseException {\r
+ if(map != null) {\r
+ link.type.updateRange(g, map, link.domainElement, link.rangeElement);\r
+ map = null;\r
+ return Boolean.TRUE;\r
+ }\r
+ else if(mapping != null) {\r
+ mapping.domainModified(link);\r
+ mapping = null;\r
+ return Boolean.FALSE;\r
+ }\r
+ else\r
+ return null;\r
+ }\r
+ \r
+ @Override\r
+ public void exception(ReadGraph graph, Throwable throwable)\r
+ throws DatabaseException {\r
+ if(throwable instanceof DatabaseException)\r
+ throw (DatabaseException)throwable;\r
+ else\r
+ throw new MappingException(throwable);\r
+ }\r
+\r
+ @Override\r
+ public void execute(ReadGraph graph, Boolean result)\r
+ throws DatabaseException { \r
+ }\r
+\r
+ @Override\r
+ public boolean isDisposed() {\r
+ return mapping == null || link.removed || mapping.isDisposed();\r
+ }\r
+ \r
+ \r
+ \r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2010 Association for Decentralized Information Management\r
+ * in Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.objmap.impl;\r
+\r
+import gnu.trove.THashMap;\r
+import gnu.trove.TObjectIdentityHashingStrategy;\r
+\r
+import java.util.AbstractSet;\r
+import java.util.ArrayList;\r
+import java.util.Collection;\r
+import java.util.Iterator;\r
+import java.util.Set;\r
+\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.WriteGraph;\r
+import org.simantics.objmap.IFunction;\r
+import org.simantics.objmap.ILinkType;\r
+import org.simantics.objmap.IMapping;\r
+import org.simantics.objmap.IMappingListener;\r
+import org.simantics.objmap.IMappingSchema;\r
+import org.simantics.objmap.MappingException;\r
+\r
+/**\r
+ * An implementation of IMapping. The class should not be created\r
+ * directly but using methods in Mappings.\r
+ * @see org.simantics.objmap.Mappings\r
+ * @author Hannu Niemistö\r
+ */\r
+public class UnidirectionalMapping implements IMapping {\r
+\r
+ private static final TObjectIdentityHashingStrategy<Object> IDENTITY_HASHING =\r
+ new TObjectIdentityHashingStrategy<Object>();\r
+ \r
+ IMappingSchema schema;\r
+ \r
+ THashMap<Resource, Link> domain = new THashMap<Resource, Link>();\r
+ ArrayList<IMappingListener> listeners = new ArrayList<IMappingListener>();\r
+ \r
+ ArrayList<Link> modifiedDomainLinks = new ArrayList<Link>();\r
+ boolean disposed = false;\r
+ \r
+ public UnidirectionalMapping(IMappingSchema schema) {\r
+ this.schema = schema;\r
+ }\r
+\r
+ private void removeLink(Link link) {\r
+ if(link.domainModified)\r
+ modifiedDomainLinks.remove(link);\r
+ link.removed = true;\r
+ }\r
+ \r
+ private void createDomain(WriteGraph g, Link link) throws MappingException {\r
+ ILinkType type = schema.linkTypeOfRangeElement(link.rangeElement);\r
+ Resource domainElement = type.createDomainElement(g, link.rangeElement);\r
+ \r
+ link.type = type;\r
+ link.domainElement = domainElement;\r
+ domain.put(domainElement, link);\r
+ }\r
+ \r
+ private void createRange(ReadGraph g, Link link) throws MappingException {\r
+ ILinkType type = schema.linkTypeOfDomainElement(g, link.domainElement); \r
+ Object rangeElement = type.createRangeElement(g, link.domainElement);\r
+ \r
+ link.type = type;\r
+ link.rangeElement = rangeElement;\r
+ }\r
+ \r
+ Set<Resource> domainSet = new AbstractSet<Resource>() {\r
+\r
+ public boolean add(Resource e) {\r
+ if(domain.containsKey(e))\r
+ return false;\r
+ Link link = new Link(null, e, null);\r
+ domain.put(e, link);\r
+ modifiedDomainLinks.add(link);\r
+ return true;\r
+ }\r
+ \r
+ public boolean contains(Object o) {\r
+ return domain.contains(o);\r
+ }\r
+ \r
+ public boolean remove(Object o) {\r
+ Link link = domain.remove(o); \r
+ if(link == null)\r
+ return false;\r
+ removeLink(link);\r
+ return true; \r
+ }\r
+ \r
+ @Override\r
+ public Iterator<Resource> iterator() {\r
+ // FIXME does not implement Iterator.remove correctly\r
+ return domain.keySet().iterator();\r
+ }\r
+\r
+ @Override\r
+ public int size() {\r
+ return domain.size();\r
+ }\r
+ \r
+ };\r
+ \r
+ class DomainToRange implements IFunction<Resource, Object> {\r
+\r
+ ReadGraph g;\r
+ \r
+ public DomainToRange(ReadGraph g) {\r
+ this.g = g;\r
+ }\r
+\r
+ @Override\r
+ public Object get(Resource element) throws MappingException {\r
+ Link link = domain.get(element);\r
+ if(link == null) {\r
+ ILinkType type = schema.linkTypeOfDomainElement(g, element);\r
+ Object rangeElement = type.createRangeElement(g, element);\r
+ \r
+ link = new Link(type, element, rangeElement);\r
+ domain.put(element, link); \r
+ link.domainModified = true;\r
+ modifiedDomainLinks.add(link);\r
+ \r
+ return rangeElement; \r
+ }\r
+ else {\r
+ if(link.type == null) \r
+ createRange(g, link);\r
+ return link.rangeElement;\r
+ }\r
+ }\r
+ \r
+ };\r
+ \r
+ @Override\r
+ public Set<Resource> getDomain() {\r
+ return domainSet;\r
+ }\r
+ \r
+ @Override\r
+ public Set<Object> getRange() {\r
+ throw new UnsupportedOperationException();\r
+ }\r
+ \r
+ @Override\r
+ public Collection<Resource> updateDomain(WriteGraph g) throws MappingException {\r
+ throw new UnsupportedOperationException();\r
+ }\r
+ \r
+ @Override\r
+ public Collection<Object> updateRange(ReadGraph g) throws MappingException {\r
+ DomainToRange map = new DomainToRange(g);\r
+ ArrayList<Object> updated = new ArrayList<Object>();\r
+ while(!modifiedDomainLinks.isEmpty()) {\r
+ Link link = modifiedDomainLinks.remove(modifiedDomainLinks.size()-1);\r
+ link.domainModified = false; \r
+ if(link.type == null) {\r
+ createRange(g, link);\r
+ }\r
+ \r
+ link.type.updateRange(g, map, link.domainElement, link.rangeElement);\r
+ updated.add(link.rangeElement);\r
+ } \r
+ return updated;\r
+ }\r
+\r
+ @Override\r
+ public Object get(Resource domainElement) {\r
+ Link link = domain.get(domainElement);\r
+ if(link == null)\r
+ return null;\r
+ return link.rangeElement;\r
+ }\r
+\r
+ @Override\r
+ public Resource inverseGet(Object rangeElement) {\r
+ throw new UnsupportedOperationException();\r
+ }\r
+\r
+ @Override\r
+ public Resource inverseMap(WriteGraph g, Object rangeElement) throws MappingException {\r
+ throw new UnsupportedOperationException();\r
+ }\r
+\r
+ @Override\r
+ public Object map(ReadGraph g, Resource domainElement) throws MappingException {\r
+ getDomain().add(domainElement);\r
+ updateRange(g);\r
+ return get(domainElement);\r
+ }\r
+\r
+ void domainModified(Link link) {\r
+ if(!link.domainModified) {\r
+ link.domainModified = true;\r
+ modifiedDomainLinks.add(link);\r
+ if(modifiedDomainLinks.size() == 1) {\r
+ for(IMappingListener listener : listeners)\r
+ listener.domainModified();\r
+ }\r
+ }\r
+ }\r
+ \r
+ @Override\r
+ public void domainModified(Resource domainElement) {\r
+ Link link = domain.get(domainElement);\r
+ if(link != null)\r
+ domainModified(link);\r
+ }\r
+\r
+ @Override\r
+ public boolean isDomainModified() {\r
+ return !modifiedDomainLinks.isEmpty();\r
+ }\r
+\r
+ @Override\r
+ public boolean isRangeModified() {\r
+ throw new UnsupportedOperationException();\r
+ }\r
+\r
+ @Override\r
+ public void addMappingListener(IMappingListener listener) {\r
+ listeners.add(listener);\r
+ }\r
+\r
+ @Override\r
+ public void removeMappingListener(IMappingListener listener) {\r
+ listeners.remove(listener); \r
+ }\r
+\r
+ @Override\r
+ public Collection<Resource> getConflictingDomainElements() {\r
+ throw new UnsupportedOperationException();\r
+ }\r
+\r
+ @Override\r
+ public Collection<Object> getConflictingRangeElements() {\r
+ throw new UnsupportedOperationException();\r
+ }\r
+\r
+ @Override\r
+ public void dispose() {\r
+ disposed = true;\r
+ }\r
+ \r
+ public boolean isDisposed() {\r
+ return disposed;\r
+ }\r
+\r
+ @Override\r
+ public void rangeModified(Object rangeElement) {\r
+ throw new UnsupportedOperationException();\r
+ }\r
+ \r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2010 Association for Decentralized Information Management\r
+ * in Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.objmap.rules;\r
+\r
+import org.apache.log4j.Logger;\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.WriteGraph;\r
+import org.simantics.objmap.IFunction;\r
+import org.simantics.objmap.IMappingRule;\r
+import org.simantics.objmap.MappingException;\r
+import org.simantics.objmap.rules.domain.IDomainAccessor;\r
+import org.simantics.objmap.rules.range.IRangeAccessor;\r
+\r
+/**\r
+ * A rule that synchronizes collection of elements between\r
+ * domain and range accessors. Elements are mapped from\r
+ * between domain and range during the synchronization.\r
+ * @author Hannu Niemistö\r
+ */\r
+public class MappedElementRule implements IMappingRule {\r
+ \r
+ static Logger LOGGER = Logger.getLogger("org.simantics.objmap");\r
+ \r
+ IDomainAccessor<Resource> domainAccessor;\r
+ IRangeAccessor<Object> rangeAccessor;\r
+ \r
+ public MappedElementRule(IDomainAccessor<Resource> domainAccessor,\r
+ IRangeAccessor<Object> rangeAccessor) {\r
+ this.domainAccessor = domainAccessor;\r
+ this.rangeAccessor = rangeAccessor;\r
+ }\r
+\r
+ @Override\r
+ public boolean updateDomain(WriteGraph g, IFunction<Object, Resource> map,\r
+ Resource domainElement, Object rangeElement)\r
+ throws MappingException {\r
+ LOGGER.info(" MappedElementRule.updateDomain");\r
+ Object value = rangeAccessor.get(rangeElement);\r
+ Resource mappedValue = value == null ? null : map.get(value);\r
+ return domainAccessor.set(g, domainElement, mappedValue);\r
+ }\r
+\r
+ @Override\r
+ public boolean updateRange(ReadGraph g, IFunction<Resource, Object> map,\r
+ Resource domainElement, Object rangeElement)\r
+ throws MappingException {\r
+ LOGGER.info(" MappedElementRule.updateRange"); \r
+ Resource value = domainAccessor.get(g, domainElement);\r
+ Object mappedValue = value == null ? null : map.get(value);\r
+ return rangeAccessor.set(rangeElement, mappedValue);\r
+ } \r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2010 Association for Decentralized Information Management\r
+ * in Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.objmap.rules;\r
+\r
+import java.util.ArrayList;\r
+import java.util.Collection;\r
+\r
+import org.apache.log4j.Logger;\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.WriteGraph;\r
+import org.simantics.objmap.IFunction;\r
+import org.simantics.objmap.IMappingRule;\r
+import org.simantics.objmap.MappingException;\r
+import org.simantics.objmap.rules.domain.IDomainAccessor;\r
+import org.simantics.objmap.rules.range.IRangeAccessor;\r
+\r
+/**\r
+ * A rule that synchronizes collection of elements between\r
+ * domain and range accessors. Elements are mapped from\r
+ * between domain and range during the synchronization.\r
+ * @author Hannu Niemistö\r
+ */\r
+public class MappedElementsRule implements IMappingRule {\r
+\r
+ static Logger LOGGER = Logger.getLogger("org.simantics.objmap");\r
+\r
+ IDomainAccessor<Collection<Resource>> domainAccessor;\r
+ IRangeAccessor<Collection<Object>> rangeAccessor;\r
+\r
+ public MappedElementsRule(IDomainAccessor<Collection<Resource>> domainAccessor,\r
+ IRangeAccessor<Collection<Object>> rangeAccessor) {\r
+ this.domainAccessor = domainAccessor;\r
+ this.rangeAccessor = rangeAccessor;\r
+ }\r
+\r
+ @Override\r
+ public boolean updateDomain(WriteGraph g, IFunction<Object, Resource> map,\r
+ Resource domainElement, Object rangeElement)\r
+ throws MappingException {\r
+ LOGGER.info(" MappedElementsRule.updateDomain");\r
+ // Snapshot the accessed range value for concurrency safety.\r
+ // NOTE: still assumes that the accessed collection is concurrent or\r
+ // synchronized for toArray to be atomic.\r
+ Collection<Object> value = rangeAccessor.get(rangeElement);\r
+ Object[] rangeSnapshot = value.toArray();\r
+ ArrayList<Resource> mappedValue = new ArrayList<Resource>(rangeSnapshot.length);\r
+ for (Object obj : rangeSnapshot)\r
+ mappedValue.add(map.get(obj));\r
+ return domainAccessor.set(g, domainElement, mappedValue);\r
+ }\r
+\r
+ @Override\r
+ public boolean updateRange(ReadGraph g, IFunction<Resource, Object> map,\r
+ Resource domainElement, Object rangeElement)\r
+ throws MappingException {\r
+ LOGGER.info(" MappedElementsRule.updateRange");\r
+ Collection<Resource> value = domainAccessor.get(g, domainElement);\r
+ ArrayList<Object> mappedValue = new ArrayList<Object>(value.size());\r
+ for(Resource r : value)\r
+ mappedValue.add(map.get(r));\r
+ return rangeAccessor.set(rangeElement, mappedValue);\r
+ }\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2010 Association for Decentralized Information Management\r
+ * in Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.objmap.rules;\r
+\r
+import org.apache.log4j.Logger;\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.WriteGraph;\r
+import org.simantics.objmap.IFunction;\r
+import org.simantics.objmap.IMappingRule;\r
+import org.simantics.objmap.MappingException;\r
+import org.simantics.objmap.rules.domain.IDomainAccessor;\r
+import org.simantics.objmap.rules.range.IRangeAccessor;\r
+\r
+/**\r
+ * A rule that synchronizes values between domain and\r
+ * range accessors.\r
+ * @author Hannu Niemistö\r
+ */\r
+public class ValueRule implements IMappingRule {\r
+ \r
+ static Logger LOGGER = Logger.getLogger("org.simantics.objmap");\r
+ \r
+ IDomainAccessor<Object> domainAccessor;\r
+ IRangeAccessor<Object> rangeAccessor;\r
+ \r
+ public ValueRule(IDomainAccessor<Object> domainAccessor,\r
+ IRangeAccessor<Object> rangeAccessor) {\r
+ this.domainAccessor = domainAccessor;\r
+ this.rangeAccessor = rangeAccessor;\r
+ }\r
+\r
+ @Override\r
+ public boolean updateDomain(WriteGraph g, IFunction<Object, Resource> map,\r
+ Resource domainElement, Object rangeElement)\r
+ throws MappingException {\r
+ LOGGER.info(" ValueRule.updateDomain"); \r
+ Object value = rangeAccessor.get(rangeElement);\r
+ return domainAccessor.set(g, domainElement, value);\r
+ }\r
+\r
+ @Override\r
+ public boolean updateRange(ReadGraph g, IFunction<Resource, Object> map,\r
+ Resource domainElement, Object rangeElement)\r
+ throws MappingException {\r
+ LOGGER.info(" ValueRule.updateRange");\r
+ Object value = domainAccessor.get(g, domainElement);\r
+ return rangeAccessor.set(rangeElement, value);\r
+ } \r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2010 Association for Decentralized Information Management\r
+ * in Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.objmap.rules.domain;\r
+\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.WriteGraph;\r
+import org.simantics.objmap.MappingException;\r
+\r
+/**\r
+ * Provides access to some property of domain elements.\r
+ * @author Hannu Niemistö\r
+ */\r
+public interface IDomainAccessor<T> {\r
+ T get(ReadGraph g, Resource element) throws MappingException;\r
+ boolean set(WriteGraph g, Resource element, T value) throws MappingException;\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2010 Association for Decentralized Information Management\r
+ * in Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.objmap.rules.domain;\r
+\r
+import java.util.Arrays;\r
+import java.util.Collection;\r
+\r
+import org.apache.log4j.Logger;\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.WriteGraph;\r
+import org.simantics.db.exception.DatabaseException;\r
+\r
+/**\r
+ * Static utility methods for rule implementations.\r
+ * @author Hannu Niemistö\r
+ */\r
+public class MappingUtils {\r
+\r
+ static Logger LOGGER = Logger.getLogger("org.simantics.objmap");\r
+ \r
+ /**\r
+ * Adds and removes statements to/from the database so that <code>objects</code>\r
+ * will be exactly the objects connected to <code>subject</code> by <code>predicate</code>.\r
+ * Returns true if the method made modifications to the database.\r
+ */\r
+ public static boolean synchronizeStatements(WriteGraph g, Resource subject, Resource predicate, Resource[] objects,\r
+ boolean deleteExtraObjects) \r
+ throws DatabaseException {\r
+ Collection<Resource> currentObjects0 = g.getObjects(subject, predicate);\r
+ Resource[] currentObjects = currentObjects0.toArray(new Resource[currentObjects0.size()]);\r
+ \r
+ Arrays.sort(objects);\r
+ Arrays.sort(currentObjects);\r
+ \r
+ boolean modified = false;\r
+ int i=0, j=0; \r
+ if(currentObjects.length > 0 && objects.length > 0)\r
+ while(true) {\r
+ int cmp = currentObjects[i].compareTo(objects[j]);\r
+ if(cmp < 0) {\r
+ LOGGER.info(" remove statement");\r
+ if(deleteExtraObjects)\r
+ g.deny(currentObjects[i]);\r
+ else\r
+ g.denyStatement(subject, predicate, currentObjects[i]); \r
+ modified = true;\r
+ ++i;\r
+ if(i >= currentObjects.length)\r
+ break;\r
+ }\r
+ else if(cmp > 0) {\r
+ LOGGER.info(" add statement");\r
+ g.claim(subject, predicate, objects[j]);\r
+ modified = true;\r
+ ++j;\r
+ if(j >= objects.length)\r
+ break;\r
+ }\r
+ else {\r
+ ++i; ++j;\r
+ if(i >= currentObjects.length)\r
+ break;\r
+ if(j >= objects.length)\r
+ break;\r
+ }\r
+ }\r
+ while(i < currentObjects.length) {\r
+ if(deleteExtraObjects)\r
+ g.deny(currentObjects[i]);\r
+ else\r
+ g.denyStatement(subject, predicate, currentObjects[i]);\r
+ modified = true;\r
+ ++i;\r
+ }\r
+ while(j < objects.length) {\r
+ g.claim(subject, predicate, objects[j]);\r
+ modified = true;\r
+ ++j;\r
+ }\r
+ return modified;\r
+ }\r
+\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2010 Association for Decentralized Information Management\r
+ * in Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.objmap.rules.domain;\r
+\r
+import org.apache.log4j.Logger;\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.WriteGraph;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.objmap.MappingException;\r
+\r
+/**\r
+ * Accesses a resource attached to the element by given functional relation.\r
+ * @author Hannu Niemistö\r
+ */\r
+public class RelatedObjectAccessor implements IDomainAccessor<Resource> {\r
+\r
+ static Logger LOGGER = Logger.getLogger("org.simantics.objmap");\r
+ \r
+ Resource relation;\r
+ \r
+ public RelatedObjectAccessor(Resource relation) {\r
+ this.relation = relation;\r
+ }\r
+\r
+ @Override\r
+ public Resource get(ReadGraph g, Resource element) throws MappingException {\r
+ try {\r
+ LOGGER.info(" RelatedObjectAccessor.get");\r
+ return g.getPossibleObject(element, relation);\r
+ } catch (DatabaseException e) {\r
+ throw new MappingException(e);\r
+ }\r
+ }\r
+ \r
+ @Override\r
+ public boolean set(WriteGraph g, Resource element, Resource value)\r
+ throws MappingException {\r
+ try {\r
+ LOGGER.info(" RelatedObjectAccessor.set");\r
+ Resource resource = g.getPossibleObject(element, relation);\r
+ if(resource == null) {\r
+ if(value == null)\r
+ return false;\r
+ g.claim(element, relation, value);\r
+ return true;\r
+ }\r
+ else if(resource.equals(value))\r
+ return false;\r
+ else {\r
+ g.deny(element, relation);\r
+ if(value != null)\r
+ g.claim(element, relation, value);\r
+ return true;\r
+ }\r
+ } catch (DatabaseException e) {\r
+ throw new MappingException(e);\r
+ }\r
+ \r
+ }\r
+\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2010 Association for Decentralized Information Management\r
+ * in Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.objmap.rules.domain;\r
+\r
+import java.util.Collection;\r
+\r
+import org.apache.log4j.Logger;\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.WriteGraph;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.objmap.MappingException;\r
+\r
+/**\r
+ * Accesses the set of objects attached to the element by the given relation.\r
+ * @author Hannu Niemistö\r
+ */\r
+public class RelatedObjectsAccessor implements IDomainAccessor<Collection<Resource>> {\r
+\r
+ static Logger LOGGER = Logger.getLogger("org.simantics.objmap");\r
+ \r
+ Resource relation;\r
+ boolean deleteExtraObjects;\r
+\r
+ public RelatedObjectsAccessor(Resource relation, boolean deleteExtraObjects) {\r
+ super();\r
+ this.relation = relation;\r
+ this.deleteExtraObjects = deleteExtraObjects;\r
+ }\r
+\r
+ @Override\r
+ public Collection<Resource> get(ReadGraph g, Resource element) throws MappingException {\r
+ try {\r
+ LOGGER.info(" RelatedObjectsAccessor.get");\r
+ return g.getObjects(element, relation);\r
+ } catch (DatabaseException e) {\r
+ throw new MappingException(e);\r
+ }\r
+ }\r
+ \r
+ @Override\r
+ public boolean set(WriteGraph g, Resource element, Collection<Resource> value)\r
+ throws MappingException {\r
+ try {\r
+ LOGGER.info(" RelatedObjectsAccessor.set");\r
+ return MappingUtils.synchronizeStatements(g, element, relation, \r
+ value.toArray(new Resource[value.size()]), deleteExtraObjects);\r
+ } catch (DatabaseException e) {\r
+ throw new MappingException(e);\r
+ }\r
+ \r
+ }\r
+\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2010 Association for Decentralized Information Management\r
+ * in Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.objmap.rules.domain;\r
+\r
+import java.util.Collection;\r
+\r
+import org.apache.log4j.Logger;\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.WriteGraph;\r
+import org.simantics.db.common.utils.OrderedSetUtils;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.objmap.MappingException;\r
+\r
+/**\r
+ * Accesses the set of objects attached to the element by the given relation.\r
+ * @author Hannu Niemistö\r
+ */\r
+public class RelatedOrderedSetElementsAccessor implements IDomainAccessor<Collection<Resource>> {\r
+\r
+ static Logger LOGGER = Logger.getLogger("org.simantics.objmap");\r
+ \r
+ boolean deleteExtraObjects;\r
+\r
+ public RelatedOrderedSetElementsAccessor(boolean deleteExtraObjects) {\r
+ super();\r
+ this.deleteExtraObjects = deleteExtraObjects;\r
+ }\r
+\r
+ @Override\r
+ public Collection<Resource> get(ReadGraph g, Resource element) throws MappingException {\r
+ try {\r
+ LOGGER.info(" RelatedOrderedSetElementsAccessor.get");\r
+ return OrderedSetUtils.toList(g, element);\r
+ } catch (DatabaseException e) {\r
+ throw new MappingException(e);\r
+ }\r
+ }\r
+ \r
+ @Override\r
+ public boolean set(WriteGraph g, Resource element, Collection<Resource> value)\r
+ throws MappingException {\r
+ try {\r
+ LOGGER.info(" RelatedOrderedSetElementsAccessor.set");\r
+ return OrderedSetUtils.set(g, element, value);\r
+ // FIXME Implement deleteExtraObjects\r
+ } catch (DatabaseException e) {\r
+ throw new MappingException(e);\r
+ }\r
+ \r
+ }\r
+\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2010 Association for Decentralized Information Management\r
+ * in Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.objmap.rules.domain;\r
+\r
+import org.apache.log4j.Logger;\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.WriteGraph;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.layer0.Layer0;\r
+import org.simantics.objmap.MappingException;\r
+\r
+/**\r
+ * Accesses a value attached to the element by given functional relation.\r
+ * @author Hannu Niemist�\r
+ */\r
+public class RelatedValueAccessor implements IDomainAccessor<Object> {\r
+\r
+ static Logger LOGGER = Logger.getLogger("org.simantics.objmap");\r
+ \r
+ Resource relation;\r
+ Resource valueType;\r
+\r
+ public RelatedValueAccessor(Resource relation, Resource valueType) {\r
+ this.relation = relation;\r
+ this.valueType = valueType;\r
+ }\r
+\r
+ @Override\r
+ public Object get(ReadGraph g, Resource element) throws MappingException {\r
+ try {\r
+ LOGGER.info(" RelatedValueAccessor.get");\r
+ Resource valueResource = g.getPossibleObject(element, relation);\r
+ if(valueResource == null)\r
+ return null;\r
+ return g.getValue(valueResource);\r
+ } catch (DatabaseException e) {\r
+ throw new MappingException(e);\r
+ }\r
+ }\r
+ \r
+ @Override\r
+ public boolean set(WriteGraph g, Resource element, Object value)\r
+ throws MappingException {\r
+ try {\r
+ LOGGER.info(" RelatedValueAccessor.set");\r
+ Resource valueResource = g.getPossibleObject(element, relation);\r
+ if(valueResource == null) {\r
+ if(value == null)\r
+ return false;\r
+ valueResource = g.newResource();\r
+ g.claim(valueResource, Layer0.getInstance(g).InstanceOf, null,\r
+ valueType);\r
+ g.claim(element, relation, valueResource);\r
+ g.claimValue(valueResource, value); \r
+ return true;\r
+ }\r
+ else {\r
+ if(value == null) {\r
+ g.deny(valueResource);\r
+ return true;\r
+ } \r
+ Object currentValue = g.getValue(valueResource);\r
+ if(currentValue.equals(value))\r
+ return false;\r
+ g.claimValue(valueResource, value);\r
+ return true;\r
+ }\r
+ } catch (DatabaseException e) {\r
+ throw new MappingException(e);\r
+ }\r
+ \r
+ }\r
+\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2010 Association for Decentralized Information Management\r
+ * in Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.objmap.rules.factory;\r
+\r
+import java.lang.annotation.Annotation;\r
+\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.objmap.IMappingRule;\r
+\r
+public interface IClassRuleFactory {\r
+ IMappingRule create(ReadGraph g, Annotation annotation, Class<?> clazz) throws DatabaseException;\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2010 Association for Decentralized Information Management\r
+ * in Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.objmap.rules.factory;\r
+\r
+import java.lang.annotation.Annotation;\r
+import java.lang.reflect.Field;\r
+\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.objmap.IMappingRule;\r
+\r
+public interface IFieldRuleFactory {\r
+ IMappingRule create(ReadGraph g, Annotation annotation, Field field) throws DatabaseException;\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2010 Association for Decentralized Information Management\r
+ * in Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.objmap.rules.factory;\r
+\r
+import java.lang.annotation.Annotation;\r
+import java.lang.reflect.Method;\r
+\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.objmap.IMappingRule;\r
+\r
+public interface IMethodRuleFactory {\r
+ IMappingRule create(ReadGraph g, Annotation annotation, Method method) throws DatabaseException;\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2010 Association for Decentralized Information Management\r
+ * in Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.objmap.rules.range;\r
+\r
+import java.lang.reflect.Field;\r
+\r
+import org.apache.log4j.Logger;\r
+import org.simantics.objmap.MappingException;\r
+\r
+/**\r
+ * Accesses the given field of the element.\r
+ * @author Hannu Niemistö\r
+ */\r
+public class FieldAccessor<T> implements IRangeAccessor<T> {\r
+ \r
+ static Logger LOGGER = Logger.getLogger("org.simantics.objmap");\r
+ \r
+ Field field;\r
+\r
+ public FieldAccessor(Field field) {\r
+ this.field = field;\r
+ }\r
+\r
+ @Override\r
+ public T get(Object element) throws MappingException {\r
+ try {\r
+ T result = (T)field.get(element);\r
+ \r
+ if(LOGGER.isInfoEnabled())\r
+ LOGGER.info(" FieldAccessor.get " +\r
+ field.getName() + " -> " + result\r
+ );\r
+ \r
+ return result;\r
+ } catch (IllegalArgumentException e) {\r
+ throw new MappingException(e);\r
+ } catch (IllegalAccessException e) {\r
+ throw new MappingException(e);\r
+ }\r
+ }\r
+\r
+ @Override\r
+ public boolean set(Object element, T value) throws MappingException {\r
+ try {\r
+ Object currentValue = field.get(element);\r
+ \r
+ if(LOGGER.isInfoEnabled())\r
+ LOGGER.info(" FieldAccessor.set " +\r
+ field.getName() + " " + currentValue + \r
+ " -> " + value\r
+ );\r
+ \r
+ if(value == null \r
+ ? (currentValue == null || field.getType().isPrimitive()) \r
+ : value.equals(currentValue))\r
+ return false; \r
+ field.set(element, value);\r
+ return true;\r
+ } catch (IllegalArgumentException e) {\r
+ throw new MappingException(e);\r
+ } catch (IllegalAccessException e) {\r
+ throw new MappingException(e);\r
+ }\r
+ } \r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2010 Association for Decentralized Information Management\r
+ * in Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.objmap.rules.range;\r
+\r
+import java.lang.reflect.Field;\r
+\r
+import org.simantics.objmap.MappingException;\r
+\r
+/**\r
+ * Accesses the given field of the element.\r
+ * @author Hannu Niemist�\r
+ */\r
+public class FieldAccessorWithDefault<T> extends FieldAccessor<T> {\r
+ \r
+ T defaultValue;\r
+\r
+ public FieldAccessorWithDefault(Field field, T defaultValue) {\r
+ super(field);\r
+ this.defaultValue = defaultValue;\r
+ }\r
+\r
+ @Override\r
+ public T get(Object element) throws MappingException {\r
+ T value = super.get(element);\r
+ if(value == null)\r
+ return defaultValue;\r
+ else\r
+ return value;\r
+ }\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2010 Association for Decentralized Information Management\r
+ * in Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.objmap.rules.range;\r
+\r
+import org.simantics.objmap.MappingException;\r
+\r
+/**\r
+ * Provides access to some property of range elements.\r
+ * @author Hannu Niemistö\r
+ */\r
+public interface IRangeAccessor<T> {\r
+ T get(Object element) throws MappingException;\r
+ boolean set(Object element, T value) throws MappingException;\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2010 Association for Decentralized Information Management\r
+ * in Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.objmap.schema;\r
+\r
+import java.lang.annotation.Annotation;\r
+import java.lang.reflect.Field;\r
+import java.lang.reflect.Method;\r
+import java.util.ArrayList;\r
+import java.util.Collection;\r
+\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.objmap.IMappingRule;\r
+import org.simantics.objmap.annotations.GraphType;\r
+import org.simantics.objmap.annotations.RelatedValue;\r
+import org.simantics.objmap.annotations.meta.HasClassRuleFactory;\r
+import org.simantics.objmap.annotations.meta.HasFieldRuleFactory;\r
+import org.simantics.objmap.annotations.meta.HasMethodRuleFactory;\r
+\r
+/**\r
+ * Static utility methods for mapping schemas\r
+ * @author Hannu Niemistö\r
+ */\r
+public class MappingSchemas {\r
+ \r
+ /**\r
+ * Creates a new SimpleLinkType based on the annotations in the given class.\r
+ * @throws IllegalAccessException \r
+ * @throws InstantiationException \r
+ * @see GraphType\r
+ * @see RelatedValue\r
+ */\r
+ public static SimpleLinkType fromAnnotations(ReadGraph g, Class<?> clazz) throws DatabaseException, InstantiationException, IllegalAccessException {\r
+ GraphType graphType = clazz.getAnnotation(GraphType.class);\r
+ \r
+ ArrayList<IMappingRule> rules = new ArrayList<IMappingRule>();\r
+ collectRulesFromAnnotations(g, clazz, rules);\r
+ \r
+ return new SimpleLinkType(\r
+ g.getResource(graphType.value()), \r
+ clazz, rules); \r
+ }\r
+ \r
+ public static void collectRulesFromAnnotations(ReadGraph g, Class<?> clazz, Collection<IMappingRule> rules) throws DatabaseException, InstantiationException, IllegalAccessException {\r
+ Class<?> superclass = clazz.getSuperclass();\r
+ if(superclass != null)\r
+ collectRulesFromAnnotations(g, superclass, rules);\r
+ \r
+ for(Annotation annotation : clazz.getAnnotations()) {\r
+ HasClassRuleFactory factory = \r
+ annotation.annotationType().getAnnotation(HasClassRuleFactory.class);\r
+ if(factory != null) {\r
+ rules.add(factory.value().newInstance()\r
+ .create(g, annotation, clazz));\r
+ }\r
+ }\r
+\r
+ for(Field f : clazz.getDeclaredFields()) {\r
+ f.setAccessible(true);\r
+\r
+ for(Annotation annotation : f.getAnnotations()) {\r
+ HasFieldRuleFactory factory = \r
+ annotation.annotationType().getAnnotation(HasFieldRuleFactory.class);\r
+ if(factory != null) {\r
+ rules.add(factory.value().newInstance()\r
+ .create(g, annotation, f));\r
+ }\r
+ }\r
+ }\r
+\r
+ for(Method m : clazz.getDeclaredMethods()) {\r
+ m.setAccessible(true);\r
+\r
+ for(Annotation annotation : m.getAnnotations()) {\r
+ HasMethodRuleFactory factory = \r
+ annotation.annotationType().getAnnotation(HasMethodRuleFactory.class);\r
+ if(factory != null) {\r
+ rules.add(factory.value().newInstance()\r
+ .create(g, annotation, m));\r
+ }\r
+ }\r
+ }\r
+ }\r
+ \r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2010 Association for Decentralized Information Management\r
+ * in Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.objmap.schema;\r
+\r
+import java.util.ArrayList;\r
+\r
+import org.apache.log4j.Logger;\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.WriteGraph;\r
+import org.simantics.db.common.utils.NameUtils;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.layer0.Layer0;\r
+import org.simantics.objmap.IFunction;\r
+import org.simantics.objmap.ILinkType;\r
+import org.simantics.objmap.IMappingRule;\r
+import org.simantics.objmap.MappingException;\r
+\r
+/**\r
+ * A link type that is associated with single domain and range type (class).\r
+ * SimpleLinkType is composed of simpler rules whose combination determines\r
+ * its update policy.\r
+ * @author Hannu Niemist�\r
+ */\r
+public class SimpleLinkType implements ILinkType {\r
+ \r
+ static Logger LOGGER = Logger.getLogger("org.simantics.objmap");\r
+ \r
+ Resource domainType;\r
+ Class<?> rangeType;\r
+ ArrayList<IMappingRule> rules;\r
+ \r
+ public SimpleLinkType(Resource domainType, Class<?> rangeType,\r
+ ArrayList<IMappingRule> rules) {\r
+ this.domainType = domainType;\r
+ this.rangeType = rangeType;\r
+ this.rules = rules;\r
+ }\r
+\r
+ public SimpleLinkType(Resource domainType, Class<?> rangeType) {\r
+ this(domainType, rangeType, new ArrayList<IMappingRule>());\r
+ }\r
+\r
+ /**\r
+ * Adds a new rule to this link type that is enforced\r
+ * during updates.\r
+ */\r
+ public void addRule(IMappingRule rule) {\r
+ rules.add(rule);\r
+ }\r
+ \r
+ @Override\r
+ public Resource createDomainElement(WriteGraph g, Object rangeElement)\r
+ throws MappingException {\r
+ try {\r
+ if(LOGGER.isInfoEnabled())\r
+ LOGGER.info("SimpleLinkType.createDomainElement " +\r
+ rangeElement.toString()\r
+ );\r
+ Resource result = g.newResource();\r
+ g.claim(result, Layer0.getInstance(g).InstanceOf, null, domainType);\r
+ return result;\r
+ } catch(DatabaseException e) {\r
+ throw new MappingException(e);\r
+ }\r
+ }\r
+ @Override\r
+ public Object createRangeElement(ReadGraph g, Resource domainElement)\r
+ throws MappingException {\r
+ try {\r
+ if(LOGGER.isInfoEnabled())\r
+ try { \r
+ LOGGER.info("SimpleLinkType.createRangeElement " +\r
+ NameUtils.getSafeName(g, domainElement)\r
+ );\r
+ } catch(DatabaseException e) {\r
+ throw new MappingException(e);\r
+ }\r
+ return rangeType.newInstance();\r
+ } catch (InstantiationException e) {\r
+ throw new MappingException(e);\r
+ } catch (IllegalAccessException e) {\r
+ throw new MappingException(e);\r
+ }\r
+ }\r
+ @Override\r
+ public boolean updateDomain(WriteGraph g, IFunction<Object, Resource> map,\r
+ Resource domainElement, Object rangeElement)\r
+ throws MappingException {\r
+ if(LOGGER.isInfoEnabled())\r
+ try { \r
+ LOGGER.info("SimpleLinkType.updateDomain " +\r
+ NameUtils.getSafeName(g, domainElement) + " " +\r
+ rangeElement.toString()\r
+ );\r
+ } catch(DatabaseException e) {\r
+ throw new MappingException(e);\r
+ }\r
+ \r
+ boolean updated = false;\r
+ for(IMappingRule rule : rules)\r
+ updated |= rule.updateDomain(g, map, domainElement, rangeElement);\r
+ return updated;\r
+ }\r
+ @Override\r
+ public boolean updateRange(ReadGraph g, IFunction<Resource, Object> map,\r
+ Resource domainElement, Object rangeElement)\r
+ throws MappingException {\r
+ if(LOGGER.isInfoEnabled())\r
+ try { \r
+ LOGGER.info("SimpleLinkType.updateRange " +\r
+ NameUtils.getSafeName(g, domainElement) + " " +\r
+ rangeElement.toString()\r
+ );\r
+ } catch(DatabaseException e) {\r
+ throw new MappingException(e);\r
+ }\r
+ \r
+ boolean updated = false;\r
+ for(IMappingRule rule : rules)\r
+ updated |= rule.updateRange(g, map, domainElement, rangeElement);\r
+ return updated;\r
+ }\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2010 Association for Decentralized Information Management\r
+ * in Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.objmap.schema;\r
+\r
+import gnu.trove.THashMap;\r
+\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.common.utils.NameUtils;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.objmap.ILinkType;\r
+import org.simantics.objmap.IMappingSchema;\r
+import org.simantics.objmap.MappingException;\r
+\r
+/**\r
+ * An implementation of IMappingSchema that contains\r
+ * only SimpleLinkTypes. The link type of any domain\r
+ * element is based solely on its type in database and\r
+ * the link type of any range element is based on its class.\r
+ * @author Hannu Niemistö\r
+ */\r
+public class SimpleSchema implements IMappingSchema {\r
+\r
+ THashMap<Resource, SimpleLinkType> domainLinkTypes = \r
+ new THashMap<Resource, SimpleLinkType>();\r
+ THashMap<Class<?>, SimpleLinkType> rangeLinkTypes = \r
+ new THashMap<Class<?>, SimpleLinkType>();\r
+ \r
+ public void addLinkType(SimpleLinkType linkType) {\r
+ domainLinkTypes.put(linkType.domainType, linkType);\r
+ rangeLinkTypes.put(linkType.rangeType, linkType);\r
+ }\r
+ \r
+ @Override\r
+ public ILinkType linkTypeOfDomainElement(ReadGraph g, Resource element) throws MappingException { \r
+ try {\r
+ \r
+ for(Resource type : g.getTypes(element)) {\r
+\r
+ ILinkType linkType = domainLinkTypes.get(type);\r
+ if(linkType != null) return linkType;\r
+ \r
+ }\r
+ \r
+ throw new MappingException("Didn't find a link type for " +\r
+ NameUtils.getSafeName(g, element) + ".");\r
+ \r
+ } catch (DatabaseException e) {\r
+ throw new MappingException(e);\r
+ }\r
+ }\r
+\r
+ @Override\r
+ public ILinkType linkTypeOfRangeElement(Object element) throws MappingException {\r
+ ILinkType type = rangeLinkTypes.get(element.getClass());\r
+ if(type == null) \r
+ throw new MappingException("Didn't find a link type for " + element + ".");\r
+ return type;\r
+ }\r
+\r
+}\r
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>\r
+<projectDescription>\r
+ <name>org.simantics.sysdyn.feature</name>\r
+ <comment></comment>\r
+ <projects>\r
+ </projects>\r
+ <buildSpec>\r
+ <buildCommand>\r
+ <name>org.eclipse.pde.FeatureBuilder</name>\r
+ <arguments>\r
+ </arguments>\r
+ </buildCommand>\r
+ </buildSpec>\r
+ <natures>\r
+ <nature>org.eclipse.pde.FeatureNature</nature>\r
+ </natures>\r
+</projectDescription>\r
--- /dev/null
+###############################################################################\r
+# Copyright (c) 2010 Association for Decentralized Information Management in\r
+# Industry THTH ry.\r
+# All rights reserved. This program and the accompanying materials\r
+# are made available under the terms of the Eclipse Public License v1.0\r
+# which accompanies this distribution, and is available at\r
+# http://www.eclipse.org/legal/epl-v10.html\r
+#\r
+# Contributors:\r
+# VTT Technical Research Centre of Finland - initial API and implementation\r
+###############################################################################\r
+bin.includes = feature.xml\r
+root=rootfiles/
\ No newline at end of file
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>\r
+<!--
+ Copyright (c) 2010 Association for Decentralized Information Management in
+ Industry THTH ry.
+ All rights reserved. This program and the accompanying materials
+ are made available under the terms of the Eclipse Public License v1.0
+ which accompanies this distribution, and is available at
+ http://www.eclipse.org/legal/epl-v10.html
+
+ Contributors:
+ VTT Technical Research Centre of Finland - initial API and implementation
+ -->\r
+<feature\r
+ id="org.simantics.sysdyn"\r
+ label="Simantics System Dynamics Feature"\r
+ version="1.0.0.qualifier"\r
+ provider-name="VTT Technical Research Centre of Finland">\r
+\r
+ <description url="http://www.example.com/description">\r
+ [Enter Feature Description here.]\r
+ </description>\r
+\r
+ <copyright url="http://www.example.com/copyright">\r
+ [Enter Copyright Description here.]\r
+ </copyright>\r
+\r
+ <license url="http://www.example.com/license">\r
+ [Enter License Description here.]\r
+ </license>\r
+\r
+ <includes\r
+ id="org.eclipse.equinox.executable"\r
+ version="0.0.0"/>\r
+\r
+ <includes\r
+ id="org.simantics.help"\r
+ version="0.0.0"/>\r
+\r
+ <includes\r
+ id="org.simantics.issues"\r
+ version="0.0.0"/>\r
+\r
+ <includes\r
+ id="org.simantics.modeling"\r
+ version="0.0.0"/>\r
+\r
+ <includes\r
+ id="org.simantics.issues.ui"\r
+ version="0.0.0"/>\r
+\r
+ <includes\r
+ id="org.simantics.structural"\r
+ version="0.0.0"/>\r
+\r
+ <includes\r
+ id="org.simantics.workbench"\r
+ version="0.0.0"/>\r
+\r
+ <includes\r
+ id="org.simantics.spreadsheet"\r
+ version="0.0.0"/>\r
+\r
+ <includes\r
+ id="org.simantics.operating"\r
+ version="0.0.0"\r
+ optional="true"/>\r
+\r
+ <plugin\r
+ id="org.simantics.objmap"\r
+ download-size="0"\r
+ install-size="0"\r
+ version="0.0.0"\r
+ unpack="false"/>\r
+\r
+ <plugin\r
+ id="org.simantics.sysdyn"\r
+ download-size="0"\r
+ install-size="0"\r
+ version="0.0.0"\r
+ unpack="false"/>\r
+\r
+ <plugin\r
+ id="org.simantics.sysdyn.ui"\r
+ download-size="0"\r
+ install-size="0"\r
+ version="0.0.0"\r
+ unpack="false"/>\r
+\r
+ <plugin\r
+ id="org.simantics.modelica"\r
+ download-size="0"\r
+ install-size="0"\r
+ version="0.0.0"\r
+ unpack="false"/>\r
+\r
+ <plugin\r
+ id="org.simantics.diagram.ontology"\r
+ download-size="0"\r
+ install-size="0"\r
+ version="0.0.0"\r
+ unpack="false"/>\r
+\r
+ <plugin\r
+ id="org.simantics.structural.ontology"\r
+ download-size="0"\r
+ install-size="0"\r
+ version="0.0.0"\r
+ unpack="false"/>\r
+\r
+ <plugin\r
+ id="org.simantics.sysdyn.ontology"\r
+ download-size="0"\r
+ install-size="0"\r
+ version="0.0.0"\r
+ unpack="false"/>\r
+\r
+ <plugin\r
+ id="freemarker"\r
+ download-size="0"\r
+ install-size="0"\r
+ version="0.0.0"\r
+ unpack="false"/>\r
+\r
+ <plugin\r
+ id="org.antlr.runtime"\r
+ download-size="0"\r
+ install-size="0"\r
+ version="0.0.0"\r
+ unpack="false"/>\r
+\r
+ <plugin\r
+ id="org.simantics.openmodelica.win32"\r
+ os="win32"\r
+ download-size="0"\r
+ install-size="0"\r
+ version="0.0.0"/>\r
+\r
+</feature>\r
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>\r
+<classpath>\r
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>\r
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>\r
+ <classpathentry kind="src" path="src"/>\r
+ <classpathentry kind="output" path="bin"/>\r
+</classpath>\r
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>\r
+<projectDescription>\r
+ <name>org.simantics.sysdyn.ontology</name>\r
+ <comment></comment>\r
+ <projects>\r
+ </projects>\r
+ <buildSpec>\r
+ <buildCommand>\r
+ <name>org.simantics.graph.builder</name>\r
+ <arguments>\r
+ </arguments>\r
+ </buildCommand>\r
+ <buildCommand>\r
+ <name>org.eclipse.jdt.core.javabuilder</name>\r
+ <arguments>\r
+ </arguments>\r
+ </buildCommand>\r
+ <buildCommand>\r
+ <name>org.eclipse.pde.ManifestBuilder</name>\r
+ <arguments>\r
+ </arguments>\r
+ </buildCommand>\r
+ <buildCommand>\r
+ <name>org.eclipse.pde.SchemaBuilder</name>\r
+ <arguments>\r
+ </arguments>\r
+ </buildCommand>\r
+ </buildSpec>\r
+ <natures>\r
+ <nature>org.eclipse.pde.PluginNature</nature>\r
+ <nature>org.eclipse.jdt.core.javanature</nature>\r
+ <nature>org.simantics.graph.nature</nature>\r
+ </natures>\r
+</projectDescription>\r
--- /dev/null
+#Thu Jul 22 15:15:41 EEST 2010\r
+eclipse.preferences.version=1\r
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled\r
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6\r
+org.eclipse.jdt.core.compiler.compliance=1.6\r
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error\r
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error\r
+org.eclipse.jdt.core.compiler.source=1.6\r
--- /dev/null
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: Simantics System Dynamics Ontology
+Bundle-SymbolicName: org.simantics.sysdyn.ontology
+Bundle-Version: 1.0.0.qualifier
+Require-Bundle: org.simantics.layer0,
+ org.simantics.diagram.ontology;bundle-version="1.0.0",
+ org.simantics.structural.ontology;bundle-version="1.0.0"
+Bundle-RequiredExecutionEnvironment: JavaSE-1.6
+Export-Package: org.simantics.sysdyn
+Bundle-Vendor: VTT Technical Reserarch Centre of Finland
--- /dev/null
+###############################################################################\r
+# Copyright (c) 2010 Association for Decentralized Information Management in\r
+# Industry THTH ry.\r
+# All rights reserved. This program and the accompanying materials\r
+# are made available under the terms of the Eclipse Public License v1.0\r
+# which accompanies this distribution, and is available at\r
+# http://www.eclipse.org/legal/epl-v10.html\r
+#\r
+# Contributors:\r
+# VTT Technical Research Centre of Finland - initial API and implementation\r
+###############################################################################\r
+source.. = src/\r
+output.. = bin/\r
+bin.includes = META-INF/,\\r
+ .,\\r
+ graphs/*.tg,\\r
+ graph.tg\r
+src.includes = graph/\r
--- /dev/null
+L0 = <http://www.simantics.org/Layer0-1.0>
+G2D = <http://www.simantics.org/G2D-1.0>
+STR = <http://www.simantics.org/Structural-1.0>
+DIA = <http://www.simantics.org/Diagram-2.0>
+SIMU = <http://www.simantics.org/Simulation-1.0>
+MOD = <http://www.simantics.org/Modeling-1.0>
+PROJ = <http://www.simantics.org/Project-1.0>
+
+//#####################################################################
+// Defines ontology and attaches it to SimanticsDomain
+//#####################################################################
+
+SYSDYN = <http://www.simantics.org/Sysdyn-1.0> : L0.Ontology
+ @L0.new
+ L0.HasResourceClass "org.simantics.sysdyn.SysdynResource"
+
+SYSDYN.ImportedOntologies : PROJ.NamespaceRequirement
+ L0.HasDescription "Specifies the ontologies required by a Sysdyn project."
+ PROJ.RequiresNamespace
+ "http://www.simantics.org/Sysdyn-1.0" : L0.URI
+ "http://www.simantics.org/Layer0-1.0" : L0.URI
+
+SYSDYN.SharedFunctionOntology <T L0.Ontology
+SYSDYN.SharedModuleOntolofgy <T L0.Ontology
+
+//#####################################################################
+// Model
+//#####################################################################
+
+SYSDYN.SysdynModel <T SIMU.Model
+ // TODO [SIMU.HasConfiguration all SYSDYN.Configuration]
+ @L0.assert SYSDYN.HasStartTime 0.0
+ @L0.assert SYSDYN.HasStopTime 10.0
+ @L0.singleProperty SYSDYN.HasOutputInterval
+ @L0.singleProperty SYSDYN.HasTolerance
+ @L0.assert SYSDYN.HasSolver "euler"
+
+SYSDYN.HasStartTime <R L0.HasProperty : L0.FunctionalRelation
+ L0.HasRange L0.Double
+
+SYSDYN.HasStopTime <R L0.HasProperty : L0.FunctionalRelation
+ L0.HasRange L0.Double
+
+SYSDYN.HasOutputInterval <R L0.HasProperty : L0.FunctionalRelation
+ L0.HasRange L0.Double
+
+SYSDYN.HasTolerance <R L0.HasProperty : L0.FunctionalRelation
+ L0.HasRange L0.Double
+
+SYSDYN.HasSolver <R L0.HasProperty : L0.FunctionalRelation
+ L0.HasRange L0.String
+
+//#####################################################################
+// Configuration
+//#####################################################################
+
+SYSDYN.Symbols : L0.Library
+SYSDYN.SysdynConnectionType : STR.ConnectionType
+
+SYSDYN.DiagramToCompositeMapping <T L0.Trigger
+
+SYSDYN.ConfigurationDiagram <T DIA.Diagram
+ @L0.assert STR.HasModelingRules SYSDYN.SysdynDiagramModelingRules
+ DIA.HasSymbolContribution _ : DIA.BasicSymbolContribution
+ DIA.BasicSymbolContributionHasSymbolLibrary
+ BasicSymbols
+
+SYSDYN.ConfigurationDiagramTemplate : MOD.DiagramTemplate
+ MOD.HasDiagramType SYSDYN.ConfigurationDiagram
+
+SYSDYN.SysdynDiagramModelingRules : MOD.MappedModelingRules
+ MOD.HasBaseRules STR.StandardModelingRules
+
+SYSDYN.SymbolReferences : DIA.SymbolReferenceLibrary
+BasicSymbols = SYSDYN.SymbolReferences.BasicSymbols : DIA.SymbolReferenceLibrary
+
+SYSDYN.Configuration <T STR.Composite <T L0.Realization
+ // TODO [L0.ConsistsOf all (Variable or Dependency or Module)]
+
+SYSDYN.HistoryRealization <T L0.Realization
+SYSDYN.DefaultRealization <T L0.Realization
+
+//#####################################################################
+// Variables
+//#####################################################################
+
+SYSDYN.Variable <T STR.Component
+ @L0.singleProperty L0.HasType
+ @L0.optionalProperty SYSDYN.HasArrayIndexes
+ @L0.optionalProperty SYSDYN.HasExpressions
+
+SYSDYN.HasExpressions <R L0.DependsOn : L0.FunctionalRelation
+ L0.HasDomain SYSDYN.Variable
+ L0.HasRange SYSDYN.Expressions
+
+SYSDYN.HasUnit <R L0.HasProperty
+ L0.HasRange L0.String
+
+SYSDYN.HasRangeStart <R L0.HasProperty
+ L0.HasRange L0.Double
+
+SYSDYN.HasRangeEnd <R L0.HasProperty
+ L0.HasRange L0.Double
+
+SYSDYN.HasRangeStep <R L0.HasProperty
+ L0.HasRange L0.Double
+
+SYSDYN.IndependentVariable <T SYSDYN.Variable
+ @L0.optionalProperty SYSDYN.HasUnit
+ @L0.optionalProperty SYSDYN.HasRangeStart
+ @L0.optionalProperty SYSDYN.HasRangeEnd
+ @L0.optionalProperty SYSDYN.HasRangeStep
+ @L0.optionalProperty L0.HasDescription
+ @L0.singleProperty SYSDYN.HasExpressions
+
+SYSDYN.Auxiliary <T SYSDYN.IndependentVariable
+ @L0.assert L0.HasType "Real"
+
+SYSDYN.Valve <T SYSDYN.IndependentVariable
+ @L0.assert L0.HasType "Real"
+
+SYSDYN.Stock <T SYSDYN.IndependentVariable
+ @L0.assert L0.HasType "Real"
+
+SYSDYN.Cloud <T SYSDYN.Variable
+
+SYSDYN.Input <T SYSDYN.Variable
+ @L0.optionalProperty SYSDYN.HasDefaultInputValue
+ @L0.optionalProperty L0.HasDescription
+ @L0.optionalProperty SYSDYN.HasUnit
+ @L0.assert SYSDYN.HasDefaultInputValue 0.0
+ @L0.assert L0.HasType "Real"
+
+SYSDYN.Enumeration <T SYSDYN.Variable
+ @L0.singleProperty SYSDYN.HasEnumerationIndexes
+ @L0.assert L0.HasType "type"
+ @L0.assert SYSDYN.IsReplaceable false
+
+
+//#####################################################################
+// Modules
+//#####################################################################
+
+SYSDYN.Module <T STR.Component
+ // TODO [STR.IsDefinedBy all Configuration]
+ @L0.singleProperty L0.HasLabel
+ @L0.property SYSDYN.HasRedeclaration
+
+SYSDYN.ModuleSymbol <T DIA.FontProvider <T DIA.ColorProvider
+ @MOD.defSymbol "ModuleSymbol" SYSDYN.Module
+ STR.IsDefinedBy _ : DIA.Composite
+ @L0.list
+ _ : SYSDYN.SysdynTerminal
+ @MOD.terminal SYSDYN.ModuleSymbol SYSDYN.IsHeadOfTerminal
+ _ : SYSDYN.SysdynTerminal
+ @MOD.terminal SYSDYN.ModuleSymbol SYSDYN.IsTailOfTerminal
+
+SYSDYN.IsOutput <R L0.IsRelatedTo : L0.Tag
+ @L0.symmetric
+
+
+SYSDYN.SysdynModuleLibrary <T L0.Library
+ @L0.singleProperty L0.HasName
+ @L0.optionalProperty L0.HasDescription
+
+
+//#####################################################################
+// Connections and Relations
+//#####################################################################
+
+SYSDYN.IsTailOf <R STR.IsConnectedTo
+ L0.HasDomain SYSDYN.Variable
+ L0.HasRange SYSDYN.Dependency
+ L0.InverseOf SYSDYN.HasTail
+ STR.AllowsConnectionType SYSDYN.SysdynConnectionType
+ STR.HasAttachmentRelation DIA.HasPlainConnector
+SYSDYN.IsHeadOf <R STR.IsConnectedTo
+ L0.HasDomain SYSDYN.Variable
+ L0.HasRange SYSDYN.Dependency
+ L0.InverseOf SYSDYN.HasHead
+ STR.AllowsConnectionType SYSDYN.SysdynConnectionType
+ STR.HasAttachmentRelation DIA.HasArrowConnector
+
+SYSDYN.Dependency <T STR.Connection
+ @L0.singleProperty SYSDYN.angle
+ @L0.singleProperty SYSDYN.HasHead
+ @L0.singleProperty SYSDYN.HasTail
+ @L0.optionalProperty SYSDYN.RefersTo
+
+SYSDYN.Flow <T STR.Connection
+ @L0.singleProperty SYSDYN.HasHead
+ @L0.singleProperty SYSDYN.HasTail
+
+SYSDYN.RefersTo <R L0.IsRelatedTo : L0.FunctionalRelation
+ L0.HasDomain SYSDYN.Variable
+ L0.HasRange SYSDYN.Variable
+
+
+//#####################################################################
+// Expression
+//#####################################################################
+
+SYSDYN.HasEquation <R L0.HasProperty
+ L0.HasRange L0.String
+
+SYSDYN.HasInitialEquation <R L0.HasProperty
+ L0.HasRange L0.String
+
+SYSDYN.HasLookup <R L0.HasProperty
+ L0.HasRange L0.String
+
+SYSDYN.HasMinX <R L0.HasProperty
+ L0.HasRange L0.Double
+
+SYSDYN.HasMaxX <R L0.HasProperty
+ L0.HasRange L0.Double
+
+SYSDYN.HasMinY <R L0.HasProperty
+ L0.HasRange L0.Double
+
+SYSDYN.HasMaxY <R L0.HasProperty
+ L0.HasRange L0.Double
+
+SYSDYN.HasArrayRange <R L0.HasProperty
+ L0.HasRange L0.String
+
+SYSDYN.Expressions <T L0.OrderedSet <R L0.HasNext
+
+SYSDYN.Expression <T L0.Entity
+ @L0.optionalProperty SYSDYN.HasArrayRange
+
+SYSDYN.NormalExpression <T SYSDYN.Expression
+ @L0.singleProperty SYSDYN.HasEquation
+
+SYSDYN.ParameterExpression <T SYSDYN.Expression
+ @L0.singleProperty SYSDYN.HasEquation
+
+SYSDYN.ConstantExpression <T SYSDYN.Expression
+ @L0.singleProperty SYSDYN.HasEquation
+
+SYSDYN.DelayExpression <T SYSDYN.Expression
+ @L0.singleProperty SYSDYN.HasEquation
+
+SYSDYN.StockExpression <T SYSDYN.Expression
+ @L0.singleProperty SYSDYN.HasInitialEquation
+
+SYSDYN.LookupExpression <T SYSDYN.Expression
+ @L0.singleProperty SYSDYN.HasLookup
+
+SYSDYN.WithLookupExpression <T SYSDYN.Expression
+ @L0.singleProperty SYSDYN.HasLookup
+ @L0.singleProperty SYSDYN.HasEquation
+ @L0.singleProperty SYSDYN.HasMinX
+ @L0.singleProperty SYSDYN.HasMaxX
+ @L0.singleProperty SYSDYN.HasMinY
+ @L0.singleProperty SYSDYN.HasMaxY
+
+SYSDYN.HasDefaultInputValue <R L0.HasProperty : L0.FunctionalRelation
+ L0.HasRange L0.Double
+
+// To be used in transient graphs for showing the correct experiment in equation editor
+SYSDYN.HasActiveExpression <R L0.HasProperty : L0.FunctionalRelation
+ L0.HasDomain SYSDYN.IndependentVariable
+ L0.HasRange SYSDYN.Expression
+
+//#####################################################################
+// Enumerations
+//#####################################################################
+
+SYSDYN.HasArrayIndexes <R L0.DependsOn : L0.FunctionalRelation
+ L0.HasDomain SYSDYN.Variable
+ L0.HasRange SYSDYN.ArrayIndexes
+
+SYSDYN.ArrayIndexes <T L0.OrderedSet <R L0.HasNext
+
+SYSDYN.HasEnumerationIndexes <R L0.DependsOn : L0.FunctionalRelation
+ L0.HasDomain SYSDYN.Enumeration
+ L0.HasRange SYSDYN.EnumerationIndexes
+
+SYSDYN.EnumerationIndexes <T L0.OrderedSet <R L0.HasNext
+
+SYSDYN.EnumerationIndex <T L0.Entity
+ @L0.singleProperty L0.HasName
+ @L0.assert SYSDYN.ShowEnumerationIndexInCharts true
+
+SYSDYN.ShowEnumerationIndexInCharts <R L0.HasProperty : L0.FunctionalRelation
+ L0.HasRange L0.Boolean
+
+//#####################################################################
+// Redeclarations
+//#####################################################################
+
+SYSDYN.IsReplaceable <R L0.HasProperty : L0.FunctionalRelation
+ L0.HasDomain SYSDYN.Enumeration
+ L0.HasRange L0.Boolean
+
+SYSDYN.ReplacedEnumeration <R L0.HasProperty : L0.FunctionalRelation
+ L0.HasDomain SYSDYN.Redeclaration
+ L0.HasRange SYSDYN.Enumeration
+
+SYSDYN.ReplacingEnumeration <R L0.HasProperty : L0.FunctionalRelation
+ L0.HasDomain SYSDYN.Redeclaration
+ L0.HasRange SYSDYN.Enumeration
+
+SYSDYN.Redeclaration <T L0.Entity
+ @L0.singleProperty SYSDYN.ReplacedEnumeration
+ @L0.singleProperty SYSDYN.ReplacingEnumeration
+
+SYSDYN.HasRedeclaration <R L0.IsComposedOf
+ L0.HasRange SYSDYN.Redeclaration
+
+//#####################################################################
+// Functions
+//#####################################################################
+
+SYSDYN.SysdynModelicaFunction <T L0.Entity
+ @L0.singleProperty L0.HasName
+ @L0.singleProperty SYSDYN.HasModelicaFunctionCode
+ @L0.optionalProperty L0.HasDescription
+
+SYSDYN.HasModelicaFunctionCode <R L0.HasProperty : L0.FunctionalRelation
+ L0.HasRange L0.String
+
+SYSDYN.ExternalFunctionFile <T L0.Entity
+ @L0.singleProperty L0.HasName
+ @L0.singleProperty SYSDYN.HasExternalFile
+
+SYSDYN.HasExternalFile <R L0.HasProperty
+ L0.HasRange L0.ByteArray
+
+SYSDYN.SysdynModelicaFunctionLibrary <T L0.Library
+ @L0.singleProperty L0.HasName
+ @L0.optionalProperty L0.HasDescription
+
+//#####################################################################
+// Experiments
+//#####################################################################
+
+SYSDYN.Experiment <T SIMU.Experiment
+ @L0.property SYSDYN.HasResult
+
+SYSDYN.BasicExperiment <T SYSDYN.Experiment
+
+SYSDYN.GameExperiment <T SYSDYN.Experiment
+
+SYSDYN.SimulateOnChangeExperiment <T SYSDYN.Experiment
+
+SYSDYN.HasResult <R L0.IsComposedOf
+ L0.HasRange SYSDYN.Result
+
+//#####################################################################
+// Results
+//#####################################################################
+
+SYSDYN.Result <T L0.Entity
+ // ??? SIMU.IsActive
+ @L0.singleProperty L0.HasName
+ @L0.optionalProperty SYSDYN.HasParameterFile
+ @L0.optionalProperty SYSDYN.HasResultFile
+
+SYSDYN.HasParameterFile <R L0.HasProperty
+ L0.HasRange L0.String
+
+SYSDYN.HasResultFile <R L0.HasProperty
+ L0.HasRange L0.String
+
+
+//#####################################################################
+//#####################################################################
+//################ DIAGRAM #################
+//#####################################################################
+//#####################################################################
+
+//#####################################################################
+// Component types
+//#####################################################################
+
+SYSDYN.IsHeadOfTerminal
+ L0.InverseOf SYSDYN.HasHeadTerminal
+ @MOD.terminalRelation SYSDYN.IsHeadOf
+SYSDYN.IsTailOfTerminal
+ L0.InverseOf SYSDYN.HasTailTerminal
+ @MOD.terminalRelation SYSDYN.IsTailOf
+
+SYSDYN.SysdynTerminal <T DIA.Terminal
+
+//#####################################################################
+SYSDYN.Valve <T STR.Component
+ @MOD.connection SYSDYN.IsTailOf
+ @MOD.connection SYSDYN.IsHeadOf
+
+SYSDYN.ValveSymbol <T DIA.FontProvider <T DIA.ColorProvider
+ @MOD.defSymbol "Valve" SYSDYN.Valve
+ L0.IsDependencyOf BasicSymbols
+ STR.IsDefinedBy _ : DIA.Composite <R L0.HasNext
+ @L0.list
+ _ : SYSDYN.SysdynTerminal
+ @MOD.terminal SYSDYN.ValveSymbol SYSDYN.IsHeadOfTerminal
+ _ : SYSDYN.SysdynTerminal
+ @MOD.terminal SYSDYN.ValveSymbol SYSDYN.IsTailOfTerminal
+
+//#####################################################################
+SYSDYN.Auxiliary <T STR.Component
+ @MOD.connection SYSDYN.IsTailOf
+ @MOD.connection SYSDYN.IsHeadOf
+
+SYSDYN.AuxiliarySymbol <T DIA.FontProvider <T DIA.ColorProvider
+ @MOD.defSymbol "Auxiliary" SYSDYN.Auxiliary
+ L0.IsDependencyOf BasicSymbols
+ STR.IsDefinedBy _ : DIA.Composite <R L0.HasNext
+ @L0.list
+ _ : SYSDYN.SysdynTerminal
+ @MOD.terminal SYSDYN.AuxiliarySymbol SYSDYN.IsHeadOfTerminal
+ _ : SYSDYN.SysdynTerminal
+ @MOD.terminal SYSDYN.AuxiliarySymbol SYSDYN.IsTailOfTerminal
+
+//#####################################################################
+SYSDYN.Cloud <T STR.Component
+ @MOD.connection SYSDYN.IsTailOf
+ @MOD.connection SYSDYN.IsHeadOf
+
+SYSDYN.CloudSymbol <T DIA.FontProvider <T DIA.ColorProvider
+ @MOD.defSymbol "Cloud" SYSDYN.Cloud
+ L0.IsDependencyOf BasicSymbols
+ STR.IsDefinedBy _ : DIA.Composite <R L0.HasNext
+ @L0.list
+ _ : SYSDYN.SysdynTerminal
+ @MOD.terminal SYSDYN.CloudSymbol SYSDYN.IsHeadOfTerminal
+ _ : SYSDYN.SysdynTerminal
+ @MOD.terminal SYSDYN.CloudSymbol SYSDYN.IsTailOfTerminal
+
+//#####################################################################
+SYSDYN.Input <T STR.Component
+ @MOD.connection SYSDYN.IsTailOf
+ @MOD.connection SYSDYN.IsHeadOf
+
+SYSDYN.InputSymbol <T DIA.FontProvider <T DIA.ColorProvider
+ @MOD.defSymbol "Input" SYSDYN.Input
+ L0.IsDependencyOf BasicSymbols
+ STR.IsDefinedBy _ : DIA.Composite <R L0.HasNext
+ @L0.list
+ _ : SYSDYN.SysdynTerminal
+ @MOD.terminal SYSDYN.InputSymbol SYSDYN.IsHeadOfTerminal
+ _ : SYSDYN.SysdynTerminal
+ @MOD.terminal SYSDYN.InputSymbol SYSDYN.IsTailOfTerminal
+
+//#####################################################################
+SYSDYN.Stock <T STR.Component
+ @MOD.connection SYSDYN.IsTailOf
+ @MOD.connection SYSDYN.IsHeadOf
+
+SYSDYN.StockSymbol <T DIA.FontProvider <T DIA.ColorProvider
+ @MOD.defSymbol "Stock" SYSDYN.Stock
+ L0.IsDependencyOf BasicSymbols
+ STR.IsDefinedBy _ : DIA.Composite <R L0.HasNext
+ @L0.list
+ _ : SYSDYN.SysdynTerminal
+ @MOD.terminal SYSDYN.StockSymbol SYSDYN.IsHeadOfTerminal
+ _ : SYSDYN.SysdynTerminal
+ @MOD.terminal SYSDYN.StockSymbol SYSDYN.IsTailOfTerminal
+
+//#####################################################################
+// Diagram connection types
+//#####################################################################
+
+SYSDYN.angle <R L0.HasProperty : L0.FunctionalRelation
+ L0.HasRange L0.Double
+
+SYSDYN.FlowConnection <T DIA.Connection
+ MOD.DiagramConnectionTypeToConnectionType
+ SYSDYN.Flow
+
+SYSDYN.DependencyConnection <T DIA.Connection
+ @L0.singleProperty SYSDYN.angle
+ @L0.assert SYSDYN.angle 0.1
+ MOD.DiagramConnectionTypeToConnectionType
+ SYSDYN.Dependency
--- /dev/null
+L0 = <http://www.simantics.org/Layer0-1.0>\r
+SYSDYN = <http://www.simantics.org/Sysdyn-1.0>\r
+\r
+FL = <http://www.simantics.org/Sysdyn-1.0/Built-in Functions> : SYSDYN.SysdynModelicaFunctionLibrary\r
+\r
+\r
+FL.xidz : SYSDYN.SysdynModelicaFunction\r
+ L0.HasDescription "X if divided by zero"\r
+ SYSDYN.HasModelicaFunctionCode """ input Real a;\r
+ input Real b;\r
+ input Real x;\r
+ output Real z;\r
+algorithm\r
+ if b > 0.0 or b < 0.0 then\r
+ z := a / b;\r
+ else\r
+ z := x;\r
+ end if;"""\r
+\r
+FL.zidz : SYSDYN.SysdynModelicaFunction\r
+ L0.HasDescription "Zero if divided by zero"\r
+ SYSDYN.HasModelicaFunctionCode """ input Real a;\r
+ input Real b;\r
+ output Real z;\r
+algorithm\r
+ z := xidz(a,b,0.0);"""\r
+\r
+FL.interpolate : SYSDYN.SysdynModelicaFunction\r
+ L0.HasDescription "Interpolate function for two-dimensional table"\r
+ SYSDYN.HasModelicaFunctionCode """ input Real u "input value (first column of table)";\r
+ input Real table[:, :] "table to be interpolated";\r
+ output Real y "interpolated input value (icol column of table)";\r
+algorithm\r
+ y := interpolateFull(u, table, 2);"""\r
+ \r
+ \r
+FL.interpolateFull : SYSDYN.SysdynModelicaFunction\r
+ L0.HasDescription "The full interpolate function"\r
+ SYSDYN.HasModelicaFunctionCode """ input Real u "input value (first column of table)";\r
+ input Real table[:, :] "table to be interpolated";\r
+ input Integer icol "column of table to be interpolated";\r
+ output Real y "interpolated input value (icol column of table)";\r
+protected \r
+ Integer i;\r
+ Integer n "number of rows of table";\r
+ Real u1;\r
+ Real u2;\r
+ Real y1;\r
+ Real y2;\r
+algorithm \r
+ n := size(table, 1);\r
+ if n <= 1 then\r
+ y := table[1, icol];\r
+ else\r
+ /* Search interval */\r
+ if u <= table[1, 1] then\r
+ i := 1;\r
+ else\r
+ i := 2;\r
+ while i < n and u > table[i, 1] loop\r
+ i := i + 1;\r
+ end while;\r
+ i := i - 1;\r
+ end if;\r
+\r
+ /* Get interpolation data */\r
+ u1 := table[i, 1];\r
+ u2 := table[i + 1, 1];\r
+ y1 := table[i, icol];\r
+ y2 := table[i + 1, icol];\r
+ /* Interpolate */\r
+ if u1 >= u2 then\r
+ y := y1;\r
+ /* since not possible to throw error */\r
+ else\r
+ y := y1 + (y2 - y1)*(u - u1)/(u2 - u1);\r
+ end if;\r
+ end if;"""
\ No newline at end of file
--- /dev/null
+\r
+L0 = <http://www.simantics.org/Layer0-1.0>\r
+SYSDYN = <http://www.simantics.org/Sysdyn-1.0>\r
+\r
+VF = <http://www.simantics.org/Sysdyn-1.0/Built-in Functions/Vensim Functions> : SYSDYN.SysdynModelicaFunctionLibrary\r
+\r
+/*\r
+VF.DELAYFIXED : SYSDYN.SysdynModelicaFunction\r
+ L0.HasDescription """DELAY FIXED( inputVar , dtime , init )\r
+ -> delay(inputVar, dtime)\r
+ init -value is ignored."""\r
+ SYSDYN.HasModelicaFunctionCode """ input Real inputVar;\r
+ input Real dtime;\r
+ input Real init;\r
+ input Real t = time;\r
+ output Real z;\r
+protected\r
+ parameter Real parameterDTime = dtime; \r
+algorithm\r
+ z := if time < parameterDTime then init else delay(inputVar, parameterDTime);"""\r
+*/\r
+ \r
+VF.IFTHENELSE : SYSDYN.SysdynModelicaFunction\r
+ L0.HasDescription """IF THEN ELSE( cond , ontrue , onfalse )\r
+ -> if cond then ontrue else onfalse"""\r
+ SYSDYN.HasModelicaFunctionCode """ input Boolean cond;\r
+ input Real ontrue;\r
+ input Real onfalse;\r
+ output Real z;\r
+algorithm\r
+ z := if cond then ontrue else onfalse;""" \r
+ \r
+VF.MAX : SYSDYN.SysdynModelicaFunction\r
+ L0.HasDescription """MAX(a, b) \r
+ Returns the larger of a and b."""\r
+ SYSDYN.HasModelicaFunctionCode """ input Real a;\r
+ input Real b;\r
+ output Real z;\r
+algorithm\r
+ z := if a > b then a else b;""" \r
+ \r
+VF.MIN : SYSDYN.SysdynModelicaFunction\r
+ L0.HasDescription """MIN(a, b) \r
+ Returns the smaller of a and b."""\r
+ SYSDYN.HasModelicaFunctionCode """ input Real a;\r
+ input Real b;\r
+ output Real z;\r
+algorithm\r
+ z := if a < b then a else b;""" \r
+ \r
+VF.XIDZ : SYSDYN.SysdynModelicaFunction\r
+ L0.HasDescription """XIDZ(a, b, x)\r
+ x if divided by zero, a/b otherwise."""\r
+ SYSDYN.HasModelicaFunctionCode """ input Real a;\r
+ input Real b;\r
+ input Real x;\r
+ output Real z;\r
+algorithm\r
+ z := xidz(a, b, x);""" \r
+ \r
+VF.ZIDZ : SYSDYN.SysdynModelicaFunction\r
+ L0.HasDescription """XIDZ(a, b)\r
+ Zero if divided by zero, a/b otherwise."""\r
+ SYSDYN.HasModelicaFunctionCode """ input Real a;\r
+ input Real b;\r
+ output Real z;\r
+algorithm\r
+ z := zidz(a, b);""" \r
+ \r
+VF.ABS : SYSDYN.SysdynModelicaFunction\r
+ L0.HasDescription """ABS(x)\r
+ Returns the absolute value of x."""\r
+ SYSDYN.HasModelicaFunctionCode """ input Real x;\r
+ output Real z;\r
+algorithm\r
+ z := abs(x);""" \r
+ \r
+VF.SQRT : SYSDYN.SysdynModelicaFunction\r
+ L0.HasDescription """SQRT(x)\r
+ Returns the square root of x."""\r
+ SYSDYN.HasModelicaFunctionCode """ input Real x;\r
+ output Real z;\r
+algorithm\r
+ z := sqrt(x);""" \r
+ \r
+VF.MODULO : SYSDYN.SysdynModelicaFunction\r
+ L0.HasDescription """MODULO(a, b)\r
+ Returns the remainder when a is divided by b. """\r
+ SYSDYN.HasModelicaFunctionCode """ input Real a;\r
+ input Real b;\r
+ output Real z;\r
+algorithm\r
+ z := mod(a, b);""" \r
+ \r
+VF.PULSE : SYSDYN.SysdynModelicaFunction\r
+ L0.HasDescription """PULSE(start, width)\r
+ Returns 1.0 starting at time start and lasting for interval width. 0.0 is returned at other times."""\r
+ SYSDYN.HasModelicaFunctionCode """ input Real start;\r
+ input Real width;\r
+ input Real t = time;\r
+ output Real z; \r
+algorithm\r
+ z := if t >= start and (t - start) <= width then 1.0 else 0.0;""" \r
+ \r
+VF.RAMP : SYSDYN.SysdynModelicaFunction\r
+ L0.HasDescription """RAMP(slope, startTime, endTime) \r
+ Returns 0 until the start time and then slopes upward until end time and then holds constant."""\r
+ SYSDYN.HasModelicaFunctionCode """ input Real slope;\r
+ input Real startTime;\r
+ input Real endTime;\r
+ input Real t = time;\r
+ output Real z; \r
+algorithm\r
+ z := \r
+ if t > startTime then\r
+ if t < endTime then \r
+ slope * (t - startTime) \r
+ else\r
+ slope * (endTime - startTime)\r
+ else\r
+ 0;""" \r
+ \r
+VF.STEP : SYSDYN.SysdynModelicaFunction\r
+ L0.HasDescription """STEP(height, stepTime)\r
+ Returns 0.0 until the step time and then returns height."""\r
+ SYSDYN.HasModelicaFunctionCode """ input Real height;\r
+ input Real stepTime;\r
+ input Real t = time;\r
+ output Real z;\r
+algorithm\r
+ z := if t >= stepTime then height else 0.0;""" \r
+ \r
+/* Continuous built-in common mathematical functions */\r
+\r
+VF.EXP : SYSDYN.SysdynModelicaFunction\r
+ L0.HasDescription """\r
+ """\r
+ SYSDYN.HasModelicaFunctionCode """ input Real x;\r
+ output Real z;\r
+algorithm\r
+ z := exp(x);"""\r
+ \r
+VF.SIN : SYSDYN.SysdynModelicaFunction\r
+ L0.HasDescription """SIN(x)\r
+ Returns the sine of x."""\r
+ SYSDYN.HasModelicaFunctionCode """ input Real x;\r
+ output Real z;\r
+algorithm\r
+ z := sin(x);""" \r
+ \r
+VF.SINH : SYSDYN.SysdynModelicaFunction\r
+ L0.HasDescription """SINH(x)\r
+ Returns the hyperbolic sine of x."""\r
+ SYSDYN.HasModelicaFunctionCode """ input Real x;\r
+ output Real z;\r
+algorithm\r
+ z := sinh(x);""" \r
+\r
+VF.COS : SYSDYN.SysdynModelicaFunction\r
+ L0.HasDescription """COS(x)\r
+ Returns the cosine of x."""\r
+ SYSDYN.HasModelicaFunctionCode """ input Real x;\r
+ output Real z;\r
+algorithm\r
+ z := cos(x);""" \r
+ \r
+VF.COSH : SYSDYN.SysdynModelicaFunction\r
+ L0.HasDescription """COSH(x)\r
+ Returns the hyperbolic cosine of x."""\r
+ SYSDYN.HasModelicaFunctionCode """ input Real x;\r
+ output Real z;\r
+algorithm\r
+ z := cosh(x);""" \r
+ \r
+VF.TAN : SYSDYN.SysdynModelicaFunction\r
+ L0.HasDescription """TAN(x)\r
+ Returns the tangent of x."""\r
+ SYSDYN.HasModelicaFunctionCode """ input Real x;\r
+ output Real z;\r
+algorithm\r
+ z := tan(x);""" \r
+ \r
+VF.TANH : SYSDYN.SysdynModelicaFunction\r
+ L0.HasDescription """TANH(x)\r
+ Returns the hyperbolic tangent of x."""\r
+ SYSDYN.HasModelicaFunctionCode """ input Real x;\r
+ output Real z;\r
+algorithm\r
+ z := tanh(x);""" \r
+ \r
+VF.LN : SYSDYN.SysdynModelicaFunction\r
+ L0.HasDescription """LN(x)\r
+ Returns the natural logarithm of x. \r
+ In modelica log(x) is the natural logarighm and log10(x) is base 10 logarighm."""\r
+ SYSDYN.HasModelicaFunctionCode """ input Real x;\r
+ output Real z;\r
+algorithm\r
+ z := log(x);""" \r
+
\ No newline at end of file
--- /dev/null
+L0 = <http://www.simantics.org/Layer0-1.0>\r
+G2D = <http://www.simantics.org/G2D-1.0>\r
+STR = <http://www.simantics.org/Structural-1.0>\r
+DIA = <http://www.simantics.org/Diagram-2.0>\r
+SIMU = <http://www.simantics.org/Simulation-1.0>\r
+MOD = <http://www.simantics.org/Modeling-1.0>\r
+SYSDYN = <http://www.simantics.org/Sysdyn-1.0>\r
+PROJ = <http://www.simantics.org/Project-1.0>\r
+\r
+//######################################################################\r
+//# Example work model with two modules\r
+//######################################################################\r
+\r
+/*\r
+WM = <http://Projects/Development Project> : PROJ.Project\r
+ @L0.new\r
+*/\r
+ \r
+WM = <http://Projects/Work Model Project> : PROJ.Project\r
+ @L0.new\r
+\r
+\r
+TAGS = WM.Tags : L0.Library\r
+ \r
+ \r
+WM.dependency : L0.Template\r
+ @template %type %head %tail %angle\r
+ %type \r
+ @L0.tag TAGS.AdminIsVisible\r
+ @L0.tag TAGS.AdminIsFocusable\r
+ STR.HasConnectionType SYSDYN.SysdynConnectionType\r
+ SYSDYN.angle %angle \r
+ DIA.HasArrowConnector _ : DIA.Connector\r
+ SYSDYN.HasHeadTerminal %head\r
+ DIA.AreConnected _ : DIA.Connector \r
+ SYSDYN.HasTailTerminal %tail\r
+ DIA.IsPlainConnectorOf %type\r
+ \r
+WM.flow : L0.Template\r
+ @template %type %head %tail\r
+ %type \r
+ @L0.tag TAGS.AdminIsVisible\r
+ @L0.tag TAGS.AdminIsFocusable\r
+ STR.HasConnectionType SYSDYN.SysdynConnectionType\r
+ DIA.HasArrowConnector _ : DIA.Connector\r
+ SYSDYN.HasHeadTerminal %head\r
+ DIA.AreConnected _ : DIA.Connector \r
+ SYSDYN.HasTailTerminal %tail\r
+ DIA.IsPlainConnectorOf %type \r
+\r
+WM.conf_dependency : L0.Template\r
+ @template %type %head %tail\r
+ %type \r
+ @L0.tag MOD.Mapped\r
+ SYSDYN.HasHead %head\r
+ SYSDYN.HasTail %tail\r
+ \r
+WM.conf_dependency_ref : L0.Template\r
+ @template %type %head %tail %ref\r
+ %type \r
+ @L0.tag MOD.Mapped\r
+ SYSDYN.HasHead %head\r
+ SYSDYN.HasTail %tail\r
+ SYSDYN.RefersTo %ref \r
+\r
+\r
+\r
+WM.WorkSymbol <T SYSDYN.ModuleSymbol\r
+ MOD.SymbolToComponentType WM.WorkModel.WorkModule\r
+ STR.IsDefinedBy _ : DIA.Composite <R L0.HasNext\r
+ @L0.list \r
+ _ : SYSDYN.SysdynTerminal\r
+ @MOD.terminal SYSDYN.ModuleSymbol SYSDYN.IsHeadOfTerminal\r
+ _ : SYSDYN.SysdynTerminal\r
+ @MOD.terminal SYSDYN.ModuleSymbol SYSDYN.IsTailOfTerminal\r
+\r
+WM.WorkforceSymbol <T SYSDYN.ModuleSymbol\r
+ MOD.SymbolToComponentType WM.WorkModel.WorkforceModule\r
+ STR.IsDefinedBy _ : DIA.Composite <R L0.HasNext\r
+ @L0.list \r
+ _ : SYSDYN.SysdynTerminal\r
+ @MOD.terminal SYSDYN.ModuleSymbol SYSDYN.IsHeadOfTerminal\r
+ _ : SYSDYN.SysdynTerminal\r
+ @MOD.terminal SYSDYN.ModuleSymbol SYSDYN.IsTailOfTerminal\r
+\r
+WM.WorkModel : SYSDYN.SysdynModel\r
+ L0.HasLabel "Work Model" \r
+ SIMU.HasConfiguration WC\r
+ SYSDYN.HasStartTime 0.0 \r
+ SYSDYN.HasStopTime 24.0 \r
+ L0.IsLinkedTo SYSDYN\r
+ L0.IsLinkedTo L0\r
+ \r
+WM.WorkModel.Experiment : SYSDYN.Experiment\r
+ L0.HasLabel "Experiment" \r
+\r
+WC = WM.WorkModel.WorkModelConfiguration : SYSDYN.Configuration\r
+ L0.HasLabel "WorkModelConfiguration" \r
+\r
+ \r
+// Modules\r
+WC.Workforce : WM.WorkModel.WorkforceModule\r
+ @L0.tag MOD.Mapped\r
+ L0.HasLabel "Workforce" \r
+WC.Work1 : WM.WorkModel.WorkModule\r
+ @L0.tag MOD.Mapped\r
+ L0.HasLabel "Work1" \r
+WC.Work2 : WM.WorkModel.WorkModule\r
+ @L0.tag MOD.Mapped\r
+ L0.HasLabel "Work2" \r
+ \r
+// Parameters\r
+WC.Work1CompletionTime : SYSDYN.Auxiliary\r
+ @L0.tag MOD.Mapped\r
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions\r
+ @L0.list\r
+ _ : SYSDYN.ParameterExpression\r
+ SYSDYN.HasEquation "15" \r
+WC.Work2CompletionTime : SYSDYN.Auxiliary\r
+ @L0.tag MOD.Mapped \r
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions\r
+ @L0.list\r
+ _ : SYSDYN.ParameterExpression\r
+ SYSDYN.HasEquation "11" \r
+WC.Work2Amount : SYSDYN.Auxiliary\r
+ @L0.tag MOD.Mapped \r
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions\r
+ @L0.list\r
+ _ : SYSDYN.ParameterExpression\r
+ SYSDYN.HasEquation "700" \r
+ \r
+// Enumeration Test\r
+WC.EnumerationTest : SYSDYN.Enumeration\r
+ SYSDYN.HasEnumerationIndexes _ : SYSDYN.EnumerationIndexes\r
+ @L0.list\r
+ _ : SYSDYN.EnumerationIndex\r
+ L0.HasName "Moro" : L0.String\r
+ _ : SYSDYN.EnumerationIndex\r
+ L0.HasName "Tere" : L0.String \r
+ \r
+// Inputs\r
+WC.TotalPossibleWorkingSpeedInput : SYSDYN.Input\r
+ @L0.tag MOD.Mapped\r
+WC.RequiredWorkingSpeed1 : SYSDYN.Input\r
+ @L0.tag MOD.Mapped\r
+WC.RequiredWorkingSpeed2 : SYSDYN.Input\r
+ @L0.tag MOD.Mapped \r
+WC.Work1WorkDone : SYSDYN.Input\r
+ @L0.tag MOD.Mapped \r
+WC.Work2WorkDone : SYSDYN.Input\r
+ @L0.tag MOD.Mapped \r
+ \r
+// Auxiliaries \r
+WC.RequiredWorkingSpeedTotal : SYSDYN.Auxiliary\r
+ @L0.tag MOD.Mapped\r
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions\r
+ @L0.list\r
+ _ : SYSDYN.NormalExpression\r
+ SYSDYN.HasEquation "RequiredWorkingSpeed1+RequiredWorkingSpeed2" \r
+ \r
+WC.d1 : SYSDYN.Dependency\r
+ @WM.conf_dependency_ref WC.TotalPossibleWorkingSpeedInput WC.Workforce WFC.PossibleWorkingSpeed \r
+WC.d2 : SYSDYN.Dependency\r
+ @WM.conf_dependency_ref WC.Work1 WC.TotalPossibleWorkingSpeedInput WMC.PossibleWorkingSpeedInput \r
+WC.d3 : SYSDYN.Dependency\r
+ @WM.conf_dependency_ref WC.Work1 WC.Work1CompletionTime WMC.WorkCompletionTimeInput\r
+WC.d4 : SYSDYN.Dependency\r
+ @WM.conf_dependency_ref WC.Work1 WC.RequiredWorkingSpeedTotal WMC.RequiredWorkingSpeedTotalInput \r
+WC.d5 : SYSDYN.Dependency\r
+ @WM.conf_dependency_ref WC.RequiredWorkingSpeed1 WC.Work1 WMC.RequiredWorkingSpeed \r
+WC.d6 : SYSDYN.Dependency\r
+ @WM.conf_dependency_ref WC.Work2 WC.TotalPossibleWorkingSpeedInput WMC.PossibleWorkingSpeedInput \r
+WC.d7 : SYSDYN.Dependency\r
+ @WM.conf_dependency_ref WC.Work2 WC.Work2CompletionTime WMC.WorkCompletionTimeInput \r
+WC.d8 : SYSDYN.Dependency\r
+ @WM.conf_dependency_ref WC.Work2 WC.RequiredWorkingSpeedTotal WMC.RequiredWorkingSpeedTotalInput \r
+WC.d9 : SYSDYN.Dependency\r
+ @WM.conf_dependency_ref WC.RequiredWorkingSpeed2 WC.Work2 WMC.RequiredWorkingSpeed \r
+WC.d10 : SYSDYN.Dependency\r
+ @WM.conf_dependency_ref WC.Workforce WC.RequiredWorkingSpeedTotal WFC.RequiredWorkingSpeedInput \r
+WC.d11 : SYSDYN.Dependency\r
+ @WM.conf_dependency WC.RequiredWorkingSpeedTotal WC.RequiredWorkingSpeed1\r
+WC.d12 : SYSDYN.Dependency\r
+ @WM.conf_dependency WC.RequiredWorkingSpeedTotal WC.RequiredWorkingSpeed2\r
+WC.d13 : SYSDYN.Dependency\r
+ @WM.conf_dependency_ref WC.Work1WorkDone WC.Work1 WMC.WorkDone\r
+WC.d14 : SYSDYN.Dependency\r
+ @WM.conf_dependency_ref WC.Work2WorkDone WC.Work2 WMC.WorkDone \r
+WC.d15 : SYSDYN.Dependency\r
+ @WM.conf_dependency_ref WC.Work2 WC.Work2Amount WMC.ProjectWorkAmount \r
+ \r
+ \r
+WorkModelConfigurationDiagram : SYSDYN.ConfigurationDiagram <R L0.HasNext\r
+ MOD.DiagramToComposite WC\r
+ DIA.HasLayer WM.Admin : DIA.Layer\r
+ DIA.IsActive true \r
+ DIA.HasFocusableTag TAGS.AdminIsFocusable <R DIA.IsFocusable\r
+ @L0.symmetric\r
+ DIA.HasVisibleTag TAGS.AdminIsVisible <R DIA.IsVisible\r
+ @L0.symmetric\r
+ L0.HasTrigger _ : SYSDYN.DiagramToCompositeMapping\r
+// DIA.NavigationEnabled "false" \r
+ @L0.list\r
+ WorkforceElement : WM.WorkforceSymbol\r
+ MOD.ElementToComponent WC.Workforce\r
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, 101.0, 50.0] : G2D.Transform\r
+ Work1Element : WM.WorkSymbol\r
+ MOD.ElementToComponent WC.Work1\r
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, 114.0, 87.0] : G2D.Transform\r
+ Work2Element : WM.WorkSymbol\r
+ MOD.ElementToComponent WC.Work2\r
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, 108.0, 161.0] : G2D.Transform \r
+ Work1CompletionTimeElement : SYSDYN.AuxiliarySymbol\r
+ MOD.ElementToComponent WC.Work1CompletionTime\r
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, 165.0, 99.0] : G2D.Transform \r
+ Work2CompletionTimeElement : SYSDYN.AuxiliarySymbol\r
+ MOD.ElementToComponent WC.Work2CompletionTime\r
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, 165.0, 153.0] : G2D.Transform \r
+ Work2AmountElement : SYSDYN.AuxiliarySymbol\r
+ MOD.ElementToComponent WC.Work2Amount\r
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, 75.0, 160.0] : G2D.Transform \r
+ RequiredWorkingSpeedTotalElement : SYSDYN.AuxiliarySymbol\r
+ MOD.ElementToComponent WC.RequiredWorkingSpeedTotal\r
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, 32.0, 76.0] : G2D.Transform \r
+ TotalPossibleWorkingSpeedInputElement : SYSDYN.InputSymbol\r
+ MOD.ElementToComponent WC.TotalPossibleWorkingSpeedInput\r
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, 141.0, 60.0] : G2D.Transform\r
+ RequiredWorkingSpeed1Element : SYSDYN.InputSymbol\r
+ MOD.ElementToComponent WC.RequiredWorkingSpeed1\r
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, 65.0, 125.0] : G2D.Transform\r
+ RequiredWorkingSpeed2Element : SYSDYN.InputSymbol\r
+ MOD.ElementToComponent WC.RequiredWorkingSpeed2\r
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, 100.0, 122.0] : G2D.Transform\r
+ Work1WorkDoneElement : SYSDYN.InputSymbol\r
+ MOD.ElementToComponent WC.Work1WorkDone\r
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, 155.0, 110.0] : G2D.Transform\r
+ Work2WorkDoneElement : SYSDYN.InputSymbol\r
+ MOD.ElementToComponent WC.Work2WorkDone\r
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, 155.0, 130.0] : G2D.Transform \r
+ _ : SYSDYN.DependencyConnection\r
+ MOD.DiagramConnectionToConnection WC.d1 \r
+ @WM.dependency TotalPossibleWorkingSpeedInputElement WorkforceElement -0.1 \r
+ _ : SYSDYN.DependencyConnection\r
+ MOD.DiagramConnectionToConnection WC.d2\r
+ @WM.dependency Work1Element TotalPossibleWorkingSpeedInputElement -0.1 \r
+ _ : SYSDYN.DependencyConnection\r
+ MOD.DiagramConnectionToConnection WC.d3 \r
+ @WM.dependency Work1Element Work1CompletionTimeElement -0.1 \r
+ _ : SYSDYN.DependencyConnection\r
+ MOD.DiagramConnectionToConnection WC.d4 \r
+ @WM.dependency Work1Element RequiredWorkingSpeedTotalElement -0.1 \r
+ _ : SYSDYN.DependencyConnection\r
+ MOD.DiagramConnectionToConnection WC.d5 \r
+ @WM.dependency RequiredWorkingSpeed1Element Work1Element -0.1 \r
+ _ : SYSDYN.DependencyConnection\r
+ MOD.DiagramConnectionToConnection WC.d6\r
+ @WM.dependency Work2Element TotalPossibleWorkingSpeedInputElement -0.1 \r
+ _ : SYSDYN.DependencyConnection\r
+ MOD.DiagramConnectionToConnection WC.d7 \r
+ @WM.dependency Work2Element Work2CompletionTimeElement -0.1 \r
+ _ : SYSDYN.DependencyConnection\r
+ MOD.DiagramConnectionToConnection WC.d8 \r
+ @WM.dependency Work2Element RequiredWorkingSpeedTotalElement -0.1 \r
+ _ : SYSDYN.DependencyConnection\r
+ MOD.DiagramConnectionToConnection WC.d9\r
+ @WM.dependency RequiredWorkingSpeed2Element Work2Element -0.1 \r
+ _ : SYSDYN.DependencyConnection\r
+ MOD.DiagramConnectionToConnection WC.d10\r
+ @WM.dependency WorkforceElement RequiredWorkingSpeedTotalElement -0.1 \r
+ _ : SYSDYN.DependencyConnection\r
+ MOD.DiagramConnectionToConnection WC.d11\r
+ @WM.dependency RequiredWorkingSpeedTotalElement RequiredWorkingSpeed1Element -0.1 \r
+ _ : SYSDYN.DependencyConnection\r
+ MOD.DiagramConnectionToConnection WC.d12\r
+ @WM.dependency RequiredWorkingSpeedTotalElement RequiredWorkingSpeed2Element -0.1 \r
+ _ : SYSDYN.DependencyConnection\r
+ MOD.DiagramConnectionToConnection WC.d13\r
+ @WM.dependency Work1WorkDoneElement Work1Element -0.1 \r
+ _ : SYSDYN.DependencyConnection\r
+ MOD.DiagramConnectionToConnection WC.d14\r
+ @WM.dependency Work2WorkDoneElement Work2Element -0.1 \r
+ _ : SYSDYN.DependencyConnection\r
+ MOD.DiagramConnectionToConnection WC.d15\r
+ @WM.dependency Work2Element Work2AmountElement -0.1 \r
+ \r
+WM.WorkModel.WorkModule <T SYSDYN.Module\r
+ STR.IsDefinedBy WMC\r
+\r
+WMC = WM.WorkModel.WorkModuleConfiguration : SYSDYN.Configuration \r
+// Parameters\r
+WMC.MaximumWorkingSpeed : SYSDYN.Auxiliary\r
+ @L0.tag MOD.Mapped\r
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions\r
+ @L0.list\r
+ _ : SYSDYN.ParameterExpression\r
+ SYSDYN.HasEquation "500" \r
+WMC.WorkQuality : SYSDYN.Auxiliary\r
+ @L0.tag MOD.Mapped\r
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions\r
+ @L0.list\r
+ _ : SYSDYN.ParameterExpression\r
+ SYSDYN.HasEquation "0.9" \r
+ \r
+// Valves\r
+WMC.WorkingSpeed : SYSDYN.Valve\r
+ @L0.tag MOD.Mapped\r
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions\r
+ @L0.list\r
+ _ : SYSDYN.NormalExpression\r
+ SYSDYN.HasEquation "if ProjectIsReady < 1 then WorkAllocation else 0" \r
+WMC.ErrorsGenerated : SYSDYN.Valve\r
+ @L0.tag MOD.Mapped\r
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions\r
+ @L0.list\r
+ _ : SYSDYN.NormalExpression\r
+ SYSDYN.HasEquation "(1-WorkQuality)*WorkingSpeed" \r
+WMC.ErrorsFoundRate : SYSDYN.Valve\r
+ @L0.tag MOD.Mapped\r
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions\r
+ @L0.list\r
+ _ : SYSDYN.NormalExpression\r
+ SYSDYN.HasEquation "Errors/ErrorsFoundTime" \r
+WMC.ProjectReadyness : SYSDYN.Valve\r
+ @L0.tag MOD.Mapped\r
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions\r
+ @L0.list\r
+ _ : SYSDYN.NormalExpression\r
+ SYSDYN.HasEquation "(xidz(WorkDone, ProjectWorkAmount, 0.0) - ProjectIsReady) / 0.08" \r
+ \r
+\r
+ \r
+// Stocks\r
+WMC.WorkToDo : SYSDYN.Stock\r
+ @L0.tag MOD.Mapped\r
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions\r
+ @L0.list\r
+ _ : SYSDYN.StockExpression\r
+ SYSDYN.HasInitialEquation "ProjectWorkAmount" \r
+WMC.WorkDone : SYSDYN.Stock\r
+ @L0.tag MOD.Mapped\r
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions\r
+ @L0.list\r
+ _ : SYSDYN.StockExpression\r
+ SYSDYN.HasInitialEquation "0" \r
+ @L0.tag SYSDYN.IsOutput\r
+WMC.Errors : SYSDYN.Stock\r
+ @L0.tag MOD.Mapped\r
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions\r
+ @L0.list\r
+ _ : SYSDYN.StockExpression\r
+ SYSDYN.HasInitialEquation "0" \r
+WMC.ProjectIsReady : SYSDYN.Stock\r
+ @L0.tag MOD.Mapped\r
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions\r
+ @L0.list\r
+ _ : SYSDYN.StockExpression\r
+ SYSDYN.HasInitialEquation "0" \r
+ \r
+// Auxiliaries \r
+WMC.TimeToDeadline : SYSDYN.Auxiliary\r
+ @L0.tag MOD.Mapped\r
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions\r
+ @L0.list\r
+ _ : SYSDYN.NormalExpression\r
+ SYSDYN.HasEquation "max(0, WorkCompletionTimeInput-time)" \r
+WMC.RequiredWorkingSpeed : SYSDYN.Auxiliary\r
+ @L0.tag MOD.Mapped\r
+ @L0.tag SYSDYN.IsOutput\r
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions\r
+ @L0.list\r
+ _ : SYSDYN.NormalExpression\r
+ SYSDYN.HasEquation "if ProjectIsReady < 1 then xidz(WorkToDo, TimeToDeadline, MaximumWorkingSpeed) else 0" \r
+WMC.WorkAllocation : SYSDYN.Auxiliary\r
+ @L0.tag MOD.Mapped\r
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions\r
+ @L0.list\r
+ _ : SYSDYN.NormalExpression\r
+ SYSDYN.HasEquation "xidz(RequiredWorkingSpeed, RequiredWorkingSpeedTotalInput, 0.0) * PossibleWorkingSpeedInput" \r
+WMC.ErrorsFoundTime : SYSDYN.Auxiliary\r
+ @L0.tag MOD.Mapped\r
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions\r
+ @L0.list\r
+ _ : SYSDYN.WithLookupExpression\r
+ SYSDYN.HasEquation "xidz(WorkDone, ProjectWorkAmount, 0.0)" \r
+ SYSDYN.HasLookup "{{0,5},{0.5,3},{1,0.5},{2,0.5}}" \r
+ SYSDYN.HasMinX 0.0\r
+ SYSDYN.HasMaxX 5.0\r
+ SYSDYN.HasMinY 0.0\r
+ SYSDYN.HasMaxY 5.0\r
+\r
+// Inputs\r
+WMC.WorkCompletionTimeInput : SYSDYN.Input\r
+ @L0.tag MOD.Mapped\r
+WMC.PossibleWorkingSpeedInput : SYSDYN.Input\r
+ @L0.tag MOD.Mapped \r
+WMC.RequiredWorkingSpeedTotalInput : SYSDYN.Input\r
+ @L0.tag MOD.Mapped \r
+WMC.ProjectWorkAmount : SYSDYN.Input\r
+ @L0.tag MOD.Mapped\r
+ SYSDYN.HasDefaultInputValue 1000.0 \r
+ \r
+WMC.c31 : SYSDYN.Cloud\r
+WMC.c33 : SYSDYN.Cloud\r
+ \r
+WMC.d31 : SYSDYN.Dependency\r
+ @WM.conf_dependency WMC.TimeToDeadline WMC.WorkCompletionTimeInput \r
+WMC.d32 : SYSDYN.Dependency\r
+ @WM.conf_dependency WMC.RequiredWorkingSpeed WMC.MaximumWorkingSpeed \r
+WMC.d33 : SYSDYN.Dependency\r
+ @WM.conf_dependency WMC.RequiredWorkingSpeed WMC.TimeToDeadline \r
+WMC.d34 : SYSDYN.Dependency\r
+ @WM.conf_dependency WMC.RequiredWorkingSpeed WMC.ProjectIsReady \r
+WMC.d35 : SYSDYN.Dependency\r
+ @WM.conf_dependency WMC.RequiredWorkingSpeed WMC.WorkToDo \r
+WMC.d36 : SYSDYN.Dependency\r
+ @WM.conf_dependency WMC.WorkAllocation WMC.RequiredWorkingSpeedTotalInput \r
+WMC.d37 : SYSDYN.Dependency\r
+ @WM.conf_dependency WMC.WorkAllocation WMC.PossibleWorkingSpeedInput \r
+WMC.d38 : SYSDYN.Dependency\r
+ @WM.conf_dependency WMC.WorkAllocation WMC.RequiredWorkingSpeed \r
+WMC.d40 : SYSDYN.Dependency\r
+ @WM.conf_dependency WMC.ProjectReadyness WMC.WorkDone \r
+WMC.d41 : SYSDYN.Dependency\r
+ @WM.conf_dependency WMC.ProjectReadyness WMC.ProjectWorkAmount \r
+WMC.d42 : SYSDYN.Dependency\r
+ @WM.conf_dependency WMC.WorkingSpeed WMC.WorkAllocation \r
+WMC.d43 : SYSDYN.Dependency\r
+ @WM.conf_dependency WMC.WorkingSpeed WMC.ProjectIsReady \r
+WMC.d44 : SYSDYN.Dependency\r
+ @WM.conf_dependency WMC.ErrorsGenerated WMC.WorkingSpeed \r
+WMC.d45 : SYSDYN.Dependency\r
+ @WM.conf_dependency WMC.ErrorsGenerated WMC.WorkQuality \r
+WMC.d46 : SYSDYN.Dependency\r
+ @WM.conf_dependency WMC.ErrorsFoundRate WMC.Errors \r
+WMC.d47 : SYSDYN.Dependency\r
+ @WM.conf_dependency WMC.ErrorsFoundRate WMC.ErrorsFoundTime \r
+WMC.d48 : SYSDYN.Dependency\r
+ @WM.conf_dependency WMC.ErrorsFoundTime WMC.ProjectWorkAmount \r
+WMC.d49 : SYSDYN.Dependency\r
+ @WM.conf_dependency WMC.ErrorsFoundTime WMC.WorkDone \r
+ \r
+ \r
+WMC.f31 : SYSDYN.Flow\r
+ @WM.conf_dependency WMC.WorkingSpeed WMC.WorkToDo \r
+WMC.f32 : SYSDYN.Flow\r
+ @WM.conf_dependency WMC.WorkDone WMC.WorkingSpeed \r
+WMC.f33 : SYSDYN.Flow\r
+ @WM.conf_dependency WMC.ErrorsGenerated WMC.c31 \r
+WMC.f34 : SYSDYN.Flow\r
+ @WM.conf_dependency WMC.Errors WMC.ErrorsGenerated \r
+WMC.f35 : SYSDYN.Flow\r
+ @WM.conf_dependency WMC.ErrorsFoundRate WMC.Errors \r
+WMC.f36 : SYSDYN.Flow\r
+ @WM.conf_dependency WMC.ErrorsFoundRate WMC.WorkDone \r
+WMC.f37 : SYSDYN.Flow\r
+ @WM.conf_dependency WMC.WorkToDo WMC.ErrorsFoundRate \r
+WMC.f40 : SYSDYN.Flow\r
+ @WM.conf_dependency WMC.ProjectIsReady WMC.ProjectReadyness \r
+WMC.f41 : SYSDYN.Flow\r
+ @WM.conf_dependency WMC.ProjectReadyness WMC.c33 \r
+ \r
+WorkModuleConfigurationDiagram : SYSDYN.ConfigurationDiagram <R L0.HasNext\r
+ MOD.DiagramToComposite WMC\r
+ DIA.HasLayer WM.Admin\r
+/*\r
+ DIA.HasLayer _ : DIA.Layer\r
+ DIA.IsActive true \r
+ DIA.HasFocusableTag TAGS.AdminIsFocusable\r
+ DIA.HasVisibleTag TAGS.AdminIsVisible\r
+*/\r
+ L0.HasTrigger _ : SYSDYN.DiagramToCompositeMapping\r
+ @L0.list\r
+ WorkCompletionTimeInputElement : SYSDYN.InputSymbol\r
+ MOD.ElementToComponent WMC.WorkCompletionTimeInput\r
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, 60.0, 55.0] : G2D.Transform \r
+ PossibleWorkingSpeedInputElement : SYSDYN.InputSymbol\r
+ MOD.ElementToComponent WMC.PossibleWorkingSpeedInput\r
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, 190.0, 60.0] : G2D.Transform \r
+ RequiredWorkingSpeedTotalInputElement : SYSDYN.InputSymbol\r
+ MOD.ElementToComponent WMC.RequiredWorkingSpeedTotalInput\r
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, 165.0, 45.0] : G2D.Transform \r
+ ProjectWorkAmountElement : SYSDYN.InputSymbol\r
+ MOD.ElementToComponent WMC.ProjectWorkAmount\r
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, 210.0, 120.0] : G2D.Transform \r
+ \r
+ WorkingSpeedElement : SYSDYN.ValveSymbol\r
+ MOD.ElementToComponent WMC.WorkingSpeed\r
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, 125.0, 100.0] : G2D.Transform \r
+ ErrorsGeneratedElement : SYSDYN.ValveSymbol\r
+ MOD.ElementToComponent WMC.ErrorsGenerated\r
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, 135.0, 110.0] : G2D.Transform \r
+ ErrorsFoundRateElement : SYSDYN.ValveSymbol\r
+ MOD.ElementToComponent WMC.ErrorsFoundRate\r
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, 140.0, 140.0] : G2D.Transform \r
+ ProjectReadynessElement : SYSDYN.ValveSymbol\r
+ MOD.ElementToComponent WMC.ProjectReadyness\r
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, 215.0, 85.0] : G2D.Transform \r
+ \r
+ WorkToDoElement : SYSDYN.StockSymbol\r
+ MOD.ElementToComponent WMC.WorkToDo\r
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, 85.0, 100.0] : G2D.Transform \r
+ WorkDoneElement : SYSDYN.StockSymbol\r
+ MOD.ElementToComponent WMC.WorkDone\r
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, 160.0, 100.0] : G2D.Transform \r
+ ErrorsElement : SYSDYN.StockSymbol\r
+ MOD.ElementToComponent WMC.Errors\r
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, 153.0, 110.0] : G2D.Transform \r
+ ProjectIsReadyElement : SYSDYN.StockSymbol\r
+ MOD.ElementToComponent WMC.ProjectIsReady\r
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, 180.0, 85.0] : G2D.Transform \r
+ \r
+ MaximumWorkingSpeedElement : SYSDYN.AuxiliarySymbol\r
+ MOD.ElementToComponent WMC.MaximumWorkingSpeed\r
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, 45.0, 70.0] : G2D.Transform \r
+ WorkQualityElement : SYSDYN.AuxiliarySymbol\r
+ MOD.ElementToComponent WMC.WorkQuality\r
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, 120.0, 130.0] : G2D.Transform \r
+ TimeToDeadlineElement : SYSDYN.AuxiliarySymbol\r
+ MOD.ElementToComponent WMC.TimeToDeadline\r
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, 80.0, 75.0] : G2D.Transform \r
+ RequiredWorkingSpeedElement : SYSDYN.AuxiliarySymbol\r
+ MOD.ElementToComponent WMC.RequiredWorkingSpeed\r
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, 90.0, 90.0] : G2D.Transform \r
+ WorkAllocationElement : SYSDYN.AuxiliarySymbol\r
+ MOD.ElementToComponent WMC.WorkAllocation\r
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, 140.0, 75.0] : G2D.Transform \r
+ ErrorsFoundTimeElement : SYSDYN.AuxiliarySymbol\r
+ MOD.ElementToComponent WMC.ErrorsFoundTime\r
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, 180.0, 140.0] : G2D.Transform \r
+\r
+ c31Element : SYSDYN.CloudSymbol\r
+ MOD.ElementToComponent WMC.c31\r
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, 110.0, 110.0] : G2D.Transform \r
+ c33Element : SYSDYN.CloudSymbol\r
+ MOD.ElementToComponent WMC.c33\r
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, 230.0, 85.0] : G2D.Transform \r
+ \r
+ _ : SYSDYN.DependencyConnection\r
+ MOD.DiagramConnectionToConnection WMC.d31\r
+ @WM.dependency TimeToDeadlineElement WorkCompletionTimeInputElement -0.1 \r
+ _ : SYSDYN.DependencyConnection\r
+ MOD.DiagramConnectionToConnection WMC.d32\r
+ @WM.dependency RequiredWorkingSpeedElement MaximumWorkingSpeedElement -0.1 \r
+ _ : SYSDYN.DependencyConnection\r
+ MOD.DiagramConnectionToConnection WMC.d33\r
+ @WM.dependency RequiredWorkingSpeedElement TimeToDeadlineElement -0.1 \r
+ _ : SYSDYN.DependencyConnection\r
+ MOD.DiagramConnectionToConnection WMC.d34\r
+ @WM.dependency RequiredWorkingSpeedElement ProjectIsReadyElement -0.1 \r
+ _ : SYSDYN.DependencyConnection\r
+ MOD.DiagramConnectionToConnection WMC.d36\r
+ @WM.dependency WorkAllocationElement RequiredWorkingSpeedTotalInputElement -0.1 \r
+ _ : SYSDYN.DependencyConnection\r
+ MOD.DiagramConnectionToConnection WMC.d35\r
+ @WM.dependency RequiredWorkingSpeedElement WorkToDoElement -0.1 \r
+ _ : SYSDYN.DependencyConnection\r
+ MOD.DiagramConnectionToConnection WMC.d37\r
+ @WM.dependency WorkAllocationElement PossibleWorkingSpeedInputElement -0.1 \r
+ _ : SYSDYN.DependencyConnection\r
+ MOD.DiagramConnectionToConnection WMC.d38\r
+ @WM.dependency WorkAllocationElement RequiredWorkingSpeedElement -0.1 \r
+ _ : SYSDYN.DependencyConnection\r
+ MOD.DiagramConnectionToConnection WMC.d40\r
+ @WM.dependency ProjectReadynessElement WorkDoneElement -0.1 \r
+ _ : SYSDYN.DependencyConnection\r
+ MOD.DiagramConnectionToConnection WMC.d41\r
+ @WM.dependency ProjectReadynessElement ProjectWorkAmountElement -0.1 \r
+ _ : SYSDYN.DependencyConnection \r
+ MOD.DiagramConnectionToConnection WMC.d42\r
+ @WM.dependency WorkingSpeedElement WorkAllocationElement -0.1 \r
+ _ : SYSDYN.DependencyConnection\r
+ MOD.DiagramConnectionToConnection WMC.d43\r
+ @WM.dependency WorkingSpeedElement ProjectIsReadyElement -0.1 \r
+ _ : SYSDYN.DependencyConnection\r
+ MOD.DiagramConnectionToConnection WMC.d44\r
+ @WM.dependency ErrorsGeneratedElement WorkingSpeedElement -0.1 \r
+ _ : SYSDYN.DependencyConnection\r
+ MOD.DiagramConnectionToConnection WMC.d45\r
+ @WM.dependency ErrorsGeneratedElement WorkQualityElement -0.1 \r
+ _ : SYSDYN.DependencyConnection\r
+ MOD.DiagramConnectionToConnection WMC.d46\r
+ @WM.dependency ErrorsFoundRateElement ErrorsElement -0.1 \r
+ _ : SYSDYN.DependencyConnection\r
+ MOD.DiagramConnectionToConnection WMC.d47\r
+ @WM.dependency ErrorsFoundRateElement ErrorsFoundTimeElement -0.1 \r
+ _ : SYSDYN.DependencyConnection\r
+ MOD.DiagramConnectionToConnection WMC.d48\r
+ @WM.dependency ErrorsFoundTimeElement ProjectWorkAmountElement -0.1 \r
+ _ : SYSDYN.DependencyConnection\r
+ MOD.DiagramConnectionToConnection WMC.d49\r
+ @WM.dependency ErrorsFoundTimeElement WorkDoneElement -0.1 \r
+ \r
+ _ : SYSDYN.FlowConnection\r
+ MOD.DiagramConnectionToConnection WMC.f31\r
+ @WM.flow WorkingSpeedElement WorkToDoElement \r
+ _ : SYSDYN.FlowConnection\r
+ MOD.DiagramConnectionToConnection WMC.f32\r
+ @WM.flow WorkDoneElement WorkingSpeedElement \r
+ _ : SYSDYN.FlowConnection\r
+ MOD.DiagramConnectionToConnection WMC.f33\r
+ @WM.flow ErrorsGeneratedElement c31Element \r
+ _ : SYSDYN.FlowConnection\r
+ MOD.DiagramConnectionToConnection WMC.f34\r
+ @WM.flow ErrorsElement ErrorsGeneratedElement \r
+ _ : SYSDYN.FlowConnection\r
+ MOD.DiagramConnectionToConnection WMC.f35\r
+ @WM.flow ErrorsFoundRateElement ErrorsElement \r
+ _ : SYSDYN.FlowConnection\r
+ MOD.DiagramConnectionToConnection WMC.f36\r
+ @WM.flow ErrorsFoundRateElement WorkDoneElement \r
+ _ : SYSDYN.FlowConnection\r
+ MOD.DiagramConnectionToConnection WMC.f37\r
+ @WM.flow WorkToDoElement ErrorsFoundRateElement \r
+ _ : SYSDYN.FlowConnection\r
+ MOD.DiagramConnectionToConnection WMC.f40\r
+ @WM.flow ProjectIsReadyElement ProjectReadynessElement \r
+ _ : SYSDYN.FlowConnection\r
+ MOD.DiagramConnectionToConnection WMC.f41\r
+ @WM.flow ProjectReadynessElement c33Element \r
+ \r
+ \r
+WM.WorkModel.WorkforceModule <T SYSDYN.Module\r
+ STR.IsDefinedBy WM.WorkModel.WorkforceModuleConfiguration\r
+\r
+WFC = WM.WorkModel.WorkforceModuleConfiguration : SYSDYN.Configuration\r
+// Parameters\r
+WFC.TimeToAllocateResources : SYSDYN.Auxiliary\r
+ @L0.tag MOD.Mapped\r
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions\r
+ @L0.list\r
+ _ : SYSDYN.ParameterExpression\r
+ SYSDYN.HasEquation "2" \r
+WFC.Productivity : SYSDYN.Auxiliary\r
+ @L0.tag MOD.Mapped \r
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions\r
+ @L0.list\r
+ _ : SYSDYN.ParameterExpression\r
+ SYSDYN.HasEquation "1" \r
+ \r
+// SYSDYN.Valve\r
+WFC.NetResources : SYSDYN.Valve\r
+ @L0.tag MOD.Mapped\r
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions\r
+ @L0.list\r
+ _ : SYSDYN.NormalExpression\r
+ SYSDYN.HasEquation "(WorkForceRequired-WorkforceStock)/TimeToAllocateResources" \r
+\r
+// Stock\r
+WFC.WorkforceStock : SYSDYN.Stock\r
+ @L0.tag MOD.Mapped\r
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions\r
+ @L0.list\r
+ _ : SYSDYN.StockExpression\r
+ SYSDYN.HasInitialEquation "0" \r
+ \r
+// Auxiliaries \r
+WFC.WorkForceRequired : SYSDYN.Auxiliary\r
+ @L0.tag MOD.Mapped\r
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions\r
+ @L0.list\r
+ _ : SYSDYN.NormalExpression\r
+ SYSDYN.HasEquation "RequiredWorkingSpeedInput/Productivity" \r
+WFC.PossibleWorkingSpeed : SYSDYN.Auxiliary\r
+ @L0.tag MOD.Mapped\r
+ @L0.tag SYSDYN.IsOutput\r
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions\r
+ @L0.list\r
+ _ : SYSDYN.NormalExpression\r
+ SYSDYN.HasEquation "WorkforceStock*Productivity" \r
+ \r
+// Inputs\r
+WFC.RequiredWorkingSpeedInput : SYSDYN.Input\r
+ @L0.tag MOD.Mapped \r
+ \r
+WFC.c21 : SYSDYN.Cloud\r
+ \r
+WFC.d21 : SYSDYN.Dependency\r
+ @WM.conf_dependency WFC.NetResources WFC.TimeToAllocateResources \r
+WFC.d22 : SYSDYN.Dependency\r
+ @WM.conf_dependency WFC.NetResources WFC.WorkforceStock \r
+WFC.d23 : SYSDYN.Dependency\r
+ @WM.conf_dependency WFC.NetResources WFC.WorkForceRequired \r
+WFC.d24 : SYSDYN.Dependency\r
+ @WM.conf_dependency WFC.WorkForceRequired WFC.Productivity \r
+WFC.d25 : SYSDYN.Dependency\r
+ @WM.conf_dependency WFC.WorkForceRequired WFC.RequiredWorkingSpeedInput \r
+WFC.d26 : SYSDYN.Dependency\r
+ @WM.conf_dependency WFC.PossibleWorkingSpeed WFC.WorkforceStock \r
+WFC.d27 : SYSDYN.Dependency\r
+ @WM.conf_dependency WFC.PossibleWorkingSpeed WFC.Productivity\r
+WFC.f21 : SYSDYN.Flow\r
+ @WM.conf_dependency WFC.WorkforceStock WFC.NetResources \r
+WFC.f22 : SYSDYN.Flow\r
+ @WM.conf_dependency WFC.NetResources WFC.c21 \r
+ \r
+WorkforceModuleConfigurationDiagram : SYSDYN.ConfigurationDiagram <R L0.HasNext\r
+ MOD.DiagramToComposite WFC\r
+ DIA.HasLayer WM.Admin \r
+/*\r
+ DIA.HasLayer _ : DIA.Layer\r
+// DIA.IsActive true\r
+ DIA.HasFocusableTag TAGS.AdminIsFocusable\r
+ DIA.HasVisibleTag TAGS.AdminIsVisible\r
+*/\r
+ L0.HasTrigger _ : SYSDYN.DiagramToCompositeMapping\r
+ \r
+ @L0.list\r
+ TimeToAllocateResourcesElement : SYSDYN.AuxiliarySymbol\r
+ MOD.ElementToComponent WFC.TimeToAllocateResources\r
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, 45.0, 75.0] : G2D.Transform \r
+ ProductivityElement : SYSDYN.AuxiliarySymbol\r
+ MOD.ElementToComponent WFC.Productivity\r
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, 120.0, 115.0] : G2D.Transform\r
+ NetResourcesElement : SYSDYN.ValveSymbol\r
+ MOD.ElementToComponent WFC.NetResources\r
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, 60.0, 84.0] : G2D.Transform \r
+ WorkforceStockElement : SYSDYN.StockSymbol\r
+ MOD.ElementToComponent WFC.WorkforceStock\r
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, 93.0, 84.0] : G2D.Transform \r
+ WorkForceRequiredElement : SYSDYN.AuxiliarySymbol\r
+ MOD.ElementToComponent WFC.WorkForceRequired\r
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, 82.0, 117.0] : G2D.Transform\r
+ PossibleWorkingSpeedElement : SYSDYN.AuxiliarySymbol\r
+ MOD.ElementToComponent WFC.PossibleWorkingSpeed\r
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, 115.0, 102.0] : G2D.Transform \r
+ RequiredWorkingSpeedInputElement : SYSDYN.InputSymbol\r
+ MOD.ElementToComponent WFC.RequiredWorkingSpeedInput\r
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, 45.0, 127.0] : G2D.Transform \r
+ c21Element : SYSDYN.CloudSymbol\r
+ MOD.ElementToComponent WFC.c21\r
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, 45.0, 85.0] : G2D.Transform \r
+ _ : SYSDYN.DependencyConnection\r
+ MOD.DiagramConnectionToConnection WFC.d21\r
+ @WM.dependency NetResourcesElement TimeToAllocateResourcesElement -0.1\r
+ _ : SYSDYN.DependencyConnection\r
+ MOD.DiagramConnectionToConnection WFC.d22\r
+ @WM.dependency NetResourcesElement WorkforceStockElement -0.1\r
+ _ : SYSDYN.DependencyConnection\r
+ MOD.DiagramConnectionToConnection WFC.d23\r
+ @WM.dependency NetResourcesElement WorkForceRequiredElement -0.1\r
+ _ : SYSDYN.DependencyConnection\r
+ MOD.DiagramConnectionToConnection WFC.d24\r
+ @WM.dependency WorkForceRequiredElement ProductivityElement -0.1\r
+ _ : SYSDYN.DependencyConnection\r
+ MOD.DiagramConnectionToConnection WFC.d25\r
+ @WM.dependency WorkForceRequiredElement RequiredWorkingSpeedInputElement -0.1\r
+ _ : SYSDYN.DependencyConnection\r
+ MOD.DiagramConnectionToConnection WFC.d26\r
+ @WM.dependency PossibleWorkingSpeedElement WorkforceStockElement -0.1\r
+ _ : SYSDYN.DependencyConnection\r
+ MOD.DiagramConnectionToConnection WFC.d27\r
+ @WM.dependency PossibleWorkingSpeedElement ProductivityElement -0.1 \r
+ _ : SYSDYN.FlowConnection\r
+ MOD.DiagramConnectionToConnection WFC.f21\r
+ @WM.flow WorkforceStockElement NetResourcesElement \r
+ _ : SYSDYN.FlowConnection\r
+ MOD.DiagramConnectionToConnection WFC.f22\r
+ @WM.flow c21Element NetResourcesElement \r
--- /dev/null
+#!/usr/bin/perl
+#
+# Script for converting Vensim .mdl files into Simantics .pgraph files
+#
+
+use strict;
+use warnings;
+use Data::Dumper;
+
+die("Usage:\n\tparser.pl [filetoparse] [targetfile]") if($#ARGV < 1);
+
+sub trim($) {
+ my $string = shift;
+ $string =~ s/^\s+//;
+ $string =~ s/\s+$//;
+ return $string;
+}
+
+# Equation parser
+# See http://www.perlmonks.org/?node_id=678119
+
+my @token_def = (
+ [Whitespace => qr{\s+}, 1],
+ [Comment => qr{#.*\n?$}m, 1],
+ [AddOp => qr{[+-]} ],
+ [MulOp => qr{[*/]} ],
+ [Number => qr{(\d\.)+} ],
+ [Equals => qr{=} ],
+ [Lt => qr{<} ],
+ [Gt => qr{>} ],
+ [OpenParen => qr{\(} ],
+ [CloseParen => qr{\)} ],
+ [Comma => qr{,} ],
+ [If => qr{IFTHENELSE} ],
+ [Xls => qr{GETXLSCONSTANTS} ],
+ [XlsData => qr{GETXLSDATA} ],
+ [TimeShift => qr{TIMESHIFT} ],
+ [VectorMap => qr{VECTORELMMAP} ],
+ [Sum => qr{SUM} ],
+ [Integ => qr{INTEG} ],
+ [Str => qr{'[^']+'} ],
+ [Array => qr{[0-9\w]+\[[^\]]+\]} ],
+ [Variable => qr{[0-9\w]+} ],
+);
+
+sub parseEquation($) {
+ my $input = shift;
+ my @tokens;
+ pos($input) = 0;
+
+ while(pos($input) < length $input){
+ my $matched = 0;
+ for my $t (@token_def){
+ my ($name, $re, $ignore_flag) = @$t;
+ if ($input =~ m/\G($re)/gc){
+ $matched = 1;
+ next if $ignore_flag;
+ push @tokens, [$name, $1];
+ next;
+ }
+ }
+ unless($matched) {
+ print "Syntax error at position " . pos($input).": $input\n";
+ return;
+ }
+ }
+ return token2str(\@tokens);
+}
+
+sub match {
+ my $tokens = shift;
+ my $expected_token = shift;
+ if ($tokens->[0][0] eq $expected_token){
+ my $current = shift @$tokens;
+ return $current->[1];
+ } else {
+ print "Syntax error: expected $expected_token, got $tokens->[0][0]\n";
+ }
+}
+
+sub lookahead {
+ my $tokens = shift;
+ my @expected = @_;
+ no warnings 'uninitialized';
+ for (0 .. $#expected){
+ return 0 if $tokens->[$_][0] ne $expected[$_];
+ }
+ return 1;
+}
+
+#
+# Parse vensim equations and convert to modelica equations
+# NOTE: This is not a bullet proof solution, but does parse correctly formed Vensim equations
+# FIXME: Find corresponding modelica version for the functions that are currently not transformed
+#
+sub token2str {
+ my $tokens = shift;
+ my $rval = "";
+
+ if (lookahead($tokens, 'Integ')){
+ # Stock.
+ match($tokens, 'Integ');
+ match($tokens, 'OpenParen');
+ my $a = token2str($tokens);
+ match($tokens, 'Comma');
+ my $b = token2str($tokens);
+ match($tokens, 'CloseParen');
+# $rval = "INTEG($a, $b)"; # Integ function will be replaced with stock component, and it has only initial value ?
+ $rval = $b; # FIXME!
+ } elsif (lookahead($tokens, 'If')){
+ match($tokens, 'If');
+ match($tokens, 'OpenParen');
+ my $check = token2str($tokens);
+ match($tokens, 'Comma');
+ my $then = token2str($tokens);
+ match($tokens, 'Comma');
+ my $else = "";
+ if (lookahead($tokens, 'If')){
+ match($tokens, 'If');
+ match($tokens, 'OpenParen');
+ my $subcheck = token2str($tokens);
+ match($tokens, 'Comma');
+ my $subthen = token2str($tokens);
+ match($tokens, 'Comma');
+ my $subelse = token2str($tokens); # TODO doesn't support elseif yet..
+ match($tokens, 'CloseParen');
+ $else = "elseif $subcheck then $subthen else $subelse";
+ } else {
+ $else = "else ".token2str($tokens)."";
+ }
+ match($tokens, 'CloseParen');
+ $rval = "if $check then $then ".$else.""; # Apparently, end if is not used inside equations..
+ } elsif (lookahead($tokens, 'Xls')){
+ match($tokens, 'Xls');
+ match($tokens, 'OpenParen');
+ my $a = match($tokens, 'Str');
+ match($tokens, 'Comma');
+ my $b = match($tokens, 'Str');
+ match($tokens, 'Comma');
+ my $c = match($tokens, 'Str');
+ match($tokens, 'CloseParen');
+ $rval = "XLS_CONSTANT($a, $b, $c)";
+ } elsif (lookahead($tokens, 'XlsData')){
+ match($tokens, 'XlsData');
+ match($tokens, 'OpenParen');
+ my $a = match($tokens, 'Str');
+ match($tokens, 'Comma');
+ my $b = match($tokens, 'Str');
+ match($tokens, 'Comma');
+ my $c = match($tokens, 'Str');
+ match($tokens, 'Comma');
+ my $d = match($tokens, 'Str');
+ match($tokens, 'CloseParen');
+ $rval = "XLS_DATA($a, $b, $c, $d)";
+ } elsif (lookahead($tokens, 'VectorMap')){
+ match($tokens, 'VectorMap');
+ match($tokens, 'OpenParen');
+ my $a = token2str($tokens); # Should be a variable, but we can use token2str to parse it anyway
+ match($tokens, 'Comma');
+ my $b = token2str($tokens); # Should be a number, but we can use token2str to parse it anyway
+ match($tokens, 'CloseParen');
+ $rval = "VECTOR_MAP($a, $b)"; #
+ } elsif (lookahead($tokens, 'TimeShift')){
+ match($tokens, 'TimeShift');
+ match($tokens, 'OpenParen');
+ my $var = token2str($tokens); # Should be a variable, but we can use token2str to parse it anyway
+ match($tokens, 'Comma');
+ my $num = token2str($tokens); # Should be a number, but we can use token2str to parse it anyway
+ match($tokens, 'CloseParen');
+ $rval = "delay($var, $num)"; # FIXME: Not sure if this is correct..
+ } elsif (lookahead($tokens, 'Sum')){
+ match($tokens, 'Sum');
+ match($tokens, 'OpenParen');
+ my $var = token2str($tokens); # Should be a variable, but we can use token2str to parse it anyway
+ match($tokens, 'CloseParen');
+ $rval = "sum($var)";
+ } elsif (lookahead($tokens, 'Array')){
+ my $var = match($tokens, 'Array');
+ $rval = $var;
+ } elsif (lookahead($tokens, 'Variable')){
+ my $var = match($tokens, 'Variable');
+ $rval = $var;
+ } elsif (lookahead($tokens, 'AddOp')){
+ my $op = match($tokens, 'AddOp');
+ $rval = $op;
+ } elsif (lookahead($tokens, 'MulOp')){
+ my $op = match($tokens, 'MulOp');
+ $rval = $op;
+ } elsif (lookahead($tokens, 'Number')){
+ my $n = match($tokens, 'Number');
+ $rval = $n;
+ } elsif (lookahead($tokens, 'Equals')){
+ my $n = match($tokens, 'Equals');
+ $rval = $n.$n; # In modelica we must use two times = (This should be used only in if statements..)
+ } elsif (lookahead($tokens, 'Lt')){
+ my $n = match($tokens, 'Lt');
+ $rval = $n;
+ } elsif (lookahead($tokens, 'Gt')){
+ my $n = match($tokens, 'Gt');
+ $rval = $n;
+ } elsif (lookahead($tokens, 'OpenParen')){
+ match($tokens, 'OpenParen');
+ my $inner = token2str($tokens);
+ match($tokens, 'CloseParen');
+ $rval = "($inner)";
+ } else {
+ return "";
+ }
+ my $next = token2str($tokens);
+ return $rval.$next;
+}
+
+# And finally the actual program
+
+my $sourcefile = $ARGV[0];
+my $targetfile = $ARGV[1];
+
+open(DAT, $sourcefile) || die("Could not open source file for reading!");
+my @raw_data=<DAT>;
+close(DAT);
+
+my $elements = {};
+
+# 1. Parse equations
+
+my $text = join("\n", @raw_data);
+while($text =~ m/(.*)(:=|=|:)([^~]*)~([^~]*)~([^\|]*)/mg) {
+ my $var = trim($1);
+ my $op = $2;
+ my $equation = trim($3);
+ my $unit = trim($4);
+ my $comment = trim($5); # May include also "~ :SUPPLEMENTARY"
+
+ $var =~ s/\[.*//g; # Remove the array part from the end ( foo[bar] => foo )
+
+ $equation =~ s/[\n\s\\]//g; # Remove white spaces, line breaks and backslashes (backslash seems to be used to break equation into two lines).
+ my $type = "";
+ # FIXME: No idea what is the exact difference of these:
+# if($op =~ m/^:=$/) {
+# $type = "VARIABLE";
+# } elsif($op =~ m/^:$/) {
+# $type = "CONSTANT";
+# } else {
+# $type = "EQUATION";
+# }
+ $type = "auxiliary";
+ if($equation =~ m/^\s*INTEG\(/) { # If equation is integral, the element type is stock.
+ $type = "stock";
+ }
+ # TODO: is there any way to detect valve?
+
+ # Convert equation to modelica format
+ my $modelica_equation = parseEquation($equation);
+ if($modelica_equation =~ m/^\+if/) { # FIXME: Not sure why "+ IF THEN ELSE" is used in Vensim..
+ $modelica_equation =~ s/^\+//g;
+ }
+ $modelica_equation =~ s/\+-/-/g; # For some reason there is +- ... which means same as -
+ if($elements->{$var}) {
+ push(@{$elements->{$var}->{'equations'}}, $modelica_equation);
+ } else {
+ my @eq = ($modelica_equation);
+ $elements->{$var} = {name => $var,
+ type => $type,
+ equations => \@eq,
+ unit => $unit,
+ comment => $comment};
+ }
+}
+
+my $diagrams = {};
+my $connections = {};
+my $ghost_symbols = {};
+my $types = {};
+
+# 2. Parse diagram layout
+# i.e., the part after this:
+# \\\---/// Sketch information - do not modify anything except names
+# V300 Do not put anything below this section - it will be ignored
+#
+
+my $diagram;
+foreach my $row (@raw_data) {
+ # Lines starting with * indicates new diagram configuration..
+ if($row =~ m/^\*\w/) {
+ $diagram = trim($row);
+ $diagram =~ s/^(\*)//;
+ }
+ if($diagram) {
+ if($row =~ m/^1\d*,/) {
+ my @data = split(/,/, $row);
+ my $type = $data[0];
+ my $id = $data[1];
+ if($type == 1) {
+ # Connection
+ # 1,6,1,5,1,0,0,0,0,64,0,-1--1--1,,1|(729,352)|
+ # 1,546,138,3,0,0,0,0,0,64,1,-1--1--1,,1|(-1642,-250)| <- this connection is not visible in vensim?
+ # Flow
+ # 1,33,35,8,4,0,0,22,0,0,0,-1--1--1,,1|(456,528)|
+
+ my $target = $data[2];
+ my $source = $data[3];
+ my $foo = $data[4]; # If this is 100, the flow direction must be changed (Yeah, wtf?)
+ my $t = $data[9] == 64 ? "dependency" : "flow";
+ my $hidden = $data[10] == 1 ? 1 : 0; # TODO: Not sure if this is correct
+ if($t eq "flow" && $foo == 100) {
+ my $tmp = $target;
+ $target = $source;
+ $source = $tmp;
+ }
+
+ $connections->{$diagram} = {} unless($connections->{$diagram});
+ $connections->{$diagram}->{$id} = {source => $source, target => $target, type => $t, hidden => $hidden};
+ } elsif($type == 10) {
+ # Element
+ # 10,1,TotalPopulation,417,269,47,65,3,131,0,0,0,0,0,0 <- not sure, might be stock (but actually is auxiliary9
+ # 10,11,TotalPopulationT1,417,610,47,65,3,131,0,0,0,0,0,0 <- what is this?
+ # 10,274,LungCsIVNoD,-1050,1269,40,20,3,3,0,0,0,0,0,0 <- level aka stock?
+ # 10,2,LungCs01,-1109,-650,79,18,3,131,0,0,0,0,0,0 <- stock
+ # 10,786,LungCSmokersPercentageOfPopulation,-700,-835,147,21,8,131,0,0,0,0,0,0 <- input?
+ # 10,63,LungCProgress0102Rate,-1248,-541,91,9,8,3,0,0,0,0,0,0 <- aux ?
+ # 10,125,LungCModelPopCorrectionRate,1582,65,105,9,8,3,0,0,0,0,0,0 <- constant (FIXME: seems to be identical with aux)
+ # 10,152,LungCTreated1PopCorr,287,269,102,9,40,3,1,0,-1,0,0,0 <- valve
+
+ my $name = $data[2];
+ my $x = $data[3];
+ my $y = $data[4];
+ my $width = $data[5];
+ my $height = $data[6];
+ my $foo = $data[7];
+ my $bar = $data[8]; # 131 for stock, 3 for aux
+ my $t = "unknown"; #$data[11] == -1 ? "valve" : "stock"; # -1 for valve, 0 for stock ?
+ my $ghost = 0;
+ if($#data > 15) { # Ghost symbols contains more parameters..
+ # 10,505,LungCs01Diagnosis, -808,-633, 64,9,40,3,0,0,-1,0,0,0
+ # 10,590,LungCs01Diagnosis, 2614,1033, 73,9,8, 2,0,3,-1,0,0,0,128-128-128,0-0-0,|12||128-128-128
+ $ghost = 1;
+ }
+
+ if($foo == 3 && $bar == 3) {
+ $t = "stock";
+ } elsif($foo == 3 && $bar == 131) {
+ $t = "auxiliary"; # FIXME:
+ } elsif($foo == 8 && $bar == 131) {
+ $t = "auxiliary";
+ } elsif($foo == 40 && $bar == 3) {
+ $t = "valve";
+ } elsif($bar == 3) {
+ $t = "auxiliary";
+ } else {
+ $t = "valve";
+ }
+ if(!$ghost) {
+ $types->{$name} = $t;
+ }
+
+ $diagrams->{$diagram} = {} unless($diagrams->{$diagram});
+ $diagrams->{$diagram}->{$id} = {
+ id => $id,
+ name => $name,
+ x => $x,
+ y => $y,
+ width => $width,
+ height => $height,
+ type => $t,
+ ghost => $ghost
+ };
+ if($t eq "valve" && $ghost_symbols->{$id}) {
+ $diagrams->{$diagram}->{($ghost_symbols->{$id})} = $diagrams->{$diagram}->{$id};
+ }
+ } elsif($type == 11) {
+ # Valve
+ # 11,48,48,-1348,-887,6,8,34,3,0,0,1,0,0,0
+ my $x = $data[3];
+ my $y = $data[4];
+
+ # This data is very much related to the valve symbol on the next line ..
+ $ghost_symbols->{$id+1} = $id;
+ } elsif($type == 12) {
+ # Textbox (can be ignored, the string is on the next line)
+ # 12,2,0,430,56,114,34,8,132,0,0,-1,0,0,0
+ # Cloud
+ # 12,45,48,-1553,-888,10,8,0,3,0,0,-1,0,0,0
+
+ my $x = $data[3];
+ my $y = $data[4];
+ my $foo = $data[7];
+ my $bar = $data[8]; # 132 for textbox, 3 for cloud
+ if($bar == 3) {
+ $diagrams->{$diagram} = {} unless($diagrams->{$diagram});
+ $diagrams->{$diagram}->{$id} = {
+ id => $id,
+ name => "Cloud".$id, # Cloud does not have name, but we can generate one
+ x => $x,
+ y => $y,
+ type => 'cloud',
+ ghost => 0};
+ $types->{"Cloud".$id} = 'cloud';
+ }
+ }
+ } else {
+ # Comment or something...
+ }
+ }
+}
+
+# 3. Generate .pgraph file
+my $generated_elements = {};
+my $generated_symbols = {};
+
+# Create combined configuration
+my $output = "";
+foreach my $key (keys (%$diagrams)) {
+ my $d = $key;
+ $d =~ s/\s+//g;
+ my $WC = "CMC";
+
+ my $tmp = $diagrams->{$key};
+ foreach my $id (keys (%$tmp)) {
+ my $n = $tmp->{$id}->{'name'};
+ if($tmp->{$id}->{'ghost'} == 1) { # Ghost does not contain correct element type
+ next;
+ }
+ my $type = $tmp->{$id}->{'type'};
+ no warnings 'uninitialized';
+ $type = "stock" if($elements->{$n}->{'type'} eq "stock");
+
+ if($type eq "cloud") {
+ # Cloud is not a real element, thus it is not present in elements array..
+ $output .= $WC.".".$tmp->{$id}->{'name'}." : SYSDYN.Cloud\n";
+ $output .= "\n";
+ } elsif($elements->{$n} && $elements->{$n}->{'name'} && !$generated_elements->{$elements->{$n}->{'name'}}) {
+ if($type eq "valve") {
+ $output .= $WC.".".$elements->{$n}->{'name'}." : SYSDYN.Valve\n";
+ $output .= " \@L0.tag MOD.Mapped\n";
+ $output .= " SYSDYN.HasExpressions _ : SYSDYN.Expressions\n";
+ $output .= " \@L0.list\n";
+ my $equations = $elements->{$n}->{'equations'};
+ foreach my $equation (@$equations) {
+ $output .= " _ : SYSDYN.NormalExpression\n";
+ $output .= " SYSDYN.HasEquation \"".$equation."\" \n";
+ }
+ } elsif($type eq "stock") {
+ $output .= $WC.".".$elements->{$n}->{'name'}." : SYSDYN.Stock\n";
+ $output .= " \@L0.tag MOD.Mapped\n";
+ $output .= " SYSDYN.HasExpressions _ : SYSDYN.Expressions\n";
+ $output .= " \@L0.list\n";
+ my $equations = $elements->{$n}->{'equations'};
+ foreach my $equation (@$equations) {
+ $output .= " _ : SYSDYN.StockExpression\n";
+ $output .= " SYSDYN.HasInitialEquation \"".$equation."\" \n";
+ }
+ $output .= "\n";
+ } elsif($type eq "auxiliary") {
+ $output .= $WC.".".$elements->{$n}->{'name'}." : SYSDYN.Auxiliary\n";
+ $output .= " \@L0.tag MOD.Mapped\n";
+ $output .= " SYSDYN.HasExpressions _ : SYSDYN.Expressions\n";
+ $output .= " \@L0.list\n";
+ my $equations = $elements->{$n}->{'equations'};
+ foreach my $equation (@$equations) {
+ $output .= " _ : SYSDYN.NormalExpression\n";
+ $output .= " SYSDYN.HasEquation \"".$equation."\" \n";
+ }
+ $output .= "\n";
+ } else {
+ print("Unknown element type: $type\n");
+ }
+ }
+ $generated_elements->{$elements->{$n}->{'name'}} = 1;
+ }
+
+ my $c = $connections->{$key};
+ foreach my $id (keys (%$c)) {
+ my $source = $tmp->{$c->{$id}->{'source'}}->{'name'};
+ my $target = $tmp->{$c->{$id}->{'target'}}->{'name'};
+ if($source && $target) {
+ if($c->{$id}->{'type'} eq "flow") {
+ $output .= $WC.".f".$id." : SYSDYN.Flow\n";
+ $output .= " \@WM.conf_dependency ".$WC.".".$source." ".$WC.".".$target."\n";
+ } elsif($c->{$id}->{'type'} eq "dependency") {
+ $output .= $WC.".d".$id." : SYSDYN.Dependency\n";
+ $output .= " \@WM.conf_dependency ".$WC.".".$source." ".$WC.".".$target."\n";
+ } else {
+ print("Unknown connection type ".$c->{$id}->{'type'}."\n");
+ }
+ } else {
+ print("WARNING: ");
+ print("No source element for connection #".$c->{$id}->{'source'}." -> $target\n") if($target);
+ print("No target element for connection $source -> #".$c->{$id}->{'target'}."\n") if($source);
+ }
+ }
+ $output .= "\n";
+}
+
+# Create combined diagram
+my $max_x = 0; # FIXME: Assumes that there are positive locations..
+foreach my $key (keys (%$diagrams)) {
+ my $d = $key;
+ $d =~ s/\s+//g;
+
+ my $WC = "CMC";
+ my $tmp = $diagrams->{$key};
+ unless($key eq "Population") {
+ $output .= $d."ConfigurationDiagram : SYSDYN.ConfigurationDiagram <R L0.HasNext\n";
+ $output .= " MOD.DiagramToComposite ".$WC."\n";
+ $output .= " DIA.HasLayer WM.Admin : DIA.Layer\n";
+ $output .= " DIA.IsActive true\n";
+ $output .= " DIA.HasFocusableTag TAGS.AdminIsFocusable <R DIA.IsFocusable\n";
+ $output .= " \@L0.symmetric\n";
+ $output .= " DIA.HasVisibleTag TAGS.AdminIsVisible <R DIA.IsVisible\n";
+ $output .= " \@L0.symmetric\n";
+ $output .= " L0.HasTrigger _ : SYSDYN.DiagramToCompositeMapping\n";
+ $output .= " \@L0.list\n";
+ }
+ my $offset_x = $max_x;
+ no warnings 'uninitialized';
+ foreach my $id (keys (%$tmp)) {
+ my $n = $tmp->{$id}->{'name'};
+ my $suffix = "Element".$tmp->{$id}->{'id'}; # id field in hash might be different than $id (see parsing of type 11 and type 10 elements)
+
+ if(!$generated_symbols->{$n.$suffix}) {
+ my $x = sprintf("%.1f", $tmp->{$id}->{'x'} / 5 + $offset_x); # Scale
+ my $y = sprintf("%.1f", $tmp->{$id}->{'y'} / 5); # Scale
+ $max_x = $x if(($tmp->{$id}->{'x'} / 5 + $offset_x) > $max_x) ;
+ my $type = $types->{$n}; # Type lookup contains correct type (ghosts does not..)
+ $type = "stock" if($elements->{$n}->{'type'} eq "stock");
+
+ if($type eq "stock") {
+ $output .= " ".$n.$suffix." : SYSDYN.StockSymbol\n";
+ $output .= " MOD.ElementToComponent ".$WC.".$n\n";
+ $output .= " DIA.HasTransform [1.0, 0.0, 0.0, 1.0, ".$x.", ".$y."] : G2D.Transform\n";
+ } elsif($type eq "auxiliary") {
+ $output .= " ".$n.$suffix." : SYSDYN.AuxiliarySymbol\n";
+ $output .= " MOD.ElementToComponent ".$WC.".$n\n";
+ $output .= " DIA.HasTransform [1.0, 0.0, 0.0, 1.0, ".$x.", ".$y."] : G2D.Transform\n";
+ } elsif($type eq "valve") {
+ $output .= " ".$n.$suffix." : SYSDYN.ValveSymbol\n";
+ $output .= " MOD.ElementToComponent ".$WC.".$n\n";
+ $output .= " DIA.HasTransform [1.0, 0.0, 0.0, 1.0, ".$x.", ".$y."] : G2D.Transform\n";
+ } elsif($type eq "input") {
+ $output .= " ".$n.$suffix." : SYSDYN.InputSymbol\n";
+ $output .= " MOD.ElementToComponent ".$WC.".$n\n";
+ $output .= " DIA.HasTransform [1.0, 0.0, 0.0, 1.0, ".$x.", ".$y."] : G2D.Transform\n";
+ } elsif($type eq "cloud") {
+ $output .= " ".$n.$suffix." : SYSDYN.CloudSymbol\n";
+ $output .= " MOD.ElementToComponent ".$WC.".$n\n";
+ $output .= " DIA.HasTransform [1.0, 0.0, 0.0, 1.0, ".$x.", ".$y."] : G2D.Transform\n";
+ } else {
+ print("Unknown element type $type\n");
+ }
+ }
+ $generated_symbols->{$n.$suffix} = 1;
+ }
+
+ my $c = $connections->{$key};
+ foreach my $id (keys (%$c)) {
+ my $source = $tmp->{$c->{$id}->{'source'}}->{'name'};
+ my $target = $tmp->{$c->{$id}->{'target'}}->{'name'};
+ if($source && $target) {
+ my $source_suffix = "Element".$tmp->{$c->{$id}->{'source'}}->{'id'};
+ my $target_suffix = "Element".$tmp->{$c->{$id}->{'target'}}->{'id'};
+
+ if($c->{$id}->{'hidden'} == 0) {
+ if($c->{$id}->{'type'} eq "flow") {
+ $output .= " _ : SYSDYN.FlowConnection\n";
+ $output .= " MOD.DiagramConnectionToConnection ".$WC.".f".$id."\n";
+ $output .= " \@WM.flow ".$source.$source_suffix." ".$target.$target_suffix."\n";
+ } elsif($c->{$id}->{'type'} eq "dependency") {
+ $output .= " _ : SYSDYN.DependencyConnection\n";
+ $output .= " MOD.DiagramConnectionToConnection ".$WC.".d".$id."\n";
+ $output .= " \@WM.dependency ".$source.$source_suffix." ".$target.$target_suffix." -0.1\n";
+ } else {
+ print("Unknown element type ".$c->{$id}->{'type'}."\n");
+ }
+ }
+ }
+ }
+ $output .= "\n";
+}
+
+my $header = <<END;
+L0 = <http://www.simantics.org/Layer0-1.0>
+G2D = <http://www.simantics.org/G2D-1.0>
+STR = <http://www.simantics.org/Structural-1.0>
+DIA = <http://www.simantics.org/Diagram-2.0>
+SIMU = <http://www.simantics.org/Simulation-1.0>
+MOD = <http://www.simantics.org/Modeling-1.0>
+SYSDYN = <http://www.simantics.org/Sysdyn-1.0>
+PROJ = <http://www.simantics.org/Project-1.0>
+
+//######################################################################
+//# Example work model with two modules
+//######################################################################
+
+WM = <http://www.simantics.org/Sysdyn-1.0/DevelopmentProject> : PROJ.Project
+ PROJ.HasFeature _ : PROJ.FeatureSpec
+ PROJ.HasGroupId "org.simantics.sysdyn.feature.group"
+ L0.PartOf <http://Projects>
+
+TAGS = WM.Tags : L0.Library
+
+WM.dependency : L0.Template
+ \@template %type %head %tail %angle
+ %type
+ \@L0.tag TAGS.AdminIsVisible
+ \@L0.tag TAGS.AdminIsFocusable
+ STR.HasConnectionType SYSDYN.SysdynConnectionType
+ SYSDYN.angle %angle
+ DIA.HasArrowConnector _ : DIA.Connector
+ SYSDYN.HasHeadTerminal %head
+ DIA.AreConnected _ : DIA.Connector
+ SYSDYN.HasTailTerminal %tail
+ DIA.IsPlainConnectorOf %type
+
+WM.flow : L0.Template
+ \@template %type %head %tail
+ %type
+ \@L0.tag TAGS.AdminIsVisible
+ \@L0.tag TAGS.AdminIsFocusable
+ STR.HasConnectionType SYSDYN.SysdynConnectionType
+ DIA.HasArrowConnector _ : DIA.Connector
+ SYSDYN.HasHeadTerminal %head
+ DIA.AreConnected _ : DIA.Connector
+ SYSDYN.HasTailTerminal %tail
+ DIA.IsPlainConnectorOf %type
+
+WM.conf_dependency : L0.Template
+ \@template %type %head %tail
+ %type
+ \@L0.tag MOD.Mapped
+ SYSDYN.HasHead %head
+ SYSDYN.HasTail %tail
+
+WM.conf_dependency_ref : L0.Template
+ \@template %type %head %tail %ref
+ %type
+ \@L0.tag MOD.Mapped
+ SYSDYN.HasHead %head
+ SYSDYN.HasTail %tail
+ SYSDYN.RefersTo %ref
+
+WM.CancerModel : SYSDYN.SysdynModel
+ L0.HasLabel "Cancer Model"
+ SIMU.HasConfiguration CMC
+ SYSDYN.HasStartTime 0.0
+ SYSDYN.HasStopTime 24.0
+
+WM.CancerModel.Experiment : SYSDYN.Experiment
+ L0.HasLabel "Experiment"
+
+CMC = WM.CancerModel.CancerModelConfiguration : SYSDYN.Configuration
+ L0.HasLabel "CancerModelConfiguration"
+
+END
+
+open(OUTPUT, ">$targetfile") || die("Could not open target file for writing!");
+print OUTPUT $header;
+print OUTPUT $output;
+close(OUTPUT);
+
+print("Simantics graph configuration saved successfully to file $targetfile\n");
--- /dev/null
+package org.simantics.sysdyn;\r
+\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.request.Read;\r
+import org.simantics.db.Session;\r
+import org.simantics.db.exception.DatabaseException;\r
+\r
+public class SysdynResource {\r
+ \r
+ public final Resource ArrayIndexes;\r
+ public final Resource ArrayIndexes_Inverse;\r
+ public final Resource Auxiliary;\r
+ public final Resource AuxiliarySymbol;\r
+ public final Resource BasicExperiment;\r
+ public final Resource Built$in_Functions;\r
+ public final Resource Built$in_Functions_Vensim_Functions;\r
+ public final Resource Built$in_Functions_Vensim_Functions_ABS;\r
+ public final Resource Built$in_Functions_Vensim_Functions_COS;\r
+ public final Resource Built$in_Functions_Vensim_Functions_COSH;\r
+ public final Resource Built$in_Functions_Vensim_Functions_EXP;\r
+ public final Resource Built$in_Functions_Vensim_Functions_IFTHENELSE;\r
+ public final Resource Built$in_Functions_Vensim_Functions_LN;\r
+ public final Resource Built$in_Functions_Vensim_Functions_MAX;\r
+ public final Resource Built$in_Functions_Vensim_Functions_MIN;\r
+ public final Resource Built$in_Functions_Vensim_Functions_MODULO;\r
+ public final Resource Built$in_Functions_Vensim_Functions_PULSE;\r
+ public final Resource Built$in_Functions_Vensim_Functions_RAMP;\r
+ public final Resource Built$in_Functions_Vensim_Functions_SIN;\r
+ public final Resource Built$in_Functions_Vensim_Functions_SINH;\r
+ public final Resource Built$in_Functions_Vensim_Functions_SQRT;\r
+ public final Resource Built$in_Functions_Vensim_Functions_STEP;\r
+ public final Resource Built$in_Functions_Vensim_Functions_TAN;\r
+ public final Resource Built$in_Functions_Vensim_Functions_TANH;\r
+ public final Resource Built$in_Functions_Vensim_Functions_XIDZ;\r
+ public final Resource Built$in_Functions_Vensim_Functions_ZIDZ;\r
+ public final Resource Built$in_Functions_interpolate;\r
+ public final Resource Built$in_Functions_interpolateFull;\r
+ public final Resource Built$in_Functions_xidz;\r
+ public final Resource Built$in_Functions_zidz;\r
+ public final Resource Cloud;\r
+ public final Resource CloudSymbol;\r
+ public final Resource Configuration;\r
+ public final Resource ConfigurationDiagram;\r
+ public final Resource ConfigurationDiagramTemplate;\r
+ public final Resource ConstantExpression;\r
+ public final Resource DefaultRealization;\r
+ public final Resource DelayExpression;\r
+ public final Resource Dependency;\r
+ public final Resource DependencyConnection;\r
+ public final Resource DiagramToCompositeMapping;\r
+ public final Resource Enumeration;\r
+ public final Resource EnumerationIndex;\r
+ public final Resource EnumerationIndexes;\r
+ public final Resource EnumerationIndexes_Inverse;\r
+ public final Resource Experiment;\r
+ public final Resource Expression;\r
+ public final Resource Expressions;\r
+ public final Resource Expressions_Inverse;\r
+ public final Resource ExternalFunctionFile;\r
+ public final Resource Flow;\r
+ public final Resource FlowConnection;\r
+ public final Resource GameExperiment;\r
+ public final Resource HasActiveExpression;\r
+ public final Resource HasActiveExpression_Inverse;\r
+ public final Resource HasArrayIndexes;\r
+ public final Resource HasArrayIndexes_Inverse;\r
+ public final Resource HasArrayRange;\r
+ public final Resource HasArrayRange_Inverse;\r
+ public final Resource HasDefaultInputValue;\r
+ public final Resource HasDefaultInputValue_Inverse;\r
+ public final Resource HasEnumerationIndexes;\r
+ public final Resource HasEnumerationIndexes_Inverse;\r
+ public final Resource HasEquation;\r
+ public final Resource HasEquation_Inverse;\r
+ public final Resource HasExpressions;\r
+ public final Resource HasExpressions_Inverse;\r
+ public final Resource HasExternalFile;\r
+ public final Resource HasExternalFile_Inverse;\r
+ public final Resource HasHead;\r
+ public final Resource HasHeadTerminal;\r
+ public final Resource HasInitialEquation;\r
+ public final Resource HasInitialEquation_Inverse;\r
+ public final Resource HasLookup;\r
+ public final Resource HasLookup_Inverse;\r
+ public final Resource HasMaxX;\r
+ public final Resource HasMaxX_Inverse;\r
+ public final Resource HasMaxY;\r
+ public final Resource HasMaxY_Inverse;\r
+ public final Resource HasMinX;\r
+ public final Resource HasMinX_Inverse;\r
+ public final Resource HasMinY;\r
+ public final Resource HasMinY_Inverse;\r
+ public final Resource HasModelicaFunctionCode;\r
+ public final Resource HasModelicaFunctionCode_Inverse;\r
+ public final Resource HasOutputInterval;\r
+ public final Resource HasOutputInterval_Inverse;\r
+ public final Resource HasParameterFile;\r
+ public final Resource HasParameterFile_Inverse;\r
+ public final Resource HasRangeEnd;\r
+ public final Resource HasRangeEnd_Inverse;\r
+ public final Resource HasRangeStart;\r
+ public final Resource HasRangeStart_Inverse;\r
+ public final Resource HasRangeStep;\r
+ public final Resource HasRangeStep_Inverse;\r
+ public final Resource HasRedeclaration;\r
+ public final Resource HasRedeclaration_Inverse;\r
+ public final Resource HasResult;\r
+ public final Resource HasResultFile;\r
+ public final Resource HasResultFile_Inverse;\r
+ public final Resource HasResult_Inverse;\r
+ public final Resource HasSolver;\r
+ public final Resource HasSolver_Inverse;\r
+ public final Resource HasStartTime;\r
+ public final Resource HasStartTime_Inverse;\r
+ public final Resource HasStopTime;\r
+ public final Resource HasStopTime_Inverse;\r
+ public final Resource HasTail;\r
+ public final Resource HasTailTerminal;\r
+ public final Resource HasTolerance;\r
+ public final Resource HasTolerance_Inverse;\r
+ public final Resource HasUnit;\r
+ public final Resource HasUnit_Inverse;\r
+ public final Resource HistoryRealization;\r
+ public final Resource ImportedOntologies;\r
+ public final Resource IndependentVariable;\r
+ public final Resource Input;\r
+ public final Resource InputSymbol;\r
+ public final Resource IsHeadOf;\r
+ public final Resource IsHeadOfTerminal;\r
+ public final Resource IsOutput;\r
+ public final Resource IsReplaceable;\r
+ public final Resource IsReplaceable_Inverse;\r
+ public final Resource IsTailOf;\r
+ public final Resource IsTailOfTerminal;\r
+ public final Resource LookupExpression;\r
+ public final Resource Module;\r
+ public final Resource ModuleSymbol;\r
+ public final Resource NormalExpression;\r
+ public final Resource ParameterExpression;\r
+ public final Resource Redeclaration;\r
+ public final Resource RefersTo;\r
+ public final Resource ReplacedEnumeration;\r
+ public final Resource ReplacedEnumeration_Inverse;\r
+ public final Resource ReplacingEnumeration;\r
+ public final Resource ReplacingEnumeration_Inverse;\r
+ public final Resource Result;\r
+ public final Resource SharedFunctionOntology;\r
+ public final Resource SharedModuleOntolofgy;\r
+ public final Resource ShowEnumerationIndexInCharts;\r
+ public final Resource ShowEnumerationIndexInCharts_Inverse;\r
+ public final Resource SimulateOnChangeExperiment;\r
+ public final Resource Stock;\r
+ public final Resource StockExpression;\r
+ public final Resource StockSymbol;\r
+ public final Resource SymbolReferences;\r
+ public final Resource SymbolReferences_BasicSymbols;\r
+ public final Resource Symbols;\r
+ public final Resource SysdynConnectionType;\r
+ public final Resource SysdynDiagramModelingRules;\r
+ public final Resource SysdynModel;\r
+ public final Resource SysdynModelicaFunction;\r
+ public final Resource SysdynModelicaFunctionLibrary;\r
+ public final Resource SysdynModuleLibrary;\r
+ public final Resource SysdynTerminal;\r
+ public final Resource Valve;\r
+ public final Resource ValveSymbol;\r
+ public final Resource Variable;\r
+ public final Resource WithLookupExpression;\r
+ public final Resource angle;\r
+ public final Resource angle_Inverse;\r
+ \r
+ public static class URIs {\r
+ public static final String ArrayIndexes = "http://www.simantics.org/Sysdyn-1.0/ArrayIndexes";\r
+ public static final String ArrayIndexes_Inverse = "http://www.simantics.org/Sysdyn-1.0/ArrayIndexes/Inverse";\r
+ public static final String Auxiliary = "http://www.simantics.org/Sysdyn-1.0/Auxiliary";\r
+ public static final String AuxiliarySymbol = "http://www.simantics.org/Sysdyn-1.0/AuxiliarySymbol";\r
+ public static final String BasicExperiment = "http://www.simantics.org/Sysdyn-1.0/BasicExperiment";\r
+ public static final String Built$in_Functions = "http://www.simantics.org/Sysdyn-1.0/Built-in+Functions";\r
+ public static final String Built$in_Functions_Vensim_Functions = "http://www.simantics.org/Sysdyn-1.0/Built-in+Functions/Vensim+Functions";\r
+ public static final String Built$in_Functions_Vensim_Functions_ABS = "http://www.simantics.org/Sysdyn-1.0/Built-in+Functions/Vensim+Functions/ABS";\r
+ public static final String Built$in_Functions_Vensim_Functions_COS = "http://www.simantics.org/Sysdyn-1.0/Built-in+Functions/Vensim+Functions/COS";\r
+ public static final String Built$in_Functions_Vensim_Functions_COSH = "http://www.simantics.org/Sysdyn-1.0/Built-in+Functions/Vensim+Functions/COSH";\r
+ public static final String Built$in_Functions_Vensim_Functions_EXP = "http://www.simantics.org/Sysdyn-1.0/Built-in+Functions/Vensim+Functions/EXP";\r
+ public static final String Built$in_Functions_Vensim_Functions_IFTHENELSE = "http://www.simantics.org/Sysdyn-1.0/Built-in+Functions/Vensim+Functions/IFTHENELSE";\r
+ public static final String Built$in_Functions_Vensim_Functions_LN = "http://www.simantics.org/Sysdyn-1.0/Built-in+Functions/Vensim+Functions/LN";\r
+ public static final String Built$in_Functions_Vensim_Functions_MAX = "http://www.simantics.org/Sysdyn-1.0/Built-in+Functions/Vensim+Functions/MAX";\r
+ public static final String Built$in_Functions_Vensim_Functions_MIN = "http://www.simantics.org/Sysdyn-1.0/Built-in+Functions/Vensim+Functions/MIN";\r
+ public static final String Built$in_Functions_Vensim_Functions_MODULO = "http://www.simantics.org/Sysdyn-1.0/Built-in+Functions/Vensim+Functions/MODULO";\r
+ public static final String Built$in_Functions_Vensim_Functions_PULSE = "http://www.simantics.org/Sysdyn-1.0/Built-in+Functions/Vensim+Functions/PULSE";\r
+ public static final String Built$in_Functions_Vensim_Functions_RAMP = "http://www.simantics.org/Sysdyn-1.0/Built-in+Functions/Vensim+Functions/RAMP";\r
+ public static final String Built$in_Functions_Vensim_Functions_SIN = "http://www.simantics.org/Sysdyn-1.0/Built-in+Functions/Vensim+Functions/SIN";\r
+ public static final String Built$in_Functions_Vensim_Functions_SINH = "http://www.simantics.org/Sysdyn-1.0/Built-in+Functions/Vensim+Functions/SINH";\r
+ public static final String Built$in_Functions_Vensim_Functions_SQRT = "http://www.simantics.org/Sysdyn-1.0/Built-in+Functions/Vensim+Functions/SQRT";\r
+ public static final String Built$in_Functions_Vensim_Functions_STEP = "http://www.simantics.org/Sysdyn-1.0/Built-in+Functions/Vensim+Functions/STEP";\r
+ public static final String Built$in_Functions_Vensim_Functions_TAN = "http://www.simantics.org/Sysdyn-1.0/Built-in+Functions/Vensim+Functions/TAN";\r
+ public static final String Built$in_Functions_Vensim_Functions_TANH = "http://www.simantics.org/Sysdyn-1.0/Built-in+Functions/Vensim+Functions/TANH";\r
+ public static final String Built$in_Functions_Vensim_Functions_XIDZ = "http://www.simantics.org/Sysdyn-1.0/Built-in+Functions/Vensim+Functions/XIDZ";\r
+ public static final String Built$in_Functions_Vensim_Functions_ZIDZ = "http://www.simantics.org/Sysdyn-1.0/Built-in+Functions/Vensim+Functions/ZIDZ";\r
+ public static final String Built$in_Functions_interpolate = "http://www.simantics.org/Sysdyn-1.0/Built-in+Functions/interpolate";\r
+ public static final String Built$in_Functions_interpolateFull = "http://www.simantics.org/Sysdyn-1.0/Built-in+Functions/interpolateFull";\r
+ public static final String Built$in_Functions_xidz = "http://www.simantics.org/Sysdyn-1.0/Built-in+Functions/xidz";\r
+ public static final String Built$in_Functions_zidz = "http://www.simantics.org/Sysdyn-1.0/Built-in+Functions/zidz";\r
+ public static final String Cloud = "http://www.simantics.org/Sysdyn-1.0/Cloud";\r
+ public static final String CloudSymbol = "http://www.simantics.org/Sysdyn-1.0/CloudSymbol";\r
+ public static final String Configuration = "http://www.simantics.org/Sysdyn-1.0/Configuration";\r
+ public static final String ConfigurationDiagram = "http://www.simantics.org/Sysdyn-1.0/ConfigurationDiagram";\r
+ public static final String ConfigurationDiagramTemplate = "http://www.simantics.org/Sysdyn-1.0/ConfigurationDiagramTemplate";\r
+ public static final String ConstantExpression = "http://www.simantics.org/Sysdyn-1.0/ConstantExpression";\r
+ public static final String DefaultRealization = "http://www.simantics.org/Sysdyn-1.0/DefaultRealization";\r
+ public static final String DelayExpression = "http://www.simantics.org/Sysdyn-1.0/DelayExpression";\r
+ public static final String Dependency = "http://www.simantics.org/Sysdyn-1.0/Dependency";\r
+ public static final String DependencyConnection = "http://www.simantics.org/Sysdyn-1.0/DependencyConnection";\r
+ public static final String DiagramToCompositeMapping = "http://www.simantics.org/Sysdyn-1.0/DiagramToCompositeMapping";\r
+ public static final String Enumeration = "http://www.simantics.org/Sysdyn-1.0/Enumeration";\r
+ public static final String EnumerationIndex = "http://www.simantics.org/Sysdyn-1.0/EnumerationIndex";\r
+ public static final String EnumerationIndexes = "http://www.simantics.org/Sysdyn-1.0/EnumerationIndexes";\r
+ public static final String EnumerationIndexes_Inverse = "http://www.simantics.org/Sysdyn-1.0/EnumerationIndexes/Inverse";\r
+ public static final String Experiment = "http://www.simantics.org/Sysdyn-1.0/Experiment";\r
+ public static final String Expression = "http://www.simantics.org/Sysdyn-1.0/Expression";\r
+ public static final String Expressions = "http://www.simantics.org/Sysdyn-1.0/Expressions";\r
+ public static final String Expressions_Inverse = "http://www.simantics.org/Sysdyn-1.0/Expressions/Inverse";\r
+ public static final String ExternalFunctionFile = "http://www.simantics.org/Sysdyn-1.0/ExternalFunctionFile";\r
+ public static final String Flow = "http://www.simantics.org/Sysdyn-1.0/Flow";\r
+ public static final String FlowConnection = "http://www.simantics.org/Sysdyn-1.0/FlowConnection";\r
+ public static final String GameExperiment = "http://www.simantics.org/Sysdyn-1.0/GameExperiment";\r
+ public static final String HasActiveExpression = "http://www.simantics.org/Sysdyn-1.0/HasActiveExpression";\r
+ public static final String HasActiveExpression_Inverse = "http://www.simantics.org/Sysdyn-1.0/HasActiveExpression/Inverse";\r
+ public static final String HasArrayIndexes = "http://www.simantics.org/Sysdyn-1.0/HasArrayIndexes";\r
+ public static final String HasArrayIndexes_Inverse = "http://www.simantics.org/Sysdyn-1.0/HasArrayIndexes/Inverse";\r
+ public static final String HasArrayRange = "http://www.simantics.org/Sysdyn-1.0/HasArrayRange";\r
+ public static final String HasArrayRange_Inverse = "http://www.simantics.org/Sysdyn-1.0/HasArrayRange/Inverse";\r
+ public static final String HasDefaultInputValue = "http://www.simantics.org/Sysdyn-1.0/HasDefaultInputValue";\r
+ public static final String HasDefaultInputValue_Inverse = "http://www.simantics.org/Sysdyn-1.0/HasDefaultInputValue/Inverse";\r
+ public static final String HasEnumerationIndexes = "http://www.simantics.org/Sysdyn-1.0/HasEnumerationIndexes";\r
+ public static final String HasEnumerationIndexes_Inverse = "http://www.simantics.org/Sysdyn-1.0/HasEnumerationIndexes/Inverse";\r
+ public static final String HasEquation = "http://www.simantics.org/Sysdyn-1.0/HasEquation";\r
+ public static final String HasEquation_Inverse = "http://www.simantics.org/Sysdyn-1.0/HasEquation/Inverse";\r
+ public static final String HasExpressions = "http://www.simantics.org/Sysdyn-1.0/HasExpressions";\r
+ public static final String HasExpressions_Inverse = "http://www.simantics.org/Sysdyn-1.0/HasExpressions/Inverse";\r
+ public static final String HasExternalFile = "http://www.simantics.org/Sysdyn-1.0/HasExternalFile";\r
+ public static final String HasExternalFile_Inverse = "http://www.simantics.org/Sysdyn-1.0/HasExternalFile/Inverse";\r
+ public static final String HasHead = "http://www.simantics.org/Sysdyn-1.0/HasHead";\r
+ public static final String HasHeadTerminal = "http://www.simantics.org/Sysdyn-1.0/HasHeadTerminal";\r
+ public static final String HasInitialEquation = "http://www.simantics.org/Sysdyn-1.0/HasInitialEquation";\r
+ public static final String HasInitialEquation_Inverse = "http://www.simantics.org/Sysdyn-1.0/HasInitialEquation/Inverse";\r
+ public static final String HasLookup = "http://www.simantics.org/Sysdyn-1.0/HasLookup";\r
+ public static final String HasLookup_Inverse = "http://www.simantics.org/Sysdyn-1.0/HasLookup/Inverse";\r
+ public static final String HasMaxX = "http://www.simantics.org/Sysdyn-1.0/HasMaxX";\r
+ public static final String HasMaxX_Inverse = "http://www.simantics.org/Sysdyn-1.0/HasMaxX/Inverse";\r
+ public static final String HasMaxY = "http://www.simantics.org/Sysdyn-1.0/HasMaxY";\r
+ public static final String HasMaxY_Inverse = "http://www.simantics.org/Sysdyn-1.0/HasMaxY/Inverse";\r
+ public static final String HasMinX = "http://www.simantics.org/Sysdyn-1.0/HasMinX";\r
+ public static final String HasMinX_Inverse = "http://www.simantics.org/Sysdyn-1.0/HasMinX/Inverse";\r
+ public static final String HasMinY = "http://www.simantics.org/Sysdyn-1.0/HasMinY";\r
+ public static final String HasMinY_Inverse = "http://www.simantics.org/Sysdyn-1.0/HasMinY/Inverse";\r
+ public static final String HasModelicaFunctionCode = "http://www.simantics.org/Sysdyn-1.0/HasModelicaFunctionCode";\r
+ public static final String HasModelicaFunctionCode_Inverse = "http://www.simantics.org/Sysdyn-1.0/HasModelicaFunctionCode/Inverse";\r
+ public static final String HasOutputInterval = "http://www.simantics.org/Sysdyn-1.0/HasOutputInterval";\r
+ public static final String HasOutputInterval_Inverse = "http://www.simantics.org/Sysdyn-1.0/HasOutputInterval/Inverse";\r
+ public static final String HasParameterFile = "http://www.simantics.org/Sysdyn-1.0/HasParameterFile";\r
+ public static final String HasParameterFile_Inverse = "http://www.simantics.org/Sysdyn-1.0/HasParameterFile/Inverse";\r
+ public static final String HasRangeEnd = "http://www.simantics.org/Sysdyn-1.0/HasRangeEnd";\r
+ public static final String HasRangeEnd_Inverse = "http://www.simantics.org/Sysdyn-1.0/HasRangeEnd/Inverse";\r
+ public static final String HasRangeStart = "http://www.simantics.org/Sysdyn-1.0/HasRangeStart";\r
+ public static final String HasRangeStart_Inverse = "http://www.simantics.org/Sysdyn-1.0/HasRangeStart/Inverse";\r
+ public static final String HasRangeStep = "http://www.simantics.org/Sysdyn-1.0/HasRangeStep";\r
+ public static final String HasRangeStep_Inverse = "http://www.simantics.org/Sysdyn-1.0/HasRangeStep/Inverse";\r
+ public static final String HasRedeclaration = "http://www.simantics.org/Sysdyn-1.0/HasRedeclaration";\r
+ public static final String HasRedeclaration_Inverse = "http://www.simantics.org/Sysdyn-1.0/HasRedeclaration/Inverse";\r
+ public static final String HasResult = "http://www.simantics.org/Sysdyn-1.0/HasResult";\r
+ public static final String HasResultFile = "http://www.simantics.org/Sysdyn-1.0/HasResultFile";\r
+ public static final String HasResultFile_Inverse = "http://www.simantics.org/Sysdyn-1.0/HasResultFile/Inverse";\r
+ public static final String HasResult_Inverse = "http://www.simantics.org/Sysdyn-1.0/HasResult/Inverse";\r
+ public static final String HasSolver = "http://www.simantics.org/Sysdyn-1.0/HasSolver";\r
+ public static final String HasSolver_Inverse = "http://www.simantics.org/Sysdyn-1.0/HasSolver/Inverse";\r
+ public static final String HasStartTime = "http://www.simantics.org/Sysdyn-1.0/HasStartTime";\r
+ public static final String HasStartTime_Inverse = "http://www.simantics.org/Sysdyn-1.0/HasStartTime/Inverse";\r
+ public static final String HasStopTime = "http://www.simantics.org/Sysdyn-1.0/HasStopTime";\r
+ public static final String HasStopTime_Inverse = "http://www.simantics.org/Sysdyn-1.0/HasStopTime/Inverse";\r
+ public static final String HasTail = "http://www.simantics.org/Sysdyn-1.0/HasTail";\r
+ public static final String HasTailTerminal = "http://www.simantics.org/Sysdyn-1.0/HasTailTerminal";\r
+ public static final String HasTolerance = "http://www.simantics.org/Sysdyn-1.0/HasTolerance";\r
+ public static final String HasTolerance_Inverse = "http://www.simantics.org/Sysdyn-1.0/HasTolerance/Inverse";\r
+ public static final String HasUnit = "http://www.simantics.org/Sysdyn-1.0/HasUnit";\r
+ public static final String HasUnit_Inverse = "http://www.simantics.org/Sysdyn-1.0/HasUnit/Inverse";\r
+ public static final String HistoryRealization = "http://www.simantics.org/Sysdyn-1.0/HistoryRealization";\r
+ public static final String ImportedOntologies = "http://www.simantics.org/Sysdyn-1.0/ImportedOntologies";\r
+ public static final String IndependentVariable = "http://www.simantics.org/Sysdyn-1.0/IndependentVariable";\r
+ public static final String Input = "http://www.simantics.org/Sysdyn-1.0/Input";\r
+ public static final String InputSymbol = "http://www.simantics.org/Sysdyn-1.0/InputSymbol";\r
+ public static final String IsHeadOf = "http://www.simantics.org/Sysdyn-1.0/IsHeadOf";\r
+ public static final String IsHeadOfTerminal = "http://www.simantics.org/Sysdyn-1.0/IsHeadOfTerminal";\r
+ public static final String IsOutput = "http://www.simantics.org/Sysdyn-1.0/IsOutput";\r
+ public static final String IsReplaceable = "http://www.simantics.org/Sysdyn-1.0/IsReplaceable";\r
+ public static final String IsReplaceable_Inverse = "http://www.simantics.org/Sysdyn-1.0/IsReplaceable/Inverse";\r
+ public static final String IsTailOf = "http://www.simantics.org/Sysdyn-1.0/IsTailOf";\r
+ public static final String IsTailOfTerminal = "http://www.simantics.org/Sysdyn-1.0/IsTailOfTerminal";\r
+ public static final String LookupExpression = "http://www.simantics.org/Sysdyn-1.0/LookupExpression";\r
+ public static final String Module = "http://www.simantics.org/Sysdyn-1.0/Module";\r
+ public static final String ModuleSymbol = "http://www.simantics.org/Sysdyn-1.0/ModuleSymbol";\r
+ public static final String NormalExpression = "http://www.simantics.org/Sysdyn-1.0/NormalExpression";\r
+ public static final String ParameterExpression = "http://www.simantics.org/Sysdyn-1.0/ParameterExpression";\r
+ public static final String Redeclaration = "http://www.simantics.org/Sysdyn-1.0/Redeclaration";\r
+ public static final String RefersTo = "http://www.simantics.org/Sysdyn-1.0/RefersTo";\r
+ public static final String ReplacedEnumeration = "http://www.simantics.org/Sysdyn-1.0/ReplacedEnumeration";\r
+ public static final String ReplacedEnumeration_Inverse = "http://www.simantics.org/Sysdyn-1.0/ReplacedEnumeration/Inverse";\r
+ public static final String ReplacingEnumeration = "http://www.simantics.org/Sysdyn-1.0/ReplacingEnumeration";\r
+ public static final String ReplacingEnumeration_Inverse = "http://www.simantics.org/Sysdyn-1.0/ReplacingEnumeration/Inverse";\r
+ public static final String Result = "http://www.simantics.org/Sysdyn-1.0/Result";\r
+ public static final String SharedFunctionOntology = "http://www.simantics.org/Sysdyn-1.0/SharedFunctionOntology";\r
+ public static final String SharedModuleOntolofgy = "http://www.simantics.org/Sysdyn-1.0/SharedModuleOntolofgy";\r
+ public static final String ShowEnumerationIndexInCharts = "http://www.simantics.org/Sysdyn-1.0/ShowEnumerationIndexInCharts";\r
+ public static final String ShowEnumerationIndexInCharts_Inverse = "http://www.simantics.org/Sysdyn-1.0/ShowEnumerationIndexInCharts/Inverse";\r
+ public static final String SimulateOnChangeExperiment = "http://www.simantics.org/Sysdyn-1.0/SimulateOnChangeExperiment";\r
+ public static final String Stock = "http://www.simantics.org/Sysdyn-1.0/Stock";\r
+ public static final String StockExpression = "http://www.simantics.org/Sysdyn-1.0/StockExpression";\r
+ public static final String StockSymbol = "http://www.simantics.org/Sysdyn-1.0/StockSymbol";\r
+ public static final String SymbolReferences = "http://www.simantics.org/Sysdyn-1.0/SymbolReferences";\r
+ public static final String SymbolReferences_BasicSymbols = "http://www.simantics.org/Sysdyn-1.0/SymbolReferences/BasicSymbols";\r
+ public static final String Symbols = "http://www.simantics.org/Sysdyn-1.0/Symbols";\r
+ public static final String SysdynConnectionType = "http://www.simantics.org/Sysdyn-1.0/SysdynConnectionType";\r
+ public static final String SysdynDiagramModelingRules = "http://www.simantics.org/Sysdyn-1.0/SysdynDiagramModelingRules";\r
+ public static final String SysdynModel = "http://www.simantics.org/Sysdyn-1.0/SysdynModel";\r
+ public static final String SysdynModelicaFunction = "http://www.simantics.org/Sysdyn-1.0/SysdynModelicaFunction";\r
+ public static final String SysdynModelicaFunctionLibrary = "http://www.simantics.org/Sysdyn-1.0/SysdynModelicaFunctionLibrary";\r
+ public static final String SysdynModuleLibrary = "http://www.simantics.org/Sysdyn-1.0/SysdynModuleLibrary";\r
+ public static final String SysdynTerminal = "http://www.simantics.org/Sysdyn-1.0/SysdynTerminal";\r
+ public static final String Valve = "http://www.simantics.org/Sysdyn-1.0/Valve";\r
+ public static final String ValveSymbol = "http://www.simantics.org/Sysdyn-1.0/ValveSymbol";\r
+ public static final String Variable = "http://www.simantics.org/Sysdyn-1.0/Variable";\r
+ public static final String WithLookupExpression = "http://www.simantics.org/Sysdyn-1.0/WithLookupExpression";\r
+ public static final String angle = "http://www.simantics.org/Sysdyn-1.0/angle";\r
+ public static final String angle_Inverse = "http://www.simantics.org/Sysdyn-1.0/angle/Inverse";\r
+ }\r
+ \r
+ public static Resource getResourceOrNull(ReadGraph graph, String uri) {\r
+ try {\r
+ return graph.getResource(uri);\r
+ } catch(DatabaseException e) {\r
+ System.err.println(e.getMessage());\r
+ return null;\r
+ }\r
+ }\r
+ \r
+ public SysdynResource(ReadGraph graph) {\r
+ ArrayIndexes = getResourceOrNull(graph, URIs.ArrayIndexes);\r
+ ArrayIndexes_Inverse = getResourceOrNull(graph, URIs.ArrayIndexes_Inverse);\r
+ Auxiliary = getResourceOrNull(graph, URIs.Auxiliary);\r
+ AuxiliarySymbol = getResourceOrNull(graph, URIs.AuxiliarySymbol);\r
+ BasicExperiment = getResourceOrNull(graph, URIs.BasicExperiment);\r
+ Built$in_Functions = getResourceOrNull(graph, URIs.Built$in_Functions);\r
+ Built$in_Functions_Vensim_Functions = getResourceOrNull(graph, URIs.Built$in_Functions_Vensim_Functions);\r
+ Built$in_Functions_Vensim_Functions_ABS = getResourceOrNull(graph, URIs.Built$in_Functions_Vensim_Functions_ABS);\r
+ Built$in_Functions_Vensim_Functions_COS = getResourceOrNull(graph, URIs.Built$in_Functions_Vensim_Functions_COS);\r
+ Built$in_Functions_Vensim_Functions_COSH = getResourceOrNull(graph, URIs.Built$in_Functions_Vensim_Functions_COSH);\r
+ Built$in_Functions_Vensim_Functions_EXP = getResourceOrNull(graph, URIs.Built$in_Functions_Vensim_Functions_EXP);\r
+ Built$in_Functions_Vensim_Functions_IFTHENELSE = getResourceOrNull(graph, URIs.Built$in_Functions_Vensim_Functions_IFTHENELSE);\r
+ Built$in_Functions_Vensim_Functions_LN = getResourceOrNull(graph, URIs.Built$in_Functions_Vensim_Functions_LN);\r
+ Built$in_Functions_Vensim_Functions_MAX = getResourceOrNull(graph, URIs.Built$in_Functions_Vensim_Functions_MAX);\r
+ Built$in_Functions_Vensim_Functions_MIN = getResourceOrNull(graph, URIs.Built$in_Functions_Vensim_Functions_MIN);\r
+ Built$in_Functions_Vensim_Functions_MODULO = getResourceOrNull(graph, URIs.Built$in_Functions_Vensim_Functions_MODULO);\r
+ Built$in_Functions_Vensim_Functions_PULSE = getResourceOrNull(graph, URIs.Built$in_Functions_Vensim_Functions_PULSE);\r
+ Built$in_Functions_Vensim_Functions_RAMP = getResourceOrNull(graph, URIs.Built$in_Functions_Vensim_Functions_RAMP);\r
+ Built$in_Functions_Vensim_Functions_SIN = getResourceOrNull(graph, URIs.Built$in_Functions_Vensim_Functions_SIN);\r
+ Built$in_Functions_Vensim_Functions_SINH = getResourceOrNull(graph, URIs.Built$in_Functions_Vensim_Functions_SINH);\r
+ Built$in_Functions_Vensim_Functions_SQRT = getResourceOrNull(graph, URIs.Built$in_Functions_Vensim_Functions_SQRT);\r
+ Built$in_Functions_Vensim_Functions_STEP = getResourceOrNull(graph, URIs.Built$in_Functions_Vensim_Functions_STEP);\r
+ Built$in_Functions_Vensim_Functions_TAN = getResourceOrNull(graph, URIs.Built$in_Functions_Vensim_Functions_TAN);\r
+ Built$in_Functions_Vensim_Functions_TANH = getResourceOrNull(graph, URIs.Built$in_Functions_Vensim_Functions_TANH);\r
+ Built$in_Functions_Vensim_Functions_XIDZ = getResourceOrNull(graph, URIs.Built$in_Functions_Vensim_Functions_XIDZ);\r
+ Built$in_Functions_Vensim_Functions_ZIDZ = getResourceOrNull(graph, URIs.Built$in_Functions_Vensim_Functions_ZIDZ);\r
+ Built$in_Functions_interpolate = getResourceOrNull(graph, URIs.Built$in_Functions_interpolate);\r
+ Built$in_Functions_interpolateFull = getResourceOrNull(graph, URIs.Built$in_Functions_interpolateFull);\r
+ Built$in_Functions_xidz = getResourceOrNull(graph, URIs.Built$in_Functions_xidz);\r
+ Built$in_Functions_zidz = getResourceOrNull(graph, URIs.Built$in_Functions_zidz);\r
+ Cloud = getResourceOrNull(graph, URIs.Cloud);\r
+ CloudSymbol = getResourceOrNull(graph, URIs.CloudSymbol);\r
+ Configuration = getResourceOrNull(graph, URIs.Configuration);\r
+ ConfigurationDiagram = getResourceOrNull(graph, URIs.ConfigurationDiagram);\r
+ ConfigurationDiagramTemplate = getResourceOrNull(graph, URIs.ConfigurationDiagramTemplate);\r
+ ConstantExpression = getResourceOrNull(graph, URIs.ConstantExpression);\r
+ DefaultRealization = getResourceOrNull(graph, URIs.DefaultRealization);\r
+ DelayExpression = getResourceOrNull(graph, URIs.DelayExpression);\r
+ Dependency = getResourceOrNull(graph, URIs.Dependency);\r
+ DependencyConnection = getResourceOrNull(graph, URIs.DependencyConnection);\r
+ DiagramToCompositeMapping = getResourceOrNull(graph, URIs.DiagramToCompositeMapping);\r
+ Enumeration = getResourceOrNull(graph, URIs.Enumeration);\r
+ EnumerationIndex = getResourceOrNull(graph, URIs.EnumerationIndex);\r
+ EnumerationIndexes = getResourceOrNull(graph, URIs.EnumerationIndexes);\r
+ EnumerationIndexes_Inverse = getResourceOrNull(graph, URIs.EnumerationIndexes_Inverse);\r
+ Experiment = getResourceOrNull(graph, URIs.Experiment);\r
+ Expression = getResourceOrNull(graph, URIs.Expression);\r
+ Expressions = getResourceOrNull(graph, URIs.Expressions);\r
+ Expressions_Inverse = getResourceOrNull(graph, URIs.Expressions_Inverse);\r
+ ExternalFunctionFile = getResourceOrNull(graph, URIs.ExternalFunctionFile);\r
+ Flow = getResourceOrNull(graph, URIs.Flow);\r
+ FlowConnection = getResourceOrNull(graph, URIs.FlowConnection);\r
+ GameExperiment = getResourceOrNull(graph, URIs.GameExperiment);\r
+ HasActiveExpression = getResourceOrNull(graph, URIs.HasActiveExpression);\r
+ HasActiveExpression_Inverse = getResourceOrNull(graph, URIs.HasActiveExpression_Inverse);\r
+ HasArrayIndexes = getResourceOrNull(graph, URIs.HasArrayIndexes);\r
+ HasArrayIndexes_Inverse = getResourceOrNull(graph, URIs.HasArrayIndexes_Inverse);\r
+ HasArrayRange = getResourceOrNull(graph, URIs.HasArrayRange);\r
+ HasArrayRange_Inverse = getResourceOrNull(graph, URIs.HasArrayRange_Inverse);\r
+ HasDefaultInputValue = getResourceOrNull(graph, URIs.HasDefaultInputValue);\r
+ HasDefaultInputValue_Inverse = getResourceOrNull(graph, URIs.HasDefaultInputValue_Inverse);\r
+ HasEnumerationIndexes = getResourceOrNull(graph, URIs.HasEnumerationIndexes);\r
+ HasEnumerationIndexes_Inverse = getResourceOrNull(graph, URIs.HasEnumerationIndexes_Inverse);\r
+ HasEquation = getResourceOrNull(graph, URIs.HasEquation);\r
+ HasEquation_Inverse = getResourceOrNull(graph, URIs.HasEquation_Inverse);\r
+ HasExpressions = getResourceOrNull(graph, URIs.HasExpressions);\r
+ HasExpressions_Inverse = getResourceOrNull(graph, URIs.HasExpressions_Inverse);\r
+ HasExternalFile = getResourceOrNull(graph, URIs.HasExternalFile);\r
+ HasExternalFile_Inverse = getResourceOrNull(graph, URIs.HasExternalFile_Inverse);\r
+ HasHead = getResourceOrNull(graph, URIs.HasHead);\r
+ HasHeadTerminal = getResourceOrNull(graph, URIs.HasHeadTerminal);\r
+ HasInitialEquation = getResourceOrNull(graph, URIs.HasInitialEquation);\r
+ HasInitialEquation_Inverse = getResourceOrNull(graph, URIs.HasInitialEquation_Inverse);\r
+ HasLookup = getResourceOrNull(graph, URIs.HasLookup);\r
+ HasLookup_Inverse = getResourceOrNull(graph, URIs.HasLookup_Inverse);\r
+ HasMaxX = getResourceOrNull(graph, URIs.HasMaxX);\r
+ HasMaxX_Inverse = getResourceOrNull(graph, URIs.HasMaxX_Inverse);\r
+ HasMaxY = getResourceOrNull(graph, URIs.HasMaxY);\r
+ HasMaxY_Inverse = getResourceOrNull(graph, URIs.HasMaxY_Inverse);\r
+ HasMinX = getResourceOrNull(graph, URIs.HasMinX);\r
+ HasMinX_Inverse = getResourceOrNull(graph, URIs.HasMinX_Inverse);\r
+ HasMinY = getResourceOrNull(graph, URIs.HasMinY);\r
+ HasMinY_Inverse = getResourceOrNull(graph, URIs.HasMinY_Inverse);\r
+ HasModelicaFunctionCode = getResourceOrNull(graph, URIs.HasModelicaFunctionCode);\r
+ HasModelicaFunctionCode_Inverse = getResourceOrNull(graph, URIs.HasModelicaFunctionCode_Inverse);\r
+ HasOutputInterval = getResourceOrNull(graph, URIs.HasOutputInterval);\r
+ HasOutputInterval_Inverse = getResourceOrNull(graph, URIs.HasOutputInterval_Inverse);\r
+ HasParameterFile = getResourceOrNull(graph, URIs.HasParameterFile);\r
+ HasParameterFile_Inverse = getResourceOrNull(graph, URIs.HasParameterFile_Inverse);\r
+ HasRangeEnd = getResourceOrNull(graph, URIs.HasRangeEnd);\r
+ HasRangeEnd_Inverse = getResourceOrNull(graph, URIs.HasRangeEnd_Inverse);\r
+ HasRangeStart = getResourceOrNull(graph, URIs.HasRangeStart);\r
+ HasRangeStart_Inverse = getResourceOrNull(graph, URIs.HasRangeStart_Inverse);\r
+ HasRangeStep = getResourceOrNull(graph, URIs.HasRangeStep);\r
+ HasRangeStep_Inverse = getResourceOrNull(graph, URIs.HasRangeStep_Inverse);\r
+ HasRedeclaration = getResourceOrNull(graph, URIs.HasRedeclaration);\r
+ HasRedeclaration_Inverse = getResourceOrNull(graph, URIs.HasRedeclaration_Inverse);\r
+ HasResult = getResourceOrNull(graph, URIs.HasResult);\r
+ HasResultFile = getResourceOrNull(graph, URIs.HasResultFile);\r
+ HasResultFile_Inverse = getResourceOrNull(graph, URIs.HasResultFile_Inverse);\r
+ HasResult_Inverse = getResourceOrNull(graph, URIs.HasResult_Inverse);\r
+ HasSolver = getResourceOrNull(graph, URIs.HasSolver);\r
+ HasSolver_Inverse = getResourceOrNull(graph, URIs.HasSolver_Inverse);\r
+ HasStartTime = getResourceOrNull(graph, URIs.HasStartTime);\r
+ HasStartTime_Inverse = getResourceOrNull(graph, URIs.HasStartTime_Inverse);\r
+ HasStopTime = getResourceOrNull(graph, URIs.HasStopTime);\r
+ HasStopTime_Inverse = getResourceOrNull(graph, URIs.HasStopTime_Inverse);\r
+ HasTail = getResourceOrNull(graph, URIs.HasTail);\r
+ HasTailTerminal = getResourceOrNull(graph, URIs.HasTailTerminal);\r
+ HasTolerance = getResourceOrNull(graph, URIs.HasTolerance);\r
+ HasTolerance_Inverse = getResourceOrNull(graph, URIs.HasTolerance_Inverse);\r
+ HasUnit = getResourceOrNull(graph, URIs.HasUnit);\r
+ HasUnit_Inverse = getResourceOrNull(graph, URIs.HasUnit_Inverse);\r
+ HistoryRealization = getResourceOrNull(graph, URIs.HistoryRealization);\r
+ ImportedOntologies = getResourceOrNull(graph, URIs.ImportedOntologies);\r
+ IndependentVariable = getResourceOrNull(graph, URIs.IndependentVariable);\r
+ Input = getResourceOrNull(graph, URIs.Input);\r
+ InputSymbol = getResourceOrNull(graph, URIs.InputSymbol);\r
+ IsHeadOf = getResourceOrNull(graph, URIs.IsHeadOf);\r
+ IsHeadOfTerminal = getResourceOrNull(graph, URIs.IsHeadOfTerminal);\r
+ IsOutput = getResourceOrNull(graph, URIs.IsOutput);\r
+ IsReplaceable = getResourceOrNull(graph, URIs.IsReplaceable);\r
+ IsReplaceable_Inverse = getResourceOrNull(graph, URIs.IsReplaceable_Inverse);\r
+ IsTailOf = getResourceOrNull(graph, URIs.IsTailOf);\r
+ IsTailOfTerminal = getResourceOrNull(graph, URIs.IsTailOfTerminal);\r
+ LookupExpression = getResourceOrNull(graph, URIs.LookupExpression);\r
+ Module = getResourceOrNull(graph, URIs.Module);\r
+ ModuleSymbol = getResourceOrNull(graph, URIs.ModuleSymbol);\r
+ NormalExpression = getResourceOrNull(graph, URIs.NormalExpression);\r
+ ParameterExpression = getResourceOrNull(graph, URIs.ParameterExpression);\r
+ Redeclaration = getResourceOrNull(graph, URIs.Redeclaration);\r
+ RefersTo = getResourceOrNull(graph, URIs.RefersTo);\r
+ ReplacedEnumeration = getResourceOrNull(graph, URIs.ReplacedEnumeration);\r
+ ReplacedEnumeration_Inverse = getResourceOrNull(graph, URIs.ReplacedEnumeration_Inverse);\r
+ ReplacingEnumeration = getResourceOrNull(graph, URIs.ReplacingEnumeration);\r
+ ReplacingEnumeration_Inverse = getResourceOrNull(graph, URIs.ReplacingEnumeration_Inverse);\r
+ Result = getResourceOrNull(graph, URIs.Result);\r
+ SharedFunctionOntology = getResourceOrNull(graph, URIs.SharedFunctionOntology);\r
+ SharedModuleOntolofgy = getResourceOrNull(graph, URIs.SharedModuleOntolofgy);\r
+ ShowEnumerationIndexInCharts = getResourceOrNull(graph, URIs.ShowEnumerationIndexInCharts);\r
+ ShowEnumerationIndexInCharts_Inverse = getResourceOrNull(graph, URIs.ShowEnumerationIndexInCharts_Inverse);\r
+ SimulateOnChangeExperiment = getResourceOrNull(graph, URIs.SimulateOnChangeExperiment);\r
+ Stock = getResourceOrNull(graph, URIs.Stock);\r
+ StockExpression = getResourceOrNull(graph, URIs.StockExpression);\r
+ StockSymbol = getResourceOrNull(graph, URIs.StockSymbol);\r
+ SymbolReferences = getResourceOrNull(graph, URIs.SymbolReferences);\r
+ SymbolReferences_BasicSymbols = getResourceOrNull(graph, URIs.SymbolReferences_BasicSymbols);\r
+ Symbols = getResourceOrNull(graph, URIs.Symbols);\r
+ SysdynConnectionType = getResourceOrNull(graph, URIs.SysdynConnectionType);\r
+ SysdynDiagramModelingRules = getResourceOrNull(graph, URIs.SysdynDiagramModelingRules);\r
+ SysdynModel = getResourceOrNull(graph, URIs.SysdynModel);\r
+ SysdynModelicaFunction = getResourceOrNull(graph, URIs.SysdynModelicaFunction);\r
+ SysdynModelicaFunctionLibrary = getResourceOrNull(graph, URIs.SysdynModelicaFunctionLibrary);\r
+ SysdynModuleLibrary = getResourceOrNull(graph, URIs.SysdynModuleLibrary);\r
+ SysdynTerminal = getResourceOrNull(graph, URIs.SysdynTerminal);\r
+ Valve = getResourceOrNull(graph, URIs.Valve);\r
+ ValveSymbol = getResourceOrNull(graph, URIs.ValveSymbol);\r
+ Variable = getResourceOrNull(graph, URIs.Variable);\r
+ WithLookupExpression = getResourceOrNull(graph, URIs.WithLookupExpression);\r
+ angle = getResourceOrNull(graph, URIs.angle);\r
+ angle_Inverse = getResourceOrNull(graph, URIs.angle_Inverse);\r
+ }\r
+ \r
+ public static SysdynResource getInstance(ReadGraph graph) {\r
+ Session session = graph.getSession();\r
+ SysdynResource ret = session.peekService(SysdynResource.class);\r
+ if(ret == null) {\r
+ ret = new SysdynResource(graph);\r
+ session.registerService(SysdynResource.class, ret);\r
+ }\r
+ return ret;\r
+ }\r
+ \r
+ public static SysdynResource getInstance(Session session) throws DatabaseException {\r
+ SysdynResource ret = session.peekService(SysdynResource.class);\r
+ if(ret == null) {\r
+ ret = session.syncRequest(new Read<SysdynResource>() {\r
+ public SysdynResource perform(ReadGraph graph) throws DatabaseException {\r
+ return new SysdynResource(graph);\r
+ }\r
+ });\r
+ session.registerService(SysdynResource.class, ret);\r
+ }\r
+ return ret;\r
+ }\r
+ \r
+}\r
+\r
--- /dev/null
+L0 = <http://www.simantics.org/Layer0-1.0>
+G2D = <http://www.simantics.org/G2D-1.0>
+STR = <http://www.simantics.org/Structural-1.0>
+DIA = <http://www.simantics.org/Diagram-2.0>
+SIMU = <http://www.simantics.org/Simulation-1.0>
+MOD = <http://www.simantics.org/Modeling-1.0>
+SYSDYN = <http://www.simantics.org/Sysdyn-1.0>
+PROJ = <http://www.simantics.org/Project-1.0>
+
+//######################################################################
+//# Example work model with two modules
+//######################################################################
+
+WM = <http://www.simantics.org/Sysdyn-1.0/DevelopmentProject> : PROJ.Project
+ PROJ.HasFeature _ : PROJ.FeatureSpec
+ PROJ.HasGroupId "org.simantics.sysdyn.feature.group"
+ L0.PartOf <http://Projects>
+
+TAGS = WM.Tags : L0.Library
+
+//WM.dependency : L0.Template
+// @template %type %head %tail %angle
+// %type
+// @L0.tag TAGS.AdminIsVisible
+// @L0.tag TAGS.AdminIsFocusable
+// STR.HasConnectionType SYSDYN.SysdynConnectionType
+// SYSDYN.angle %angle
+// DIA.HasArrowConnector _ : DIA.Connector
+// SYSDYN.HasHeadTerminal %head
+// DIA.AreConnected _ : DIA.Connector
+// SYSDYN.HasTailTerminal %tail
+// DIA.IsPlainConnectorOf %type
+//
+//WM.flow : L0.Template
+// @template %type %head %tail
+// %type
+// @L0.tag TAGS.AdminIsVisible
+// @L0.tag TAGS.AdminIsFocusable
+// STR.HasConnectionType SYSDYN.SysdynConnectionType
+// DIA.HasArrowConnector _ : DIA.Connector
+// SYSDYN.HasHeadTerminal %head
+// DIA.AreConnected _ : DIA.Connector
+// SYSDYN.HasTailTerminal %tail
+// DIA.IsPlainConnectorOf %type
+//
+//WM.conf_dependency : L0.Template
+// @template %type %head %tail
+// %type
+// @L0.tag MOD.Mapped
+// SYSDYN.HasHead %head
+// SYSDYN.HasTail %tail
+//
+//WM.conf_dependency_ref : L0.Template
+// @template %type %head %tail %ref
+// %type
+// @L0.tag MOD.Mapped
+// SYSDYN.HasHead %head
+// SYSDYN.HasTail %tail
+// SYSDYN.RefersTo %ref
+
+WM.CancerModel : SYSDYN.SysdynModel
+ L0.HasLabel "Cancer Model"
+ SIMU.HasConfiguration CMC
+ SYSDYN.HasStartTime 0.0
+ SYSDYN.HasStopTime 24.0
+
+WM.CancerModel.Experiment : SYSDYN.Experiment
+ L0.HasLabel "Experiment"
+
+CMC = WM.CancerModel.CancerModelConfiguration : SYSDYN.Configuration
+ L0.HasLabel "CancerModelConfiguration"
+
+CMC.LungCProgressIAIVRate : SYSDYN.Auxiliary
+ @L0.tag MOD.Mapped
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions
+ @L0.list
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PIAIVSm')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PIAIVNs')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PIAIVNos')"
+
+CMC.LungCT1Progresses : SYSDYN.Valve
+ @L0.tag MOD.Mapped
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions
+ @L0.list
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "LungCNotProgressing1[Type,Stage,Gender,Age]*LungCT1ProgressesRate[Type,Stage,Age,Gender]"
+CMC.LungCProgressIAIB : SYSDYN.Valve
+ @L0.tag MOD.Mapped
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions
+ @L0.list
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "LungCProgressIAIBRate[Type,Age,Gender]*LungCsIANoD[Type,Gender,Age]"
+CMC.LungCT1Death : SYSDYN.Valve
+ @L0.tag MOD.Mapped
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions
+ @L0.list
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "LungCT1Disabling[Type,Stage,Gender,Age]*LungCT1DeathRate[Type,Stage,Age,Gender]"
+CMC.LungCHealthyPopCorr : SYSDYN.Valve
+ @L0.tag MOD.Mapped
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions
+ @L0.list
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "LungCHealthy[Gender,Age]*LungCModelPopCorrectionFactor[Gender,Age]"
+CMC.LungCsIADiagnosisRate : SYSDYN.Auxiliary
+ @L0.tag MOD.Mapped
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions
+ @L0.list
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PDIASm')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PDIANs')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PDIANos')"
+
+CMC.LungCProgress03IV : SYSDYN.Valve
+ @L0.tag MOD.Mapped
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions
+ @L0.list
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "LungCProgress03IVRate[Type,Age,Gender]*LungCs03[Type,Gender,Age]"
+CMC.LungCsIIIBNoDAgeing : SYSDYN.Valve
+ @L0.tag MOD.Mapped
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions
+ @L0.list
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "if Age==Age0 then -LungCsIIIBNoD[Type,Gender,Age] elseif Age==Age100 then +VECTOR_MAP(LungCsIIIBNoD[Type,Gender,Age], -1) else -LungCsIIIBNoD[Type,Gender,Age]+VECTOR_MAP(LungCsIIIBNoD[Type,Gender,Age], -1)*DummyRateForUnitsConversion"
+CMC.LungCProgressIBIVRate : SYSDYN.Auxiliary
+ @L0.tag MOD.Mapped
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions
+ @L0.list
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PIBIVSm')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PIBIVNs')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PIBIVNos')"
+
+CMC.LungCOutputs02NosDiagnosis : SYSDYN.Auxiliary
+ @L0.tag MOD.Mapped
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions
+ @L0.list
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "sum(LungCs02Diagnosis[NotSmoker,Gender!,Age!])"
+
+CMC.LungCProgressIIAIV : SYSDYN.Valve
+ @L0.tag MOD.Mapped
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions
+ @L0.list
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "LungCProgressIIAIVRate[Type,Age,Gender]*LungCsIIANoD[Type,Gender,Age]"
+CMC.LungCTherapy1Mortality : SYSDYN.Valve
+ @L0.tag MOD.Mapped
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions
+ @L0.list
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "LungCFirstTreatmentRate*(LungCD[Type,Stage,Gender,Age]*LungCTherapy1Ratio[Type,Stage,Age,Gender])*LungCTherapy1MortalityRatio/100"
+CMC.LungCCured1PopCorr : SYSDYN.Valve
+ @L0.tag MOD.Mapped
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions
+ @L0.list
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "LungCModelPopCorrectionFactor[Gender,Age]*LungCCured1[Type,Stage,Gender,Age]"
+CMC.LungCProgress01IV : SYSDYN.Valve
+ @L0.tag MOD.Mapped
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions
+ @L0.list
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "LungCProgress01IVRate[Type,Age,Gender]*LungCs01[Type,Gender,Age]"
+CMC.LungCs03Diagnosis : SYSDYN.Valve
+ @L0.tag MOD.Mapped
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions
+ @L0.list
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "LungCs03DiagnosisRate[Type,Age,Gender]*LungCs03[Type,Gender,Age]"
+CMC.LungCs03PopCorr : SYSDYN.Valve
+ @L0.tag MOD.Mapped
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions
+ @L0.list
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "LungCModelPopCorrectionFactor[Gender,Age]*LungCs03[Type,Gender,Age]"
+CMC.LungCProgressIAIIA : SYSDYN.Valve
+ @L0.tag MOD.Mapped
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions
+ @L0.list
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "LungCProgressIAIIARate[Type,Age,Gender]*LungCsIANoD[Type,Gender,Age]"
+CMC.LungCDPopCorr : SYSDYN.Valve
+ @L0.tag MOD.Mapped
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions
+ @L0.list
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "LungCModelPopCorrectionFactor[Gender,Age]*LungCD[Type,Stage,Gender,Age]"
+CMC.LungCsIIIADiagnosisRate : SYSDYN.Auxiliary
+ @L0.tag MOD.Mapped
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions
+ @L0.list
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PDIIIASm')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PDIIIANs')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PDIIIANos')"
+
+CMC.LungCOutputsIANsNoD : SYSDYN.Auxiliary
+ @L0.tag MOD.Mapped
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions
+ @L0.list
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "sum(LungCsIANoD[NonSmall,Gender!,Age!])"
+
+CMC.LungCOutputTherapy1 : SYSDYN.Auxiliary
+ @L0.tag MOD.Mapped
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions
+ @L0.list
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "sum(LungCTherapy1[Type!,Stage!,Gender!,Age!])+sum(LungCTherapyCure1[Type!,Stage!,Gender!,Age!])+sum(LungCTherapy1Mortality[Type!,Stage!,Gender!,Age!])"
+
+CMC.LungCT2ProgressesRate : SYSDYN.Auxiliary
+ @L0.tag MOD.Mapped
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions
+ @L0.list
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT2Re01Sm')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT2Re02Sm')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT2Re03Sm')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT2ReIASm')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT2ReIBSm')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT2ReIIASm')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT2ReIIBSm')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT2ReIIIASm')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT2ReIIIBSm')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT2ReIVSm')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT2Re01Ns')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT2Re02Ns')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT2Re03Ns')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT2ReIANs')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT2ReIBNs')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT2ReIIANs')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT2ReIIBNs')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT2ReIIIANs')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT2ReIIIBNs')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT2ReIVNs')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT2Re01Nos')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT2Re02Nos')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT2Re03Nos')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT2ReIANos')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT2ReIBNos')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT2ReIIANos')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT2ReIIBNos')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT2ReIIIANos')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT2ReIIIBNos')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT2ReIVNos')"
+
+CMC.LungCOutputTherapy2Cure : SYSDYN.Auxiliary
+ @L0.tag MOD.Mapped
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions
+ @L0.list
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "sum(LungCTherapyCure2[Type!,Stage!,Gender!,Age!])"
+
+CMC.LungCT2Progresses : SYSDYN.Valve
+ @L0.tag MOD.Mapped
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions
+ @L0.list
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "LungCNotProgressing2[Type,Stage,Gender,Age]*LungCT2ProgressesRate[Type,Stage,Age,Gender]"
+CMC.LungCT1ProgToDisablingRate : SYSDYN.Auxiliary
+ @L0.tag MOD.Mapped
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions
+ @L0.list
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT1Di01Sm')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT1Di02Sm')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT1Di03Sm')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT1DiIASm')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT1DiIBSm')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT1DiIIASm')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT1DiIIBSm')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT1DiIIIASm')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT1DiIIIBSm')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT1DiIVSm')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT1Di01Ns')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT1Di02Ns')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT1Di03Ns')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT1DiIANs')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT1DiIBNs')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT1DiIIANs')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT1DiIIBNs')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT1DiIIIANs')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT1DiIIIBNs')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT1DiIVNs')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT1Di01Nos')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT1Di02Nos')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT1Di03Nos')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT1DiIANos')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT1DiIBNos')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT1DiIIANos')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT1DiIIBNos')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT1DiIIIANos')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT1DiIIIBNos')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT1DiIVNos')"
+
+CMC.LungCProgressIIBIIIB : SYSDYN.Valve
+ @L0.tag MOD.Mapped
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions
+ @L0.list
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "LungCProgressIIBIIIBRate[Type,Age,Gender]*LungCsIIBNoD[Type,Gender,Age]"
+CMC.LungCsIIIANoDAgeing : SYSDYN.Valve
+ @L0.tag MOD.Mapped
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions
+ @L0.list
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "if Age==Age0 then -LungCsIIIANoD[Type,Gender,Age] elseif Age==Age100 then +VECTOR_MAP(LungCsIIIANoD[Type,Gender,Age], -1) else -LungCsIIIANoD[Type,Gender,Age]+VECTOR_MAP(LungCsIIIANoD[Type,Gender,Age], -1)*DummyRateForUnitsConversion"
+CMC.LungCOutputsIBNsDiagnosis : SYSDYN.Auxiliary
+ @L0.tag MOD.Mapped
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions
+ @L0.list
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "sum(LungCsIBDiagnosis[NonSmall,Gender!,Age!])"
+
+CMC.LungCOutputRelapse : SYSDYN.Auxiliary
+ @L0.tag MOD.Mapped
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions
+ @L0.list
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "sum(LungCT1Progresses[Type!,Stage!,Gender!,Age!])+sum(LungCT2Progresses[Type!,Stage!,Gender!,Age!])"
+
+CMC.LungCT1Deceased : SYSDYN.Stock
+ @L0.tag MOD.Mapped
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions
+ @L0.list
+ _ : SYSDYN.StockExpression
+ SYSDYN.HasInitialEquation "0"
+
+CMC.LungCT1DisablingPopCorr : SYSDYN.Valve
+ @L0.tag MOD.Mapped
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions
+ @L0.list
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "LungCModelPopCorrectionFactor[Gender,Age]*LungCT1Disabling[Type,Stage,Gender,Age]"
+CMC.LungCOutputsIAScDiagnosis : SYSDYN.Auxiliary
+ @L0.tag MOD.Mapped
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions
+ @L0.list
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "sum(LungCsIADiagnosis[Small,Gender!,Age!])"
+
+CMC.LungCProgressIBIV : SYSDYN.Valve
+ @L0.tag MOD.Mapped
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions
+ @L0.list
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "LungCProgressIBIVRate[Type,Age,Gender]*LungCsIBNoD[Type,Gender,Age]"
+CMC.LungCsIVDiagnosis : SYSDYN.Valve
+ @L0.tag MOD.Mapped
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions
+ @L0.list
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "LungCsIVDiagnosisRate[Type,Age,Gender]*LungCsIVNoD[Type,Gender,Age]"
+CMC.LungCOutputsIIIBScDiagnosis : SYSDYN.Auxiliary
+ @L0.tag MOD.Mapped
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions
+ @L0.list
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "sum(LungCsIIIBDiagnosis[Small,Gender!,Age!])"
+
+CMC.LungCsIIADiagnosis : SYSDYN.Valve
+ @L0.tag MOD.Mapped
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions
+ @L0.list
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "LungCsIIADiagnosisRate[Type,Age,Gender]*LungCsIIANoD[Type,Gender,Age]"
+CMC.LungCTherapy1Ratio : SYSDYN.Auxiliary
+ @L0.tag MOD.Mapped
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions
+ @L0.list
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT1Ra01Sm')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT1Ra02Sm')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT1Ra03Sm')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT1RaIASm')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT1RaIBSm')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT1RaIIASm')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT1RaIIBSm')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT1RaIIIASm')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT1RaIIIBSm')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT1RaIVSm')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT1Ra01Ns')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT1Ra02Ns')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT1Ra03Ns')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT1RaIANs')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT1RaIBNs')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT1RaIIANs')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT1RaIIBNs')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT1RaIIIANs')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT1RaIIIBNs')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT1RaIVNs')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT1Ra01Nos')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT1Ra02Nos')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT1Ra03Nos')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT1RaIANos')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT1RaIBNos')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT1RaIIANos')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT1RaIIBNos')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT1RaIIIANos')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT1RaIIIBNos')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT1RaIVNos')"
+
+CMC.LungCsIBNoDPopCorr : SYSDYN.Valve
+ @L0.tag MOD.Mapped
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions
+ @L0.list
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "LungCModelPopCorrectionFactor[Gender,Age]*LungCsIBNoD[Type,Gender,Age]"
+CMC.LungCsIANoDAgeing : SYSDYN.Valve
+ @L0.tag MOD.Mapped
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions
+ @L0.list
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "if Age==Age0 then -LungCsIANoD[Type,Gender,Age] elseif Age==Age100 then +VECTOR_MAP(LungCsIANoD[Type,Gender,Age], -1) else -LungCsIANoD[Type,Gender,Age]+VECTOR_MAP(LungCsIANoD[Type,Gender,Age], -1)*DummyRateForUnitsConversion"
+CMC.LungCCured1Ageing : SYSDYN.Valve
+ @L0.tag MOD.Mapped
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions
+ @L0.list
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "if Age==Age0 then -LungCCured1[Type,Stage,Gender,Age] elseif Age==Age100 then +VECTOR_MAP(LungCCured1[Type,Stage,Gender,Age], -1) else -LungCCured1[Type,Stage,Gender,Age]+VECTOR_MAP(LungCCured1[Type,Stage,Gender,Age], -1)*DummyRateForUnitsConversion"
+CMC.LungCProgress03IARate : SYSDYN.Auxiliary
+ @L0.tag MOD.Mapped
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions
+ @L0.list
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'P03IASm')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'P03IANs')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'P03IANos')"
+
+CMC.LungCT1Disabling : SYSDYN.Stock
+ @L0.tag MOD.Mapped
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions
+ @L0.list
+ _ : SYSDYN.StockExpression
+ SYSDYN.HasInitialEquation "LungCT1DisablingIniVal[Type,Stage,Age,Gender]"
+
+CMC.LungCCured2PopCorr : SYSDYN.Valve
+ @L0.tag MOD.Mapped
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions
+ @L0.list
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "LungCModelPopCorrectionFactor[Gender,Age]*LungCCured2[Type,Stage,Gender,Age]"
+CMC.LungCTreated2IniVal : SYSDYN.Auxiliary
+ @L0.tag MOD.Mapped
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions
+ @L0.list
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'IT2TrIASm')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'IT2TrIBSm')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'IT2TrIIASm')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'IT2TrIIBSm')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'IT2TrIIIASm')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'IT2TrIIIBSm')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'IT2TrIVSm')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'IT2Tr01Sm')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'IT2Tr02Sm')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'IT2Tr03Sm')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'IT2TrIANs')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'IT2TrIBNs')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'IT2TrIIANs')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'IT2TrIIBNs')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'IT2TrIIIANs')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'IT2TrIIIBNs')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'IT2TrIVNs')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'IT2Tr01Ns')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'IT2Tr02Ns')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'IT2Tr03Ns')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'IT2TrIANos')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'IT2TrIBNos')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'IT2TrIIANos')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'IT2TrIIBNos')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'IT2TrIIIANos')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'IT2TrIIIBNos')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'IT2TrIVNos')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'IT2Tr01Nos')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'IT2Tr02Nos')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'IT2Tr03Nos')"
+
+CMC.LungCsIIBDiagnosisRate : SYSDYN.Auxiliary
+ @L0.tag MOD.Mapped
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions
+ @L0.list
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PDIIBSm')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PDIIBNs')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PDIIBNos')"
+
+CMC.LungCOutputNoDSc : SYSDYN.Auxiliary
+ @L0.tag MOD.Mapped
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions
+ @L0.list
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "LungCOutputs01ScNoD+LungCOutputs02ScNoD+LungCOutputs03ScNoD+LungCOutputsIAScNoD+LungCOutputsIBScNoD+LungCOutputsIIAScNoD+LungCOutputsIIBScNoD+LungCOutputsIIIAScNoD+LungCOutputsIIIBScNoD+LungCOutputsIVScNoD"
+
+CMC.LungCOutputsIANsDiagnosis : SYSDYN.Auxiliary
+ @L0.tag MOD.Mapped
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions
+ @L0.list
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "sum(LungCsIADiagnosis[NonSmall,Gender!,Age!])"
+
+CMC.LungCTherapy2Failed : SYSDYN.Valve
+ @L0.tag MOD.Mapped
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions
+ @L0.list
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "LungCFirstTreatmentRate*(LungCD[Type,Stage,Gender,Age]*LungCTherapy2Ratio[Type,Stage,Age,Gender])*LungCTherapy2FailRatio/100"
+CMC.LungCProgressIIBIIIARate : SYSDYN.Auxiliary
+ @L0.tag MOD.Mapped
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions
+ @L0.list
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PIIBIIIASm')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PIIBIIIANs')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PIIBIIIANos')"
+
+CMC.LungCProgressIBIIB : SYSDYN.Valve
+ @L0.tag MOD.Mapped
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions
+ @L0.list
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "LungCProgressIBIIBRate[Type,Age,Gender]*LungCsIBNoD[Type,Gender,Age]"
+CMC.LungCsIIIBNoD : SYSDYN.Stock
+ @L0.tag MOD.Mapped
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions
+ @L0.list
+ _ : SYSDYN.StockExpression
+ SYSDYN.HasInitialEquation "LungCsIIIBNoDIniVal[Type,Age,Gender]"
+
+CMC.LungCDAgeing : SYSDYN.Valve
+ @L0.tag MOD.Mapped
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions
+ @L0.list
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "if Age==Age0 then -LungCD[Type,Stage,Gender,Age] elseif Age==Age100 then +VECTOR_MAP(LungCD[Type,Stage,Gender,Age], -1) else -LungCD[Type,Stage,Gender,Age]+VECTOR_MAP(LungCD[Type,Stage,Gender,Age], -1)*DummyRateForUnitsConversion"
+CMC.LungCOutputProgressing2 : SYSDYN.Auxiliary
+ @L0.tag MOD.Mapped
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions
+ @L0.list
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "sum(LungCT2Progressing[Type!,Stage!,Gender!,Age!])"
+
+CMC.LungCT1ProgressingAgeing : SYSDYN.Valve
+ @L0.tag MOD.Mapped
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions
+ @L0.list
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "if Age==Age0 then -LungCT1Progressing[Type,Stage,Gender,Age] elseif Age==Age100 then +VECTOR_MAP(LungCT1Progressing[Type,Stage,Gender,Age], -1) else -LungCT1Progressing[Type,Stage,Gender,Age]+VECTOR_MAP(LungCT1Progressing[Type,Stage,Gender,Age], -1)*DummyRateForUnitsConversion"
+CMC.LungCT1ProgToDisabling : SYSDYN.Valve
+ @L0.tag MOD.Mapped
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions
+ @L0.list
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "LungCT1Progressing[Type,Stage,Gender,Age]*LungCT1ProgToDisablingRate[Type,Stage,Age,Gender]"
+CMC.LungCT2ProgressingPopCorr : SYSDYN.Valve
+ @L0.tag MOD.Mapped
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions
+ @L0.list
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "LungCModelPopCorrectionFactor[Gender,Age]*LungCT2Progressing[Type,Stage,Gender,Age]"
+CMC.LungCInception : SYSDYN.Valve
+ @L0.tag MOD.Mapped
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions
+ @L0.list
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "LungCHealthy[Gender,Age]*LungCSmokersPercentageOfPopulation[Age,Gender]/100*LungCInceptionRate[Small,Age,Gender]"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "LungCHealthy[Gender,Age]*LungCSmokersPercentageOfPopulation[Age,Gender]/100*LungCInceptionRate[NonSmall,Age,Gender]"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "LungCHealthy[Gender,Age]*LungCInceptionRate[NotSmoker,Age,Gender]*LungCInceptionRateChanges[Gender]"
+CMC.LungCTherapyCure2 : SYSDYN.Valve
+ @L0.tag MOD.Mapped
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions
+ @L0.list
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "LungCFirstTreatmentRate*(LungCD[Type,Stage,Gender,Age]*LungCTherapy2Ratio[Type,Stage,Age,Gender]*LungCTherapy2CureRatio[Type,Stage,Age,Gender])*(1-LungCTherapy2FailRatio/100)"
+CMC.LungCCured1 : SYSDYN.Stock
+ @L0.tag MOD.Mapped
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions
+ @L0.list
+ _ : SYSDYN.StockExpression
+ SYSDYN.HasInitialEquation "LungCCured1IniVal[Type,Stage,Age,Gender]"
+
+CMC.LungCBirth : SYSDYN.Valve
+ @L0.tag MOD.Mapped
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions
+ @L0.list
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "TotalPopulationBirth[Gender]"
+CMC.LungCT2ProgressingAgeing : SYSDYN.Valve
+ @L0.tag MOD.Mapped
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions
+ @L0.list
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "if Age==Age0 then -LungCT2Progressing[Type,Stage,Gender,Age] elseif Age==Age100 then +VECTOR_MAP(LungCT2Progressing[Type,Stage,Gender,Age], -1) else -LungCT2Progressing[Type,Stage,Gender,Age]+VECTOR_MAP(LungCT2Progressing[Type,Stage,Gender,Age], -1)*DummyRateForUnitsConversion"
+CMC.LungCTherapy1 : SYSDYN.Valve
+ @L0.tag MOD.Mapped
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions
+ @L0.list
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "LungCFirstTreatmentRate*(LungCD[Type,Stage,Gender,Age]*LungCTherapy1Ratio[Type,Stage,Age,Gender]*(1-LungCTherapy1CureRatio[Type,Stage,Age,Gender]))*(1-LungCTherapy1MortalityRatio/100)"
+CMC.LungCOutputNoDNs : SYSDYN.Auxiliary
+ @L0.tag MOD.Mapped
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions
+ @L0.list
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "LungCOutputs01NsNoD+LungCOutputs02NsNoD+LungCOutputs03NsNoD+LungCOutputsIANsNoD+LungCOutputsIBNsNoD+LungCOutputsIIANsNoD+LungCOutputsIIBNsNoD+LungCOutputsIIIANsNoD+LungCOutputsIIIBNsNoD+LungCOutputsIVNsNoD"
+
+CMC.LungCProgressIIAIIIA : SYSDYN.Valve
+ @L0.tag MOD.Mapped
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions
+ @L0.list
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "LungCProgressIIAIIIARate[Type,Age,Gender]*LungCsIIANoD[Type,Gender,Age]"
+CMC.LungCs01PopCorr : SYSDYN.Valve
+ @L0.tag MOD.Mapped
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions
+ @L0.list
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "LungCModelPopCorrectionFactor[Gender,Age]*LungCs01[Type,Gender,Age]"
+CMC.LungCOutputsIIBNosDiagnosis : SYSDYN.Auxiliary
+ @L0.tag MOD.Mapped
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions
+ @L0.list
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "sum(LungCsIIBDiagnosis[NotSmoker,Gender!,Age!])"
+
+CMC.LungCModelPop : SYSDYN.Auxiliary
+ @L0.tag MOD.Mapped
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions
+ @L0.list
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "0.1+LungCHealthy[Gender,Age]+LungCNoDSum[Gender,Age]+sum(LungCD[Type!,Stage!,Gender,Age])+sum(LungCCured1[Type!,Stage!,Gender,Age])+sum(LungCNotProgressing1[Type!,Stage!,Gender,Age])+sum(LungCT1Progressing[Type!,Stage!,Gender,Age])+sum(LungCT1Disabling[Type!,Stage!,Gender,Age])+sum(LungCCured2[Type!,Stage!,Gender,Age])+sum(LungCNotProgressing2[Type!,Stage!,Gender,Age])+sum(LungCT2Progressing[Type!,Stage!,Gender,Age])+sum(LungCT2Disabling[Type!,Stage!,Gender,Age])"
+
+CMC.LungCProgressIIIAIIIBRate : SYSDYN.Auxiliary
+ @L0.tag MOD.Mapped
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions
+ @L0.list
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PIIIAIIIBSm')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PIIIAIIIBNs')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PIIIAIIIBNos')"
+
+CMC.LungCProgress0203 : SYSDYN.Valve
+ @L0.tag MOD.Mapped
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions
+ @L0.list
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "LungCProgress0203Rate[Type,Age,Gender]*LungCs02[Type,Gender,Age]"
+CMC.LungCOutputsIIBNosNoD : SYSDYN.Auxiliary
+ @L0.tag MOD.Mapped
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions
+ @L0.list
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "sum(LungCsIIBNoD[NotSmoker,Gender!,Age!])"
+
+CMC.LungCsIIBDiagnosis : SYSDYN.Valve
+ @L0.tag MOD.Mapped
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions
+ @L0.list
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "LungCsIIBDiagnosisRate[Type,Age,Gender]*LungCsIIBNoD[Type,Gender,Age]"
+CMC.LungCOutputs03ScNoD : SYSDYN.Auxiliary
+ @L0.tag MOD.Mapped
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions
+ @L0.list
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "sum(LungCs03[Small,Gender!,Age!])"
+
+CMC.LungCsIIIBNoDPopCorr : SYSDYN.Valve
+ @L0.tag MOD.Mapped
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions
+ @L0.list
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "LungCModelPopCorrectionFactor[Gender,Age]*LungCsIIIBNoD[Type,Gender,Age]"
+CMC.LungCsIIANoDIniVal : SYSDYN.Auxiliary
+ @L0.tag MOD.Mapped
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions
+ @L0.list
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'INdIIASm')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'INdIIANs')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'INdIIANos')"
+
+CMC.LungCProgress02IVRate : SYSDYN.Auxiliary
+ @L0.tag MOD.Mapped
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions
+ @L0.list
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'P02IVSm')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'P02IVNs')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'P02IVNos')"
+
+CMC.LungCOutputs01ScDiagnosis : SYSDYN.Auxiliary
+ @L0.tag MOD.Mapped
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions
+ @L0.list
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "sum(LungCs01Diagnosis[Small,Gender!,Age!])"
+
+CMC.LungCT2Progressing : SYSDYN.Stock
+ @L0.tag MOD.Mapped
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions
+ @L0.list
+ _ : SYSDYN.StockExpression
+ SYSDYN.HasInitialEquation "LungCT2ProgressingIniVal[Type,Stage,Age,Gender]"
+
+CMC.LungCT2Death : SYSDYN.Valve
+ @L0.tag MOD.Mapped
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions
+ @L0.list
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "LungCT2Disabling[Type,Stage,Gender,Age]*LungCT2DeathRate[Type,Stage,Age,Gender]"
+CMC.LungCOutputsIIAScDiagnosis : SYSDYN.Auxiliary
+ @L0.tag MOD.Mapped
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions
+ @L0.list
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "sum(LungCsIIADiagnosis[Small,Gender!,Age!])"
+
+CMC.LungCsIBNoD : SYSDYN.Stock
+ @L0.tag MOD.Mapped
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions
+ @L0.list
+ _ : SYSDYN.StockExpression
+ SYSDYN.HasInitialEquation "LungCsIBNoDIniVal[Type,Age,Gender]"
+
+CMC.LungCT1DisablingIniVal : SYSDYN.Auxiliary
+ @L0.tag MOD.Mapped
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions
+ @L0.list
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'IT1DiIASm')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'IT1DiIBSm')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'IT1DiIIASm')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'IT1DiIIBSm')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'IT1DiIIIASm')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'IT1DiIIIBSm')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'IT1DiIVSm')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'IT1Di01Sm')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'IT1Di02Sm')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'IT1Di03Sm')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'IT1DiIANs')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'IT1DiIBNs')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'IT1DiIIANs')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'IT1DiIIBNs')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'IT1DiIIIANs')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'IT1DiIIIBNs')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'IT1DiIVNs')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'IT1Di01Ns')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'IT1Di02Ns')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'IT1Di03Ns')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'IT1DiIANos')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'IT1DiIBNos')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'IT1DiIIANos')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'IT1DiIIBNos')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'IT1DiIIIANos')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'IT1DiIIIBNos')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'IT1DiIVNos')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'IT1Di01Nos')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'IT1Di02Nos')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'IT1Di03Nos')"
+
+CMC.LungCNotProgressing1 : SYSDYN.Stock
+ @L0.tag MOD.Mapped
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions
+ @L0.list
+ _ : SYSDYN.StockExpression
+ SYSDYN.HasInitialEquation "LungCTreated1IniVal[Type,Stage,Age,Gender]"
+
+CMC.LungCOutputsIBScDiagnosis : SYSDYN.Auxiliary
+ @L0.tag MOD.Mapped
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions
+ @L0.list
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "sum(LungCsIBDiagnosis[Small,Gender!,Age!])"
+
+CMC.LungCOutputProgressing1 : SYSDYN.Auxiliary
+ @L0.tag MOD.Mapped
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions
+ @L0.list
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "sum(LungCT1Progressing[Type!,Stage!,Gender!,Age!])"
+
+CMC.LungCProgressIIIAIV : SYSDYN.Valve
+ @L0.tag MOD.Mapped
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions
+ @L0.list
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "LungCProgressIIIAIVRate[Type,Age,Gender]*LungCsIIIANoD[Type,Gender,Age]"
+CMC.LungCProgressIAIV : SYSDYN.Valve
+ @L0.tag MOD.Mapped
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions
+ @L0.list
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "LungCProgressIAIVRate[Type,Age,Gender]*LungCsIANoD[Type,Gender,Age]"
+CMC.LungCsIADiagnosis : SYSDYN.Valve
+ @L0.tag MOD.Mapped
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions
+ @L0.list
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "LungCsIADiagnosisRate[Type,Age,Gender]*LungCsIANoD[Type,Gender,Age]"
+CMC.LungCOutputsIVNsDiagnosis : SYSDYN.Auxiliary
+ @L0.tag MOD.Mapped
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions
+ @L0.list
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "sum(LungCsIVDiagnosis[NonSmall,Gender!,Age!])"
+
+CMC.LungCOutputsIIIBNsDiagnosis : SYSDYN.Auxiliary
+ @L0.tag MOD.Mapped
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions
+ @L0.list
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "sum(LungCsIIIBDiagnosis[NonSmall,Gender!,Age!])"
+
+CMC.LungCProgress01IVRate : SYSDYN.Auxiliary
+ @L0.tag MOD.Mapped
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions
+ @L0.list
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'P01IVSm')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'P01IVNs')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'P01IVNos')"
+
+CMC.LungCProgressIIAIIB : SYSDYN.Valve
+ @L0.tag MOD.Mapped
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions
+ @L0.list
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "LungCProgressIIAIIBRate[Type,Age,Gender]*LungCsIIANoD[Type,Gender,Age]"
+CMC.LungCOutputNotProgressing1 : SYSDYN.Auxiliary
+ @L0.tag MOD.Mapped
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions
+ @L0.list
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "sum(LungCNotProgressing1[Type!,Stage!,Gender!,Age!])"
+
+CMC.LungCsIIANoDPopCorr : SYSDYN.Valve
+ @L0.tag MOD.Mapped
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions
+ @L0.list
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "LungCModelPopCorrectionFactor[Gender,Age]*LungCsIIANoD[Type,Gender,Age]"
+CMC.LungCOutputsIIBNsNoD : SYSDYN.Auxiliary
+ @L0.tag MOD.Mapped
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions
+ @L0.list
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "sum(LungCsIIBNoD[NonSmall,Gender!,Age!])"
+
+CMC.LungCProgressIIAIIBRate : SYSDYN.Auxiliary
+ @L0.tag MOD.Mapped
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions
+ @L0.list
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PIIAIIBSm')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PIIAIIBNs')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PIIAIIBNos')"
+
+CMC.LungCProgress0203Rate : SYSDYN.Auxiliary
+ @L0.tag MOD.Mapped
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions
+ @L0.list
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'P0203Sm')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'P0203Ns')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'P0203Nos')"
+
+CMC.LungCsIIBNoDPopCorr : SYSDYN.Valve
+ @L0.tag MOD.Mapped
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions
+ @L0.list
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "LungCModelPopCorrectionFactor[Gender,Age]*LungCsIIBNoD[Type,Gender,Age]"
+CMC.LungCSmokersPercentageOfPopulation : SYSDYN.Auxiliary
+ @L0.tag MOD.Mapped
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions
+ @L0.list
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_DATA('LCancer.xls', 'LungC_Risk', 'PSmokingMenT', 'PSmokingMen')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_DATA('LCancer.xls', 'LungC_Risk', 'PSmokingWomenT', 'PSmokingWomen')"
+
+CMC.LungCOutputsIVScDiagnosis : SYSDYN.Auxiliary
+ @L0.tag MOD.Mapped
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions
+ @L0.list
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "sum(LungCsIVDiagnosis[Small,Gender!,Age!])"
+
+CMC.LungCs01Ageing : SYSDYN.Valve
+ @L0.tag MOD.Mapped
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions
+ @L0.list
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "if Age==Age0 then -LungCs01[Type,Gender,Age] elseif Age==Age100 then +VECTOR_MAP(LungCs01[Type,Gender,Age], -1) else -LungCs01[Type,Gender,Age]+VECTOR_MAP(LungCs01[Type,Gender,Age], -1)*DummyRateForUnitsConversion"
+CMC.LungCOutputsIBNosNoD : SYSDYN.Auxiliary
+ @L0.tag MOD.Mapped
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions
+ @L0.list
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "sum(LungCsIBNoD[NotSmoker,Gender!,Age!])"
+
+CMC.LungCs02 : SYSDYN.Stock
+ @L0.tag MOD.Mapped
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions
+ @L0.list
+ _ : SYSDYN.StockExpression
+ SYSDYN.HasInitialEquation "LungCs02IniVal[Type,Age,Gender]"
+
+CMC.LungCCausedDeath : SYSDYN.Auxiliary
+ @L0.tag MOD.Mapped
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions
+ @L0.list
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "sum(LungCT1Death[Type!,Stage!,Gender,Age])+sum(LungCT2Death[Type!,Stage!,Gender,Age])+sum(LungCTherapy1Mortality[Type!,Stage!,Gender,Age])"
+
+CMC.LungCsIBDiagnosis : SYSDYN.Valve
+ @L0.tag MOD.Mapped
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions
+ @L0.list
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "LungCsIBNoD[Type,Gender,Age]*LungCsIBDiagnosisRate[Type,Age,Gender]"
+CMC.LungCProgressIIBIV : SYSDYN.Valve
+ @L0.tag MOD.Mapped
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions
+ @L0.list
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "LungCProgressIIBIVRate[Type,Age,Gender]*LungCsIIBNoD[Type,Gender,Age]"
+CMC.LungCOutputCured2 : SYSDYN.Auxiliary
+ @L0.tag MOD.Mapped
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions
+ @L0.list
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "sum(LungCCured2[Type!,Stage!,Gender!,Age!])"
+
+CMC.LungCsIBDiagnosisRate : SYSDYN.Auxiliary
+ @L0.tag MOD.Mapped
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions
+ @L0.list
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PDIBSm')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PDIBNs')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PDIBNos')"
+
+CMC.LungCTherapy1MortalityRatio : SYSDYN.Auxiliary
+ @L0.tag MOD.Mapped
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions
+ @L0.list
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT1Mor')"
+
+CMC.LungCTreated1PopCorr : SYSDYN.Valve
+ @L0.tag MOD.Mapped
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions
+ @L0.list
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "LungCModelPopCorrectionFactor[Gender,Age]*LungCNotProgressing1[Type,Stage,Gender,Age]"
+CMC.LungCOutputTherapy2 : SYSDYN.Auxiliary
+ @L0.tag MOD.Mapped
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions
+ @L0.list
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "sum(LungCTherapy2[Type!,Stage!,Gender!,Age!])+sum(LungCTherapyCure2[Type!,Stage!,Gender!,Age!])+sum(LungCTherapy2Failed[Type!,Stage!,Gender!,Age!])"
+
+CMC.LungCsIIBNoDIniVal : SYSDYN.Auxiliary
+ @L0.tag MOD.Mapped
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions
+ @L0.list
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'INdIIBSm')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'INdIIBNs')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'INdIIBNos')"
+
+CMC.LungCs03DiagnosisRate : SYSDYN.Auxiliary
+ @L0.tag MOD.Mapped
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions
+ @L0.list
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PD03Sm')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PD03Ns')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PD03Nos')"
+
+CMC.LungCsIIIANoDIniVal : SYSDYN.Auxiliary
+ @L0.tag MOD.Mapped
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions
+ @L0.list
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'INdIIIASm')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'INdIIIANs')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'INdIIIANos')"
+
+CMC.LungCTreated1Ageing : SYSDYN.Valve
+ @L0.tag MOD.Mapped
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions
+ @L0.list
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "if Age==Age0 then -LungCNotProgressing1[Type,Stage,Gender,Age] elseif Age==Age100 then +VECTOR_MAP(LungCNotProgressing1[Type,Stage,Gender,Age], -1) else -LungCNotProgressing1[Type,Stage,Gender,Age]+VECTOR_MAP(LungCNotProgressing1[Type,Stage,Gender,Age], -1)*DummyRateForUnitsConversion"
+CMC.LungCT2DisablingPopCorr : SYSDYN.Valve
+ @L0.tag MOD.Mapped
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions
+ @L0.list
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "LungCModelPopCorrectionFactor[Gender,Age]*LungCT2Disabling[Type,Stage,Gender,Age]"
+CMC.LungCOutputs03ScDiagnosis : SYSDYN.Auxiliary
+ @L0.tag MOD.Mapped
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions
+ @L0.list
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "sum(LungCs03Diagnosis[Small,Gender!,Age!])"
+
+CMC.LungCProgressIIIBIV : SYSDYN.Valve
+ @L0.tag MOD.Mapped
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions
+ @L0.list
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "LungCProgressIIIBIVRate[Type,Age,Gender]*LungCsIIIBNoD[Type,Gender,Age]"
+CMC.LungCProgressIIIBIVRate : SYSDYN.Auxiliary
+ @L0.tag MOD.Mapped
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions
+ @L0.list
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PIIIBIVSm')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PIIIBIVNs')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PIIIBIVNos')"
+
+CMC.LungCProgressIIIAIVRate : SYSDYN.Auxiliary
+ @L0.tag MOD.Mapped
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions
+ @L0.list
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PIIIAIVSm')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PIIIAIVNs')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PIIIAIVNos')"
+
+CMC.LungCT2ProgToDisabling : SYSDYN.Valve
+ @L0.tag MOD.Mapped
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions
+ @L0.list
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "LungCT2Progressing[Type,Stage,Gender,Age]*LungCT2ProgToDisablingRate[Type,Stage,Age,Gender]"
+CMC.LungCProgress03IVRate : SYSDYN.Auxiliary
+ @L0.tag MOD.Mapped
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions
+ @L0.list
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'P03IVSm')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'P03IVNs')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'P03IVNos')"
+
+CMC.LungCOutputs03NosNoD : SYSDYN.Auxiliary
+ @L0.tag MOD.Mapped
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions
+ @L0.list
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "sum(LungCs03[NotSmoker,Gender!,Age!])"
+
+CMC.LungCOutputsIIIAScDiagnosis : SYSDYN.Auxiliary
+ @L0.tag MOD.Mapped
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions
+ @L0.list
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "sum(LungCsIIIADiagnosis[Small,Gender!,Age!])"
+
+CMC.LungCOutputsIIBScNoD : SYSDYN.Auxiliary
+ @L0.tag MOD.Mapped
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions
+ @L0.list
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "sum(LungCsIIBNoD[Small,Gender!,Age!])"
+
+CMC.LungCOutputsIIIBNosDiagnosis : SYSDYN.Auxiliary
+ @L0.tag MOD.Mapped
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions
+ @L0.list
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "sum(LungCsIIIBDiagnosis[NotSmoker,Gender!,Age!])"
+
+CMC.Cloud45 : SYSDYN.Cloud
+
+CMC.LungCOutputs03NosDiagnosis : SYSDYN.Auxiliary
+ @L0.tag MOD.Mapped
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions
+ @L0.list
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "sum(LungCs03Diagnosis[NotSmoker,Gender!,Age!])"
+
+CMC.LungCOutputs03NsDiagnosis : SYSDYN.Auxiliary
+ @L0.tag MOD.Mapped
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions
+ @L0.list
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "sum(LungCs03Diagnosis[NonSmall,Gender!,Age!])"
+
+CMC.LungCOutputsIBNosDiagnosis : SYSDYN.Auxiliary
+ @L0.tag MOD.Mapped
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions
+ @L0.list
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "sum(LungCsIBDiagnosis[NotSmoker,Gender!,Age!])"
+
+CMC.LungCOutputsIIIANsNoD : SYSDYN.Auxiliary
+ @L0.tag MOD.Mapped
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions
+ @L0.list
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "sum(LungCsIIIANoD[NonSmall,Gender!,Age!])"
+
+CMC.LungCHealthy : SYSDYN.Stock
+ @L0.tag MOD.Mapped
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions
+ @L0.list
+ _ : SYSDYN.StockExpression
+ SYSDYN.HasInitialEquation "LungCHealthyIniVal[Age,Gender]"
+
+CMC.LungCs01DiagnosisRate : SYSDYN.Auxiliary
+ @L0.tag MOD.Mapped
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions
+ @L0.list
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PD01Sm')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PD01Ns')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PD01Nos')"
+
+CMC.LungCTreated1IniVal : SYSDYN.Auxiliary
+ @L0.tag MOD.Mapped
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions
+ @L0.list
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'IT1TrIASm')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'IT1TrIBSm')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'IT1TrIIASm')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'IT1TrIIBSm')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'IT1TrIIIASm')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'IT1TrIIIBSm')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'IT1TrIVSm')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'IT1Tr01Sm')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'IT1Tr02Sm')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'IT1Tr03Sm')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'IT1TrIANs')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'IT1TrIBNs')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'IT1TrIIANs')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'IT1TrIIBNs')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'IT1TrIIIANs')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'IT1TrIIIBNs')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'IT1TrIVNs')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'IT1Tr01Ns')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'IT1Tr02Ns')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'IT1Tr03Ns')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'IT1TrIANos')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'IT1TrIBNos')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'IT1TrIIANos')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'IT1TrIIBNos')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'IT1TrIIIANos')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'IT1TrIIIBNos')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'IT1TrIVNos')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'IT1Tr01Nos')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'IT1Tr02Nos')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'IT1Tr03Nos')"
+
+CMC.LungCProgressIBIIBRate : SYSDYN.Auxiliary
+ @L0.tag MOD.Mapped
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions
+ @L0.list
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PIBIIBSm')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PIBIIBNs')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PIBIIBNos')"
+
+CMC.LungCsIIBNoDAgeing : SYSDYN.Valve
+ @L0.tag MOD.Mapped
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions
+ @L0.list
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "if Age==Age0 then -LungCsIIBNoD[Type,Gender,Age] elseif Age==Age100 then +VECTOR_MAP(LungCsIIBNoD[Type,Gender,Age], -1) else -LungCsIIBNoD[Type,Gender,Age]+VECTOR_MAP(LungCsIIBNoD[Type,Gender,Age], -1)*DummyRateForUnitsConversion"
+CMC.LungCProgressIIIAIIIB : SYSDYN.Valve
+ @L0.tag MOD.Mapped
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions
+ @L0.list
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "LungCsIIIANoD[Type,Gender,Age]*LungCProgressIIIAIIIBRate[Type,Age,Gender]"
+CMC.LungCOutputsIVNsNoD : SYSDYN.Auxiliary
+ @L0.tag MOD.Mapped
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions
+ @L0.list
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "sum(LungCsIVNoD[NonSmall,Gender!,Age!])"
+
+CMC.LungCT1ProgressingIniVal : SYSDYN.Auxiliary
+ @L0.tag MOD.Mapped
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions
+ @L0.list
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'IT1PrIASm')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'IT1PrIBSm')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'IT1PrIIASm')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'IT1PrIIBSm')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'IT1PrIIIASm')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'IT1PrIIIBSm')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'IT1PrIVSm')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'IT1Pr01Sm')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'IT1Pr02Sm')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'IT1Pr03Sm')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'IT1PrIANs')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'IT1PrIBNs')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'IT1PrIIANs')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'IT1PrIIBNs')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'IT1PrIIIANs')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'IT1PrIIIBNs')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'IT1PrIVNs')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'IT1Pr01Ns')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'IT1Pr02Ns')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'IT1Pr03Ns')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'IT1PrIANos')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'IT1PrIBNos')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'IT1PrIIANos')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'IT1PrIIBNos')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'IT1PrIIIANos')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'IT1PrIIIBNos')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'IT1PrIVNos')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'IT1Pr01Nos')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'IT1Pr02Nos')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'IT1Pr03Nos')"
+
+CMC.LungCs02Ageing : SYSDYN.Valve
+ @L0.tag MOD.Mapped
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions
+ @L0.list
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "if Age==Age0 then -LungCs02[Type,Gender,Age] elseif Age==Age100 then +VECTOR_MAP(LungCs02[Type,Gender,Age], -1) else -LungCs02[Type,Gender,Age]+VECTOR_MAP(LungCs02[Type,Gender,Age], -1)*DummyRateForUnitsConversion"
+CMC.LungCOutputDisabling1 : SYSDYN.Auxiliary
+ @L0.tag MOD.Mapped
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions
+ @L0.list
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "sum(LungCT1Disabling[Type!,Stage!,Gender!,Age!])"
+
+CMC.LungCOutputsIIIANsDiagnosis : SYSDYN.Auxiliary
+ @L0.tag MOD.Mapped
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions
+ @L0.list
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "sum(LungCsIIIADiagnosis[NonSmall,Gender!,Age!])"
+
+CMC.LungCsIIANoDAgeing : SYSDYN.Valve
+ @L0.tag MOD.Mapped
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions
+ @L0.list
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "if Age==Age0 then -LungCsIIANoD[Type,Gender,Age] elseif Age==Age100 then +VECTOR_MAP(LungCsIIANoD[Type,Gender,Age], -1) else -LungCsIIANoD[Type,Gender,Age]+VECTOR_MAP(LungCsIIANoD[Type,Gender,Age], -1)*DummyRateForUnitsConversion"
+CMC.LungCOutputsIIIANosNoD : SYSDYN.Auxiliary
+ @L0.tag MOD.Mapped
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions
+ @L0.list
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "sum(LungCsIIIANoD[NotSmoker,Gender!,Age!])"
+
+CMC.LungCProgress03IA : SYSDYN.Valve
+ @L0.tag MOD.Mapped
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions
+ @L0.list
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "LungCProgress03IARate[Type,Age,Gender]*LungCs03[Type,Gender,Age]"
+CMC.LungCOutputsIIIANosDiagnosis : SYSDYN.Auxiliary
+ @L0.tag MOD.Mapped
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions
+ @L0.list
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "sum(LungCsIIIADiagnosis[NotSmoker,Gender!,Age!])"
+
+CMC.LungCTreated2PopCorr : SYSDYN.Valve
+ @L0.tag MOD.Mapped
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions
+ @L0.list
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "LungCModelPopCorrectionFactor[Gender,Age]*LungCNotProgressing2[Type,Stage,Gender,Age]"
+CMC.LungCsIIIBDiagnosis : SYSDYN.Valve
+ @L0.tag MOD.Mapped
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions
+ @L0.list
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "LungCsIIIBDiagnosisRate[Type,Age,Gender]*LungCsIIIBNoD[Type,Gender,Age]"
+CMC.LungCInceptionRateChanges : SYSDYN.Auxiliary
+ @L0.tag MOD.Mapped
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions
+ @L0.list
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_DATA('LCancer.xls', 'LungC_Risk', 'B', 'C147')"
+
+CMC.LungCNotProgressing2 : SYSDYN.Stock
+ @L0.tag MOD.Mapped
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions
+ @L0.list
+ _ : SYSDYN.StockExpression
+ SYSDYN.HasInitialEquation "LungCTreated2IniVal[Type,Stage,Age,Gender]"
+
+CMC.LungCProgressIIBIVRate : SYSDYN.Auxiliary
+ @L0.tag MOD.Mapped
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions
+ @L0.list
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PIIBIVSm')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PIIBIVNs')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PIIBIVNos')"
+
+CMC.LungCs02Diagnosis : SYSDYN.Valve
+ @L0.tag MOD.Mapped
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions
+ @L0.list
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "LungCs02DiagnosisRate[Type,Age,Gender]*LungCs02[Type,Gender,Age]"
+CMC.LungCFirstTreatmentRate : SYSDYN.Auxiliary
+ @L0.tag MOD.Mapped
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions
+ @L0.list
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "10"
+
+CMC.LungCCured2 : SYSDYN.Stock
+ @L0.tag MOD.Mapped
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions
+ @L0.list
+ _ : SYSDYN.StockExpression
+ SYSDYN.HasInitialEquation "LungCCured2IniVal[Type,Stage,Age,Gender]"
+
+CMC.LungCOutputs02NosNoD : SYSDYN.Auxiliary
+ @L0.tag MOD.Mapped
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions
+ @L0.list
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "sum(LungCs02[NotSmoker,Gender!,Age!])"
+
+CMC.LungCOutputs02ScNoD : SYSDYN.Auxiliary
+ @L0.tag MOD.Mapped
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions
+ @L0.list
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "sum(LungCs02[Small,Gender!,Age!])"
+
+CMC.LungCProgressIIBIIIA : SYSDYN.Valve
+ @L0.tag MOD.Mapped
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions
+ @L0.list
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "LungCProgressIIBIIIARate[Type,Age,Gender]*LungCsIIBNoD[Type,Gender,Age]"
+CMC.LungCs03Ageing : SYSDYN.Valve
+ @L0.tag MOD.Mapped
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions
+ @L0.list
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "if Age==Age0 then -LungCs03[Type,Gender,Age] elseif Age==Age100 then +VECTOR_MAP(LungCs03[Type,Gender,Age], -1) else -LungCs03[Type,Gender,Age]+VECTOR_MAP(LungCs03[Type,Gender,Age], -1)*DummyRateForUnitsConversion"
+CMC.LungCOutputNsDiagnosis : SYSDYN.Auxiliary
+ @L0.tag MOD.Mapped
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions
+ @L0.list
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "sum(LungCs01Diagnosis[NonSmall,Gender!,Age!])+sum(LungCs02Diagnosis[NonSmall,Gender!,Age!])+sum(LungCs03Diagnosis[NonSmall,Gender!,Age!])+sum(LungCsIADiagnosis[NonSmall,Gender!,Age!])+sum(LungCsIBDiagnosis[NonSmall,Gender!,Age!])+sum(LungCsIIADiagnosis[NonSmall,Gender!,Age!])+sum(LungCsIIBDiagnosis[NonSmall,Gender!,Age!])+sum(LungCsIIIADiagnosis[NonSmall,Gender!,Age!])+sum(LungCsIIIBDiagnosis[NonSmall,Gender!,Age!])+sum(LungCsIVDiagnosis[NonSmall,Gender!,Age!])"
+
+CMC.LungCTherapyCure1 : SYSDYN.Valve
+ @L0.tag MOD.Mapped
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions
+ @L0.list
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "LungCFirstTreatmentRate*(LungCD[Type,Stage,Gender,Age]*LungCTherapy1Ratio[Type,Stage,Age,Gender]*LungCTherapy1CureRatio[Type,Stage,Age,Gender])*(1-LungCTherapy1MortalityRatio/100)"
+CMC.LungCT2DisablingIniVal : SYSDYN.Auxiliary
+ @L0.tag MOD.Mapped
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions
+ @L0.list
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'IT2DiIASm')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'IT2DiIBSm')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'IT2DiIIASm')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'IT2DiIIBSm')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'IT2DiIIIASm')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'IT2DiIIIBSm')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'IT2DiIVSm')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'IT2Di01Sm')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'IT2Di02Sm')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'IT2Di03Sm')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'IT2DiIANs')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'IT2DiIBNs')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'IT2DiIIANs')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'IT2DiIIBNs')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'IT2DiIIIANs')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'IT2DiIIIBNs')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'IT2DiIVNs')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'IT2Di01Ns')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'IT2Di02Ns')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'IT2Di03Ns')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'IT2DiIANos')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'IT2DiIBNos')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'IT2DiIIANos')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'IT2DiIIBNos')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'IT2DiIIIANos')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'IT2DiIIIBNos')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'IT2DiIVNos')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'IT2Di01Nos')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'IT2Di02Nos')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'IT2Di03Nos')"
+
+CMC.LungCsIBNoDIniVal : SYSDYN.Auxiliary
+ @L0.tag MOD.Mapped
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions
+ @L0.list
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'INdIBSm')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'INdIBNs')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'INdIBNos')"
+
+CMC.LungCOutputModelPopExcludingHealthy : SYSDYN.Auxiliary
+ @L0.tag MOD.Mapped
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions
+ @L0.list
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "LungCModelPop[Gender,Age]-LungCHealthy[Gender,Age]"
+
+CMC.LungCsIIADiagnosisRate : SYSDYN.Auxiliary
+ @L0.tag MOD.Mapped
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions
+ @L0.list
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PDIIASm')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PDIIANs')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PDIIANos')"
+
+CMC.LungCProgress0102 : SYSDYN.Valve
+ @L0.tag MOD.Mapped
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions
+ @L0.list
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "LungCProgress0102Rate[Type,Age,Gender]*LungCs01[Type,Gender,Age]"
+CMC.LungCsIVNoDAgeing : SYSDYN.Valve
+ @L0.tag MOD.Mapped
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions
+ @L0.list
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "if Age==Age0 then -LungCsIVNoD[Type,Gender,Age] elseif Age==Age100 then +VECTOR_MAP(LungCsIVNoD[Type,Gender,Age], -1) else -LungCsIVNoD[Type,Gender,Age]+VECTOR_MAP(LungCsIVNoD[Type,Gender,Age], -1)*DummyRateForUnitsConversion"
+CMC.LungCModelPopCorrectionRate : SYSDYN.Auxiliary
+ @L0.tag MOD.Mapped
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions
+ @L0.list
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "0.9"
+
+CMC.LungCTherapy2 : SYSDYN.Valve
+ @L0.tag MOD.Mapped
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions
+ @L0.list
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "LungCFirstTreatmentRate*(LungCD[Type,Stage,Gender,Age]*LungCTherapy2Ratio[Type,Stage,Age,Gender]*(1-LungCTherapy2CureRatio[Type,Stage,Age,Gender]))*(1-LungCTherapy2FailRatio/100)"
+CMC.LungCsIIANoD : SYSDYN.Stock
+ @L0.tag MOD.Mapped
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions
+ @L0.list
+ _ : SYSDYN.StockExpression
+ SYSDYN.HasInitialEquation "LungCsIIANoDIniVal[Type,Age,Gender]"
+
+CMC.LungCsIIIANoD : SYSDYN.Stock
+ @L0.tag MOD.Mapped
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions
+ @L0.list
+ _ : SYSDYN.StockExpression
+ SYSDYN.HasInitialEquation "LungCsIIIANoDIniVal[Type,Age,Gender]"
+
+CMC.LungCOutputsIVNosDiagnosis : SYSDYN.Auxiliary
+ @L0.tag MOD.Mapped
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions
+ @L0.list
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "sum(LungCsIVDiagnosis[NotSmoker,Gender!,Age!])"
+
+CMC.LungCTherapy2Ratio : SYSDYN.Auxiliary
+ @L0.tag MOD.Mapped
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions
+ @L0.list
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT2Ra01Sm')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT2Ra02Sm')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT2Ra03Sm')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT2RaIASm')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT2RaIBSm')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT2RaIIASm')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT2RaIIBSm')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT2RaIIIASm')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT2RaIIIBSm')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT2RaIVSm')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT2Ra01Ns')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT2Ra02Ns')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT2Ra03Ns')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT2RaIANs')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT2RaIBNs')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT2RaIIANs')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT2RaIIBNs')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT2RaIIIANs')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT2RaIIIBNs')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT2RaIVNs')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT2Ra01Nos')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT2Ra02Nos')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT2Ra03Nos')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT2RaIANos')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT2RaIBNos')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT2RaIIANos')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT2RaIIBNos')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT2RaIIIANos')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT2RaIIIBNos')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT2RaIVNos')"
+
+CMC.LungCOutputs01NosNoD : SYSDYN.Auxiliary
+ @L0.tag MOD.Mapped
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions
+ @L0.list
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "sum(LungCs01[NotSmoker,Gender!,Age!])"
+
+CMC.LungCCured2Ageing : SYSDYN.Valve
+ @L0.tag MOD.Mapped
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions
+ @L0.list
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "if Age==Age0 then -LungCCured2[Type,Stage,Gender,Age] elseif Age==Age100 then +VECTOR_MAP(LungCCured2[Type,Stage,Gender,Age], -1) else -LungCCured2[Type,Stage,Gender,Age]+VECTOR_MAP(LungCCured2[Type,Stage,Gender,Age], -1)*DummyRateForUnitsConversion"
+CMC.LungCs03 : SYSDYN.Stock
+ @L0.tag MOD.Mapped
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions
+ @L0.list
+ _ : SYSDYN.StockExpression
+ SYSDYN.HasInitialEquation "LungCs03IniVal[Type,Age,Gender]"
+
+CMC.LungCOutputs03NsNoD : SYSDYN.Auxiliary
+ @L0.tag MOD.Mapped
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions
+ @L0.list
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "sum(LungCs03[NonSmall,Gender!,Age!])"
+
+CMC.LungCOutputsIIANosNoD : SYSDYN.Auxiliary
+ @L0.tag MOD.Mapped
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions
+ @L0.list
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "sum(LungCsIIANoD[NotSmoker,Gender!,Age!])"
+
+CMC.LungCsIIIANoDPopCorr : SYSDYN.Valve
+ @L0.tag MOD.Mapped
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions
+ @L0.list
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "LungCModelPopCorrectionFactor[Gender,Age]*LungCsIIIANoD[Type,Gender,Age]"
+CMC.LungCs01Diagnosis : SYSDYN.Valve
+ @L0.tag MOD.Mapped
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions
+ @L0.list
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "LungCs01DiagnosisRate[Type,Age,Gender]*LungCs01[Type,Gender,Age]"
+CMC.LungCOutputs02NsDiagnosis : SYSDYN.Auxiliary
+ @L0.tag MOD.Mapped
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions
+ @L0.list
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "sum(LungCs02Diagnosis[NonSmall,Gender!,Age!])"
+
+CMC.LungCOutputsIANosDiagnosis : SYSDYN.Auxiliary
+ @L0.tag MOD.Mapped
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions
+ @L0.list
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "sum(LungCsIADiagnosis[NotSmoker,Gender!,Age!])"
+
+CMC.LungCProgress02IV : SYSDYN.Valve
+ @L0.tag MOD.Mapped
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions
+ @L0.list
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "LungCProgress02IVRate[Type,Age,Gender]*LungCs02[Type,Gender,Age]"
+CMC.LungCT1Progressing : SYSDYN.Stock
+ @L0.tag MOD.Mapped
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions
+ @L0.list
+ _ : SYSDYN.StockExpression
+ SYSDYN.HasInitialEquation "LungCT1ProgressingIniVal[Type,Stage,Age,Gender]"
+
+CMC.LungCOutputTherapy1Cure : SYSDYN.Auxiliary
+ @L0.tag MOD.Mapped
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions
+ @L0.list
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "sum(LungCTherapyCure1[Type!,Stage!,Gender!,Age!])"
+
+CMC.LungCsIANoDIniVal : SYSDYN.Auxiliary
+ @L0.tag MOD.Mapped
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions
+ @L0.list
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'INdIASm')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'INdIANs')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'INdIANos')"
+
+CMC.LungCOutputsIANosNoD : SYSDYN.Auxiliary
+ @L0.tag MOD.Mapped
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions
+ @L0.list
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "sum(LungCsIANoD[NotSmoker,Gender!,Age!])"
+
+CMC.LungCOutputTherapy1MortalityInTherapy : SYSDYN.Auxiliary
+ @L0.tag MOD.Mapped
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions
+ @L0.list
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "sum(LungCTherapy1Mortality[Type!,Stage!,Gender!,Age!])"
+
+CMC.LungCTreated2Ageing : SYSDYN.Valve
+ @L0.tag MOD.Mapped
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions
+ @L0.list
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "if Age==Age0 then -LungCNotProgressing2[Type,Stage,Gender,Age] elseif Age==Age100 then +VECTOR_MAP(LungCNotProgressing2[Type,Stage,Gender,Age], -1) else -LungCNotProgressing2[Type,Stage,Gender,Age]+VECTOR_MAP(LungCNotProgressing2[Type,Stage,Gender,Age], -1)*DummyRateForUnitsConversion"
+CMC.LungCs01IniVal : SYSDYN.Auxiliary
+ @L0.tag MOD.Mapped
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions
+ @L0.list
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'INd01Sm')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'INd01Ns')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'INd01Nos')"
+
+CMC.LungCOutputDisabling2 : SYSDYN.Auxiliary
+ @L0.tag MOD.Mapped
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions
+ @L0.list
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "sum(LungCT2Disabling[Type!,Stage!,Gender!,Age!])"
+
+CMC.LungCT1ProgressesRate : SYSDYN.Auxiliary
+ @L0.tag MOD.Mapped
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions
+ @L0.list
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT1Re01Sm')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT1Re02Sm')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT1Re03Sm')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT1ReIASm')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT1ReIBSm')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT1ReIIASm')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT1ReIIBSm')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT1ReIIIASm')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT1ReIIIBSm')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT1ReIVSm')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT1Re01Ns')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT1Re02Ns')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT1Re03Ns')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT1ReIANs')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT1ReIBNs')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT1ReIIANs')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT1ReIIBNs')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT1ReIIIANs')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT1ReIIIBNs')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT1ReIVNs')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT1Re01Nos')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT1Re02Nos')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT1Re03Nos')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT1ReIANos')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT1ReIBNos')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT1ReIIANos')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT1ReIIBNos')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT1ReIIIANos')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT1ReIIIBNos')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT1ReIVNos')"
+
+CMC.LungCs02PopCorr : SYSDYN.Valve
+ @L0.tag MOD.Mapped
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions
+ @L0.list
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "LungCModelPopCorrectionFactor[Gender,Age]*LungCs02[Type,Gender,Age]"
+CMC.LungCOutputsIIAScNoD : SYSDYN.Auxiliary
+ @L0.tag MOD.Mapped
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions
+ @L0.list
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "sum(LungCsIIANoD[Small,Gender!,Age!])"
+
+CMC.LungCsIVNoDPopCorr : SYSDYN.Valve
+ @L0.tag MOD.Mapped
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions
+ @L0.list
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "LungCsIVNoD[Type,Gender,Age]*LungCModelPopCorrectionFactor[Gender,Age]"
+CMC.LungCoutputNoDNos : SYSDYN.Auxiliary
+ @L0.tag MOD.Mapped
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions
+ @L0.list
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "LungCOutputs01NosNoD+LungCOutputs02NosNoD+LungCOutputs03NosNoD+LungCOutputsIANosNoD+LungCOutputsIBNosNoD+LungCOutputsIIANosNoD+LungCOutputsIIBNosNoD+LungCOutputsIIIANosNoD+LungCOutputsIIIBNosNoD+LungCOutputsIVNosNoD"
+
+CMC.LungCOutputsIIANosDiagnosis : SYSDYN.Auxiliary
+ @L0.tag MOD.Mapped
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions
+ @L0.list
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "sum(LungCsIIADiagnosis[NotSmoker,Gender!,Age!])"
+
+CMC.LungCs01 : SYSDYN.Stock
+ @L0.tag MOD.Mapped
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions
+ @L0.list
+ _ : SYSDYN.StockExpression
+ SYSDYN.HasInitialEquation "LungCs01IniVal[Type,Age,Gender]"
+
+CMC.LungCOutputCured1 : SYSDYN.Auxiliary
+ @L0.tag MOD.Mapped
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions
+ @L0.list
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "sum(LungCCured1[Type!,Stage!,Gender!,Age!])"
+
+CMC.LungCTherapy1CureRatio : SYSDYN.Auxiliary
+ @L0.tag MOD.Mapped
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions
+ @L0.list
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT1Cr01Sm')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT1Cr02Sm')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT1Cr03Sm')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT1CrIASm')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT1CrIBSm')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT1CrIIASm')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT1CrIIBSm')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT1CrIIIASm')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT1CrIIIBSm')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT1CrIVSm')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT1Cr01Ns')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT1Cr02Ns')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT1Cr03Ns')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT1CrIANs')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT1CrIBNs')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT1CrIIANs')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT1CrIIBNs')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT1CrIIIANs')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT1CrIIIBNs')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT1CrIVNs')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT1Cr01Nos')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT1Cr02Nos')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT1Cr03Nos')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT1CrIANos')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT1CrIBNos')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT1CrIIANos')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT1CrIIBNos')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT1CrIIIANos')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT1CrIIIBNos')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT1CrIVNos')"
+
+CMC.LungCsIIIBDiagnosisRate : SYSDYN.Auxiliary
+ @L0.tag MOD.Mapped
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions
+ @L0.list
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PDIIIBSm')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PDIIIBNs')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PDIIIBNos')"
+
+CMC.LungCsIVDiagnosisRate : SYSDYN.Auxiliary
+ @L0.tag MOD.Mapped
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions
+ @L0.list
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PDIVSm')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PDIVNs')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PDIVNos')"
+
+CMC.LungCOutputsIIBNsDiagnosis : SYSDYN.Auxiliary
+ @L0.tag MOD.Mapped
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions
+ @L0.list
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "sum(LungCsIIBDiagnosis[NonSmall,Gender!,Age!])"
+
+CMC.LungCOutputModelPop : SYSDYN.Auxiliary
+ @L0.tag MOD.Mapped
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions
+ @L0.list
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "sum(LungCModelPop[Gender!,Age!])"
+
+CMC.LungCsIANoDPopCorr : SYSDYN.Valve
+ @L0.tag MOD.Mapped
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions
+ @L0.list
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "LungCModelPopCorrectionFactor[Gender,Age]*LungCsIANoD[Type,Gender,Age]"
+CMC.LungCCured2IniVal : SYSDYN.Auxiliary
+ @L0.tag MOD.Mapped
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions
+ @L0.list
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'IT2CrIASm')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'IT2CrIBSm')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'IT2CrIIASm')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'IT2CrIIBSm')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'IT2CrIIIASm')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'IT2CrIIIBSm')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'IT2CrIVSm')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'IT2Cr01Sm')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'IT2Cr02Sm')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'IT2Cr03Sm')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'IT2CrIANs')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'IT2CrIBNs')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'IT2CrIIANs')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'IT2CrIIBNs')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'IT2CrIIIANs')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'IT2CrIIIBNs')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'IT2CrIVNs')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'IT2Cr01Ns')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'IT2Cr02Ns')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'IT2Cr03Ns')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'IT2CrIANos')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'IT2CrIBNos')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'IT2CrIIANos')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'IT2CrIIBNos')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'IT2CrIIIANos')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'IT2CrIIIBNos')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'IT2CrIVNos')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'IT2Cr01Nos')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'IT2Cr02Nos')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'IT2Cr03Nos')"
+
+CMC.LungCModelPopCorrectionFactor : SYSDYN.Auxiliary
+ @L0.tag MOD.Mapped
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions
+ @L0.list
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "LungCModelPopCorrectionRate*(TotalPopulation[Gender,Age]/LungCModelPop[Gender,Age]-1)-(TotalPopulationDeath[Gender,Age]-LungCCausedDeath[Gender,Age])/LungCModelPop[Gender,Age]"
+
+CMC.LungCTherapy2FailRatio : SYSDYN.Auxiliary
+ @L0.tag MOD.Mapped
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions
+ @L0.list
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT2Fail')"
+
+CMC.LungCsIBNoDAgeing : SYSDYN.Valve
+ @L0.tag MOD.Mapped
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions
+ @L0.list
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "if Age==Age0 then -LungCsIBNoD[Type,Gender,Age] elseif Age==Age100 then +VECTOR_MAP(LungCsIBNoD[Type,Gender,Age], -1) else -LungCsIBNoD[Type,Gender,Age]+VECTOR_MAP(LungCsIBNoD[Type,Gender,Age], -1)*DummyRateForUnitsConversion"
+CMC.LungCOutputNosDiagnosis : SYSDYN.Auxiliary
+ @L0.tag MOD.Mapped
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions
+ @L0.list
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "sum(LungCs01Diagnosis[NotSmoker,Gender!,Age!])+sum(LungCs02Diagnosis[NotSmoker,Gender!,Age!])+sum(LungCs03Diagnosis[NotSmoker,Gender!,Age!])+sum(LungCsIADiagnosis[NotSmoker,Gender!,Age!])+sum(LungCsIBDiagnosis[NotSmoker,Gender!,Age!])+sum(LungCsIIADiagnosis[NotSmoker,Gender!,Age!])+sum(LungCsIIBDiagnosis[NotSmoker,Gender!,Age!])+sum(LungCsIIIADiagnosis[NotSmoker,Gender!,Age!])+sum(LungCsIIIBDiagnosis[NotSmoker,Gender!,Age!])+sum(LungCsIVDiagnosis[NotSmoker,Gender!,Age!])"
+
+CMC.LungCOutputNotProgressing2 : SYSDYN.Auxiliary
+ @L0.tag MOD.Mapped
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions
+ @L0.list
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "sum(LungCNotProgressing2[Type!,Stage!,Gender!,Age!])"
+
+CMC.LungCOutputsIIIBNosNoD : SYSDYN.Auxiliary
+ @L0.tag MOD.Mapped
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions
+ @L0.list
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "sum(LungCsIIIBNoD[NotSmoker,Gender!,Age!])"
+
+CMC.LungCProgressIIBIIIBRate : SYSDYN.Auxiliary
+ @L0.tag MOD.Mapped
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions
+ @L0.list
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PIIBIIIBSm')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PIIBIIIBNs')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PIIBIIIBNos')"
+
+CMC.LungCOutputT1Mortality : SYSDYN.Auxiliary
+ @L0.tag MOD.Mapped
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions
+ @L0.list
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "sum(LungCT1Death[Type!,Stage!,Gender!,Age!])"
+
+CMC.LungCOutputsIIIBNsNoD : SYSDYN.Auxiliary
+ @L0.tag MOD.Mapped
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions
+ @L0.list
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "sum(LungCsIIIBNoD[NonSmall,Gender!,Age!])"
+
+CMC.LungCDIniVal : SYSDYN.Auxiliary
+ @L0.tag MOD.Mapped
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions
+ @L0.list
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'IDiaIASm')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'IDiaIBSm')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'IDiaIIASm')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'IDiaIIBSm')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'IDiaIIIASm')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'IDiaIIIBSm')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'IDiaIVSm')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'IDia01Sm')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'IDia02Sm')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'IDia03Sm')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'IDiaIANs')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'IDiaIBNs')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'IDiaIIANs')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'IDiaIIBNs')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'IDiaIIIANs')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'IDiaIIIBNs')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'IDiaIVNs')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'IDia01Ns')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'IDia02Ns')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'IDia03Ns')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'IDiaIANos')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'IDiaIBNos')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'IDiaIIANos')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'IDiaIIBNos')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'IDiaIIIANos')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'IDiaIIIBNos')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'IDiaIVNos')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'IDia01Nos')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'IDia02Nos')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'IDia03Nos')"
+
+CMC.LungCOutputsIIANsNoD : SYSDYN.Auxiliary
+ @L0.tag MOD.Mapped
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions
+ @L0.list
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "sum(LungCsIIANoD[NonSmall,Gender!,Age!])"
+
+CMC.LungCProgressIIAIVRate : SYSDYN.Auxiliary
+ @L0.tag MOD.Mapped
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions
+ @L0.list
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PIIAIVSm')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PIIAIVNs')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PIIAIVNos')"
+
+CMC.LungCOutputs01ScNoD : SYSDYN.Auxiliary
+ @L0.tag MOD.Mapped
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions
+ @L0.list
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "sum(LungCs01[Small,Gender!,Age!])"
+
+CMC.LungCOutputNoDSum : SYSDYN.Auxiliary
+ @L0.tag MOD.Mapped
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions
+ @L0.list
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "sum(LungCNoDSum[Gender!,Age!])"
+
+CMC.LungCsIVNoDIniVal : SYSDYN.Auxiliary
+ @L0.tag MOD.Mapped
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions
+ @L0.list
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'INdIVSm')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'INdIVNs')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'INdIVNos')"
+
+CMC.LungCT1ProgressingPopCorr : SYSDYN.Valve
+ @L0.tag MOD.Mapped
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions
+ @L0.list
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "LungCModelPopCorrectionFactor[Gender,Age]*LungCT1Progressing[Type,Stage,Gender,Age]"
+CMC.LungCOutputTherapy1NoCure : SYSDYN.Auxiliary
+ @L0.tag MOD.Mapped
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions
+ @L0.list
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "sum(LungCTherapy1[Type!,Stage!,Gender!,Age!])"
+
+CMC.LungCOutputsIVScNoD : SYSDYN.Auxiliary
+ @L0.tag MOD.Mapped
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions
+ @L0.list
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "sum(LungCsIVNoD[Small,Gender!,Age!])"
+
+CMC.LungCProgress0102Rate : SYSDYN.Auxiliary
+ @L0.tag MOD.Mapped
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions
+ @L0.list
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'P0102Sm')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'P0102Ns')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'P0102Nos')"
+
+CMC.LungCOutputDiagnosis : SYSDYN.Auxiliary
+ @L0.tag MOD.Mapped
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions
+ @L0.list
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "sum(LungCs01Diagnosis[Type!,Gender!,Age!])+sum(LungCs02Diagnosis[Type!,Gender!,Age!])+sum(LungCs03Diagnosis[Type!,Gender!,Age!])+sum(LungCsIADiagnosis[Type!,Gender!,Age!])+sum(LungCsIBDiagnosis[Type!,Gender!,Age!])+sum(LungCsIIADiagnosis[Type!,Gender!,Age!])+sum(LungCsIIBDiagnosis[Type!,Gender!,Age!])+sum(LungCsIIIADiagnosis[Type!,Gender!,Age!])+sum(LungCsIIIBDiagnosis[Type!,Gender!,Age!])+sum(LungCsIVDiagnosis[Type!,Gender!,Age!])"
+
+CMC.LungCOutputHealthyAndTreated : SYSDYN.Auxiliary
+ @L0.tag MOD.Mapped
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions
+ @L0.list
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "sum(LungCHealthy[Gender!,Age!])+sum(LungCNotProgressing2[Type!,Stage!,Gender!,Age!])+sum(LungCNotProgressing1[Type!,Stage!,Gender!,Age!])+sum(LungCCured1[Type!,Stage!,Gender!,Age!])+sum(LungCCured2[Type!,Stage!,Gender!,Age!])"
+
+CMC.LungCOutputsIIANsDiagnosis : SYSDYN.Auxiliary
+ @L0.tag MOD.Mapped
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions
+ @L0.list
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "sum(LungCsIIADiagnosis[NonSmall,Gender!,Age!])"
+
+CMC.LungCT2DeathRate : SYSDYN.Auxiliary
+ @L0.tag MOD.Mapped
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions
+ @L0.list
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT2Mo01Sm')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT2Mo02Sm')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT2Mo03Sm')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT2MoIASm')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT2MoIBSm')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT2MoIIASm')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT2MoIIBSm')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT2MoIIIASm')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT2MoIIIBSm')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT2MoIVSm')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT2Mo01Ns')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT2Mo02Ns')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT2Mo03Ns')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT2MoIANs')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT2MoIBNs')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT2MoIIANs')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT2MoIIBNs')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT2MoIIIANs')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT2MoIIIBNs')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT2MoIVNs')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT2Mo01Nos')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT2Mo02Nos')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT2Mo03Nos')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT2MoIANos')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT2MoIBNos')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT2MoIIANos')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT2MoIIBNos')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT2MoIIIANos')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT2MoIIIBNos')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT2MoIVNos')"
+
+CMC.LungCProgressIAIBRate : SYSDYN.Auxiliary
+ @L0.tag MOD.Mapped
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions
+ @L0.list
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PIAIBSm')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PIAIBNs')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PIAIBNos')"
+
+CMC.LungCT2Deceased : SYSDYN.Stock
+ @L0.tag MOD.Mapped
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions
+ @L0.list
+ _ : SYSDYN.StockExpression
+ SYSDYN.HasInitialEquation "0"
+
+CMC.LungCs03IniVal : SYSDYN.Auxiliary
+ @L0.tag MOD.Mapped
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions
+ @L0.list
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'INd03Sm')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'INd03Ns')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'INd03Nos')"
+
+CMC.LungCOutputs01NsDiagnosis : SYSDYN.Auxiliary
+ @L0.tag MOD.Mapped
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions
+ @L0.list
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "sum(LungCs01Diagnosis[NonSmall,Gender!,Age!])"
+
+CMC.LungCOutputs02NsNoD : SYSDYN.Auxiliary
+ @L0.tag MOD.Mapped
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions
+ @L0.list
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "sum(LungCs02[NonSmall,Gender!,Age!])"
+
+CMC.LungCsIIIADiagnosis : SYSDYN.Valve
+ @L0.tag MOD.Mapped
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions
+ @L0.list
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "LungCsIIIADiagnosisRate[Type,Age,Gender]*LungCsIIIANoD[Type,Gender,Age]"
+CMC.LungCTherapy2CureRatio : SYSDYN.Auxiliary
+ @L0.tag MOD.Mapped
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions
+ @L0.list
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT2Cr01Sm')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT2Cr02Sm')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT2Cr03Sm')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT2CrIASm')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT2CrIBSm')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT2CrIIASm')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT2CrIIBSm')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT2CrIIIASm')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT2CrIIIBSm')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT2CrIVSm')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT2Cr01Ns')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT2Cr02Ns')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT2Cr03Ns')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT2CrIANs')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT2CrIBNs')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT2CrIIANs')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT2CrIIBNs')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT2CrIIIANs')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT2CrIIIBNs')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT2CrIVNs')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT2Cr01Nos')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT2Cr02Nos')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT2Cr03Nos')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT2CrIANos')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT2CrIBNos')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT2CrIIANos')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT2CrIIBNos')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT2CrIIIANos')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT2CrIIIBNos')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT2CrIVNos')"
+
+CMC.LungCHealthyIniVal : SYSDYN.Auxiliary
+ @L0.tag MOD.Mapped
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions
+ @L0.list
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'IHe')"
+
+CMC.LungCOutputMortality : SYSDYN.Auxiliary
+ @L0.tag MOD.Mapped
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions
+ @L0.list
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "sum(LungCCausedDeath[Gender!,Age!])"
+
+CMC.LungCs02IniVal : SYSDYN.Auxiliary
+ @L0.tag MOD.Mapped
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions
+ @L0.list
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'INd02Sm')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'INd02Ns')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'INd02Nos')"
+
+CMC.LungCOutputScDiagnosis : SYSDYN.Auxiliary
+ @L0.tag MOD.Mapped
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions
+ @L0.list
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "sum(LungCs01Diagnosis[Small,Gender!,Age!])+sum(LungCs02Diagnosis[Small,Gender!,Age!])+sum(LungCs03Diagnosis[Small,Gender!,Age!])+sum(LungCsIADiagnosis[Small,Gender!,Age!])+sum(LungCsIBDiagnosis[Small,Gender!,Age!])+sum(LungCsIIADiagnosis[Small,Gender!,Age!])+sum(LungCsIIBDiagnosis[Small,Gender!,Age!])+sum(LungCsIIIADiagnosis[Small,Gender!,Age!])+sum(LungCsIIIBDiagnosis[Small,Gender!,Age!])+sum(LungCsIVDiagnosis[Small,Gender!,Age!])"
+
+CMC.LungCOutputs01NsNoD : SYSDYN.Auxiliary
+ @L0.tag MOD.Mapped
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions
+ @L0.list
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "sum(LungCs01[NonSmall,Gender!,Age!])"
+
+CMC.LungCT1DeathRate : SYSDYN.Auxiliary
+ @L0.tag MOD.Mapped
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions
+ @L0.list
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT1Mo01Sm')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT1Mo02Sm')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT1Mo03Sm')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT1MoIASm')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT1MoIBSm')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT1MoIIASm')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT1MoIIBSm')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT1MoIIIASm')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT1MoIIIBSm')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT1MoIVSm')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT1Mo01Ns')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT1Mo02Ns')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT1Mo03Ns')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT1MoIANs')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT1MoIBNs')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT1MoIIANs')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT1MoIIBNs')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT1MoIIIANs')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT1MoIIIBNs')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT1MoIVNs')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT1Mo01Nos')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT1Mo02Nos')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT1Mo03Nos')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT1MoIANos')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT1MoIBNos')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT1MoIIANos')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT1MoIIBNos')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT1MoIIIANos')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT1MoIIIBNos')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT1MoIVNos')"
+
+CMC.LungCProgressIAIIARate : SYSDYN.Auxiliary
+ @L0.tag MOD.Mapped
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions
+ @L0.list
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PIAIIASm')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PIAIIANs')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PIAIIANos')"
+
+CMC.LungCsIIIBNoDIniVal : SYSDYN.Auxiliary
+ @L0.tag MOD.Mapped
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions
+ @L0.list
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'INdIIIBSm')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'INdIIIBNs')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'INdIIIBNos')"
+
+CMC.LungCOutputs01NosDiagnosis : SYSDYN.Auxiliary
+ @L0.tag MOD.Mapped
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions
+ @L0.list
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "sum(LungCs01Diagnosis[NotSmoker,Gender!,Age!])"
+
+CMC.LungCInceptionRate : SYSDYN.Auxiliary
+ @L0.tag MOD.Mapped
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions
+ @L0.list
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PIncSm')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PIncNs')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PIncNos')"
+
+CMC.LungCs02DiagnosisRate : SYSDYN.Auxiliary
+ @L0.tag MOD.Mapped
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions
+ @L0.list
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PD02Sm')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PD02Ns')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PD02Nos')"
+
+CMC.LungCNoDSum : SYSDYN.Auxiliary
+ @L0.tag MOD.Mapped
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions
+ @L0.list
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "sum(LungCs01[Type!,Gender,Age])+sum(LungCs02[Type!,Gender,Age])+sum(LungCs03[Type!,Gender,Age])+sum(LungCsIANoD[Type!,Gender,Age])+sum(LungCsIBNoD[Type!,Gender,Age])+sum(LungCsIIANoD[Type!,Gender,Age])+sum(LungCsIIBNoD[Type!,Gender,Age])+sum(LungCsIIIANoD[Type!,Gender,Age])+sum(LungCsIIIBNoD[Type!,Gender,Age])+sum(LungCsIVNoD[Type!,Gender,Age])"
+
+CMC.LungCOutputsIIIAScNoD : SYSDYN.Auxiliary
+ @L0.tag MOD.Mapped
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions
+ @L0.list
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "sum(LungCsIIIANoD[Small,Gender!,Age!])"
+
+CMC.LungCHealthyAgeing : SYSDYN.Valve
+ @L0.tag MOD.Mapped
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions
+ @L0.list
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "(if Age==Age0 then -LungCHealthy[Gender,Age] elseif Age==Age100 then +VECTOR_MAP(LungCHealthy[Gender,Age], -1) else -LungCHealthy[Gender,Age]+VECTOR_MAP(LungCHealthy[Gender,Age], -1))*DummyRateForUnitsConversion"
+CMC.LungCsIVNoD : SYSDYN.Stock
+ @L0.tag MOD.Mapped
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions
+ @L0.list
+ _ : SYSDYN.StockExpression
+ SYSDYN.HasInitialEquation "LungCsIVNoDIniVal[Type,Age,Gender]"
+
+CMC.LungCOutputsIIIBScNoD : SYSDYN.Auxiliary
+ @L0.tag MOD.Mapped
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions
+ @L0.list
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "sum(LungCsIIIBNoD[Small,Gender!,Age!])"
+
+CMC.LungCOutputs02ScDiagnosis : SYSDYN.Auxiliary
+ @L0.tag MOD.Mapped
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions
+ @L0.list
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "sum(LungCs02Diagnosis[Small,Gender!,Age!])"
+
+CMC.LungCOutputsIBNsNoD : SYSDYN.Auxiliary
+ @L0.tag MOD.Mapped
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions
+ @L0.list
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "sum(LungCsIBNoD[NonSmall,Gender!,Age!])"
+
+CMC.LungCT2ProgToDisablingRate : SYSDYN.Auxiliary
+ @L0.tag MOD.Mapped
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions
+ @L0.list
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT2Di01Sm')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT2Di02Sm')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT2Di03Sm')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT2DiIASm')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT2DiIBSm')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT2DiIIASm')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT2DiIIBSm')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT2DiIIIASm')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT2DiIIIBSm')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT2DiIVSm')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT2Di01Ns')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT2Di02Ns')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT2Di03Ns')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT2DiIANs')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT2DiIBNs')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT2DiIIANs')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT2DiIIBNs')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT2DiIIIANs')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT2DiIIIBNs')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT2DiIVNs')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT2Di01Nos')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT2Di02Nos')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT2Di03Nos')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT2DiIANos')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT2DiIBNos')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT2DiIIANos')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT2DiIIBNos')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT2DiIIIANos')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT2DiIIIBNos')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PT2DiIVNos')"
+
+CMC.LungCOutputsIAScNoD : SYSDYN.Auxiliary
+ @L0.tag MOD.Mapped
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions
+ @L0.list
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "sum(LungCsIANoD[Small,Gender!,Age!])"
+
+CMC.LungCCured1IniVal : SYSDYN.Auxiliary
+ @L0.tag MOD.Mapped
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions
+ @L0.list
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'IT1CrIASm')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'IT1CrIBSm')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'IT1CrIIASm')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'IT1CrIIBSm')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'IT1CrIIIASm')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'IT1CrIIIBSm')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'IT1CrIVSm')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'IT1Cr01Sm')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'IT1Cr02Sm')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'IT1Cr03Sm')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'IT1CrIANs')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'IT1CrIBNs')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'IT1CrIIANs')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'IT1CrIIBNs')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'IT1CrIIIANs')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'IT1CrIIIBNs')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'IT1CrIVNs')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'IT1Cr01Ns')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'IT1Cr02Ns')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'IT1Cr03Ns')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'IT1CrIANos')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'IT1CrIBNos')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'IT1CrIIANos')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'IT1CrIIBNos')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'IT1CrIIIANos')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'IT1CrIIIBNos')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'IT1CrIVNos')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'IT1Cr01Nos')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'IT1Cr02Nos')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'IT1Cr03Nos')"
+
+CMC.LungCOutputT2Mortality : SYSDYN.Auxiliary
+ @L0.tag MOD.Mapped
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions
+ @L0.list
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "sum(LungCT2Death[Type!,Stage!,Gender!,Age!])"
+
+CMC.LungCOutputTherapy2NoCure : SYSDYN.Auxiliary
+ @L0.tag MOD.Mapped
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions
+ @L0.list
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "sum(LungCTherapy2[Type!,Stage!,Gender!,Age!])"
+
+CMC.LungCOutputsIBScNoD : SYSDYN.Auxiliary
+ @L0.tag MOD.Mapped
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions
+ @L0.list
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "sum(LungCsIBNoD[Small,Gender!,Age!])"
+
+CMC.LungCOutputsIIBScDiagnosis : SYSDYN.Auxiliary
+ @L0.tag MOD.Mapped
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions
+ @L0.list
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "sum(LungCsIIBDiagnosis[Small,Gender!,Age!])"
+
+CMC.LungCsIIBNoD : SYSDYN.Stock
+ @L0.tag MOD.Mapped
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions
+ @L0.list
+ _ : SYSDYN.StockExpression
+ SYSDYN.HasInitialEquation "LungCsIIBNoDIniVal[Type,Age,Gender]"
+
+CMC.LungCT2ProgressingIniVal : SYSDYN.Auxiliary
+ @L0.tag MOD.Mapped
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions
+ @L0.list
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'IT2PrIASm')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'IT2PrIBSm')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'IT2PrIIASm')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'IT2PrIIBSm')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'IT2PrIIIASm')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'IT2PrIIIBSm')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'IT2PrIVSm')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'IT2Pr01Sm')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'IT2Pr02Sm')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'IT2Pr03Sm')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'IT2PrIANs')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'IT2PrIBNs')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'IT2PrIIANs')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'IT2PrIIBNs')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'IT2PrIIIANs')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'IT2PrIIIBNs')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'IT2PrIVNs')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'IT2Pr01Ns')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'IT2Pr02Ns')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'IT2Pr03Ns')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'IT2PrIANos')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'IT2PrIBNos')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'IT2PrIIANos')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'IT2PrIIBNos')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'IT2PrIIIANos')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'IT2PrIIIBNos')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'IT2PrIVNos')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'IT2Pr01Nos')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'IT2Pr02Nos')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'IT2Pr03Nos')"
+
+CMC.LungCOutputTherapy2Failed : SYSDYN.Auxiliary
+ @L0.tag MOD.Mapped
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions
+ @L0.list
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "sum(LungCTherapy2Failed[Type!,Stage!,Gender!,Age!])"
+
+CMC.LungCOutputsIVNosNoD : SYSDYN.Auxiliary
+ @L0.tag MOD.Mapped
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions
+ @L0.list
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "sum(LungCsIVNoD[NotSmoker,Gender!,Age!])"
+
+CMC.LungCsIANoD : SYSDYN.Stock
+ @L0.tag MOD.Mapped
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions
+ @L0.list
+ _ : SYSDYN.StockExpression
+ SYSDYN.HasInitialEquation "LungCsIANoDIniVal[Type,Age,Gender]"
+
+CMC.LungCT2Disabling : SYSDYN.Stock
+ @L0.tag MOD.Mapped
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions
+ @L0.list
+ _ : SYSDYN.StockExpression
+ SYSDYN.HasInitialEquation "LungCT2DisablingIniVal[Type,Stage,Age,Gender]"
+
+CMC.LungCProgressIIAIIIARate : SYSDYN.Auxiliary
+ @L0.tag MOD.Mapped
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions
+ @L0.list
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PIIAIIIASm')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PIIAIIIANs')"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_CONSTANT('LCancer.xls', 'LungC_In', 'PIIAIIIANos')"
+
+CMC.LungCD : SYSDYN.Stock
+ @L0.tag MOD.Mapped
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions
+ @L0.list
+ _ : SYSDYN.StockExpression
+ SYSDYN.HasInitialEquation "LungCDIniVal[Type,sIA,Age,Gender]"
+ _ : SYSDYN.StockExpression
+ SYSDYN.HasInitialEquation "LungCDIniVal[Type,sIB,Age,Gender]"
+ _ : SYSDYN.StockExpression
+ SYSDYN.HasInitialEquation "LungCDIniVal[Type,sIIA,Age,Gender]"
+ _ : SYSDYN.StockExpression
+ SYSDYN.HasInitialEquation "LungCDIniVal[Type,sIIB,Age,Gender]"
+ _ : SYSDYN.StockExpression
+ SYSDYN.HasInitialEquation "LungCDIniVal[Type,sIIIA,Age,Gender]"
+ _ : SYSDYN.StockExpression
+ SYSDYN.HasInitialEquation "LungCDIniVal[Type,sIIIB,Age,Gender]"
+ _ : SYSDYN.StockExpression
+ SYSDYN.HasInitialEquation "LungCDIniVal[Type,sIV,Age,Gender]"
+ _ : SYSDYN.StockExpression
+ SYSDYN.HasInitialEquation "LungCDIniVal[Type,s03,Age,Gender]"
+ _ : SYSDYN.StockExpression
+ SYSDYN.HasInitialEquation "LungCDIniVal[Type,s02,Age,Gender]"
+ _ : SYSDYN.StockExpression
+ SYSDYN.HasInitialEquation "LungCDIniVal[Type,s01,Age,Gender]"
+
+CMC.d127 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCModelPop CMC.LungCD
+CMC.d882 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCoutputNoDNos CMC.LungCOutputs01NosNoD
+CMC.d331 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCsIIANoDAgeing CMC.DummyRateForUnitsConversion
+CMC.d737 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCOutputNosDiagnosis CMC.LungCs02Diagnosis
+CMC.f580 : SYSDYN.Flow
+ @WM.conf_dependency CMC.LungCsIVNoD CMC.LungCProgressIIIBIV
+CMC.f805 : SYSDYN.Flow
+ @WM.conf_dependency CMC.LungCTherapyCure1 CMC.LungCD
+CMC.d84 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCT1Progresses CMC.LungCNotProgressing1
+CMC.d463 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCModelPop CMC.LungCNotProgressing2
+CMC.f517 : SYSDYN.Flow
+ @WM.conf_dependency CMC.LungCsIVNoD CMC.LungCProgress03IV
+CMC.d458 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCNoDSum CMC.LungCsIIIBNoD
+CMC.d451 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCNoDSum CMC.LungCs02
+CMC.d220 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCT1ProgressingPopCorr CMC.LungCModelPopCorrectionFactor
+CMC.d454 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCNoDSum CMC.LungCsIBNoD
+CMC.d846 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCOutputTherapy1 CMC.LungCTherapyCure1
+CMC.d722 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCOutputNsDiagnosis CMC.LungCsIVDiagnosis
+CMC.d578 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCProgressIIIBIV CMC.LungCsIIIBNoD
+CMC.d695 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCOutputs03NsDiagnosis CMC.LungCs03Diagnosis
+CMC.d728 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCOutputScDiagnosis CMC.LungCsIIADiagnosis
+CMC.d742 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCOutputNosDiagnosis CMC.LungCsIIBDiagnosis
+CMC.d378 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCsIBDiagnosis CMC.LungCsIBNoD
+CMC.d325 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCsIIANoDPopCorr CMC.LungCsIIANoD
+CMC.f29 : SYSDYN.Flow
+ @WM.conf_dependency CMC.LungCT1Progressing CMC.LungCT1Progresses
+CMC.d889 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCoutputNoDNos CMC.LungCOutputsIIIANosNoD
+CMC.d572 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCProgressIIAIV CMC.LungCsIIANoD
+CMC.f540 : SYSDYN.Flow
+ @WM.conf_dependency CMC.LungCProgressIIIBIV CMC.LungCsIIIBNoD
+CMC.d58 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCInception CMC.LungCHealthy
+CMC.d211 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCT1Death CMC.LungCT1DeathRate
+CMC.f15 : SYSDYN.Flow
+ @WM.conf_dependency CMC.LungCs02 CMC.LungCProgress0102
+CMC.d861 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCOutputNoDNs CMC.LungCOutputs01NsNoD
+CMC.f337 : SYSDYN.Flow
+ @WM.conf_dependency CMC.LungCsIIBNoD CMC.LungCsIIBNoDAgeing
+CMC.d101 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCTreated1Ageing CMC.DummyRateForUnitsConversion
+CMC.d340 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCsIIBNoDAgeing CMC.LungCsIIBNoD
+CMC.f76 : SYSDYN.Flow
+ @WM.conf_dependency CMC.LungCNotProgressing1 CMC.LungCTreated1Ageing
+CMC.d62 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCs01Ageing CMC.LungCs01
+CMC.d833 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCCured2Ageing CMC.DummyRateForUnitsConversion
+CMC.d571 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCProgressIIAIV CMC.LungCProgressIIAIVRate
+CMC.f139 : SYSDYN.Flow
+ @WM.conf_dependency CMC.LungCs01 CMC.LungCs01PopCorr
+CMC.d129 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCModelPopCorrectionFactor CMC.TotalPopulationDeath
+CMC.d917 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCTherapyCure2 CMC.LungCTherapy2FailRatio
+CMC.d926 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCOutputTherapy2Failed CMC.LungCTherapy2Failed
+CMC.d548 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCsIIANoD CMC.LungCsIIANoDIniVal
+CMC.f495 : SYSDYN.Flow
+ @WM.conf_dependency CMC.LungCD CMC.LungCs02Diagnosis
+CMC.d739 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCOutputNosDiagnosis CMC.LungCsIADiagnosis
+CMC.d876 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCOutputNoDSc CMC.LungCOutputsIBScNoD
+CMC.d662 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCOutputs02ScNoD CMC.LungCs02
+CMC.d783 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCOutputsIIIANosDiagnosis CMC.LungCsIIIADiagnosis
+CMC.d758 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCOutputs03NosNoD CMC.LungCs03
+CMC.f236 : SYSDYN.Flow
+ @WM.conf_dependency CMC.LungCsIANoD CMC.LungCProgress03IA
+CMC.d706 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCOutputsIIIAScDiagnosis CMC.LungCsIIIADiagnosis
+CMC.f348 : SYSDYN.Flow
+ @WM.conf_dependency CMC.LungCsIIIANoD CMC.LungCsIIIANoDAgeing
+CMC.f145 : SYSDYN.Flow
+ @WM.conf_dependency CMC.LungCsIANoD CMC.LungCsIANoDPopCorr
+CMC.d627 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCOutputProgressing2 CMC.LungCT2Progressing
+CMC.d715 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCOutputNsDiagnosis CMC.LungCs03Diagnosis
+CMC.f23 : SYSDYN.Flow
+ @WM.conf_dependency CMC.LungCNotProgressing1 CMC.LungCTherapy1
+CMC.f364 : SYSDYN.Flow
+ @WM.conf_dependency CMC.LungCsIVNoD CMC.LungCsIVNoDAgeing
+CMC.d96 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCTherapy2 CMC.LungCFirstTreatmentRate
+CMC.d486 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCNotProgressing1 CMC.LungCTreated1IniVal
+CMC.f509 : SYSDYN.Flow
+ @WM.conf_dependency CMC.LungCsIVNoD CMC.LungCProgress01IV
+CMC.d160 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCTreated2PopCorr CMC.LungCModelPopCorrectionFactor
+CMC.d569 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCProgressIBIV CMC.LungCProgressIBIVRate
+CMC.d367 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCsIVNoDAgeing CMC.LungCsIVNoD
+CMC.d716 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCOutputNsDiagnosis CMC.LungCsIADiagnosis
+CMC.d391 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCsIIBDiagnosis CMC.LungCsIIBDiagnosisRate
+CMC.d778 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCOutputs03NosDiagnosis CMC.LungCs03Diagnosis
+CMC.d743 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCOutputNosDiagnosis CMC.LungCsIIIADiagnosis
+CMC.d720 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCOutputNsDiagnosis CMC.LungCsIIIADiagnosis
+CMC.d723 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCOutputScDiagnosis CMC.LungCs01Diagnosis
+CMC.d453 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCNoDSum CMC.LungCsIANoD
+CMC.d180 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCT2ProgressingAgeing CMC.DummyRateForUnitsConversion
+CMC.d244 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCProgress0203 CMC.LungCs02
+CMC.d351 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCsIIIANoDAgeing CMC.DummyRateForUnitsConversion
+CMC.f246 : SYSDYN.Flow
+ @WM.conf_dependency CMC.LungCs02 CMC.LungCs02PopCorr
+CMC.d488 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCT1Disabling CMC.LungCT1DisablingIniVal
+CMC.d835 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCCured2PopCorr CMC.LungCModelPopCorrectionFactor
+CMC.d415 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCProgressIAIB CMC.LungCProgressIAIBRate
+CMC.d452 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCNoDSum CMC.LungCs03
+CMC.f342 : SYSDYN.Flow
+ @WM.conf_dependency CMC.LungCsIIIANoD CMC.LungCsIIIANoDPopCorr
+CMC.d862 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCOutputNoDNs CMC.LungCOutputs02NsNoD
+CMC.f579 : SYSDYN.Flow
+ @WM.conf_dependency CMC.LungCsIVNoD CMC.LungCProgressIIIAIV
+CMC.f295 : SYSDYN.Flow
+ @WM.conf_dependency CMC.LungCProgressIIBIIIA CMC.LungCsIIBNoD
+CMC.d341 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCsIIBNoDAgeing CMC.DummyRateForUnitsConversion
+CMC.d87 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCT1Progresses CMC.LungCT1ProgressesRate
+CMC.d508 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCs01Diagnosis CMC.LungCs01DiagnosisRate
+CMC.d221 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCT1ProgressingPopCorr CMC.LungCT1Progressing
+CMC.d64 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCProgress0102 CMC.LungCProgress0102Rate
+CMC.d417 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCProgressIBIIB CMC.LungCProgressIBIIBRate
+CMC.f12 : SYSDYN.Flow
+ @WM.conf_dependency CMC.LungCInception CMC.LungCHealthy
+CMC.d881 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCOutputNoDSc CMC.LungCOutputsIVScNoD
+CMC.d765 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCOutputsIVNosNoD CMC.LungCsIVNoD
+CMC.d784 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCOutputsIIIBNosDiagnosis CMC.LungCsIIIBDiagnosis
+CMC.d507 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCs01Diagnosis CMC.LungCs01
+CMC.d405 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCsIIADiagnosis CMC.LungCsIIANoD
+CMC.d573 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCProgressIIBIV CMC.LungCProgressIIBIVRate
+CMC.f237 : SYSDYN.Flow
+ @WM.conf_dependency CMC.LungCProgress03IA CMC.LungCs03
+CMC.f370 : SYSDYN.Flow
+ @WM.conf_dependency CMC.LungCsIVNoD CMC.LungCsIVNoDPopCorr
+CMC.f309 : SYSDYN.Flow
+ @WM.conf_dependency CMC.LungCsIBNoD CMC.LungCsIBNoDPopCorr
+CMC.d762 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCOutputsIIBNosNoD CMC.LungCsIIBNoD
+CMC.d734 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCInception CMC.LungCInceptionRateChanges
+CMC.d875 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCOutputNoDSc CMC.LungCOutputsIAScNoD
+CMC.d567 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCProgress03IV CMC.LungCs03
+CMC.d116 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCCausedDeath CMC.LungCT2Death
+CMC.d144 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCs01PopCorr CMC.LungCs01
+CMC.d914 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCTherapy2Failed CMC.LungCFirstTreatmentRate
+CMC.d380 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCsIBDiagnosis CMC.LungCsIBDiagnosisRate
+CMC.d100 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCs01Ageing CMC.DummyRateForUnitsConversion
+CMC.f824 : SYSDYN.Flow
+ @WM.conf_dependency CMC.LungCCured2 CMC.LungCCured2PopCorr
+CMC.d661 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCOutputs01ScNoD CMC.LungCs01
+CMC.f286 : SYSDYN.Flow
+ @WM.conf_dependency CMC.LungCsIIBNoD CMC.LungCProgressIIAIIB
+CMC.d800 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCCured1PopCorr CMC.LungCCured1
+CMC.f381 : SYSDYN.Flow
+ @WM.conf_dependency CMC.LungCsIIADiagnosis CMC.LungCsIIANoD
+CMC.d581 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCsIVNoD CMC.LungCsIVNoDIniVal
+CMC.d308 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCProgressIIIAIIIB CMC.LungCsIIIANoD
+CMC.f392 : SYSDYN.Flow
+ @WM.conf_dependency CMC.LungCsIIIADiagnosis CMC.LungCsIIIANoD
+CMC.f177 : SYSDYN.Flow
+ @WM.conf_dependency CMC.LungCT2Progressing CMC.LungCT2ProgressingAgeing
+CMC.f496 : SYSDYN.Flow
+ @WM.conf_dependency CMC.LungCs02Diagnosis CMC.LungCs02
+CMC.d605 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCOutputDiagnosis CMC.LungCsIBDiagnosis
+CMC.d373 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCsIVNoDPopCorr CMC.LungCModelPopCorrectionFactor
+CMC.d607 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCOutputDiagnosis CMC.LungCsIIBDiagnosis
+CMC.d813 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCModelPop CMC.LungCCured1
+CMC.f42 : SYSDYN.Flow
+ @WM.conf_dependency CMC.LungCT2Death CMC.LungCT2Disabling
+CMC.f205 : SYSDYN.Flow
+ @WM.conf_dependency CMC.LungCT1Death CMC.LungCT1Disabling
+CMC.d759 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCOutputsIANosNoD CMC.LungCsIANoD
+CMC.d644 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCOutputsIANsNoD CMC.LungCsIANoD
+CMC.d851 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCOutputTherapy2Cure CMC.LungCTherapyCure2
+CMC.d927 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCCausedDeath CMC.LungCTherapy1Mortality
+CMC.d694 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCOutputs02ScDiagnosis CMC.LungCs02Diagnosis
+CMC.d213 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCT1Death CMC.LungCT1Disabling
+CMC.d51 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCBirth CMC.TotalPopulationBirth
+CMC.d456 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCNoDSum CMC.LungCsIIBNoD
+CMC.d568 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCProgressIAIV CMC.LungCsIANoD
+CMC.d874 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCOutputNoDSc CMC.LungCOutputs03ScNoD
+CMC.d171 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCT2ProgressingPopCorr CMC.LungCT2Progressing
+CMC.d916 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCTherapy2Failed CMC.LungCTherapy2FailRatio
+CMC.f386 : SYSDYN.Flow
+ @WM.conf_dependency CMC.LungCsIIBDiagnosis CMC.LungCsIIBNoD
+CMC.d796 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCCured1Ageing CMC.LungCCured1
+CMC.f200 : SYSDYN.Flow
+ @WM.conf_dependency CMC.LungCT1Disabling CMC.LungCT1ProgToDisabling
+CMC.f525 : SYSDYN.Flow
+ @WM.conf_dependency CMC.LungCsIVNoD CMC.LungCProgressIBIV
+CMC.d787 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCInception CMC.LungCSmokersPercentageOfPopulation
+CMC.d161 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCTreated2PopCorr CMC.LungCNotProgressing2
+CMC.d919 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCTherapy2Failed CMC.LungCTherapy2Ratio
+CMC.f534 : SYSDYN.Flow
+ @WM.conf_dependency CMC.LungCProgressIIBIV CMC.LungCsIIBNoD
+CMC.d744 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCOutputNosDiagnosis CMC.LungCsIIIBDiagnosis
+CMC.f20 : SYSDYN.Flow
+ @WM.conf_dependency CMC.LungCsIADiagnosis CMC.LungCsIANoD
+CMC.d888 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCoutputNoDNos CMC.LungCOutputsIIBNosNoD
+CMC.d557 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCProgress02IV CMC.LungCs02
+CMC.d718 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCOutputNsDiagnosis CMC.LungCsIIADiagnosis
+CMC.d468 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCModelPop CMC.LungCNoDSum
+CMC.d700 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCOutputsIBScDiagnosis CMC.LungCsIBDiagnosis
+CMC.f287 : SYSDYN.Flow
+ @WM.conf_dependency CMC.LungCProgressIIAIIB CMC.LungCsIIANoD
+CMC.f475 : SYSDYN.Flow
+ @WM.conf_dependency CMC.LungCTherapy2 CMC.LungCD
+CMC.d868 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCOutputNoDNs CMC.LungCOutputsIIIANsNoD
+CMC.f294 : SYSDYN.Flow
+ @WM.conf_dependency CMC.LungCsIIIANoD CMC.LungCProgressIIBIIIA
+CMC.d413 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCProgressIIIAIIIB CMC.LungCProgressIIIAIIIBRate
+CMC.d932 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCOutputRelapse CMC.LungCT2Progresses
+CMC.d764 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCOutputsIIIBNosNoD CMC.LungCsIIIBNoD
+CMC.f275 : SYSDYN.Flow
+ @WM.conf_dependency CMC.LungCsIBNoD CMC.LungCProgressIAIB
+CMC.d803 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCCured1PopCorr CMC.LungCModelPopCorrectionFactor
+CMC.d606 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCOutputDiagnosis CMC.LungCsIIADiagnosis
+CMC.d724 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCOutputScDiagnosis CMC.LungCs02Diagnosis
+CMC.d691 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCOutputs01NsDiagnosis CMC.LungCs01Diagnosis
+CMC.d666 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCOutputsIIAScNoD CMC.LungCsIIANoD
+CMC.d432 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCsIVDiagnosis CMC.LungCsIVDiagnosisRate
+CMC.d346 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCsIIIANoDPopCorr CMC.LungCModelPopCorrectionFactor
+CMC.f911 : SYSDYN.Flow
+ @WM.conf_dependency CMC.LungCTherapy2Failed CMC.LungCD
+CMC.d907 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCOutputTherapy1 CMC.LungCTherapy1Mortality
+CMC.d708 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCOutputsIIIBScDiagnosis CMC.LungCsIIIBDiagnosis
+CMC.d650 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCOutputsIVNsNoD CMC.LungCsIVNoD
+CMC.d710 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCOutputsIVScDiagnosis CMC.LungCsIVDiagnosis
+CMC.f895 : SYSDYN.Flow
+ @WM.conf_dependency CMC.LungCT1Deceased CMC.LungCTherapy1Mortality
+CMC.d856 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCOutputHealthyAndTreated CMC.LungCCured1
+CMC.d69 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCsIANoDAgeing CMC.LungCsIANoD
+CMC.d664 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCOutputsIAScNoD CMC.LungCsIANoD
+CMC.d545 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCs03 CMC.LungCs03IniVal
+CMC.f191 : SYSDYN.Flow
+ @WM.conf_dependency CMC.LungCsIIANoD CMC.LungCProgressIAIIA
+CMC.f224 : SYSDYN.Flow
+ @WM.conf_dependency CMC.LungCT1Disabling CMC.LungCT1DisablingPopCorr
+CMC.d187 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCOutputModelPop CMC.LungCModelPop
+CMC.d646 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCOutputsIIANsNoD CMC.LungCsIIANoD
+CMC.d262 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCs03PopCorr CMC.LungCs03
+CMC.d79 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCTreated1Ageing CMC.LungCNotProgressing1
+CMC.d212 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCT1ProgToDisabling CMC.LungCT1Progressing
+CMC.d352 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCsIIIANoDAgeing CMC.LungCsIIIANoD
+CMC.d126 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCModelPop CMC.LungCHealthy
+CMC.d251 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCs02PopCorr CMC.LungCs02
+CMC.f426 : SYSDYN.Flow
+ @WM.conf_dependency CMC.LungCD CMC.LungCsIIIBDiagnosis
+CMC.f279 : SYSDYN.Flow
+ @WM.conf_dependency CMC.LungCProgressIBIIB CMC.LungCsIBNoD
+CMC.d176 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCT2DisablingPopCorr CMC.LungCT2Disabling
+CMC.d256 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCs02Ageing CMC.DummyRateForUnitsConversion
+CMC.d810 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCTherapy1 CMC.LungCTherapy1CureRatio
+CMC.d574 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCProgressIIBIV CMC.LungCsIIBNoD
+CMC.d170 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCT2ProgressingPopCorr CMC.LungCModelPopCorrectionFactor
+CMC.f33 : SYSDYN.Flow
+ @WM.conf_dependency CMC.LungCT2Progressing CMC.LungCT2Progresses
+CMC.d920 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCTherapy2Failed CMC.LungCD
+CMC.f428 : SYSDYN.Flow
+ @WM.conf_dependency CMC.LungCD CMC.LungCsIVDiagnosis
+CMC.d887 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCoutputNoDNos CMC.LungCOutputsIIANosNoD
+CMC.d227 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCT1DisablingPopCorr CMC.LungCModelPopCorrectionFactor
+CMC.f26 : SYSDYN.Flow
+ @WM.conf_dependency CMC.LungCNotProgressing2 CMC.LungCTherapy2
+CMC.d99 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCHealthyAgeing CMC.DummyRateForUnitsConversion
+CMC.d566 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCProgressIAIV CMC.LungCProgressIAIVRate
+CMC.f526 : SYSDYN.Flow
+ @WM.conf_dependency CMC.LungCProgressIBIV CMC.LungCsIBNoD
+CMC.d72 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCsIADiagnosis CMC.LungCsIADiagnosisRate
+CMC.d869 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCOutputNoDNs CMC.LungCOutputsIIIANsNoD
+CMC.d806 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCTherapyCure1 CMC.LungCFirstTreatmentRate
+CMC.d255 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCs02Ageing CMC.LungCs02
+CMC.d500 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCs02Diagnosis CMC.LungCs02DiagnosisRate
+CMC.f790 : SYSDYN.Flow
+ @WM.conf_dependency CMC.LungCCured1 CMC.LungCTherapyCure1
+CMC.f533 : SYSDYN.Flow
+ @WM.conf_dependency CMC.LungCsIVNoD CMC.LungCProgressIIBIV
+CMC.d918 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCTherapy2 CMC.LungCTherapy2FailRatio
+CMC.d604 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCOutputDiagnosis CMC.LungCsIADiagnosis
+CMC.d556 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCProgress02IV CMC.LungCProgress02IVRate
+CMC.d717 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCOutputNsDiagnosis CMC.LungCsIBDiagnosis
+CMC.f232 : SYSDYN.Flow
+ @WM.conf_dependency CMC.LungCs03 CMC.LungCProgress0203
+CMC.d462 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCModelPop CMC.LungCNotProgressing1
+CMC.d843 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCModelPop CMC.LungCCured2
+CMC.d815 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCOutputCured1 CMC.LungCCured1
+CMC.d330 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCsIIANoDAgeing CMC.LungCsIIANoD
+CMC.f263 : SYSDYN.Flow
+ @WM.conf_dependency CMC.LungCs03 CMC.LungCs03Ageing
+CMC.f167 : SYSDYN.Flow
+ @WM.conf_dependency CMC.LungCT2Progressing CMC.LungCT2ProgressingPopCorr
+CMC.d360 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCsIIIBNoDPopCorr CMC.LungCModelPopCorrectionFactor
+CMC.d692 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCOutputs01ScDiagnosis CMC.LungCs01Diagnosis
+CMC.d610 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCOutputDiagnosis CMC.LungCsIVDiagnosis
+CMC.f514 : SYSDYN.Flow
+ @WM.conf_dependency CMC.LungCProgress02IV CMC.LungCs02
+CMC.d931 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCOutputRelapse CMC.LungCT1Progresses
+CMC.d725 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCOutputScDiagnosis CMC.LungCs03Diagnosis
+CMC.d663 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCOutputs03ScNoD CMC.LungCs03
+CMC.f513 : SYSDYN.Flow
+ @WM.conf_dependency CMC.LungCsIVNoD CMC.LungCProgress02IV
+CMC.d854 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCOutputTherapy1NoCure CMC.LungCTherapy1
+CMC.f797 : SYSDYN.Flow
+ @WM.conf_dependency CMC.LungCCured1 CMC.LungCCured1PopCorr
+CMC.f510 : SYSDYN.Flow
+ @WM.conf_dependency CMC.LungCProgress01IV CMC.LungCs01
+CMC.d549 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCsIIBNoD CMC.LungCsIIBNoDIniVal
+CMC.d877 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCOutputNoDSc CMC.LungCOutputsIIAScNoD
+CMC.d645 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCOutputsIBNsNoD CMC.LungCsIBNoD
+CMC.f322 : SYSDYN.Flow
+ @WM.conf_dependency CMC.LungCsIIANoD CMC.LungCsIIANoDPopCorr
+CMC.f469 : SYSDYN.Flow
+ @WM.conf_dependency CMC.LungCD CMC.LungCDAgeing
+CMC.f353 : SYSDYN.Flow
+ @WM.conf_dependency CMC.LungCsIIIBNoD CMC.LungCsIIIBNoDPopCorr
+CMC.d575 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCProgressIIIAIV CMC.LungCProgressIIIAIVRate
+CMC.f375 : SYSDYN.Flow
+ @WM.conf_dependency CMC.LungCsIBDiagnosis CMC.LungCsIBNoD
+CMC.d709 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCOutputsIVNsDiagnosis CMC.LungCsIVDiagnosis
+CMC.d128 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCModelPopCorrectionFactor CMC.LungCCausedDeath
+CMC.d589 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCOutputNotProgressing2 CMC.LungCNotProgressing2
+CMC.d250 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCs02PopCorr CMC.LungCModelPopCorrectionFactor
+CMC.f192 : SYSDYN.Flow
+ @WM.conf_dependency CMC.LungCProgressIAIIA CMC.LungCsIANoD
+CMC.d303 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCProgressIBIIB CMC.LungCsIBNoD
+CMC.d614 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCOutputTherapy2 CMC.LungCTherapy2
+CMC.d699 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCOutputsIBNsDiagnosis CMC.LungCsIBDiagnosis
+CMC.d501 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCs02Diagnosis CMC.LungCs02
+CMC.f278 : SYSDYN.Flow
+ @WM.conf_dependency CMC.LungCsIIBNoD CMC.LungCProgressIBIIB
+CMC.d490 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCNotProgressing2 CMC.LungCTreated2IniVal
+CMC.f150 : SYSDYN.Flow
+ @WM.conf_dependency CMC.LungCNotProgressing1 CMC.LungCTreated1PopCorr
+CMC.d155 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCTreated1PopCorr CMC.LungCNotProgressing1
+CMC.d130 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCModelPopCorrectionFactor CMC.TotalPopulation
+CMC.d245 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCProgress03IA CMC.LungCs03
+CMC.d626 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCOutputDisabling1 CMC.LungCT1Disabling
+CMC.d543 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCs01 CMC.LungCs01IniVal
+CMC.d583 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCTherapy2 CMC.LungCTherapy2Ratio
+CMC.f257 : SYSDYN.Flow
+ @WM.conf_dependency CMC.LungCs03 CMC.LungCs03PopCorr
+CMC.d782 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCOutputsIIBNosDiagnosis CMC.LungCsIIBDiagnosis
+CMC.d85 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCT2Progresses CMC.LungCNotProgressing2
+CMC.d809 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCTherapyCure1 CMC.LungCTherapy1CureRatio
+CMC.f332 : SYSDYN.Flow
+ @WM.conf_dependency CMC.LungCsIIBNoD CMC.LungCsIIBNoDPopCorr
+CMC.f425 : SYSDYN.Flow
+ @WM.conf_dependency CMC.LungCD CMC.LungCsIIIADiagnosis
+CMC.d745 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCOutputNosDiagnosis CMC.LungCsIVDiagnosis
+CMC.f34 : SYSDYN.Flow
+ @WM.conf_dependency CMC.LungCT2Progresses CMC.LungCNotProgressing2
+CMC.d832 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCTherapyCure2 CMC.LungCFirstTreatmentRate
+CMC.d736 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCOutputNosDiagnosis CMC.LungCs01Diagnosis
+CMC.d781 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCOutputsIIANosDiagnosis CMC.LungCsIIADiagnosis
+CMC.d603 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCOutputDiagnosis CMC.LungCs03Diagnosis
+CMC.d828 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCTherapyCure2 CMC.LungCTherapy2Ratio
+CMC.d90 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCT2ProgToDisabling CMC.LungCT2Progressing
+CMC.d102 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCTreated2Ageing CMC.DummyRateForUnitsConversion
+CMC.d565 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCProgress03IV CMC.LungCProgress03IVRate
+CMC.d620 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCOutputT2Mortality CMC.LungCT2Death
+CMC.d850 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCOutputTherapy2NoCure CMC.LungCTherapy2
+CMC.d891 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCoutputNoDNos CMC.LungCOutputsIVNosNoD
+CMC.f16 : SYSDYN.Flow
+ @WM.conf_dependency CMC.LungCProgress0102 CMC.LungCs01
+CMC.d730 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCOutputScDiagnosis CMC.LungCsIIIADiagnosis
+CMC.d921 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCD CMC.LungCDIniVal
+CMC.d55 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCHealthyAgeing CMC.LungCHealthy
+CMC.f233 : SYSDYN.Flow
+ @WM.conf_dependency CMC.LungCProgress0203 CMC.LungCs02
+CMC.d57 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCInception CMC.LungCInceptionRate
+CMC.d368 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCsIVNoDAgeing CMC.DummyRateForUnitsConversion
+CMC.f424 : SYSDYN.Flow
+ @WM.conf_dependency CMC.LungCD CMC.LungCsIIADiagnosis
+CMC.d872 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCOutputNoDSc CMC.LungCOutputs01ScNoD
+CMC.d316 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCsIBNoDPopCorr CMC.LungCsIBNoD
+CMC.d89 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCT2ProgToDisabling CMC.LungCT2ProgToDisablingRate
+CMC.d175 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCT2DisablingPopCorr CMC.LungCModelPopCorrectionFactor
+CMC.f11 : SYSDYN.Flow
+ @WM.conf_dependency CMC.LungCs01 CMC.LungCInception
+CMC.d492 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCT2Progressing CMC.LungCT2ProgressingIniVal
+CMC.d347 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCsIIIANoDPopCorr CMC.LungCsIIIANoD
+CMC.d842 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCOutputCured2 CMC.LungCCured2
+CMC.d665 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCOutputsIBScNoD CMC.LungCsIBNoD
+CMC.f434 : SYSDYN.Flow
+ @WM.conf_dependency CMC.LungCD CMC.LungCs03Diagnosis
+CMC.d93 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCT2Death CMC.LungCT2DeathRate
+CMC.d899 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCTherapy1Mortality CMC.LungCFirstTreatmentRate
+CMC.d865 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCOutputNoDNs CMC.LungCOutputsIBNsNoD
+CMC.f291 : SYSDYN.Flow
+ @WM.conf_dependency CMC.LungCProgressIIBIIIB CMC.LungCsIIBNoD
+CMC.d374 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCsIVNoDPopCorr CMC.LungCsIVNoD
+CMC.d904 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCTherapy1 CMC.LungCTherapy1MortalityRatio
+CMC.f429 : SYSDYN.Flow
+ @WM.conf_dependency CMC.LungCsIVDiagnosis CMC.LungCsIVNoD
+CMC.d649 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCOutputsIIIBNsNoD CMC.LungCsIIIBNoD
+CMC.d409 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCProgressIIAIIIA CMC.LungCProgressIIAIIIARate
+CMC.d642 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCOutputs02NsNoD CMC.LungCs02
+CMC.d648 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCOutputsIIIANsNoD CMC.LungCsIIIANoD
+CMC.d886 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCoutputNoDNos CMC.LungCOutputsIBNosNoD
+CMC.d585 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCT2Progresses CMC.LungCT2ProgressesRate
+CMC.f327 : SYSDYN.Flow
+ @WM.conf_dependency CMC.LungCsIIANoD CMC.LungCsIIANoDAgeing
+CMC.d727 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCOutputScDiagnosis CMC.LungCsIBDiagnosis
+CMC.d320 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCsIBNoDAgeing CMC.LungCsIBNoD
+CMC.d732 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCOutputScDiagnosis CMC.LungCsIVDiagnosis
+CMC.d811 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCCured1 CMC.LungCCured1IniVal
+CMC.d361 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCsIIIBNoDPopCorr CMC.LungCsIIIBNoD
+CMC.d465 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCModelPop CMC.LungCT1Disabling
+CMC.d184 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCOutputHealthyAndTreated CMC.LungCNotProgressing1
+CMC.d776 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCOutputs01NosDiagnosis CMC.LungCs01Diagnosis
+CMC.d894 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCOutputModelPopExcludingHealthy CMC.LungCHealthy
+CMC.d131 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCModelPopCorrectionFactor CMC.LungCModelPopCorrectionRate
+CMC.d181 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCT2ProgressingAgeing CMC.LungCT2Progressing
+CMC.d385 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCsIIADiagnosis CMC.LungCsIIADiagnosisRate
+CMC.f502 : SYSDYN.Flow
+ @WM.conf_dependency CMC.LungCD CMC.LungCs01Diagnosis
+CMC.d307 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCProgressIIBIIIA CMC.LungCsIIBNoD
+CMC.d801 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCCured1Ageing CMC.DummyRateForUnitsConversion
+CMC.d154 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCTreated1PopCorr CMC.LungCModelPopCorrectionFactor
+CMC.f830 : SYSDYN.Flow
+ @WM.conf_dependency CMC.LungCTherapyCure2 CMC.LungCD
+CMC.d553 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCProgress01IV CMC.LungCProgress01IVRate
+CMC.d747 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCOutputs01NosNoD CMC.LungCs01
+CMC.d847 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCOutputTherapy2 CMC.LungCTherapyCure2
+CMC.d704 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCOutputsIIBScDiagnosis CMC.LungCsIIBDiagnosis
+CMC.d326 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCsIIANoDPopCorr CMC.LungCModelPopCorrectionFactor
+CMC.f47 : SYSDYN.Flow
+ @WM.conf_dependency CMC.LungCBirth CMC.Cloud45
+CMC.d619 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCOutputT1Mortality CMC.LungCT1Death
+CMC.f37 : SYSDYN.Flow
+ @WM.conf_dependency CMC.LungCT2Disabling CMC.LungCT2ProgToDisabling
+CMC.d335 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCsIIBNoDPopCorr CMC.LungCsIIBNoD
+CMC.d855 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCOutputTherapy1Cure CMC.LungCTherapyCure1
+CMC.d195 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCProgressIAIIA CMC.LungCsIANoD
+CMC.d698 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCOutputsIAScDiagnosis CMC.LungCsIADiagnosis
+CMC.d554 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCProgress01IV CMC.LungCs01
+CMC.d831 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCTherapyCure2 CMC.LungCD
+CMC.f521 : SYSDYN.Flow
+ @WM.conf_dependency CMC.LungCsIVNoD CMC.LungCProgressIAIV
+CMC.f162 : SYSDYN.Flow
+ @WM.conf_dependency CMC.LungCD CMC.LungCDPopCorr
+CMC.d433 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCsIVDiagnosis CMC.LungCsIVNoD
+CMC.d780 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCOutputsIBNosDiagnosis CMC.LungCsIBDiagnosis
+CMC.d880 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCOutputNoDSc CMC.LungCOutputsIIIBScNoD
+CMC.d647 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCOutputsIIBNsNoD CMC.LungCsIIBNoD
+CMC.d74 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCTherapy2 CMC.LungCD
+CMC.d440 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCs03Diagnosis CMC.LungCs03
+CMC.d890 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCoutputNoDNos CMC.LungCOutputsIIIBNosNoD
+CMC.d740 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCOutputNosDiagnosis CMC.LungCsIBDiagnosis
+CMC.f299 : SYSDYN.Flow
+ @WM.conf_dependency CMC.LungCProgressIIIAIIIB CMC.LungCsIIIANoD
+CMC.d103 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCsIANoDAgeing CMC.DummyRateForUnitsConversion
+CMC.d922 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCT2Disabling CMC.LungCT2DisablingIniVal
+CMC.f201 : SYSDYN.Flow
+ @WM.conf_dependency CMC.LungCT1ProgToDisabling CMC.LungCT1Progressing
+CMC.d602 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCOutputDiagnosis CMC.LungCs02Diagnosis
+CMC.d871 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCOutputNoDNs CMC.LungCOutputsIVNsNoD
+CMC.f423 : SYSDYN.Flow
+ @WM.conf_dependency CMC.LungCD CMC.LungCsIIBDiagnosis
+CMC.d719 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCOutputNsDiagnosis CMC.LungCsIIBDiagnosis
+CMC.d902 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCTherapy1Mortality CMC.LungCTherapy1MortalityRatio
+CMC.d827 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCCured2PopCorr CMC.LungCCured2
+CMC.d91 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCT2Death CMC.LungCT2Disabling
+CMC.d266 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCs03Ageing CMC.LungCs03
+CMC.d467 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCModelPop CMC.LungCT2Disabling
+CMC.d701 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCOutputsIIANsDiagnosis CMC.LungCsIIADiagnosis
+CMC.f474 : SYSDYN.Flow
+ @WM.conf_dependency CMC.LungCTherapy1 CMC.LungCD
+CMC.f820 : SYSDYN.Flow
+ @WM.conf_dependency CMC.LungCCured2 CMC.LungCCured2Ageing
+CMC.d867 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCOutputNoDNs CMC.LungCOutputsIIBNsNoD
+CMC.f214 : SYSDYN.Flow
+ @WM.conf_dependency CMC.LungCT1Progressing CMC.LungCT1ProgressingPopCorr
+CMC.f422 : SYSDYN.Flow
+ @WM.conf_dependency CMC.LungCD CMC.LungCsIBDiagnosis
+CMC.f817 : SYSDYN.Flow
+ @WM.conf_dependency CMC.LungCCured2 CMC.LungCTherapyCure2
+CMC.d905 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCTherapy1Mortality CMC.LungCD
+CMC.d97 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCTherapy1 CMC.LungCTherapy1Ratio
+CMC.f41 : SYSDYN.Flow
+ @WM.conf_dependency CMC.LungCT2Deceased CMC.LungCT2Death
+CMC.d731 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCOutputScDiagnosis CMC.LungCsIIIBDiagnosis
+CMC.d668 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCOutputsIIIAScNoD CMC.LungCsIIIANoD
+CMC.f52 : SYSDYN.Flow
+ @WM.conf_dependency CMC.LungCHealthy CMC.LungCHealthyAgeing
+CMC.d302 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCProgressIAIB CMC.LungCsIANoD
+CMC.d229 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCCausedDeath CMC.LungCT1Death
+CMC.d866 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCOutputNoDNs CMC.LungCOutputsIIANsNoD
+CMC.f910 : SYSDYN.Flow
+ @WM.conf_dependency CMC.LungCT2Progressing CMC.LungCTherapy2Failed
+CMC.d693 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCOutputs02NsDiagnosis CMC.LungCs02Diagnosis
+CMC.f503 : SYSDYN.Flow
+ @WM.conf_dependency CMC.LungCs01Diagnosis CMC.LungCs01
+CMC.d315 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCsIBNoDPopCorr CMC.LungCModelPopCorrectionFactor
+CMC.d402 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCsIIIBDiagnosis CMC.LungCsIIIBNoD
+CMC.d641 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCOutputs01NsNoD CMC.LungCs01
+CMC.d893 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCOutputModelPopExcludingHealthy CMC.LungCModelPop
+CMC.d576 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCProgressIIIAIV CMC.LungCsIIIANoD
+CMC.d761 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCOutputsIIANosNoD CMC.LungCsIIANoD
+CMC.d838 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCTherapyCure2 CMC.LungCTherapy2CureRatio
+CMC.d222 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCT1ProgressingAgeing CMC.LungCT1Progressing
+CMC.d616 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCOutputMortality CMC.LungCCausedDeath
+CMC.d738 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCOutputNosDiagnosis CMC.LungCs03Diagnosis
+CMC.d83 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCTreated2Ageing CMC.LungCNotProgressing2
+CMC.d804 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCTherapyCure1 CMC.LungCTherapy1Ratio
+CMC.d870 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCOutputNoDNs CMC.LungCOutputsIIIBNsNoD
+CMC.d305 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCProgressIIAIIB CMC.LungCsIIANoD
+CMC.f896 : SYSDYN.Flow
+ @WM.conf_dependency CMC.LungCTherapy1Mortality CMC.LungCD
+CMC.d544 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCs02 CMC.LungCs02IniVal
+CMC.f217 : SYSDYN.Flow
+ @WM.conf_dependency CMC.LungCT1Progressing CMC.LungCT1ProgressingAgeing
+CMC.d122 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCHealthyPopCorr CMC.LungCHealthy
+CMC.d777 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCOutputs02NosDiagnosis CMC.LungCs02Diagnosis
+CMC.d143 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCs01PopCorr CMC.LungCModelPopCorrectionFactor
+CMC.d269 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCs03Ageing CMC.DummyRateForUnitsConversion
+CMC.d464 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCModelPop CMC.LungCT1Progressing
+CMC.d628 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCOutputDisabling2 CMC.LungCT2Disabling
+CMC.d878 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCOutputNoDSc CMC.LungCOutputsIIBScNoD
+CMC.d363 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCsIIIBNoDAgeing CMC.DummyRateForUnitsConversion
+CMC.f46 : SYSDYN.Flow
+ @WM.conf_dependency CMC.LungCHealthy CMC.LungCBirth
+CMC.d630 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCOutputNoDSum CMC.LungCNoDSum
+CMC.d183 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCOutputHealthyAndTreated CMC.LungCHealthy
+CMC.f518 : SYSDYN.Flow
+ @WM.conf_dependency CMC.LungCProgress03IV CMC.LungCs03
+CMC.d472 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCDAgeing CMC.LungCD
+CMC.d362 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCsIIIBNoDAgeing CMC.LungCsIIIBNoD
+CMC.d439 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCs03Diagnosis CMC.LungCs03DiagnosisRate
+CMC.f317 : SYSDYN.Flow
+ @WM.conf_dependency CMC.LungCsIBNoD CMC.LungCsIBNoDAgeing
+CMC.d608 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCOutputDiagnosis CMC.LungCsIIIADiagnosis
+CMC.d132 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCModelPopCorrectionFactor CMC.LungCModelPop
+CMC.d411 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCProgressIIAIIB CMC.LungCProgressIIAIIBRate
+CMC.d705 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCOutputsIIIANsDiagnosis CMC.LungCsIIIADiagnosis
+CMC.f398 : SYSDYN.Flow
+ @WM.conf_dependency CMC.LungCsIIIBDiagnosis CMC.LungCsIIIBNoD
+CMC.d836 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCCured2 CMC.LungCCured2IniVal
+CMC.d546 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCsIANoD CMC.LungCsIANoDIniVal
+CMC.d407 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCProgressIAIIA CMC.LungCProgressIAIIARate
+CMC.f537 : SYSDYN.Flow
+ @WM.conf_dependency CMC.LungCProgressIIIAIV CMC.LungCsIIIANoD
+CMC.f522 : SYSDYN.Flow
+ @WM.conf_dependency CMC.LungCProgressIAIV CMC.LungCsIANoD
+CMC.d785 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCOutputsIVNosDiagnosis CMC.LungCsIVDiagnosis
+CMC.d587 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCOutputNotProgressing1 CMC.LungCNotProgressing1
+CMC.d609 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCOutputDiagnosis CMC.LungCsIIIBDiagnosis
+CMC.d667 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCOutputsIIBScNoD CMC.LungCsIIBNoD
+CMC.d741 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCOutputNosDiagnosis CMC.LungCsIIADiagnosis
+CMC.f298 : SYSDYN.Flow
+ @WM.conf_dependency CMC.LungCsIIIBNoD CMC.LungCProgressIIIAIIIB
+CMC.d95 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCTherapy1 CMC.LungCFirstTreatmentRate
+CMC.d714 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCOutputNsDiagnosis CMC.LungCs02Diagnosis
+CMC.d601 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCOutputDiagnosis CMC.LungCs01Diagnosis
+CMC.d243 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCProgress03IA CMC.LungCProgress03IARate
+CMC.d779 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCOutputsIANosDiagnosis CMC.LungCsIADiagnosis
+CMC.d551 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCsIIIBNoD CMC.LungCsIIIBNoDIniVal
+CMC.f529 : SYSDYN.Flow
+ @WM.conf_dependency CMC.LungCsIVNoD CMC.LungCProgressIIAIV
+CMC.d697 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCOutputsIANsDiagnosis CMC.LungCsIADiagnosis
+CMC.d726 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCOutputScDiagnosis CMC.LungCsIADiagnosis
+CMC.d397 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCsIIIADiagnosis CMC.LungCsIIIANoD
+CMC.d857 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCOutputHealthyAndTreated CMC.LungCCured2
+CMC.d707 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCOutputsIIIBNsDiagnosis CMC.LungCsIIIBDiagnosis
+CMC.d65 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCProgress0102 CMC.LungCs01
+CMC.d261 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCs03PopCorr CMC.LungCModelPopCorrectionFactor
+CMC.d459 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCNoDSum CMC.LungCsIVNoD
+CMC.d321 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCsIBNoDAgeing CMC.DummyRateForUnitsConversion
+CMC.d823 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCCured2Ageing CMC.LungCCured2
+CMC.d903 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCTherapyCure1 CMC.LungCTherapy1MortalityRatio
+CMC.f204 : SYSDYN.Flow
+ @WM.conf_dependency CMC.LungCT1Deceased CMC.LungCT1Death
+CMC.d165 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCDPopCorr CMC.LungCModelPopCorrectionFactor
+CMC.d729 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCOutputScDiagnosis CMC.LungCsIIBDiagnosis
+CMC.f435 : SYSDYN.Flow
+ @WM.conf_dependency CMC.LungCs03Diagnosis CMC.LungCs03
+CMC.d924 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCOutputTherapy2 CMC.LungCTherapy2Failed
+CMC.d885 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCoutputNoDNos CMC.LungCOutputsIANosNoD
+CMC.d884 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCoutputNoDNos CMC.LungCOutputs03NosNoD
+CMC.d228 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCT1DisablingPopCorr CMC.LungCT1Disabling
+CMC.d760 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCOutputsIBNosNoD CMC.LungCsIBNoD
+CMC.d863 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCOutputNoDNs CMC.LungCOutputs03NsNoD
+CMC.d749 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCOutputs02NosNoD CMC.LungCs02
+CMC.d268 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCsIANoDPopCorr CMC.LungCModelPopCorrectionFactor
+CMC.f172 : SYSDYN.Flow
+ @WM.conf_dependency CMC.LungCT2Disabling CMC.LungCT2DisablingPopCorr
+CMC.f404 : SYSDYN.Flow
+ @WM.conf_dependency CMC.LungCProgressIAIB CMC.LungCsIANoD
+CMC.d223 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCT1ProgressingAgeing CMC.DummyRateForUnitsConversion
+CMC.d613 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCOutputTherapy1 CMC.LungCTherapy1
+CMC.d721 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCOutputNsDiagnosis CMC.LungCsIIIBDiagnosis
+CMC.f282 : SYSDYN.Flow
+ @WM.conf_dependency CMC.LungCsIIIANoD CMC.LungCProgressIIAIIIA
+CMC.d669 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCOutputsIIIBScNoD CMC.LungCsIIIBNoD
+CMC.d121 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCHealthyPopCorr CMC.LungCModelPopCorrectionFactor
+CMC.d702 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCOutputsIIAScDiagnosis CMC.LungCsIIADiagnosis
+CMC.d487 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCT1Progressing CMC.LungCT1ProgressingIniVal
+CMC.d873 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCOutputNoDSc CMC.LungCOutputs02ScNoD
+CMC.d577 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCProgressIIIBIV CMC.LungCProgressIIIBIVRate
+CMC.d209 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCT1ProgToDisabling CMC.LungCT1ProgToDisablingRate
+CMC.f117 : SYSDYN.Flow
+ @WM.conf_dependency CMC.LungCHealthy CMC.LungCHealthyPopCorr
+CMC.d643 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCOutputs03NsNoD CMC.LungCs03
+CMC.d455 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCNoDSum CMC.LungCsIIANoD
+CMC.f80 : SYSDYN.Flow
+ @WM.conf_dependency CMC.LungCNotProgressing2 CMC.LungCTreated2Ageing
+CMC.d336 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCsIIBNoDPopCorr CMC.LungCModelPopCorrectionFactor
+CMC.d457 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCNoDSum CMC.LungCsIIIANoD
+CMC.d696 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCOutputs03ScDiagnosis CMC.LungCs03Diagnosis
+CMC.d713 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCOutputNsDiagnosis CMC.LungCs01Diagnosis
+CMC.d879 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCOutputNoDSc CMC.LungCOutputsIIIAScNoD
+CMC.d550 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCsIIIANoD CMC.LungCsIIIANoDIniVal
+CMC.d670 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCOutputsIVScNoD CMC.LungCsIVNoD
+CMC.d419 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCProgressIIBIIIA CMC.LungCProgressIIBIIIARate
+CMC.f290 : SYSDYN.Flow
+ @WM.conf_dependency CMC.LungCsIIIBNoD CMC.LungCProgressIIBIIIB
+CMC.d149 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCsIANoDPopCorr CMC.LungCsIANoD
+CMC.d625 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCOutputProgressing1 CMC.LungCT1Progressing
+CMC.d304 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCProgressIIAIIIA CMC.LungCsIIANoD
+CMC.d547 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCsIBNoD CMC.LungCsIBNoDIniVal
+CMC.d396 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCsIIIADiagnosis CMC.LungCsIIIADiagnosisRate
+CMC.f530 : SYSDYN.Flow
+ @WM.conf_dependency CMC.LungCProgressIIAIV CMC.LungCsIIANoD
+CMC.f66 : SYSDYN.Flow
+ @WM.conf_dependency CMC.LungCsIANoD CMC.LungCsIANoDAgeing
+CMC.f19 : SYSDYN.Flow
+ @WM.conf_dependency CMC.LungCD CMC.LungCsIADiagnosis
+CMC.d306 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCProgressIIBIIIB CMC.LungCsIIBNoD
+CMC.d763 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCOutputsIIIANosNoD CMC.LungCsIIIANoD
+CMC.d70 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCsIADiagnosis CMC.LungCsIANoD
+CMC.d839 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCTherapy2 CMC.LungCTherapy2CureRatio
+CMC.f793 : SYSDYN.Flow
+ @WM.conf_dependency CMC.LungCCured1 CMC.LungCCured1Ageing
+CMC.d166 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCDPopCorr CMC.LungCD
+CMC.f30 : SYSDYN.Flow
+ @WM.conf_dependency CMC.LungCT1Progresses CMC.LungCNotProgressing1
+CMC.d570 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCProgressIBIV CMC.LungCsIBNoD
+CMC.d909 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCOutputTherapy1MortalityInTherapy CMC.LungCTherapy1Mortality
+CMC.d403 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCsIIIBDiagnosis CMC.LungCsIIIBDiagnosisRate
+CMC.d466 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCModelPop CMC.LungCT2Progressing
+CMC.f252 : SYSDYN.Flow
+ @WM.conf_dependency CMC.LungCs02 CMC.LungCs02Ageing
+CMC.d883 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCoutputNoDNos CMC.LungCOutputs02NosNoD
+CMC.f283 : SYSDYN.Flow
+ @WM.conf_dependency CMC.LungCProgressIIAIIIA CMC.LungCsIIANoD
+CMC.d134 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCHealthy CMC.LungCHealthyIniVal
+CMC.d75 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCTherapy1 CMC.LungCD
+CMC.f156 : SYSDYN.Flow
+ @WM.conf_dependency CMC.LungCNotProgressing2 CMC.LungCTreated2PopCorr
+CMC.d421 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCProgressIIBIIIB CMC.LungCProgressIIBIIIBRate
+CMC.f59 : SYSDYN.Flow
+ @WM.conf_dependency CMC.LungCs01 CMC.LungCs01Ageing
+CMC.d450 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCNoDSum CMC.LungCs01
+CMC.d703 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCOutputsIIBNsDiagnosis CMC.LungCsIIBDiagnosis
+CMC.d864 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCOutputNoDNs CMC.LungCOutputsIANsNoD
+CMC.d900 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCTherapy1Mortality CMC.LungCTherapy1Ratio
+CMC.d473 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCDAgeing CMC.DummyRateForUnitsConversion
+CMC.d185 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCOutputHealthyAndTreated CMC.LungCNotProgressing2
+CMC.d390 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCsIIBDiagnosis CMC.LungCsIIBNoD
+CMC.f356 : SYSDYN.Flow
+ @WM.conf_dependency CMC.LungCsIIIBNoD CMC.LungCsIIIBNoDAgeing
+CMC.f38 : SYSDYN.Flow
+ @WM.conf_dependency CMC.LungCT2ProgToDisabling CMC.LungCT2Progressing
+CMC.d807 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCTherapyCure1 CMC.LungCD
+CMC.d242 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.LungCProgress0203 CMC.LungCProgress0203Rate
+
+CMC.TotalPopulationT1 : SYSDYN.Auxiliary
+ @L0.tag MOD.Mapped
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions
+ @L0.list
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "delay(TotalPopulation[Gender,Age], 1)"
+
+CMC.TotalPopulationBirth : SYSDYN.Auxiliary
+ @L0.tag MOD.Mapped
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions
+ @L0.list
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "DummyRateForUnitsConversion*TotalPopulationT1[Gender,Age0]"
+
+CMC.TotalPopulationMen : SYSDYN.Auxiliary
+ @L0.tag MOD.Mapped
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions
+ @L0.list
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_DATA('LCancer.xls', 'Population_In', '7', 'C113')"
+
+CMC.OutputDataTotalPopulationMenSum : SYSDYN.Auxiliary
+ @L0.tag MOD.Mapped
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions
+ @L0.list
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "sum(TotalPopulationMen[Age!])"
+
+CMC.TotalPopulationWomen : SYSDYN.Auxiliary
+ @L0.tag MOD.Mapped
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions
+ @L0.list
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "XLS_DATA('LCancer.xls', 'Population_In', '7', 'C9')"
+
+CMC.TotalPopulation : SYSDYN.Auxiliary
+ @L0.tag MOD.Mapped
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions
+ @L0.list
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "TotalPopulationMen[Age]"
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "TotalPopulationWomen[Age]"
+
+CMC.OutputDataTotalPopulationWomenSum : SYSDYN.Auxiliary
+ @L0.tag MOD.Mapped
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions
+ @L0.list
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "sum(TotalPopulationWomen[Age!])"
+
+CMC.DummyRateForUnitsConversion : SYSDYN.Auxiliary
+ @L0.tag MOD.Mapped
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions
+ @L0.list
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "1"
+
+CMC.TotalPopulationDeath : SYSDYN.Auxiliary
+ @L0.tag MOD.Mapped
+ SYSDYN.HasExpressions _ : SYSDYN.Expressions
+ @L0.list
+ _ : SYSDYN.NormalExpression
+ SYSDYN.HasEquation "if Age==Age99 then (TotalPopulation[Gender,Age99]+TotalPopulation[Gender,Age100]-TotalPopulationT1[Gender,Age100])/4 elseif Age==Age100 then (TotalPopulation[Gender,Age99]+TotalPopulation[Gender,Age100]-TotalPopulationT1[Gender,Age100])*3/4 else VECTOR_MAP(TotalPopulation[Gender,Age], 0)-VECTOR_MAP(TotalPopulationT1[Gender,Age], 1)*DummyRateForUnitsConversion"
+
+CMC.d6 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.TotalPopulationDeath CMC.TotalPopulation
+CMC.d21 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.TotalPopulationDeath CMC.DummyRateForUnitsConversion
+CMC.d9 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.TotalPopulation CMC.TotalPopulationMen
+CMC.d17 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.OutputDataTotalPopulationMenSum CMC.TotalPopulationMen
+CMC.d12 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.TotalPopulationDeath CMC.TotalPopulationT1
+CMC.d20 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.TotalPopulationBirth CMC.DummyRateForUnitsConversion
+CMC.d14 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.TotalPopulationT1 CMC.TotalPopulation
+CMC.d18 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.OutputDataTotalPopulationWomenSum CMC.TotalPopulationWomen
+CMC.d10 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.TotalPopulation CMC.TotalPopulationWomen
+CMC.d13 : SYSDYN.Dependency
+ @WM.conf_dependency CMC.TotalPopulationBirth CMC.TotalPopulationT1
+
+LungCancerConfigurationDiagram : SYSDYN.ConfigurationDiagram <R L0.HasNext
+ MOD.DiagramToComposite CMC
+ DIA.HasLayer WM.Admin : DIA.Layer
+ DIA.IsActive true
+ DIA.HasFocusableTag TAGS.AdminIsFocusable <R DIA.IsFocusable
+ @L0.symmetric
+ DIA.HasVisibleTag TAGS.AdminIsVisible <R DIA.IsVisible
+ @L0.symmetric
+ L0.HasTrigger _ : SYSDYN.DiagramToCompositeMapping
+ @L0.list
+ LungCProgressIAIVRateElement559 : SYSDYN.AuxiliarySymbol
+ MOD.ElementToComponent CMC.LungCProgressIAIVRate
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, -343.2, -21.0] : G2D.Transform
+ LungCT1ProgressesElement32 : SYSDYN.ValveSymbol
+ MOD.ElementToComponent CMC.LungCT1Progresses
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, 76.2, 40.8] : G2D.Transform
+ LungCProgressIAIBElement277 : SYSDYN.ValveSymbol
+ MOD.ElementToComponent CMC.LungCProgressIAIB
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, -211.0, 16.2] : G2D.Transform
+ LungCsIBNoDElement443 : SYSDYN.StockSymbol
+ MOD.ElementToComponent CMC.LungCsIBNoD
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, 516.4, -10.6] : G2D.Transform
+ LungCT1DeathElement207 : SYSDYN.ValveSymbol
+ MOD.ElementToComponent CMC.LungCT1Death
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, 247.2, 41.4] : G2D.Transform
+ LungCHealthyPopCorrElement119 : SYSDYN.ValveSymbol
+ MOD.ElementToComponent CMC.LungCHealthyPopCorr
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, -208.0, -203.6] : G2D.Transform
+ LungCsIADiagnosisRateElement71 : SYSDYN.AuxiliarySymbol
+ MOD.ElementToComponent CMC.LungCsIADiagnosisRate
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, -187.2, -16.2] : G2D.Transform
+ LungCProgress03IVElement520 : SYSDYN.ValveSymbol
+ MOD.ElementToComponent CMC.LungCProgress03IV
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, -325.6, -52.2] : G2D.Transform
+ LungCsIIIBNoDAgeingElement358 : SYSDYN.ValveSymbol
+ MOD.ElementToComponent CMC.LungCsIIIBNoDAgeing
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, -158.4, 200.8] : G2D.Transform
+ LungCProgressIBIVRateElement560 : SYSDYN.AuxiliarySymbol
+ MOD.ElementToComponent CMC.LungCProgressIBIVRate
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, -348.0, 29.8] : G2D.Transform
+ LungCOutputs02NosDiagnosisElement767 : SYSDYN.AuxiliarySymbol
+ MOD.ElementToComponent CMC.LungCOutputs02NosDiagnosis
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, 476.2, 233.2] : G2D.Transform
+ LungCProgressIIAIVElement532 : SYSDYN.ValveSymbol
+ MOD.ElementToComponent CMC.LungCProgressIIAIV
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, -333.2, 82.2] : G2D.Transform
+ LungCTherapy1MortalityElement898 : SYSDYN.ValveSymbol
+ MOD.ElementToComponent CMC.LungCTherapy1Mortality
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, 57.8, -26.6] : G2D.Transform
+ LungCCured1PopCorrElement799 : SYSDYN.ValveSymbol
+ MOD.ElementToComponent CMC.LungCCured1PopCorr
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, 26.4, -28.8] : G2D.Transform
+ LungCProgress01IVElement512 : SYSDYN.ValveSymbol
+ MOD.ElementToComponent CMC.LungCProgress01IV
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, -319.8, -128.8] : G2D.Transform
+ LungCs03DiagnosisElement437 : SYSDYN.ValveSymbol
+ MOD.ElementToComponent CMC.LungCs03Diagnosis
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, -163.4, -48.4] : G2D.Transform
+ LungCs03PopCorrElement259 : SYSDYN.ValveSymbol
+ MOD.ElementToComponent CMC.LungCs03PopCorr
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, -203.6, -68.2] : G2D.Transform
+ LungCProgressIAIIAElement194 : SYSDYN.ValveSymbol
+ MOD.ElementToComponent CMC.LungCProgressIAIIA
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, -260.4, 1.4] : G2D.Transform
+ LungCDPopCorrElement164 : SYSDYN.ValveSymbol
+ MOD.ElementToComponent CMC.LungCDPopCorr
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, -62.4, 191.0] : G2D.Transform
+ LungCsIIIADiagnosisRateElement395 : SYSDYN.AuxiliarySymbol
+ MOD.ElementToComponent CMC.LungCsIIIADiagnosisRate
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, -210.2, 187.0] : G2D.Transform
+ LungCOutputsIANsNoDElement634 : SYSDYN.AuxiliarySymbol
+ MOD.ElementToComponent CMC.LungCOutputsIANsNoD
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, 556.8, -25.2] : G2D.Transform
+ LungCOutputTherapy1Element611 : SYSDYN.AuxiliarySymbol
+ MOD.ElementToComponent CMC.LungCOutputTherapy1
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, 589.4, 161.0] : G2D.Transform
+ LungCT2ProgressesRateElement584 : SYSDYN.AuxiliarySymbol
+ MOD.ElementToComponent CMC.LungCT2ProgressesRate
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, 71.8, 96.0] : G2D.Transform
+ LungCOutputTherapy2CureElement849 : SYSDYN.AuxiliarySymbol
+ MOD.ElementToComponent CMC.LungCOutputTherapy2Cure
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, 450.0, 186.8] : G2D.Transform
+ LungCT2ProgressesElement36 : SYSDYN.ValveSymbol
+ MOD.ElementToComponent CMC.LungCT2Progresses
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, 76.2, 109.6] : G2D.Transform
+ LungCT1ProgToDisablingRateElement208 : SYSDYN.AuxiliarySymbol
+ MOD.ElementToComponent CMC.LungCT1ProgToDisablingRate
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, 161.0, 24.4] : G2D.Transform
+ LungCProgressIIBIIIBElement293 : SYSDYN.ValveSymbol
+ MOD.ElementToComponent CMC.LungCProgressIIBIIIB
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, -168.6, 144.4] : G2D.Transform
+ LungCsIIIANoDAgeingElement350 : SYSDYN.ValveSymbol
+ MOD.ElementToComponent CMC.LungCsIIIANoDAgeing
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, -274.4, 154.6] : G2D.Transform
+ LungCOutputsIBNsDiagnosisElement675 : SYSDYN.AuxiliarySymbol
+ MOD.ElementToComponent CMC.LungCOutputsIBNsDiagnosis
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, 459.4, 275.0] : G2D.Transform
+ LungCOutputRelapseElement930 : SYSDYN.AuxiliarySymbol
+ MOD.ElementToComponent CMC.LungCOutputRelapse
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, 262.4, 220.8] : G2D.Transform
+ LungCs03Element442 : SYSDYN.StockSymbol
+ MOD.ElementToComponent CMC.LungCs03
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, 516.4, -41.2] : G2D.Transform
+ LungCT1DeceasedElement199 : SYSDYN.StockSymbol
+ MOD.ElementToComponent CMC.LungCT1Deceased
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, 286.8, 37.6] : G2D.Transform
+ TotalPopulationDeathElement114 : SYSDYN.AuxiliarySymbol
+ MOD.ElementToComponent CMC.TotalPopulationDeath
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, 389.4, 57.6] : G2D.Transform
+ LungCT1DisablingPopCorrElement226 : SYSDYN.ValveSymbol
+ MOD.ElementToComponent CMC.LungCT1DisablingPopCorr
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, 226.8, 54.4] : G2D.Transform
+ LungCOutputsIAScDiagnosisElement684 : SYSDYN.AuxiliarySymbol
+ MOD.ElementToComponent CMC.LungCOutputsIAScDiagnosis
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, 473.0, 260.6] : G2D.Transform
+ LungCModelPopCorrectionFactorElement153 : SYSDYN.AuxiliarySymbol
+ MOD.ElementToComponent CMC.LungCModelPopCorrectionFactor
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, 121.8, 66.8] : G2D.Transform
+ LungCProgressIBIVElement528 : SYSDYN.ValveSymbol
+ MOD.ElementToComponent CMC.LungCProgressIBIV
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, -330.2, 37.8] : G2D.Transform
+ LungCsIVDiagnosisElement431 : SYSDYN.ValveSymbol
+ MOD.ElementToComponent CMC.LungCsIVDiagnosis
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, -163.6, 257.2] : G2D.Transform
+ LungCOutputsIIIBScDiagnosisElement689 : SYSDYN.AuxiliarySymbol
+ MOD.ElementToComponent CMC.LungCOutputsIIIBScDiagnosis
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, 470.8, 347.0] : G2D.Transform
+ LungCsIIADiagnosisElement383 : SYSDYN.ValveSymbol
+ MOD.ElementToComponent CMC.LungCsIIADiagnosis
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, -213.6, 85.8] : G2D.Transform
+ LungCTherapy1RatioElement73 : SYSDYN.AuxiliarySymbol
+ MOD.ElementToComponent CMC.LungCTherapy1Ratio
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, -16.4, 20.4] : G2D.Transform
+ LungCsIBNoDPopCorrElement311 : SYSDYN.ValveSymbol
+ MOD.ElementToComponent CMC.LungCsIBNoDPopCorr
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, -173.0, 19.0] : G2D.Transform
+ LungCsIANoDAgeingElement68 : SYSDYN.ValveSymbol
+ MOD.ElementToComponent CMC.LungCsIANoDAgeing
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, -200.0, -22.4] : G2D.Transform
+ LungCCured1Element812 : SYSDYN.StockSymbol
+ MOD.ElementToComponent CMC.LungCCured1
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, 517.4, 91.8] : G2D.Transform
+ LungCCured1AgeingElement795 : SYSDYN.ValveSymbol
+ MOD.ElementToComponent CMC.LungCCured1Ageing
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, 38.2, -19.2] : G2D.Transform
+ LungCProgress03IARateElement241 : SYSDYN.AuxiliarySymbol
+ MOD.ElementToComponent CMC.LungCProgress03IARate
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, -263.4, -44.8] : G2D.Transform
+ LungCT1DisablingElement198 : SYSDYN.StockSymbol
+ MOD.ElementToComponent CMC.LungCT1Disabling
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, 208.8, 37.2] : G2D.Transform
+ LungCCured2PopCorrElement826 : SYSDYN.ValveSymbol
+ MOD.ElementToComponent CMC.LungCCured2PopCorr
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, 33.6, 165.8] : G2D.Transform
+ LungCTreated2IniValElement489 : SYSDYN.AuxiliarySymbol
+ MOD.ElementToComponent CMC.LungCTreated2IniVal
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, -429.8, 46.2] : G2D.Transform
+ LungCsIIBDiagnosisRateElement389 : SYSDYN.AuxiliarySymbol
+ MOD.ElementToComponent CMC.LungCsIIBDiagnosisRate
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, -141.4, 136.6] : G2D.Transform
+ LungCOutputNoDScElement859 : SYSDYN.AuxiliarySymbol
+ MOD.ElementToComponent CMC.LungCOutputNoDSc
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, 659.0, -9.6] : G2D.Transform
+ LungCOutputsIANsDiagnosisElement674 : SYSDYN.AuxiliarySymbol
+ MOD.ElementToComponent CMC.LungCOutputsIANsDiagnosis
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, 459.4, 256.2] : G2D.Transform
+ LungCTherapy2FailedElement913 : SYSDYN.ValveSymbol
+ MOD.ElementToComponent CMC.LungCTherapy2Failed
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, 59.6, 183.0] : G2D.Transform
+ LungCProgressIIBIIIARateElement418 : SYSDYN.AuxiliarySymbol
+ MOD.ElementToComponent CMC.LungCProgressIIBIIIARate
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, -212.2, 147.6] : G2D.Transform
+ LungCProgressIBIIBElement281 : SYSDYN.ValveSymbol
+ MOD.ElementToComponent CMC.LungCProgressIBIIB
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, -175.4, 55.8] : G2D.Transform
+ LungCsIIIBNoDElement273 : SYSDYN.StockSymbol
+ MOD.ElementToComponent CMC.LungCsIIIBNoD
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, -183.4, 213.0] : G2D.Transform
+ LungCDAgeingElement471 : SYSDYN.ValveSymbol
+ MOD.ElementToComponent CMC.LungCDAgeing
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, -65.4, 210.6] : G2D.Transform
+ LungCOutputProgressing2Element622 : SYSDYN.AuxiliarySymbol
+ MOD.ElementToComponent CMC.LungCOutputProgressing2
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, 623.8, 132.2] : G2D.Transform
+ LungCModelPopCorrectionFactorElement249 : SYSDYN.AuxiliarySymbol
+ MOD.ElementToComponent CMC.LungCModelPopCorrectionFactor
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, -189.8, -115.4] : G2D.Transform
+ LungCT1ProgressingAgeingElement219 : SYSDYN.ValveSymbol
+ MOD.ElementToComponent CMC.LungCT1ProgressingAgeing
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, 140.8, 51.2] : G2D.Transform
+ LungCT1ProgToDisablingElement203 : SYSDYN.ValveSymbol
+ MOD.ElementToComponent CMC.LungCT1ProgToDisabling
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, 157.4, 41.4] : G2D.Transform
+ LungCT2ProgressingPopCorrElement169 : SYSDYN.ValveSymbol
+ MOD.ElementToComponent CMC.LungCT2ProgressingPopCorr
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, 131.4, 123.8] : G2D.Transform
+ LungCInceptionElement14 : SYSDYN.ValveSymbol
+ MOD.ElementToComponent CMC.LungCInception
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, -211.2, -155.0] : G2D.Transform
+ LungCTherapyCure2Element819 : SYSDYN.ValveSymbol
+ MOD.ElementToComponent CMC.LungCTherapyCure2
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, -24.0, 152.0] : G2D.Transform
+ LungCCured1Element789 : SYSDYN.StockSymbol
+ MOD.ElementToComponent CMC.LungCCured1
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, 13.0, -6.4] : G2D.Transform
+ LungCBirthElement49 : SYSDYN.ValveSymbol
+ MOD.ElementToComponent CMC.LungCBirth
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, -269.6, -173.6] : G2D.Transform
+ LungCModelPopCorrectionFactorElement834 : SYSDYN.AuxiliarySymbol
+ MOD.ElementToComponent CMC.LungCModelPopCorrectionFactor
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, 42.0, 179.6] : G2D.Transform
+ LungCT2ProgressingAgeingElement179 : SYSDYN.ValveSymbol
+ MOD.ElementToComponent CMC.LungCT2ProgressingAgeing
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, 139.6, 118.6] : G2D.Transform
+ LungCTherapy1Element25 : SYSDYN.ValveSymbol
+ MOD.ElementToComponent CMC.LungCTherapy1
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, -25.8, 39.6] : G2D.Transform
+ LungCOutputNoDNsElement858 : SYSDYN.AuxiliarySymbol
+ MOD.ElementToComponent CMC.LungCOutputNoDNs
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, 657.4, -27.6] : G2D.Transform
+ LungCProgressIIAIIIAElement285 : SYSDYN.ValveSymbol
+ MOD.ElementToComponent CMC.LungCProgressIIAIIIA
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, -265.6, 97.8] : G2D.Transform
+ LungCs01PopCorrElement141 : SYSDYN.ValveSymbol
+ MOD.ElementToComponent CMC.LungCs01PopCorr
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, -200.8, -148.6] : G2D.Transform
+ LungCOutputsIIBNosDiagnosisElement772 : SYSDYN.AuxiliarySymbol
+ MOD.ElementToComponent CMC.LungCOutputsIIBNosDiagnosis
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, 476.6, 318.6] : G2D.Transform
+ LungCDElement124 : SYSDYN.StockSymbol
+ MOD.ElementToComponent CMC.LungCD
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, 507.2, 69.6] : G2D.Transform
+ LungCModelPopElement104 : SYSDYN.AuxiliarySymbol
+ MOD.ElementToComponent CMC.LungCModelPop
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, 394.8, 15.4] : G2D.Transform
+ LungCProgressIIIAIIIBRateElement412 : SYSDYN.AuxiliarySymbol
+ MOD.ElementToComponent CMC.LungCProgressIIIAIIIBRate
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, -273.8, 194.8] : G2D.Transform
+ LungCProgress0203Element235 : SYSDYN.ValveSymbol
+ MOD.ElementToComponent CMC.LungCProgress0203
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, -239.8, -76.6] : G2D.Transform
+ LungCsIBDiagnosisElement594 : SYSDYN.ValveSymbol
+ MOD.ElementToComponent CMC.LungCsIBDiagnosis
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, 522.8, 273.8] : G2D.Transform
+ LungCModelPopCorrectionFactorElement314 : SYSDYN.AuxiliarySymbol
+ MOD.ElementToComponent CMC.LungCModelPopCorrectionFactor
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, -279.6, 41.4] : G2D.Transform
+ LungCOutputsIIBNosNoDElement754 : SYSDYN.AuxiliarySymbol
+ MOD.ElementToComponent CMC.LungCOutputsIIBNosNoD
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, 557.0, 24.0] : G2D.Transform
+ LungCsIIBDiagnosisElement388 : SYSDYN.ValveSymbol
+ MOD.ElementToComponent CMC.LungCsIIBDiagnosis
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, -147.8, 128.6] : G2D.Transform
+ LungCOutputs03ScNoDElement653 : SYSDYN.AuxiliarySymbol
+ MOD.ElementToComponent CMC.LungCOutputs03ScNoD
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, 565.0, -37.6] : G2D.Transform
+ LungCsIIIBNoDPopCorrElement355 : SYSDYN.ValveSymbol
+ MOD.ElementToComponent CMC.LungCsIIIBNoDPopCorr
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, -162.6, 194.6] : G2D.Transform
+ LungCsIIANoDIniValElement479 : SYSDYN.AuxiliarySymbol
+ MOD.ElementToComponent CMC.LungCsIIANoDIniVal
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, -429.4, -74.4] : G2D.Transform
+ LungCModelPopCorrectionFactorElement159 : SYSDYN.AuxiliarySymbol
+ MOD.ElementToComponent CMC.LungCModelPopCorrectionFactor
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, 123.6, 134.2] : G2D.Transform
+ LungCProgress02IVRateElement555 : SYSDYN.AuxiliarySymbol
+ MOD.ElementToComponent CMC.LungCProgress02IVRate
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, -327.0, -102.4] : G2D.Transform
+ LungCOutputs01ScDiagnosisElement681 : SYSDYN.AuxiliarySymbol
+ MOD.ElementToComponent CMC.LungCOutputs01ScDiagnosis
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, 470.8, 210.2] : G2D.Transform
+ LungCT2ProgressingElement8 : SYSDYN.StockSymbol
+ MOD.ElementToComponent CMC.LungCT2Progressing
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, 116.2, 105.6] : G2D.Transform
+ DummyRateForUnitsConversionElement98 : SYSDYN.AuxiliarySymbol
+ MOD.ElementToComponent CMC.DummyRateForUnitsConversion
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, 70.0, -141.0] : G2D.Transform
+ LungCT2DeathElement44 : SYSDYN.ValveSymbol
+ MOD.ElementToComponent CMC.LungCT2Death
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, 247.2, 108.6] : G2D.Transform
+ LungCOutputsIIAScDiagnosisElement686 : SYSDYN.AuxiliarySymbol
+ MOD.ElementToComponent CMC.LungCOutputsIIAScDiagnosis
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, 470.8, 296.6] : G2D.Transform
+ LungCsIBNoDElement270 : SYSDYN.StockSymbol
+ MOD.ElementToComponent CMC.LungCsIBNoD
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, -187.6, 40.4] : G2D.Transform
+ LungCT1DisablingIniValElement485 : SYSDYN.AuxiliarySymbol
+ MOD.ElementToComponent CMC.LungCT1DisablingIniVal
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, -426.2, 26.6] : G2D.Transform
+ LungCNotProgressing1Element5 : SYSDYN.StockSymbol
+ MOD.ElementToComponent CMC.LungCNotProgressing1
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, 30.0, 35.8] : G2D.Transform
+ LungCOutputsIBScDiagnosisElement685 : SYSDYN.AuxiliarySymbol
+ MOD.ElementToComponent CMC.LungCOutputsIBScDiagnosis
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, 470.8, 279.4] : G2D.Transform
+ LungCOutputProgressing1Element621 : SYSDYN.AuxiliarySymbol
+ MOD.ElementToComponent CMC.LungCOutputProgressing1
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, 623.8, 114.6] : G2D.Transform
+ LungCProgressIIIAIVElement539 : SYSDYN.ValveSymbol
+ MOD.ElementToComponent CMC.LungCProgressIIIAIV
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, -338.8, 170.0] : G2D.Transform
+ LungCProgressIAIVElement524 : SYSDYN.ValveSymbol
+ MOD.ElementToComponent CMC.LungCProgressIAIV
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, -328.0, -10.4] : G2D.Transform
+ LungCsIADiagnosisElement22 : SYSDYN.ValveSymbol
+ MOD.ElementToComponent CMC.LungCsIADiagnosis
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, -195.6, -5.4] : G2D.Transform
+ LungCOutputsIVNsDiagnosisElement680 : SYSDYN.AuxiliarySymbol
+ MOD.ElementToComponent CMC.LungCOutputsIVNsDiagnosis
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, 459.4, 359.8] : G2D.Transform
+ LungCOutputsIIIBNsDiagnosisElement679 : SYSDYN.AuxiliarySymbol
+ MOD.ElementToComponent CMC.LungCOutputsIIIBNsDiagnosis
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, 459.4, 343.6] : G2D.Transform
+ LungCProgress01IVRateElement552 : SYSDYN.AuxiliarySymbol
+ MOD.ElementToComponent CMC.LungCProgress01IVRate
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, -314.0, -143.8] : G2D.Transform
+ LungCProgressIIAIIBElement289 : SYSDYN.ValveSymbol
+ MOD.ElementToComponent CMC.LungCProgressIIAIIB
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, -225.8, 101.6] : G2D.Transform
+ LungCT1ProgressingElement460 : SYSDYN.StockSymbol
+ MOD.ElementToComponent CMC.LungCT1Progressing
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, 516.2, 114.6] : G2D.Transform
+ LungCOutputNotProgressing1Element586 : SYSDYN.AuxiliarySymbol
+ MOD.ElementToComponent CMC.LungCOutputNotProgressing1
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, 630.0, 88.0] : G2D.Transform
+ LungCsIIANoDPopCorrElement324 : SYSDYN.ValveSymbol
+ MOD.ElementToComponent CMC.LungCsIIANoDPopCorr
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, -268.8, 46.2] : G2D.Transform
+ LungCsIIIBDiagnosisElement598 : SYSDYN.ValveSymbol
+ MOD.ElementToComponent CMC.LungCsIIIBDiagnosis
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, 522.8, 342.8] : G2D.Transform
+ LungCOutputsIIBNsNoDElement637 : SYSDYN.AuxiliarySymbol
+ MOD.ElementToComponent CMC.LungCOutputsIIBNsNoD
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, 556.0, 17.0] : G2D.Transform
+ LungCProgressIIAIIBRateElement410 : SYSDYN.AuxiliarySymbol
+ MOD.ElementToComponent CMC.LungCProgressIIAIIBRate
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, -213.4, 94.2] : G2D.Transform
+ LungCsIIADiagnosisElement595 : SYSDYN.ValveSymbol
+ MOD.ElementToComponent CMC.LungCsIIADiagnosis
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, 522.8, 291.2] : G2D.Transform
+ LungCProgress0203RateElement240 : SYSDYN.AuxiliarySymbol
+ MOD.ElementToComponent CMC.LungCProgress0203Rate
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, -258.6, -82.8] : G2D.Transform
+ LungCsIIBNoDPopCorrElement334 : SYSDYN.ValveSymbol
+ MOD.ElementToComponent CMC.LungCsIIBNoDPopCorr
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, -166.4, 99.8] : G2D.Transform
+ LungCSmokersPercentageOfPopulationElement786 : SYSDYN.AuxiliarySymbol
+ MOD.ElementToComponent CMC.LungCSmokersPercentageOfPopulation
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, -140.0, -167.0] : G2D.Transform
+ LungCOutputsIVScDiagnosisElement690 : SYSDYN.AuxiliarySymbol
+ MOD.ElementToComponent CMC.LungCOutputsIVScDiagnosis
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, 470.8, 364.0] : G2D.Transform
+ LungCs01AgeingElement61 : SYSDYN.ValveSymbol
+ MOD.ElementToComponent CMC.LungCs01Ageing
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, -193.8, -143.0] : G2D.Transform
+ LungCOutputsIBNosNoDElement752 : SYSDYN.AuxiliarySymbol
+ MOD.ElementToComponent CMC.LungCOutputsIBNosNoD
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, 562.8, -4.0] : G2D.Transform
+ LungCs02Element230 : SYSDYN.StockSymbol
+ MOD.ElementToComponent CMC.LungCs02
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, -221.8, -89.4] : G2D.Transform
+ LungCCausedDeathElement115 : SYSDYN.AuxiliarySymbol
+ MOD.ElementToComponent CMC.LungCCausedDeath
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, 357.4, 65.0] : G2D.Transform
+ LungCsIBDiagnosisElement377 : SYSDYN.ValveSymbol
+ MOD.ElementToComponent CMC.LungCsIBDiagnosis
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, -148.8, 44.6] : G2D.Transform
+ LungCsIIBNoDElement447 : SYSDYN.StockSymbol
+ MOD.ElementToComponent CMC.LungCsIIBNoD
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, 514.6, 17.0] : G2D.Transform
+ LungCProgressIIBIVElement536 : SYSDYN.ValveSymbol
+ MOD.ElementToComponent CMC.LungCProgressIIBIV
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, -335.6, 122.4] : G2D.Transform
+ LungCOutputCured2Element841 : SYSDYN.AuxiliarySymbol
+ MOD.ElementToComponent CMC.LungCOutputCured2
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, 628.0, 106.8] : G2D.Transform
+ LungCsIBDiagnosisRateElement379 : SYSDYN.AuxiliarySymbol
+ MOD.ElementToComponent CMC.LungCsIBDiagnosisRate
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, -136.2, 56.0] : G2D.Transform
+ LungCTherapy1MortalityRatioElement901 : SYSDYN.AuxiliarySymbol
+ MOD.ElementToComponent CMC.LungCTherapy1MortalityRatio
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, 32.4, 11.0] : G2D.Transform
+ TotalPopulationElement113 : SYSDYN.AuxiliarySymbol
+ MOD.ElementToComponent CMC.TotalPopulation
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, 350.8, 10.2] : G2D.Transform
+ LungCTreated1PopCorrElement152 : SYSDYN.ValveSymbol
+ MOD.ElementToComponent CMC.LungCTreated1PopCorr
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, 57.4, 53.8] : G2D.Transform
+ LungCTherapy2Element189 : SYSDYN.ValveSymbol
+ MOD.ElementToComponent CMC.LungCTherapy2
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, 518.6, 182.6] : G2D.Transform
+ LungCOutputTherapy2Element612 : SYSDYN.AuxiliarySymbol
+ MOD.ElementToComponent CMC.LungCOutputTherapy2
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, 590.2, 182.4] : G2D.Transform
+ LungCsIIBNoDIniValElement480 : SYSDYN.AuxiliarySymbol
+ MOD.ElementToComponent CMC.LungCsIIBNoDIniVal
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, -429.4, -66.6] : G2D.Transform
+ LungCs03DiagnosisRateElement438 : SYSDYN.AuxiliarySymbol
+ MOD.ElementToComponent CMC.LungCs03DiagnosisRate
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, -154.2, -60.8] : G2D.Transform
+ LungCsIIIANoDIniValElement481 : SYSDYN.AuxiliarySymbol
+ MOD.ElementToComponent CMC.LungCsIIIANoDIniVal
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, -429.2, -58.6] : G2D.Transform
+ LungCTreated1AgeingElement78 : SYSDYN.ValveSymbol
+ MOD.ElementToComponent CMC.LungCTreated1Ageing
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, 62.8, 48.6] : G2D.Transform
+ LungCT2DisablingPopCorrElement174 : SYSDYN.ValveSymbol
+ MOD.ElementToComponent CMC.LungCT2DisablingPopCorr
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, 227.4, 122.4] : G2D.Transform
+ LungCOutputs03ScDiagnosisElement683 : SYSDYN.AuxiliarySymbol
+ MOD.ElementToComponent CMC.LungCOutputs03ScDiagnosis
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, 470.8, 244.0] : G2D.Transform
+ LungCsIIANoDElement444 : SYSDYN.StockSymbol
+ MOD.ElementToComponent CMC.LungCsIIANoD
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, 514.6, 1.8] : G2D.Transform
+ LungCProgressIIIBIVElement542 : SYSDYN.ValveSymbol
+ MOD.ElementToComponent CMC.LungCProgressIIIBIV
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, -341.2, 210.8] : G2D.Transform
+ LungCProgressIIIBIVRateElement564 : SYSDYN.AuxiliarySymbol
+ MOD.ElementToComponent CMC.LungCProgressIIIBIVRate
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, -351.6, 197.6] : G2D.Transform
+ LungCProgressIIIAIVRateElement563 : SYSDYN.AuxiliarySymbol
+ MOD.ElementToComponent CMC.LungCProgressIIIAIVRate
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, -351.0, 160.6] : G2D.Transform
+ LungCT2ProgToDisablingElement40 : SYSDYN.ValveSymbol
+ MOD.ElementToComponent CMC.LungCT2ProgToDisabling
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, 159.6, 110.2] : G2D.Transform
+ LungCProgress03IVRateElement558 : SYSDYN.AuxiliarySymbol
+ MOD.ElementToComponent CMC.LungCProgress03IVRate
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, -333.0, -63.6] : G2D.Transform
+ LungCOutputs03NosNoDElement750 : SYSDYN.AuxiliarySymbol
+ MOD.ElementToComponent CMC.LungCOutputs03NosNoD
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, 560.2, -33.2] : G2D.Transform
+ LungCOutputsIIIAScDiagnosisElement688 : SYSDYN.AuxiliarySymbol
+ MOD.ElementToComponent CMC.LungCOutputsIIIAScDiagnosis
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, 470.8, 328.8] : G2D.Transform
+ LungCOutputsIIBScNoDElement657 : SYSDYN.AuxiliarySymbol
+ MOD.ElementToComponent CMC.LungCOutputsIIBScNoD
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, 563.2, 20.8] : G2D.Transform
+ LungCModelPopCorrectionFactorElement312 : SYSDYN.AuxiliarySymbol
+ MOD.ElementToComponent CMC.LungCModelPopCorrectionFactor
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, -164.8, 8.8] : G2D.Transform
+ LungCOutputsIIIBNosDiagnosisElement774 : SYSDYN.AuxiliarySymbol
+ MOD.ElementToComponent CMC.LungCOutputsIIIBNosDiagnosis
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, 474.4, 351.2] : G2D.Transform
+ Cloud45Element45 : SYSDYN.CloudSymbol
+ MOD.ElementToComponent CMC.Cloud45
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, -310.6, -177.6] : G2D.Transform
+ LungCModelPopCorrectionFactorElement260 : SYSDYN.AuxiliarySymbol
+ MOD.ElementToComponent CMC.LungCModelPopCorrectionFactor
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, -189.4, -74.4] : G2D.Transform
+ LungCOutputs03NosDiagnosisElement768 : SYSDYN.AuxiliarySymbol
+ MOD.ElementToComponent CMC.LungCOutputs03NosDiagnosis
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, 477.0, 248.0] : G2D.Transform
+ LungCOutputs03NsDiagnosisElement673 : SYSDYN.AuxiliarySymbol
+ MOD.ElementToComponent CMC.LungCOutputs03NsDiagnosis
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, 459.4, 240.2] : G2D.Transform
+ LungCOutputsIBNosDiagnosisElement770 : SYSDYN.AuxiliarySymbol
+ MOD.ElementToComponent CMC.LungCOutputsIBNosDiagnosis
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, 475.4, 283.8] : G2D.Transform
+ LungCsIADiagnosisElement593 : SYSDYN.ValveSymbol
+ MOD.ElementToComponent CMC.LungCsIADiagnosis
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, 522.8, 255.4] : G2D.Transform
+ LungCTherapy1Element188 : SYSDYN.ValveSymbol
+ MOD.ElementToComponent CMC.LungCTherapy1
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, 517.6, 159.2] : G2D.Transform
+ LungCOutputsIIIANsNoDElement638 : SYSDYN.AuxiliarySymbol
+ MOD.ElementToComponent CMC.LungCOutputsIIIANsNoD
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, 555.8, 30.6] : G2D.Transform
+ LungCHealthyElement1 : SYSDYN.StockSymbol
+ MOD.ElementToComponent CMC.LungCHealthy
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, -222.4, -177.6] : G2D.Transform
+ LungCs01DiagnosisRateElement506 : SYSDYN.AuxiliarySymbol
+ MOD.ElementToComponent CMC.LungCs01DiagnosisRate
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, -153.8, -140.2] : G2D.Transform
+ LungCTreated1IniValElement136 : SYSDYN.AuxiliarySymbol
+ MOD.ElementToComponent CMC.LungCTreated1IniVal
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, -429.2, 10.0] : G2D.Transform
+ LungCProgressIBIIBRateElement416 : SYSDYN.AuxiliarySymbol
+ MOD.ElementToComponent CMC.LungCProgressIBIIBRate
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, -154.6, 62.4] : G2D.Transform
+ LungCsIIBNoDAgeingElement339 : SYSDYN.ValveSymbol
+ MOD.ElementToComponent CMC.LungCsIIBNoDAgeing
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, -163.6, 106.2] : G2D.Transform
+ LungCProgressIIIAIIIBElement301 : SYSDYN.ValveSymbol
+ MOD.ElementToComponent CMC.LungCProgressIIIAIIIB
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, -270.8, 183.8] : G2D.Transform
+ LungCOutputsIVNsNoDElement640 : SYSDYN.AuxiliarySymbol
+ MOD.ElementToComponent CMC.LungCOutputsIVNsNoD
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, 556.8, 60.4] : G2D.Transform
+ LungCModelPopCorrectionFactorElement120 : SYSDYN.AuxiliarySymbol
+ MOD.ElementToComponent CMC.LungCModelPopCorrectionFactor
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, -182.6, -209.0] : G2D.Transform
+ LungCT1ProgressingIniValElement484 : SYSDYN.AuxiliarySymbol
+ MOD.ElementToComponent CMC.LungCT1ProgressingIniVal
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, -425.0, 17.6] : G2D.Transform
+ LungCT1ProgressesElement928 : SYSDYN.ValveSymbol
+ MOD.ElementToComponent CMC.LungCT1Progresses
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, 206.4, 211.6] : G2D.Transform
+ LungCTherapy1MortalityElement906 : SYSDYN.ValveSymbol
+ MOD.ElementToComponent CMC.LungCTherapy1Mortality
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, 517.6, 154.2] : G2D.Transform
+ LungCs02AgeingElement254 : SYSDYN.ValveSymbol
+ MOD.ElementToComponent CMC.LungCs02Ageing
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, -199.6, -102.4] : G2D.Transform
+ LungCOutputDisabling1Element623 : SYSDYN.AuxiliarySymbol
+ MOD.ElementToComponent CMC.LungCOutputDisabling1
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, 623.8, 121.0] : G2D.Transform
+ LungCOutputsIIIANsDiagnosisElement678 : SYSDYN.AuxiliarySymbol
+ MOD.ElementToComponent CMC.LungCOutputsIIIANsDiagnosis
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, 459.4, 325.2] : G2D.Transform
+ LungCsIIANoDAgeingElement329 : SYSDYN.ValveSymbol
+ MOD.ElementToComponent CMC.LungCsIIANoDAgeing
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, -276.0, 72.2] : G2D.Transform
+ LungCOutputsIIIANosNoDElement755 : SYSDYN.AuxiliarySymbol
+ MOD.ElementToComponent CMC.LungCOutputsIIIANosNoD
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, 553.6, 38.4] : G2D.Transform
+ LungCProgress03IAElement239 : SYSDYN.ValveSymbol
+ MOD.ElementToComponent CMC.LungCProgress03IA
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, -239.2, -37.4] : G2D.Transform
+ LungCOutputsIIIANosDiagnosisElement773 : SYSDYN.AuxiliarySymbol
+ MOD.ElementToComponent CMC.LungCOutputsIIIANosDiagnosis
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, 474.4, 332.8] : G2D.Transform
+ LungCTreated2PopCorrElement158 : SYSDYN.ValveSymbol
+ MOD.ElementToComponent CMC.LungCTreated2PopCorr
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, 44.8, 123.2] : G2D.Transform
+ LungCsIIIBDiagnosisElement400 : SYSDYN.ValveSymbol
+ MOD.ElementToComponent CMC.LungCsIIIBDiagnosis
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, -146.6, 216.4] : G2D.Transform
+ LungCInceptionRateChangesElement733 : SYSDYN.AuxiliarySymbol
+ MOD.ElementToComponent CMC.LungCInceptionRateChanges
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, -164.6, -180.8] : G2D.Transform
+ LungCNotProgressing2Element6 : SYSDYN.StockSymbol
+ MOD.ElementToComponent CMC.LungCNotProgressing2
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, 30.2, 105.8] : G2D.Transform
+ LungCProgressIIBIVRateElement562 : SYSDYN.AuxiliarySymbol
+ MOD.ElementToComponent CMC.LungCProgressIIBIVRate
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, -348.8, 115.8] : G2D.Transform
+ LungCs02DiagnosisElement498 : SYSDYN.ValveSymbol
+ MOD.ElementToComponent CMC.LungCs02Diagnosis
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, -163.2, -86.0] : G2D.Transform
+ LungCFirstTreatmentRateElement94 : SYSDYN.AuxiliarySymbol
+ MOD.ElementToComponent CMC.LungCFirstTreatmentRate
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, 3.2, 73.4] : G2D.Transform
+ LungCCured2Element816 : SYSDYN.StockSymbol
+ MOD.ElementToComponent CMC.LungCCured2
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, 22.8, 148.4] : G2D.Transform
+ LungCOutputs02NosNoDElement748 : SYSDYN.AuxiliarySymbol
+ MOD.ElementToComponent CMC.LungCOutputs02NosNoD
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, 562.2, -48.0] : G2D.Transform
+ LungCOutputs02ScNoDElement652 : SYSDYN.AuxiliarySymbol
+ MOD.ElementToComponent CMC.LungCOutputs02ScNoD
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, 564.2, -52.2] : G2D.Transform
+ LungCProgressIIBIIIAElement297 : SYSDYN.ValveSymbol
+ MOD.ElementToComponent CMC.LungCProgressIIBIIIA
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, -209.6, 139.8] : G2D.Transform
+ LungCs03AgeingElement265 : SYSDYN.ValveSymbol
+ MOD.ElementToComponent CMC.LungCs03Ageing
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, -200.2, -63.8] : G2D.Transform
+ LungCOutputNsDiagnosisElement711 : SYSDYN.AuxiliarySymbol
+ MOD.ElementToComponent CMC.LungCOutputNsDiagnosis
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, 598.2, 260.0] : G2D.Transform
+ LungCTherapyCure1Element792 : SYSDYN.ValveSymbol
+ MOD.ElementToComponent CMC.LungCTherapyCure1
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, -32.8, -2.6] : G2D.Transform
+ LungCT2DisablingIniValElement493 : SYSDYN.AuxiliarySymbol
+ MOD.ElementToComponent CMC.LungCT2DisablingIniVal
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, -427.2, 61.4] : G2D.Transform
+ LungCsIBNoDIniValElement478 : SYSDYN.AuxiliarySymbol
+ MOD.ElementToComponent CMC.LungCsIBNoDIniVal
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, -430.0, -83.0] : G2D.Transform
+ LungCOutputModelPopExcludingHealthyElement892 : SYSDYN.AuxiliarySymbol
+ MOD.ElementToComponent CMC.LungCOutputModelPopExcludingHealthy
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, 408.8, -56.4] : G2D.Transform
+ LungCsIIADiagnosisRateElement384 : SYSDYN.AuxiliarySymbol
+ MOD.ElementToComponent CMC.LungCsIIADiagnosisRate
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, -219.2, 75.2] : G2D.Transform
+ LungCsIIIBNoDElement445 : SYSDYN.StockSymbol
+ MOD.ElementToComponent CMC.LungCsIIIBNoD
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, 514.6, 44.4] : G2D.Transform
+ LungCProgress0102Element18 : SYSDYN.ValveSymbol
+ MOD.ElementToComponent CMC.LungCProgress0102
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, -239.6, -117.0] : G2D.Transform
+ LungCsIVNoDAgeingElement366 : SYSDYN.ValveSymbol
+ MOD.ElementToComponent CMC.LungCsIVNoDAgeing
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, -190.8, 266.8] : G2D.Transform
+ LungCTherapyCure1Element844 : SYSDYN.ValveSymbol
+ MOD.ElementToComponent CMC.LungCTherapyCure1
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, 517.6, 164.6] : G2D.Transform
+ LungCModelPopCorrectionRateElement125 : SYSDYN.AuxiliarySymbol
+ MOD.ElementToComponent CMC.LungCModelPopCorrectionRate
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, 316.4, 13.0] : G2D.Transform
+ LungCsIVDiagnosisElement599 : SYSDYN.ValveSymbol
+ MOD.ElementToComponent CMC.LungCsIVDiagnosis
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, 522.8, 359.8] : G2D.Transform
+ LungCTherapy2Element28 : SYSDYN.ValveSymbol
+ MOD.ElementToComponent CMC.LungCTherapy2
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, -24.8, 109.8] : G2D.Transform
+ LungCsIIANoDElement190 : SYSDYN.StockSymbol
+ MOD.ElementToComponent CMC.LungCsIIANoD
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, -250.0, 83.2] : G2D.Transform
+ LungCsIIIANoDElement272 : SYSDYN.StockSymbol
+ MOD.ElementToComponent CMC.LungCsIIIANoD
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, -249.2, 169.0] : G2D.Transform
+ LungCOutputsIVNosDiagnosisElement775 : SYSDYN.AuxiliarySymbol
+ MOD.ElementToComponent CMC.LungCOutputsIVNosDiagnosis
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, 475.8, 368.8] : G2D.Transform
+ LungCTherapy2RatioElement582 : SYSDYN.AuxiliarySymbol
+ MOD.ElementToComponent CMC.LungCTherapy2Ratio
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, 19.6, 128.8] : G2D.Transform
+ LungCOutputs01NosNoDElement746 : SYSDYN.AuxiliarySymbol
+ MOD.ElementToComponent CMC.LungCOutputs01NosNoD
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, 561.4, -61.8] : G2D.Transform
+ LungCTherapy2FailedElement923 : SYSDYN.ValveSymbol
+ MOD.ElementToComponent CMC.LungCTherapy2Failed
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, 518.0, 176.8] : G2D.Transform
+ LungCCured2AgeingElement822 : SYSDYN.ValveSymbol
+ MOD.ElementToComponent CMC.LungCCured2Ageing
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, 39.4, 161.2] : G2D.Transform
+ LungCModelPopCorrectionFactorElement313 : SYSDYN.AuxiliarySymbol
+ MOD.ElementToComponent CMC.LungCModelPopCorrectionFactor
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, -161.8, 93.4] : G2D.Transform
+ LungCNotProgressing2Element109 : SYSDYN.StockSymbol
+ MOD.ElementToComponent CMC.LungCNotProgressing2
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, 518.6, 101.8] : G2D.Transform
+ LungCs03Element231 : SYSDYN.StockSymbol
+ MOD.ElementToComponent CMC.LungCs03
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, -222.4, -51.8] : G2D.Transform
+ LungCOutputs03NsNoDElement633 : SYSDYN.AuxiliarySymbol
+ MOD.ElementToComponent CMC.LungCOutputs03NsNoD
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, 557.8, -41.2] : G2D.Transform
+ LungCModelPopCorrectionFactorElement148 : SYSDYN.AuxiliarySymbol
+ MOD.ElementToComponent CMC.LungCModelPopCorrectionFactor
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, -37.0, 181.0] : G2D.Transform
+ LungCOutputsIIANosNoDElement753 : SYSDYN.AuxiliarySymbol
+ MOD.ElementToComponent CMC.LungCOutputsIIANosNoD
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, 562.4, 9.6] : G2D.Transform
+ LungCsIIIANoDPopCorrElement344 : SYSDYN.ValveSymbol
+ MOD.ElementToComponent CMC.LungCsIIIANoDPopCorr
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, -272.2, 147.0] : G2D.Transform
+ LungCs01DiagnosisElement505 : SYSDYN.ValveSymbol
+ MOD.ElementToComponent CMC.LungCs01Diagnosis
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, -161.6, -126.6] : G2D.Transform
+ LungCs02Element441 : SYSDYN.StockSymbol
+ MOD.ElementToComponent CMC.LungCs02
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, 515.0, -54.8] : G2D.Transform
+ LungCOutputs02NsDiagnosisElement672 : SYSDYN.AuxiliarySymbol
+ MOD.ElementToComponent CMC.LungCOutputs02NsDiagnosis
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, 459.4, 223.8] : G2D.Transform
+ LungCOutputsIANosDiagnosisElement769 : SYSDYN.AuxiliarySymbol
+ MOD.ElementToComponent CMC.LungCOutputsIANosDiagnosis
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, 477.6, 265.6] : G2D.Transform
+ LungCs01Element106 : SYSDYN.StockSymbol
+ MOD.ElementToComponent CMC.LungCs01
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, 514.6, -68.2] : G2D.Transform
+ LungCProgress02IVElement516 : SYSDYN.ValveSymbol
+ MOD.ElementToComponent CMC.LungCProgress02IV
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, -323.4, -89.0] : G2D.Transform
+ LungCT1ProgressingElement197 : SYSDYN.StockSymbol
+ MOD.ElementToComponent CMC.LungCT1Progressing
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, 115.0, 36.2] : G2D.Transform
+ LungCOutputTherapy1CureElement853 : SYSDYN.AuxiliarySymbol
+ MOD.ElementToComponent CMC.LungCOutputTherapy1Cure
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, 460.0, 162.4] : G2D.Transform
+ LungCsIANoDIniValElement138 : SYSDYN.AuxiliarySymbol
+ MOD.ElementToComponent CMC.LungCsIANoDIniVal
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, -430.0, -90.2] : G2D.Transform
+ LungCOutputsIANosNoDElement751 : SYSDYN.AuxiliarySymbol
+ MOD.ElementToComponent CMC.LungCOutputsIANosNoD
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, 563.0, -17.8] : G2D.Transform
+ LungCOutputTherapy1MortalityInTherapyElement908 : SYSDYN.AuxiliarySymbol
+ MOD.ElementToComponent CMC.LungCOutputTherapy1MortalityInTherapy
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, 456.4, 150.8] : G2D.Transform
+ LungCTreated2AgeingElement82 : SYSDYN.ValveSymbol
+ MOD.ElementToComponent CMC.LungCTreated2Ageing
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, 49.8, 118.6] : G2D.Transform
+ LungCs01IniValElement137 : SYSDYN.AuxiliarySymbol
+ MOD.ElementToComponent CMC.LungCs01IniVal
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, -427.8, -114.0] : G2D.Transform
+ LungCOutputDisabling2Element624 : SYSDYN.AuxiliarySymbol
+ MOD.ElementToComponent CMC.LungCOutputDisabling2
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, 628.8, 137.6] : G2D.Transform
+ LungCT1ProgressesRateElement86 : SYSDYN.AuxiliarySymbol
+ MOD.ElementToComponent CMC.LungCT1ProgressesRate
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, 70.0, 26.8] : G2D.Transform
+ LungCs02PopCorrElement248 : SYSDYN.ValveSymbol
+ MOD.ElementToComponent CMC.LungCs02PopCorr
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, -202.0, -107.4] : G2D.Transform
+ LungCOutputsIIAScNoDElement656 : SYSDYN.AuxiliarySymbol
+ MOD.ElementToComponent CMC.LungCOutputsIIAScNoD
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, 563.2, 5.8] : G2D.Transform
+ LungCsIVNoDPopCorrElement372 : SYSDYN.ValveSymbol
+ MOD.ElementToComponent CMC.LungCsIVNoDPopCorr
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, -194.6, 272.0] : G2D.Transform
+ LungCoutputNoDNosElement860 : SYSDYN.AuxiliarySymbol
+ MOD.ElementToComponent CMC.LungCoutputNoDNos
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, 659.6, 9.6] : G2D.Transform
+ LungCOutputsIIANosDiagnosisElement771 : SYSDYN.AuxiliarySymbol
+ MOD.ElementToComponent CMC.LungCOutputsIIANosDiagnosis
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, 477.4, 301.2] : G2D.Transform
+ LungCs01Element2 : SYSDYN.StockSymbol
+ MOD.ElementToComponent CMC.LungCs01
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, -221.8, -130.0] : G2D.Transform
+ LungCOutputCured1Element814 : SYSDYN.AuxiliarySymbol
+ MOD.ElementToComponent CMC.LungCOutputCured1
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, 631.2, 92.0] : G2D.Transform
+ LungCTherapy1CureRatioElement808 : SYSDYN.AuxiliarySymbol
+ MOD.ElementToComponent CMC.LungCTherapy1CureRatio
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, -53.0, 19.4] : G2D.Transform
+ LungCsIIIBDiagnosisRateElement401 : SYSDYN.AuxiliarySymbol
+ MOD.ElementToComponent CMC.LungCsIIIBDiagnosisRate
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, -144.0, 223.4] : G2D.Transform
+ LungCsIVDiagnosisRateElement427 : SYSDYN.AuxiliarySymbol
+ MOD.ElementToComponent CMC.LungCsIVDiagnosisRate
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, -153.0, 266.6] : G2D.Transform
+ LungCTherapyCure2Element845 : SYSDYN.ValveSymbol
+ MOD.ElementToComponent CMC.LungCTherapyCure2
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, 519.2, 188.6] : G2D.Transform
+ LungCOutputsIIBNsDiagnosisElement677 : SYSDYN.AuxiliarySymbol
+ MOD.ElementToComponent CMC.LungCOutputsIIBNsDiagnosis
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, 459.4, 310.2] : G2D.Transform
+ LungCOutputModelPopElement186 : SYSDYN.AuxiliarySymbol
+ MOD.ElementToComponent CMC.LungCOutputModelPop
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, 384.6, -0.2] : G2D.Transform
+ LungCT2ProgressingElement110 : SYSDYN.StockSymbol
+ MOD.ElementToComponent CMC.LungCT2Progressing
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, 517.0, 131.8] : G2D.Transform
+ LungCsIANoDPopCorrElement147 : SYSDYN.ValveSymbol
+ MOD.ElementToComponent CMC.LungCsIANoDPopCorr
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, -202.4, -30.2] : G2D.Transform
+ LungCs01DiagnosisElement590 : SYSDYN.ValveSymbol
+ MOD.ElementToComponent CMC.LungCs01Diagnosis
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, 522.8, 206.6] : G2D.Transform
+ LungCCured2IniValElement829 : SYSDYN.AuxiliarySymbol
+ MOD.ElementToComponent CMC.LungCCured2IniVal
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, -428.4, 69.8] : G2D.Transform
+ LungCModelPopCorrectionFactorElement112 : SYSDYN.AuxiliarySymbol
+ MOD.ElementToComponent CMC.LungCModelPopCorrectionFactor
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, 359.0, 33.2] : G2D.Transform
+ LungCModelPopCorrectionFactorElement345 : SYSDYN.AuxiliarySymbol
+ MOD.ElementToComponent CMC.LungCModelPopCorrectionFactor
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, -274.2, 139.2] : G2D.Transform
+ LungCTherapy2FailRatioElement915 : SYSDYN.AuxiliarySymbol
+ MOD.ElementToComponent CMC.LungCTherapy2FailRatio
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, -2.4, 165.8] : G2D.Transform
+ LungCsIIBDiagnosisElement596 : SYSDYN.ValveSymbol
+ MOD.ElementToComponent CMC.LungCsIIBDiagnosis
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, 522.8, 309.2] : G2D.Transform
+ LungCsIBNoDAgeingElement319 : SYSDYN.ValveSymbol
+ MOD.ElementToComponent CMC.LungCsIBNoDAgeing
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, -167.0, 25.8] : G2D.Transform
+ LungCOutputNosDiagnosisElement735 : SYSDYN.AuxiliarySymbol
+ MOD.ElementToComponent CMC.LungCOutputNosDiagnosis
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, 604.2, 325.2] : G2D.Transform
+ LungCOutputNotProgressing2Element588 : SYSDYN.AuxiliarySymbol
+ MOD.ElementToComponent CMC.LungCOutputNotProgressing2
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, 628.6, 102.0] : G2D.Transform
+ LungCOutputsIIIBNosNoDElement756 : SYSDYN.AuxiliarySymbol
+ MOD.ElementToComponent CMC.LungCOutputsIIIBNosNoD
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, 559.6, 53.8] : G2D.Transform
+ LungCsIIIANoDElement446 : SYSDYN.StockSymbol
+ MOD.ElementToComponent CMC.LungCsIIIANoD
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, 514.4, 30.6] : G2D.Transform
+ LungCProgressIIBIIIBRateElement420 : SYSDYN.AuxiliarySymbol
+ MOD.ElementToComponent CMC.LungCProgressIIBIIIBRate
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, -160.2, 152.0] : G2D.Transform
+ LungCOutputT1MortalityElement617 : SYSDYN.AuxiliarySymbol
+ MOD.ElementToComponent CMC.LungCOutputT1Mortality
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, 250.0, 57.8] : G2D.Transform
+ LungCOutputsIIIBNsNoDElement639 : SYSDYN.AuxiliarySymbol
+ MOD.ElementToComponent CMC.LungCOutputsIIIBNsNoD
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, 556.0, 45.2] : G2D.Transform
+ LungCDIniValElement494 : SYSDYN.AuxiliarySymbol
+ MOD.ElementToComponent CMC.LungCDIniVal
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, -429.0, -9.4] : G2D.Transform
+ LungCOutputsIIANsNoDElement636 : SYSDYN.AuxiliarySymbol
+ MOD.ElementToComponent CMC.LungCOutputsIIANsNoD
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, 556.0, 2.4] : G2D.Transform
+ LungCModelPopCorrectionFactorElement369 : SYSDYN.AuxiliarySymbol
+ MOD.ElementToComponent CMC.LungCModelPopCorrectionFactor
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, -198.8, 278.6] : G2D.Transform
+ LungCProgressIIAIVRateElement561 : SYSDYN.AuxiliarySymbol
+ MOD.ElementToComponent CMC.LungCProgressIIAIVRate
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, -349.4, 72.4] : G2D.Transform
+ LungCOutputs01ScNoDElement651 : SYSDYN.AuxiliarySymbol
+ MOD.ElementToComponent CMC.LungCOutputs01ScNoD
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, 563.2, -65.6] : G2D.Transform
+ LungCsIVNoDElement448 : SYSDYN.StockSymbol
+ MOD.ElementToComponent CMC.LungCsIVNoD
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, 515.4, 59.8] : G2D.Transform
+ LungCOutputNoDSumElement629 : SYSDYN.AuxiliarySymbol
+ MOD.ElementToComponent CMC.LungCOutputNoDSum
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, 459.4, 20.6] : G2D.Transform
+ LungCsIVNoDIniValElement483 : SYSDYN.AuxiliarySymbol
+ MOD.ElementToComponent CMC.LungCsIVNoDIniVal
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, -429.8, -42.6] : G2D.Transform
+ LungCT1ProgressingPopCorrElement216 : SYSDYN.ValveSymbol
+ MOD.ElementToComponent CMC.LungCT1ProgressingPopCorr
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, 133.2, 55.8] : G2D.Transform
+ LungCOutputTherapy1NoCureElement852 : SYSDYN.AuxiliarySymbol
+ MOD.ElementToComponent CMC.LungCOutputTherapy1NoCure
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, 457.2, 156.6] : G2D.Transform
+ LungCOutputsIVScNoDElement660 : SYSDYN.AuxiliarySymbol
+ MOD.ElementToComponent CMC.LungCOutputsIVScNoD
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, 564.0, 65.0] : G2D.Transform
+ LungCProgress0102RateElement63 : SYSDYN.AuxiliarySymbol
+ MOD.ElementToComponent CMC.LungCProgress0102Rate
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, -249.6, -108.2] : G2D.Transform
+ LungCOutputDiagnosisElement600 : SYSDYN.AuxiliarySymbol
+ MOD.ElementToComponent CMC.LungCOutputDiagnosis
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, 603.8, 229.6] : G2D.Transform
+ LungCModelPopCorrectionFactorElement359 : SYSDYN.AuxiliarySymbol
+ MOD.ElementToComponent CMC.LungCModelPopCorrectionFactor
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, -155.6, 186.2] : G2D.Transform
+ LungCOutputHealthyAndTreatedElement182 : SYSDYN.AuxiliarySymbol
+ MOD.ElementToComponent CMC.LungCOutputHealthyAndTreated
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, 654.6, -70.8] : G2D.Transform
+ LungCOutputsIIANsDiagnosisElement676 : SYSDYN.AuxiliarySymbol
+ MOD.ElementToComponent CMC.LungCOutputsIIANsDiagnosis
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, 459.4, 292.2] : G2D.Transform
+ LungCNotProgressing1Element108 : SYSDYN.StockSymbol
+ MOD.ElementToComponent CMC.LungCNotProgressing1
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, 516.8, 87.4] : G2D.Transform
+ LungCT2DeathRateElement92 : SYSDYN.AuxiliarySymbol
+ MOD.ElementToComponent CMC.LungCT2DeathRate
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, 243.8, 89.6] : G2D.Transform
+ LungCProgressIAIBRateElement414 : SYSDYN.AuxiliarySymbol
+ MOD.ElementToComponent CMC.LungCProgressIAIBRate
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, -195.4, 4.6] : G2D.Transform
+ LungCT2DeceasedElement10 : SYSDYN.StockSymbol
+ MOD.ElementToComponent CMC.LungCT2Deceased
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, 292.6, 103.8] : G2D.Transform
+ LungCs03IniValElement477 : SYSDYN.AuxiliarySymbol
+ MOD.ElementToComponent CMC.LungCs03IniVal
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, -428.0, -100.0] : G2D.Transform
+ LungCOutputs01NsDiagnosisElement671 : SYSDYN.AuxiliarySymbol
+ MOD.ElementToComponent CMC.LungCOutputs01NsDiagnosis
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, 459.4, 206.0] : G2D.Transform
+ LungCModelPopCorrectionFactorElement142 : SYSDYN.AuxiliarySymbol
+ MOD.ElementToComponent CMC.LungCModelPopCorrectionFactor
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, -149.8, -148.8] : G2D.Transform
+ LungCOutputs02NsNoDElement632 : SYSDYN.AuxiliarySymbol
+ MOD.ElementToComponent CMC.LungCOutputs02NsNoD
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, 556.4, -55.4] : G2D.Transform
+ LungCsIIIADiagnosisElement394 : SYSDYN.ValveSymbol
+ MOD.ElementToComponent CMC.LungCsIIIADiagnosis
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, -213.0, 176.2] : G2D.Transform
+ LungCT2ProgressesElement929 : SYSDYN.ValveSymbol
+ MOD.ElementToComponent CMC.LungCT2Progresses
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, 205.2, 229.0] : G2D.Transform
+ LungCTherapy2CureRatioElement837 : SYSDYN.AuxiliarySymbol
+ MOD.ElementToComponent CMC.LungCTherapy2CureRatio
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, -47.8, 128.6] : G2D.Transform
+ LungCHealthyIniValElement133 : SYSDYN.AuxiliarySymbol
+ MOD.ElementToComponent CMC.LungCHealthyIniVal
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, -424.2, -127.4] : G2D.Transform
+ LungCOutputMortalityElement615 : SYSDYN.AuxiliarySymbol
+ MOD.ElementToComponent CMC.LungCOutputMortality
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, 387.8, 76.4] : G2D.Transform
+ LungCs03DiagnosisElement592 : SYSDYN.ValveSymbol
+ MOD.ElementToComponent CMC.LungCs03Diagnosis
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, 522.8, 239.4] : G2D.Transform
+ LungCsIANoDElement123 : SYSDYN.StockSymbol
+ MOD.ElementToComponent CMC.LungCsIANoD
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, 515.4, -25.6] : G2D.Transform
+ TotalPopulationBirthElement50 : SYSDYN.AuxiliarySymbol
+ MOD.ElementToComponent CMC.TotalPopulationBirth
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, -296.2, -187.4] : G2D.Transform
+ LungCs02IniValElement476 : SYSDYN.AuxiliarySymbol
+ MOD.ElementToComponent CMC.LungCs02IniVal
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, -428.0, -107.4] : G2D.Transform
+ LungCOutputScDiagnosisElement712 : SYSDYN.AuxiliarySymbol
+ MOD.ElementToComponent CMC.LungCOutputScDiagnosis
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, 601.0, 290.2] : G2D.Transform
+ LungCOutputs01NsNoDElement631 : SYSDYN.AuxiliarySymbol
+ MOD.ElementToComponent CMC.LungCOutputs01NsNoD
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, 556.0, -68.6] : G2D.Transform
+ LungCT1DeathRateElement210 : SYSDYN.AuxiliarySymbol
+ MOD.ElementToComponent CMC.LungCT1DeathRate
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, 239.2, 25.4] : G2D.Transform
+ LungCProgressIAIIARateElement406 : SYSDYN.AuxiliarySymbol
+ MOD.ElementToComponent CMC.LungCProgressIAIIARate
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, -265.8, 9.4] : G2D.Transform
+ LungCsIIIBNoDIniValElement482 : SYSDYN.AuxiliarySymbol
+ MOD.ElementToComponent CMC.LungCsIIIBNoDIniVal
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, -428.8, -50.8] : G2D.Transform
+ LungCOutputs01NosDiagnosisElement766 : SYSDYN.AuxiliarySymbol
+ MOD.ElementToComponent CMC.LungCOutputs01NosDiagnosis
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, 476.0, 215.2] : G2D.Transform
+ LungCInceptionRateElement56 : SYSDYN.AuxiliarySymbol
+ MOD.ElementToComponent CMC.LungCInceptionRate
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, -160.4, -155.2] : G2D.Transform
+ LungCs02DiagnosisRateElement499 : SYSDYN.AuxiliarySymbol
+ MOD.ElementToComponent CMC.LungCs02DiagnosisRate
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, -158.8, -101.0] : G2D.Transform
+ LungCNoDSumElement449 : SYSDYN.AuxiliarySymbol
+ MOD.ElementToComponent CMC.LungCNoDSum
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, 462.0, 1.0] : G2D.Transform
+ LungCOutputsIIIAScNoDElement658 : SYSDYN.AuxiliarySymbol
+ MOD.ElementToComponent CMC.LungCOutputsIIIAScNoD
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, 563.0, 34.8] : G2D.Transform
+ LungCHealthyAgeingElement54 : SYSDYN.ValveSymbol
+ MOD.ElementToComponent CMC.LungCHealthyAgeing
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, -197.6, -197.2] : G2D.Transform
+ LungCsIVNoDElement274 : SYSDYN.StockSymbol
+ MOD.ElementToComponent CMC.LungCsIVNoD
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, -210.0, 253.8] : G2D.Transform
+ LungCOutputsIIIBScNoDElement659 : SYSDYN.AuxiliarySymbol
+ MOD.ElementToComponent CMC.LungCOutputsIIIBScNoD
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, 563.2, 49.4] : G2D.Transform
+ LungCOutputs02ScDiagnosisElement682 : SYSDYN.AuxiliarySymbol
+ MOD.ElementToComponent CMC.LungCOutputs02ScDiagnosis
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, 470.8, 228.4] : G2D.Transform
+ LungCOutputsIBNsNoDElement635 : SYSDYN.AuxiliarySymbol
+ MOD.ElementToComponent CMC.LungCOutputsIBNsNoD
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, 557.8, -10.8] : G2D.Transform
+ LungCT2ProgToDisablingRateElement88 : SYSDYN.AuxiliarySymbol
+ MOD.ElementToComponent CMC.LungCT2ProgToDisablingRate
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, 161.0, 95.2] : G2D.Transform
+ LungCOutputsIAScNoDElement654 : SYSDYN.AuxiliarySymbol
+ MOD.ElementToComponent CMC.LungCOutputsIAScNoD
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, 564.0, -21.4] : G2D.Transform
+ LungCCured1IniValElement788 : SYSDYN.AuxiliarySymbol
+ MOD.ElementToComponent CMC.LungCCured1IniVal
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, -431.0, 32.2] : G2D.Transform
+ LungCOutputT2MortalityElement618 : SYSDYN.AuxiliarySymbol
+ MOD.ElementToComponent CMC.LungCOutputT2Mortality
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, 258.4, 126.0] : G2D.Transform
+ LungCOutputTherapy2NoCureElement848 : SYSDYN.AuxiliarySymbol
+ MOD.ElementToComponent CMC.LungCOutputTherapy2NoCure
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, 448.6, 181.8] : G2D.Transform
+ LungCOutputsIBScNoDElement655 : SYSDYN.AuxiliarySymbol
+ MOD.ElementToComponent CMC.LungCOutputsIBScNoD
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, 565.0, -7.0] : G2D.Transform
+ LungCOutputsIIBScDiagnosisElement687 : SYSDYN.AuxiliarySymbol
+ MOD.ElementToComponent CMC.LungCOutputsIIBScDiagnosis
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, 470.8, 314.2] : G2D.Transform
+ LungCsIIBNoDElement271 : SYSDYN.StockSymbol
+ MOD.ElementToComponent CMC.LungCsIIBNoD
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, -185.6, 125.2] : G2D.Transform
+ LungCModelPopCorrectionFactorElement267 : SYSDYN.AuxiliarySymbol
+ MOD.ElementToComponent CMC.LungCModelPopCorrectionFactor
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, -189.4, -36.6] : G2D.Transform
+ LungCT2ProgressingIniValElement491 : SYSDYN.AuxiliarySymbol
+ MOD.ElementToComponent CMC.LungCT2ProgressingIniVal
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, -425.8, 53.4] : G2D.Transform
+ LungCT1DisablingElement461 : SYSDYN.StockSymbol
+ MOD.ElementToComponent CMC.LungCT1Disabling
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, 517.8, 120.0] : G2D.Transform
+ LungCHealthyElement105 : SYSDYN.StockSymbol
+ MOD.ElementToComponent CMC.LungCHealthy
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, 515.8, -82.8] : G2D.Transform
+ LungCOutputTherapy2FailedElement925 : SYSDYN.AuxiliarySymbol
+ MOD.ElementToComponent CMC.LungCOutputTherapy2Failed
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, 452.4, 176.2] : G2D.Transform
+ LungCOutputsIVNosNoDElement757 : SYSDYN.AuxiliarySymbol
+ MOD.ElementToComponent CMC.LungCOutputsIVNosNoD
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, 561.4, 69.4] : G2D.Transform
+ LungCCured2Element840 : SYSDYN.StockSymbol
+ MOD.ElementToComponent CMC.LungCCured2
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, 518.8, 106.6] : G2D.Transform
+ LungCsIANoDElement3 : SYSDYN.StockSymbol
+ MOD.ElementToComponent CMC.LungCsIANoD
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, -223.4, -8.6] : G2D.Transform
+ LungCsIIIADiagnosisElement597 : SYSDYN.ValveSymbol
+ MOD.ElementToComponent CMC.LungCsIIIADiagnosis
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, 522.8, 324.6] : G2D.Transform
+ LungCT2DisablingElement9 : SYSDYN.StockSymbol
+ MOD.ElementToComponent CMC.LungCT2Disabling
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, 210.0, 104.4] : G2D.Transform
+ LungCT2DisablingElement111 : SYSDYN.StockSymbol
+ MOD.ElementToComponent CMC.LungCT2Disabling
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, 517.4, 136.2] : G2D.Transform
+ LungCModelPopCorrectionFactorElement802 : SYSDYN.AuxiliarySymbol
+ MOD.ElementToComponent CMC.LungCModelPopCorrectionFactor
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, 45.8, -41.2] : G2D.Transform
+ LungCProgressIIAIIIARateElement408 : SYSDYN.AuxiliarySymbol
+ MOD.ElementToComponent CMC.LungCProgressIIAIIIARate
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, -287.0, 89.2] : G2D.Transform
+ LungCs02DiagnosisElement591 : SYSDYN.ValveSymbol
+ MOD.ElementToComponent CMC.LungCs02Diagnosis
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, 522.8, 224.0] : G2D.Transform
+ LungCDElement4 : SYSDYN.StockSymbol
+ MOD.ElementToComponent CMC.LungCD
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, -107.6, 73.2] : G2D.Transform
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d127
+ @WM.dependency LungCModelPopElement104 LungCDElement124 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d882
+ @WM.dependency LungCoutputNoDNosElement860 LungCOutputs01NosNoDElement746 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d331
+ @WM.dependency LungCsIIANoDAgeingElement329 DummyRateForUnitsConversionElement98 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d737
+ @WM.dependency LungCOutputNosDiagnosisElement735 LungCs02DiagnosisElement591 -0.1
+ _ : SYSDYN.FlowConnection
+ MOD.DiagramConnectionToConnection CMC.f580
+ @WM.flow LungCsIVNoDElement274 LungCProgressIIIBIVElement542
+ _ : SYSDYN.FlowConnection
+ MOD.DiagramConnectionToConnection CMC.f805
+ @WM.flow LungCTherapyCure1Element792 LungCDElement4
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d84
+ @WM.dependency LungCT1ProgressesElement32 LungCNotProgressing1Element5 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d463
+ @WM.dependency LungCModelPopElement104 LungCNotProgressing2Element109 -0.1
+ _ : SYSDYN.FlowConnection
+ MOD.DiagramConnectionToConnection CMC.f517
+ @WM.flow LungCsIVNoDElement274 LungCProgress03IVElement520
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d458
+ @WM.dependency LungCNoDSumElement449 LungCsIIIBNoDElement445 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d451
+ @WM.dependency LungCNoDSumElement449 LungCs02Element441 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d220
+ @WM.dependency LungCT1ProgressingPopCorrElement216 LungCModelPopCorrectionFactorElement153 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d454
+ @WM.dependency LungCNoDSumElement449 LungCsIBNoDElement443 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d846
+ @WM.dependency LungCOutputTherapy1Element611 LungCTherapyCure1Element844 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d722
+ @WM.dependency LungCOutputNsDiagnosisElement711 LungCsIVDiagnosisElement599 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d578
+ @WM.dependency LungCProgressIIIBIVElement542 LungCsIIIBNoDElement273 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d695
+ @WM.dependency LungCOutputs03NsDiagnosisElement673 LungCs03DiagnosisElement592 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d728
+ @WM.dependency LungCOutputScDiagnosisElement712 LungCsIIADiagnosisElement595 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d742
+ @WM.dependency LungCOutputNosDiagnosisElement735 LungCsIIBDiagnosisElement596 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d378
+ @WM.dependency LungCsIBDiagnosisElement377 LungCsIBNoDElement270 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d325
+ @WM.dependency LungCsIIANoDPopCorrElement324 LungCsIIANoDElement190 -0.1
+ _ : SYSDYN.FlowConnection
+ MOD.DiagramConnectionToConnection CMC.f29
+ @WM.flow LungCT1ProgressingElement197 LungCT1ProgressesElement32
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d889
+ @WM.dependency LungCoutputNoDNosElement860 LungCOutputsIIIANosNoDElement755 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d572
+ @WM.dependency LungCProgressIIAIVElement532 LungCsIIANoDElement190 -0.1
+ _ : SYSDYN.FlowConnection
+ MOD.DiagramConnectionToConnection CMC.f540
+ @WM.flow LungCProgressIIIBIVElement542 LungCsIIIBNoDElement273
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d58
+ @WM.dependency LungCInceptionElement14 LungCHealthyElement1 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d211
+ @WM.dependency LungCT1DeathElement207 LungCT1DeathRateElement210 -0.1
+ _ : SYSDYN.FlowConnection
+ MOD.DiagramConnectionToConnection CMC.f15
+ @WM.flow LungCs02Element230 LungCProgress0102Element18
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d861
+ @WM.dependency LungCOutputNoDNsElement858 LungCOutputs01NsNoDElement631 -0.1
+ _ : SYSDYN.FlowConnection
+ MOD.DiagramConnectionToConnection CMC.f337
+ @WM.flow LungCsIIBNoDElement271 LungCsIIBNoDAgeingElement339
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d101
+ @WM.dependency LungCTreated1AgeingElement78 DummyRateForUnitsConversionElement98 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d340
+ @WM.dependency LungCsIIBNoDAgeingElement339 LungCsIIBNoDElement271 -0.1
+ _ : SYSDYN.FlowConnection
+ MOD.DiagramConnectionToConnection CMC.f76
+ @WM.flow LungCNotProgressing1Element5 LungCTreated1AgeingElement78
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d62
+ @WM.dependency LungCs01AgeingElement61 LungCs01Element2 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d833
+ @WM.dependency LungCCured2AgeingElement822 DummyRateForUnitsConversionElement98 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d571
+ @WM.dependency LungCProgressIIAIVElement532 LungCProgressIIAIVRateElement561 -0.1
+ _ : SYSDYN.FlowConnection
+ MOD.DiagramConnectionToConnection CMC.f139
+ @WM.flow LungCs01Element2 LungCs01PopCorrElement141
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d129
+ @WM.dependency LungCModelPopCorrectionFactorElement112 TotalPopulationDeathElement114 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d917
+ @WM.dependency LungCTherapyCure2Element819 LungCTherapy2FailRatioElement915 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d926
+ @WM.dependency LungCOutputTherapy2FailedElement925 LungCTherapy2FailedElement923 -0.1
+ _ : SYSDYN.FlowConnection
+ MOD.DiagramConnectionToConnection CMC.f495
+ @WM.flow LungCDElement4 LungCs02DiagnosisElement498
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d739
+ @WM.dependency LungCOutputNosDiagnosisElement735 LungCsIADiagnosisElement593 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d876
+ @WM.dependency LungCOutputNoDScElement859 LungCOutputsIBScNoDElement655 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d662
+ @WM.dependency LungCOutputs02ScNoDElement652 LungCs02Element441 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d783
+ @WM.dependency LungCOutputsIIIANosDiagnosisElement773 LungCsIIIADiagnosisElement597 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d758
+ @WM.dependency LungCOutputs03NosNoDElement750 LungCs03Element442 -0.1
+ _ : SYSDYN.FlowConnection
+ MOD.DiagramConnectionToConnection CMC.f236
+ @WM.flow LungCsIANoDElement3 LungCProgress03IAElement239
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d706
+ @WM.dependency LungCOutputsIIIAScDiagnosisElement688 LungCsIIIADiagnosisElement597 -0.1
+ _ : SYSDYN.FlowConnection
+ MOD.DiagramConnectionToConnection CMC.f348
+ @WM.flow LungCsIIIANoDElement272 LungCsIIIANoDAgeingElement350
+ _ : SYSDYN.FlowConnection
+ MOD.DiagramConnectionToConnection CMC.f145
+ @WM.flow LungCsIANoDElement3 LungCsIANoDPopCorrElement147
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d627
+ @WM.dependency LungCOutputProgressing2Element622 LungCT2ProgressingElement110 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d715
+ @WM.dependency LungCOutputNsDiagnosisElement711 LungCs03DiagnosisElement592 -0.1
+ _ : SYSDYN.FlowConnection
+ MOD.DiagramConnectionToConnection CMC.f23
+ @WM.flow LungCNotProgressing1Element5 LungCTherapy1Element25
+ _ : SYSDYN.FlowConnection
+ MOD.DiagramConnectionToConnection CMC.f364
+ @WM.flow LungCsIVNoDElement274 LungCsIVNoDAgeingElement366
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d96
+ @WM.dependency LungCTherapy2Element28 LungCFirstTreatmentRateElement94 -0.1
+ _ : SYSDYN.FlowConnection
+ MOD.DiagramConnectionToConnection CMC.f509
+ @WM.flow LungCsIVNoDElement274 LungCProgress01IVElement512
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d160
+ @WM.dependency LungCTreated2PopCorrElement158 LungCModelPopCorrectionFactorElement159 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d569
+ @WM.dependency LungCProgressIBIVElement528 LungCProgressIBIVRateElement560 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d367
+ @WM.dependency LungCsIVNoDAgeingElement366 LungCsIVNoDElement274 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d716
+ @WM.dependency LungCOutputNsDiagnosisElement711 LungCsIADiagnosisElement593 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d391
+ @WM.dependency LungCsIIBDiagnosisElement388 LungCsIIBDiagnosisRateElement389 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d778
+ @WM.dependency LungCOutputs03NosDiagnosisElement768 LungCs03DiagnosisElement592 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d743
+ @WM.dependency LungCOutputNosDiagnosisElement735 LungCsIIIADiagnosisElement597 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d720
+ @WM.dependency LungCOutputNsDiagnosisElement711 LungCsIIIADiagnosisElement597 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d723
+ @WM.dependency LungCOutputScDiagnosisElement712 LungCs01DiagnosisElement590 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d453
+ @WM.dependency LungCNoDSumElement449 LungCsIANoDElement123 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d180
+ @WM.dependency LungCT2ProgressingAgeingElement179 DummyRateForUnitsConversionElement98 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d244
+ @WM.dependency LungCProgress0203Element235 LungCs02Element230 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d351
+ @WM.dependency LungCsIIIANoDAgeingElement350 DummyRateForUnitsConversionElement98 -0.1
+ _ : SYSDYN.FlowConnection
+ MOD.DiagramConnectionToConnection CMC.f246
+ @WM.flow LungCs02Element230 LungCs02PopCorrElement248
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d835
+ @WM.dependency LungCCured2PopCorrElement826 LungCModelPopCorrectionFactorElement834 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d415
+ @WM.dependency LungCProgressIAIBElement277 LungCProgressIAIBRateElement414 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d452
+ @WM.dependency LungCNoDSumElement449 LungCs03Element442 -0.1
+ _ : SYSDYN.FlowConnection
+ MOD.DiagramConnectionToConnection CMC.f342
+ @WM.flow LungCsIIIANoDElement272 LungCsIIIANoDPopCorrElement344
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d862
+ @WM.dependency LungCOutputNoDNsElement858 LungCOutputs02NsNoDElement632 -0.1
+ _ : SYSDYN.FlowConnection
+ MOD.DiagramConnectionToConnection CMC.f579
+ @WM.flow LungCsIVNoDElement274 LungCProgressIIIAIVElement539
+ _ : SYSDYN.FlowConnection
+ MOD.DiagramConnectionToConnection CMC.f295
+ @WM.flow LungCProgressIIBIIIAElement297 LungCsIIBNoDElement271
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d341
+ @WM.dependency LungCsIIBNoDAgeingElement339 DummyRateForUnitsConversionElement98 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d87
+ @WM.dependency LungCT1ProgressesElement32 LungCT1ProgressesRateElement86 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d508
+ @WM.dependency LungCs01DiagnosisElement505 LungCs01DiagnosisRateElement506 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d221
+ @WM.dependency LungCT1ProgressingPopCorrElement216 LungCT1ProgressingElement197 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d64
+ @WM.dependency LungCProgress0102Element18 LungCProgress0102RateElement63 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d417
+ @WM.dependency LungCProgressIBIIBElement281 LungCProgressIBIIBRateElement416 -0.1
+ _ : SYSDYN.FlowConnection
+ MOD.DiagramConnectionToConnection CMC.f12
+ @WM.flow LungCInceptionElement14 LungCHealthyElement1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d881
+ @WM.dependency LungCOutputNoDScElement859 LungCOutputsIVScNoDElement660 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d765
+ @WM.dependency LungCOutputsIVNosNoDElement757 LungCsIVNoDElement448 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d784
+ @WM.dependency LungCOutputsIIIBNosDiagnosisElement774 LungCsIIIBDiagnosisElement598 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d507
+ @WM.dependency LungCs01DiagnosisElement505 LungCs01Element2 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d405
+ @WM.dependency LungCsIIADiagnosisElement383 LungCsIIANoDElement190 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d573
+ @WM.dependency LungCProgressIIBIVElement536 LungCProgressIIBIVRateElement562 -0.1
+ _ : SYSDYN.FlowConnection
+ MOD.DiagramConnectionToConnection CMC.f237
+ @WM.flow LungCProgress03IAElement239 LungCs03Element231
+ _ : SYSDYN.FlowConnection
+ MOD.DiagramConnectionToConnection CMC.f370
+ @WM.flow LungCsIVNoDElement274 LungCsIVNoDPopCorrElement372
+ _ : SYSDYN.FlowConnection
+ MOD.DiagramConnectionToConnection CMC.f309
+ @WM.flow LungCsIBNoDElement270 LungCsIBNoDPopCorrElement311
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d762
+ @WM.dependency LungCOutputsIIBNosNoDElement754 LungCsIIBNoDElement447 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d734
+ @WM.dependency LungCInceptionElement14 LungCInceptionRateChangesElement733 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d875
+ @WM.dependency LungCOutputNoDScElement859 LungCOutputsIAScNoDElement654 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d567
+ @WM.dependency LungCProgress03IVElement520 LungCs03Element231 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d116
+ @WM.dependency LungCCausedDeathElement115 LungCT2DeathElement44 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d144
+ @WM.dependency LungCs01PopCorrElement141 LungCs01Element2 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d914
+ @WM.dependency LungCTherapy2FailedElement913 LungCFirstTreatmentRateElement94 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d380
+ @WM.dependency LungCsIBDiagnosisElement377 LungCsIBDiagnosisRateElement379 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d100
+ @WM.dependency LungCs01AgeingElement61 DummyRateForUnitsConversionElement98 -0.1
+ _ : SYSDYN.FlowConnection
+ MOD.DiagramConnectionToConnection CMC.f824
+ @WM.flow LungCCured2Element816 LungCCured2PopCorrElement826
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d661
+ @WM.dependency LungCOutputs01ScNoDElement651 LungCs01Element106 -0.1
+ _ : SYSDYN.FlowConnection
+ MOD.DiagramConnectionToConnection CMC.f286
+ @WM.flow LungCsIIBNoDElement271 LungCProgressIIAIIBElement289
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d800
+ @WM.dependency LungCCured1PopCorrElement799 LungCCured1Element789 -0.1
+ _ : SYSDYN.FlowConnection
+ MOD.DiagramConnectionToConnection CMC.f381
+ @WM.flow LungCsIIADiagnosisElement383 LungCsIIANoDElement190
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d308
+ @WM.dependency LungCProgressIIIAIIIBElement301 LungCsIIIANoDElement272 -0.1
+ _ : SYSDYN.FlowConnection
+ MOD.DiagramConnectionToConnection CMC.f392
+ @WM.flow LungCsIIIADiagnosisElement394 LungCsIIIANoDElement272
+ _ : SYSDYN.FlowConnection
+ MOD.DiagramConnectionToConnection CMC.f177
+ @WM.flow LungCT2ProgressingElement8 LungCT2ProgressingAgeingElement179
+ _ : SYSDYN.FlowConnection
+ MOD.DiagramConnectionToConnection CMC.f496
+ @WM.flow LungCs02DiagnosisElement498 LungCs02Element230
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d605
+ @WM.dependency LungCOutputDiagnosisElement600 LungCsIBDiagnosisElement594 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d373
+ @WM.dependency LungCsIVNoDPopCorrElement372 LungCModelPopCorrectionFactorElement369 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d607
+ @WM.dependency LungCOutputDiagnosisElement600 LungCsIIBDiagnosisElement596 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d813
+ @WM.dependency LungCModelPopElement104 LungCCured1Element812 -0.1
+ _ : SYSDYN.FlowConnection
+ MOD.DiagramConnectionToConnection CMC.f42
+ @WM.flow LungCT2DeathElement44 LungCT2DisablingElement9
+ _ : SYSDYN.FlowConnection
+ MOD.DiagramConnectionToConnection CMC.f205
+ @WM.flow LungCT1DeathElement207 LungCT1DisablingElement198
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d759
+ @WM.dependency LungCOutputsIANosNoDElement751 LungCsIANoDElement123 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d644
+ @WM.dependency LungCOutputsIANsNoDElement634 LungCsIANoDElement123 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d851
+ @WM.dependency LungCOutputTherapy2CureElement849 LungCTherapyCure2Element845 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d927
+ @WM.dependency LungCCausedDeathElement115 LungCTherapy1MortalityElement898 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d694
+ @WM.dependency LungCOutputs02ScDiagnosisElement682 LungCs02DiagnosisElement591 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d213
+ @WM.dependency LungCT1DeathElement207 LungCT1DisablingElement198 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d51
+ @WM.dependency LungCBirthElement49 TotalPopulationBirthElement50 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d456
+ @WM.dependency LungCNoDSumElement449 LungCsIIBNoDElement447 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d568
+ @WM.dependency LungCProgressIAIVElement524 LungCsIANoDElement3 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d874
+ @WM.dependency LungCOutputNoDScElement859 LungCOutputs03ScNoDElement653 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d171
+ @WM.dependency LungCT2ProgressingPopCorrElement169 LungCT2ProgressingElement8 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d916
+ @WM.dependency LungCTherapy2FailedElement913 LungCTherapy2FailRatioElement915 -0.1
+ _ : SYSDYN.FlowConnection
+ MOD.DiagramConnectionToConnection CMC.f386
+ @WM.flow LungCsIIBDiagnosisElement388 LungCsIIBNoDElement271
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d796
+ @WM.dependency LungCCured1AgeingElement795 LungCCured1Element789 -0.1
+ _ : SYSDYN.FlowConnection
+ MOD.DiagramConnectionToConnection CMC.f200
+ @WM.flow LungCT1DisablingElement198 LungCT1ProgToDisablingElement203
+ _ : SYSDYN.FlowConnection
+ MOD.DiagramConnectionToConnection CMC.f525
+ @WM.flow LungCsIVNoDElement274 LungCProgressIBIVElement528
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d787
+ @WM.dependency LungCInceptionElement14 LungCSmokersPercentageOfPopulationElement786 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d161
+ @WM.dependency LungCTreated2PopCorrElement158 LungCNotProgressing2Element6 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d919
+ @WM.dependency LungCTherapy2FailedElement913 LungCTherapy2RatioElement582 -0.1
+ _ : SYSDYN.FlowConnection
+ MOD.DiagramConnectionToConnection CMC.f534
+ @WM.flow LungCProgressIIBIVElement536 LungCsIIBNoDElement271
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d744
+ @WM.dependency LungCOutputNosDiagnosisElement735 LungCsIIIBDiagnosisElement598 -0.1
+ _ : SYSDYN.FlowConnection
+ MOD.DiagramConnectionToConnection CMC.f20
+ @WM.flow LungCsIADiagnosisElement22 LungCsIANoDElement3
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d888
+ @WM.dependency LungCoutputNoDNosElement860 LungCOutputsIIBNosNoDElement754 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d557
+ @WM.dependency LungCProgress02IVElement516 LungCs02Element230 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d718
+ @WM.dependency LungCOutputNsDiagnosisElement711 LungCsIIADiagnosisElement595 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d468
+ @WM.dependency LungCModelPopElement104 LungCNoDSumElement449 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d700
+ @WM.dependency LungCOutputsIBScDiagnosisElement685 LungCsIBDiagnosisElement594 -0.1
+ _ : SYSDYN.FlowConnection
+ MOD.DiagramConnectionToConnection CMC.f287
+ @WM.flow LungCProgressIIAIIBElement289 LungCsIIANoDElement190
+ _ : SYSDYN.FlowConnection
+ MOD.DiagramConnectionToConnection CMC.f475
+ @WM.flow LungCTherapy2Element28 LungCDElement4
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d868
+ @WM.dependency LungCOutputNoDNsElement858 LungCOutputsIIIANsNoDElement638 -0.1
+ _ : SYSDYN.FlowConnection
+ MOD.DiagramConnectionToConnection CMC.f294
+ @WM.flow LungCsIIIANoDElement272 LungCProgressIIBIIIAElement297
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d413
+ @WM.dependency LungCProgressIIIAIIIBElement301 LungCProgressIIIAIIIBRateElement412 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d932
+ @WM.dependency LungCOutputRelapseElement930 LungCT2ProgressesElement929 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d764
+ @WM.dependency LungCOutputsIIIBNosNoDElement756 LungCsIIIBNoDElement445 -0.1
+ _ : SYSDYN.FlowConnection
+ MOD.DiagramConnectionToConnection CMC.f275
+ @WM.flow LungCsIBNoDElement270 LungCProgressIAIBElement277
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d803
+ @WM.dependency LungCCured1PopCorrElement799 LungCModelPopCorrectionFactorElement802 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d606
+ @WM.dependency LungCOutputDiagnosisElement600 LungCsIIADiagnosisElement595 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d724
+ @WM.dependency LungCOutputScDiagnosisElement712 LungCs02DiagnosisElement591 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d691
+ @WM.dependency LungCOutputs01NsDiagnosisElement671 LungCs01DiagnosisElement590 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d666
+ @WM.dependency LungCOutputsIIAScNoDElement656 LungCsIIANoDElement444 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d432
+ @WM.dependency LungCsIVDiagnosisElement431 LungCsIVDiagnosisRateElement427 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d346
+ @WM.dependency LungCsIIIANoDPopCorrElement344 LungCModelPopCorrectionFactorElement345 -0.1
+ _ : SYSDYN.FlowConnection
+ MOD.DiagramConnectionToConnection CMC.f911
+ @WM.flow LungCTherapy2FailedElement913 LungCDElement4
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d907
+ @WM.dependency LungCOutputTherapy1Element611 LungCTherapy1MortalityElement906 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d708
+ @WM.dependency LungCOutputsIIIBScDiagnosisElement689 LungCsIIIBDiagnosisElement598 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d650
+ @WM.dependency LungCOutputsIVNsNoDElement640 LungCsIVNoDElement448 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d710
+ @WM.dependency LungCOutputsIVScDiagnosisElement690 LungCsIVDiagnosisElement599 -0.1
+ _ : SYSDYN.FlowConnection
+ MOD.DiagramConnectionToConnection CMC.f895
+ @WM.flow LungCT1DeceasedElement199 LungCTherapy1MortalityElement898
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d856
+ @WM.dependency LungCOutputHealthyAndTreatedElement182 LungCCured1Element812 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d69
+ @WM.dependency LungCsIANoDAgeingElement68 LungCsIANoDElement3 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d664
+ @WM.dependency LungCOutputsIAScNoDElement654 LungCsIANoDElement123 -0.1
+ _ : SYSDYN.FlowConnection
+ MOD.DiagramConnectionToConnection CMC.f191
+ @WM.flow LungCsIIANoDElement190 LungCProgressIAIIAElement194
+ _ : SYSDYN.FlowConnection
+ MOD.DiagramConnectionToConnection CMC.f224
+ @WM.flow LungCT1DisablingElement198 LungCT1DisablingPopCorrElement226
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d187
+ @WM.dependency LungCOutputModelPopElement186 LungCModelPopElement104 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d646
+ @WM.dependency LungCOutputsIIANsNoDElement636 LungCsIIANoDElement444 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d262
+ @WM.dependency LungCs03PopCorrElement259 LungCs03Element231 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d79
+ @WM.dependency LungCTreated1AgeingElement78 LungCNotProgressing1Element5 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d212
+ @WM.dependency LungCT1ProgToDisablingElement203 LungCT1ProgressingElement197 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d352
+ @WM.dependency LungCsIIIANoDAgeingElement350 LungCsIIIANoDElement272 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d126
+ @WM.dependency LungCModelPopElement104 LungCHealthyElement105 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d251
+ @WM.dependency LungCs02PopCorrElement248 LungCs02Element230 -0.1
+ _ : SYSDYN.FlowConnection
+ MOD.DiagramConnectionToConnection CMC.f426
+ @WM.flow LungCDElement4 LungCsIIIBDiagnosisElement400
+ _ : SYSDYN.FlowConnection
+ MOD.DiagramConnectionToConnection CMC.f279
+ @WM.flow LungCProgressIBIIBElement281 LungCsIBNoDElement270
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d176
+ @WM.dependency LungCT2DisablingPopCorrElement174 LungCT2DisablingElement9 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d256
+ @WM.dependency LungCs02AgeingElement254 DummyRateForUnitsConversionElement98 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d810
+ @WM.dependency LungCTherapy1Element25 LungCTherapy1CureRatioElement808 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d574
+ @WM.dependency LungCProgressIIBIVElement536 LungCsIIBNoDElement271 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d170
+ @WM.dependency LungCT2ProgressingPopCorrElement169 LungCModelPopCorrectionFactorElement159 -0.1
+ _ : SYSDYN.FlowConnection
+ MOD.DiagramConnectionToConnection CMC.f33
+ @WM.flow LungCT2ProgressingElement8 LungCT2ProgressesElement36
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d920
+ @WM.dependency LungCTherapy2FailedElement913 LungCDElement4 -0.1
+ _ : SYSDYN.FlowConnection
+ MOD.DiagramConnectionToConnection CMC.f428
+ @WM.flow LungCDElement4 LungCsIVDiagnosisElement431
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d887
+ @WM.dependency LungCoutputNoDNosElement860 LungCOutputsIIANosNoDElement753 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d227
+ @WM.dependency LungCT1DisablingPopCorrElement226 LungCModelPopCorrectionFactorElement153 -0.1
+ _ : SYSDYN.FlowConnection
+ MOD.DiagramConnectionToConnection CMC.f26
+ @WM.flow LungCNotProgressing2Element6 LungCTherapy2Element28
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d99
+ @WM.dependency LungCHealthyAgeingElement54 DummyRateForUnitsConversionElement98 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d566
+ @WM.dependency LungCProgressIAIVElement524 LungCProgressIAIVRateElement559 -0.1
+ _ : SYSDYN.FlowConnection
+ MOD.DiagramConnectionToConnection CMC.f526
+ @WM.flow LungCProgressIBIVElement528 LungCsIBNoDElement270
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d72
+ @WM.dependency LungCsIADiagnosisElement22 LungCsIADiagnosisRateElement71 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d869
+ @WM.dependency LungCOutputNoDNsElement858 LungCOutputsIIIANsNoDElement638 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d806
+ @WM.dependency LungCTherapyCure1Element792 LungCFirstTreatmentRateElement94 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d255
+ @WM.dependency LungCs02AgeingElement254 LungCs02Element230 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d500
+ @WM.dependency LungCs02DiagnosisElement498 LungCs02DiagnosisRateElement499 -0.1
+ _ : SYSDYN.FlowConnection
+ MOD.DiagramConnectionToConnection CMC.f790
+ @WM.flow LungCCured1Element789 LungCTherapyCure1Element792
+ _ : SYSDYN.FlowConnection
+ MOD.DiagramConnectionToConnection CMC.f533
+ @WM.flow LungCsIVNoDElement274 LungCProgressIIBIVElement536
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d918
+ @WM.dependency LungCTherapy2Element28 LungCTherapy2FailRatioElement915 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d604
+ @WM.dependency LungCOutputDiagnosisElement600 LungCsIADiagnosisElement593 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d556
+ @WM.dependency LungCProgress02IVElement516 LungCProgress02IVRateElement555 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d717
+ @WM.dependency LungCOutputNsDiagnosisElement711 LungCsIBDiagnosisElement594 -0.1
+ _ : SYSDYN.FlowConnection
+ MOD.DiagramConnectionToConnection CMC.f232
+ @WM.flow LungCs03Element231 LungCProgress0203Element235
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d462
+ @WM.dependency LungCModelPopElement104 LungCNotProgressing1Element108 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d843
+ @WM.dependency LungCModelPopElement104 LungCCured2Element840 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d815
+ @WM.dependency LungCOutputCured1Element814 LungCCured1Element812 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d330
+ @WM.dependency LungCsIIANoDAgeingElement329 LungCsIIANoDElement190 -0.1
+ _ : SYSDYN.FlowConnection
+ MOD.DiagramConnectionToConnection CMC.f263
+ @WM.flow LungCs03Element231 LungCs03AgeingElement265
+ _ : SYSDYN.FlowConnection
+ MOD.DiagramConnectionToConnection CMC.f167
+ @WM.flow LungCT2ProgressingElement8 LungCT2ProgressingPopCorrElement169
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d360
+ @WM.dependency LungCsIIIBNoDPopCorrElement355 LungCModelPopCorrectionFactorElement359 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d692
+ @WM.dependency LungCOutputs01ScDiagnosisElement681 LungCs01DiagnosisElement590 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d610
+ @WM.dependency LungCOutputDiagnosisElement600 LungCsIVDiagnosisElement599 -0.1
+ _ : SYSDYN.FlowConnection
+ MOD.DiagramConnectionToConnection CMC.f514
+ @WM.flow LungCProgress02IVElement516 LungCs02Element230
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d931
+ @WM.dependency LungCOutputRelapseElement930 LungCT1ProgressesElement928 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d725
+ @WM.dependency LungCOutputScDiagnosisElement712 LungCs03DiagnosisElement592 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d663
+ @WM.dependency LungCOutputs03ScNoDElement653 LungCs03Element442 -0.1
+ _ : SYSDYN.FlowConnection
+ MOD.DiagramConnectionToConnection CMC.f513
+ @WM.flow LungCsIVNoDElement274 LungCProgress02IVElement516
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d854
+ @WM.dependency LungCOutputTherapy1NoCureElement852 LungCTherapy1Element188 -0.1
+ _ : SYSDYN.FlowConnection
+ MOD.DiagramConnectionToConnection CMC.f797
+ @WM.flow LungCCured1Element789 LungCCured1PopCorrElement799
+ _ : SYSDYN.FlowConnection
+ MOD.DiagramConnectionToConnection CMC.f510
+ @WM.flow LungCProgress01IVElement512 LungCs01Element2
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d877
+ @WM.dependency LungCOutputNoDScElement859 LungCOutputsIIAScNoDElement656 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d645
+ @WM.dependency LungCOutputsIBNsNoDElement635 LungCsIBNoDElement443 -0.1
+ _ : SYSDYN.FlowConnection
+ MOD.DiagramConnectionToConnection CMC.f322
+ @WM.flow LungCsIIANoDElement190 LungCsIIANoDPopCorrElement324
+ _ : SYSDYN.FlowConnection
+ MOD.DiagramConnectionToConnection CMC.f469
+ @WM.flow LungCDElement4 LungCDAgeingElement471
+ _ : SYSDYN.FlowConnection
+ MOD.DiagramConnectionToConnection CMC.f353
+ @WM.flow LungCsIIIBNoDElement273 LungCsIIIBNoDPopCorrElement355
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d575
+ @WM.dependency LungCProgressIIIAIVElement539 LungCProgressIIIAIVRateElement563 -0.1
+ _ : SYSDYN.FlowConnection
+ MOD.DiagramConnectionToConnection CMC.f375
+ @WM.flow LungCsIBDiagnosisElement377 LungCsIBNoDElement270
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d709
+ @WM.dependency LungCOutputsIVNsDiagnosisElement680 LungCsIVDiagnosisElement599 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d128
+ @WM.dependency LungCModelPopCorrectionFactorElement112 LungCCausedDeathElement115 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d589
+ @WM.dependency LungCOutputNotProgressing2Element588 LungCNotProgressing2Element109 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d250
+ @WM.dependency LungCs02PopCorrElement248 LungCModelPopCorrectionFactorElement249 -0.1
+ _ : SYSDYN.FlowConnection
+ MOD.DiagramConnectionToConnection CMC.f192
+ @WM.flow LungCProgressIAIIAElement194 LungCsIANoDElement3
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d303
+ @WM.dependency LungCProgressIBIIBElement281 LungCsIBNoDElement270 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d614
+ @WM.dependency LungCOutputTherapy2Element612 LungCTherapy2Element189 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d699
+ @WM.dependency LungCOutputsIBNsDiagnosisElement675 LungCsIBDiagnosisElement594 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d501
+ @WM.dependency LungCs02DiagnosisElement498 LungCs02Element230 -0.1
+ _ : SYSDYN.FlowConnection
+ MOD.DiagramConnectionToConnection CMC.f278
+ @WM.flow LungCsIIBNoDElement271 LungCProgressIBIIBElement281
+ _ : SYSDYN.FlowConnection
+ MOD.DiagramConnectionToConnection CMC.f150
+ @WM.flow LungCNotProgressing1Element5 LungCTreated1PopCorrElement152
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d155
+ @WM.dependency LungCTreated1PopCorrElement152 LungCNotProgressing1Element5 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d130
+ @WM.dependency LungCModelPopCorrectionFactorElement112 TotalPopulationElement113 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d245
+ @WM.dependency LungCProgress03IAElement239 LungCs03Element231 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d626
+ @WM.dependency LungCOutputDisabling1Element623 LungCT1DisablingElement461 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d583
+ @WM.dependency LungCTherapy2Element28 LungCTherapy2RatioElement582 -0.1
+ _ : SYSDYN.FlowConnection
+ MOD.DiagramConnectionToConnection CMC.f257
+ @WM.flow LungCs03Element231 LungCs03PopCorrElement259
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d782
+ @WM.dependency LungCOutputsIIBNosDiagnosisElement772 LungCsIIBDiagnosisElement596 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d85
+ @WM.dependency LungCT2ProgressesElement36 LungCNotProgressing2Element6 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d809
+ @WM.dependency LungCTherapyCure1Element792 LungCTherapy1CureRatioElement808 -0.1
+ _ : SYSDYN.FlowConnection
+ MOD.DiagramConnectionToConnection CMC.f332
+ @WM.flow LungCsIIBNoDElement271 LungCsIIBNoDPopCorrElement334
+ _ : SYSDYN.FlowConnection
+ MOD.DiagramConnectionToConnection CMC.f425
+ @WM.flow LungCDElement4 LungCsIIIADiagnosisElement394
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d745
+ @WM.dependency LungCOutputNosDiagnosisElement735 LungCsIVDiagnosisElement599 -0.1
+ _ : SYSDYN.FlowConnection
+ MOD.DiagramConnectionToConnection CMC.f34
+ @WM.flow LungCT2ProgressesElement36 LungCNotProgressing2Element6
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d832
+ @WM.dependency LungCTherapyCure2Element819 LungCFirstTreatmentRateElement94 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d736
+ @WM.dependency LungCOutputNosDiagnosisElement735 LungCs01DiagnosisElement590 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d781
+ @WM.dependency LungCOutputsIIANosDiagnosisElement771 LungCsIIADiagnosisElement595 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d603
+ @WM.dependency LungCOutputDiagnosisElement600 LungCs03DiagnosisElement592 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d828
+ @WM.dependency LungCTherapyCure2Element819 LungCTherapy2RatioElement582 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d90
+ @WM.dependency LungCT2ProgToDisablingElement40 LungCT2ProgressingElement8 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d102
+ @WM.dependency LungCTreated2AgeingElement82 DummyRateForUnitsConversionElement98 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d565
+ @WM.dependency LungCProgress03IVElement520 LungCProgress03IVRateElement558 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d620
+ @WM.dependency LungCOutputT2MortalityElement618 LungCT2DeathElement44 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d850
+ @WM.dependency LungCOutputTherapy2NoCureElement848 LungCTherapy2Element189 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d891
+ @WM.dependency LungCoutputNoDNosElement860 LungCOutputsIVNosNoDElement757 -0.1
+ _ : SYSDYN.FlowConnection
+ MOD.DiagramConnectionToConnection CMC.f16
+ @WM.flow LungCProgress0102Element18 LungCs01Element2
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d730
+ @WM.dependency LungCOutputScDiagnosisElement712 LungCsIIIADiagnosisElement597 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d55
+ @WM.dependency LungCHealthyAgeingElement54 LungCHealthyElement1 -0.1
+ _ : SYSDYN.FlowConnection
+ MOD.DiagramConnectionToConnection CMC.f233
+ @WM.flow LungCProgress0203Element235 LungCs02Element230
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d57
+ @WM.dependency LungCInceptionElement14 LungCInceptionRateElement56 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d368
+ @WM.dependency LungCsIVNoDAgeingElement366 DummyRateForUnitsConversionElement98 -0.1
+ _ : SYSDYN.FlowConnection
+ MOD.DiagramConnectionToConnection CMC.f424
+ @WM.flow LungCDElement4 LungCsIIADiagnosisElement383
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d872
+ @WM.dependency LungCOutputNoDScElement859 LungCOutputs01ScNoDElement651 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d316
+ @WM.dependency LungCsIBNoDPopCorrElement311 LungCsIBNoDElement270 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d89
+ @WM.dependency LungCT2ProgToDisablingElement40 LungCT2ProgToDisablingRateElement88 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d175
+ @WM.dependency LungCT2DisablingPopCorrElement174 LungCModelPopCorrectionFactorElement159 -0.1
+ _ : SYSDYN.FlowConnection
+ MOD.DiagramConnectionToConnection CMC.f11
+ @WM.flow LungCs01Element2 LungCInceptionElement14
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d347
+ @WM.dependency LungCsIIIANoDPopCorrElement344 LungCsIIIANoDElement272 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d842
+ @WM.dependency LungCOutputCured2Element841 LungCCured2Element840 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d665
+ @WM.dependency LungCOutputsIBScNoDElement655 LungCsIBNoDElement443 -0.1
+ _ : SYSDYN.FlowConnection
+ MOD.DiagramConnectionToConnection CMC.f434
+ @WM.flow LungCDElement4 LungCs03DiagnosisElement437
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d93
+ @WM.dependency LungCT2DeathElement44 LungCT2DeathRateElement92 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d899
+ @WM.dependency LungCTherapy1MortalityElement898 LungCFirstTreatmentRateElement94 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d865
+ @WM.dependency LungCOutputNoDNsElement858 LungCOutputsIBNsNoDElement635 -0.1
+ _ : SYSDYN.FlowConnection
+ MOD.DiagramConnectionToConnection CMC.f291
+ @WM.flow LungCProgressIIBIIIBElement293 LungCsIIBNoDElement271
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d374
+ @WM.dependency LungCsIVNoDPopCorrElement372 LungCsIVNoDElement274 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d904
+ @WM.dependency LungCTherapy1Element25 LungCTherapy1MortalityRatioElement901 -0.1
+ _ : SYSDYN.FlowConnection
+ MOD.DiagramConnectionToConnection CMC.f429
+ @WM.flow LungCsIVDiagnosisElement431 LungCsIVNoDElement274
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d649
+ @WM.dependency LungCOutputsIIIBNsNoDElement639 LungCsIIIBNoDElement445 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d409
+ @WM.dependency LungCProgressIIAIIIAElement285 LungCProgressIIAIIIARateElement408 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d642
+ @WM.dependency LungCOutputs02NsNoDElement632 LungCs02Element441 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d648
+ @WM.dependency LungCOutputsIIIANsNoDElement638 LungCsIIIANoDElement446 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d886
+ @WM.dependency LungCoutputNoDNosElement860 LungCOutputsIBNosNoDElement752 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d585
+ @WM.dependency LungCT2ProgressesElement36 LungCT2ProgressesRateElement584 -0.1
+ _ : SYSDYN.FlowConnection
+ MOD.DiagramConnectionToConnection CMC.f327
+ @WM.flow LungCsIIANoDElement190 LungCsIIANoDAgeingElement329
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d727
+ @WM.dependency LungCOutputScDiagnosisElement712 LungCsIBDiagnosisElement594 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d320
+ @WM.dependency LungCsIBNoDAgeingElement319 LungCsIBNoDElement270 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d732
+ @WM.dependency LungCOutputScDiagnosisElement712 LungCsIVDiagnosisElement599 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d361
+ @WM.dependency LungCsIIIBNoDPopCorrElement355 LungCsIIIBNoDElement273 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d465
+ @WM.dependency LungCModelPopElement104 LungCT1DisablingElement461 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d184
+ @WM.dependency LungCOutputHealthyAndTreatedElement182 LungCNotProgressing1Element108 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d776
+ @WM.dependency LungCOutputs01NosDiagnosisElement766 LungCs01DiagnosisElement590 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d894
+ @WM.dependency LungCOutputModelPopExcludingHealthyElement892 LungCHealthyElement105 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d131
+ @WM.dependency LungCModelPopCorrectionFactorElement112 LungCModelPopCorrectionRateElement125 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d181
+ @WM.dependency LungCT2ProgressingAgeingElement179 LungCT2ProgressingElement8 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d385
+ @WM.dependency LungCsIIADiagnosisElement383 LungCsIIADiagnosisRateElement384 -0.1
+ _ : SYSDYN.FlowConnection
+ MOD.DiagramConnectionToConnection CMC.f502
+ @WM.flow LungCDElement4 LungCs01DiagnosisElement505
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d307
+ @WM.dependency LungCProgressIIBIIIAElement297 LungCsIIBNoDElement271 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d801
+ @WM.dependency LungCCured1AgeingElement795 DummyRateForUnitsConversionElement98 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d154
+ @WM.dependency LungCTreated1PopCorrElement152 LungCModelPopCorrectionFactorElement153 -0.1
+ _ : SYSDYN.FlowConnection
+ MOD.DiagramConnectionToConnection CMC.f830
+ @WM.flow LungCTherapyCure2Element819 LungCDElement4
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d553
+ @WM.dependency LungCProgress01IVElement512 LungCProgress01IVRateElement552 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d747
+ @WM.dependency LungCOutputs01NosNoDElement746 LungCs01Element106 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d847
+ @WM.dependency LungCOutputTherapy2Element612 LungCTherapyCure2Element845 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d704
+ @WM.dependency LungCOutputsIIBScDiagnosisElement687 LungCsIIBDiagnosisElement596 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d326
+ @WM.dependency LungCsIIANoDPopCorrElement324 LungCModelPopCorrectionFactorElement314 -0.1
+ _ : SYSDYN.FlowConnection
+ MOD.DiagramConnectionToConnection CMC.f47
+ @WM.flow LungCBirthElement49 Cloud45Element45
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d619
+ @WM.dependency LungCOutputT1MortalityElement617 LungCT1DeathElement207 -0.1
+ _ : SYSDYN.FlowConnection
+ MOD.DiagramConnectionToConnection CMC.f37
+ @WM.flow LungCT2DisablingElement9 LungCT2ProgToDisablingElement40
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d335
+ @WM.dependency LungCsIIBNoDPopCorrElement334 LungCsIIBNoDElement271 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d855
+ @WM.dependency LungCOutputTherapy1CureElement853 LungCTherapyCure1Element844 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d195
+ @WM.dependency LungCProgressIAIIAElement194 LungCsIANoDElement3 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d698
+ @WM.dependency LungCOutputsIAScDiagnosisElement684 LungCsIADiagnosisElement593 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d554
+ @WM.dependency LungCProgress01IVElement512 LungCs01Element2 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d831
+ @WM.dependency LungCTherapyCure2Element819 LungCDElement4 -0.1
+ _ : SYSDYN.FlowConnection
+ MOD.DiagramConnectionToConnection CMC.f521
+ @WM.flow LungCsIVNoDElement274 LungCProgressIAIVElement524
+ _ : SYSDYN.FlowConnection
+ MOD.DiagramConnectionToConnection CMC.f162
+ @WM.flow LungCDElement4 LungCDPopCorrElement164
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d433
+ @WM.dependency LungCsIVDiagnosisElement431 LungCsIVNoDElement274 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d780
+ @WM.dependency LungCOutputsIBNosDiagnosisElement770 LungCsIBDiagnosisElement594 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d880
+ @WM.dependency LungCOutputNoDScElement859 LungCOutputsIIIBScNoDElement659 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d647
+ @WM.dependency LungCOutputsIIBNsNoDElement637 LungCsIIBNoDElement447 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d74
+ @WM.dependency LungCTherapy2Element28 LungCDElement4 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d440
+ @WM.dependency LungCs03DiagnosisElement437 LungCs03Element231 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d890
+ @WM.dependency LungCoutputNoDNosElement860 LungCOutputsIIIBNosNoDElement756 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d740
+ @WM.dependency LungCOutputNosDiagnosisElement735 LungCsIBDiagnosisElement594 -0.1
+ _ : SYSDYN.FlowConnection
+ MOD.DiagramConnectionToConnection CMC.f299
+ @WM.flow LungCProgressIIIAIIIBElement301 LungCsIIIANoDElement272
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d103
+ @WM.dependency LungCsIANoDAgeingElement68 DummyRateForUnitsConversionElement98 -0.1
+ _ : SYSDYN.FlowConnection
+ MOD.DiagramConnectionToConnection CMC.f201
+ @WM.flow LungCT1ProgToDisablingElement203 LungCT1ProgressingElement197
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d602
+ @WM.dependency LungCOutputDiagnosisElement600 LungCs02DiagnosisElement591 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d871
+ @WM.dependency LungCOutputNoDNsElement858 LungCOutputsIVNsNoDElement640 -0.1
+ _ : SYSDYN.FlowConnection
+ MOD.DiagramConnectionToConnection CMC.f423
+ @WM.flow LungCDElement4 LungCsIIBDiagnosisElement388
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d719
+ @WM.dependency LungCOutputNsDiagnosisElement711 LungCsIIBDiagnosisElement596 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d902
+ @WM.dependency LungCTherapy1MortalityElement898 LungCTherapy1MortalityRatioElement901 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d827
+ @WM.dependency LungCCured2PopCorrElement826 LungCCured2Element816 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d91
+ @WM.dependency LungCT2DeathElement44 LungCT2DisablingElement9 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d266
+ @WM.dependency LungCs03AgeingElement265 LungCs03Element231 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d467
+ @WM.dependency LungCModelPopElement104 LungCT2DisablingElement111 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d701
+ @WM.dependency LungCOutputsIIANsDiagnosisElement676 LungCsIIADiagnosisElement595 -0.1
+ _ : SYSDYN.FlowConnection
+ MOD.DiagramConnectionToConnection CMC.f474
+ @WM.flow LungCTherapy1Element25 LungCDElement4
+ _ : SYSDYN.FlowConnection
+ MOD.DiagramConnectionToConnection CMC.f820
+ @WM.flow LungCCured2Element816 LungCCured2AgeingElement822
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d867
+ @WM.dependency LungCOutputNoDNsElement858 LungCOutputsIIBNsNoDElement637 -0.1
+ _ : SYSDYN.FlowConnection
+ MOD.DiagramConnectionToConnection CMC.f214
+ @WM.flow LungCT1ProgressingElement197 LungCT1ProgressingPopCorrElement216
+ _ : SYSDYN.FlowConnection
+ MOD.DiagramConnectionToConnection CMC.f422
+ @WM.flow LungCDElement4 LungCsIBDiagnosisElement377
+ _ : SYSDYN.FlowConnection
+ MOD.DiagramConnectionToConnection CMC.f817
+ @WM.flow LungCCured2Element816 LungCTherapyCure2Element819
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d905
+ @WM.dependency LungCTherapy1MortalityElement898 LungCDElement4 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d97
+ @WM.dependency LungCTherapy1Element25 LungCTherapy1RatioElement73 -0.1
+ _ : SYSDYN.FlowConnection
+ MOD.DiagramConnectionToConnection CMC.f41
+ @WM.flow LungCT2DeceasedElement10 LungCT2DeathElement44
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d731
+ @WM.dependency LungCOutputScDiagnosisElement712 LungCsIIIBDiagnosisElement598 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d668
+ @WM.dependency LungCOutputsIIIAScNoDElement658 LungCsIIIANoDElement446 -0.1
+ _ : SYSDYN.FlowConnection
+ MOD.DiagramConnectionToConnection CMC.f52
+ @WM.flow LungCHealthyElement1 LungCHealthyAgeingElement54
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d302
+ @WM.dependency LungCProgressIAIBElement277 LungCsIANoDElement3 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d229
+ @WM.dependency LungCCausedDeathElement115 LungCT1DeathElement207 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d866
+ @WM.dependency LungCOutputNoDNsElement858 LungCOutputsIIANsNoDElement636 -0.1
+ _ : SYSDYN.FlowConnection
+ MOD.DiagramConnectionToConnection CMC.f910
+ @WM.flow LungCT2ProgressingElement8 LungCTherapy2FailedElement913
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d693
+ @WM.dependency LungCOutputs02NsDiagnosisElement672 LungCs02DiagnosisElement591 -0.1
+ _ : SYSDYN.FlowConnection
+ MOD.DiagramConnectionToConnection CMC.f503
+ @WM.flow LungCs01DiagnosisElement505 LungCs01Element2
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d315
+ @WM.dependency LungCsIBNoDPopCorrElement311 LungCModelPopCorrectionFactorElement312 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d402
+ @WM.dependency LungCsIIIBDiagnosisElement400 LungCsIIIBNoDElement273 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d641
+ @WM.dependency LungCOutputs01NsNoDElement631 LungCs01Element106 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d893
+ @WM.dependency LungCOutputModelPopExcludingHealthyElement892 LungCModelPopElement104 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d576
+ @WM.dependency LungCProgressIIIAIVElement539 LungCsIIIANoDElement272 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d761
+ @WM.dependency LungCOutputsIIANosNoDElement753 LungCsIIANoDElement444 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d838
+ @WM.dependency LungCTherapyCure2Element819 LungCTherapy2CureRatioElement837 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d222
+ @WM.dependency LungCT1ProgressingAgeingElement219 LungCT1ProgressingElement197 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d616
+ @WM.dependency LungCOutputMortalityElement615 LungCCausedDeathElement115 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d738
+ @WM.dependency LungCOutputNosDiagnosisElement735 LungCs03DiagnosisElement592 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d83
+ @WM.dependency LungCTreated2AgeingElement82 LungCNotProgressing2Element6 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d804
+ @WM.dependency LungCTherapyCure1Element792 LungCTherapy1RatioElement73 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d870
+ @WM.dependency LungCOutputNoDNsElement858 LungCOutputsIIIBNsNoDElement639 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d305
+ @WM.dependency LungCProgressIIAIIBElement289 LungCsIIANoDElement190 -0.1
+ _ : SYSDYN.FlowConnection
+ MOD.DiagramConnectionToConnection CMC.f896
+ @WM.flow LungCTherapy1MortalityElement898 LungCDElement4
+ _ : SYSDYN.FlowConnection
+ MOD.DiagramConnectionToConnection CMC.f217
+ @WM.flow LungCT1ProgressingElement197 LungCT1ProgressingAgeingElement219
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d122
+ @WM.dependency LungCHealthyPopCorrElement119 LungCHealthyElement1 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d777
+ @WM.dependency LungCOutputs02NosDiagnosisElement767 LungCs02DiagnosisElement591 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d143
+ @WM.dependency LungCs01PopCorrElement141 LungCModelPopCorrectionFactorElement142 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d269
+ @WM.dependency LungCs03AgeingElement265 DummyRateForUnitsConversionElement98 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d464
+ @WM.dependency LungCModelPopElement104 LungCT1ProgressingElement460 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d628
+ @WM.dependency LungCOutputDisabling2Element624 LungCT2DisablingElement111 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d878
+ @WM.dependency LungCOutputNoDScElement859 LungCOutputsIIBScNoDElement657 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d363
+ @WM.dependency LungCsIIIBNoDAgeingElement358 DummyRateForUnitsConversionElement98 -0.1
+ _ : SYSDYN.FlowConnection
+ MOD.DiagramConnectionToConnection CMC.f46
+ @WM.flow LungCHealthyElement1 LungCBirthElement49
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d630
+ @WM.dependency LungCOutputNoDSumElement629 LungCNoDSumElement449 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d183
+ @WM.dependency LungCOutputHealthyAndTreatedElement182 LungCHealthyElement105 -0.1
+ _ : SYSDYN.FlowConnection
+ MOD.DiagramConnectionToConnection CMC.f518
+ @WM.flow LungCProgress03IVElement520 LungCs03Element231
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d472
+ @WM.dependency LungCDAgeingElement471 LungCDElement4 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d362
+ @WM.dependency LungCsIIIBNoDAgeingElement358 LungCsIIIBNoDElement273 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d439
+ @WM.dependency LungCs03DiagnosisElement437 LungCs03DiagnosisRateElement438 -0.1
+ _ : SYSDYN.FlowConnection
+ MOD.DiagramConnectionToConnection CMC.f317
+ @WM.flow LungCsIBNoDElement270 LungCsIBNoDAgeingElement319
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d608
+ @WM.dependency LungCOutputDiagnosisElement600 LungCsIIIADiagnosisElement597 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d132
+ @WM.dependency LungCModelPopCorrectionFactorElement112 LungCModelPopElement104 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d411
+ @WM.dependency LungCProgressIIAIIBElement289 LungCProgressIIAIIBRateElement410 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d705
+ @WM.dependency LungCOutputsIIIANsDiagnosisElement678 LungCsIIIADiagnosisElement597 -0.1
+ _ : SYSDYN.FlowConnection
+ MOD.DiagramConnectionToConnection CMC.f398
+ @WM.flow LungCsIIIBDiagnosisElement400 LungCsIIIBNoDElement273
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d407
+ @WM.dependency LungCProgressIAIIAElement194 LungCProgressIAIIARateElement406 -0.1
+ _ : SYSDYN.FlowConnection
+ MOD.DiagramConnectionToConnection CMC.f537
+ @WM.flow LungCProgressIIIAIVElement539 LungCsIIIANoDElement272
+ _ : SYSDYN.FlowConnection
+ MOD.DiagramConnectionToConnection CMC.f522
+ @WM.flow LungCProgressIAIVElement524 LungCsIANoDElement3
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d785
+ @WM.dependency LungCOutputsIVNosDiagnosisElement775 LungCsIVDiagnosisElement599 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d587
+ @WM.dependency LungCOutputNotProgressing1Element586 LungCNotProgressing1Element108 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d609
+ @WM.dependency LungCOutputDiagnosisElement600 LungCsIIIBDiagnosisElement598 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d667
+ @WM.dependency LungCOutputsIIBScNoDElement657 LungCsIIBNoDElement447 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d741
+ @WM.dependency LungCOutputNosDiagnosisElement735 LungCsIIADiagnosisElement595 -0.1
+ _ : SYSDYN.FlowConnection
+ MOD.DiagramConnectionToConnection CMC.f298
+ @WM.flow LungCsIIIBNoDElement273 LungCProgressIIIAIIIBElement301
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d95
+ @WM.dependency LungCTherapy1Element25 LungCFirstTreatmentRateElement94 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d714
+ @WM.dependency LungCOutputNsDiagnosisElement711 LungCs02DiagnosisElement591 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d601
+ @WM.dependency LungCOutputDiagnosisElement600 LungCs01DiagnosisElement590 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d243
+ @WM.dependency LungCProgress03IAElement239 LungCProgress03IARateElement241 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d779
+ @WM.dependency LungCOutputsIANosDiagnosisElement769 LungCsIADiagnosisElement593 -0.1
+ _ : SYSDYN.FlowConnection
+ MOD.DiagramConnectionToConnection CMC.f529
+ @WM.flow LungCsIVNoDElement274 LungCProgressIIAIVElement532
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d697
+ @WM.dependency LungCOutputsIANsDiagnosisElement674 LungCsIADiagnosisElement593 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d726
+ @WM.dependency LungCOutputScDiagnosisElement712 LungCsIADiagnosisElement593 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d397
+ @WM.dependency LungCsIIIADiagnosisElement394 LungCsIIIANoDElement272 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d857
+ @WM.dependency LungCOutputHealthyAndTreatedElement182 LungCCured2Element840 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d707
+ @WM.dependency LungCOutputsIIIBNsDiagnosisElement679 LungCsIIIBDiagnosisElement598 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d65
+ @WM.dependency LungCProgress0102Element18 LungCs01Element2 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d261
+ @WM.dependency LungCs03PopCorrElement259 LungCModelPopCorrectionFactorElement260 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d459
+ @WM.dependency LungCNoDSumElement449 LungCsIVNoDElement448 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d321
+ @WM.dependency LungCsIBNoDAgeingElement319 DummyRateForUnitsConversionElement98 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d823
+ @WM.dependency LungCCured2AgeingElement822 LungCCured2Element816 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d903
+ @WM.dependency LungCTherapyCure1Element792 LungCTherapy1MortalityRatioElement901 -0.1
+ _ : SYSDYN.FlowConnection
+ MOD.DiagramConnectionToConnection CMC.f204
+ @WM.flow LungCT1DeceasedElement199 LungCT1DeathElement207
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d165
+ @WM.dependency LungCDPopCorrElement164 LungCModelPopCorrectionFactorElement148 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d729
+ @WM.dependency LungCOutputScDiagnosisElement712 LungCsIIBDiagnosisElement596 -0.1
+ _ : SYSDYN.FlowConnection
+ MOD.DiagramConnectionToConnection CMC.f435
+ @WM.flow LungCs03DiagnosisElement437 LungCs03Element231
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d924
+ @WM.dependency LungCOutputTherapy2Element612 LungCTherapy2FailedElement923 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d885
+ @WM.dependency LungCoutputNoDNosElement860 LungCOutputsIANosNoDElement751 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d884
+ @WM.dependency LungCoutputNoDNosElement860 LungCOutputs03NosNoDElement750 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d228
+ @WM.dependency LungCT1DisablingPopCorrElement226 LungCT1DisablingElement198 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d760
+ @WM.dependency LungCOutputsIBNosNoDElement752 LungCsIBNoDElement443 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d863
+ @WM.dependency LungCOutputNoDNsElement858 LungCOutputs03NsNoDElement633 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d749
+ @WM.dependency LungCOutputs02NosNoDElement748 LungCs02Element441 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d268
+ @WM.dependency LungCsIANoDPopCorrElement147 LungCModelPopCorrectionFactorElement267 -0.1
+ _ : SYSDYN.FlowConnection
+ MOD.DiagramConnectionToConnection CMC.f172
+ @WM.flow LungCT2DisablingElement9 LungCT2DisablingPopCorrElement174
+ _ : SYSDYN.FlowConnection
+ MOD.DiagramConnectionToConnection CMC.f404
+ @WM.flow LungCProgressIAIBElement277 LungCsIANoDElement3
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d223
+ @WM.dependency LungCT1ProgressingAgeingElement219 DummyRateForUnitsConversionElement98 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d613
+ @WM.dependency LungCOutputTherapy1Element611 LungCTherapy1Element188 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d721
+ @WM.dependency LungCOutputNsDiagnosisElement711 LungCsIIIBDiagnosisElement598 -0.1
+ _ : SYSDYN.FlowConnection
+ MOD.DiagramConnectionToConnection CMC.f282
+ @WM.flow LungCsIIIANoDElement272 LungCProgressIIAIIIAElement285
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d669
+ @WM.dependency LungCOutputsIIIBScNoDElement659 LungCsIIIBNoDElement445 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d121
+ @WM.dependency LungCHealthyPopCorrElement119 LungCModelPopCorrectionFactorElement120 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d702
+ @WM.dependency LungCOutputsIIAScDiagnosisElement686 LungCsIIADiagnosisElement595 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d873
+ @WM.dependency LungCOutputNoDScElement859 LungCOutputs02ScNoDElement652 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d577
+ @WM.dependency LungCProgressIIIBIVElement542 LungCProgressIIIBIVRateElement564 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d209
+ @WM.dependency LungCT1ProgToDisablingElement203 LungCT1ProgToDisablingRateElement208 -0.1
+ _ : SYSDYN.FlowConnection
+ MOD.DiagramConnectionToConnection CMC.f117
+ @WM.flow LungCHealthyElement1 LungCHealthyPopCorrElement119
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d643
+ @WM.dependency LungCOutputs03NsNoDElement633 LungCs03Element442 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d455
+ @WM.dependency LungCNoDSumElement449 LungCsIIANoDElement444 -0.1
+ _ : SYSDYN.FlowConnection
+ MOD.DiagramConnectionToConnection CMC.f80
+ @WM.flow LungCNotProgressing2Element6 LungCTreated2AgeingElement82
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d336
+ @WM.dependency LungCsIIBNoDPopCorrElement334 LungCModelPopCorrectionFactorElement313 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d457
+ @WM.dependency LungCNoDSumElement449 LungCsIIIANoDElement446 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d696
+ @WM.dependency LungCOutputs03ScDiagnosisElement683 LungCs03DiagnosisElement592 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d713
+ @WM.dependency LungCOutputNsDiagnosisElement711 LungCs01DiagnosisElement590 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d879
+ @WM.dependency LungCOutputNoDScElement859 LungCOutputsIIIAScNoDElement658 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d670
+ @WM.dependency LungCOutputsIVScNoDElement660 LungCsIVNoDElement448 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d419
+ @WM.dependency LungCProgressIIBIIIAElement297 LungCProgressIIBIIIARateElement418 -0.1
+ _ : SYSDYN.FlowConnection
+ MOD.DiagramConnectionToConnection CMC.f290
+ @WM.flow LungCsIIIBNoDElement273 LungCProgressIIBIIIBElement293
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d149
+ @WM.dependency LungCsIANoDPopCorrElement147 LungCsIANoDElement3 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d625
+ @WM.dependency LungCOutputProgressing1Element621 LungCT1ProgressingElement460 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d304
+ @WM.dependency LungCProgressIIAIIIAElement285 LungCsIIANoDElement190 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d396
+ @WM.dependency LungCsIIIADiagnosisElement394 LungCsIIIADiagnosisRateElement395 -0.1
+ _ : SYSDYN.FlowConnection
+ MOD.DiagramConnectionToConnection CMC.f530
+ @WM.flow LungCProgressIIAIVElement532 LungCsIIANoDElement190
+ _ : SYSDYN.FlowConnection
+ MOD.DiagramConnectionToConnection CMC.f66
+ @WM.flow LungCsIANoDElement3 LungCsIANoDAgeingElement68
+ _ : SYSDYN.FlowConnection
+ MOD.DiagramConnectionToConnection CMC.f19
+ @WM.flow LungCDElement4 LungCsIADiagnosisElement22
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d306
+ @WM.dependency LungCProgressIIBIIIBElement293 LungCsIIBNoDElement271 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d763
+ @WM.dependency LungCOutputsIIIANosNoDElement755 LungCsIIIANoDElement446 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d70
+ @WM.dependency LungCsIADiagnosisElement22 LungCsIANoDElement3 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d839
+ @WM.dependency LungCTherapy2Element28 LungCTherapy2CureRatioElement837 -0.1
+ _ : SYSDYN.FlowConnection
+ MOD.DiagramConnectionToConnection CMC.f793
+ @WM.flow LungCCured1Element789 LungCCured1AgeingElement795
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d166
+ @WM.dependency LungCDPopCorrElement164 LungCDElement4 -0.1
+ _ : SYSDYN.FlowConnection
+ MOD.DiagramConnectionToConnection CMC.f30
+ @WM.flow LungCT1ProgressesElement32 LungCNotProgressing1Element5
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d570
+ @WM.dependency LungCProgressIBIVElement528 LungCsIBNoDElement270 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d909
+ @WM.dependency LungCOutputTherapy1MortalityInTherapyElement908 LungCTherapy1MortalityElement906 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d403
+ @WM.dependency LungCsIIIBDiagnosisElement400 LungCsIIIBDiagnosisRateElement401 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d466
+ @WM.dependency LungCModelPopElement104 LungCT2ProgressingElement110 -0.1
+ _ : SYSDYN.FlowConnection
+ MOD.DiagramConnectionToConnection CMC.f252
+ @WM.flow LungCs02Element230 LungCs02AgeingElement254
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d883
+ @WM.dependency LungCoutputNoDNosElement860 LungCOutputs02NosNoDElement748 -0.1
+ _ : SYSDYN.FlowConnection
+ MOD.DiagramConnectionToConnection CMC.f283
+ @WM.flow LungCProgressIIAIIIAElement285 LungCsIIANoDElement190
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d75
+ @WM.dependency LungCTherapy1Element25 LungCDElement4 -0.1
+ _ : SYSDYN.FlowConnection
+ MOD.DiagramConnectionToConnection CMC.f156
+ @WM.flow LungCNotProgressing2Element6 LungCTreated2PopCorrElement158
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d421
+ @WM.dependency LungCProgressIIBIIIBElement293 LungCProgressIIBIIIBRateElement420 -0.1
+ _ : SYSDYN.FlowConnection
+ MOD.DiagramConnectionToConnection CMC.f59
+ @WM.flow LungCs01Element2 LungCs01AgeingElement61
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d450
+ @WM.dependency LungCNoDSumElement449 LungCs01Element106 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d703
+ @WM.dependency LungCOutputsIIBNsDiagnosisElement677 LungCsIIBDiagnosisElement596 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d864
+ @WM.dependency LungCOutputNoDNsElement858 LungCOutputsIANsNoDElement634 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d900
+ @WM.dependency LungCTherapy1MortalityElement898 LungCTherapy1RatioElement73 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d473
+ @WM.dependency LungCDAgeingElement471 DummyRateForUnitsConversionElement98 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d185
+ @WM.dependency LungCOutputHealthyAndTreatedElement182 LungCNotProgressing2Element109 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d390
+ @WM.dependency LungCsIIBDiagnosisElement388 LungCsIIBNoDElement271 -0.1
+ _ : SYSDYN.FlowConnection
+ MOD.DiagramConnectionToConnection CMC.f356
+ @WM.flow LungCsIIIBNoDElement273 LungCsIIIBNoDAgeingElement358
+ _ : SYSDYN.FlowConnection
+ MOD.DiagramConnectionToConnection CMC.f38
+ @WM.flow LungCT2ProgToDisablingElement40 LungCT2ProgressingElement8
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d807
+ @WM.dependency LungCTherapyCure1Element792 LungCDElement4 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d242
+ @WM.dependency LungCProgress0203Element235 LungCProgress0203RateElement240 -0.1
+
+ TotalPopulationT1Element11 : SYSDYN.AuxiliarySymbol
+ MOD.ElementToComponent CMC.TotalPopulationT1
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, 743.0, 122.0] : G2D.Transform
+ TotalPopulationBirthElement3 : SYSDYN.AuxiliarySymbol
+ MOD.ElementToComponent CMC.TotalPopulationBirth
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, 708.0, 85.0] : G2D.Transform
+ TotalPopulationMenElement7 : SYSDYN.AuxiliarySymbol
+ MOD.ElementToComponent CMC.TotalPopulationMen
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, 709.4, 24.0] : G2D.Transform
+ OutputDataTotalPopulationMenSumElement15 : SYSDYN.AuxiliarySymbol
+ MOD.ElementToComponent CMC.OutputDataTotalPopulationMenSum
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, 679.6, 38.6] : G2D.Transform
+ TotalPopulationWomenElement8 : SYSDYN.AuxiliarySymbol
+ MOD.ElementToComponent CMC.TotalPopulationWomen
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, 775.0, 25.2] : G2D.Transform
+ TotalPopulationElement1 : SYSDYN.AuxiliarySymbol
+ MOD.ElementToComponent CMC.TotalPopulation
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, 743.0, 53.8] : G2D.Transform
+ OutputDataTotalPopulationWomenSumElement16 : SYSDYN.AuxiliarySymbol
+ MOD.ElementToComponent CMC.OutputDataTotalPopulationWomenSum
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, 800.8, 41.4] : G2D.Transform
+ DummyRateForUnitsConversionElement19 : SYSDYN.AuxiliarySymbol
+ MOD.ElementToComponent CMC.DummyRateForUnitsConversion
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, 735.8, 149.0] : G2D.Transform
+ TotalPopulationDeathElement5 : SYSDYN.AuxiliarySymbol
+ MOD.ElementToComponent CMC.TotalPopulationDeath
+ DIA.HasTransform [1.0, 0.0, 0.0, 1.0, 832.8, 85.0] : G2D.Transform
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d6
+ @WM.dependency TotalPopulationDeathElement5 TotalPopulationElement1 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d21
+ @WM.dependency TotalPopulationDeathElement5 DummyRateForUnitsConversionElement19 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d9
+ @WM.dependency TotalPopulationElement1 TotalPopulationMenElement7 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d17
+ @WM.dependency OutputDataTotalPopulationMenSumElement15 TotalPopulationMenElement7 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d12
+ @WM.dependency TotalPopulationDeathElement5 TotalPopulationT1Element11 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d20
+ @WM.dependency TotalPopulationBirthElement3 DummyRateForUnitsConversionElement19 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d14
+ @WM.dependency TotalPopulationT1Element11 TotalPopulationElement1 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d18
+ @WM.dependency OutputDataTotalPopulationWomenSumElement16 TotalPopulationWomenElement8 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d10
+ @WM.dependency TotalPopulationElement1 TotalPopulationWomenElement8 -0.1
+ _ : SYSDYN.DependencyConnection
+ MOD.DiagramConnectionToConnection CMC.d13
+ @WM.dependency TotalPopulationBirthElement3 TotalPopulationT1Element11 -0.1
+
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>\r
+<classpath>\r
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>\r
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>\r
+ <classpathentry kind="src" path="src"/>\r
+ <classpathentry kind="output" path="bin"/>\r
+</classpath>\r
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>\r
+<projectDescription>\r
+ <name>org.simantics.sysdyn.ui</name>\r
+ <comment></comment>\r
+ <projects>\r
+ </projects>\r
+ <buildSpec>\r
+ <buildCommand>\r
+ <name>org.eclipse.jdt.core.javabuilder</name>\r
+ <arguments>\r
+ </arguments>\r
+ </buildCommand>\r
+ <buildCommand>\r
+ <name>org.eclipse.pde.ManifestBuilder</name>\r
+ <arguments>\r
+ </arguments>\r
+ </buildCommand>\r
+ <buildCommand>\r
+ <name>org.eclipse.pde.SchemaBuilder</name>\r
+ <arguments>\r
+ </arguments>\r
+ </buildCommand>\r
+ </buildSpec>\r
+ <natures>\r
+ <nature>org.eclipse.pde.PluginNature</nature>\r
+ <nature>org.eclipse.jdt.core.javanature</nature>\r
+ </natures>\r
+</projectDescription>\r
--- /dev/null
+#Thu Nov 05 12:45:23 EET 2009\r
+eclipse.preferences.version=1\r
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled\r
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6\r
+org.eclipse.jdt.core.compiler.compliance=1.6\r
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error\r
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error\r
+org.eclipse.jdt.core.compiler.source=1.6\r
--- /dev/null
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: Ui
+Bundle-SymbolicName: org.simantics.sysdyn.ui;singleton:=true
+Bundle-Version: 1.0.0.qualifier
+Bundle-Activator: org.simantics.sysdyn.ui.Activator
+Require-Bundle: org.eclipse.ui,
+ org.eclipse.core.runtime,
+ org.simantics.ui;bundle-version="1.0.0",
+ org.simantics.diagram;bundle-version="1.0.0",
+ org.simantics.db;bundle-version="0.6.2",
+ org.simantics.db.common;bundle-version="0.6.2",
+ org.simantics.db.layer0;bundle-version="0.7.0",
+ org.simantics.g2d;bundle-version="1.0.0",
+ org.simantics.scenegraph;bundle-version="1.0.0",
+ org.simantics.layer0.utils;bundle-version="0.6.2"
+Bundle-ActivationPolicy: lazy
+Bundle-RequiredExecutionEnvironment: JavaSE-1.6
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>\r
+<adapters>\r
+<!-- \r
+ <target interface="org.simantics.project.features.IProjectFeature">\r
+ <type\r
+ uri="http://www.simantics.org/Ontology/ProConf/1.0#SymbolManagerFeature"\r
+ class="org.simantics.diagram.symbollibrary.SymbolManagerFeature">\r
+ </type>\r
+ </target>\r
+\r
+ <target interface="org.simantics.g2d.diagram.DiagramClass">\r
+ <baseType uri="http://www.simantics.org/Simantics/Diagram/2.0#Composite" />\r
+ <adapter uri="http://www.simantics.org/Simantics/Diagram/2.0#Composite"\r
+ adapterClass="org.simantics.diagram.adapter.DiagramClassAdapter" />\r
+ </target>\r
+ -->\r
+ <target interface="org.simantics.diagram.adapter.GraphElementClassFactory">\r
+ <resource uri="http://www.simantics.org/Sysdyn#VariableElement"\r
+ class="org.simantics.sysdyn.ui.adapters.VariableClassFactory" />\r
+ </target>\r
+\r
+ <target interface="org.simantics.diagram.adapter.GraphElementFactory">\r
+ <type uri="http://www.simantics.org/Sysdyn#VariableElement"\r
+ class="org.simantics.sysdyn.ui.adapters.VariableClassFactory" />\r
+ </target>\r
+\r
+ <target interface="org.simantics.diagram.synchronization.graph.ElementWriter">\r
+ <type uri="http://www.simantics.org/Sysdyn#VariableElement"\r
+ class="org.simantics.sysdyn.ui.adapters.VariableElementWriter" />\r
+ </target>\r
+\r
+</adapters>
\ No newline at end of file
--- /dev/null
+source.. = src/\r
+output.. = bin/\r
+bin.includes = META-INF/,\\r
+ .,\\r
+ plugin.xml\r
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>\r
+<?eclipse version="3.4"?>\r
+<plugin>\r
+ <extension\r
+ point="org.eclipse.ui.editors">\r
+ <editor\r
+ class="org.simantics.sysdyn.ui.diagram.SysdynDiagramEditor"\r
+ default="false"\r
+ id="org.simantics.sysdyn.ui.diagramEditor"\r
+ name="Sysdyn diagram editor">\r
+ </editor>\r
+ </extension>\r
+ <extension\r
+ point="org.simantics.ui.resourceEditorAdapter">\r
+ <adapter\r
+ editorId="org.simantics.sysdyn.ui.diagramEditor"\r
+ priority="3"\r
+ type_uris="http://www.vtt.fi/Simantics/Layer0/1.0/Types#Entity">\r
+ </adapter>\r
+ </extension>\r
+\r
+</plugin>\r
--- /dev/null
+package org.simantics.sysdyn.ui;\r
+\r
+import org.eclipse.ui.plugin.AbstractUIPlugin;\r
+import org.osgi.framework.BundleContext;\r
+\r
+/**\r
+ * The activator class controls the plug-in life cycle\r
+ */\r
+public class Activator extends AbstractUIPlugin {\r
+\r
+ // The plug-in ID\r
+ public static final String PLUGIN_ID = "org.simantics.sysdyn.ui";\r
+\r
+ // The shared instance\r
+ private static Activator plugin;\r
+ \r
+ /**\r
+ * The constructor\r
+ */\r
+ public Activator() {\r
+ }\r
+\r
+ /*\r
+ * (non-Javadoc)\r
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)\r
+ */\r
+ public void start(BundleContext context) throws Exception {\r
+ super.start(context);\r
+ plugin = this;\r
+ }\r
+\r
+ /*\r
+ * (non-Javadoc)\r
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)\r
+ */\r
+ public void stop(BundleContext context) throws Exception {\r
+ plugin = null;\r
+ super.stop(context);\r
+ }\r
+\r
+ /**\r
+ * Returns the shared instance\r
+ *\r
+ * @return the shared instance\r
+ */\r
+ public static Activator getDefault() {\r
+ return plugin;\r
+ }\r
+\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2007- VTT Technical Research Centre of Finland.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.ui;\r
+\r
+\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.Session;\r
+import org.simantics.db.exception.DatabaseException;\r
+\r
+public class SysdynResource {\r
+ \r
+ public final Resource HasX;\r
+ public final Resource HasY;\r
+ public final Resource SysdynModel;\r
+ public final Resource SysdynModelManager;\r
+ public final Resource SysdynModellingDomain;\r
+ public final Resource TestDiagram;\r
+ public final Resource Variable;\r
+ public final Resource VariableElement;\r
+ \r
+ public static class URIs {\r
+ public static final String HasX = "http://www.simantics.org/Sysdyn#HasX";\r
+ public static final String HasY = "http://www.simantics.org/Sysdyn#HasY";\r
+ public static final String SysdynModel = "http://www.simantics.org/Sysdyn#SysdynModel";\r
+ public static final String SysdynModelManager = "http://www.simantics.org/Sysdyn#SysdynModelManager";\r
+ public static final String SysdynModellingDomain = "http://www.simantics.org/Sysdyn#SysdynModellingDomain";\r
+ public static final String TestDiagram = "http://www.simantics.org/Sysdyn#TestDiagram";\r
+ public static final String Variable = "http://www.simantics.org/Sysdyn#Variable";\r
+ public static final String VariableElement = "http://www.simantics.org/Sysdyn#VariableElement";\r
+ }\r
+ \r
+ public static Resource getResourceOrNull(ReadGraph graph, String uri) {\r
+ try {\r
+ return graph.getResourceByURI(uri);\r
+ } catch(DatabaseException e) {\r
+ System.err.println(e.getMessage());\r
+ return null;\r
+ }\r
+ }\r
+ \r
+ public SysdynResource(ReadGraph graph) {\r
+ HasX = getResourceOrNull(graph, URIs.HasX);\r
+ HasY = getResourceOrNull(graph, URIs.HasY);\r
+ SysdynModel = getResourceOrNull(graph, URIs.SysdynModel);\r
+ SysdynModelManager = getResourceOrNull(graph, URIs.SysdynModelManager);\r
+ SysdynModellingDomain = getResourceOrNull(graph, URIs.SysdynModellingDomain);\r
+ TestDiagram = getResourceOrNull(graph, URIs.TestDiagram);\r
+ Variable = getResourceOrNull(graph, URIs.Variable);\r
+ VariableElement = getResourceOrNull(graph, URIs.VariableElement);\r
+ }\r
+ \r
+ public static SysdynResource getInstance(ReadGraph graph) {\r
+ Session session = graph.getSession();\r
+ SysdynResource ret = session.getService(SysdynResource.class);\r
+ if(ret == null) {\r
+ ret = new SysdynResource(graph);\r
+ session.registerService(SysdynResource.class, ret);\r
+ }\r
+ return ret;\r
+ }\r
+ \r
+}\r
+\r
--- /dev/null
+package org.simantics.sysdyn.ui.adapters;\r
+\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.diagram.adapter.ElementQuerySupport;\r
+import org.simantics.diagram.adapter.GraphElementClassFactory;\r
+import org.simantics.diagram.adapter.GraphElementFactory;\r
+import org.simantics.g2d.diagram.IDiagram;\r
+import org.simantics.g2d.element.ElementClass;\r
+import org.simantics.g2d.element.IElement;\r
+import org.simantics.g2d.element.impl.Element;\r
+import org.simantics.sysdyn.ui.SysdynResource;\r
+import org.simantics.sysdyn.ui.diagram.DrawableElementClass;\r
+import org.simantics.sysdyn.ui.elements.TestDrawable;\r
+\r
+public class VariableClassFactory implements GraphElementFactory, GraphElementClassFactory {\r
+\r
+ @Override\r
+ public IElement spawn(ReadGraph g, Resource resource,\r
+ ElementQuerySupport support, IDiagram diagram)\r
+ throws DatabaseException {\r
+ SysdynResource sr = SysdynResource.getInstance(g);\r
+ \r
+ ElementClass elementClass = \r
+ DrawableElementClass.createElementClass(sr.VariableElement);\r
+ IElement element = Element.spawnNew(elementClass);\r
+ \r
+ TestDrawable drawable = new TestDrawable();\r
+ drawable.moveTo(\r
+ (Double)g.getRelatedValue(resource, sr.HasX),\r
+ (Double)g.getRelatedValue(resource, sr.HasY)\r
+ );\r
+ element.setHint(DrawableElementClass.KEY_CONTENT, drawable);\r
+ \r
+ //diagram.addElement(element);\r
+ return element;\r
+ }\r
+\r
+ @Override\r
+ public ElementClass create(ReadGraph g, Resource elementType,\r
+ ElementQuerySupport support) throws DatabaseException {\r
+ return DrawableElementClass.createElementClass(elementType);\r
+ }\r
+\r
+}\r
--- /dev/null
+package org.simantics.sysdyn.ui.adapters;\r
+\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.WriteGraph;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.diagram.synchronization.graph.ElementWriter;\r
+import org.simantics.g2d.element.IElement;\r
+\r
+public class VariableElementWriter implements ElementWriter {\r
+\r
+ @Override\r
+ public void addToGraph(WriteGraph graph, IElement element,\r
+ Resource elementResource) throws DatabaseException {\r
+ System.out.println("addToGraph"); \r
+ }\r
+\r
+ @Override\r
+ public void removeFromGraph(WriteGraph graph, Resource elementResource)\r
+ throws DatabaseException {\r
+ System.out.println("removeFromGraph"); \r
+ }\r
+\r
+}\r
--- /dev/null
+package org.simantics.sysdyn.ui.diagram;\r
+\r
+import java.awt.Color;\r
+\r
+import org.eclipse.swt.SWT;\r
+import org.eclipse.swt.widgets.Composite;\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.common.request.ReadRequest;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.diagram.adapter.GraphToDiagramSynchronizer;\r
+import org.simantics.diagram.adapter.IDiagramLoader;\r
+import org.simantics.diagram.participant.SGFocusParticipant;\r
+import org.simantics.g2d.canvas.Hints;\r
+import org.simantics.g2d.canvas.ICanvasContext;\r
+import org.simantics.g2d.canvas.impl.CanvasContext;\r
+import org.simantics.g2d.chassis.SWTChassis;\r
+import org.simantics.g2d.diagram.DiagramHints;\r
+import org.simantics.g2d.diagram.IDiagram;\r
+import org.simantics.g2d.diagram.participant.CanvasBoundsParticipant;\r
+import org.simantics.g2d.diagram.participant.DiagramParticipant;\r
+import org.simantics.g2d.diagram.participant.ElementInteractor;\r
+import org.simantics.g2d.diagram.participant.ElementPainter;\r
+import org.simantics.g2d.diagram.participant.Selection;\r
+import org.simantics.g2d.diagram.participant.pointertool.PointerInteractor;\r
+import org.simantics.g2d.element.ElementClassProviders;\r
+import org.simantics.g2d.element.IElement;\r
+import org.simantics.g2d.element.impl.Element;\r
+import org.simantics.g2d.participant.CanvasGrab;\r
+import org.simantics.g2d.participant.KeyUtil;\r
+import org.simantics.g2d.participant.MousePanZoomInteractor;\r
+import org.simantics.g2d.participant.MouseUtil;\r
+import org.simantics.g2d.participant.Notifications;\r
+import org.simantics.g2d.participant.PanZoomRotateHandler;\r
+import org.simantics.g2d.participant.PointerPainter;\r
+import org.simantics.g2d.participant.RulerPainter;\r
+import org.simantics.g2d.participant.SGTransformUtil;\r
+import org.simantics.g2d.snap.GridSnapAdvisor;\r
+import org.simantics.layer0.utils.ResourceArray;\r
+import org.simantics.sysdyn.ui.elements.IDrawable;\r
+import org.simantics.ui.SimanticsUI;\r
+import org.simantics.ui.workbench.ResourceEditorPart;\r
+import org.simantics.utils.datastructures.hints.IHintContext;\r
+import org.simantics.utils.threads.AWTThread;\r
+\r
+public abstract class DiagramEditorFacade extends ResourceEditorPart {\r
+\r
+ SWTChassis chassis;\r
+ IDiagram diagram;\r
+ IDiagramLoader loader;\r
+ \r
+ public DiagramEditorFacade() {\r
+ super(); \r
+ }\r
+ \r
+ @Override\r
+ public void reload(ReadGraph g) throws DatabaseException {\r
+ // TODO Auto-generated method stub \r
+ }\r
+ \r
+ @Override\r
+ public void createPartControl(Composite parent) {\r
+ chassis = new SWTChassis(parent, SWT.NONE);\r
+ chassis.syncPopulate(); \r
+ \r
+ final ICanvasContext context = new CanvasContext(\r
+ AWTThread.getThreadAccess());\r
+ chassis.setCanvasContext(context);\r
+\r
+ context.add(new SGTransformUtil());\r
+ context.add(new MouseUtil());\r
+ context.add(new KeyUtil());\r
+ context.add(new PanZoomRotateHandler());\r
+ context.add(new MousePanZoomInteractor());\r
+ context.add(new RulerPainter());\r
+ context.add(new CanvasGrab());\r
+ context.add(new CanvasBoundsParticipant());\r
+ context.add(new Notifications());\r
+ context.add(new SGFocusParticipant(chassis)); \r
+ context.add(new DiagramParticipant());\r
+ context.add(new ElementPainter());\r
+ context.add(new PointerInteractor(true, true, true, false, true, false, null));\r
+ context.add(new ElementInteractor());\r
+ context.add(new Selection()); \r
+ \r
+ IHintContext h = context.getDefaultHintContext(); \r
+ h.setHint(PointerPainter.KEY_PAINT_POINTER, true); \r
+ \r
+ h.setHint(ElementPainter.KEY_SELECTION_FRAME_COLOR, Color.MAGENTA);\r
+ h.setHint(Hints.KEY_TOOL, Hints.POINTERTOOL);\r
+\r
+ h.setHint(PanZoomRotateHandler.KEY_ZOOM_IN_LIMIT, 100000.0);\r
+ h.setHint(PanZoomRotateHandler.KEY_ZOOM_OUT_LIMIT, 10.0);\r
+\r
+ h.setHint(DiagramHints.SNAP_ADVISOR,\r
+ new GridSnapAdvisor(10.0));\r
+ \r
+ try {\r
+ SimanticsUI.getSession().syncRequest(new ReadRequest() {\r
+ \r
+ @Override\r
+ public void run(ReadGraph graph) throws DatabaseException {\r
+ loader = new GraphToDiagramSynchronizer(graph, context, \r
+ ElementClassProviders.staticProvider(null));\r
+ \r
+ diagram = loader.loadDiagram(graph,\r
+ getResourceInput().getResource(),\r
+ ResourceArray.EMPTY, \r
+ null); \r
+ }\r
+ \r
+ });\r
+ h.setHint(DiagramHints.KEY_DIAGRAM, diagram);\r
+ } catch (DatabaseException e) {\r
+ e.printStackTrace();\r
+ } \r
+ \r
+ }\r
+ \r
+ @Override\r
+ public void setFocus() {\r
+ chassis.setFocus(); \r
+ }\r
+ \r
+}\r
--- /dev/null
+package org.simantics.sysdyn.ui.diagram;\r
+\r
+import java.awt.Shape;\r
+import java.awt.geom.AffineTransform;\r
+import java.awt.geom.Point2D;\r
+import java.awt.geom.Rectangle2D;\r
+import java.util.Collection;\r
+\r
+import org.simantics.db.Resource;\r
+import org.simantics.diagram.adapter.handler.ResourceAdapter;\r
+import org.simantics.g2d.diagram.handler.PickRequest.PickPolicy;\r
+import org.simantics.g2d.element.ElementClass;\r
+import org.simantics.g2d.element.IElement;\r
+import org.simantics.g2d.element.handler.InternalSize;\r
+import org.simantics.g2d.element.handler.Move;\r
+import org.simantics.g2d.element.handler.Outline;\r
+import org.simantics.g2d.element.handler.Pick2;\r
+import org.simantics.g2d.element.handler.SceneGraph;\r
+import org.simantics.g2d.element.handler.Transform;\r
+import org.simantics.scenegraph.g2d.G2DParentNode;\r
+import org.simantics.sysdyn.ui.elements.IDrawable;\r
+import org.simantics.sysdyn.ui.elements.ITransformable;\r
+import org.simantics.utils.datastructures.hints.IHintContext.KeyOf;\r
+\r
+public class DrawableElementClass {\r
+ private DrawableElementClass() {}\r
+ \r
+ public static KeyOf KEY_CONTENT = new KeyOf(IDrawable.class, "CONTENT");\r
+ public static AffineTransform IDENTITY_TRANSFORM = new AffineTransform();\r
+ \r
+ public static WidgetHandler WIDGET_HANDLER_INSTANCE = new WidgetHandler();\r
+ \r
+ private static class WidgetHandler implements Transform, SceneGraph, InternalSize, Move, Outline, Pick2 {\r
+\r
+ private static final long serialVersionUID = 1722978969083481038L;\r
+ \r
+ @Override\r
+ public void setTransform(IElement e, AffineTransform at) {\r
+ IDrawable drawable = (IDrawable)e.getHint(KEY_CONTENT);\r
+ if(drawable instanceof ITransformable) {\r
+ drawable = ((ITransformable)drawable).setTransform(at);\r
+ e.setHint(KEY_CONTENT, drawable);\r
+ drawable.updateSG();\r
+ }\r
+ }\r
+ \r
+ @Override\r
+ public AffineTransform getTransform(IElement e) {\r
+ IDrawable drawable = (IDrawable)e.getHint(KEY_CONTENT);\r
+ if(drawable instanceof ITransformable)\r
+ return ((ITransformable)drawable).getTransform(); \r
+ else\r
+ return IDENTITY_TRANSFORM;\r
+ }\r
+ \r
+ @Override\r
+ public void cleanup(IElement e) {\r
+ ((IDrawable)e.getHint(KEY_CONTENT)).cleanupSG(); \r
+ }\r
+\r
+ @Override\r
+ public void init(IElement e, G2DParentNode parent) {\r
+ ((IDrawable)e.getHint(KEY_CONTENT)).initSG(parent);\r
+ }\r
+ \r
+ @Override\r
+ public Rectangle2D getBounds(IElement e, Rectangle2D size) {\r
+ if(size == null)\r
+ size = new Rectangle2D.Double();\r
+ ((IDrawable)e.getHint(KEY_CONTENT)).getBounds(size);\r
+ return size;\r
+ }\r
+\r
+ @Override\r
+ public Point2D getPosition(IElement e) {\r
+ IDrawable drawable = (IDrawable)e.getHint(KEY_CONTENT);\r
+ if(drawable instanceof ITransformable)\r
+ return ((ITransformable)drawable).getPosition(); \r
+ else\r
+ return new Point2D.Double(0.0, 0.0);\r
+ }\r
+\r
+ @Override\r
+ public void moveTo(IElement e, double x, double y) {\r
+ IDrawable drawable = (IDrawable)e.getHint(KEY_CONTENT);\r
+ if(drawable instanceof ITransformable) {\r
+ drawable = ((ITransformable)drawable).moveTo(x, y);\r
+ e.setHint(KEY_CONTENT, drawable);\r
+ drawable.updateSG();\r
+ }\r
+ }\r
+\r
+ @Override\r
+ public Shape getElementShape(IElement e) {\r
+ return getBounds(e, null);\r
+ }\r
+ \r
+ @Override\r
+ public int pick(IElement e, Shape s, PickPolicy policy,\r
+ Collection<IElement> result) {\r
+ if(pickTest(e, s, policy)) {\r
+ result.add(e);\r
+ return 1;\r
+ }\r
+ else\r
+ return 0; \r
+ }\r
+\r
+ @Override\r
+ public boolean pickTest(IElement e, Shape s, PickPolicy policy) {\r
+ IDrawable drawable = (IDrawable)e.getHint(KEY_CONTENT);\r
+ switch(policy) {\r
+ case PICK_CONTAINED_OBJECTS:\r
+ return drawable.pickContained(s);\r
+ case PICK_INTERSECTING_OBJECTS:\r
+ return drawable.pickIntersecting(s);\r
+ default:\r
+ return false;\r
+ } \r
+ }\r
+ \r
+ }\r
+\r
+ public static ElementClass createElementClass(final Resource resource) { \r
+ return ElementClass.compile(\r
+ WIDGET_HANDLER_INSTANCE,\r
+ new ResourceAdapter() {\r
+\r
+ @Override\r
+ public Resource getResource() {\r
+ return resource;\r
+ }\r
+ \r
+ }\r
+ );\r
+ }\r
+}\r
--- /dev/null
+package org.simantics.sysdyn.ui.diagram;\r
+\r
+import org.simantics.sysdyn.ui.elements.TestDrawable;\r
+\r
+\r
+public class SysdynDiagramEditor extends DiagramEditorFacade {\r
+\r
+ public SysdynDiagramEditor() {\r
+ super();\r
+ }\r
+ \r
+}\r
--- /dev/null
+package org.simantics.sysdyn.ui.elements;\r
+\r
+import java.awt.Shape;\r
+import java.awt.geom.AffineTransform;\r
+\r
+import org.simantics.scenegraph.g2d.G2DParentNode;\r
+\r
+public abstract class Drawable implements IDrawable {\r
+\r
+ public static final AffineTransform IDENTITY = new AffineTransform();\r
+ \r
+ @Override\r
+ public void initSG(G2DParentNode parent) {\r
+ }\r
+ \r
+ @Override\r
+ public void cleanupSG() {\r
+ }\r
+\r
+ @Override\r
+ public void updateSG() { \r
+ }\r
+\r
+ @Override\r
+ public boolean pickContained(Shape s) {\r
+ return false;\r
+ }\r
+\r
+ @Override\r
+ public boolean pickIntersecting(Shape s) {\r
+ return false;\r
+ } \r
+\r
+}\r
--- /dev/null
+package org.simantics.sysdyn.ui.elements;\r
+\r
+import java.awt.Shape;\r
+import java.awt.geom.Rectangle2D;\r
+\r
+import org.simantics.scenegraph.g2d.G2DParentNode;\r
+\r
+public interface IDrawable {\r
+ void getBounds(Rectangle2D size);\r
+ void initSG(G2DParentNode parent);\r
+ void updateSG();\r
+ void cleanupSG();\r
+ boolean pickIntersecting(Shape s);\r
+ boolean pickContained(Shape s);\r
+}\r
--- /dev/null
+package org.simantics.sysdyn.ui.elements;\r
+\r
+import java.awt.geom.AffineTransform;\r
+import java.awt.geom.Point2D;\r
+\r
+public interface ITransformable extends IDrawable {\r
+ ITransformable setTransform(AffineTransform at);\r
+ AffineTransform getTransform(); \r
+ public ITransformable moveTo(double x, double y);\r
+ Point2D getPosition();\r
+}\r
--- /dev/null
+package org.simantics.sysdyn.ui.elements;\r
+\r
+import java.awt.geom.AffineTransform;\r
+import java.awt.geom.Point2D;\r
+\r
+public abstract class PositionableDrawable extends Drawable implements ITransformable, Cloneable {\r
+ protected double posX;\r
+ protected double posY;\r
+ \r
+ @Override\r
+ public Point2D getPosition() {\r
+ return new Point2D.Double(posX, posY);\r
+ }\r
+ @Override\r
+ public AffineTransform getTransform() {\r
+ return new AffineTransform(1.0, 0.0, 0.0, 1.0, posX, posY);\r
+ }\r
+ @Override\r
+ public ITransformable moveTo(double x, double y) {\r
+ try {\r
+ PositionableDrawable d = (PositionableDrawable)clone();\r
+ d.posX = x;\r
+ d.posY = y;\r
+ return d;\r
+ } catch(CloneNotSupportedException e) { \r
+ throw new Error(e);\r
+ }\r
+ }\r
+ @Override\r
+ public ITransformable setTransform(AffineTransform at) {\r
+ try {\r
+ PositionableDrawable d = (PositionableDrawable)clone();\r
+ d.posX = at.getTranslateX();\r
+ d.posY = at.getTranslateY();\r
+ return d;\r
+ } catch(CloneNotSupportedException e) { \r
+ throw new Error(e);\r
+ } \r
+ }\r
+}\r
--- /dev/null
+package org.simantics.sysdyn.ui.elements;\r
+\r
+import java.awt.Shape;\r
+import java.awt.geom.AffineTransform;\r
+import java.awt.geom.Rectangle2D;\r
+\r
+import org.simantics.scenegraph.g2d.G2DParentNode;\r
+import org.simantics.scenegraph.g2d.nodes.ShapeNode;\r
+\r
+\r
+public class TestDrawable extends PositionableDrawable {\r
+\r
+ @Override\r
+ public void getBounds(Rectangle2D size) {\r
+ size.setFrame(-10.0, -10.0, 20.0, 20.0);\r
+ }\r
+ \r
+ ShapeNode node;\r
+ \r
+ @Override\r
+ public void initSG(G2DParentNode parent) {\r
+ node = parent.addNode(ShapeNode.class);\r
+ node.setShape(new Rectangle2D.Double(-10.0, -10.0, 20.0, 20.0));\r
+ } \r
+ \r
+ @Override\r
+ public boolean pickContained(Shape s) {\r
+ return s.contains(-10.0, -10.0, 20.0, 20.0);\r
+ }\r
+ \r
+ @Override\r
+ public boolean pickIntersecting(Shape s) {\r
+ return s.intersects(-10.0, -10.0, 20.0, 20.0);\r
+ }\r
+ \r
+}\r
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>\r
+<classpath>\r
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>\r
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>\r
+ <classpathentry kind="src" path="src"/>\r
+ <classpathentry kind="output" path="bin"/>\r
+</classpath>\r
--- /dev/null
+syntax: regexp\r
+^bin/\r
+\r
+syntax: glob\r
+*.svn/*
\ No newline at end of file
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>\r
+<projectDescription>\r
+ <name>org.simantics.sysdyn.ui</name>\r
+ <comment></comment>\r
+ <projects>\r
+ </projects>\r
+ <buildSpec>\r
+ <buildCommand>\r
+ <name>org.eclipse.jdt.core.javabuilder</name>\r
+ <arguments>\r
+ </arguments>\r
+ </buildCommand>\r
+ <buildCommand>\r
+ <name>org.eclipse.pde.ManifestBuilder</name>\r
+ <arguments>\r
+ </arguments>\r
+ </buildCommand>\r
+ <buildCommand>\r
+ <name>org.eclipse.pde.SchemaBuilder</name>\r
+ <arguments>\r
+ </arguments>\r
+ </buildCommand>\r
+ </buildSpec>\r
+ <natures>\r
+ <nature>org.eclipse.pde.PluginNature</nature>\r
+ <nature>org.eclipse.jdt.core.javanature</nature>\r
+ </natures>\r
+</projectDescription>\r
--- /dev/null
+#Tue Nov 10 13:35:16 EET 2009\r
+eclipse.preferences.version=1\r
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled\r
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6\r
+org.eclipse.jdt.core.compiler.compliance=1.6\r
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error\r
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error\r
+org.eclipse.jdt.core.compiler.source=1.6\r
--- /dev/null
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: Simantics System Dynamics UI
+Bundle-SymbolicName: org.simantics.sysdyn.ui;singleton:=true
+Bundle-Version: 1.0.0.qualifier
+Bundle-RequiredExecutionEnvironment: JavaSE-1.6
+Require-Bundle: org.simantics.layer0.utils;bundle-version="0.6.2",
+ org.simantics.scenegraph;bundle-version="0.9.0",
+ org.junit4;bundle-version="4.5.0";resolution:=optional,
+ org.simantics.ui;bundle-version="1.0.0",
+ org.eclipse.ui;bundle-version="3.5.0",
+ org.eclipse.core.runtime;bundle-version="3.5.0",
+ org.simantics.objmap;bundle-version="0.1.0",
+ org.simantics.sysdyn;bundle-version="1.0.0",
+ org.simantics.project;bundle-version="1.0.0",
+ org.eclipse.jface.text;bundle-version="3.5.0",
+ org.eclipse.ui.editors;bundle-version="3.5.0",
+ org.jfree.jcommon;bundle-version="1.0.16",
+ org.jfree.jchart;bundle-version="1.0.13",
+ org.simantics.modelica;bundle-version="1.0.0",
+ org.apache.log4j;bundle-version="1.2.15",
+ org.eclipse.ui.console;bundle-version="3.4.0",
+ org.simantics.browsing.ui.graph;bundle-version="1.1.0",
+ org.simantics.browsing.ui.swt;bundle-version="1.1.0",
+ org.simantics.modeling.ui;bundle-version="1.0.0",
+ org.eclipse.ui.cheatsheets,
+ org.simantics.graphviz.ui;bundle-version="1.0.0",
+ org.simantics.graphviz;bundle-version="1.0.0",
+ org.simantics.diagram;bundle-version="0.9.4",
+ org.simantics.modeling;bundle-version="1.0.0",
+ org.simantics.mapping;bundle-version="1.0.0",
+ org.simantics.structural.ontology;bundle-version="1.0.0",
+ gnu.trove2;bundle-version="2.0.4",
+ org.simantics.simulation;bundle-version="1.0.0",
+ org.simantics.data;bundle-version="0.6.3",
+ org.simantics.message;bundle-version="0.9.0",
+ org.simantics.structural2;bundle-version="1.0.0",
+ org.simantics.layer0;bundle-version="1.0.0",
+ org.simantics.diagram.ontology;bundle-version="1.0.0",
+ org.simantics.graph;bundle-version="1.0.2",
+ org.simantics.graph.db;bundle-version="1.0.0",
+ org.simantics.structural.ui;bundle-version="1.1.1"
+Bundle-Activator: org.simantics.sysdyn.ui.Activator
+Bundle-ActivationPolicy: lazy
+Export-Package: org.simantics.sysdyn.ui.browser.nodes
+Bundle-Vendor: VTT Technical Reserarch Centre of Finland
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>\r<!--\r
+ Copyright (c) 2010 Association for Decentralized Information Management in\r
+ Industry THTH ry.\r
+ All rights reserved. This program and the accompanying materials\r
+ are made available under the terms of the Eclipse Public License v1.0\r
+ which accompanies this distribution, and is available at\r
+ http://www.eclipse.org/legal/epl-v10.html\r
+ \r
+ Contributors:\r
+ VTT Technical Research Centre of Finland - initial API and implementation\r
+ -->\r
+
+<adapters>\r\r <target interface="org.simantics.db.layer0.adapter.Realization">\r <type uri="http://www.simantics.org/Sysdyn-1.0/Module"\r class="org.simantics.structural2.realization.StructuralRealization">\r <this />\r </type>\r </target>\r\r<!-- \r <target interface="org.simantics.db.layer0.variable.Variable">\r <type uri="http://www.simantics.org/Sysdyn-1.0/HistoryRealization"\r class="org.simantics.sysdyn.ui.project.HistoryVariable" >\r <this />\r </type>\r <type uri="http://www.simantics.org/Sysdyn-1.0/DefaultRealization"\r class="org.simantics.sysdyn.ui.project.DefaultVariable" >\r <this />\r </type>\r </target>\r -->\r\r <target interface="org.simantics.layer0.utils.triggers.ITrigger">\r <type uri = "http://www.simantics.org/Sysdyn-1.0/DiagramToCompositeMapping"\r class = "org.simantics.sysdyn.ui.editor.DiagramToCompositeMapping3">\r <graph/>\r <this />\r </type>\r </target>\r \r <target interface="org.simantics.structural.ui.modelBrowser.nodes.AbstractNode">\r <type uri="http://www.simantics.org/Sysdyn-1.0/SysdynModel"\r class="org.simantics.structural.ui.modelBrowser.nodes.ModelNode">\r <this />\r </type>\r </target> \r \r\r <target\r interface="org.simantics.browsing.ui.common.node.AbstractNode">\r <type\r uri="http://www.simantics.org/Sysdyn-1.0/SysdynModel"\r class="org.simantics.sysdyn.ui.browser.nodes.ModelNode">\r <this />\r </type>\r\r <resource\r uri="http://www.simantics.org/Sysdyn-1.0/ModuleSymbol"\r class="org.simantics.sysdyn.ui.browser.nodes.SymbolNode">\r <this />\r </resource>\r\r <type\r uri="http://www.simantics.org/Simulation-1.0/Experiment"\r class="org.simantics.sysdyn.ui.browser.nodes.ExperimentNode">\r <this />\r </type>\r \r <type\r uri="http://www.simantics.org/Sysdyn-1.0/Result"\r class="org.simantics.sysdyn.ui.browser.nodes.SimulationResultNode">\r <this />\r </type>\r \r </target>\r\r <!-- Inject default connection routing algorithm for sysdyn diagrams -->\r <target interface="org.simantics.g2d.diagram.DiagramClass">\r <adapter uri="http://www.simantics.org/Sysdyn-1.0/ConfigurationDiagram"\r adapterClass="org.simantics.sysdyn.ui.elements2.ConfigurationDiagramClassAdapter" />\r </target>\r\r <!-- Sysdyn symbols -->\r <target interface="org.simantics.diagram.adapter.ElementFactory">\r <resource uri="http://www.simantics.org/Sysdyn-1.0/StockSymbol"\r class="org.simantics.sysdyn.ui.elements2.StockFactory" />\r <resource uri="http://www.simantics.org/Sysdyn-1.0/ModuleSymbol"\r class="org.simantics.sysdyn.ui.elements2.ModuleFactory" />\r <resource uri="http://www.simantics.org/Sysdyn-1.0/ValveSymbol"\r class="org.simantics.sysdyn.ui.elements2.ValveFactory" />\r <resource uri="http://www.simantics.org/Sysdyn-1.0/AuxiliarySymbol"\r class="org.simantics.sysdyn.ui.elements2.AuxiliaryFactory" />\r <resource uri="http://www.simantics.org/Sysdyn-1.0/CloudSymbol"\r class="org.simantics.sysdyn.ui.elements2.CloudFactory" />\r <resource uri="http://www.simantics.org/Sysdyn-1.0/InputSymbol"\r class="org.simantics.sysdyn.ui.elements2.InputFactory" />\r\r <type uri="http://www.simantics.org/Sysdyn-1.0/StockSymbol"\r class="org.simantics.sysdyn.ui.elements2.StockFactory" />\r <type uri="http://www.simantics.org/Sysdyn-1.0/ModuleSymbol"\r class="org.simantics.sysdyn.ui.elements2.ModuleFactory" />\r <type uri="http://www.simantics.org/Sysdyn-1.0/ValveSymbol"\r class="org.simantics.sysdyn.ui.elements2.ValveFactory" />\r <type uri="http://www.simantics.org/Sysdyn-1.0/AuxiliarySymbol"\r class="org.simantics.sysdyn.ui.elements2.AuxiliaryFactory" />\r <type uri="http://www.simantics.org/Sysdyn-1.0/CloudSymbol"\r class="org.simantics.sysdyn.ui.elements2.CloudFactory" />\r <type uri="http://www.simantics.org/Sysdyn-1.0/InputSymbol"\r class="org.simantics.sysdyn.ui.elements2.InputFactory" /> \r </target>\r \r <!-- Sysdyn connections -->\r <target interface="org.simantics.diagram.adapter.ElementFactory">\r <!-- Edges -->\r <resource uri="http://www.simantics.org/Sysdyn-1.0/FlowConnection"\r class="org.simantics.sysdyn.ui.elements2.connections.FlowEdgeFactory" />\r <resource uri="http://www.simantics.org/Sysdyn-1.0/DependencyConnection"\r class="org.simantics.sysdyn.ui.elements2.connections.DependencyEdgeFactory" />\r <type uri="http://www.simantics.org/Sysdyn-1.0/FlowConnection"\r class="org.simantics.sysdyn.ui.elements2.connections.FlowEdgeFactory" />\r <type uri="http://www.simantics.org/Sysdyn-1.0/DependencyConnection"\r class="org.simantics.sysdyn.ui.elements2.connections.DependencyEdgeFactory" />\r <!-- : SYSDYN.Connection-->\r <type uri="http://www.simantics.org/Sysdyn-1.0/FlowConnection"\r class="org.simantics.sysdyn.ui.elements2.connections.FlowConnectionFactory" />\r <type uri="http://www.simantics.org/Sysdyn-1.0/DependencyConnection"\r class="org.simantics.sysdyn.ui.elements2.connections.DependencyConnectionFactory" />\r </target>\r \r <target interface="org.simantics.g2d.connection.EdgeVisualsConfigurer">\r <baseType uri="http://www.simantics.org/Diagram-2.0/HasConnector" />\r <resource uri="http://www.simantics.org/Diagram-2.0/HasPlainConnector"\r class="org.simantics.diagram.content.ArrowConfigurer">\r <string>none 0</string>\r </resource>\r <resource uri="http://www.simantics.org/Diagram-2.0/HasArrowConnector"\r class="org.simantics.diagram.content.ArrowConfigurer">\r <string>fill 1</string>\r </resource>\r </target>\r \r
+</adapters>
\ No newline at end of file
--- /dev/null
+###############################################################################\r
+# Copyright (c) 2010 Association for Decentralized Information Management in\r
+# Industry THTH ry.\r
+# All rights reserved. This program and the accompanying materials\r
+# are made available under the terms of the Eclipse Public License v1.0\r
+# which accompanies this distribution, and is available at\r
+# http://www.eclipse.org/legal/epl-v10.html\r
+#\r
+# Contributors:\r
+# VTT Technical Research Centre of Finland - initial API and implementation\r
+###############################################################################\r
+source.. = src/\r
+output.. = bin/\r
+bin.includes = META-INF/,\\r
+ .,\\r
+ plugin.xml,\\r
+ adapters.xml,\\r
+ icons/,\\r
+ doc/,\\r
+ cheatsheet/\r
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>\r<!--\r
+ Copyright (c) 2010 Association for Decentralized Information Management in\r
+ Industry THTH ry.\r
+ All rights reserved. This program and the accompanying materials\r
+ are made available under the terms of the Eclipse Public License v1.0\r
+ which accompanies this distribution, and is available at\r
+ http://www.eclipse.org/legal/epl-v10.html\r
+ \r
+ Contributors:\r
+ VTT Technical Research Centre of Finland - initial API and implementation\r
+ -->\r
+
+<cheatsheet\r
+ title="System Dynamics Modeling">\r
+ <intro>\r
+ <description>\r
+ This cheatsheet helps with basic system dynamics modeling.\r
+ \r
+ </description>\r
+ </intro>\r
+ <item\r
+ href="https://www.simantics.org/wiki/index.php/System_Dynamics_Modelling_and_Simulation_Perspective"\r
+ skip="false"\r
+ title="Simple Working Model">\r
+ <description>\r
+ Press the ? button on the right to open the tutorial.\r
+ </description>\r
+ </item>
+</cheatsheet>\r
--- /dev/null
+Possible connections between sysdyn elements:\r
+\r
+{| border="1"\r
+| \r
+| \r
+| colspan="4", align="center" | To\r
+|-\r
+| \r
+| \r
+| Auxiliary\r
+| Stock\r
+| Valve\r
+| Cloud\r
+|-\r
+| rowspan="4" | From\r
+| Auxiliary\r
+| dependency\r
+| -\r
+| dependency\r
+| -\r
+|-\r
+| Stock\r
+| dependency\r
+| -\r
+| flow / dependency\r
+| -\r
+|-\r
+| Valve\r
+| dependency\r
+| flow\r
+| dependency (?)\r
+| flow\r
+|-\r
+| Cloud\r
+| -\r
+| -\r
+| flow\r
+| -\r
+|}\r
+\r
+Connection actions between sysdyn elements:\r
+\r
+{| border="1"\r
+| \r
+| \r
+| colspan="4", align="center" | To\r
+|-\r
+| \r
+| \r
+| Auxiliary\r
+| Stock\r
+| Valve\r
+| Cloud\r
+|-\r
+| rowspan="4" | From\r
+| Auxiliary\r
+| dependency\r
+| -\r
+| dependency\r
+| -\r
+|-\r
+| Stock\r
+| dependency\r
+| valve + 2 x flow\r
+| flow / dependency\r
+| valve + 2 x flow\r
+|-\r
+| Valve\r
+| dependency\r
+| flow\r
+| dependency (?)\r
+| flow\r
+|-\r
+| Cloud\r
+| -\r
+| valve + 2 x flow\r
+| flow\r
+| -\r
+|}
\ No newline at end of file
--- /dev/null
+###############################################################################\r
+# Copyright (c) 2010 Association for Decentralized Information Management in\r
+# Industry THTH ry.\r
+# All rights reserved. This program and the accompanying materials\r
+# are made available under the terms of the Eclipse Public License v1.0\r
+# which accompanies this distribution, and is available at\r
+# http://www.eclipse.org/legal/epl-v10.html\r
+#\r
+# Contributors:\r
+# VTT Technical Research Centre of Finland - initial API and implementation\r
+###############################################################################\r
+about.text=Simantics System Dynamics Workbench.\n\\r
+\n\\r
+Development build
\ No newline at end of file
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>\r
+<?eclipse version="3.4"?>\r<!--\r
+ Copyright (c) 2010 Association for Decentralized Information Management in\r
+ Industry THTH ry.\r
+ All rights reserved. This program and the accompanying materials\r
+ are made available under the terms of the Eclipse Public License v1.0\r
+ which accompanies this distribution, and is available at\r
+ http://www.eclipse.org/legal/epl-v10.html\r
+ \r
+ Contributors:\r
+ VTT Technical Research Centre of Finland - initial API and implementation\r
+ -->\r
+
+<plugin>\r
+ <extension\r
+ point="org.eclipse.ui.editors">\r
+ <editor\r
+ class="org.simantics.sysdyn.ui.editor.DiagramViewer"\r
+ default="false"\r
+ id="org.simantics.sysdyn.ui.diagramViewer"\r
+ name="System dynamic diagram viewer">\r
+ </editor>\r
+ <editor\r
+ class="org.simantics.sysdyn.ui.modelica.SysdynModelicaEditor"\r
+ contributorClass="org.simantics.sysdyn.ui.modelica.TextEditorActionBarContributor"\r
+ default="false"\r
+ id="org.simantics.sysdyn.ui.modelicaEditor"\r
+ name="Modelica code viewer">\r
+ </editor>\r
+ </extension>\r
+ <extension\r
+ point="org.simantics.ui.resourceEditorAdapter">\r
+ <adapterClass\r
+ class="org.simantics.sysdyn.ui.editor.OpenDiagramFromConfigurationAdapter"\r
+ groupId="org.simantics.diagramEditor.group"\r
+ priority="100">\r
+ </adapterClass>\r
+ <adapter\r
+ editorId="org.simantics.sysdyn.ui.modelicaEditor"\r
+ priority="2"\r
+ type_uris="http://www.simantics.org/Sysdyn-1.0/Configuration">\r
+ </adapter>\r
+ </extension>\r
+ <extension\r
+ point="org.eclipse.ui.views">\r
+ <category\r
+ id="org.simantics.sysdyn.ui.category"\r
+ name="System Dynamics">\r
+ </category>\r
+ <view\r
+ allowMultiple="true"\r
+ category="org.simantics.sysdyn.ui.category"\r
+ class="org.simantics.sysdyn.ui.trend.TrendView"\r
+ id="org.simantics.sysdyn.ui.trend.view"\r
+ name="Trend View"\r
+ restorable="true">\r
+ </view>\r
+ <view\r
+ category="org.simantics.sysdyn.ui.category"\r
+ class="org.simantics.sysdyn.ui.browser.SysdynBrowser"\r
+ id="org.simantics.sysdyn.ui.browser"\r
+ name="Sysdyn Model Browser"\r
+ restorable="true">\r
+ </view>\r
+ <view\r
+ allowMultiple="false"\r
+ category="org.simantics.sysdyn.ui.category"\r
+ class="org.simantics.sysdyn.ui.dependencies.DependencyView"\r
+ id="org.simantics.sysdyn.ui.dependencies.view"\r
+ name="Dependencies"\r
+ restorable="true">\r
+ </view>\r
+ <view\r
+ allowMultiple="false"\r
+ category="org.simantics.sysdyn.ui.category"\r
+ class="org.simantics.sysdyn.ui.values.ValueView"\r
+ id="org.simantics.sysdyn.ui.values.view"\r
+ name="Values View"\r
+ restorable="true">\r
+ </view>\r
+ <view\r
+ category="org.simantics.sysdyn.ui.category"\r
+ class="org.simantics.sysdyn.ui.browser.SysdynOperationBrowser"\r
+ icon="icons/chart_organisation.png"\r
+ id="org.simantics.sysdyn.ui.operationBrowser"\r
+ name="Operation Browser"\r
+ restorable="true">\r
+ <description>\r
+ Variable browser for Sysdyn.\r
+ </description>\r
+ </view>\r
+ <view\r
+ category="org.simantics.sysdyn.ui.category"\r
+ class="org.simantics.sysdyn.ui.browser.SysdynModelBrowser"\r
+ icon="icons/chart_organisation.png"\r
+ id="org.simantics.sysdyn.ui.modelBrowser"\r
+ name="Model Browser"\r
+ restorable="true">\r
+ <description>\r
+ Structural model browser view for Sysdyn.\r
+ </description>\r
+ </view>\r
+ </extension>\r
+ <extension\r
+ point="org.eclipse.ui.perspectives">\r
+ <perspective\r
+ class="org.simantics.sysdyn.ui.project.SysdynPerspectiveFactory"\r
+ icon="icons/chart_curve.png"\r
+ id="org.simantics.sysdyn.ui.perspective"\r
+ name="System dynamics">\r
+ </perspective>\r
+ </extension>\r
+ <extension\r
+ point="org.eclipse.ui.perspectiveExtensions">\r
+ <perspectiveExtension\r
+ targetID="org.simantics.sysdyn.ui.perspective">\r
+ <view\r
+ id="org.simantics.browsing.ui.graph.propertyView"\r
+ ratio="0.75f"\r
+ relationship="bottom"\r
+ relative="org.eclipse.ui.editorss">\r
+ </view>\r
+ <view\r
+ id="org.eclipse.ui.console.ConsoleView"\r
+ minimized="false"\r
+ relationship="stack"\r
+ relative="org.simantics.browsing.ui.graph.propertyView">\r
+ </view>\r
+ <view\r
+ id="org.simantics.sysdyn.ui.trend.view"\r
+ ratio="0.4f"\r
+ relationship="left"\r
+ relative="org.simantics.browsing.ui.graph.propertyView">\r
+ </view>\r
+ <view\r
+ id="org.simantics.sysdyn.ui.dependencies.view"\r
+ minimized="false"\r
+ relationship="stack"\r
+ relative="org.simantics.sysdyn.ui.trend.view">\r
+ </view>\r
+ <view\r
+ id="org.simantics.sysdyn.ui.browser"\r
+ ratio="0.25f"\r
+ relationship="left"\r
+ relative="org.eclipse.ui.editorss">\r
+ </view>\r
+ <view\r
+ id="org.simantics.diagram.symbollibrary"\r
+ minimized="false"\r
+ relationship="stack"\r
+ relative="org.simantics.sysdyn.ui.browser">\r
+ </view>\r
+ <view\r
+ id="org.simantics.sysdyn.ui.values.view"\r
+ relationship="stack"\r
+ relative="org.simantics.sysdyn.ui.trend.view">\r
+ </view>\r
+ \r
+ </perspectiveExtension>\r
+ </extension>\r
+ <extension\r
+ point="org.eclipse.ui.contexts">\r
+ <context\r
+ id="org.simantics.sysdyn.ui.basicExperiment"\r
+ name="Basic Experiment">\r
+ </context>\r
+ </extension>\r
+ <extension\r
+ point="org.eclipse.ui.menus">\r
+ <menuContribution\r
+ locationURI="toolbar:org.eclipse.ui.main.toolbar">\r
+ <toolbar\r
+ id="org.simantics.sysdyn.ui.experimentControlToolbar">\r
+ <command\r
+ commandId="org.simantics.sysdyn.ui.run"\r
+ hoverIcon="icons/control_play_blue.png"\r
+ icon="icons/control_play.png"\r
+ id="org.simantics.sysdyn.ui.run.button"\r
+ label="Simulate"\r
+ style="push">\r
+ <visibleWhen>\r
+ <with\r
+ variable="activeContexts">\r
+ <iterate\r
+ ifEmpty="false"\r
+ operator="or">\r
+ <equals\r
+ value="org.simantics.sysdyn.ui.basicExperiment">\r
+ </equals>\r
+ </iterate>\r
+ </with>\r
+ </visibleWhen>\r
+ </command>\r
+ <command\r
+ commandId="org.simantics.sysdyn.ui.toggleSimulation"\r
+ hoverIcon="icons/control_repeat_blue.png"\r
+ icon="icons/control_repeat.png"\r
+ label="Simulate On Change"\r
+ style="toggle"\r
+ tooltip="Simulate On Change">\r
+ <visibleWhen>\r
+ <with\r
+ variable="activeContexts">\r
+ <iterate\r
+ ifEmpty="false"\r
+ operator="or">\r
+ <equals\r
+ value="org.simantics.sysdyn.ui.basicExperiment">\r
+ </equals>\r
+ </iterate>\r
+ </with>\r
+ </visibleWhen>\r
+ </command>\r
+ <command\r
+ commandId="org.simantics.sysdyn.ui.dispose"\r
+ hoverIcon="icons/control_eject_blue.png"\r
+ icon="icons/control_eject.png"\r
+ id="org.simantics.sysdyn.ui.dispose.button"\r
+ label="Quit Experiment">\r
+ <visibleWhen>\r
+ <with\r
+ variable="activeContexts">\r
+ <iterate\r
+ ifEmpty="false"\r
+ operator="or">\r
+ <equals\r
+ value="org.simantics.sysdyn.ui.basicExperiment">\r
+ </equals>\r
+ </iterate>\r
+ </with>\r
+ </visibleWhen>\r
+ </command>\r
+ <command\r
+ commandId="org.simantics.sysdyn.ui.saveResults"\r
+ icon="icons/disk.png"\r
+ id="org.simantics.sysdyn.ui.save.button">\r
+ <visibleWhen>\r
+ <with\r
+ variable="activeContexts">\r
+ <iterate\r
+ ifEmpty="false"\r
+ operator="or">\r
+ <equals\r
+ value="org.simantics.sysdyn.ui.basicExperiment">\r
+ </equals>\r
+ </iterate>\r
+ </with>\r
+ </visibleWhen>\r
+ </command>\r
+ </toolbar>\r
+ </menuContribution>\r
+ <menuContribution\r
+ locationURI="toolbar:org.simantics.sysdyn.ui.trend.view">\r
+ <command\r
+ commandId="org.simantics.sysdyn.ui.trend.view.pin"\r
+ icon="icons/table_multiple_pinned.png"\r
+ label="Pin Trend"\r
+ style="toggle"\r
+ tooltip="Pins the trend so that it does not react to selection changes">\r
+ </command>\r
+ </menuContribution>\r
+ <menuContribution\r
+ locationURI="popup:#SysdynBrowserPopup?after=wbStart">\r
+ <menu id="org.simantics.new"\r
+ label="New">\r
+ <command\r
+ commandId="org.simantics.modeling.ui.newModel"\r
+ id="org.simantics.sysdyn.ui.browser.newModel"\r
+ label="Model"\r
+ style="push">\r
+ </command>\r
+ <command\r
+ commandId="org.simantics.sysdyn.ui.newModuleNode"\r
+ id="org.simantics.sysdyn.ui.browser.newModule"\r
+ label="Module"\r
+ style="push">\r
+ <visibleWhen\r
+ checkEnabled="true">\r
+ <with\r
+ variable="selection">\r
+ <test\r
+ args="org.simantics.sysdyn.ui.browser.nodes.ModulesNode"\r
+ property="org.simantics.sysdyn.ui.nodeClass">\r
+ </test>\r
+ </with>\r
+ </visibleWhen>\r
+ </command>\r
+ <command\r
+ commandId="org.simantics.sysdyn.ui.newExperiment"\r
+ id="org.simantics.sysdyn.ui.browser.newExperiment"\r
+ label="Experiment"\r
+ style="push">\r
+ <visibleWhen\r
+ checkEnabled="true">\r
+ <with\r
+ variable="selection">\r
+ <test\r
+ args="org.simantics.sysdyn.ui.browser.nodes.ExperimentsFolder"\r
+ property="org.simantics.sysdyn.ui.nodeClass">\r
+ </test>\r
+ </with>\r
+ </visibleWhen>\r
+ </command>\r
+ <command\r
+ commandId="org.simantics.sysdyn.ui.newEnumeration"\r
+ id="org.simantics.sysdyn.ui.browser.newEnumeration"\r
+ label="Enumeration"\r
+ style="push">\r
+ <visibleWhen\r
+ checkEnabled="true">\r
+ </visibleWhen>\r
+ </command>\r
+ <command\r
+ commandId="org.simantics.sysdyn.ui.newFunction"\r
+ id="org.simantics.sysdyn.ui.browser.newFunction"\r
+ label="Function"\r
+ style="push">\r
+ <visibleWhen\r
+ checkEnabled="true">\r
+ <with\r
+ variable="selection">\r
+ <or>\r
+ <test\r
+ args="org.simantics.sysdyn.ui.browser.nodes.FunctionsFolder"\r
+ property="org.simantics.sysdyn.ui.nodeClass">\r
+ </test>\r
+ <test\r
+ args="org.simantics.sysdyn.ui.browser.nodes.FunctionLibraryNode"\r
+ property="org.simantics.sysdyn.ui.nodeClass">\r
+ </test>\r
+ <test\r
+ args="org.simantics.sysdyn.ui.browser.nodes.FunctionNode"\r
+ property="org.simantics.sysdyn.ui.nodeClass">\r
+ </test>\r
+ </or>\r
+ </with>\r
+ </visibleWhen>\r
+ </command>\r
+ <command\r
+ commandId="org.simantics.sysdyn.ui.newFunctionLibrary"\r
+ label="Function Library"\r
+ style="push">\r
+ <visibleWhen\r
+ checkEnabled="true">\r
+ <with\r
+ variable="selection">\r
+ <or>\r
+ <test\r
+ args="org.simantics.sysdyn.ui.browser.nodes.FunctionsFolder"\r
+ property="org.simantics.sysdyn.ui.nodeClass">\r
+ </test>\r
+ <test\r
+ args="org.simantics.sysdyn.ui.browser.nodes.FunctionLibraryNode"\r
+ property="org.simantics.sysdyn.ui.nodeClass">\r
+ </test>\r
+ </or>\r
+ </with>\r
+ </visibleWhen>\r
+ </command>\r
+ <command\r
+ commandId="org.simantics.sysdyn.ui.newSharedFunctionLibrary"\r
+ label="Shared Function Library"\r
+ style="push">\r
+ <visibleWhen\r
+ checkEnabled="true">\r
+ <with\r
+ variable="selection">\r
+ <test\r
+ args="org.simantics.sysdyn.ui.browser.nodes.SharedFunctionsFolder"\r
+ property="org.simantics.sysdyn.ui.nodeClass">\r
+ </test>\r
+ </with>\r
+ </visibleWhen>\r
+ </command>\r
+ </menu>\r
+ <dynamic\r
+ class="org.simantics.ui.contribution.OpenWithMenuContribution"\r
+ id="org.simantics.sysdyn.ui.browser.openWithMenu">\r
+ </dynamic>\r
+ <command\r
+ commandId="org.simantics.sysdyn.ui.activateResult"\r
+ id="org.simantics.sysdyn.ui.browser.activateResult"\r
+ label="Show in charts"\r
+ style="push">\r
+ <visibleWhen\r
+ checkEnabled="true">\r
+ <with\r
+ variable="selection">\r
+ <test\r
+ args="org.simantics.sysdyn.ui.browser.nodes.SimulationResultNode"\r
+ property="org.simantics.sysdyn.ui.nodeClass">\r
+ </test>\r
+ </with>\r
+ </visibleWhen>\r
+ </command>\r
+ <command\r
+ commandId="org.simantics.sysdyn.ui.renameNode"\r
+ icon="icons/textfield_rename.png"\r
+ id="org.simantics.sysdyn.ui.browser.rename"\r
+ label="Rename"\r
+ style="push">\r
+ <visibleWhen checkEnabled="true">\r
+ </visibleWhen>\r
+ </command>\r
+ <command\r
+ commandId="org.simantics.sysdyn.ui.removeNode"\r
+ icon="icons/cross.png"\r
+ id="org.simantics.sysdyn.ui.browser.remove"\r
+ label="Remove"\r
+ style="push">\r
+ <visibleWhen checkEnabled="true">\r
+ </visibleWhen>\r
+ </command>\r
+ <menu\r
+ id="org.simantics.sysdyn.import"\r
+ label="Import">\r
+ <command\r
+ commandId="org.simantics.sysdyn.ui.importModel"\r
+ label="Model"\r
+ style="push">\r
+ <visibleWhen\r
+ checkEnabled="true">\r
+ </visibleWhen>\r
+ </command>\r
+ <command\r
+ commandId="org.simantics.sysdyn.ui.importMdl"\r
+ label="Vensim model (*.mdl)"\r
+ style="push">\r
+ <visibleWhen\r
+ checkEnabled="true">\r
+ </visibleWhen>\r
+ </command>\r
+ <command\r
+ commandId="org.simantics.image.ui.importImage"\r
+ icon="icons/image_add.png"\r
+ label="Image"\r
+ style="push">\r
+ <visibleWhen\r
+ checkEnabled="true">\r
+ <with\r
+ variable="selection">\r
+ <test\r
+ args="org.simantics.image.ui.modelBrowser.ImagesNode"\r
+ property="org.simantics.modeling.ui.nodeClass">\r
+ </test>\r
+ </with>\r
+ </visibleWhen>\r
+ </command>\r
+ <command\r
+ commandId="org.simantics.sysdyn.ui.importFunctionLibrary"\r
+ label="Function library"\r
+ style="push">\r
+ <visibleWhen\r
+ checkEnabled="true">\r
+ </visibleWhen>\r
+ </command>\r
+ <command\r
+ commandId="org.simantics.sysdyn.ui.importModuleLibrary"\r
+ label="Module library"\r
+ style="push">\r
+ <visibleWhen\r
+ checkEnabled="true">\r
+ </visibleWhen>\r
+ </command>\r
+ </menu>\r
+ <menu\r
+ id="org.simantics.sysdyn.export"\r
+ label="Export">\r
+ <command\r
+ commandId="org.simantics.sysdyn.ui.exportModel"\r
+ label="Model"\r
+ style="push">\r
+ <visibleWhen\r
+ checkEnabled="true">\r
+ </visibleWhen>\r
+ </command>\r
+ <command\r
+ commandId="org.simantics.sysdyn.ui.exportFunctionLibrary"\r
+ label="Function library"\r
+ style="push">\r
+ <visibleWhen\r
+ checkEnabled="true">\r
+ </visibleWhen>\r
+ </command>\r
+ <command\r
+ commandId="org.simantics.sysdyn.ui.exportModuleLibrary"\r
+ label="Module library"\r
+ style="push">\r
+ <visibleWhen\r
+ checkEnabled="true">\r
+ </visibleWhen>\r
+ </command>\r
+ </menu>\r
+ </menuContribution>\r
+ <menuContribution\r
+ locationURI="popup:#SysdynDiagramPopup?after=wbStart">\r
+ <command\r
+ commandId="org.simantics.sysdyn.ui.showModule"\r
+ icon="icons/palette.png"\r
+ label="Show Module"\r
+ style="push">\r
+ <visibleWhen>\r
+ <with\r
+ variable="selection">\r
+ <test\r
+ args="http://www.simantics.org/Sysdyn-1.0/ModuleSymbol"\r
+ property="org.simantics.graph.resourceType">\r
+ </test>\r
+ </with>\r
+ </visibleWhen>\r
+ </command>\r
+ </menuContribution>\r
+ <menuContribution\r
+ locationURI="popup:#ExternalFunctionFileBrowser?after=wbStart">\r
+ <command\r
+ commandId="org.simantics.sysdyn.ui.importExternalFunctionFile"\r
+ label="Import Files"\r
+ style="push">\r
+ </command>\r
+ <command\r
+ commandId="org.simantics.sysdyn.ui.exportExternalFunctionFile"\r
+ label="Export Files"\r
+ style="push">\r
+ </command>\r
+ <command\r
+ commandId="org.simantics.sysdyn.ui.removeNode"\r
+ icon="icons/cross.png"\r
+ id="org.simantics.sysdyn.ui.browser.remove"\r
+ label="Remove"\r
+ style="push">\r
+ <visibleWhen\r
+ checkEnabled="true">\r
+ </visibleWhen>\r
+ </command>\r
+ </menuContribution>\r
+ </extension>\r
+ <extension\r
+ point="org.eclipse.ui.commands">\r
+ <command\r
+ id="org.simantics.sysdyn.ui.trend.view.pin"\r
+ name="Pin Trend">\r
+ <state\r
+ class="org.eclipse.jface.commands.ToggleState"\r
+ id="org.simantics.sysdyn.ui.trend.view.pin.state">\r
+ </state>\r
+ </command>\r
+ <command\r
+ id="org.simantics.sysdyn.ui.showModule"\r
+ name="Show Module">\r
+ </command>\r
+ <command\r
+ id="org.simantics.sysdyn.ui.removeNode"\r
+ name="Remove Node">\r
+ </command>\r
+ <command\r
+ id="org.simantics.sysdyn.ui.renameNode"\r
+ name="Rename Node">\r
+ </command>\r
+ <command\r
+ defaultHandler="org.simantics.sysdyn.ui.handlers.ToggleSimulation"\r
+ id="org.simantics.sysdyn.ui.toggleSimulation"\r
+ name="Toggle Simulate">\r
+ <state\r
+ class="org.eclipse.jface.commands.ToggleState"\r
+ id="org.simantics.sysdyn.ui.toggleSimulation.state">\r
+ </state>\r
+ </command>\r
+ <command\r
+ defaultHandler="org.simantics.sysdyn.ui.handlers.NewModuleNodeHandler"\r
+ id="org.simantics.sysdyn.ui.newModuleNode"\r
+ name="New Module">\r
+ </command>\r
+ <command\r
+ id="org.simantics.sysdyn.ui.activateExperiment"\r
+ name="Activate Experiment">\r
+ </command>\r
+ <command\r
+ defaultHandler="org.simantics.sysdyn.ui.handlers.RunBasicExperiment"\r
+ id="org.simantics.sysdyn.ui.run"\r
+ name="Run Basic Simulation">\r
+ </command>\r
+ <command\r
+ defaultHandler="org.simantics.sysdyn.ui.handlers.DisposeExperiment"\r
+ id="org.simantics.sysdyn.ui.dispose"\r
+ name="Quit Experiment">\r
+ </command>\r
+ <command\r
+ defaultHandler="org.simantics.sysdyn.ui.handlers.SaveResultsHandler"\r
+ id="org.simantics.sysdyn.ui.saveResults"\r
+ name="Save Results">\r
+ </command>\r
+ <command\r
+ defaultHandler="org.simantics.sysdyn.ui.handlers.ToggleResultActivation"\r
+ id="org.simantics.sysdyn.ui.activateResult"\r
+ name="Show in charts">\r
+ </command>\r
+ <command\r
+ defaultHandler="org.simantics.sysdyn.ui.handlers.NewExperimentNodeHandler"\r
+ id="org.simantics.sysdyn.ui.newExperiment"\r
+ name="New Experiment">\r
+ </command>\r
+ <command\r
+ id="org.simantics.sysdyn.ui.exportModel"\r
+ name="Export model">\r
+ </command>\r
+ <command\r
+ id="org.simantics.sysdyn.ui.importModel"\r
+ name="Import model">\r
+ </command>\r
+ <command\r
+ id="org.simantics.sysdyn.ui.newEnumeration"\r
+ name="New Enumeration">\r
+ </command>\r
+ <command\r
+ id="org.simantics.sysdyn.ui.importMdl"\r
+ name="Import .mdl">\r
+ </command>\r
+ <command\r
+ defaultHandler="org.simantics.sysdyn.ui.handlers.NewFunctionHandler"\r
+ id="org.simantics.sysdyn.ui.newFunction"\r
+ name="NewFunction">\r
+ </command>\r
+ <command\r
+ id="org.simantics.sysdyn.ui.importExternalFunctionFile"\r
+ name="ImportExternalFunctionFile">\r
+ </command>\r
+ <command\r
+ id="org.simantics.sysdyn.ui.exportExternalFunctionFile"\r
+ name="ExportExternalFunctionFile">\r
+ </command>\r
+ <command\r
+ id="org.simantics.sysdyn.ui.newFunctionLibrary"\r
+ name="New Function Library">\r
+ </command>\r
+ <command\r
+ id="org.simantics.sysdyn.ui.newSharedFunctionLibrary"\r
+ name="New Shared Function Library">\r
+ </command>\r
+ <command\r
+ id="org.simantics.sysdyn.ui.importFunctionLibrary"\r
+ name="Import Function Library">\r
+ </command>\r
+ <command\r
+ id="org.simantics.sysdyn.ui.exportFunctionLibrary"\r
+ name="Export Function Library">\r
+ </command>\r
+ </extension>\r
+ <extension\r
+ point="org.eclipse.ui.handlers">\r
+ <handler\r
+ class="org.simantics.sysdyn.ui.trend.PinTrend"\r
+ commandId="org.simantics.sysdyn.ui.trend.view.pin">\r
+ </handler>\r
+ <handler\r
+ class="org.simantics.sysdyn.ui.handlers.ShowModuleHandler"\r
+ commandId="org.simantics.sysdyn.ui.showModule">\r
+ <enabledWhen>\r
+ <and>\r
+ <with\r
+ variable="selection">\r
+ <and>\r
+ <test\r
+ args="http://www.simantics.org/Sysdyn-1.0/ModuleSymbol"\r
+ property="org.simantics.graph.resourceType">\r
+ </test>\r
+ </and>\r
+ </with>\r
+ </and>\r
+ </enabledWhen>\r
+ </handler>\r
+ <handler\r
+ class="org.simantics.sysdyn.ui.handlers.UnlinkNodeHandler2"\r
+ commandId="org.simantics.sysdyn.ui.removeNode">\r
+ <activeWhen>\r
+ <with\r
+ variable="selection">\r
+ <or>\r
+ <test\r
+ args="org.simantics.sysdyn.ui.browser.nodes.ModelNode"\r
+ property="org.simantics.sysdyn.ui.nodeClass">\r
+ </test>\r
+ <test\r
+ args="org.simantics.sysdyn.ui.browser.nodes.ExperimentNode"\r
+ property="org.simantics.sysdyn.ui.nodeClass">\r
+ </test>\r
+ <test\r
+ args="org.simantics.sysdyn.ui.browser.nodes.SimulationResultNode"\r
+ property="org.simantics.sysdyn.ui.nodeClass">\r
+ </test>\r
+ <test\r
+ args="org.simantics.sysdyn.ui.browser.nodes.ModuleTypeNode"\r
+ property="org.simantics.sysdyn.ui.nodeClass">\r
+ </test>\r
+ <test\r
+ args="org.simantics.image.ui.modelBrowser.ImageNode"\r
+ property="org.simantics.sysdyn.ui.nodeClass">\r
+ </test>\r
+ <test\r
+ args="org.simantics.sysdyn.ui.browser.nodes.EnumerationNode"\r
+ property="org.simantics.sysdyn.ui.nodeClass">\r
+ </test>\r
+ <test\r
+ args="org.simantics.operating.ui.modelBrowser.CompositeNode"\r
+ property="org.simantics.sysdyn.ui.nodeClass">\r
+ </test>\r
+ <test\r
+ args="org.simantics.sysdyn.ui.properties.widgets.externalFiles.ExternalFileNode"\r
+ property="org.simantics.sysdyn.ui.nodeClass">\r
+ </test>\r
+ <test\r
+ args="org.simantics.sysdyn.ui.browser.nodes.FunctionNode"\r
+ property="org.simantics.sysdyn.ui.nodeClass">\r
+ </test>\r
+ <test\r
+ args="org.simantics.sysdyn.ui.browser.nodes.FunctionLibraryNode"\r
+ property="org.simantics.sysdyn.ui.nodeClass">\r
+ </test>\r
+ </or>\r
+ </with>\r
+ </activeWhen>\r
+ </handler>\r
+ <handler\r
+ class="org.simantics.sysdyn.ui.handlers.RenameNodeHandler"\r
+ commandId="org.simantics.sysdyn.ui.renameNode">\r
+ <activeWhen>\r
+ <with\r
+ variable="selection">\r
+ <or>\r
+ <test\r
+ args="org.simantics.sysdyn.ui.browser.nodes.ModelNode"\r
+ property="org.simantics.sysdyn.ui.nodeClass">\r
+ </test>\r
+ <test\r
+ args="org.simantics.sysdyn.ui.browser.nodes.ExperimentNode"\r
+ property="org.simantics.sysdyn.ui.nodeClass">\r
+ </test>\r
+ <test\r
+ args="org.simantics.sysdyn.ui.browser.nodes.SimulationResultNode"\r
+ property="org.simantics.sysdyn.ui.nodeClass">\r
+ </test>\r
+ <test\r
+ args="org.simantics.sysdyn.ui.browser.nodes.ModuleTypeNode"\r
+ property="org.simantics.sysdyn.ui.nodeClass">\r
+ </test>\r
+ <test\r
+ args="org.simantics.sysdyn.ui.browser.nodes.FunctionNode"\r
+ property="org.simantics.sysdyn.ui.nodeClass">\r
+ </test>\r
+ <test\r
+ args="org.simantics.sysdyn.ui.browser.nodes.FunctionLibraryNode"\r
+ property="org.simantics.sysdyn.ui.nodeClass">\r
+ </test>\r
+ </or>\r
+ </with>\r
+ </activeWhen>\r
+ </handler>\r
+ <handler\r
+ class="org.simantics.sysdyn.ui.handlers.ImportModelHandler"\r
+ commandId="org.simantics.sysdyn.ui.importModel">\r
+ </handler>\r
+ <handler\r
+ class="org.simantics.sysdyn.ui.handlers.ExportModelHandler"\r
+ commandId="org.simantics.sysdyn.ui.exportModel">\r
+ <activeWhen>\r
+ <with\r
+ variable="selection">\r
+ <test\r
+ args="org.simantics.sysdyn.ui.browser.nodes.ModelNode"\r
+ property="org.simantics.sysdyn.ui.nodeClass">\r
+ </test>\r
+ </with>\r
+ </activeWhen>\r
+ </handler>\r
+ <handler\r
+ class="org.simantics.sysdyn.ui.handlers.ImportMdlHandler"\r
+ commandId="org.simantics.sysdyn.ui.importMdl">\r
+ </handler>\r
+ <handler\r
+ class="org.simantics.sysdyn.ui.handlers.NewEnumerationNodeHandler"\r
+ commandId="org.simantics.sysdyn.ui.newEnumeration">\r
+ <activeWhen>\r
+ <with\r
+ variable="selection">\r
+ <or>\r
+ <test\r
+ args="org.simantics.sysdyn.ui.browser.nodes.ModuleTypeNode"\r
+ property="org.simantics.sysdyn.ui.nodeClass">\r
+ </test>\r
+ <test\r
+ args="org.simantics.sysdyn.ui.browser.nodes.ConfigurationNode"\r
+ property="org.simantics.sysdyn.ui.nodeClass">\r
+ </test>\r
+ </or>\r
+ </with>\r
+ </activeWhen>\r
+ </handler>\r
+ <handler\r
+ class="org.simantics.sysdyn.ui.handlers.ImportExternalFunctionFilesHandler"\r
+ commandId="org.simantics.sysdyn.ui.importExternalFunctionFile">\r
+ </handler>\r
+ <handler\r
+ class="org.simantics.sysdyn.ui.handlers.ExportExternalFunctionFilesHandler"\r
+ commandId="org.simantics.sysdyn.ui.exportExternalFunctionFile">\r
+ </handler>\r
+ <handler\r
+ class="org.simantics.sysdyn.ui.handlers.NewFunctionLibraryHandler"\r
+ commandId="org.simantics.sysdyn.ui.newFunctionLibrary">\r
+ </handler>\r
+ <handler\r
+ class="org.simantics.sysdyn.ui.handlers.NewSharedFunctionLibraryHandler"\r
+ commandId="org.simantics.sysdyn.ui.newSharedFunctionLibrary">\r
+ </handler>\r
+ <handler\r
+ class="org.simantics.sysdyn.ui.handlers.ExportFunctionLibrary"\r
+ commandId="org.simantics.sysdyn.ui.exportFunctionLibrary">\r
+ <activeWhen>\r
+ <with\r
+ variable="selection">\r
+ <or>\r
+ <test\r
+ args="org.simantics.sysdyn.ui.browser.nodes.FunctionLibraryNode"\r
+ property="org.simantics.sysdyn.ui.nodeClass">\r
+ </test>\r
+ <test\r
+ args="org.simantics.sysdyn.ui.browser.nodes.SharedFunctionLibraryNode"\r
+ property="org.simantics.sysdyn.ui.nodeClass">\r
+ </test>\r
+ </or>\r
+ </with>\r
+ </activeWhen>\r
+ </handler>\r
+ <handler\r
+ class="org.simantics.sysdyn.ui.handlers.ImportFunctionLibrary"\r
+ commandId="org.simantics.sysdyn.ui.importFunctionLibrary">\r
+ <activeWhen>\r
+ <with\r
+ variable="selection">\r
+ <or>\r
+ <test\r
+ args="org.simantics.sysdyn.ui.browser.nodes.FunctionLibraryNode"\r
+ property="org.simantics.sysdyn.ui.nodeClass">\r
+ </test>\r
+ <test\r
+ args="org.simantics.sysdyn.ui.browser.nodes.SharedFunctionLibraryNode"\r
+ property="org.simantics.sysdyn.ui.nodeClass">\r
+ </test>\r
+ <test\r
+ args="org.simantics.sysdyn.ui.browser.nodes.FunctionsFolder"\r
+ property="org.simantics.sysdyn.ui.nodeClass">\r
+ </test>\r
+ </or>\r
+ </with>\r
+ </activeWhen>\r
+ </handler>\r
+ </extension>\r
+ <extension\r
+ point="org.simantics.browsing.ui.common.viewpointContributionBinding">\r
+ <binding\r
+ browseContext="http://www.simantics.org/Sysdyn-1.0/Browser">\r
+ <implementation\r
+ class="org.simantics.sysdyn.ui.browser.contributions.ModuleType"\r
+ preference="1.0">\r
+ </implementation>\r
+ <implementation\r
+ class="org.simantics.sysdyn.ui.browser.contributions.Project"\r
+ preference="1.0">\r
+ </implementation>\r
+ <implementation\r
+ class="org.simantics.sysdyn.ui.browser.contributions.Modules"\r
+ preference="1.0">\r
+ </implementation>\r
+ <implementation\r
+ class="org.simantics.sysdyn.ui.browser.contributions.Model"\r
+ preference="2.0">\r
+ </implementation>\r
+ <implementation\r
+ class="org.simantics.sysdyn.ui.browser.contributions.Experiment"\r
+ preference="1.0">\r
+ </implementation>\r
+ <implementation\r
+ class="org.simantics.sysdyn.ui.browser.contributions.SimulationResult"\r
+ preference="2.0">\r
+ </implementation>\r
+ <implementation\r
+ class="org.simantics.sysdyn.ui.browser.contributions.Configuration"\r
+ preference="2.0">\r
+ </implementation>\r
+ <implementation\r
+ class="org.simantics.sysdyn.ui.browser.contributions.FunctionLibraries"\r
+ preference="2.0">\r
+ </implementation>\r
+ <implementation\r
+ class="org.simantics.sysdyn.ui.browser.contributions.LibraryFunctions"\r
+ preference="2.0">\r
+ </implementation>\r
+ <implementation\r
+ class="org.simantics.sysdyn.ui.browser.contributions.SharedFunctionLibraries"\r
+ preference="2.0">\r
+ </implementation>\r
+ </binding>\r
+ <binding browseContext="http://www.simantics.org/Sysdyn-1.0/SysdynOperationBrowser">\r
+ <implementation class="org.simantics.sysdyn.ui.property.OperationProjectContributor" preference="1.0"/>\r
+ <implementation class="org.simantics.sysdyn.ui.property.OperationModelContributor" preference="1.0"/>\r
+ <implementation class="org.simantics.sysdyn.ui.property.OperationVariableContributor" preference="1.0"/>\r
+ </binding>\r
+ <binding\r
+ browseContext="http://www.simantics.org/Sysdyn-1.0/AvailableVariableIndexes">\r
+ <implementation\r
+ class="org.simantics.sysdyn.ui.properties.widgets.arrays.AvailableEnumerations"\r
+ preference="2.0">\r
+ </implementation>\r
+ </binding>\r
+ <binding\r
+ browseContext="http://www.simantics.org/Sysdyn-1.0/UsedVariableIndexes">\r
+ <implementation\r
+ class="org.simantics.sysdyn.ui.properties.widgets.arrays.UsedEnumerations"\r
+ preference="2.0">\r
+ </implementation>\r
+ </binding>\r
+ <binding\r
+ browseContext="http://www.simantics.org/Sysdyn-1.0/EnumerationIndexes">\r
+ <implementation\r
+ class="org.simantics.sysdyn.ui.properties.widgets.arrays.EnumerationIndexes"\r
+ preference="2.0">\r
+ </implementation>\r
+ </binding>\r
+ <binding\r
+ browseContext="http://www.simantics.org/Sysdyn-1.0/EnumerationReplacement">\r
+ <implementation\r
+ class="org.simantics.sysdyn.ui.properties.widgets.arrays.ReplaceableEnumerations"\r
+ preference="2.0">\r
+ </implementation>\r
+ </binding>\r
+ <binding\r
+ browseContext="http://www.simantics.org/Sysdyn-1.0/ExternalFiles">\r
+ <implementation\r
+ class="org.simantics.sysdyn.ui.properties.widgets.externalFiles.ExternalFiles"\r
+ preference="2.0">\r
+ </implementation>\r
+ </binding>\r
+ <binding\r
+ browseContext="http://www.simantics.org/Sysdyn-1.0/ModelBrowser">\r
+ <implementation\r
+ class="org.simantics.sysdyn.ui.browser.contributions.SysdynProject"\r
+ preference="2.0">\r
+ </implementation>\r
+ </binding>\r
+ <binding\r
+ browseContext="http://www.simantics.org/Sysdyn-1.0/AvailableSharedFunctionLibraries">\r
+ <implementation\r
+ class="org.simantics.sysdyn.ui.properties.widgets.functions.SharedFunctionLibraries"\r
+ preference="2.0">\r
+ </implementation>\r
+ </binding>\r
+ <binding\r
+ browseContext="http://www.simantics.org/Sysdyn-1.0/SelectedSharedFunctionLibraries">\r
+ <implementation\r
+ class="org.simantics.sysdyn.ui.properties.widgets.functions.SelectedSharedFunctionLibraries"\r
+ preference="2.0">\r
+ </implementation>\r
+ </binding>\r
+ </extension>\r
+ <extension\r
+ point="org.simantics.browsing.ui.common.labelerBinding">\r
+ <binding\r
+ browseContext="http://www.simantics.org/Sysdyn-1.0/Browser">\r
+ <implementation\r
+ class="org.simantics.sysdyn.ui.browser.contributions.ConfigurationLabeler"\r
+ preference="2.0">\r
+ </implementation>\r
+ <implementation\r
+ class="org.simantics.sysdyn.ui.browser.contributions.VariableLabeler"\r
+ preference="2.0">\r
+ </implementation>\r
+ <implementation\r
+ class="org.simantics.sysdyn.ui.browser.contributions.ExperimentsLabeler"\r
+ preference="2.0">\r
+ </implementation>\r
+ <implementation\r
+ class="org.simantics.sysdyn.ui.browser.contributions.ModelLabeler"\r
+ preference="2.0">\r
+ </implementation>\r
+ <implementation\r
+ class="org.simantics.sysdyn.ui.browser.contributions.ModulesLabeler"\r
+ preference="2.0">\r
+ </implementation>\r
+ <implementation\r
+ class="org.simantics.sysdyn.ui.browser.contributions.ExperimentLabeler"\r
+ preference="2.0">\r
+ </implementation>\r
+ <implementation\r
+ class="org.simantics.sysdyn.ui.browser.contributions.SimulationResultLabeler"\r
+ preference="2.0">\r
+ </implementation>\r
+ <implementation\r
+ class="org.simantics.sysdyn.ui.browser.contributions.ModuleLabeler"\r
+ preference="2.0">\r
+ </implementation>\r
+ <implementation\r
+ class="org.simantics.sysdyn.ui.browser.contributions.InputLabeler"\r
+ preference="2.0">\r
+ </implementation>\r
+ <implementation\r
+ class="org.simantics.sysdyn.ui.browser.contributions.ModuleTypeLabeler"\r
+ preference="2.0">\r
+ </implementation>\r
+ <implementation\r
+ class="org.simantics.sysdyn.ui.browser.contributions.FunctionsLabeler"\r
+ preference="2.0">\r
+ </implementation>\r
+ <implementation\r
+ class="org.simantics.sysdyn.ui.browser.contributions.FunctionLibraryLabeler"\r
+ preference="2.0">\r
+ </implementation>\r
+ <implementation\r
+ class="org.simantics.sysdyn.ui.browser.contributions.SharedFunctionsLabeler"\r
+ preference="2.0">\r
+ </implementation>\r
+ </binding>\r
+ <binding browseContext="http://www.simantics.org/Sysdyn-1.0/SysdynOperationBrowser">\r
+ <implementation class="org.simantics.sysdyn.ui.property.OperationModelLabels" preference="1.0"/>\r
+ <implementation class="org.simantics.sysdyn.ui.property.OperationVariableLabels" preference="1.0"/>\r
+ </binding>\r
+ <binding\r
+ browseContext="http://www.simantics.org/Sysdyn-1.0/AvailableVariableIndexes">\r
+ <implementation\r
+ class="org.simantics.sysdyn.ui.properties.widgets.arrays.EnumerationLabeler"\r
+ preference="1.0">\r
+ </implementation>\r
+ </binding>\r
+ <binding\r
+ browseContext="http://www.simantics.org/Sysdyn-1.0/UsedVariableIndexes">\r
+ <implementation\r
+ class="org.simantics.sysdyn.ui.properties.widgets.arrays.EnumerationLabeler"\r
+ preference="2.0">\r
+ </implementation>\r
+ </binding>\r
+ <binding\r
+ browseContext="http://www.simantics.org/Sysdyn-1.0/EnumerationIndexes">\r
+ <implementation\r
+ class="org.simantics.sysdyn.ui.properties.widgets.arrays.EnumerationIndexLabeler"\r
+ preference="2.0">\r
+ </implementation>\r
+ </binding>\r
+ <binding\r
+ browseContext="http://www.simantics.org/Sysdyn-1.0/EnumerationReplacement">\r
+ <implementation\r
+ class="org.simantics.sysdyn.ui.properties.widgets.arrays.ReplaceableEnumerationsLabeler"\r
+ preference="2.0">\r
+ </implementation>\r
+ </binding>\r
+ <binding\r
+ browseContext="http://www.simantics.org/Sysdyn-1.0/ExternalFiles">\r
+ <implementation\r
+ class="org.simantics.sysdyn.ui.properties.widgets.externalFiles.ExternalFileLabeler"\r
+ preference="2.0">\r
+ </implementation>\r
+ </binding>\r
+ <binding\r
+ browseContext="http://www.simantics.org/Sysdyn-1.0/AvailableSharedFunctionLibraries">\r
+ <implementation\r
+ class="org.simantics.sysdyn.ui.browser.contributions.FunctionLibraryLabeler"\r
+ preference="2.0">\r
+ </implementation>\r
+ </binding>\r
+ <binding\r
+ browseContext="http://www.simantics.org/Sysdyn-1.0/SelectedSharedFunctionLibraries">\r
+ <implementation\r
+ class="org.simantics.sysdyn.ui.browser.contributions.FunctionLibraryLabeler"\r
+ preference="2.0">\r
+ </implementation>\r
+ </binding>\r
+ </extension>\r
+ <extension\r
+ point="org.simantics.browsing.ui.common.imagerBinding">\r
+ <binding\r
+ browseContext="http://www.simantics.org/Sysdyn-1.0/Browser">\r
+ <implementation\r
+ class="org.simantics.sysdyn.ui.browser.contributions.AbstractNodeImager"\r
+ preference="2.0">\r
+ </implementation>\r
+ <implementation\r
+ class="org.simantics.sysdyn.ui.browser.contributions.SimulationResultImager"\r
+ preference="2.0">\r
+ </implementation>\r
+ </binding>\r
+ <binding browseContext="http://www.simantics.org/Sysdyn-1.0/SysdynOperationBrowser">\r
+<!-- <implementation class="org.simantics.sysdyn.ui.property.LibraryVariableImager" preference="2.0"/> -->\r
+ <implementation class="org.simantics.sysdyn.ui.property.OperationVariableImager" preference="1.0"/>\r
+ </binding>\r
+ <binding\r
+ browseContext="http://www.simantics.org/Sysdyn-1.0/ExternalFiles">\r
+ <implementation\r
+ class="org.simantics.sysdyn.ui.properties.widgets.externalFiles.ExternalFileImager"\r
+ preference="2.0">\r
+ </implementation>\r
+ </binding>\r
+ <binding\r
+ browseContext="http://www.simantics.org/Sysdyn-1.0/AvailableSharedFunctionLibraries">\r
+ <implementation\r
+ class="org.simantics.sysdyn.ui.browser.contributions.AbstractNodeImager"\r
+ preference="2.0">\r
+ </implementation>\r
+ </binding>\r
+ <binding\r
+ browseContext="http://www.simantics.org/Sysdyn-1.0/SelectedSharedFunctionLibraries">\r
+ <implementation\r
+ class="org.simantics.sysdyn.ui.browser.contributions.AbstractNodeImager"\r
+ preference="2.0">\r
+ </implementation>\r
+ </binding>\r
+ </extension>\r
+ <extension\r
+ point="org.simantics.browsing.ui.common.labelDecoratorBinding">\r
+ <binding\r
+ browseContext="http://www.simantics.org/Sysdyn-1.0/Browser">\r
+ <implementation\r
+ class="org.simantics.sysdyn.ui.browser.contributions.SimulationResultDecorator"\r
+ preference="2.0">\r
+ </implementation>\r
+ <implementation\r
+ class="org.simantics.sysdyn.ui.browser.contributions.ExperimentLabelDecorator"\r
+ preference="2.0">\r
+ </implementation>\r
+ </binding>\r
+ </extension>\r
+ <extension\r
+ point="org.eclipse.core.expressions.propertyTesters">\r
+ <propertyTester\r
+ class="org.simantics.browsing.ui.swt.NodePropertyTester"\r
+ id="org.simantics.browsing.ui.nodePropertyTester"\r
+ namespace="org.simantics.sysdyn.ui"\r
+ properties="nodeClass"\r
+ type="org.eclipse.jface.viewers.IStructuredSelection">\r
+ </propertyTester>\r
+ </extension>\r
+ <extension\r
+ point="org.eclipse.ui.cheatsheets.cheatSheetContent">\r
+ <category\r
+ id="org.simantics.sysdyn.ui.category"\r
+ name="System Dynamics">\r
+ </category>\r
+ <cheatsheet\r
+ category="org.simantics.sysdyn.ui.category"\r
+ composite="false"\r
+ contentFile="$nl$/cheatsheet/tutorial.xml"\r
+ id="org.simantics.sysdyn.ui.cheatsheet1"\r
+ name="Simple System Dynamics Tutorial">\r
+ <description>\r
+ Simple System Dynamics Tutorials\r
+ </description>\r
+ </cheatsheet>\r
+ </extension>\r
+ <extension\r
+ point="org.simantics.ui.doubleClick">\r
+ <doubleClickAction\r
+ class="org.simantics.sysdyn.ui.actions.ActivateExperimentAction"\r
+ name="Activate Sysdyn Experiment"\r
+ priority="300.0">\r
+ </doubleClickAction>\r
+ <doubleClickAction\r
+ class="org.simantics.sysdyn.ui.actions.ConsumeUnnecessaryEntersAction"\r
+ name="Consume unnecessary enters"\r
+ priority="200.0">\r
+ </doubleClickAction>\r
+ <doubleClickAction\r
+ class="org.simantics.sysdyn.ui.actions.ShowInstantiatedModuleAction"\r
+ name="Consume unnecessary enters"\r
+ priority="100.0">\r
+ </doubleClickAction>\r
+ </extension>\r
+ <extension\r
+ point="org.simantics.browsing.ui.common.selectionProcessorBinding">\r
+ <binding\r
+ browseContext="http://www.simantics.org/Sysdyn-1.0/Browser">\r
+ <implementation\r
+ class="org.simantics.sysdyn.ui.properties.ResourceSelectionProcessor">\r
+ </implementation>\r
+ </binding>\r
+ </extension>\r
+ <extension\r
+ id="product"\r
+ point="org.eclipse.core.runtime.products">\r
+ <product\r
+ application="org.simantics.workbench.application"\r
+ description="Simantics System Dynamic Modelling Environment"\r
+ name="Simantics System Dynamic Tool">\r
+ <property\r
+ name="appName"\r
+ value="Simantics System Dynamic Tool"/>\r
+ <property\r
+ name="preferenceCustomization"\r
+ value="plugin_customization.ini"/>\r
+ </product>\r
+ </extension>\r
+ <extension\r
+ point="org.simantics.project.feature">\r
+ <feature\r
+ class="org.simantics.sysdyn.ui.project.SysdynProject"\r
+ description="System dynamics modelling project. Create system dynamics models and simulate them with OpenModelica."\r
+ id="org.simantics.sysdyn.project"\r
+ label="System Dynamics Project"\r
+ published="true">\r
+ <requires id="org.simantics.sysdyn.dependencies"/>\r
+ <requires id="org.simantics.simulation.experimentManager"/>\r
+ <installGroup id="org.simantics.sysdyn.feature.group" version="[1.0.0,2.0.0)"/>\r
+ </feature>\r
+ <feature\r
+ class="org.simantics.project.features.DependencyValidationFeature:http://www.simantics.org/Sysdyn-1.0/ImportedOntologies"\r
+ id="org.simantics.sysdyn.dependencies"\r
+ label="System Dynamics ontology dependencies">\r
+ </feature>\r
+ </extension>\r
+ <extension\r
+ point="org.simantics.browsing.ui.common.checkedStateBinding">\r
+ <binding\r
+ browseContext="http://www.simantics.org/Sysdyn-1.0/EnumerationIndexes">\r
+ <implementation\r
+ class="org.simantics.sysdyn.ui.properties.widgets.arrays.ShowInChartsCheckBox"\r
+ preference="2.0">\r
+ </implementation>\r
+ </binding>\r
+ </extension>\r
+</plugin>\r
--- /dev/null
+org.eclipse.ui/SHOW_PROGRESS_ON_STARTUP = false\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2010 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.ui;\r
+\r
+import java.net.URL;\r
+\r
+import org.apache.log4j.BasicConfigurator;\r
+import org.apache.log4j.ConsoleAppender;\r
+import org.apache.log4j.Level;\r
+import org.apache.log4j.Logger;\r
+import org.apache.log4j.SimpleLayout;\r
+import org.eclipse.jface.resource.JFaceResources;\r
+import org.eclipse.jface.resource.LocalResourceManager;\r
+import org.eclipse.jface.resource.ResourceManager;\r
+import org.eclipse.swt.widgets.Display;\r
+import org.eclipse.ui.plugin.AbstractUIPlugin;\r
+import org.osgi.framework.BundleContext;\r
+\r
+public class Activator extends AbstractUIPlugin {\r
+\r
+ // The plug-in ID\r
+ public static final String PLUGIN_ID = "org.simantics.sysdyn.ui";\r
+ \r
+ // The shared instance\r
+ private static Activator plugin;\r
+ \r
+ private static LocalResourceManager resourceManager;\r
+\r
+ @Override\r
+ public void start(BundleContext context) throws Exception {\r
+ super.start(context);\r
+ ConsoleAppender appender =\r
+ new ConsoleAppender(new SimpleLayout());\r
+ BasicConfigurator.configure(appender);\r
+ Logger.getRootLogger().setLevel(Level.WARN);\r
+ plugin = this;\r
+ }\r
+ \r
+ @Override\r
+ public void stop(BundleContext context) throws Exception {\r
+ plugin = null;\r
+ super.stop(context);\r
+ }\r
+\r
+ public static Activator getDefault() {\r
+ return plugin;\r
+ }\r
+ \r
+ public static ResourceManager initializeResourceManager(Display display) {\r
+ if (resourceManager == null) {\r
+ resourceManager = new LocalResourceManager(JFaceResources.getResources(display));\r
+ }\r
+ return resourceManager;\r
+ }\r
+\r
+ public static ResourceManager getResources() {\r
+ if (resourceManager == null)\r
+ throw new IllegalStateException("ResourceManager of bundle '" + PLUGIN_ID + "' is not initialized.");\r
+ return resourceManager;\r
+ }\r
+ \r
+ public static URL getDefaultResource(String name) {\r
+ Activator plugin = getDefault();\r
+ if(plugin == null) throw new IllegalStateException("The plugin is not active.");\r
+ return plugin.getBundle().getResource(name);\r
+ }\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2010 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.ui.actions;\r
+\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.project.IProject;\r
+import org.simantics.simulation.ontology.SimulationResource;\r
+import org.simantics.simulation.project.IExperimentManager;\r
+import org.simantics.sysdyn.ui.handlers.SysdynExperimentActivator;\r
+import org.simantics.ui.DoubleClickEvent;\r
+import org.simantics.ui.IDoubleClickAction;\r
+import org.simantics.ui.SimanticsUI;\r
+import org.simantics.ui.utils.ResourceAdaptionUtils;\r
+import org.simantics.utils.ui.ErrorLogger;\r
+import org.simantics.utils.ui.action.PriorityAction;\r
+\r
+public class ActivateExperimentAction implements IDoubleClickAction {\r
+\r
+ @Override\r
+ public void doubleClickEvent(DoubleClickEvent e) throws DatabaseException {\r
+ ReadGraph g = e.getGraph();\r
+ final Resource experiment = ResourceAdaptionUtils.toSingleResource(e.getResource());\r
+ if (experiment == null)\r
+ return;\r
+\r
+ if (g.isInstanceOf(experiment, SimulationResource.getInstance(g).Experiment)) {\r
+ final IProject project = SimanticsUI.getProject();\r
+ if (project == null)\r
+ return;\r
+\r
+ final IExperimentManager experimentManager = project.getHint(IExperimentManager.KEY_EXPERIMENT_MANAGER);\r
+ if (experimentManager == null) {\r
+ ErrorLogger.defaultLogWarning("Experiment manager not available.", new Exception());\r
+ return;\r
+ }\r
+\r
+ e.add(new PriorityAction(PriorityAction.HIGH+20) {\r
+ @Override\r
+ public void run() {\r
+ SysdynExperimentActivator.scheduleActivation(SimanticsUI.getSession(), project, experimentManager, experiment);\r
+ }\r
+ });\r
+ e.consume();\r
+ }\r
+ \r
+ }\r
+\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2010 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.ui.actions;\r
+\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.layer0.Layer0;\r
+import org.simantics.sysdyn.SysdynResource;\r
+import org.simantics.ui.DoubleClickEvent;\r
+import org.simantics.ui.IDoubleClickAction;\r
+import org.simantics.ui.utils.ResourceAdaptionUtils;\r
+import org.simantics.utils.ui.action.PriorityAction;\r
+\r
+public class ConsumeUnnecessaryEntersAction implements IDoubleClickAction {\r
+\r
+ @Override\r
+ public void doubleClickEvent(DoubleClickEvent e) throws DatabaseException {\r
+ ReadGraph g = e.getGraph();\r
+ Layer0 l0 = Layer0.getInstance(g);\r
+ final Resource resource = ResourceAdaptionUtils.toSingleResource(e.getResource());\r
+ if(resource == null)\r
+ return;\r
+ SysdynResource sr = SysdynResource.getInstance(g);\r
+ \r
+ if(g.isInstanceOf(resource, sr.SysdynModel) || g.isInstanceOf(resource, sr.Variable)) {\r
+ consume(e);\r
+ } else if(g.hasStatement(resource, l0.Represents)){\r
+ Resource represents = g.getSingleObject(resource, l0.Represents); \r
+ if (g.isInstanceOf(represents, sr.Variable)) {\r
+ consume(e);\r
+ }\r
+ }\r
+ }\r
+ \r
+ private void consume(DoubleClickEvent e) {\r
+ e.add(new PriorityAction(PriorityAction.HIGH) {\r
+ @Override\r
+ public void run() {\r
+ \r
+ }\r
+ });\r
+ e.consume();\r
+ }\r
+\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2010 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.ui.actions;\r
+\r
+import java.util.Set;\r
+\r
+import org.eclipse.jface.viewers.IStructuredSelection;\r
+import org.eclipse.ui.PartInitException;\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.db.layer0.variable.Variable;\r
+import org.simantics.db.layer0.variable.Variables;\r
+import org.simantics.layer0.Layer0;\r
+import org.simantics.modeling.ModelingResources;\r
+import org.simantics.structural.stubs.StructuralResource2;\r
+import org.simantics.sysdyn.SysdynResource;\r
+import org.simantics.sysdyn.ui.browser.BrowserSelection;\r
+import org.simantics.sysdyn.ui.browser.nodes.ModuleNode;\r
+import org.simantics.ui.DoubleClickEvent;\r
+import org.simantics.ui.IDoubleClickAction;\r
+import org.simantics.ui.workbench.ResourceEditorInput2;\r
+import org.simantics.utils.ui.ISelectionUtils;\r
+import org.simantics.utils.ui.action.PriorityAction;\r
+import org.simantics.utils.ui.workbench.WorkbenchUtils;\r
+\r
+public class ShowInstantiatedModuleAction implements IDoubleClickAction {\r
+\r
+ private static final String EDITOR_ID = "org.simantics.sysdyn.ui.diagramViewer";\r
+ \r
+ @Override\r
+ public void doubleClickEvent(DoubleClickEvent e) throws DatabaseException {\r
+ \r
+ ReadGraph g = e.getGraph();\r
+ \r
+ if(e.getResource() instanceof IStructuredSelection) {\r
+ Set<BrowserSelection> bss = ISelectionUtils.filterSetSelection(e.getResource(), BrowserSelection.class);\r
+ \r
+ if(!bss.isEmpty()) {\r
+ Layer0 l0 = Layer0.getInstance(g);\r
+ for(BrowserSelection bs : bss) {\r
+ Resource configuration = (Resource)bs.getAdapter(Resource.class);\r
+ Resource instanceOf = g.getSingleObject(configuration, l0.InstanceOf);\r
+ \r
+ SysdynResource sr = SysdynResource.getInstance(g);\r
+ StructuralResource2 sr2 = StructuralResource2.getInstance(g);\r
+ if(g.isInheritedFrom(instanceOf, sr.Module)) {\r
+ configuration = g.getSingleObject(instanceOf, sr2.IsDefinedBy);\r
+ Variable variable = (Variable) bs.getAdapter(Variable.class);\r
+ String rvi = Variables.getRVI(g, variable).substring(1);\r
+ Resource model = Variables.getModel(g, variable);\r
+ addShowModuleAction(e, getResourceEditorInput(g, model, configuration, rvi));\r
+ } \r
+ }\r
+ } else {\r
+ ModuleNode moduleNode = ISelectionUtils.filterSingleSelection(e.getResource(), ModuleNode.class);\r
+ if(moduleNode != null) {\r
+ Layer0 l0 = Layer0.getInstance(g);\r
+ StructuralResource2 sr2 = StructuralResource2.getInstance(g);\r
+ Resource model;\r
+ String rvi;\r
+ if(moduleNode.getVariable() != null) {\r
+ model = Variables.getModel(g, moduleNode.getVariable());\r
+ Variable var = moduleNode.getVariable();\r
+ rvi = Variables.getRVI(g, var).substring(1);\r
+ } else {\r
+ rvi = (String)g.getRelatedValue(moduleNode.data, Layer0.getInstance(g).HasName);\r
+ model = g.getSingleObject(moduleNode.data, l0.PartOf);\r
+ }\r
+ \r
+ Resource instanceOf = g.getSingleObject(moduleNode.data, l0.InstanceOf);\r
+ Resource conf = g.getSingleObject(instanceOf, sr2.IsDefinedBy);\r
+ \r
+ addShowModuleAction(e, getResourceEditorInput(g, model, conf, rvi));\r
+ }\r
+ }\r
+ } \r
+ }\r
+ \r
+ private ResourceEditorInput2 getResourceEditorInput(ReadGraph g, Resource model, Resource configuration, String rvi) throws DatabaseException {\r
+ Layer0 l0 = Layer0.getInstance(g);\r
+ SysdynResource sr = SysdynResource.getInstance(g);\r
+ \r
+ String modelURI;\r
+ if(model != null) {\r
+ modelURI = g.getURI(model);\r
+ } else {\r
+ Resource parent = configuration;\r
+ do {\r
+ parent = g.getPossibleObject(parent, l0.PartOf);\r
+ } while (parent != null && !g.isInstanceOf(parent, sr.SysdynModel));\r
+ modelURI = g.getURI(parent);\r
+ rvi = null;\r
+ }\r
+ \r
+ Resource diagram = g.getSingleObject(configuration, ModelingResources.getInstance(g).CompositeToDiagram);\r
+ return new ResourceEditorInput2(EDITOR_ID, diagram, modelURI, rvi == null ? "" : "/" + rvi);\r
+ }\r
+ \r
+ private void addShowModuleAction(DoubleClickEvent e, final ResourceEditorInput2 editorInput) {\r
+ e.add(new PriorityAction(PriorityAction.HIGH) {\r
+ @Override\r
+ public void run() {\r
+ try {\r
+ WorkbenchUtils.openEditor(EDITOR_ID, editorInput);\r
+ } catch (PartInitException e) {\r
+ e.printStackTrace();\r
+ }\r
+ }\r
+ });\r
+ e.consume();\r
+ }\r
+\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2010 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.ui.browser;\r
+\r
+import org.eclipse.core.runtime.IAdaptable;\r
+import org.eclipse.jface.viewers.ISelection;\r
+import org.simantics.browsing.ui.NodeContext;\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.layer0.variable.Variable;\r
+import org.simantics.sysdyn.ui.browser.nodes.VariableNode;\r
+\r
+public class BrowserSelection implements IAdaptable, ISelection {\r
+ private Resource resource;\r
+ private Object originalInput;\r
+ private Variable variable;\r
+\r
+ public BrowserSelection(Object originalInput, VariableNode<Variable> vn) {\r
+ this.originalInput = originalInput;\r
+ this.resource = vn.data;\r
+ Variable variable = vn.getVariable();\r
+ if(variable != null) {\r
+ this.variable = variable;\r
+ }\r
+ }\r
+\r
+ @SuppressWarnings("rawtypes")\r
+ @Override\r
+ public Object getAdapter(Class adapter) {\r
+ if (adapter == Resource.class)\r
+ return resource;\r
+ if (adapter == Variable.class)\r
+ return variable;\r
+ if (NodeContext.class.equals(adapter))\r
+ return originalInput;\r
+ if (originalInput instanceof IAdaptable) {\r
+ IAdaptable input = (IAdaptable)originalInput;\r
+ return input.getAdapter(adapter);\r
+ }\r
+ return null;\r
+ }\r
+\r
+ @Override\r
+ public boolean isEmpty() {\r
+ if(originalInput == null)\r
+ return true;\r
+ return false;\r
+ }\r
+ \r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2010 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.ui.browser;\r
+\r
+import java.util.Arrays;\r
+import java.util.Collections;\r
+import java.util.HashSet;\r
+import java.util.Set;\r
+\r
+import org.eclipse.swt.widgets.Composite;\r
+import org.simantics.browsing.ui.GraphExplorer;\r
+import org.simantics.browsing.ui.NodeContext;\r
+import org.simantics.browsing.ui.swt.AdaptableHintContext;\r
+import org.simantics.browsing.ui.swt.ContextMenuInitializer;\r
+import org.simantics.browsing.ui.swt.DefaultSelectionDataResolver;\r
+import org.simantics.browsing.ui.swt.GraphExplorerFactory;\r
+import org.simantics.browsing.ui.swt.GraphExplorerView;\r
+import org.simantics.browsing.ui.swt.IContextMenuInitializer;\r
+import org.simantics.browsing.ui.swt.IPropertyPage;\r
+import org.simantics.db.layer0.SelectionHints;\r
+import org.simantics.db.layer0.variable.Variable;\r
+import org.simantics.sysdyn.ui.Activator;\r
+import org.simantics.sysdyn.ui.browser.nodes.VariableNode;\r
+import org.simantics.sysdyn.ui.properties.SysdynPropertyPage;\r
+import org.simantics.utils.datastructures.BinaryFunction;\r
+import org.simantics.utils.datastructures.hints.IHintContext;\r
+\r
+\r
+public class SysdynBrowser extends GraphExplorerView {\r
+ \r
+// private static final Set<String> browseContexts = Collections.singleton("http://www.simantics.org/Sysdyn-1.0/Browser");\r
+ private static final Set<String> browseContexts = new HashSet<String>(Arrays.asList("http://www.simantics.org/Sysdyn-1.0/Browser", "http://www.simantics.org/Operating-1.0/Browser", "http://www.simantics.org/Image-1.0/Browser")); \r
+\r
+ private BinaryFunction<Object[], GraphExplorer, Object[]> selectionTransformation = new BinaryFunction<Object[], GraphExplorer, Object[]>() {\r
+\r
+ @Override\r
+ public Object[] call(GraphExplorer explorer, Object[] objects) {\r
+ Object[] result = new Object[objects.length];\r
+ for (int i = 0; i < objects.length; i++) {\r
+ \r
+ NodeContext ctx = (NodeContext)objects[i]; \r
+ @SuppressWarnings("unchecked")\r
+ VariableNode<Variable> vn = (VariableNode<Variable>) ctx.getAdapter(VariableNode.class);\r
+ IHintContext context;\r
+ if(vn != null && vn.getVariable() != null) {\r
+ context = new AdaptableHintContext(SelectionHints.KEY_MAIN, SelectionHints.KEY_SELECTION_PROPERTY);\r
+ context.setHint(SelectionHints.KEY_MAIN, new BrowserSelection(objects[i], vn));\r
+ context.setHint(SelectionHints.KEY_SELECTION_PROPERTY, vn.getVariable());\r
+ } else {\r
+ context = new AdaptableHintContext(SelectionHints.KEY_MAIN);\r
+ context.setHint(SelectionHints.KEY_MAIN, objects[i]);\r
+ }\r
+ result[i] = context;\r
+ }\r
+ return result;\r
+ }\r
+ \r
+ };\r
+ \r
+ protected GraphExplorer createExplorerControl(Composite parent) {\r
+ return GraphExplorerFactory.getInstance()\r
+ .selectionDataResolver(new DefaultSelectionDataResolver())\r
+ .selectionTransformation(selectionTransformation)\r
+ .create(parent, getStyle());\r
+ }\r
+ \r
+ @Override\r
+ protected IContextMenuInitializer getContextMenuInitializer() {\r
+ return new ContextMenuInitializer("#SysdynBrowserPopup");\r
+ }\r
+ \r
+ @Override\r
+ protected Set<String> getBrowseContexts() {\r
+ return browseContexts;\r
+ }\r
+ \r
+ @Override\r
+ protected void createControls(Composite parent) {\r
+ // Make sure the resource manager of this plug-in is initialized\r
+ // properly before using it in this browser.\r
+ Activator.initializeResourceManager(parent.getDisplay());\r
+\r
+ super.createControls(parent);\r
+ //IToolBarManager toolBar = getViewSite().getActionBars().getToolBarManager();\r
+ //toolBar.add(new HomeAction());\r
+ }\r
+ \r
+ @SuppressWarnings("rawtypes")\r
+ @Override\r
+ public Object getAdapter(Class adapter) {\r
+ if (adapter == IPropertyPage.class)\r
+ return new SysdynPropertyPage(getSite(), Collections.singleton("http://www.simantics.org/Sysdyn-1.0/Browser"));\r
+ return super.getAdapter(adapter);\r
+ }\r
+}\r
--- /dev/null
+package org.simantics.sysdyn.ui.browser;\r
+\r
+import java.util.Arrays;\r
+import java.util.Collections;\r
+import java.util.HashSet;\r
+import java.util.Set;\r
+\r
+import org.simantics.browsing.ui.swt.IPropertyPage;\r
+import org.simantics.structural.ui.modelBrowser.ModelBrowser;\r
+import org.simantics.sysdyn.ui.properties.SysdynPropertyPage;\r
+\r
+public class SysdynModelBrowser extends ModelBrowser {\r
+\r
+ final private Set<String> browseContexts = new HashSet<String>(Arrays.asList("http://www.simantics.org/Sysdyn-1.0/ModelBrowser", "http://www.simantics.org/Operating-1.0/Browser", "http://www.simantics.org/Image-1.0/Browser"));\r
+\r
+ @Override\r
+ protected IPropertyPage getPropertyPage() {\r
+ return new SysdynPropertyPage(getSite(), Collections.singleton("http://www.simantics.org/Sysdyn-1.0/ModelBrowser"));\r
+ }\r
+\r
+ @Override\r
+ protected Set<String> getBrowseContexts() {\r
+ return browseContexts;\r
+ }\r
+\r
+\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2010 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.ui.browser;\r
+\r
+import java.util.Collections;\r
+import java.util.Set;\r
+\r
+import org.simantics.browsing.ui.swt.GraphExplorerView;\r
+\r
+public class SysdynOperationBrowser extends GraphExplorerView {\r
+\r
+ final private Set<String> browseContexts = Collections.singleton("http://www.simantics.org/Sysdyn-1.0/SysdynOperationBrowser");\r
+\r
+ @Override\r
+ protected Set<String> getBrowseContexts() {\r
+ return browseContexts;\r
+ }\r
+\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2010 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.ui.browser.contributions;\r
+\r
+import org.eclipse.jface.resource.ImageDescriptor;\r
+import org.simantics.browsing.ui.common.node.AbstractNode;\r
+import org.simantics.browsing.ui.swt.ImagerContributor;\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.sysdyn.ui.Activator;\r
+import org.simantics.sysdyn.ui.browser.nodes.ConfigurationNode;\r
+import org.simantics.sysdyn.ui.browser.nodes.ExperimentNode;\r
+import org.simantics.sysdyn.ui.browser.nodes.ExperimentsFolder;\r
+import org.simantics.sysdyn.ui.browser.nodes.FunctionLibraryNode;\r
+import org.simantics.sysdyn.ui.browser.nodes.FunctionsFolder;\r
+import org.simantics.sysdyn.ui.browser.nodes.InputNode;\r
+import org.simantics.sysdyn.ui.browser.nodes.ModelNode;\r
+import org.simantics.sysdyn.ui.browser.nodes.ModuleNode;\r
+import org.simantics.sysdyn.ui.browser.nodes.ModuleTypeNode;\r
+import org.simantics.sysdyn.ui.browser.nodes.ModulesNode;\r
+import org.simantics.sysdyn.ui.browser.nodes.SharedFunctionLibraryNode;\r
+import org.simantics.sysdyn.ui.browser.nodes.SharedFunctionsFolder;\r
+import org.simantics.sysdyn.ui.browser.nodes.VariableNode;\r
+\r
+public class AbstractNodeImager extends ImagerContributor<AbstractNode<Resource>> {\r
+\r
+ @Override\r
+ public ImageDescriptor getDescriptor(ReadGraph graph, AbstractNode<Resource> node) throws DatabaseException {\r
+ \r
+ String image = null;\r
+ if (node instanceof SharedFunctionsFolder)\r
+ image = "icons/folder_link.png";\r
+ else if (node instanceof ExperimentsFolder || \r
+ node instanceof ModulesNode || \r
+ node instanceof FunctionsFolder ||\r
+ node instanceof FunctionLibraryNode ||\r
+ node instanceof SharedFunctionLibraryNode)\r
+ image = "icons/folder.png";\r
+ else if (node instanceof ModuleTypeNode || node instanceof ModuleNode || node instanceof ConfigurationNode)\r
+ image = "icons/bricks.png";\r
+ else if (node instanceof ExperimentNode)\r
+ image = "icons/time.png";\r
+ else if (node instanceof InputNode)\r
+ image = "icons/brick_link.png";\r
+ else if (node instanceof ModelNode)\r
+ image = "icons/chart_organisation.png";\r
+ else if (node instanceof VariableNode)\r
+ image = "icons/brick.png";\r
+ \r
+ if (image != null)\r
+ return ImageDescriptor.createFromURL(Activator.getDefault().getBundle().getResource(image));\r
+ return null;\r
+ }\r
+\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2010 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.ui.browser.contributions;\r
+\r
+import org.simantics.browsing.ui.common.node.AbstractNode;\r
+import org.simantics.browsing.ui.graph.contributor.labeler.LabelerContributor;\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.exception.DatabaseException;\r
+\r
+public class AbstractNodeLabeler extends LabelerContributor<AbstractNode<Resource>> {\r
+\r
+ @Override\r
+ public String getLabel(ReadGraph graph, AbstractNode<Resource> node) throws DatabaseException {\r
+ if (!graph.hasStatement(node.data))\r
+ return "";\r
+ return graph.adapt(node.data, String.class);\r
+ }\r
+\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2010 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.ui.browser.contributions;\r
+\r
+import java.util.ArrayList;\r
+import java.util.Collection;\r
+\r
+import org.simantics.browsing.ui.common.node.AbstractNode;\r
+import org.simantics.browsing.ui.graph.contributor.viewpoint.ViewpointContributor;\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.db.layer0.variable.Variable;\r
+import org.simantics.db.layer0.variable.Variables;\r
+import org.simantics.sysdyn.SysdynResource;\r
+import org.simantics.sysdyn.ui.browser.nodes.ConfigurationNode;\r
+import org.simantics.sysdyn.ui.browser.nodes.EnumerationNode;\r
+import org.simantics.sysdyn.ui.browser.nodes.InputNode;\r
+import org.simantics.sysdyn.ui.browser.nodes.ModuleNode;\r
+import org.simantics.sysdyn.ui.browser.nodes.VariableNode;\r
+\r
+public class Configuration extends ViewpointContributor<ConfigurationNode<Resource>> {\r
+\r
+ @Override\r
+ public Collection<?> getContribution(ReadGraph graph, ConfigurationNode<Resource> configuration) throws DatabaseException {\r
+ ArrayList<AbstractNode<Resource>> result = new ArrayList<AbstractNode<Resource>>();\r
+ Variable variable = configuration.getVariable();\r
+ \r
+ if (variable == null) {\r
+ return result;\r
+ }\r
+ \r
+ SysdynResource sr = SysdynResource.getInstance(graph);\r
+ ArrayList<Variable> variables = new ArrayList<Variable>();\r
+ ArrayList<Variable> inputs = new ArrayList<Variable>();\r
+ ArrayList<Variable> modules = new ArrayList<Variable>();\r
+ ArrayList<Variable> enumerations = new ArrayList<Variable>();\r
+\r
+ for(Variable child : variable.browseChildren(graph)) {\r
+ Resource represents = (Resource)child.getPropertyValue(graph, Variables.REPRESENTS);\r
+ if(graph.isInstanceOf(represents, sr.IndependentVariable)) {\r
+ variables.add(child);\r
+ } else if (graph.isInstanceOf(represents, sr.Input)) {\r
+ inputs.add(child);\r
+ } else if (graph.isInstanceOf(represents, sr.Module)) {\r
+ modules.add(child);\r
+ } else if (graph.isInstanceOf(represents, sr.Enumeration)) {\r
+ enumerations.add(child);\r
+ }\r
+ }\r
+ \r
+ for (Variable v : variables) {\r
+ Resource represents = (Resource)v.getPropertyValue(graph, Variables.REPRESENTS);\r
+ result.add(new VariableNode<Variable>(v, represents));\r
+ }\r
+ for (Variable v : inputs) {\r
+ Resource represents = (Resource)v.getPropertyValue(graph, Variables.REPRESENTS);\r
+ result.add(new InputNode(v, represents));\r
+ }\r
+ for (Variable v : modules) { \r
+ Resource represents = (Resource)v.getPropertyValue(graph, Variables.REPRESENTS);\r
+ result.add(new ModuleNode(v, represents));\r
+ }\r
+ for (Variable v : enumerations) {\r
+ Resource represents = (Resource)v.getPropertyValue(graph, Variables.REPRESENTS);\r
+ result.add(new EnumerationNode(v, represents));\r
+ }\r
+ return result;\r
+ }\r
+\r
+ @Override\r
+ public String getViewpointId() {\r
+ return "Standard";\r
+ }\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2010 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.ui.browser.contributions;\r
+\r
+import org.simantics.browsing.ui.graph.contributor.labeler.LabelerContributor;\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.sysdyn.ui.browser.nodes.ConfigurationNode;\r
+\r
+public class ConfigurationLabeler extends LabelerContributor<ConfigurationNode<Resource>>{\r
+\r
+ @Override\r
+ public String getLabel(ReadGraph graph, ConfigurationNode<Resource> conf) throws DatabaseException {\r
+ return "Configuration";\r
+ }\r
+\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2010 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.ui.browser.contributions;\r
+\r
+import java.util.ArrayList;\r
+import java.util.Collection;\r
+\r
+import org.simantics.browsing.ui.common.node.AbstractNode;\r
+import org.simantics.browsing.ui.graph.contributor.viewpoint.ViewpointContributor;\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.common.request.ObjectsWithType;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.layer0.Layer0;\r
+import org.simantics.simulation.ontology.SimulationResource;\r
+import org.simantics.sysdyn.ui.browser.nodes.ExperimentsFolder;\r
+\r
+public class Experiment extends ViewpointContributor<ExperimentsFolder> {\r
+\r
+ @SuppressWarnings("unchecked")\r
+ @Override\r
+ public Collection<?> getContribution(ReadGraph graph, ExperimentsFolder experimentsFolder) throws DatabaseException {\r
+ ArrayList<AbstractNode<Resource>> result = new ArrayList<AbstractNode<Resource>>();\r
+ Layer0 l0 = Layer0.getInstance(graph);\r
+ for(Resource r : graph.syncRequest(new ObjectsWithType(experimentsFolder.data, l0.ConsistsOf, SimulationResource.getInstance(graph).Experiment))) {\r
+ try {\r
+ result.add(graph.adapt(r, AbstractNode.class));\r
+ } catch(DatabaseException e) {\r
+ e.printStackTrace();\r
+ }\r
+ }\r
+ return result;\r
+ }\r
+\r
+ @Override\r
+ public String getViewpointId() {\r
+ return "Standard";\r
+ }\r
+\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2010 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.ui.browser.contributions;\r
+\r
+import org.eclipse.jface.resource.FontDescriptor;\r
+import org.eclipse.swt.SWT;\r
+import org.simantics.browsing.ui.content.LabelDecorator;\r
+import org.simantics.browsing.ui.graph.contributor.labeler.LabelDecoratorContributor;\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.simulation.ontology.SimulationResource;\r
+import org.simantics.sysdyn.ui.browser.nodes.ExperimentNode;\r
+\r
+public class ExperimentLabelDecorator extends LabelDecoratorContributor<ExperimentNode> {\r
+\r
+ @Override\r
+ public LabelDecorator getDecorator(ReadGraph graph, ExperimentNode experimentNode) throws DatabaseException {\r
+ if (graph.hasStatement(experimentNode.data, SimulationResource.getInstance(graph).IsActive)) {\r
+ return new LabelDecorator.Stub() {\r
+ @Override\r
+ public String decorateLabel(String label, String column, int itemIndex) {\r
+ return label + " [ACTIVE]";\r
+ }\r
+\r
+ @SuppressWarnings("unchecked")\r
+ @Override\r
+ public <F> F decorateFont(F font, String column, int itemIndex) {\r
+ return (F) ((FontDescriptor) font).withStyle(SWT.BOLD);\r
+ }\r
+ };\r
+ }\r
+ return null;\r
+ }\r
+\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2010 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+\r
+package org.simantics.sysdyn.ui.browser.contributions;\r
+\r
+import org.simantics.browsing.ui.graph.contributor.labeler.LabelerContributor;\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.layer0.Layer0;\r
+import org.simantics.sysdyn.ui.browser.nodes.ExperimentNode;\r
+\r
+public class ExperimentLabeler extends LabelerContributor<ExperimentNode>{\r
+\r
+ @Override\r
+ public String getLabel(ReadGraph graph, ExperimentNode experiment) throws DatabaseException {\r
+ String name = graph.getPossibleRelatedValue(experiment.data, Layer0.getInstance(graph).HasLabel);\r
+ return name == null ? "Experiment (no name)" : name;\r
+ }\r
+\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2010 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+\r
+package org.simantics.sysdyn.ui.browser.contributions;\r
+\r
+import org.simantics.browsing.ui.graph.contributor.labeler.LabelerContributor;\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.sysdyn.ui.browser.nodes.ExperimentsFolder;\r
+\r
+public class ExperimentsLabeler extends LabelerContributor<ExperimentsFolder> {\r
+\r
+ @Override\r
+ public String getLabel(ReadGraph graph, ExperimentsFolder experiments) throws DatabaseException {\r
+ return "Experiments";\r
+ }\r
+\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2011 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.ui.browser.contributions;\r
+\r
+import java.util.ArrayList;\r
+import java.util.Collection;\r
+\r
+import org.simantics.browsing.ui.common.node.AbstractNode;\r
+import org.simantics.browsing.ui.graph.contributor.viewpoint.ViewpointContributor;\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.common.request.ObjectsWithType;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.layer0.Layer0;\r
+import org.simantics.sysdyn.SysdynResource;\r
+import org.simantics.sysdyn.ui.browser.nodes.FunctionLibraryNode;\r
+import org.simantics.sysdyn.ui.browser.nodes.FunctionNode;\r
+import org.simantics.sysdyn.ui.browser.nodes.FunctionsFolder;\r
+import org.simantics.sysdyn.ui.browser.nodes.SharedFunctionsFolder;\r
+\r
+public class FunctionLibraries extends ViewpointContributor<FunctionsFolder> {\r
+\r
+ @Override\r
+ public Collection<?> getContribution(ReadGraph graph, FunctionsFolder functionsFolder)\r
+ throws DatabaseException {\r
+\r
+ Layer0 l0 = Layer0.getInstance(graph);\r
+ SysdynResource sr = SysdynResource.getInstance(graph);\r
+ \r
+ ArrayList<AbstractNode<Resource>> result = new ArrayList<AbstractNode<Resource>>();\r
+ \r
+ // Find model functions\r
+ for(Resource function : graph.syncRequest(new ObjectsWithType(functionsFolder.data, l0.ConsistsOf, sr.SysdynModelicaFunction))) {\r
+ result.add(new FunctionNode(function));\r
+ }\r
+ \r
+ // Find model function libraries\r
+ for(Resource modelLibrary : graph.syncRequest(new ObjectsWithType(functionsFolder.data, l0.ConsistsOf, sr.SysdynModelicaFunctionLibrary))) {\r
+ new FunctionLibraryNode<Resource>(modelLibrary);\r
+ } \r
+ \r
+ Resource sysdyn = graph.getPossibleResource("http://www.simantics.org/Sysdyn-1.0");\r
+ if(sysdyn != null) {\r
+ for(Resource library : graph.syncRequest(new ObjectsWithType(sysdyn, l0.ConsistsOf, sr.SysdynModelicaFunctionLibrary))) {\r
+ result.add(new FunctionLibraryNode<Resource>(library));\r
+ }\r
+ }\r
+ \r
+ \r
+ result.add(new SharedFunctionsFolder(functionsFolder.data));\r
+ \r
+ return result;\r
+\r
+ }\r
+\r
+ @Override\r
+ public String getViewpointId() {\r
+ return "Standard";\r
+ }\r
+ \r
+\r
+}\r
--- /dev/null
+package org.simantics.sysdyn.ui.browser.contributions;\r
+\r
+import org.simantics.browsing.ui.graph.contributor.labeler.LabelerContributor;\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.common.utils.NameUtils;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.sysdyn.ui.browser.nodes.FunctionLibraryNode;\r
+\r
+public class FunctionLibraryLabeler extends LabelerContributor<FunctionLibraryNode<Resource>>{\r
+\r
+ @Override\r
+ public String getLabel(ReadGraph graph, FunctionLibraryNode<Resource> input)\r
+ throws DatabaseException {\r
+ String name = NameUtils.getSafeName(graph, input.data);\r
+ return name;\r
+ }\r
+\r
+\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2011 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.ui.browser.contributions;\r
+\r
+import org.simantics.browsing.ui.graph.contributor.labeler.LabelerContributor;\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.sysdyn.ui.browser.nodes.FunctionsFolder;\r
+\r
+public class FunctionsLabeler extends LabelerContributor<FunctionsFolder>{\r
+\r
+ @Override\r
+ public String getLabel(ReadGraph graph, FunctionsFolder input) throws DatabaseException {\r
+ return "Functions";\r
+ }\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2010 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.ui.browser.contributions;\r
+\r
+import org.simantics.browsing.ui.graph.contributor.labeler.LabelerContributor;\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.layer0.Layer0;\r
+import org.simantics.sysdyn.ui.browser.nodes.InputNode;\r
+\r
+public class InputLabeler extends LabelerContributor<InputNode>{\r
+\r
+ @Override\r
+ public String getLabel(ReadGraph graph, InputNode var) throws DatabaseException {\r
+ Layer0 l0 = Layer0.getInstance(graph);\r
+ Resource varres = var.data;\r
+ StringBuilder sb = new StringBuilder();\r
+ for(Resource r : graph.getObjects(varres, l0.HasName))\r
+ sb.append(graph.getValue(r));\r
+ if(graph.isInstanceOf(varres, l0.Realization)) {\r
+ varres = graph.getPossibleObject(varres, l0.Represents);\r
+ if(varres == null) return sb.toString();\r
+ }\r
+ sb.append(" : ");\r
+ for(Resource t : graph.getObjects(varres, l0.InstanceOf))\r
+ for(Resource r : graph.getObjects(t, l0.HasName))\r
+ sb.append(graph.getValue(r));\r
+ return sb.toString();\r
+ }\r
+\r
+\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2011 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.ui.browser.contributions;\r
+\r
+import java.util.ArrayList;\r
+import java.util.Collection;\r
+\r
+import org.simantics.browsing.ui.common.node.AbstractNode;\r
+import org.simantics.browsing.ui.graph.contributor.viewpoint.ViewpointContributor;\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.common.request.ObjectsWithType;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.layer0.Layer0;\r
+import org.simantics.sysdyn.SysdynResource;\r
+import org.simantics.sysdyn.ui.browser.nodes.FunctionLibraryNode;\r
+import org.simantics.sysdyn.ui.browser.nodes.FunctionNode;\r
+\r
+public class LibraryFunctions extends ViewpointContributor<FunctionLibraryNode<Resource>> {\r
+\r
+ @Override\r
+ public Collection<?> getContribution(ReadGraph graph,\r
+ FunctionLibraryNode<Resource> library) throws DatabaseException {\r
+ Layer0 l0 = Layer0.getInstance(graph);\r
+ ArrayList<AbstractNode<Resource>> result = new ArrayList<AbstractNode<Resource>>();\r
+ for(Resource function : graph.syncRequest(new ObjectsWithType(library.data, l0.ConsistsOf, SysdynResource.getInstance(graph).SysdynModelicaFunction))) {\r
+ result.add(new FunctionNode(function));\r
+ }\r
+ for(Resource functionLibrary : graph.syncRequest(new ObjectsWithType(library.data, l0.ConsistsOf, SysdynResource.getInstance(graph).SysdynModelicaFunctionLibrary))) {\r
+ result.add(new FunctionLibraryNode<Resource>(functionLibrary));\r
+ }\r
+ return result;\r
+\r
+ }\r
+\r
+ @Override\r
+ public String getViewpointId() {\r
+ return "Standard";\r
+ }\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2010 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.ui.browser.contributions;\r
+\r
+import java.util.ArrayList;\r
+import java.util.Collection;\r
+\r
+import org.simantics.browsing.ui.common.node.AbstractNode;\r
+import org.simantics.browsing.ui.graph.contributor.viewpoint.ViewpointContributor;\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.common.primitiverequest.PossibleObject;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.db.layer0.variable.Variable;\r
+import org.simantics.db.layer0.variable.Variables;\r
+import org.simantics.layer0.Layer0;\r
+import org.simantics.sysdyn.ui.browser.nodes.ConfigurationNode;\r
+import org.simantics.sysdyn.ui.browser.nodes.ExperimentsFolder;\r
+import org.simantics.sysdyn.ui.browser.nodes.FunctionsFolder;\r
+import org.simantics.sysdyn.ui.browser.nodes.ModelNode;\r
+import org.simantics.sysdyn.ui.browser.nodes.ModulesNode;\r
+\r
+public class Model extends ViewpointContributor<ModelNode> {\r
+\r
+ @Override\r
+ public Collection<?> getContribution(ReadGraph graph, ModelNode model)\r
+ throws DatabaseException {\r
+ ArrayList<AbstractNode<Resource>> result = new ArrayList<AbstractNode<Resource>>();\r
+ \r
+ Layer0 l0 = Layer0.getInstance(graph);\r
+ Resource baseRealization = graph.syncRequest(new PossibleObject(model.data, l0.HasBaseRealization));\r
+ if (baseRealization != null) {\r
+ try {\r
+ String URI = graph.getURI(baseRealization);\r
+ Variable variable = Variables.getVariable(graph, URI);\r
+ result.add(new ConfigurationNode<Resource>(variable, baseRealization));\r
+ } catch (DatabaseException e) {\r
+ }\r
+ }\r
+ result.add(new ExperimentsFolder(model.data));\r
+ result.add(new ModulesNode(model.data));\r
+ result.add(new FunctionsFolder(model.data));\r
+ return result;\r
+ }\r
+\r
+ @Override\r
+ public String getViewpointId() {\r
+ return "Standard";\r
+ }\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2010 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.ui.browser.contributions;\r
+\r
+import org.simantics.browsing.ui.graph.contributor.labeler.LabelerContributor;\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.layer0.Layer0;\r
+import org.simantics.sysdyn.ui.browser.nodes.ModelNode;\r
+\r
+public class ModelLabeler extends LabelerContributor<ModelNode>{\r
+\r
+ @Override\r
+ public String getLabel(ReadGraph graph, ModelNode model) throws DatabaseException {\r
+ String label = graph.getPossibleRelatedValue(model.data, Layer0.getInstance(graph).HasLabel);\r
+ return label == null ? "Model (no name)" : label;\r
+ }\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2010 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.ui.browser.contributions;\r
+\r
+import org.simantics.browsing.ui.graph.contributor.labeler.LabelerContributor;\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.layer0.Layer0;\r
+import org.simantics.sysdyn.ui.browser.nodes.ModuleNode;\r
+\r
+public class ModuleLabeler extends LabelerContributor<ModuleNode>{\r
+\r
+ @Override\r
+ public String getLabel(ReadGraph graph, ModuleNode module) throws DatabaseException {\r
+ Layer0 l0 = Layer0.getInstance(graph);\r
+ Resource resource = module.data;\r
+ StringBuilder sb = new StringBuilder();\r
+ for(Resource r : graph.getObjects(resource, l0.HasName))\r
+ sb.append(graph.getValue(r));\r
+ if(graph.isInstanceOf(resource, l0.Realization)) {\r
+ resource = graph.getPossibleObject(resource, l0.Represents);\r
+ if(resource == null) return sb.toString();\r
+ }\r
+ sb.append(" : ");\r
+ for(Resource t : graph.getObjects(resource, l0.InstanceOf))\r
+ for(Resource r : graph.getObjects(t, l0.HasName))\r
+ sb.append(graph.getValue(r));\r
+ return sb.toString();\r
+ }\r
+\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2010 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.ui.browser.contributions;\r
+\r
+import java.util.ArrayList;\r
+import java.util.Collection;\r
+\r
+import org.simantics.browsing.ui.common.node.AbstractNode;\r
+import org.simantics.browsing.ui.graph.contributor.viewpoint.ViewpointContributor;\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.common.request.ObjectsWithType;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.layer0.Layer0;\r
+import org.simantics.modeling.ModelingResources;\r
+import org.simantics.structural.stubs.StructuralResource2;\r
+import org.simantics.sysdyn.SysdynResource;\r
+import org.simantics.sysdyn.ui.browser.nodes.EnumerationNode;\r
+import org.simantics.sysdyn.ui.browser.nodes.InputNode;\r
+import org.simantics.sysdyn.ui.browser.nodes.ModuleNode;\r
+import org.simantics.sysdyn.ui.browser.nodes.ModuleTypeNode;\r
+import org.simantics.sysdyn.ui.browser.nodes.VariableNode;\r
+\r
+public class ModuleType extends ViewpointContributor<ModuleTypeNode> {\r
+\r
+ @Override\r
+ public Collection<?> getContribution(ReadGraph graph, ModuleTypeNode module) throws DatabaseException {\r
+ ArrayList<AbstractNode<Resource>> result = new ArrayList<AbstractNode<Resource>>();\r
+ Layer0 l0 = Layer0.getInstance(graph);\r
+ SysdynResource sr = SysdynResource.getInstance(graph);\r
+ StructuralResource2 str = StructuralResource2.getInstance(graph);\r
+ \r
+ ModelingResources mr = ModelingResources.getInstance(graph);\r
+ Resource instance = graph.getPossibleObject(module.data, mr.SymbolToComponentType);\r
+\r
+ if(instance == null) return result;\r
+ Resource conf = graph.getSingleObject(instance, str.IsDefinedBy);\r
+ for(Resource r : graph.syncRequest(new ObjectsWithType(conf, l0.ConsistsOf, sr.IndependentVariable))) {\r
+ result.add(new VariableNode<Resource>(r));\r
+ }\r
+ for(Resource r : graph.syncRequest(new ObjectsWithType(conf, l0.ConsistsOf, sr.Input))) {\r
+ result.add(new InputNode(r));\r
+ }\r
+ for(Resource r : graph.syncRequest(new ObjectsWithType(conf, l0.ConsistsOf, sr.Module))) {\r
+ result.add(new ModuleNode(r));\r
+ }\r
+ for(Resource r : graph.syncRequest(new ObjectsWithType(conf, l0.ConsistsOf, sr.Enumeration))) {\r
+ result.add(new EnumerationNode(r));\r
+ }\r
+ return result;\r
+ }\r
+\r
+ @Override\r
+ public String getViewpointId() {\r
+ return "Standard";\r
+ }\r
+\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2010 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.ui.browser.contributions;\r
+\r
+import org.simantics.browsing.ui.graph.contributor.labeler.LabelerContributor;\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.layer0.Layer0;\r
+import org.simantics.modeling.ModelingResources;\r
+import org.simantics.sysdyn.ui.browser.nodes.ModuleTypeNode;\r
+\r
+public class ModuleTypeLabeler extends LabelerContributor<ModuleTypeNode>{\r
+\r
+ @Override\r
+ public String getLabel(ReadGraph graph, ModuleTypeNode moduleType) throws DatabaseException {\r
+ ModelingResources mr = ModelingResources.getInstance(graph);\r
+ Resource typeResource = graph.getPossibleObject(moduleType.data, mr.SymbolToComponentType);\r
+ String label = graph.getPossibleRelatedValue(typeResource, Layer0.getInstance(graph).HasName);\r
+ return label == null ? "ModuleType (no name)" : label;\r
+ }\r
+\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2010 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.ui.browser.contributions;\r
+\r
+import java.util.ArrayList;\r
+import java.util.Collection;\r
+\r
+import org.simantics.browsing.ui.common.node.AbstractNode;\r
+import org.simantics.browsing.ui.graph.contributor.viewpoint.ViewpointContributor;\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.common.request.ObjectsWithType;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.layer0.Layer0;\r
+import org.simantics.modeling.ModelingResources;\r
+import org.simantics.structural.stubs.StructuralResource2;\r
+import org.simantics.sysdyn.SysdynResource;\r
+import org.simantics.sysdyn.ui.browser.nodes.ModuleTypeNode;\r
+import org.simantics.sysdyn.ui.browser.nodes.ModulesNode;\r
+\r
+public class Modules extends ViewpointContributor<ModulesNode> {\r
+\r
+ @Override\r
+ public Collection<?> getContribution(ReadGraph graph, ModulesNode model)\r
+ throws DatabaseException {\r
+\r
+ ArrayList<AbstractNode<Resource>> result = new ArrayList<AbstractNode<Resource>>();\r
+ Layer0 l0 = Layer0.getInstance(graph);\r
+ StructuralResource2 st = StructuralResource2.getInstance(graph);\r
+ for(Resource r : graph.syncRequest(new ObjectsWithType(model.data, l0.ConsistsOf, st.ComponentType))) {\r
+ if(graph.isInheritedFrom(r, SysdynResource.getInstance(graph).Module)) {\r
+ Resource symbol = graph.getPossibleObject(r,ModelingResources.getInstance(graph).ComponentTypeToSymbol);\r
+ result.add(new ModuleTypeNode(symbol));\r
+ }\r
+ }\r
+ return result;\r
+\r
+ }\r
+\r
+ @Override\r
+ public String getViewpointId() {\r
+ return "Standard";\r
+ }\r
+ \r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2010 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+\r
+package org.simantics.sysdyn.ui.browser.contributions;\r
+\r
+import org.simantics.browsing.ui.graph.contributor.labeler.LabelerContributor;\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.sysdyn.ui.browser.nodes.ModulesNode;\r
+\r
+public class ModulesLabeler extends LabelerContributor<ModulesNode>{\r
+\r
+ @Override\r
+ public String getLabel(ReadGraph graph, ModulesNode input) throws DatabaseException {\r
+ return "Modules";\r
+ }\r
+\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2010 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.ui.browser.contributions;\r
+\r
+import org.simantics.browsing.ui.graph.contributor.labeler.LabelerContributor;\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.sysdyn.ui.browser.nodes.OperatingInterfacesFolder;\r
+\r
+public class OperatingInterfacesLabeler extends LabelerContributor<OperatingInterfacesFolder> {\r
+\r
+ @Override\r
+ public String getLabel(ReadGraph graph, OperatingInterfacesFolder input) throws DatabaseException {\r
+ return "Operating interfaces";\r
+ }\r
+\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2010 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.ui.browser.contributions;\r
+\r
+import java.util.ArrayList;\r
+import java.util.Collection;\r
+\r
+import org.simantics.browsing.ui.common.node.AbstractNode;\r
+import org.simantics.browsing.ui.graph.contributor.viewpoint.ViewpointContributor;\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.common.request.ObjectsWithType;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.layer0.Layer0;\r
+import org.simantics.sysdyn.SysdynResource;\r
+\r
+public class Project extends ViewpointContributor<Resource> {\r
+\r
+ @SuppressWarnings("unchecked")\r
+ @Override\r
+ public Collection<?> getContribution(ReadGraph graph, Resource project)\r
+ throws DatabaseException {\r
+\r
+ ArrayList<AbstractNode<Resource>> result = new ArrayList<AbstractNode<Resource>>();\r
+ Layer0 l0 = Layer0.getInstance(graph);\r
+ SysdynResource sr = SysdynResource.getInstance(graph);\r
+ for(Resource r : graph.syncRequest(new ObjectsWithType(project, l0.ConsistsOf, sr.SysdynModel))) {\r
+ try {\r
+ result.add(graph.adapt(r, AbstractNode.class));\r
+ } catch(DatabaseException e) {\r
+ e.printStackTrace();\r
+ }\r
+ }\r
+ return result;\r
+\r
+ }\r
+\r
+ @Override\r
+ public String getViewpointId() {\r
+ return "Standard";\r
+ }\r
+ \r
+}\r
--- /dev/null
+package org.simantics.sysdyn.ui.browser.contributions;\r
+\r
+import java.util.ArrayList;\r
+import java.util.Collection;\r
+\r
+import org.simantics.browsing.ui.common.node.AbstractNode;\r
+import org.simantics.browsing.ui.graph.contributor.viewpoint.ViewpointContributor;\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.common.request.ObjectsWithType;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.layer0.Layer0;\r
+import org.simantics.sysdyn.SysdynResource;\r
+import org.simantics.sysdyn.ui.browser.nodes.SharedFunctionLibraryNode;\r
+import org.simantics.sysdyn.ui.browser.nodes.SharedFunctionsFolder;\r
+\r
+public class SharedFunctionLibraries extends ViewpointContributor<SharedFunctionsFolder> {\r
+\r
+ @Override\r
+ public Collection<?> getContribution(ReadGraph graph,\r
+ SharedFunctionsFolder sharedFunctionsFolder) throws DatabaseException {\r
+ \r
+ ArrayList<AbstractNode<Resource>> result = new ArrayList<AbstractNode<Resource>>();\r
+\r
+ \r
+ for(Resource sharedLibrary : graph.syncRequest(new ObjectsWithType(\r
+ sharedFunctionsFolder.data, \r
+ Layer0.getInstance(graph).IsLinkedTo, \r
+ SysdynResource.getInstance(graph).SharedFunctionOntology)))\r
+ {\r
+ result.add(new SharedFunctionLibraryNode(sharedLibrary));\r
+ }\r
+ \r
+ return result;\r
+ }\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2011 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.ui.browser.contributions;\r
+\r
+import org.simantics.browsing.ui.graph.contributor.labeler.LabelerContributor;\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.sysdyn.ui.browser.nodes.SharedFunctionsFolder;\r
+\r
+public class SharedFunctionsLabeler extends LabelerContributor<SharedFunctionsFolder>{\r
+\r
+ @Override\r
+ public String getLabel(ReadGraph graph, SharedFunctionsFolder input) throws DatabaseException {\r
+ return "Shared Functions";\r
+ }\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2010 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.ui.browser.contributions;\r
+\r
+import java.io.File;\r
+import java.util.ArrayList;\r
+import java.util.Collection;\r
+\r
+import org.simantics.browsing.ui.common.node.AbstractNode;\r
+import org.simantics.browsing.ui.graph.contributor.viewpoint.ViewpointContributor;\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.WriteGraph;\r
+import org.simantics.db.common.request.ObjectsWithType;\r
+import org.simantics.db.common.request.WriteRequest;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.layer0.Layer0;\r
+import org.simantics.sysdyn.SysdynResource;\r
+import org.simantics.sysdyn.ui.browser.nodes.ExperimentNode;\r
+\r
+public class SimulationResult extends ViewpointContributor<ExperimentNode> {\r
+\r
+ @SuppressWarnings("unchecked")\r
+ @Override\r
+ public Collection<?> getContribution(ReadGraph graph, ExperimentNode experiment) throws DatabaseException {\r
+ ArrayList<AbstractNode<Resource>> result = new ArrayList<AbstractNode<Resource>>();\r
+ SysdynResource sr = SysdynResource.getInstance(graph);\r
+ for(final Resource r : graph.syncRequest(new ObjectsWithType(experiment.data, sr.HasResult, sr.Result))) {\r
+ String resultPath = (String)graph.getPossibleRelatedValue(r, sr.HasResultFile);\r
+ File file = new File(resultPath);\r
+ if(file.exists()) {\r
+ try {\r
+ result.add(graph.adapt(r, AbstractNode.class));\r
+ } catch(DatabaseException e) {\r
+ e.printStackTrace();\r
+ }\r
+ } else {\r
+ graph.asyncRequest(new WriteRequest() {\r
+ \r
+ @Override\r
+ public void perform(WriteGraph graph) throws DatabaseException {\r
+ Layer0 l0 = Layer0.getInstance(graph);\r
+ graph.deny(r, l0.PartOf);\r
+ graph.deny(r, graph.getInverse(SysdynResource.getInstance(graph).HasResult));\r
+ \r
+ }\r
+ });\r
+ }\r
+ }\r
+ return result;\r
+ }\r
+\r
+ @Override\r
+ public String getViewpointId() {\r
+ return "Standard";\r
+ }\r
+\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2010 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.ui.browser.contributions;\r
+\r
+import org.eclipse.jface.resource.FontDescriptor;\r
+import org.eclipse.swt.SWT;\r
+import org.simantics.browsing.ui.content.LabelDecorator;\r
+import org.simantics.browsing.ui.graph.contributor.labeler.LabelDecoratorContributor;\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.simulation.ontology.SimulationResource;\r
+import org.simantics.sysdyn.ui.browser.nodes.SimulationResultNode;\r
+\r
+public class SimulationResultDecorator extends LabelDecoratorContributor<SimulationResultNode>{\r
+\r
+ @Override\r
+ public LabelDecorator getDecorator(ReadGraph graph, SimulationResultNode result) throws DatabaseException {\r
+ if (graph.hasStatement(result.data, SimulationResource.getInstance(graph).IsActive)) {\r
+ return new LabelDecorator.Stub() {\r
+\r
+ @SuppressWarnings("unchecked")\r
+ @Override\r
+ public <F> F decorateFont(F font, String column, int itemIndex) {\r
+ return (F) ((FontDescriptor) font).withStyle(SWT.BOLD);\r
+ }\r
+ };\r
+ }\r
+ return null;\r
+ }\r
+\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2010 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.ui.browser.contributions;\r
+\r
+import org.eclipse.jface.resource.ImageDescriptor;\r
+import org.simantics.browsing.ui.swt.ImagerContributor;\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.simulation.ontology.SimulationResource;\r
+import org.simantics.sysdyn.ui.Activator;\r
+import org.simantics.sysdyn.ui.browser.nodes.SimulationResultNode;\r
+\r
+public class SimulationResultImager extends ImagerContributor<SimulationResultNode>{\r
+\r
+ @Override\r
+ public ImageDescriptor getDescriptor(ReadGraph graph, SimulationResultNode result) throws DatabaseException {\r
+ if(graph.hasStatement(result.data, SimulationResource.getInstance(graph).IsActive))\r
+ return ImageDescriptor.createFromURL(Activator.getDefault().getBundle().getResource("icons/chart_bar.png"));\r
+ else\r
+ return ImageDescriptor.createFromURL(Activator.getDefault().getBundle().getResource("icons/chart_bar_blackAndWhite.png"));\r
+ }\r
+\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2010 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.ui.browser.contributions;\r
+\r
+import org.simantics.browsing.ui.graph.contributor.labeler.LabelerContributor;\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.layer0.Layer0;\r
+import org.simantics.sysdyn.ui.browser.nodes.SimulationResultNode;\r
+\r
+public class SimulationResultLabeler extends LabelerContributor<SimulationResultNode>{\r
+\r
+ @Override\r
+ public String getLabel(ReadGraph graph, SimulationResultNode result) throws DatabaseException {\r
+ String name = graph.getPossibleRelatedValue(result.data, Layer0.getInstance(graph).HasLabel);\r
+ return name == null ? "Experiment (no name)" : name;\r
+ }\r
+\r
+}\r
--- /dev/null
+package org.simantics.sysdyn.ui.browser.contributions;\r
+\r
+import java.util.ArrayList;\r
+import java.util.Collection;\r
+\r
+import org.simantics.browsing.ui.graph.contributor.viewpoint.ViewpointContributor;\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.common.request.ObjectsWithType;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.layer0.Layer0;\r
+import org.simantics.structural.ui.modelBrowser.nodes.AbstractNode;\r
+import org.simantics.sysdyn.SysdynResource;\r
+\r
+public class SysdynProject extends ViewpointContributor<Resource> {\r
+\r
+ @Override\r
+ public Collection<?> getContribution(ReadGraph graph, Resource project)\r
+ throws DatabaseException {\r
+\r
+ ArrayList<AbstractNode> result = new ArrayList<AbstractNode>();\r
+ Layer0 L0 = Layer0.getInstance(graph);\r
+ for(Resource r : graph.syncRequest(new ObjectsWithType(project, L0.ConsistsOf, SysdynResource.getInstance(graph).SysdynModel))) {\r
+ try {\r
+ result.add(graph.adapt(r, AbstractNode.class));\r
+ } catch(DatabaseException e) {\r
+ e.printStackTrace();\r
+ }\r
+ }\r
+ return result;\r
+\r
+ }\r
+\r
+ @Override\r
+ public String getViewpointId() {\r
+ return "Standard";\r
+ }\r
+\r
+}
\ No newline at end of file
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2010 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.ui.browser.contributions;\r
+\r
+import org.simantics.browsing.ui.graph.contributor.labeler.LabelerContributor;\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.layer0.Layer0;\r
+import org.simantics.sysdyn.ui.browser.nodes.VariableNode;\r
+\r
+public class VariableLabeler extends LabelerContributor<VariableNode<Resource>>{\r
+\r
+ @Override\r
+ public String getLabel(ReadGraph graph, VariableNode<Resource> var) throws DatabaseException {\r
+ Layer0 l0 = Layer0.getInstance(graph);\r
+ Resource varres = var.data;\r
+ StringBuilder sb = new StringBuilder();\r
+ for(Resource r : graph.getObjects(varres, l0.HasName))\r
+ sb.append(graph.getValue(r));\r
+ if(graph.isInstanceOf(varres, l0.Realization)) {\r
+ varres = graph.getPossibleObject(varres, l0.Represents);\r
+ if(varres == null) return sb.toString();\r
+ }\r
+ sb.append(" : ");\r
+ for(Resource t : graph.getObjects(varres, l0.InstanceOf))\r
+ for(Resource r : graph.getObjects(t, l0.HasName))\r
+ sb.append(graph.getValue(r));\r
+ return sb.toString();\r
+ }\r
+\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2010 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.ui.browser.nodes;\r
+\r
+import org.simantics.browsing.ui.common.node.IDeletable;\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.layer0.variable.Variable;\r
+\r
+public class ConfigurationNode<T> extends VariableNode<Resource> implements IDeletable {\r
+ \r
+ public ConfigurationNode(Resource resource) {\r
+ super(resource);\r
+ }\r
+ \r
+ public ConfigurationNode(Variable variable, Resource represents) {\r
+ super(variable, represents);\r
+ }\r
+ \r
+}\r
--- /dev/null
+package org.simantics.sysdyn.ui.browser.nodes;\r
+\r
+import org.simantics.browsing.ui.common.node.DeleteException;\r
+import org.simantics.browsing.ui.common.node.IDeletableNode;\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.WriteGraph;\r
+import org.simantics.db.common.request.WriteRequest;\r
+import org.simantics.db.common.utils.OrderedSetUtils;\r
+import org.simantics.db.exception.CancelTransactionException;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.db.layer0.variable.Variable;\r
+import org.simantics.layer0.Layer0;\r
+import org.simantics.sysdyn.SysdynResource;\r
+import org.simantics.ui.SimanticsUI;\r
+import org.simantics.utils.ui.ExceptionUtils;\r
+\r
+public class EnumerationNode extends VariableNode<Resource> implements IDeletableNode {\r
+\r
+ public EnumerationNode(Resource resource) {\r
+ super(resource);\r
+ }\r
+ \r
+ public EnumerationNode(Variable variable, Resource represents) {\r
+ super(variable, represents);\r
+ }\r
+\r
+ @Override\r
+ public void delete() throws DeleteException {\r
+ try {\r
+ SimanticsUI.getSession().syncRequest(new WriteRequest() {\r
+ @Override\r
+ public void perform(WriteGraph graph) throws DatabaseException, CancelTransactionException {\r
+ Layer0 l0 = Layer0.getInstance(graph);\r
+ SysdynResource sr = SysdynResource.getInstance(graph);\r
+ graph.deny(data, l0.PartOf); \r
+ for(Resource redeclaration : graph.getObjects(data, sr.ReplacedEnumeration_Inverse)) {\r
+ graph.deny(redeclaration, sr.HasRedeclaration_Inverse);\r
+ }\r
+ \r
+ for(Resource redeclaration : graph.getObjects(data, sr.ReplacingEnumeration_Inverse)) {\r
+ graph.deny(redeclaration, sr.HasRedeclaration_Inverse);\r
+ }\r
+ \r
+ for(Resource list : OrderedSetUtils.getOwnerLists(graph, data, sr.ArrayIndexes)) {\r
+ OrderedSetUtils.remove(graph, list, data);\r
+ }\r
+ \r
+ }\r
+ });\r
+ } catch (DatabaseException e) {\r
+ ExceptionUtils.logAndShowError(e);\r
+ } \r
+ }\r
+\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2010 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.ui.browser.nodes;\r
+\r
+import java.util.Collection;\r
+\r
+import org.simantics.browsing.ui.common.node.AbstractNode;\r
+import org.simantics.browsing.ui.common.node.DeleteException;\r
+import org.simantics.browsing.ui.common.node.IDeletableNode;\r
+import org.simantics.browsing.ui.common.node.IDoubleClickableNode;\r
+import org.simantics.browsing.ui.common.node.IModifiableNode;\r
+import org.simantics.browsing.ui.content.Labeler.Modifier;\r
+import org.simantics.browsing.ui.graph.impl.LabelModifier;\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.WriteGraph;\r
+import org.simantics.db.common.request.WriteRequest;\r
+import org.simantics.db.exception.CancelTransactionException;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.layer0.Layer0;\r
+import org.simantics.project.IProject;\r
+import org.simantics.simulation.project.IExperimentManager;\r
+import org.simantics.sysdyn.SysdynResource;\r
+import org.simantics.sysdyn.ui.handlers.SysdynExperimentActivator;\r
+import org.simantics.ui.SimanticsUI;\r
+import org.simantics.utils.ui.ErrorLogger;\r
+import org.simantics.utils.ui.ExceptionUtils;\r
+\r
+public class ExperimentNode extends AbstractNode<Resource> implements IDoubleClickableNode, IDeletableNode, IModifiableNode{\r
+\r
+ public ExperimentNode(Resource resource) {\r
+ super(resource);\r
+ }\r
+\r
+ @Override\r
+ public boolean handleDoubleClick() {\r
+ if (data == null)\r
+ return false;\r
+ IProject project = SimanticsUI.getProject();\r
+ IExperimentManager experimentManager = project.getHint(IExperimentManager.KEY_EXPERIMENT_MANAGER);\r
+ if (experimentManager == null) {\r
+ ErrorLogger.defaultLogWarning("Experiment manager not available.", new Exception());\r
+ return false;\r
+ }\r
+ SysdynExperimentActivator.scheduleActivation(SimanticsUI.getSession(), project, experimentManager, data);\r
+ return true;\r
+ }\r
+\r
+ @Override\r
+ public Modifier getModifier(String columnId) {\r
+ LabelModifier modifier = new LabelModifier(SimanticsUI.getSession(), data) {\r
+ @Override\r
+ public String isValid(String label) {\r
+ if (label.isEmpty())\r
+ return "Empty label not allowed";\r
+ return null;\r
+ }\r
+ };\r
+ return modifier;\r
+ }\r
+\r
+ @Override\r
+ public void delete() throws DeleteException {\r
+ try {\r
+ SimanticsUI.getSession().syncRequest(new WriteRequest() {\r
+ @Override\r
+ public void perform(WriteGraph graph) throws DatabaseException, CancelTransactionException {\r
+ Layer0 l0 = Layer0.getInstance(graph);\r
+ Collection<Resource> results = graph.getObjects(data, SysdynResource.getInstance(graph).HasResult);\r
+ if(results != null)\r
+ for(Resource result : results) \r
+ SimulationResultNode.unlinkResult(graph, result);\r
+ graph.deny(data, l0.PartOf);\r
+ }\r
+ });\r
+ } catch (DatabaseException e) {\r
+ ExceptionUtils.logAndShowError(e);\r
+ } \r
+ }\r
+\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2010 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.ui.browser.nodes;\r
+\r
+import org.simantics.browsing.ui.common.node.AbstractNode;\r
+import org.simantics.db.Resource;\r
+\r
+public class ExperimentsFolder extends AbstractNode<Resource> {\r
+\r
+ public ExperimentsFolder(Resource resource) {\r
+ super(resource);\r
+ }\r
+ \r
+ @SuppressWarnings("rawtypes")\r
+ @Override\r
+ public Object getAdapter(Class adapter) {\r
+ if(clazz == adapter) // There is no resource for this node..\r
+ return null;\r
+ return super.getAdapter(adapter);\r
+ }\r
+\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2011 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.ui.browser.nodes;\r
+\r
+import org.simantics.browsing.ui.common.node.AbstractNode;\r
+import org.simantics.browsing.ui.common.node.DeleteException;\r
+import org.simantics.browsing.ui.common.node.IDeletableNode;\r
+import org.simantics.browsing.ui.common.node.IDropTargetNode;\r
+import org.simantics.browsing.ui.common.node.IModifiableNode;\r
+import org.simantics.browsing.ui.content.Labeler.Modifier;\r
+import org.simantics.browsing.ui.graph.impl.LabelModifier;\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.WriteGraph;\r
+import org.simantics.db.common.request.WriteRequest;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.layer0.Layer0;\r
+import org.simantics.sysdyn.SysdynResource;\r
+import org.simantics.sysdyn.manager.FunctionUtils;\r
+import org.simantics.ui.SimanticsUI;\r
+import org.simantics.ui.utils.ResourceAdaptionUtils;\r
+\r
+public class FunctionLibraryNode<T> extends AbstractNode<Resource> implements IDeletableNode, IModifiableNode, IDropTargetNode {\r
+\r
+ \r
+ public FunctionLibraryNode(Resource resource) {\r
+ super(resource);\r
+ }\r
+\r
+ @Override\r
+ public Modifier getModifier(String columnId) {\r
+ try {\r
+ Resource hasName = Layer0.getInstance(SimanticsUI.getSession()).HasName;\r
+ LabelModifier modifier = new LabelModifier(SimanticsUI.getSession(), data, hasName) {\r
+ @Override\r
+ public String isValid(String label) {\r
+ if (label.isEmpty())\r
+ return "Empty label not allowed";\r
+ if (label.contains(" "))\r
+ return "Spaces are not allowed";\r
+ return null;\r
+ }\r
+ };\r
+ return modifier;\r
+ } catch (DatabaseException e) {\r
+ e.printStackTrace();\r
+ }\r
+ return null;\r
+ }\r
+\r
+ @Override\r
+ public void delete() throws DeleteException {\r
+ SimanticsUI.getSession().asyncRequest(new WriteRequest() {\r
+\r
+ @Override\r
+ public void perform(WriteGraph graph) throws DatabaseException {\r
+ Layer0 l0 = Layer0.getInstance(graph);\r
+ graph.deny(data, l0.PartOf);\r
+ }\r
+ });\r
+ }\r
+\r
+ @Override\r
+ public void drop(Object data) {\r
+ final Resource[] resources = ResourceAdaptionUtils.toResources(data);\r
+ final Resource library = this.data;\r
+ if(resources.length > 0) {\r
+ SimanticsUI.getSession().asyncRequest(new WriteRequest() {\r
+ \r
+ @Override\r
+ public void perform(WriteGraph graph) throws DatabaseException {\r
+ SysdynResource sr = SysdynResource.getInstance(graph);\r
+ Layer0 l0 = Layer0.getInstance(graph);\r
+ for(Resource tobeMoved : resources) {\r
+ if(graph.isInstanceOf(tobeMoved, sr.SysdynModelicaFunction) ||\r
+ graph.isInstanceOf(tobeMoved, sr.SysdynModelicaFunctionLibrary)) {\r
+ Resource oldLib = graph.getSingleObject(tobeMoved, l0.PartOf);\r
+ graph.deny(tobeMoved, l0.PartOf);\r
+ graph.claim(tobeMoved, l0.PartOf, library);\r
+ FunctionUtils.updateFunctionFileForLibrary(graph, oldLib);\r
+ FunctionUtils.updateFunctionFileForLibrary(graph, library);\r
+ }\r
+ }\r
+ }\r
+ });\r
+ }\r
+ }\r
+ \r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2011 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.ui.browser.nodes;\r
+\r
+import org.simantics.browsing.ui.common.node.DeleteException;\r
+import org.simantics.browsing.ui.common.node.IDeletableNode;\r
+import org.simantics.browsing.ui.common.node.IDropTargetNode;\r
+import org.simantics.browsing.ui.common.node.IModifiableNode;\r
+import org.simantics.browsing.ui.content.Labeler.Modifier;\r
+import org.simantics.browsing.ui.graph.impl.LabelModifier;\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.WriteGraph;\r
+import org.simantics.db.common.request.WriteRequest;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.layer0.Layer0;\r
+import org.simantics.sysdyn.SysdynResource;\r
+import org.simantics.sysdyn.manager.FunctionUtils;\r
+import org.simantics.ui.SimanticsUI;\r
+import org.simantics.ui.utils.ResourceAdaptionUtils;\r
+\r
+public class FunctionNode extends VariableNode<Resource> implements IDeletableNode, IModifiableNode, IDropTargetNode {\r
+ \r
+ public FunctionNode(final Resource resource) {\r
+ super(resource);\r
+ }\r
+ \r
+ @Override\r
+ public Modifier getModifier(String columnId) {\r
+ try {\r
+ Resource hasName = Layer0.getInstance(SimanticsUI.getSession()).HasName;\r
+ LabelModifier modifier = new LabelModifier(SimanticsUI.getSession(), data, hasName) {\r
+ @Override\r
+ public String isValid(String label) {\r
+ if (label.isEmpty())\r
+ return "Empty label not allowed";\r
+ if (label.contains(" "))\r
+ return "Spaces are not allowed";\r
+ return null;\r
+ }\r
+ };\r
+ return modifier;\r
+ } catch (DatabaseException e) {\r
+ e.printStackTrace();\r
+ }\r
+ return null;\r
+ }\r
+\r
+ @Override\r
+ public void delete() throws DeleteException {\r
+ SimanticsUI.getSession().asyncRequest(new WriteRequest() {\r
+\r
+ @Override\r
+ public void perform(WriteGraph graph) throws DatabaseException {\r
+ Layer0 l0 = Layer0.getInstance(graph);\r
+ Resource partOf = graph.getSingleObject(data, l0.PartOf);\r
+ if(partOf != null) {\r
+ graph.deny(data, l0.PartOf, partOf);\r
+ }\r
+ }\r
+ });\r
+ }\r
+ \r
+ @Override\r
+ public void drop(Object data) {\r
+ final Resource[] resources = ResourceAdaptionUtils.toResources(data);\r
+ final Resource thisFunction = this.data;\r
+ \r
+ if(resources.length > 0) {\r
+ SimanticsUI.getSession().asyncRequest(new WriteRequest() {\r
+ \r
+ @Override\r
+ public void perform(WriteGraph graph) throws DatabaseException {\r
+ SysdynResource sr = SysdynResource.getInstance(graph);\r
+ Layer0 l0 = Layer0.getInstance(graph);\r
+ Resource library = null;\r
+ for(Resource tobeMoved : resources) {\r
+ if(graph.isInstanceOf(tobeMoved, sr.SysdynModelicaFunction) ||\r
+ graph.isInstanceOf(tobeMoved, sr.SysdynModelicaFunctionLibrary)) {\r
+ if(library == null) {\r
+ library = graph.getSingleObject(thisFunction, l0.PartOf);\r
+ }\r
+ Resource oldLib = graph.getSingleObject(tobeMoved, l0.PartOf);\r
+ graph.deny(tobeMoved, l0.PartOf);\r
+ graph.claim(tobeMoved, l0.PartOf, library);\r
+ FunctionUtils.updateFunctionFileForLibrary(graph, oldLib);\r
+ FunctionUtils.updateFunctionFileForLibrary(graph, library);\r
+ }\r
+ }\r
+ }\r
+ });\r
+ }\r
+ }\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2011 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.ui.browser.nodes;\r
+\r
+import org.simantics.browsing.ui.common.node.AbstractNode;\r
+import org.simantics.browsing.ui.common.node.IDropTargetNode;\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.WriteGraph;\r
+import org.simantics.db.common.request.WriteRequest;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.layer0.Layer0;\r
+import org.simantics.sysdyn.SysdynResource;\r
+import org.simantics.sysdyn.manager.FunctionUtils;\r
+import org.simantics.ui.SimanticsUI;\r
+import org.simantics.ui.utils.ResourceAdaptionUtils;\r
+\r
+public class FunctionsFolder extends AbstractNode<Resource> implements IDropTargetNode{\r
+\r
+ public FunctionsFolder(Resource resource) {\r
+ super(resource);\r
+ }\r
+ \r
+ @SuppressWarnings("rawtypes")\r
+ @Override\r
+ public Object getAdapter(Class adapter) {\r
+ if(clazz == adapter) // There is no resource for this node..\r
+ return null;\r
+ return super.getAdapter(adapter);\r
+ }\r
+ \r
+ @Override\r
+ public void drop(Object data) {\r
+ final Resource[] resources = ResourceAdaptionUtils.toResources(data);\r
+ final Resource library = this.data;\r
+ if(resources.length > 0) {\r
+ SimanticsUI.getSession().asyncRequest(new WriteRequest() {\r
+ \r
+ @Override\r
+ public void perform(WriteGraph graph) throws DatabaseException {\r
+ SysdynResource sr = SysdynResource.getInstance(graph);\r
+ Layer0 l0 = Layer0.getInstance(graph);\r
+ for(Resource tobeMoved : resources) {\r
+ if(graph.isInstanceOf(tobeMoved, sr.SysdynModelicaFunction) ||\r
+ graph.isInstanceOf(tobeMoved, sr.SysdynModelicaFunctionLibrary)) {\r
+ Resource oldLib = graph.getSingleObject(tobeMoved, l0.PartOf);\r
+ graph.deny(tobeMoved, l0.PartOf);\r
+ graph.claim(tobeMoved, l0.PartOf, library);\r
+ FunctionUtils.updateFunctionFileForLibrary(graph, oldLib);\r
+ FunctionUtils.updateFunctionFileForLibrary(graph, library);\r
+ }\r
+ }\r
+ }\r
+ });\r
+ }\r
+ }\r
+ \r
+\r
+
+ \r
+ \r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2010 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.ui.browser.nodes;\r
+\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.layer0.variable.Variable;\r
+\r
+public class InputNode extends VariableNode<Resource> {\r
+\r
+ public InputNode(Resource resource) {\r
+ super(resource);\r
+ }\r
+ \r
+ public InputNode(Variable variable, Resource represents) {\r
+ super(variable, represents);\r
+ }\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2010 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.ui.browser.nodes;\r
+\r
+import org.simantics.browsing.ui.common.node.AbstractNode;\r
+import org.simantics.browsing.ui.common.node.DeleteException;\r
+import org.simantics.browsing.ui.common.node.IDeletableNode;\r
+import org.simantics.browsing.ui.common.node.IDoubleClickableNode;\r
+import org.simantics.browsing.ui.common.node.IModifiableNode;\r
+import org.simantics.browsing.ui.content.Labeler.Modifier;\r
+import org.simantics.browsing.ui.graph.impl.LabelModifier;\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.WriteGraph;\r
+import org.simantics.db.common.request.WriteRequest;\r
+import org.simantics.db.common.utils.NameUtils;\r
+import org.simantics.db.exception.CancelTransactionException;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.db.procedure.Listener;\r
+import org.simantics.db.request.Read;\r
+import org.simantics.db.request.Write;\r
+import org.simantics.layer0.Layer0;\r
+import org.simantics.simulation.ontology.SimulationResource;\r
+import org.simantics.sysdyn.SysdynResource;\r
+import org.simantics.ui.SimanticsUI;\r
+import org.simantics.utils.ui.ExceptionUtils;\r
+\r
+public class ModelNode extends AbstractNode<Resource> implements IDoubleClickableNode, IDeletableNode, IModifiableNode {\r
+\r
+ Listener<String> configurationNameSynchronizer;\r
+ private boolean disposed = false;\r
+ \r
+ public ModelNode(Resource resource) {\r
+ super(resource);\r
+ \r
+ // Not the best solution for name sync\r
+ configurationNameSynchronizer = new Listener<String>() {\r
+\r
+ @Override\r
+ public void execute(final String result) {\r
+ SimanticsUI.getSession().asyncRequest(new WriteRequest() {\r
+ \r
+ @Override\r
+ public void perform(WriteGraph graph) throws DatabaseException {\r
+ Layer0 l0 = Layer0.getInstance(graph);\r
+ SimulationResource sim = SimulationResource.getInstance(graph);\r
+ Resource configuration = graph.getPossibleObject(data, sim.HasConfiguration);\r
+ graph.claimLiteral(configuration, l0.HasLabel, result);\r
+ }\r
+ });\r
+ }\r
+\r
+ @Override\r
+ public void exception(Throwable t) {\r
+ t.printStackTrace();\r
+ }\r
+\r
+ @Override\r
+ public boolean isDisposed() {\r
+ return disposed;\r
+ }\r
+ };\r
+ \r
+ SimanticsUI.getSession().asyncRequest(new Read<String>() {\r
+\r
+ @Override\r
+ public String perform(ReadGraph graph) throws DatabaseException {\r
+ return graph.getRelatedValue(data, Layer0.getInstance(graph).HasLabel);\r
+ }\r
+ \r
+ }, configurationNameSynchronizer);\r
+ }\r
+\r
+ @Override\r
+ public Modifier getModifier(String columnId) {\r
+ LabelModifier modifier = new LabelModifier(SimanticsUI.getSession(), data) {\r
+ @Override\r
+ public String isValid(String label) {\r
+ if (label.isEmpty())\r
+ return "Empty label not allowed";\r
+ if (label.contains(" "))\r
+ return "Spaces are not allowed";\r
+ return null;\r
+ }\r
+ \r
+ @Override\r
+ protected Write getWriteRequest(final String label) {\r
+ return new WriteRequest() {\r
+ @Override\r
+ public void perform(WriteGraph g) throws DatabaseException {\r
+ Layer0 l0 = Layer0.getInstance(g);\r
+ g.claimLiteral(data, l0.HasLabel, label);\r
+ String safeName = NameUtils.findFreshName(g, label, g.getSingleObject(data, l0.PartOf), l0.ConsistsOf, "%s%d");\r
+ g.claimLiteral(data, l0.HasName, safeName);\r
+ }\r
+ };\r
+ }\r
+ };\r
+ return modifier;\r
+ }\r
+\r
+ @Override\r
+ public void delete() throws DeleteException {\r
+ disposed = true;\r
+ try {\r
+ SimanticsUI.getSession().syncRequest(new WriteRequest() {\r
+ @Override\r
+ public void perform(WriteGraph graph) throws DatabaseException, CancelTransactionException {\r
+ Layer0 l0 = Layer0.getInstance(graph);\r
+ \r
+ for(Resource r : graph.getObjects(data, l0.ConsistsOf))\r
+ if(graph.isInstanceOf(r, SysdynResource.getInstance(graph).Result))\r
+ SimulationResultNode.deleteResultFiles(graph, r);\r
+\r
+ graph.deny(data, l0.PartOf);\r
+ }\r
+ });\r
+ } catch (DatabaseException e) {\r
+ ExceptionUtils.logAndShowError(e);\r
+ }\r
+ \r
+ }\r
+\r
+ @Override\r
+ public boolean handleDoubleClick() {\r
+ return true;\r
+ }\r
+\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2010 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.ui.browser.nodes;\r
+\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.layer0.variable.Variable;\r
+\r
+public class ModuleNode extends ConfigurationNode<Resource> {\r
+\r
+ public ModuleNode(Resource resource) {\r
+ super(resource);\r
+ }\r
+ \r
+ public ModuleNode(Variable variable, Resource represents) {\r
+ super(variable, represents);\r
+ }\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2010 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.ui.browser.nodes;\r
+\r
+import java.util.Collection;\r
+\r
+import org.simantics.browsing.ui.common.node.AbstractNode;\r
+import org.simantics.browsing.ui.common.node.DeleteException;\r
+import org.simantics.browsing.ui.common.node.IDeletableNode;\r
+import org.simantics.browsing.ui.common.node.IModifiableNode;\r
+import org.simantics.browsing.ui.content.Labeler.Modifier;\r
+import org.simantics.browsing.ui.graph.impl.LabelModifier;\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.WriteGraph;\r
+import org.simantics.db.common.request.ObjectsWithType;\r
+import org.simantics.db.common.request.WriteRequest;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.db.exception.ManyObjectsForFunctionalRelationException;\r
+import org.simantics.db.exception.ServiceException;\r
+import org.simantics.db.procedure.Listener;\r
+import org.simantics.db.request.Read;\r
+import org.simantics.layer0.Layer0;\r
+import org.simantics.modeling.ModelingResources;\r
+import org.simantics.simulation.ontology.SimulationResource;\r
+import org.simantics.structural.stubs.StructuralResource2;\r
+import org.simantics.ui.SimanticsUI;\r
+\r
+public class ModuleTypeNode extends AbstractNode<Resource> implements IDeletableNode, IModifiableNode {\r
+\r
+ \r
+ Listener<String> configurationNameSynchronizer;\r
+ private boolean disposed = false;\r
+ \r
+ public ModuleTypeNode(Resource resource) {\r
+ super(resource);\r
+ \r
+ // Not the best solution for name sync\r
+ configurationNameSynchronizer = new Listener<String>() {\r
+\r
+ @Override\r
+ public void execute(final String result) {\r
+ SimanticsUI.getSession().asyncRequest(new WriteRequest() {\r
+ \r
+ @Override\r
+ public void perform(WriteGraph graph) throws DatabaseException {\r
+ Layer0 l0 = Layer0.getInstance(graph);\r
+ ModelingResources mr = ModelingResources.getInstance(graph);\r
+ StructuralResource2 sr2 = StructuralResource2.getInstance(graph);\r
+ Resource type = graph.getPossibleObject(data, mr.SymbolToComponentType);\r
+ Resource configuration = graph.getPossibleObject(type, sr2.IsDefinedBy);\r
+ graph.claimLiteral(configuration, l0.HasLabel, result);\r
+ }\r
+ });\r
+ }\r
+\r
+ @Override\r
+ public void exception(Throwable t) {\r
+ t.printStackTrace();\r
+ }\r
+\r
+ @Override\r
+ public boolean isDisposed() {\r
+ return disposed;\r
+ }\r
+ };\r
+ \r
+ SimanticsUI.getSession().asyncRequest(new Read<String>() {\r
+\r
+ @Override\r
+ public String perform(ReadGraph graph) throws DatabaseException {\r
+ Layer0 l0 = Layer0.getInstance(graph);\r
+ ModelingResources mr = ModelingResources.getInstance(graph);\r
+ Resource type = graph.getPossibleObject(data, mr.SymbolToComponentType);\r
+ return graph.getRelatedValue(type, l0.HasName);\r
+ }\r
+ \r
+ }, configurationNameSynchronizer);\r
+ \r
+ }\r
+\r
+ @Override\r
+ public Modifier getModifier(String columnId) {\r
+ Modifier modifier = null;\r
+ try {\r
+ modifier = SimanticsUI.getSession().syncRequest(new Read<Modifier>() {\r
+\r
+ @Override\r
+ public Modifier perform(ReadGraph graph) throws ManyObjectsForFunctionalRelationException, ServiceException {\r
+ ModelingResources mr = ModelingResources.getInstance(graph);\r
+ Layer0 l0 = Layer0.getInstance(graph);\r
+ Resource type = graph.getPossibleObject(data, mr.SymbolToComponentType);\r
+\r
+ LabelModifier modifier = new LabelModifier(SimanticsUI.getSession(), type, l0.HasName) {\r
+ @Override\r
+ public String isValid(String label) {\r
+ if (label.isEmpty())\r
+ return "Empty name not allowed";\r
+ return null;\r
+ }\r
+ };\r
+\r
+\r
+ return modifier;\r
+ }\r
+ });\r
+ } catch (DatabaseException e) {\r
+ e.printStackTrace();\r
+ }\r
+\r
+ return modifier;\r
+ }\r
+\r
+ @Override\r
+ public void delete() throws DeleteException {\r
+ disposed = true;\r
+ try {\r
+ SimanticsUI.getSession().syncRequest(new WriteRequest() {\r
+\r
+ @Override\r
+ public void perform(WriteGraph graph) throws DatabaseException {\r
+ Layer0 l0 = Layer0.getInstance(graph);\r
+ StructuralResource2 st = StructuralResource2.getInstance(graph);\r
+ ModelingResources mr = ModelingResources.getInstance(graph);\r
+\r
+ Resource type = graph.getPossibleObject(data, mr.SymbolToComponentType);\r
+ Resource model = graph.getSingleObject(type, l0.PartOf);\r
+ Resource modelConfiguration = graph.getSingleObject(model, SimulationResource.getInstance(graph).HasConfiguration);\r
+ if (!graph.syncRequest(new ObjectsWithType(modelConfiguration, l0.ConsistsOf, type)).isEmpty()) {\r
+ System.out.println("The module is used at the model configuration");\r
+ return;\r
+ }\r
+ Collection<Resource> moduleTypes = graph.syncRequest(new ObjectsWithType(model, l0.ConsistsOf, st.ComponentType));\r
+ for(Resource r : moduleTypes) {\r
+ Resource configuration = graph.getSingleObject(r, st.IsDefinedBy);\r
+ if(!graph.syncRequest(new ObjectsWithType(configuration, l0.ConsistsOf, type)).isEmpty()) {\r
+ System.out.println("The module is used at another module: " + graph.getRelatedValue(r, l0.HasName));\r
+ return;\r
+ }\r
+ }\r
+ graph.deny(model, l0.ConsistsOf, type);\r
+ }\r
+ });\r
+ } catch (DatabaseException e) {\r
+ e.printStackTrace();\r
+ }\r
+ }\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2010 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.ui.browser.nodes;\r
+\r
+import org.simantics.browsing.ui.common.node.AbstractNode;\r
+import org.simantics.db.Resource;\r
+\r
+public class ModulesNode extends AbstractNode<Resource> {\r
+ \r
+ public ModulesNode(Resource resource) {\r
+ super(resource);\r
+ }\r
+\r
+ @SuppressWarnings("rawtypes")\r
+ @Override\r
+ public Object getAdapter(Class adapter) {\r
+ if(clazz == adapter) // There is no resource for this node..\r
+ return null;\r
+ return super.getAdapter(adapter);\r
+ }\r
+\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2010 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.ui.browser.nodes;\r
+\r
+import org.simantics.browsing.ui.common.node.AbstractNode;\r
+import org.simantics.db.Resource;\r
+\r
+public class OperatingInterfacesFolder extends AbstractNode<Resource> {\r
+\r
+ public OperatingInterfacesFolder(Resource resource) {\r
+ super(resource);\r
+ }\r
+\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2011 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.ui.browser.nodes;\r
+\r
+import org.simantics.browsing.ui.common.node.DeleteException;\r
+import org.simantics.browsing.ui.common.node.IDropTargetNode;\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.WriteGraph;\r
+import org.simantics.db.common.request.WriteRequest;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.layer0.Layer0;\r
+import org.simantics.sysdyn.SysdynResource;\r
+import org.simantics.sysdyn.manager.FunctionUtils;\r
+import org.simantics.ui.SimanticsUI;\r
+import org.simantics.ui.utils.ResourceAdaptionUtils;\r
+\r
+public class SharedFunctionLibraryNode extends FunctionLibraryNode<Resource> implements IDropTargetNode {\r
+\r
+ public SharedFunctionLibraryNode(Resource resource) {\r
+ super(resource);\r
+ }\r
+\r
+ @Override\r
+ public void delete() throws DeleteException {\r
+ SimanticsUI.getSession().asyncRequest(new WriteRequest() {\r
+\r
+ @Override\r
+ public void perform(WriteGraph graph) throws DatabaseException {\r
+ Layer0 l0 = Layer0.getInstance(graph);\r
+ \r
+ graph.deny(data, l0.PartOf);\r
+ graph.deny(data, l0.IsLinkedTo_Inverse);\r
+\r
+ // TODO: remove file\r
+ }\r
+ });\r
+ }\r
+ \r
+ @Override\r
+ public void drop(Object data) {\r
+ final Resource[] resources = ResourceAdaptionUtils.toResources(data);\r
+ final Resource library = this.data;\r
+ if(resources.length > 0) {\r
+ SimanticsUI.getSession().asyncRequest(new WriteRequest() {\r
+ \r
+ @Override\r
+ public void perform(WriteGraph graph) throws DatabaseException {\r
+ SysdynResource sr = SysdynResource.getInstance(graph);\r
+ Layer0 l0 = Layer0.getInstance(graph);\r
+ for(Resource tobeMoved : resources) {\r
+ if(graph.isInstanceOf(tobeMoved, sr.SysdynModelicaFunction) ||\r
+ graph.isInstanceOf(tobeMoved, sr.SysdynModelicaFunctionLibrary)) {\r
+ Resource oldLib = graph.getSingleObject(tobeMoved, l0.PartOf);\r
+ graph.deny(tobeMoved, l0.PartOf);\r
+ graph.claim(tobeMoved, l0.PartOf, library);\r
+ FunctionUtils.updateFunctionFileForLibrary(graph, oldLib);\r
+ FunctionUtils.updateFunctionFileForLibrary(graph, library);\r
+ }\r
+ }\r
+ \r
+ }\r
+ });\r
+ }\r
+ }\r
+\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2011 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.ui.browser.nodes;\r
+\r
+import org.simantics.browsing.ui.common.node.AbstractNode;\r
+import org.simantics.db.Resource;\r
+\r
+public class SharedFunctionsFolder extends AbstractNode<Resource> {\r
+\r
+ public SharedFunctionsFolder(Resource data) {\r
+ super(data);\r
+ }\r
+\r
+ @SuppressWarnings("rawtypes")\r
+ @Override\r
+ public Object getAdapter(Class adapter) {\r
+ if(clazz == adapter) // There is no resource for this node..\r
+ return null;\r
+ return super.getAdapter(adapter);\r
+ }\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2010 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.ui.browser.nodes;\r
+\r
+import java.io.File;\r
+\r
+import org.simantics.browsing.ui.common.node.AbstractNode;\r
+import org.simantics.browsing.ui.common.node.DeleteException;\r
+import org.simantics.browsing.ui.common.node.IDeletableNode;\r
+import org.simantics.browsing.ui.common.node.IDoubleClickableNode;\r
+import org.simantics.browsing.ui.common.node.IModifiableNode;\r
+import org.simantics.browsing.ui.content.Labeler.Modifier;\r
+import org.simantics.browsing.ui.graph.impl.LabelModifier;\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.WriteGraph;\r
+import org.simantics.db.common.request.WriteRequest;\r
+import org.simantics.db.exception.CancelTransactionException;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.layer0.Layer0;\r
+import org.simantics.sysdyn.SysdynResource;\r
+import org.simantics.sysdyn.ui.handlers.ToggleResultActivation;\r
+import org.simantics.ui.SimanticsUI;\r
+import org.simantics.utils.ui.ExceptionUtils;\r
+\r
+public class SimulationResultNode extends AbstractNode<Resource> implements IDoubleClickableNode, IDeletableNode, IModifiableNode {\r
+\r
+ public SimulationResultNode(Resource resource) {\r
+ super(resource);\r
+ }\r
+ \r
+ \r
+ @Override\r
+ public Modifier getModifier(String columnId) {\r
+ LabelModifier modifier = new LabelModifier(SimanticsUI.getSession(), data) {\r
+ @Override\r
+ public String isValid(String label) {\r
+ if (label.isEmpty())\r
+ return "Empty label not allowed";\r
+ return null;\r
+ }\r
+ };\r
+ return modifier;\r
+ }\r
+\r
+\r
+ @Override\r
+ public void delete() throws DeleteException {\r
+ try {\r
+ SimanticsUI.getSession().syncRequest(new WriteRequest() {\r
+ @Override\r
+ public void perform(WriteGraph graph) throws DatabaseException, CancelTransactionException {\r
+ unlinkResult(graph, data);\r
+ }\r
+ });\r
+ } catch (DatabaseException e) {\r
+ ExceptionUtils.logAndShowError(e);\r
+ }\r
+ \r
+ }\r
+ \r
+ \r
+ public static void unlinkResult(WriteGraph graph, Resource result) throws DatabaseException {\r
+ Layer0 l0 = Layer0.getInstance(graph);\r
+ deleteResultFiles(graph, result);\r
+ graph.deny(result, l0.PartOf);\r
+ graph.deny(result, graph.getInverse(SysdynResource.getInstance(graph).HasResult));\r
+\r
+ }\r
+ \r
+ public static void deleteResultFiles(WriteGraph graph, Resource result) throws DatabaseException {\r
+ String path;\r
+ path = graph.getPossibleRelatedValue(result, SysdynResource.getInstance(graph).HasResultFile);\r
+ if(path != null) {\r
+ File file = new File(path);\r
+ file.delete();\r
+ File parent = file.getParentFile();\r
+ if(parent.listFiles() != null && parent.listFiles().length == 0)\r
+ parent.delete();\r
+ }\r
+ }\r
+\r
+\r
+ @Override\r
+ public boolean handleDoubleClick() {\r
+ Resource[] resources = {data};\r
+ ToggleResultActivation.toggleActivation(resources);\r
+ return true;\r
+ }\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2010 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.ui.browser.nodes;\r
+\r
+import org.simantics.browsing.ui.common.node.AbstractNode;\r
+import org.simantics.browsing.ui.common.node.IDeletable;\r
+import org.simantics.db.Resource;\r
+\r
+public class SymbolNode extends AbstractNode<Resource> implements IDeletable {\r
+\r
+ public SymbolNode(Resource resource) {\r
+ super(resource);\r
+ }\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2010 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.ui.browser.nodes;\r
+\r
+import org.simantics.browsing.ui.common.node.AbstractNode;\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.layer0.variable.Variable;\r
+\r
+public class VariableNode<T> extends AbstractNode<Resource> {\r
+\r
+ Variable variable;\r
+\r
+ public VariableNode(Resource resource) {\r
+ super(resource);\r
+ }\r
+\r
+ public VariableNode(Variable variable, Resource represents) {\r
+ super(represents);\r
+ this.variable = variable;\r
+ }\r
+\r
+ public Variable getVariable() {\r
+ return variable;\r
+ }\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2010 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.ui.dependencies;\r
+\r
+import java.util.ArrayList;\r
+import java.util.Collection;\r
+import java.util.Collections;\r
+import java.util.HashMap;\r
+\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.common.request.ObjectsWithType;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.db.request.Read;\r
+import org.simantics.graphviz.Edge;\r
+import org.simantics.graphviz.Graph;\r
+import org.simantics.graphviz.IGraph;\r
+import org.simantics.graphviz.Node;\r
+import org.simantics.layer0.Layer0;\r
+import org.simantics.modeling.ModelingResources;\r
+import org.simantics.sysdyn.SysdynResource;\r
+\r
+public class CreateDependencyGraph implements Read<Graph> {\r
+\r
+ Resource root;\r
+ HashMap<Resource, Node> nodes;\r
+ boolean isInverted;\r
+ int levels;\r
+\r
+ public CreateDependencyGraph(Resource root, int levels, boolean isInverted) {\r
+ this.root = root;\r
+ this.isInverted = isInverted; \r
+ this.levels = levels;\r
+ }\r
+\r
+ @Override\r
+ public Graph perform(ReadGraph g) throws DatabaseException {\r
+\r
+ nodes = new HashMap<Resource, Node>();\r
+ Graph graph = new Graph();\r
+ graph.setRankdir("LR");\r
+ ModelingResources mr = ModelingResources.getInstance(g);\r
+ Resource element = g.getPossibleObject(root, mr.ElementToComponent);\r
+ if (element != null) {\r
+ root = element;\r
+ }\r
+ SysdynResource sr = SysdynResource.getInstance(g);\r
+ if (g.isInstanceOf(root, sr.IndependentVariable) || g.isInstanceOf(root, sr.Input)) {\r
+ setRoot(g, graph, root);\r
+ Collection<Resource> resources = new ArrayList<Resource>(); \r
+ resources.add(root);\r
+ for (int i = 0; i < levels && !resources.isEmpty(); i++) {\r
+ Collection<Resource> newResources = new ArrayList<Resource>();\r
+ for(Resource r : resources) {\r
+ newResources.addAll(setDependencies(g, graph, r));\r
+ }\r
+ resources = new ArrayList<Resource>(newResources);\r
+ }\r
+ }\r
+ return graph;\r
+ }\r
+\r
+ private void setRoot(ReadGraph g, IGraph graph, Resource root) throws DatabaseException {\r
+ Node n;\r
+ n = new Node(graph, getName(g, root));\r
+ setShape(g, root, n);\r
+ n.set("style", "filled");\r
+ n.setFillColor("#d3d3d3");\r
+ nodes.put(root, n);\r
+ }\r
+\r
+\r
+ private Collection<Resource> getDependants(ReadGraph g, IGraph graph, Resource r, Resource toDependency, Resource fromDependency, Resource connectionType) throws DatabaseException {\r
+ SysdynResource sr = SysdynResource.getInstance(g);\r
+\r
+ Collection<Resource> dependencies = g.syncRequest(new ObjectsWithType(r, toDependency, connectionType));\r
+\r
+ Collection<Resource> dependants = new ArrayList<Resource>();\r
+ Node n;\r
+ for(Resource d : dependencies) {\r
+ Resource dependant = g.getPossibleObject(d, fromDependency);\r
+ if(dependant == null)\r
+ continue;\r
+ if(g.isInstanceOf(dependant, sr.Cloud)) {\r
+ break;\r
+ }\r
+ if( !nodes.containsKey(dependant)) {\r
+ n= new Node(graph, getName(g, dependant));\r
+ setShape(g, dependant, n);\r
+ nodes.put(dependant, n);\r
+ dependants.add(dependant);\r
+ }\r
+\r
+ if(isInverted) {\r
+ new Edge(graph, nodes.get(r), nodes.get(dependant));\r
+ } else {\r
+ new Edge(graph, nodes.get(dependant), nodes.get(r));\r
+ }\r
+ }\r
+ return dependants;\r
+ }\r
+ private Collection<Resource> setDependencies(ReadGraph g, IGraph graph, Resource r) throws DatabaseException{\r
+ SysdynResource sr = SysdynResource.getInstance(g);\r
+\r
+ // stop here if element is a module\r
+ if (g.isInstanceOf(r, sr.Module))\r
+ return Collections.emptyList();\r
+\r
+ Collection<Resource> dependants;\r
+ if(isInverted)\r
+ dependants = getDependants(g, graph, r, sr.IsTailOf, sr.HasHead, sr.Dependency);\r
+ else {\r
+ dependants = getDependants(g, graph, r, sr.IsHeadOf, sr.HasTail, sr.Dependency);\r
+ if (g.isInstanceOf(r, sr.Stock)) {\r
+ dependants.addAll(getDependants(g, graph, r, sr.IsTailOf, sr.HasHead, sr.Flow));\r
+ dependants.addAll(getDependants(g, graph, r, sr.IsHeadOf, sr.HasTail, sr.Flow));\r
+ }\r
+ }\r
+\r
+ return dependants;\r
+ }\r
+\r
+ private void setShape(ReadGraph g, Resource r, Node n) throws DatabaseException {\r
+ SysdynResource sr = SysdynResource.getInstance(g);\r
+ if(g.isInstanceOf(r, sr.Stock))\r
+ n.setShape("rectangle");\r
+ else if(g.isInstanceOf(r, sr.Module)) {\r
+ n.setShape("rectangle");\r
+ n.setStyle("rounded"); \r
+ }\r
+ else\r
+ n.setShape("ellipse");\r
+ }\r
+\r
+ private String getName(ReadGraph g, Resource r) throws DatabaseException {\r
+ return (String)g.getRelatedValue(r, Layer0.getInstance(g).HasName);\r
+ }\r
+\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2010 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.ui.dependencies;\r
+\r
+import java.util.Set;\r
+\r
+import org.eclipse.core.runtime.IProgressMonitor;\r
+import org.eclipse.core.runtime.IStatus;\r
+import org.eclipse.core.runtime.Status;\r
+import org.eclipse.core.runtime.jobs.Job;\r
+import org.eclipse.jface.layout.GridDataFactory;\r
+import org.eclipse.jface.layout.GridLayoutFactory;\r
+import org.eclipse.jface.viewers.ISelection;\r
+import org.eclipse.jface.viewers.IStructuredSelection;\r
+import org.eclipse.swt.SWT;\r
+import org.eclipse.swt.events.ModifyEvent;\r
+import org.eclipse.swt.events.ModifyListener;\r
+import org.eclipse.swt.events.SelectionAdapter;\r
+import org.eclipse.swt.events.SelectionEvent;\r
+import org.eclipse.swt.layout.RowLayout;\r
+import org.eclipse.swt.widgets.Button;\r
+import org.eclipse.swt.widgets.Composite;\r
+import org.eclipse.swt.widgets.Label;\r
+import org.eclipse.swt.widgets.Spinner;\r
+import org.eclipse.ui.ISelectionListener;\r
+import org.eclipse.ui.IWorkbenchPart;\r
+import org.eclipse.ui.part.ViewPart;\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.procedure.Listener;\r
+import org.simantics.graphviz.Graph;\r
+import org.simantics.graphviz.ui.GraphvizComponent;\r
+import org.simantics.ui.SimanticsUI;\r
+import org.simantics.utils.ui.ISelectionUtils;\r
+\r
+public class DependencyView extends ViewPart {\r
+\r
+ private GraphvizComponent component;\r
+ private boolean disposed, isInverted = false;\r
+ private Button bButton, fButton;\r
+ private Resource currentSelection;\r
+ private int levels = 3;\r
+ private ISelectionListener selectionListener;\r
+ private Composite baseComposite;\r
+\r
+ static int MAXLEVELS = 4;\r
+ static int MINLEVELS = 1;\r
+\r
+ @Override\r
+ public void createPartControl(Composite parent) {\r
+ disposed = false;\r
+ GridLayoutFactory.fillDefaults().margins(3, 3).applyTo(parent);\r
+ baseComposite = new Composite(parent, \r
+ SWT.NO_BACKGROUND | SWT.EMBEDDED);\r
+ GridLayoutFactory.fillDefaults().applyTo(baseComposite);\r
+ GridDataFactory.fillDefaults().grab(true, true).applyTo(baseComposite);\r
+\r
+ component = new GraphvizComponent(baseComposite, SWT.BORDER);\r
+ GridDataFactory.fillDefaults().grab(true, true).applyTo(component);\r
+\r
+ Composite composite = new Composite(parent, SWT.NULL);\r
+ RowLayout layout = new RowLayout();\r
+ layout.center = true;\r
+ composite.setLayout(layout);\r
+\r
+ Label label = new Label(composite, SWT.NULL);\r
+ label.setText("Direction: ");\r
+\r
+ bButton = new Button(composite, SWT.RADIO);\r
+ bButton.setText("Backward");\r
+ bButton.setSelection(true);\r
+ bButton.addSelectionListener(new SelectionAdapter() {\r
+ public void widgetSelected(SelectionEvent event) {\r
+ if(bButton.getSelection())\r
+ isInverted = false;\r
+ else \r
+ isInverted = true;\r
+ if(currentSelection != null) {\r
+ readGraph(currentSelection);\r
+ }\r
+ }\r
+ });\r
+\r
+ fButton = new Button(composite, SWT.RADIO);\r
+ fButton.setText("Forward");\r
+\r
+ label = new Label(composite, SWT.NULL);\r
+ label.setText("Steps: ");\r
+\r
+ Spinner spinner = new Spinner(composite, SWT.BORDER);\r
+ spinner.setMaximum(MAXLEVELS);\r
+ spinner.setMinimum(MINLEVELS);\r
+ spinner.setTextLimit(1);\r
+ spinner.setSelection(levels);\r
+\r
+ spinner.addModifyListener(new ModifyListener() {\r
+\r
+ @Override\r
+ public void modifyText(ModifyEvent e) {\r
+ Spinner s = (Spinner)e.widget;\r
+ int lvls = Integer.parseInt(s.getText());\r
+ if(lvls > MAXLEVELS)\r
+ levels = MAXLEVELS;\r
+ else if (lvls < MINLEVELS)\r
+ levels = MINLEVELS;\r
+ levels = lvls;\r
+ if(currentSelection != null) {\r
+ readGraph(currentSelection);\r
+ }\r
+\r
+ }\r
+ });\r
+\r
+ drawSelection(getSite().getWorkbenchWindow().getSelectionService().getSelection());\r
+\r
+ selectionListener = new ISelectionListener() {\r
+\r
+ @Override\r
+ public void selectionChanged(IWorkbenchPart part, ISelection selection) {\r
+ drawSelection(selection);\r
+ }\r
+ }; \r
+ getSite().getWorkbenchWindow().getSelectionService().addPostSelectionListener(selectionListener);\r
+ }\r
+\r
+ private void drawSelection(ISelection selection) {\r
+ if(selection == null || selection.isEmpty())\r
+ return;\r
+ if(selection instanceof IStructuredSelection) { \r
+ Object[] els = ((IStructuredSelection) selection).toArray();\r
+ if(els.length == 1) {\r
+ Set<Resource> ress = ISelectionUtils.filterSetSelection(selection, Resource.class);\r
+ if(ress.isEmpty()) return;\r
+ Resource r = (ress.toArray(Resource.NONE))[0];\r
+ if(r != null && !r.equals(currentSelection)) {\r
+ currentSelection = r;\r
+ readGraph(currentSelection);\r
+ }\r
+ }\r
+ } \r
+ }\r
+\r
+ private void readGraph(Resource resource) {\r
+ SimanticsUI.getSession().asyncRequest(new CreateDependencyGraph(\r
+ resource, levels, isInverted),\r
+ new Listener<Graph>() {\r
+\r
+ @Override\r
+ public void exception(Throwable e) {\r
+ e.printStackTrace();\r
+ }\r
+\r
+ @Override\r
+ public void execute(final Graph graph) {\r
+ Job job = new Job("Layout composite graph") {\r
+\r
+ @Override\r
+ protected IStatus run(IProgressMonitor monitor) {\r
+ if(!isDisposed()) {\r
+ component.setGraph(graph, "dot");\r
+ component.fit(); \r
+ }\r
+ return Status.OK_STATUS;\r
+ }\r
+ };\r
+ job.schedule();\r
+ }\r
+\r
+ @Override\r
+ public boolean isDisposed() {\r
+ return disposed;\r
+ }\r
+ });\r
+ }\r
+\r
+\r
+ @Override\r
+ public void setFocus() {\r
+ if(baseComposite != null && !baseComposite.isDisposed()) {\r
+ baseComposite.setFocus();\r
+ component.setFocus();\r
+ }\r
+ }\r
+\r
+\r
+\r
+\r
+ @Override\r
+ public void dispose() {\r
+ super.dispose();\r
+ getSite().getWorkbenchWindow().getSelectionService().removePostSelectionListener(selectionListener);\r
+ disposed = true;\r
+ }\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2010 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.ui.editor;\r
+\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.layer0.utils.binaryPredicates.InversePredicate;\r
+import org.simantics.layer0.utils.binaryPredicates.OrderedSetElementsPredicate;\r
+import org.simantics.mapping.constraint.instructions.IInstruction;\r
+import org.simantics.mapping.constraint.instructions.TypedBracketInstruction.CreationInstruction;\r
+import org.simantics.mapping.rule.instructions.IRuleInstruction;\r
+import org.simantics.sysdyn.SysdynResource;\r
+\r
+public class DiagramToCompositeMapping3 extends org.simantics.modeling.mapping.DiagramToCompositeMapping3 {\r
+\r
+ private SysdynResource sdr;\r
+\r
+ public DiagramToCompositeMapping3(ReadGraph g, Resource mapping)\r
+ throws DatabaseException {\r
+ super(g, mapping);\r
+ }\r
+\r
+ @Override\r
+ protected void setup(ReadGraph graph) {\r
+ sdr = SysdynResource.getInstance(graph);\r
+ }\r
+\r
+ @Override\r
+ protected Resource getConfigurationConnectionType() {\r
+ return sdr.DependencyConnection;\r
+ }\r
+\r
+ @Override\r
+ public CreationInstruction componentCreationInstruction(int component, int componentType, int configuration) {\r
+ return new SysdynCreationInstruction(project, configurationRoot, component, componentType, configuration);\r
+ }\r
+\r
+ @Override\r
+ protected IRuleInstruction additiveRule() {\r
+ return \r
+ \r
+ if_(bf(OrderedSetElementsPredicate.INSTANCE, Diagram, Element),\r
+ query(\r
+ if_(and(bf(b.InstanceOf, Element, ElementType),\r
+ bf(mr.SymbolToComponentType, ElementType, ComponentType)\r
+ ),\r
+ // If element type of the element has a corresponding component type\r
+ createComponentRule(),\r
+ \r
+ if_(and(b(dr.Connection, Element), bf(b.InstanceOf, Element, ElementType), bf(mr.DiagramConnectionTypeToConnectionType, ElementType, ComponentType)),\r
+ createNormalConnectionRule(),\r
+\r
+ if_(b(dr.Flag, Element),\r
+ createFlagRule()\r
+ )\r
+ )\r
+ )\r
+ )\r
+ );\r
+ }\r
+\r
+ @Override\r
+ protected IRuleInstruction destructiveRule() {\r
+ return\r
+ if_(and(bf(b.ConsistsOf, Configuration, Component),\r
+ b(mapped, Component) // handle only mapped components\r
+ ),\r
+ query(\r
+ if_(and(bf(mr.ComponentToElement, Component, Element),\r
+ bf(new InversePredicate(OrderedSetElementsPredicate.INSTANCE), Element, Diagram)\r
+ ),\r
+ // If component has a corresponding element in the diagram\r
+ if_(and(statement_bff(Component, ConnectionRelation, Connection, sr.IsConnectedTo),\r
+ b(mapped, Connection)\r
+ ),\r
+ // If component has a mapped connection\r
+ unless(\r
+ bf(mr.ConnectionToDiagramConnection, Connection, DiagramConnectionRelation),\r
+ // If the configuration connection does not have a correspondence in the diagram remove it\r
+ and(deny(exists(Connection)))\r
+ )\r
+ ),\r
+\r
+ unless(\r
+ bf(mr.ConnectionToDiagramConnection, Component, Element),\r
+ // If the configuration connection does not have a correspondence in the diagram remove it\r
+ and(deny(exists(Component)))\r
+ )\r
+\r
+ )\r
+ )\r
+ );\r
+ }\r
+\r
+ @Override\r
+ protected IInstruction claimBasicConnection() {\r
+ return and(exists(\r
+ bf(mr.DiagramConnectionToConnection, Element, Connection),\r
+ Connection\r
+ ),\r
+ bb(b.InstanceOf, Connection, ComponentType),\r
+ bb(b.PartOf, Connection, Configuration),\r
+ b(mapped, Connection)\r
+\r
+ );\r
+ }\r
+ \r
+// @Override\r
+// protected IInstruction claimBasicConnection() {\r
+// return and(exists(\r
+// bf(mr.DiagramConnectionToConnection, Element, Connection),\r
+// Connection\r
+// ),\r
+// bb(b.InstanceOf, Connection, ComponentType),\r
+// b(mapped, Connection),\r
+// bb(b.PartOf, Connection, Configuration)\r
+// );\r
+// }\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2010 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.ui.editor;\r
+\r
+import java.awt.dnd.DnDConstants;\r
+import java.util.ArrayList;\r
+import java.util.Collections;\r
+import java.util.Set;\r
+\r
+import org.eclipse.jface.viewers.ISelection;\r
+import org.eclipse.jface.viewers.StructuredSelection;\r
+import org.eclipse.swt.widgets.Composite;\r
+import org.eclipse.ui.IWorkbenchPartSite;\r
+import org.simantics.browsing.ui.swt.AdaptableHintContext;\r
+import org.simantics.browsing.ui.swt.IPropertyPage;\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.Session;\r
+import org.simantics.db.layer0.SelectionHints;\r
+import org.simantics.diagram.handler.CopyPasteHandler;\r
+import org.simantics.diagram.synchronization.IModifiableSynchronizationContext;\r
+import org.simantics.diagram.synchronization.SynchronizationHints;\r
+import org.simantics.diagram.ui.DiagramModelHints;\r
+import org.simantics.diagram.ui.WorkbenchSelectionProvider;\r
+import org.simantics.g2d.canvas.Hints;\r
+import org.simantics.g2d.canvas.ICanvasContext;\r
+import org.simantics.g2d.canvas.impl.CanvasContext;\r
+import org.simantics.g2d.connection.IConnectionAdvisor;\r
+import org.simantics.g2d.diagram.DiagramHints;\r
+import org.simantics.g2d.diagram.participant.DeleteHandler;\r
+import org.simantics.g2d.diagram.participant.ElementPainter;\r
+import org.simantics.g2d.diagram.participant.pointertool.PointerInteractor;\r
+import org.simantics.g2d.element.ElementClass;\r
+import org.simantics.g2d.element.ElementClasses;\r
+import org.simantics.g2d.element.ElementHints;\r
+import org.simantics.g2d.element.IElement;\r
+import org.simantics.g2d.element.IElementClassProvider;\r
+import org.simantics.g2d.element.handler.impl.StaticObjectAdapter;\r
+import org.simantics.g2d.participant.GridPainter;\r
+import org.simantics.g2d.participant.RulerPainter;\r
+import org.simantics.modeling.mapping.ElementCopyAdvisor;\r
+import org.simantics.modeling.mapping.MappedElementCopyAdvisor;\r
+import org.simantics.modeling.ui.diagramEditor.PopulateElementMonitorDropParticipant;\r
+import org.simantics.modeling.ui.diagramEditor.handlers.LinkBrowsingHandler;\r
+import org.simantics.structural2.modelingRules.IModelingRules;\r
+import org.simantics.sysdyn.SysdynResource;\r
+import org.simantics.sysdyn.ui.editor.participant.CreateVariablesShortcutParticipant;\r
+import org.simantics.sysdyn.ui.editor.participant.SysdynComponentCopyAdvisor;\r
+import org.simantics.sysdyn.ui.editor.participant.SysdynElementClassProviders;\r
+import org.simantics.sysdyn.ui.editor.participant.SysdynPopulateElementDropParticipant;\r
+import org.simantics.sysdyn.ui.elements2.CloudFactory;\r
+import org.simantics.sysdyn.ui.elements2.SysdynElementClasses;\r
+import org.simantics.sysdyn.ui.elements2.SysdynElementFactory;\r
+import org.simantics.sysdyn.ui.elements2.connections.ConnectionClasses;\r
+import org.simantics.sysdyn.ui.elements2.connections.SysdynConnectionClass;\r
+import org.simantics.sysdyn.ui.properties.SysdynPropertyPage;\r
+import org.simantics.utils.datastructures.hints.HintContext;\r
+import org.simantics.utils.datastructures.hints.IHintContext;\r
+\r
+/**\r
+ * @author Tuukka Lehtonen\r
+ */\r
+public class DiagramViewer extends org.simantics.modeling.ui.diagramEditor.DiagramViewer {\r
+\r
+ protected String getPopupId() {\r
+ return "#SysdynDiagramPopup";\r
+ }\r
+\r
+ @Override\r
+ public void createPartControl(Composite parent) {\r
+ super.createPartControl(parent);\r
+ \r
+ ElementPainter ep = canvasContext.getSingleItem(ElementPainter.class);\r
+ for(IElement e : sourceDiagram.getElements()) {\r
+ if(e.getElementClass().getId().contains("Connection")){\r
+ ep.update(e);\r
+ }\r
+ }\r
+ scheduleZoomToFit();\r
+ } \r
+\r
+ @Override\r
+ protected Set<String> getPropertyPageContexts() {\r
+ return Collections.singleton("http://www.simantics.org/Sysdyn-1.0/Browser");\r
+ }\r
+\r
+ @Override\r
+ protected IPropertyPage createPropertyPage(IWorkbenchPartSite site, Set<String> contexts) {\r
+ return new SysdynPropertyPage(site, contexts);\r
+ }\r
+\r
+ @Override\r
+ protected IElementClassProvider createElementClassProvider(ReadGraph graph) {\r
+ SysdynResource sr = SysdynResource.getInstance(graph);\r
+ ElementClass dependencyClass = SysdynConnectionClass.CLASS.newClassWith(new StaticObjectAdapter(sr.DependencyConnection));\r
+ return SysdynElementClassProviders.mappedProvider(\r
+ ElementClasses.CONNECTION, dependencyClass,\r
+ ElementClasses.FLAG, CloudFactory.createElementClass(sr.CloudSymbol, SysdynElementFactory.createTerminals(graph, sr.CloudSymbol)),\r
+ ConnectionClasses.FLOW, SysdynConnectionClass.CLASS.newClassWith(new StaticObjectAdapter(sr.FlowConnection)),\r
+ ConnectionClasses.DEPENDENCY, dependencyClass,\r
+ SysdynElementClasses.VALVE, CloudFactory.createElementClass(sr.ValveSymbol, SysdynElementFactory.createTerminals(graph, sr.ValveSymbol))\r
+ );\r
+\r
+\r
+ }\r
+ \r
+ @Override\r
+ public ICanvasContext createViewerCanvas() {\r
+ ICanvasContext ctx = super.createViewerCanvas();\r
+ // GRID and RULER have to be set here. They cause deadlocks in Show Module if set in onCreated()\r
+ IHintContext h = ctx.getDefaultHintContext();\r
+ h.setHint(GridPainter.KEY_GRID_ENABLED, Boolean.FALSE);\r
+ h.setHint(RulerPainter.KEY_RULER_ENABLED, Boolean.FALSE);\r
+ return ctx;\r
+ }\r
+\r
+ @Override\r
+ protected void onCreated() {\r
+ sourceDiagram.setHint(DiagramHints.KEY_ALLOW_ROUTE_POINTS, Boolean.FALSE);\r
+ sourceDiagram.setHint(SynchronizationHints.COPY_ADVISOR, new MappedElementCopyAdvisor(new ElementCopyAdvisor(), new SysdynComponentCopyAdvisor()));\r
+ }\r
+\r
+ @Override\r
+ protected void addKeyBindingParticipants(CanvasContext ctx) {\r
+ ctx.add(new DeleteHandler(getEditorSite().getActionBars().getStatusLineManager()));\r
+ ctx.add(new CopyPasteHandler(getEditorSite().getActionBars().getStatusLineManager()));\r
+ ctx.add(new CreateVariablesShortcutParticipant(synchronizer));\r
+ }\r
+\r
+ @Override\r
+ protected void initializeSynchronizationContext(ReadGraph graph, IModifiableSynchronizationContext context) {\r
+ super.initializeSynchronizationContext(graph, context);\r
+\r
+ // Make sure SysdynResource is available.\r
+ SysdynResource.getInstance(graph);\r
+ }\r
+\r
+ @Override\r
+ protected void addStructureParticipants(ICanvasContext ctx) {\r
+\r
+ ctx.add(new WorkbenchSelectionProvider(swt, getSite()) {\r
+\r
+ @Override\r
+ protected ISelection constructAdaptableSelection(Iterable<?> selection) {\r
+ ArrayList<Object> objects = new ArrayList<Object>();\r
+ Resource runtime = sourceDiagram.getHint(DiagramModelHints.KEY_DIAGRAM_RUNTIME_RESOURCE);\r
+ for (Object o : selection) {\r
+ if (o instanceof IElement) {\r
+ IElement e = (IElement) o;\r
+ Object object = e.getHint(ElementHints.KEY_OBJECT);\r
+ if (object != null && runtime != null) {\r
+ IHintContext context = new AdaptableHintContext(SelectionHints.KEY_MAIN);\r
+ context.setHint(SelectionHints.KEY_MAIN, object);\r
+ if (runtime != null)\r
+ context.setHint(SelectionHints.KEY_VARIABLE_RESOURCE, runtime);\r
+ objects.add(context);\r
+ }\r
+ } else {\r
+ System.out.println(" unrecognized selection: " + o.getClass() + ": " + o);\r
+ }\r
+ }\r
+ if(objects.isEmpty() && runtime != null) {\r
+ HintContext context = new HintContext();\r
+ context.setHint(SelectionHints.KEY_VARIABLE_RESOURCE, runtime);\r
+ objects.add(context);\r
+ }\r
+ return new StructuredSelection(objects);\r
+ }\r
+\r
+ });\r
+ // Add visual browsing capabilities for structural models\r
+\r
+ // Remove double click handler, because it is not working properly\r
+ // ctx.add(new StructuralBrowsingHandler(getSite(), sessionContext, getResourceInput2()));\r
+ ctx.add(new LinkBrowsingHandler(getSite(), this, sessionContext));\r
+\r
+ }\r
+ \r
+ protected void addDropParticipants(ICanvasContext ctx) {\r
+ ctx.getDefaultHintContext().setHint(Hints.KEY_ALLOWED_DRAG_ACTIONS, DnDConstants.ACTION_COPY);\r
+\r
+ ctx.add(new SysdynPopulateElementDropParticipant(synchronizer));\r
+ ctx.add(new PopulateElementMonitorDropParticipant(synchronizer, 0.5, 0.5));\r
+ }\r
+\r
+ @Override\r
+ protected void addOtherParticipants(CanvasContext ctx) {\r
+ }\r
+\r
+ @Override \r
+ protected PointerInteractor getPointerInteractor() {\r
+ return new org.simantics.sysdyn.ui.editor.participant.PointerInteractor(true, true, true, false, true, false, synchronizer.getElementClassProvider());\r
+ }\r
+\r
+ @Override\r
+ protected IConnectionAdvisor getConnectionAdvisor(IModelingRules modelingRules, Session session) {\r
+ return new SysdynConnectionAdvisor(modelingRules, sessionContext.getSession());\r
+ }\r
+\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2010 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.ui.editor;\r
+\r
+import org.eclipse.ui.PartInitException;\r
+import org.eclipse.ui.PlatformUI;\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.common.ResourceArray;\r
+import org.simantics.db.common.request.ReadRequest;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.layer0.Layer0;\r
+import org.simantics.modeling.ComponentUtils;\r
+import org.simantics.modeling.ModelingResources;\r
+import org.simantics.modeling.ui.Activator;\r
+import org.simantics.structural.stubs.StructuralResource2;\r
+import org.simantics.structural2.StructuralVariables;\r
+import org.simantics.sysdyn.SysdynResource;\r
+import org.simantics.ui.SimanticsUI;\r
+import org.simantics.ui.workbench.ResourceEditorInput2;\r
+import org.simantics.ui.workbench.editor.AbstractResourceEditorAdapter;\r
+import org.simantics.utils.ui.workbench.WorkbenchUtils;\r
+\r
+public class OpenDiagramFromConfigurationAdapter extends AbstractResourceEditorAdapter {\r
+\r
+ private static final String EDITOR_ID = "org.simantics.sysdyn.ui.diagramViewer";\r
+\r
+ public OpenDiagramFromConfigurationAdapter() {\r
+ super("Diagram Editor", Activator.COMPOSITE_ICON);\r
+ }\r
+\r
+ protected String getEditorId() {\r
+ return EDITOR_ID;\r
+ }\r
+\r
+ @Override\r
+ public boolean canHandle(ReadGraph g, Resource r) throws DatabaseException {\r
+ SysdynResource sr = SysdynResource.getInstance(g);\r
+ if(g.isInheritedFrom(r, sr.ModuleSymbol)) {\r
+ ModelingResources mr = ModelingResources.getInstance(g);\r
+ StructuralResource2 sr2 = StructuralResource2.getInstance(g);\r
+ Resource componentType = g.getSingleObject(r, mr.SymbolToComponentType);\r
+ r = g.getSingleObject(componentType, sr2.IsDefinedBy);\r
+ }\r
+ Layer0 l0 = Layer0.getInstance(g);\r
+ Resource represents = g.getPossibleObject(r, l0.Represents);\r
+ if(represents != null){\r
+ if(g.isInstanceOf(represents, sr.Configuration)) {\r
+ r = represents;\r
+ }\r
+ }\r
+ return ComponentUtils.compositeHasDiagram(g, r) /*|| ComponentUtils.componentHasDiagram(g, r)*/;\r
+ }\r
+\r
+ @Override\r
+ public void openEditor(final Resource r) throws Exception {\r
+\r
+ SimanticsUI.getSession().asyncRequest(new ReadRequest() {\r
+\r
+ @Override\r
+ public void run(ReadGraph g) throws DatabaseException {\r
+ Resource cr = r;\r
+ Layer0 l0 = Layer0.getInstance(g);\r
+ if(g.isInheritedFrom(r, SysdynResource.getInstance(g).ModuleSymbol)) {\r
+ ModelingResources mr = ModelingResources.getInstance(g);\r
+ StructuralResource2 sr2 = StructuralResource2.getInstance(g);\r
+ Resource componentType = g.getSingleObject(r, mr.SymbolToComponentType);\r
+ Resource configuration = g.getSingleObject(componentType, sr2.IsDefinedBy);\r
+ cr = configuration;\r
+ } else { \r
+ Resource represents = g.getPossibleObject(r, l0.Represents);\r
+ if(represents != null && g.isInstanceOf(represents, SysdynResource.getInstance(g).Configuration)){\r
+ cr = represents;\r
+ } else {\r
+ cr = r;\r
+ }\r
+ }\r
+\r
+ \r
+ final Resource diagram = ComponentUtils.getPossibleCompositeDiagram(g, cr);\r
+ if(diagram == null) return;\r
+ final ResourceArray compositePath = StructuralVariables.getCompositeArray(g, cr);\r
+ final ResourceArray variablePath = compositePath.removeFromBeginning(1);\r
+\r
+ Resource model = StructuralVariables.getModel(g, compositePath.head());\r
+ if(model == null) return;\r
+ final String modelURI = g.getURI(model);\r
+\r
+ final String rvi = StructuralVariables.getRVI(g, variablePath);\r
+ if(rvi == null) return;\r
+\r
+ PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() {\r
+ @Override\r
+ public void run() {\r
+ try {\r
+ String editorId = getEditorId();\r
+// System.out.println("Activating diagram: model=" + modelURI + " rvi='" + rvi + "'");\r
+ WorkbenchUtils.openEditor(editorId, new ResourceEditorInput2(editorId, diagram, modelURI, rvi));\r
+ } catch (PartInitException e) {\r
+ // TODO Auto-generated catch block\r
+ e.printStackTrace();\r
+ }\r
+ }\r
+ });\r
+\r
+ }\r
+\r
+ });\r
+\r
+ }\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2010 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.ui.editor;\r
+\r
+import java.util.ArrayList;\r
+import java.util.Arrays;\r
+\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.RequestProcessor;\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.db.request.Read;\r
+import org.simantics.diagram.content.ConnectionUtil;\r
+import org.simantics.diagram.content.ResourceTerminal;\r
+import org.simantics.diagram.stubs.DiagramResource;\r
+import org.simantics.g2d.connection.IConnectionAdvisor;\r
+import org.simantics.g2d.diagram.handler.Topology.Terminal;\r
+import org.simantics.g2d.element.ElementUtils;\r
+import org.simantics.g2d.element.IElement;\r
+import org.simantics.g2d.element.handler.impl.StaticObjectAdapter;\r
+import org.simantics.structural.stubs.StructuralResource2;\r
+import org.simantics.structural2.modelingRules.CPIgnore;\r
+import org.simantics.structural2.modelingRules.ConnectionJudgement;\r
+import org.simantics.structural2.modelingRules.ConnectionJudgementType;\r
+import org.simantics.structural2.modelingRules.IConnectionPoint;\r
+import org.simantics.structural2.modelingRules.IModelingRules;\r
+import org.simantics.sysdyn.SysdynResource;\r
+import org.simantics.sysdyn.ui.elements2.CloudFactory.CloudSceneGraph;\r
+\r
+public class SysdynConnectionAdvisor implements IConnectionAdvisor {\r
+\r
+ IModelingRules modelingRules;\r
+ RequestProcessor processor;\r
+\r
+ public SysdynConnectionAdvisor(IModelingRules modelingRules,\r
+ RequestProcessor processor) {\r
+ this.modelingRules = modelingRules;\r
+ this.processor = processor;\r
+ }\r
+\r
+ IConnectionPoint getConnectionPoint(ReadGraph g, IElement element, Terminal term) throws DatabaseException {\r
+ Object obj = null;\r
+ if (element != null)\r
+ obj = ElementUtils.getObject(element);\r
+\r
+ if (obj instanceof Resource) {\r
+ Resource elementResource = (Resource) obj;\r
+ return ConnectionUtil.toConnectionPoint(g, elementResource, term);\r
+ }\r
+\r
+ // FIXME: this currently allows connections to begin from flags\r
+ // but is rather hackish.\r
+ if(element.getElementClass().containsClass(CloudSceneGraph.class)) {\r
+ return CPIgnore.NULL_INSTANCE;\r
+ }\r
+\r
+ return null;\r
+ }\r
+\r
+ @Override\r
+ public Object canBeConnected(Object backend,\r
+ final IElement element1, final Terminal term1,\r
+ final IElement element2, final Terminal term2) {\r
+ try {\r
+ if(backend == null)\r
+ backend = processor;\r
+ return ((RequestProcessor)backend).syncRequest(new Read<Object>() {\r
+\r
+ @Override\r
+ public Object perform(ReadGraph g) throws DatabaseException {\r
+ if(element1 != null && term1 != null && element2 != null && term2 != null) {\r
+ StaticObjectAdapter soa = element1.getElementClass().getSingleItem(StaticObjectAdapter.class);\r
+ Resource startElementResource = soa.adapt(Resource.class);\r
+ soa = element2.getElementClass().getSingleItem(StaticObjectAdapter.class);\r
+ Resource endElementResource = soa.adapt(Resource.class);\r
+ \r
+ DiagramResource dr = DiagramResource.getInstance(g);\r
+ StructuralResource2 str2 = StructuralResource2.getInstance(g);\r
+ Resource terminal2 = ((ResourceTerminal) term2).getResource();\r
+ SysdynResource sr = SysdynResource.getInstance(g);\r
+\r
+ Resource connectionVariable = g.getPossibleObject(terminal2, dr.HasConnectionVariable);\r
+ if(!g.hasStatement(connectionVariable, str2.Binds, sr.IsHeadOfTerminal)) {\r
+ return null;\r
+ }\r
+ \r
+ if(g.isInstanceOf(endElementResource, sr.InputSymbol)) {\r
+ if(g.isInheritedFrom(startElementResource, sr.ModuleSymbol)) return null;\r
+ if(g.getObjects(endElementResource, sr.IsHeadOfTerminal).size() > 0) return null;\r
+ }\r
+ \r
+ }\r
+\r
+ ArrayList<IConnectionPoint> cps = new ArrayList<IConnectionPoint>();\r
+ cps.add(getConnectionPoint(g, element1, term1));\r
+ if(element2 != null)\r
+ cps.add(getConnectionPoint(g, element2, term2));\r
+ ConnectionJudgement judgement = \r
+ modelingRules.judgeConnection(g, cps); \r
+\r
+ if(judgement.type == ConnectionJudgementType.LEGAL)\r
+ return judgement;\r
+ else\r
+ return null;\r
+ }\r
+\r
+ });\r
+ } catch(DatabaseException e) {\r
+ e.printStackTrace();\r
+ return null;\r
+ }\r
+ }\r
+\r
+ @Override\r
+ public boolean canBeginConnection(Object backend,\r
+ final IElement element, final Terminal term) {\r
+ try {\r
+ if(backend == null)\r
+ backend = processor;\r
+ return ((RequestProcessor)backend).syncRequest(new Read<Boolean>() {\r
+\r
+ @Override\r
+ public Boolean perform(ReadGraph g) throws DatabaseException {\r
+ return modelingRules.judgeConnection(g,\r
+ Arrays.asList(getConnectionPoint(g, element, term)))\r
+ .type != ConnectionJudgementType.ILLEGAL;\r
+ }\r
+\r
+ });\r
+ } catch(DatabaseException e) {\r
+ e.printStackTrace();\r
+ return false;\r
+ }\r
+ }\r
+\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2010 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.ui.editor;\r
+\r
+import gnu.trove.TIntIntHashMap;\r
+\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.WriteGraph;\r
+import org.simantics.db.common.utils.URIStringUtils;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.layer0.Layer0;\r
+import org.simantics.layer0.utils.direct.GraphUtils;\r
+import org.simantics.mapping.constraint.instructions.TypedBracketInstruction.CreationInstruction;\r
+import org.simantics.modeling.services.ComponentNamingUtil;\r
+import org.simantics.modeling.services.NamingException;\r
+import org.simantics.project.IProject;\r
+\r
+public class SysdynCreationInstruction extends CreationInstruction {\r
+\r
+ IProject project;\r
+ Resource configurationRoot;\r
+ int lComponentType;\r
+ int lConfiguration;\r
+\r
+ public SysdynCreationInstruction(IProject project, Resource configurationRoot, int variableId, int componentType,\r
+ int configuration) {\r
+ super(variableId);\r
+ this.project = project;\r
+ this.configurationRoot = configurationRoot;\r
+ lComponentType = componentType;\r
+ lConfiguration = configuration;\r
+ }\r
+\r
+ @Override\r
+ public Resource create(WriteGraph g, Object[] bindings) throws DatabaseException {\r
+ Resource componentType = (Resource) bindings[lComponentType];\r
+ Resource configuration = (Resource) bindings[lConfiguration];\r
+\r
+ Layer0 l0 = Layer0.getInstance(g);\r
+\r
+ try {\r
+ String proposition = URIStringUtils.escape(ComponentNamingUtil.findFreshInstanceName(g, project, configurationRoot, configuration, componentType));\r
+ Resource result = GraphUtils.create(g,\r
+ l0.HasName, proposition\r
+ );\r
+ g.claim(result, l0.Represents, result);\r
+ return result;\r
+ } catch (NamingException e1) {\r
+ throw new DatabaseException(e1);\r
+ }\r
+ }\r
+\r
+ @Override\r
+ public void mapVariables(TIntIntHashMap map) {\r
+ super.mapVariables(map);\r
+ lComponentType = map.get(lComponentType);\r
+ lConfiguration = map.get(lConfiguration);\r
+ }\r
+\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2010 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.ui.editor.participant;\r
+\r
+import java.awt.geom.AffineTransform;\r
+import java.awt.geom.Point2D;\r
+import java.util.Set;\r
+\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.common.request.Queries;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.diagram.adapter.GraphToDiagramSynchronizer;\r
+import org.simantics.diagram.elements.TextNode;\r
+import org.simantics.diagram.query.DiagramRequests;\r
+import org.simantics.g2d.canvas.SGDesignation;\r
+import org.simantics.g2d.canvas.impl.DependencyReflection.Dependency;\r
+import org.simantics.g2d.canvas.impl.SGNodeReflection.SGInit;\r
+import org.simantics.g2d.diagram.DiagramHints;\r
+import org.simantics.g2d.diagram.DiagramMutator;\r
+import org.simantics.g2d.diagram.DiagramUtils;\r
+import org.simantics.g2d.diagram.IDiagram;\r
+import org.simantics.g2d.diagram.participant.AbstractDiagramParticipant;\r
+import org.simantics.g2d.diagram.participant.ElementPainter;\r
+import org.simantics.g2d.diagram.participant.Selection;\r
+import org.simantics.g2d.element.ElementClass;\r
+import org.simantics.g2d.element.ElementUtils;\r
+import org.simantics.g2d.element.IElement;\r
+import org.simantics.g2d.event.EventHandlerReflection.EventHandler;\r
+import org.simantics.g2d.event.KeyEvent;\r
+import org.simantics.g2d.event.KeyEvent.KeyPressedEvent;\r
+import org.simantics.g2d.event.KeyEvent.KeyReleasedEvent;\r
+import org.simantics.g2d.event.MouseEvent;\r
+import org.simantics.g2d.event.MouseEvent.MouseMovedEvent;\r
+import org.simantics.g2d.participant.MouseUtil;\r
+import org.simantics.g2d.participant.MouseUtil.MouseClickEvent;\r
+import org.simantics.g2d.participant.MouseUtil.MouseInfo;\r
+import org.simantics.scenegraph.g2d.G2DParentNode;\r
+import org.simantics.scenegraph.g2d.nodes.ShapeNode;\r
+import org.simantics.sysdyn.ui.elements2.AuxiliaryFactory;\r
+import org.simantics.sysdyn.ui.elements2.CloudFactory;\r
+import org.simantics.sysdyn.ui.elements2.InputFactory;\r
+import org.simantics.sysdyn.ui.elements2.StockFactory;\r
+import org.simantics.sysdyn.ui.elements2.ValveFactory;\r
+import org.simantics.ui.SimanticsUI;\r
+import org.simantics.utils.datastructures.Callback;\r
+import org.simantics.utils.ui.ExceptionUtils;\r
+\r
+public class CreateVariablesShortcutParticipant extends AbstractDiagramParticipant {\r
+\r
+ private GraphToDiagramSynchronizer synchronizer;\r
+\r
+ private VariableInformation variableInformation;\r
+\r
+ @Dependency\r
+ MouseUtil mouseUtil;\r
+\r
+ @Dependency\r
+ Selection selection;\r
+\r
+ @Dependency\r
+ ElementPainter diagramPainter;\r
+\r
+ ShapeNode node;\r
+ G2DParentNode parent;\r
+\r
+ @SGInit(designation = SGDesignation.CANVAS)\r
+ public void init(G2DParentNode parent) {\r
+ this.parent = parent;\r
+ }\r
+\r
+ public void removeSG() {\r
+ node.remove();\r
+ node = null;\r
+ setDirty();\r
+ }\r
+\r
+ void updateSG() {\r
+\r
+ if (node == null) {\r
+ node = variableInformation.node;\r
+ }\r
+\r
+ MouseInfo mi = mouseUtil.getMouseInfo(0);\r
+ if (mi == null)\r
+ return;\r
+\r
+ Point2D newPos = mi.canvasPosition;\r
+ double x = newPos.getX();\r
+ double y = newPos.getY();\r
+\r
+ AffineTransform origAt = node.getTransform();\r
+ double oldX = origAt.getTranslateX();\r
+ double oldY = origAt.getTranslateY();\r
+ AffineTransform move = new AffineTransform();\r
+ move.setToTranslation(x - oldX, y - oldY);\r
+ AffineTransform at2 = new AffineTransform(origAt);\r
+ at2.preConcatenate(move);\r
+ node.setTransform(at2);\r
+ setDirty();\r
+ }\r
+\r
+ public CreateVariablesShortcutParticipant(GraphToDiagramSynchronizer synchronizer) {\r
+ this.synchronizer = synchronizer;\r
+ }\r
+\r
+ @EventHandler(priority = -10)\r
+ public boolean handleKeyboardEvent(KeyEvent ke) {\r
+\r
+ KeyPressedEvent kpe;\r
+ if (ke instanceof KeyPressedEvent) {\r
+ \r
+ kpe = (KeyPressedEvent) ke;\r
+ \r
+ if (kpe.stateMask != java.awt.event.KeyEvent.SHIFT_DOWN_MASK || isEditing()) \r
+ return false;\r
+ \r
+ if (kpe.keyCode == java.awt.event.KeyEvent.VK_A) {\r
+ variableInformation = new VariableInformation(\r
+ java.awt.event.KeyEvent.VK_A,\r
+ "http://www.simantics.org/Sysdyn-1.0/AuxiliarySymbol",\r
+ (ShapeNode)AuxiliaryFactory.AUX_STATIC_IMAGE.init(parent)\r
+ );\r
+ } else if (kpe.keyCode == java.awt.event.KeyEvent.VK_S) {\r
+ variableInformation = new VariableInformation(\r
+ java.awt.event.KeyEvent.VK_S,\r
+ "http://www.simantics.org/Sysdyn-1.0/StockSymbol",\r
+ (ShapeNode)StockFactory.STOCK_IMAGE.init(parent)\r
+ );\r
+ } else if (kpe.keyCode == java.awt.event.KeyEvent.VK_C) {\r
+ variableInformation = new VariableInformation(\r
+ java.awt.event.KeyEvent.VK_C,\r
+ "http://www.simantics.org/Sysdyn-1.0/CloudSymbol",\r
+ (ShapeNode)CloudFactory.CLOUD_IMAGE.init(parent)\r
+ );\r
+ } else if (kpe.keyCode == java.awt.event.KeyEvent.VK_V) {\r
+ variableInformation = new VariableInformation(\r
+ java.awt.event.KeyEvent.VK_V,\r
+ "http://www.simantics.org/Sysdyn-1.0/ValveSymbol",\r
+ (ShapeNode)ValveFactory.VALVE_STATIC_IMAGE.init(parent)\r
+ );\r
+ } else if (kpe.keyCode == java.awt.event.KeyEvent.VK_I) {\r
+ variableInformation = new VariableInformation(\r
+ java.awt.event.KeyEvent.VK_I,\r
+ "http://www.simantics.org/Sysdyn-1.0/InputSymbol",\r
+ (ShapeNode)InputFactory.INPUT_IMAGE.init(parent)\r
+ );\r
+ }\r
+\r
+ if (variableInformation != null) {\r
+ updateSG();\r
+ return true;\r
+ }\r
+ }\r
+\r
+ KeyReleasedEvent kre;\r
+ if (ke instanceof KeyReleasedEvent) {\r
+ kre = (KeyReleasedEvent) ke;\r
+ \r
+ if (variableInformation != null\r
+ && (kre.keyCode == variableInformation.shortcutKey || kre.keyCode == java.awt.event.KeyEvent.VK_SHIFT)) {\r
+ if (node != null) {\r
+ variableInformation = null;\r
+ removeSG();\r
+ return true;\r
+ }\r
+ }\r
+ }\r
+\r
+ return false;\r
+\r
+ }\r
+\r
+ @EventHandler(priority = -10)\r
+ public boolean handleMouse(MouseMovedEvent e) {\r
+\r
+ if (variableInformation != null ) {\r
+ updateSG();\r
+ } else {\r
+ if (node != null) {\r
+ removeSG();\r
+ }\r
+ }\r
+ return false;\r
+ }\r
+\r
+\r
+ @EventHandler(priority = 100)\r
+ public boolean handleMouseEvent(MouseEvent me) {\r
+\r
+\r
+ MouseClickEvent mce;\r
+ if (me instanceof MouseClickEvent) {\r
+ mce = (MouseClickEvent) me;\r
+ } else {\r
+ return false;\r
+ }\r
+\r
+ if (!\r
+ (\r
+ mce.button == MouseEvent.LEFT_BUTTON && \r
+ variableInformation != null && \r
+ mce.stateMask == MouseEvent.SHIFT_MASK\r
+ )) \r
+ {\r
+ return false;\r
+ }\r
+\r
+\r
+ final IDiagram d = getHint(DiagramHints.KEY_DIAGRAM);\r
+ if (d == null)\r
+ return false;\r
+\r
+ DiagramUtils.mutateDiagram(d, new Callback<DiagramMutator>() {\r
+ @Override\r
+ public void run(DiagramMutator m) {\r
+\r
+ Resource r;\r
+ try {\r
+ r = SimanticsUI\r
+ .getSession()\r
+ .syncRequest(\r
+ Queries\r
+ .resource(variableInformation.symbolURI));\r
+ ElementClass ec = SimanticsUI.getSession().syncRequest(\r
+ DiagramRequests.getElementClass(r, diagram));\r
+\r
+ IElement element = m.newElement(ec);\r
+\r
+ // MouseUtil mutil = new MouseUtil();\r
+ MouseInfo minfo = mouseUtil.getMouseInfo(0);\r
+\r
+ //at least when using breakpoints this is possible\r
+ if(minfo == null) \r
+ return;\r
+\r
+ Point2D p = minfo.canvasPosition;\r
+ //FIXME - Arto element doesn't know its size at first. Hopefully temp fix.\r
+ p.setLocation(p.getX()-5.46, p.getY()+1);\r
+\r
+ ElementUtils.setPos(element, p);\r
+\r
+ } catch (DatabaseException e) {\r
+ ExceptionUtils.logAndShowError(e);\r
+ }\r
+\r
+ }\r
+ });\r
+\r
+ synchronizer.getCanvasContext().getContentContext().setDirty();\r
+\r
+ return true;\r
+ }\r
+\r
+ private class VariableInformation {\r
+ public String symbolURI;\r
+ public ShapeNode node;\r
+ public int shortcutKey;\r
+\r
+ public VariableInformation(int shortcutKey, String symbolURI, ShapeNode node) {\r
+ this.symbolURI = symbolURI;\r
+ this.node = node;\r
+ this.shortcutKey = shortcutKey;\r
+ }\r
+ }\r
+ \r
+ private boolean isEditing() {\r
+ int selectionId = 0;\r
+ Set<IElement> ss = selection.getSelection(selectionId);\r
+ if (ss.isEmpty()) {\r
+ return false;\r
+ }\r
+ for (IElement e : ss) {\r
+ for(Object o : e.getHints().values()) {\r
+ if (o instanceof TextNode) {\r
+ TextNode tn = (TextNode) o;\r
+ if(tn.isEditMode())\r
+ return true;\r
+ }\r
+ }\r
+ }\r
+ return false;\r
+ }\r
+\r
+}\r
--- /dev/null
+package org.simantics.sysdyn.ui.editor.participant;\r
+/*******************************************************************************\r
+ * Copyright (c) 2010 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+\r
+import java.awt.Shape;\r
+import java.awt.geom.Point2D;\r
+import java.awt.geom.Rectangle2D;\r
+import java.util.List;\r
+\r
+import org.simantics.diagram.participant.ConnectTool2;\r
+import org.simantics.g2d.canvas.Hints;\r
+import org.simantics.g2d.canvas.IToolMode;\r
+import org.simantics.g2d.canvas.impl.DependencyReflection.Dependency;\r
+import org.simantics.g2d.canvas.impl.DependencyReflection.Reference;\r
+import org.simantics.g2d.connection.IConnectionAdvisor;\r
+import org.simantics.g2d.diagram.DiagramHints;\r
+import org.simantics.g2d.diagram.handler.PickContext;\r
+import org.simantics.g2d.diagram.participant.Selection;\r
+import org.simantics.g2d.diagram.participant.TerminalPainter;\r
+import org.simantics.g2d.diagram.participant.pointertool.TerminalUtil;\r
+import org.simantics.g2d.diagram.participant.pointertool.TerminalUtil.TerminalInfo;\r
+import org.simantics.g2d.element.ElementClasses;\r
+import org.simantics.g2d.element.IElement;\r
+import org.simantics.g2d.element.IElementClassProvider;\r
+import org.simantics.g2d.event.EventHandlerReflection.EventHandler;\r
+import org.simantics.g2d.event.MouseEvent;\r
+import org.simantics.g2d.event.MouseEvent.MouseButtonPressedEvent;\r
+import org.simantics.g2d.participant.KeyUtil;\r
+import org.simantics.g2d.participant.MouseUtil;\r
+import org.simantics.g2d.participant.TransformUtil;\r
+import org.simantics.g2d.utils.GeometryUtils;\r
+import org.simantics.sysdyn.ui.editor.participant.SysdynElementClassProviders.ISysdynElementClassProvider;\r
+import org.simantics.sysdyn.ui.editor.routing.DependencyRouter;\r
+import org.simantics.sysdyn.ui.editor.routing.FlowRouter;\r
+import org.simantics.sysdyn.ui.elements2.AuxiliaryFactory;\r
+import org.simantics.sysdyn.ui.elements2.CloudFactory;\r
+import org.simantics.sysdyn.ui.elements2.InputFactory;\r
+import org.simantics.sysdyn.ui.elements2.ModuleFactory;\r
+import org.simantics.sysdyn.ui.elements2.connections.ConnectionClasses;\r
+\r
+/**\r
+ * Pointer tool does the following operations with mouse:\r
+ * - Selections\r
+ * - Scale\r
+ * - Rotate\r
+ * - Translate\r
+ * - Draws connections\r
+ *\r
+ *\r
+ * Pointer tool is active only when KEY_TOOLMODE is PointerToolMode\r
+ *\r
+ * TODO Pick rectangle not a point\r
+ *\r
+ * @author Toni Kalajainen\r
+ */\r
+public class PointerInteractor extends org.simantics.g2d.diagram.participant.pointertool.PointerInteractor {\r
+\r
+ @Dependency Selection selection;\r
+ @Dependency KeyUtil keys;\r
+ @Dependency TransformUtil util;\r
+ @Dependency PickContext pickContext;\r
+ @Dependency MouseUtil mice;\r
+ @Reference TerminalPainter terminalPainter;\r
+\r
+ public PointerInteractor(boolean clickSelect, boolean boxSelect, boolean dragElement, boolean dndDragElement, boolean connect, boolean doubleClickEdit, IElementClassProvider newConnectionClassProvider) {\r
+ super(clickSelect, boxSelect, dragElement, dndDragElement, connect, doubleClickEdit, newConnectionClassProvider);\r
+ }\r
+\r
+ @EventHandler(priority = TOOL_PRIORITY)\r
+ public boolean handlePress(MouseButtonPressedEvent me) {\r
+ if (!connects()) return false;\r
+ \r
+ IToolMode mode = getHint(Hints.KEY_TOOL);\r
+\r
+ if (mode != Hints.POINTERTOOL && mode != Hints.CONNECTTOOL) return false;\r
+ assertDependencies();\r
+ Point2D curCanvasPos = util.controlToCanvas(me.controlPosition, null);\r
+\r
+ // Pick Terminal\r
+ TerminalInfo ti = pickTerminal(me.controlPosition);\r
+\r
+ if((me.stateMask & MouseEvent.ALT_MASK) == 0) return false;\r
+\r
+ if(elementClassProvider != null) {\r
+ ConnectTool2 bsi = null;\r
+ if (ti != null) {\r
+\r
+ IElement terminalElement = ti.e;\r
+\r
+ if( me.button == MouseEvent.LEFT_BUTTON) {\r
+ if(terminalElement.getElementClass().getId().equals(CloudFactory.class.getSimpleName())) return false;\r
+ diagram.setHint(DiagramHints.ROUTE_ALGORITHM, new DependencyRouter());\r
+ diagram.setHint(DiagramHints.KEY_USE_CONNECTION_FLAGS, false);\r
+ ISysdynElementClassProvider secp = (ISysdynElementClassProvider)elementClassProvider;\r
+ secp.put(ElementClasses.CONNECTION, elementClassProvider.get(ConnectionClasses.DEPENDENCY));\r
+\r
+ } else if (me.button == MouseEvent.RIGHT_BUTTON) {\r
+ String id = terminalElement.getElementClass().getId();\r
+ if(id.equals(AuxiliaryFactory.class.getSimpleName())\r
+ || id.equals(InputFactory.class.getSimpleName())\r
+ || id.equals(ModuleFactory.class.getSimpleName())) return false;\r
+ diagram.setHint(DiagramHints.ROUTE_ALGORITHM, new FlowRouter(false));\r
+ diagram.setHint(DiagramHints.KEY_USE_CONNECTION_FLAGS, true);\r
+ ISysdynElementClassProvider secp = (ISysdynElementClassProvider)elementClassProvider;\r
+ secp.put(ElementClasses.CONNECTION, elementClassProvider.get(ConnectionClasses.FLOW));\r
+\r
+ }\r
+\r
+ IConnectionAdvisor advisor = diagram.getHint(DiagramHints.CONNECTION_ADVISOR);\r
+ if (advisor == null || (advisor != null && advisor.canBeginConnection(null, ti.e, ti.t))) {\r
+ bsi = new SysdynConnectTool(ti, me.mouseId, curCanvasPos);\r
+ }\r
+ } \r
+ else if (me.button == MouseEvent.RIGHT_BUTTON) {\r
+ // Start connection out of thin air, without a terminal.\r
+ diagram.setHint(DiagramHints.ROUTE_ALGORITHM, new FlowRouter(false));\r
+ diagram.setHint(DiagramHints.KEY_USE_CONNECTION_FLAGS, true);\r
+ ISysdynElementClassProvider secp = (ISysdynElementClassProvider)elementClassProvider;\r
+ secp.put(ElementClasses.CONNECTION, elementClassProvider.get(ConnectionClasses.FLOW));\r
+ bsi = new SysdynConnectTool(null, me.mouseId, curCanvasPos);\r
+ }\r
+\r
+ if (bsi != null) {\r
+ getContext().add(bsi);\r
+ return true;\r
+ }\r
+\r
+ }\r
+ return false;\r
+ }\r
+\r
+ public List<TerminalInfo> pickTerminals(Point2D controlPos)\r
+ {\r
+ Rectangle2D controlPickRect = new Rectangle2D.Double(controlPos.getX()-PointerInteractor.PICK_DIST, controlPos.getY()-PointerInteractor.PICK_DIST, PointerInteractor.PICK_DIST*2+1, PointerInteractor.PICK_DIST*2+1);\r
+ Shape canvasPickRect = GeometryUtils.transformShape(controlPickRect, util.getInverseTransform());\r
+ List<TerminalInfo> ti = TerminalUtil.pickTerminals(diagram, canvasPickRect, false, true);\r
+ return ti;\r
+ }\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2010 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.ui.editor.participant;\r
+\r
+import org.simantics.databoard.Bindings;\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.Statement;\r
+import org.simantics.db.WriteGraph;\r
+import org.simantics.db.common.utils.NameUtils;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.db.exception.ServiceException;\r
+import org.simantics.diagram.synchronization.ISynchronizationContext;\r
+import org.simantics.diagram.synchronization.graph.CopyAdvisorUtil;\r
+import org.simantics.layer0.Layer0;\r
+import org.simantics.modeling.ComponentUtils;\r
+import org.simantics.modeling.mapping.ComponentCopyAdvisor;\r
+import org.simantics.sysdyn.SysdynResource;\r
+import org.simantics.utils.datastructures.BinaryFunction;\r
+\r
+public class SysdynComponentCopyAdvisor extends ComponentCopyAdvisor{\r
+\r
+ @Override\r
+ public Object copy(ISynchronizationContext context, WriteGraph graph, Resource source, Resource sourceContainer, Resource targetContainer) throws DatabaseException {\r
+ \r
+ BinaryFunction<Boolean, ReadGraph, Statement> tester = new BinaryFunction<Boolean, ReadGraph, Statement>() {\r
+\r
+ @Override\r
+ public Boolean call(ReadGraph graph, Statement statement) {\r
+ SysdynResource sr = SysdynResource.getInstance(graph);\r
+ try {\r
+ if(graph.isInstanceOf(statement.getSubject(), sr.IndependentVariable)) {\r
+ if(statement.getPredicate().equals(sr.HasExpressions))\r
+ return true;\r
+ }\r
+ } catch (ServiceException e) {\r
+ e.printStackTrace();\r
+ }\r
+ return false;\r
+ }\r
+ \r
+ };\r
+ \r
+ Resource copy = CopyAdvisorUtil.copy(graph, source, tester);\r
+ \r
+ renameComponent(context, graph, source, copy, sourceContainer, targetContainer);\r
+ return copy;\r
+ }\r
+ \r
+\r
+ public static String renameComponent(ISynchronizationContext context, WriteGraph graph, Resource source,\r
+ Resource copy, Resource sourceContainer, Resource targetContainer) throws DatabaseException {\r
+ Layer0 l0 = Layer0.getInstance(graph);\r
+ String copyName = NameUtils.getSafeName(graph, copy);\r
+ Resource configurationRoot = ComponentUtils.getCompositeConfigurationRoot(graph, targetContainer);\r
+ String name = NameUtils.findFreshName(graph, copyName, configurationRoot, l0.ConsistsOf, "%s%d");\r
+ graph.claimLiteral(copy, l0.HasName, name, Bindings.STRING);\r
+ return name;\r
+ }\r
+}\r
--- /dev/null
+package org.simantics.sysdyn.ui.editor.participant;\r
+\r
+import java.awt.BasicStroke;\r
+import java.awt.Color;\r
+import java.awt.geom.AffineTransform;\r
+import java.awt.geom.Path2D;\r
+import java.awt.geom.Point2D;\r
+import java.awt.geom.Rectangle2D;\r
+import java.util.ArrayList;\r
+import java.util.Collection;\r
+import java.util.Collections;\r
+import java.util.Deque;\r
+import java.util.Iterator;\r
+import java.util.List;\r
+\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.UndoContext;\r
+import org.simantics.db.WriteGraph;\r
+import org.simantics.db.common.UndoWriteRequest;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.db.request.Read;\r
+import org.simantics.diagram.participant.ConnectTool2;\r
+import org.simantics.diagram.participant.ConnectionBuilder;\r
+import org.simantics.diagram.participant.ControlPoint;\r
+import org.simantics.diagram.ui.DiagramModelHints;\r
+import org.simantics.g2d.canvas.impl.SGNodeReflection.SGInit;\r
+import org.simantics.g2d.connection.IConnectionAdvisor;\r
+import org.simantics.g2d.diagram.DiagramHints;\r
+import org.simantics.g2d.diagram.handler.Topology.Terminal;\r
+import org.simantics.g2d.diagram.participant.pointertool.TerminalUtil;\r
+import org.simantics.g2d.diagram.participant.pointertool.TerminalUtil.TerminalInfo;\r
+import org.simantics.g2d.element.ElementClass;\r
+import org.simantics.g2d.element.ElementClasses;\r
+import org.simantics.g2d.element.ElementUtils;\r
+import org.simantics.g2d.element.IElement;\r
+import org.simantics.g2d.element.handler.EdgeVisuals.EdgeEnd;\r
+import org.simantics.g2d.element.handler.impl.StaticObjectAdapter;\r
+import org.simantics.g2d.element.impl.Element;\r
+import org.simantics.g2d.elementclass.BranchPoint;\r
+import org.simantics.g2d.elementclass.BranchPointClass;\r
+import org.simantics.g2d.elementclass.FlagClass;\r
+import org.simantics.g2d.event.MouseEvent.MouseButtonEvent;\r
+import org.simantics.g2d.event.MouseEvent.MouseButtonPressedEvent;\r
+import org.simantics.g2d.event.MouseEvent.MouseMovedEvent;\r
+import org.simantics.g2d.routing.Constants;\r
+import org.simantics.g2d.routing.IConnection;\r
+import org.simantics.g2d.routing.IRouter2;\r
+import org.simantics.g2d.routing.TrivialRouter2;\r
+import org.simantics.g2d.snap.ISnapAdvisor;\r
+import org.simantics.g2d.utils.GeometryUtils;\r
+import org.simantics.scenegraph.g2d.G2DParentNode;\r
+import org.simantics.scenegraph.g2d.nodes.ShapeNode;\r
+import org.simantics.structural2.modelingRules.ConnectionJudgement;\r
+import org.simantics.sysdyn.SysdynResource;\r
+import org.simantics.sysdyn.ui.editor.routing.FlowRouter;\r
+import org.simantics.sysdyn.ui.elements2.ValveFactory.ValveSceneGraph;\r
+import org.simantics.sysdyn.ui.elements2.connections.ConnectionClasses;\r
+import org.simantics.ui.SimanticsUI;\r
+import org.simantics.utils.datastructures.Callback;\r
+import org.simantics.utils.ui.ExceptionUtils;\r
+\r
+public class SysdynConnectTool extends ConnectTool2 {\r
+ \r
+ public SysdynConnectTool(TerminalInfo startTerminal, int mouseId,\r
+ Point2D startCanvasPos) {\r
+ super(startTerminal, mouseId, startCanvasPos);\r
+ }\r
+\r
+\r
+ @SGInit\r
+ public void initSG(G2DParentNode parent) {\r
+ ghostNode = parent.addNode(G2DParentNode.class);\r
+ ghostNode.setZIndex(PAINT_PRIORITY);\r
+\r
+ ShapeNode pathNode = ghostNode.getOrCreateNode("path", ShapeNode.class);\r
+ pathNode.setColor(Color.BLACK);\r
+ pathNode.setStroke(new BasicStroke(1f));\r
+ pathNode.setScaleStroke(true);\r
+ pathNode.setZIndex(0);\r
+\r
+ G2DParentNode points = ghostNode.getOrCreateNode("points", G2DParentNode.class);\r
+ points.setZIndex(1);\r
+\r
+ updateSG();\r
+ }\r
+\r
+ \r
+ protected TerminalInfo createFlag(EdgeEnd connectionEnd) {\r
+ ElementClass flagClass = elementClassProvider.get(ElementClasses.FLAG);\r
+ IElement e = Element.spawnNew(flagClass);\r
+\r
+ e.setHint(FlagClass.KEY_FLAG_TYPE, endToFlagType(connectionEnd));\r
+ e.setHint(FlagClass.KEY_FLAG_MODE, FlagClass.Mode.Internal);\r
+\r
+ TerminalInfo ti = new TerminalInfo();\r
+ ti.e = e;\r
+ \r
+ // start: this part changed to support overlapping terminals\r
+ ArrayList<Terminal> terminals = new ArrayList<Terminal>();\r
+ ElementUtils.getTerminals(e, terminals, false);\r
+ ti.t = terminals.get(0);\r
+ // end\r
+ \r
+ ti.posElem = TerminalUtil.getTerminalPosOnElement(e, ti.t);\r
+ ti.posDia = TerminalUtil.getTerminalPosOnDiagram(e, ti.t);\r
+\r
+ return ti;\r
+ }\r
+ \r
+ static class Segment {\r
+ public final ControlPoint begin;\r
+ public final ControlPoint end;\r
+ public Path2D path;\r
+\r
+ public Segment(ControlPoint begin, ControlPoint end) {\r
+ this.begin = begin;\r
+ this.end = end;\r
+ }\r
+\r
+ @Override\r
+ public String toString() {\r
+ return "Segment[begin=" + begin + ", end=" + end + ", path=" + path + "]";\r
+ }\r
+ }\r
+ \r
+ private List<Segment> toSegments(Deque<ControlPoint> points) {\r
+ if (points.isEmpty())\r
+ return Collections.emptyList();\r
+\r
+ List<Segment> segments = new ArrayList<Segment>();\r
+\r
+ Iterator<ControlPoint> it = points.iterator();\r
+ ControlPoint prev = it.next();\r
+ while (it.hasNext()) {\r
+ ControlPoint next = it.next();\r
+ segments.add(new Segment(prev, next));\r
+ prev = next;\r
+ }\r
+\r
+ return segments;\r
+ }\r
+ \r
+ public interface SysdynConnection extends IConnection { }\r
+ \r
+ protected void updateSG() {\r
+ if (controlPoints.isEmpty())\r
+ return;\r
+\r
+ // Route connection segments separately\r
+ IRouter2 router = ElementUtils.getHintOrDefault(diagram, DiagramHints.ROUTE_ALGORITHM, TrivialRouter2.INSTANCE);\r
+ final List<Segment> segments = toSegments(controlPoints);\r
+ //System.out.println("controlpoints: " + controlPoints);\r
+ //System.out.println("segments: " + segments);\r
+ router.route(new SysdynConnection() {\r
+ @Override\r
+ public Collection<? extends Object> getSegments() {\r
+ return segments;\r
+ }\r
+\r
+ @Override\r
+ public Connector getBegin(Object seg) {\r
+ return getConnector(((Segment) seg).begin);\r
+ }\r
+\r
+ @Override\r
+ public Connector getEnd(Object seg) {\r
+ return getConnector(((Segment) seg).end);\r
+ }\r
+\r
+ private Connector getConnector(ControlPoint cp) {\r
+ Connector c = new Connector();\r
+ c.x = cp.getPosition().getX();\r
+ c.y = cp.getPosition().getY();\r
+ \r
+ c.allowedDirections = Constants.EAST_FLAG | Constants.WEST_FLAG\r
+ | Constants.NORTH_FLAG | Constants.SOUTH_FLAG;\r
+\r
+ TerminalInfo ti = cp.getAttachedTerminal();\r
+ if (ti != null && (ti != startFlag && ti != endFlag)) {\r
+ if(ti.e.getElementClass().containsClass(ValveSceneGraph.class)) {\r
+ Rectangle2D bounds = ElementUtils.getElementBoundsOnDiagram(ti.e).getBounds2D();\r
+ c.parentObstacle = new Rectangle2D.Double(\r
+ bounds.getCenterX() - FlowRouter.OFFSET,\r
+ bounds.getCenterY() - FlowRouter.OFFSET, \r
+ FlowRouter.OFFSET * 2,\r
+ FlowRouter.OFFSET * 2);\r
+ } else {\r
+ c.parentObstacle = ElementUtils.getElementBoundsOnDiagram(ti.e).getBounds2D();\r
+ }\r
+ } else if (ti != null && ti == startFlag) {\r
+ c.parentObstacle = GeometryUtils.transformRectangle(AffineTransform.getTranslateInstance(c.x, c.y),\r
+ ElementUtils.getElementBoundsOnDiagram(ti.e).getBounds2D());\r
+ } else {\r
+ c.parentObstacle = GeometryUtils.transformRectangle(AffineTransform.getTranslateInstance(c.x, c.y),\r
+ BranchPointClass.DEFAULT_IMAGE2.getBounds());\r
+ \r
+ }\r
+\r
+ return c;\r
+ }\r
+\r
+ @Override\r
+ public void setPath(Object seg, Path2D path) {\r
+ ((Segment) seg).path = (Path2D) path.clone();\r
+ }\r
+\r
+ private int toAllowedDirections(BranchPoint.Direction direction) {\r
+ switch (direction) {\r
+ case Any:\r
+ return 0xf;\r
+ case Horizontal:\r
+ return Constants.EAST_FLAG | Constants.WEST_FLAG;\r
+ case Vertical:\r
+ return Constants.NORTH_FLAG | Constants.SOUTH_FLAG;\r
+ default:\r
+ throw new IllegalArgumentException("unrecognized direction: " + direction);\r
+ }\r
+ }\r
+ });\r
+\r
+ // Combine the routed paths\r
+ Path2D path = new Path2D.Double();\r
+ for (Segment seg : segments) {\r
+ //System.out.println("SEG: " + seg);\r
+ if (seg.path != null)\r
+ path.append(seg.path.getPathIterator(null), true);\r
+ }\r
+ \r
+ // Create scene graph to visualize the connection.\r
+ ShapeNode pathNode = ghostNode.getOrCreateNode("path", ShapeNode.class);\r
+ pathNode.setShape(path);\r
+ \r
+ /*\r
+ * Removed Points\r
+ */\r
+ \r
+ setDirty();\r
+ }\r
+ \r
+ \r
+ @Override\r
+ protected Object canConnect(final IConnectionAdvisor advisor, final IElement endElement, final Terminal endTerminal) {\r
+ final IElement se = startTerminal != null ? startTerminal.e : startFlag.e;\r
+ final Terminal st = startTerminal != null ? startTerminal.t : null;\r
+\r
+ if(se.equals(endElement)) return null;\r
+ if(Boolean.FALSE.equals(diagram.getHint(DiagramHints.KEY_USE_CONNECTION_FLAGS)) && endElement == null) {\r
+ return null;\r
+ }\r
+\r
+ if(endElement == null && endTerminal == null)\r
+ return advisor.canBeConnected(null, se, st, endElement, endTerminal);\r
+\r
+ try {\r
+ return SimanticsUI.getSession().syncRequest(new Read<Object>() {\r
+\r
+ @Override\r
+ public Object perform(ReadGraph g) throws DatabaseException {\r
+\r
+ // Checking if connection type can be connected to the intended endElement\r
+ SysdynResource sr = SysdynResource.getInstance(g);\r
+ StaticObjectAdapter soa = endElement.getElementClass().getSingleItem(StaticObjectAdapter.class);\r
+ Resource end = soa.adapt(Resource.class);\r
+ ElementClass dependency = elementClassProvider.get(ConnectionClasses.DEPENDENCY);\r
+ ElementClass flow = elementClassProvider.get(ConnectionClasses.FLOW);\r
+ ElementClass currentConnection = elementClassProvider.get(ElementClasses.CONNECTION);\r
+ if(currentConnection.equals(dependency)) {\r
+ if(end.equals(sr.CloudSymbol)) return null;\r
+ soa = se.getElementClass().getSingleItem(StaticObjectAdapter.class);\r
+ Resource start = soa.adapt(Resource.class);\r
+ if(g.isInheritedFrom(start, sr.ModuleSymbol) && !end.equals(sr.InputSymbol)) return null;\r
+ if(end.equals(sr.StockSymbol)) return null;\r
+ } else if (currentConnection.equals(flow)) {\r
+ if(!(end.equals(sr.StockSymbol) || end.equals(sr.ValveSymbol) || end.equals(sr.CloudSymbol))) return null;\r
+ } else {\r
+ return null;\r
+ }\r
+\r
+\r
+ if (advisor == null)\r
+ return Boolean.TRUE; \r
+ return advisor.canBeConnected(g, se, st, endElement, endTerminal);\r
+ }\r
+\r
+ });\r
+ } catch(DatabaseException e) {\r
+ e.printStackTrace();\r
+ return null;\r
+ }\r
+\r
+ }\r
+ \r
+ protected boolean processMouseMove(MouseMovedEvent me) {\r
+ mouseHasMoved = true;\r
+\r
+ Point2D mouseControlPos = me.controlPosition;\r
+ Point2D mouseCanvasPos = util.controlToCanvas(mouseControlPos, new Point2D.Double());\r
+\r
+ ISnapAdvisor snapAdvisor = getHint(DiagramHints.SNAP_ADVISOR);\r
+ if (snapAdvisor != null)\r
+ snapAdvisor.snap(mouseCanvasPos);\r
+\r
+ // Record last snapped canvas position of mouse.\r
+ this.lastMouseCanvasPos.setLocation(mouseCanvasPos);\r
+\r
+ if (isEndingInFlag()) {\r
+ endFlagNode.setTransform(AffineTransform.getTranslateInstance(mouseCanvasPos.getX(), mouseCanvasPos.getY()));\r
+ }\r
+\r
+ List<TerminalInfo> tiList = ((org.simantics.sysdyn.ui.editor.participant.PointerInteractor)pi).pickTerminals(me.controlPosition);\r
+ TerminalInfo ti = null;\r
+\r
+ IConnectionAdvisor advisor = diagram.getHint(DiagramHints.CONNECTION_ADVISOR);\r
+ for(TerminalInfo info : tiList) {\r
+ if(advisor == null || info.e == null || info.t == null)\r
+ continue;\r
+ Object canConnect = canConnect(advisor, info.e, info.t);\r
+ if (canConnect != null) {\r
+ ti = info;\r
+ break;\r
+ }\r
+ }\r
+ \r
+ if (ti != null && !isStartTerminal(ti.e, ti.t)) {\r
+ Object canConnect = canConnect(ti.e, ti.t);\r
+ if (canConnect != null) {\r
+ connectionJudgment = (ConnectionJudgement) canConnect;\r
+\r
+ if (!isEndingInFlag() || !TerminalUtil.isSameTerminal(ti, endTerminal)) {\r
+ controlPoints.getLast()\r
+ .setPosition(ti.posDia)\r
+ .setAttachedToTerminal(ti);\r
+\r
+ endTerminal = ti;\r
+ }\r
+\r
+ // Make sure that we are ending with a flag if ALT is pressed\r
+ // and no end terminal is defined.\r
+ endWithoutTerminal(lastMouseCanvasPos, shouldEndWithFlag(me));\r
+\r
+ updateSG();\r
+ return false;\r
+ }\r
+ }\r
+\r
+ connectionJudgment = null;\r
+ if (isEndTerminalDefined()) {\r
+ // CASE: Mouse was previously on top of a valid terminal to end\r
+ // the connection. Now the mouse has been moved where there is\r
+ // no longer a terminal to connect to.\r
+ //\r
+ // => Disconnect the last edge segment from the previous\r
+ // terminal, mark endElement/endTerminal non-existent\r
+ // and connect the disconnected edge to a new branch point.\r
+\r
+ controlPoints.getLast()\r
+ .setPosition(mouseCanvasPos)\r
+ .setDirection(calculateCurrentBranchPointDirection())\r
+ .setAttachedToTerminal(null);\r
+\r
+ endTerminal = null;\r
+ } else {\r
+ // CASE: Mouse was not previously on top of a valid ending\r
+ // element terminal.\r
+ //\r
+ // => Move and re-orient last branch point.\r
+\r
+ controlPoints.getLast()\r
+ .setPosition(mouseCanvasPos)\r
+ .setDirection(calculateCurrentBranchPointDirection());\r
+ }\r
+\r
+ // Make sure that we are ending with a flag if ALT is pressed and no end\r
+ // terminal is defined.\r
+ endWithoutTerminal(lastMouseCanvasPos, shouldEndWithFlag(me));\r
+\r
+ updateSG();\r
+\r
+ return false;\r
+ }\r
+ \r
+ Point2D mousePosition;\r
+ \r
+ protected boolean processMouseButtonPress(MouseButtonPressedEvent e) {\r
+ MouseButtonEvent me = e;\r
+ mousePosition = me.controlPosition;\r
+ return super.processMouseButtonPress(e);\r
+ }\r
+\r
+ @Override\r
+ protected void createConnection() {\r
+ \r
+ if(this.connectionJudgment == null) return;\r
+ \r
+ final UndoContext uctx = diagram.getHint(DiagramModelHints.KEY_UNDO_CONTEXT);\r
+ final ConnectionJudgement judgment = this.connectionJudgment;\r
+ // ConnectionBuilder changed to SysdynconnectionBuilder to support overlapping terminals and valve creation\r
+ final ConnectionBuilder builder = new SysdynConnectionBuilder(this.diagram);\r
+ final Deque<ControlPoint> controlPoints = this.controlPoints;\r
+ final TerminalInfo startTerminal = this.startTerminal;\r
+ final TerminalInfo endTerminal = this.endTerminal;\r
+\r
+ SimanticsUI.getSession().asyncRequest(new UndoWriteRequest(uctx, true) {\r
+ @Override\r
+ public void perform(WriteGraph graph) throws DatabaseException {\r
+ builder.create(graph, judgment, controlPoints, startTerminal, endTerminal);\r
+ }\r
+ }, new Callback<DatabaseException>() {\r
+ @Override\r
+ public void run(DatabaseException parameter) {\r
+ if (parameter != null)\r
+ ExceptionUtils.logAndShowError(parameter);\r
+ }\r
+ });\r
+ } \r
+}\r
--- /dev/null
+package org.simantics.sysdyn.ui.editor.participant;\r
+\r
+import java.awt.geom.AffineTransform;\r
+import java.awt.geom.Point2D;\r
+import java.util.ArrayList;\r
+import java.util.Deque;\r
+import java.util.Iterator;\r
+import java.util.List;\r
+\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.WriteGraph;\r
+import org.simantics.db.common.utils.OrderedSetUtils;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.diagram.content.ConnectionUtil;\r
+import org.simantics.diagram.participant.ConnectionBuilder;\r
+import org.simantics.diagram.participant.ControlPoint;\r
+import org.simantics.diagram.stubs.DiagramResource;\r
+import org.simantics.diagram.stubs.G2DResource;\r
+import org.simantics.diagram.ui.DiagramModelHints;\r
+import org.simantics.g2d.diagram.IDiagram;\r
+import org.simantics.g2d.diagram.handler.Topology.Terminal;\r
+import org.simantics.g2d.diagram.participant.pointertool.TerminalUtil;\r
+import org.simantics.g2d.diagram.participant.pointertool.TerminalUtil.TerminalInfo;\r
+import org.simantics.g2d.element.ElementClass;\r
+import org.simantics.g2d.element.ElementClasses;\r
+import org.simantics.g2d.element.ElementHints;\r
+import org.simantics.g2d.element.ElementUtils;\r
+import org.simantics.g2d.element.IElement;\r
+import org.simantics.g2d.element.handler.EdgeVisuals.EdgeEnd;\r
+import org.simantics.g2d.element.impl.Element;\r
+import org.simantics.g2d.elementclass.FlagClass;\r
+import org.simantics.layer0.Layer0;\r
+import org.simantics.structural2.modelingRules.ConnectionJudgement;\r
+import org.simantics.structural2.modelingRules.IModelingRules;\r
+import org.simantics.sysdyn.ui.elements2.SysdynElementClasses;\r
+import org.simantics.sysdyn.ui.elements2.ValveFactory;\r
+import org.simantics.sysdyn.ui.elements2.connections.ConnectionClasses;\r
+import org.simantics.utils.datastructures.Pair;\r
+\r
+public class SysdynConnectionBuilder extends ConnectionBuilder{\r
+\r
+ public SysdynConnectionBuilder(IDiagram diagram) {\r
+ super(diagram);\r
+ }\r
+\r
+ /**\r
+ * @param graph\r
+ * @param judgment\r
+ * @param controlPoints\r
+ * @param startTerminal\r
+ * @param endTerminal\r
+ * @throws DatabaseException\r
+ */\r
+ public void create(WriteGraph graph, ConnectionJudgement judgment, Deque<ControlPoint> controlPoints,\r
+ TerminalInfo startTerminal, TerminalInfo endTerminal) throws DatabaseException {\r
+ // If needs a valve, we will create two separate connections\r
+ if(needsValve(startTerminal, endTerminal)) {\r
+ createValveAndConnections(graph, judgment, controlPoints, startTerminal, endTerminal);\r
+ } \r
+ // If no need for valve, just call createConnection with false on createValve parameter\r
+ else {\r
+ createConnection(graph, judgment, controlPoints, startTerminal, endTerminal, false);\r
+ }\r
+ }\r
+ /**\r
+ * @param graph\r
+ * @param judgment\r
+ * @param controlPoints\r
+ * @param startTerminal\r
+ * @param endTerminal\r
+ * @throws DatabaseException\r
+ */\r
+ public TerminalInfo createConnection(WriteGraph graph, ConnectionJudgement judgment, Deque<ControlPoint> controlPoints,\r
+ TerminalInfo startTerminal, TerminalInfo endTerminal, boolean createValve) throws DatabaseException {\r
+ TerminalInfo newValve = null;\r
+\r
+ this.cu = new ConnectionUtil(graph);\r
+\r
+ // 1. Get diagram connection to construct.\r
+ Resource connection = getOrCreateConnection(graph, startTerminal, endTerminal);\r
+\r
+ // 2. Add branch points\r
+ List<Pair<ControlPoint, Resource>> bps = createBranchPoints(graph, connection, controlPoints);\r
+ \r
+ // 3. Create edges between branch points.\r
+ Resource firstBranchPoint = null;\r
+ Resource lastBranchPoint = null;\r
+ if (!bps.isEmpty()) {\r
+ Iterator<Pair<ControlPoint, Resource>> it = bps.iterator();\r
+ Pair<ControlPoint, Resource> prev = it.next();\r
+ firstBranchPoint = prev.second;\r
+ while (it.hasNext()) {\r
+ Pair<ControlPoint, Resource> next = it.next();\r
+ cu.connect(prev.second, next.second);\r
+ prev = next;\r
+ }\r
+ lastBranchPoint = prev.second;\r
+ }\r
+\r
+ // 4. Connect start/end terminals if those exist.\r
+ // If first/lastBranchPoint != null, connect to those.\r
+ // Otherwise connect the start/end terminals together.\r
+ Resource startConnector = null;\r
+ Resource endConnector = null;\r
+ IElement startFlag = null;\r
+ IElement endFlag = null;\r
+\r
+ if (startTerminal != null) {\r
+ startConnector = createConnectorForNode(graph, connection, startTerminal, EdgeEnd.Begin, judgment);\r
+ } else if (createFlags) {\r
+ startFlag = createFlag(graph, connection, EdgeEnd.Begin, controlPoints.getFirst(), FlagClass.Type.In, "");\r
+ ArrayList<Terminal> terminals = new ArrayList<Terminal>();\r
+ ElementUtils.getTerminals(startFlag, terminals, false);\r
+ Terminal st = terminals.get(1);\r
+ startConnector = createConnectorForNode(graph, connection, (Resource) ElementUtils.getObject(startFlag),\r
+ st, EdgeEnd.Begin, judgment);\r
+ }\r
+\r
+ if (endTerminal != null) {\r
+ endConnector = createConnectorForNode(graph, connection, endTerminal, EdgeEnd.End, judgment);\r
+ } else if (createFlags) {\r
+ if(createValve)\r
+ endFlag = createValveElement(graph, connection, EdgeEnd.End, controlPoints.getLast());\r
+ else\r
+ endFlag = createFlag(graph, connection, EdgeEnd.End, controlPoints.getLast(), FlagClass.Type.Out, "");\r
+ ArrayList<Terminal> terminals = new ArrayList<Terminal>();\r
+ ElementUtils.getTerminals(endFlag, terminals, false);\r
+ Terminal et = terminals.get(0);\r
+ endConnector = createConnectorForNode(graph, connection, (Resource) ElementUtils.getObject(endFlag),\r
+ et, EdgeEnd.End, judgment);\r
+ \r
+ if(createValve) {\r
+ newValve = new TerminalInfo();\r
+ newValve.e = endFlag;\r
+ newValve.t = terminals.get(1);\r
+ newValve.posElem = TerminalUtil.getTerminalPosOnElement(endFlag, newValve.t);\r
+ newValve.posDia = TerminalUtil.getTerminalPosOnDiagram(endFlag, newValve.t);\r
+ }\r
+ }\r
+\r
+ if (firstBranchPoint == null || lastBranchPoint == null) {\r
+ cu.connect(startConnector, endConnector);\r
+ } else {\r
+ cu.connect(startConnector, firstBranchPoint);\r
+ cu.connect(lastBranchPoint, endConnector);\r
+ }\r
+\r
+ // 5. Finally, set connection type according to modelling rules\r
+ IModelingRules modelingRules = diagram.getHint(DiagramModelHints.KEY_MODELING_RULES);\r
+ if (judgment.connectionType != null && modelingRules != null) {\r
+ modelingRules.setConnectionType(graph, connection, judgment.connectionType);\r
+ }\r
+\r
+ this.cu = null;\r
+ return newValve;\r
+ }\r
+ \r
+ \r
+ /**\r
+ * @param graph\r
+ * @param connection\r
+ * @param end\r
+ * @param cp\r
+ * @param type\r
+ * @return an element describing the new created flag resource\r
+ * @throws DatabaseException\r
+ */\r
+ public IElement createValveElement(WriteGraph graph, Resource connection, EdgeEnd end, ControlPoint cp) throws DatabaseException {\r
+ ElementClass valveClass = elementClassProvider.get(SysdynElementClasses.VALVE);\r
+ IElement valveElement = Element.spawnNew(valveClass);\r
+ Resource valveClassResource = ElementUtils.checkedAdapt(valveClass, Resource.class);\r
+\r
+ Layer0 L0 = Layer0.getInstance(graph);\r
+ G2DResource G2D = G2DResource.getInstance(graph);\r
+ DiagramResource DIA = DiagramResource.getInstance(graph);\r
+\r
+ Resource valve = graph.newResource();\r
+ graph.claim(valve, L0.InstanceOf, null, valveClassResource);\r
+ valveElement.setHint(ElementHints.KEY_OBJECT, valve);\r
+\r
+ OrderedSetUtils.add(graph, diagramResource, valve);\r
+\r
+ AffineTransform at = AffineTransform.getTranslateInstance(cp.getPosition().getX(), cp.getPosition().getY());\r
+ valveElement.setHint(ElementHints.KEY_TRANSFORM, at);\r
+ double[] matrix = new double[6];\r
+ at.getMatrix(matrix);\r
+ graph.claimLiteral(valve, DIA.HasTransform, G2D.Transform, matrix);\r
+\r
+ // Put the element on all the currently active layers if possible.\r
+ if (layerManager != null) {\r
+ layerManager.removeFromAllLayers(graph, valve);\r
+ layerManager.putElementOnVisibleLayers(diagram, graph, valve);\r
+ }\r
+\r
+ return valveElement;\r
+ }\r
+ \r
+ private boolean needsValve(TerminalInfo startTerminal, TerminalInfo endTerminal) {\r
+ if (!elementClassProvider.get(ElementClasses.CONNECTION)\r
+ .equals(elementClassProvider.get(ConnectionClasses.FLOW))) \r
+ return false;\r
+ if(startTerminal != null && startTerminal.e != null && startTerminal.e.getElementClass().getId().equals(ValveFactory.class.getSimpleName())) {\r
+ return false;\r
+ } else if(endTerminal != null && endTerminal.e != null && endTerminal.e.getElementClass().getId().equals(ValveFactory.class.getSimpleName())) {\r
+ return false;\r
+ }\r
+ return true;\r
+ }\r
+ \r
+ private void createValveAndConnections(WriteGraph graph, ConnectionJudgement judgment, Deque<ControlPoint> controlPoints,\r
+ TerminalInfo startTerminal, TerminalInfo endTerminal) throws DatabaseException {\r
+ \r
+ ControlPoint cpfirst = controlPoints.getFirst();\r
+ ControlPoint cplast = controlPoints.getLast();\r
+\r
+ // Set the position in the middle of the route\r
+ double startX = cpfirst.getPosition().getX();\r
+ double startY = cpfirst.getPosition().getY();\r
+ double x = cplast.getPosition().getX();\r
+ double y = cplast.getPosition().getY();\r
+ Point2D pos = new Point2D.Double(startX - (startX - x) / 2, startY - (startY - y) / 2);\r
+ \r
+ // Replace the last control point with the control point in the middle\r
+ controlPoints.getLast().setPosition(pos);\r
+\r
+ // Create a connection to a new valve and get the new valve\r
+ TerminalInfo newValve = createConnection(graph, judgment, controlPoints, startTerminal, null, true);\r
+ \r
+ // Replace the last control point with the original control point\r
+ controlPoints.getLast().setPosition(x, y);\r
+ \r
+ // Create a connection starting from the new valve\r
+ createConnection(graph, judgment, controlPoints, newValve, endTerminal, false);\r
+ }\r
+}\r
--- /dev/null
+package org.simantics.sysdyn.ui.editor.participant;\r
+\r
+import java.util.HashMap;\r
+import java.util.Map;\r
+\r
+import org.simantics.g2d.element.ElementClass;\r
+import org.simantics.g2d.element.ElementClassProviders;\r
+import org.simantics.g2d.element.IElementClassProvider;\r
+\r
+public class SysdynElementClassProviders extends ElementClassProviders {\r
+ \r
+ /**\r
+ * Create an element class provider that based on the specified map. The\r
+ * provider will directly access the map with the received keys. The\r
+ * argument map will be copied.\r
+ * \r
+ * @param map the map to use for element class provision\r
+ * @return <code>null</code> if there is no provider for the specified key\r
+ */\r
+ public static IElementClassProvider mappedProvider(Map<Object, ElementClass> map) {\r
+ // Copy the map as a safety measure\r
+ final Map<Object, ElementClass> copy = new HashMap<Object, ElementClass>(map);\r
+ return new ISysdynElementClassProvider() {\r
+ @Override\r
+ public ElementClass get(Object key) {\r
+ return copy.get(key);\r
+ }\r
+\r
+ @Override\r
+ public void put(Object key, ElementClass value) {\r
+ copy.put(key, value);\r
+ }\r
+\r
+ };\r
+ }\r
+ \r
+ /**\r
+ * Does the same as {@link #mappedProvider(Map)}, the map is simply provided\r
+ * differently. The specified array must contain\r
+ * <code>[key, ElementClass, key, ElementClass, ...]</code>.\r
+ * \r
+ * @param map the map to use for element class provision\r
+ * @return <code>null</code> if there is no provider for the specified key\r
+ */\r
+ public static IElementClassProvider mappedProvider(Object... keyClassPairs) {\r
+ if (keyClassPairs.length % 2 != 0)\r
+ throw new IllegalArgumentException();\r
+ Map<Object, ElementClass> map = new HashMap<Object, ElementClass>();\r
+ int n = keyClassPairs.length / 2;\r
+ for (int i = 0; i < n; ++i) {\r
+ Object key = keyClassPairs[i * 2];\r
+ Object elementClass = keyClassPairs[i*2+1];\r
+ if (!(elementClass instanceof ElementClass))\r
+ throw new IllegalArgumentException("not an ElementClass instance: " + elementClass);\r
+ map.put(key, (ElementClass) elementClass);\r
+ }\r
+ return mappedProvider(map);\r
+ }\r
+\r
+\r
+ public interface ISysdynElementClassProvider extends IElementClassProvider {\r
+ \r
+ /**\r
+ * Update a value in an IElementClassProvider\r
+ */\r
+ void put(Object key, ElementClass value);\r
+ \r
+ }\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2010 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.ui.editor.participant;\r
+\r
+import java.awt.dnd.DropTargetDragEvent;\r
+import java.util.ArrayList;\r
+import java.util.Collection;\r
+\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.db.request.Read;\r
+import org.simantics.diagram.adapter.GraphToDiagramSynchronizer;\r
+import org.simantics.diagram.ui.DiagramModelHints;\r
+import org.simantics.g2d.dnd.ElementClassDragItem;\r
+import org.simantics.g2d.dnd.IDnDContext;\r
+import org.simantics.g2d.element.handler.impl.StaticObjectAdapter;\r
+import org.simantics.modeling.ModelingResources;\r
+import org.simantics.modeling.ui.diagramEditor.PopulateElementDropParticipant;\r
+import org.simantics.structural.stubs.StructuralResource2;\r
+import org.simantics.sysdyn.SysdynResource;\r
+\r
+public class SysdynPopulateElementDropParticipant extends PopulateElementDropParticipant {\r
+\r
+ public SysdynPopulateElementDropParticipant(GraphToDiagramSynchronizer synchronizer) {\r
+ super(synchronizer);\r
+ }\r
+\r
+ @Override\r
+ public void dragEnter(DropTargetDragEvent dtde, IDnDContext dp) {\r
+ super.dragEnter(dtde, dp);\r
+ \r
+ // Check that user is not trying to populate a module to itself. \r
+ // This doesn't prevent infinite recursion if there is one module between two exactly the same modules.\r
+ // e.g. WorkModule -> WokrforceModule -> WorkModule creates an infinite recursion\r
+ final Collection<ElementClassDragItem> items = dp.getItemsByClass(ElementClassDragItem.class);\r
+ if(!items.isEmpty()) {\r
+ Collection<ElementClassDragItem> unvalidModules = null;\r
+ try {\r
+ unvalidModules = synchronizer.getSession().syncRequest(new Read<Collection<ElementClassDragItem>>() {\r
+\r
+ @Override\r
+ public Collection<ElementClassDragItem> perform(ReadGraph graph)\r
+ throws DatabaseException {\r
+ Collection<ElementClassDragItem> unvalidModules = new ArrayList<ElementClassDragItem>();\r
+ for(ElementClassDragItem item : items) {\r
+ StaticObjectAdapter soa = item.getElementClass().getSingleItem(StaticObjectAdapter.class);\r
+ Resource type = soa.adapt(Resource.class);\r
+ \r
+ SysdynResource sr = SysdynResource.getInstance(graph);\r
+ if(graph.isInheritedFrom(type, sr.ModuleSymbol)) {\r
+ Resource module = graph.getSingleObject(type, ModelingResources.getInstance(graph).SymbolToComponentType);\r
+ Resource configuration = graph.getSingleObject(module, StructuralResource2.getInstance(graph).IsDefinedBy);\r
+ Resource dia = graph.getSingleObject(configuration, ModelingResources.getInstance(graph).CompositeToDiagram);\r
+ Resource editorDia = diagram.getHint(DiagramModelHints.KEY_DIAGRAM_RESOURCE);\r
+ if(dia.equals(editorDia))\r
+ unvalidModules.add(item);\r
+ }\r
+ }\r
+ return unvalidModules;\r
+ }\r
+ });\r
+ } catch (DatabaseException e) {\r
+ e.printStackTrace();\r
+ }\r
+ if(!unvalidModules.isEmpty()) {\r
+ for(ElementClassDragItem item : unvalidModules) {\r
+ dp.remove(item);\r
+ }\r
+ }\r
+ }\r
+ }\r
+}\r
--- /dev/null
+package org.simantics.sysdyn.ui.editor.routing;\r
+\r
+import java.awt.geom.Arc2D;\r
+import java.awt.geom.Path2D;\r
+import java.awt.geom.Point2D;\r
+import java.awt.geom.Rectangle2D;\r
+\r
+import org.simantics.g2d.routing.IConnection;\r
+import org.simantics.g2d.routing.IConnection.Connector;\r
+import org.simantics.g2d.routing.IRouter2;\r
+import org.simantics.sysdyn.ui.elements2.connections.Arcs;\r
+import org.simantics.utils.datastructures.Pair;\r
+\r
+public class DependencyRouter implements IRouter2 {\r
+\r
+ @Override\r
+ public void route(IConnection connection) {\r
+ if(connection.getSegments().isEmpty())\r
+ return;\r
+ Object seg = connection.getSegments().iterator().next();\r
+ Connector begin = connection.getBegin(seg);\r
+ Connector end = connection.getEnd(seg);\r
+ \r
+ Pair<Arc2D, Path2D> shapes = new Pair<Arc2D, Path2D>(new Arc2D.Double(), new Path2D.Double());\r
+ createArrowShape(shapes,\r
+ begin.parentObstacle,\r
+ end.parentObstacle,\r
+ 0.1);\r
+ \r
+ Path2D path = new Path2D.Double();\r
+ path.append(shapes.first, false);\r
+ path.append(shapes.second, false);\r
+ connection.setPath(seg, path);\r
+ }\r
+\r
+ \r
+ /*\r
+ * Total length of the arrow is ARROW_LENGTH1 + ARROW_LENGTH2\r
+ */\r
+ public static double ARROW_LENGTH1 = 0.2;\r
+ public static double ARROW_LENGTH2 = 1.0;\r
+ public static double ARROW_WIDTH = 0.5;\r
+ \r
+\r
+ private static Path2D createArrow(Path2D shape, double x, double y, double dx, double dy) {\r
+ if(shape == null)\r
+ shape = new Path2D.Double();\r
+ else\r
+ shape.reset();\r
+ \r
+ shape.moveTo(x+ARROW_LENGTH1*dx, y+ARROW_LENGTH1*dy);\r
+ x -= ARROW_LENGTH2*dx;\r
+ y -= ARROW_LENGTH2*dy;\r
+ shape.lineTo(x-ARROW_WIDTH*dy, y+ARROW_WIDTH*dx);\r
+ shape.lineTo(x+ARROW_WIDTH*dy, y-ARROW_WIDTH*dx);\r
+ shape.closePath();\r
+ return shape;\r
+ }\r
+ \r
+ public static Arc2D createArc(Arc2D arc, Rectangle2D tail, Rectangle2D head, double angle) {\r
+ double x0 = tail.getCenterX();\r
+ double y0 = tail.getCenterY();\r
+ double x1 = head.getCenterX();\r
+ double y1 = head.getCenterY();\r
+ \r
+// System.out.println("createArrowShape " + x0 + " " + y0 + " " + x1 + " " + y1);\r
+ \r
+ double offset = \r
+ Math.abs(angle) < 1.0e-6\r
+ ? 1e3 * Math.signum(angle)\r
+ : Math.tan(Math.PI*0.5-angle)*0.5;\r
+ \r
+ double cx = 0.5*(x0+x1) + offset * (y1-y0);\r
+ double cy = 0.5*(y0+y1) + offset * (x0-x1);\r
+ double dx0 = x0 - cx;\r
+ double dy0 = y0 - cy;\r
+ double dx1 = x1 - cx;\r
+ double dy1 = y1 - cy;\r
+ \r
+ double r = Math.sqrt(dx0*dx0 + dy0*dy0);\r
+ \r
+// Rectangle2D bounds = new Rectangle2D.Double();\r
+// tail.getBounds(bounds);\r
+ double angle0 = Arcs.nextIntersectingAngle(cx, cy, r, \r
+ Math.atan2(-dy0, dx0), tail, angle < 0.0);\r
+// head.getBounds(bounds);\r
+ double angle1 = Arcs.nextIntersectingAngle(cx, cy, r, \r
+ Math.atan2(-dy1, dx1), head, angle > 0.0);\r
+ double extent = angle1-angle0;\r
+ //double arcAngle = angle0;\r
+ if(angle < 0.0) {\r
+ double temp = angle0; \r
+ angle0 = angle1;\r
+ angle1 = temp;\r
+ extent = -extent;\r
+ } \r
+ if(extent < 0)\r
+ extent += Math.PI*2.0;\r
+ else if(extent >= 360.0)\r
+ extent -= Math.PI*2.0;\r
+ if(arc == null)\r
+ arc = new Arc2D.Double();\r
+ arc.setArc(cx-r, cy-r, 2*r, 2*r, \r
+ Math.toDegrees(angle0), \r
+ Math.toDegrees(extent), \r
+ Arc2D.OPEN);\r
+// \r
+ return arc;\r
+ }\r
+ \r
+ public static Point2D computeCenter(Rectangle2D tail, Rectangle2D head, double angle) {\r
+\r
+ double x0 = tail.getCenterX();\r
+ double y0 = tail.getCenterY();\r
+ double x1 = head.getCenterX();\r
+ double y1 = head.getCenterY();\r
+ \r
+// System.out.println("createArrowShape " + x0 + " " + y0 + " " + x1 + " " + y1);\r
+ \r
+ double offset = \r
+ Math.abs(angle) < 1.0e-6\r
+ ? 1e3 * Math.signum(angle)\r
+ : Math.tan(Math.PI*0.5-angle)*0.5;\r
+ \r
+ double cx = 0.5*(x0+x1) + offset * (y1-y0);\r
+ double cy = 0.5*(y0+y1) + offset * (x0-x1);\r
+ \r
+ return new Point2D.Double(cx, cy);\r
+ \r
+ }\r
+ \r
+ public static Pair<Arc2D, Path2D> createArrowShape(Pair<Arc2D, Path2D> shapes, Rectangle2D tail, Rectangle2D head, double angle) {\r
+ if(shapes == null || shapes.first == null || shapes.second == null) {\r
+ shapes = new Pair<Arc2D, Path2D>(new Arc2D.Double(), new Path2D.Double());\r
+ }\r
+\r
+ createArc(shapes.first, tail, head, angle);\r
+ \r
+ double angle0 = Math.toRadians(shapes.first.getAngleStart());\r
+ double angle1 = Math.toRadians(shapes.first.getAngleStart() + shapes.first.getAngleExtent());\r
+ double x = Math.cos(angle > 0.0 ? angle1 : angle0);\r
+ double y = -Math.sin(angle > 0.0 ? angle1 : angle0);\r
+ double r = shapes.first.getHeight() / 2;\r
+ \r
+ createArrow(shapes.second, shapes.first.getCenterX() + r*x, shapes.first.getCenterY() + r*y, \r
+ angle < 0.0 ? -y : y, \r
+ angle > 0.0 ? -x : x);\r
+\r
+ return shapes;\r
+ \r
+ }\r
+}\r
--- /dev/null
+package org.simantics.sysdyn.ui.editor.routing;\r
+\r
+import java.awt.geom.AffineTransform;\r
+import java.awt.geom.Path2D;\r
+import java.awt.geom.PathIterator;\r
+import java.awt.geom.Rectangle2D;\r
+import java.util.Collection;\r
+\r
+import org.simantics.g2d.routing.Constants;\r
+import org.simantics.g2d.routing.IConnection;\r
+import org.simantics.g2d.routing.IConnection.Connector;\r
+import org.simantics.g2d.routing.IRouter2;\r
+import org.simantics.sysdyn.ui.editor.participant.SysdynConnectTool.SysdynConnection;\r
+import org.simantics.sysdyn.ui.elements2.connections.Flows;\r
+\r
+public class FlowRouter implements IRouter2{\r
+\r
+ SysdynLocalRouter localRouter;\r
+ \r
+ public static final double OFFSET = 1.0;\r
+\r
+ public FlowRouter() {\r
+ this(false);\r
+ }\r
+\r
+ public FlowRouter(boolean roundCorners) {\r
+ this.localRouter = new SysdynLocalRouter();\r
+ }\r
+\r
+ private Path2D route(double beginX, double beginY, int sDir, Rectangle2D beginObstacle,\r
+ double endX, double endY, int tDir, Rectangle2D endObstacle) {\r
+ localRouter.sx = beginX;\r
+ localRouter.sy = beginY;\r
+ if(beginObstacle == null) {\r
+ localRouter.aMinX = beginX;\r
+ localRouter.aMinY = beginY;\r
+ localRouter.aMaxX = beginX;\r
+ localRouter.aMaxY = beginY;\r
+ }\r
+ else {\r
+ localRouter.aMinX = beginObstacle.getMinX();\r
+ localRouter.aMinY = beginObstacle.getMinY();\r
+ localRouter.aMaxX = beginObstacle.getMaxX();\r
+ localRouter.aMaxY = beginObstacle.getMaxY();\r
+ }\r
+ localRouter.sourceDirection = sDir;\r
+\r
+ localRouter.tx = endX;\r
+ localRouter.ty = endY;\r
+ if(endObstacle == null) {\r
+ localRouter.bMinX = endX;\r
+ localRouter.bMinY = endY;\r
+ localRouter.bMaxX = endX;\r
+ localRouter.bMaxY = endY;\r
+ }\r
+ else {\r
+ localRouter.bMinX = endObstacle.getMinX();\r
+ localRouter.bMinY = endObstacle.getMinY();\r
+ localRouter.bMaxX = endObstacle.getMaxX();\r
+ localRouter.bMaxY = endObstacle.getMaxY();\r
+ }\r
+ localRouter.targetDirection = tDir;\r
+ \r
+ // adjust flows to start and stop within the obstacle\r
+ if(sDir == Constants.EAST || sDir == Constants.WEST) {\r
+ localRouter.aMinY = localRouter.aMinY + OFFSET;\r
+ localRouter.aMaxY = localRouter.aMaxY - OFFSET;\r
+ }\r
+ if(tDir == Constants.EAST || tDir == Constants.WEST) {\r
+ localRouter.bMinY = localRouter.bMinY + OFFSET;\r
+ localRouter.bMaxY = localRouter.bMaxY - OFFSET;\r
+ }\r
+ if(sDir == Constants.SOUTH || sDir == Constants.NORTH) {\r
+ localRouter.aMinX = localRouter.aMinX + OFFSET;\r
+ localRouter.aMaxX = localRouter.aMaxX - OFFSET;\r
+ }\r
+ if(tDir == Constants.SOUTH || tDir == Constants.NORTH) {\r
+ localRouter.bMinX = localRouter.bMinX + OFFSET;\r
+ localRouter.bMaxX = localRouter.bMaxX - OFFSET;\r
+ }\r
+\r
+ localRouter.route();\r
+\r
+ Path2D completePath = new Path2D.Double();\r
+ \r
+ double[] coordinates = new double[localRouter.points.size()];\r
+ for(int i = 0; i < localRouter.points.size() ; i++)\r
+ coordinates[i] = localRouter.points.get(i);\r
+ \r
+ boolean vertical = false;\r
+ \r
+ if(coordinates.length > 3) {\r
+ if(coordinates[0] == coordinates[2]) {\r
+ // starts to south or north\r
+ double[] tempCoordinates = new double[coordinates.length - 1];\r
+ for(int i = 0; i < coordinates.length - 1 ; i++)\r
+ tempCoordinates[i] = coordinates[i + 1];\r
+ \r
+ coordinates = new double[tempCoordinates.length];\r
+ for(int i = 0; i < tempCoordinates.length ; i++)\r
+ coordinates[i] = tempCoordinates[i];\r
+ vertical = true;\r
+ }\r
+ } \r
+\r
+ Flows.createOffsetLine(completePath, vertical, OFFSET, coordinates);\r
+ Flows.createOffsetLine(completePath, vertical, -OFFSET, coordinates);\r
+// return localRouter.path;\r
+ \r
+// Flows.createLines(completePath, false, beginObstacle, endObstacle);\r
+ return completePath;\r
+ }\r
+\r
+ @Override\r
+ public void route(IConnection connection) {\r
+ \r
+ if(!(connection instanceof SysdynConnection)) {\r
+ return;\r
+ }\r
+ Collection<?> segments = connection.getSegments();\r
+ if(segments.size() == 1)\r
+ for(Object seg : segments) {\r
+ Connector begin = connection.getBegin(seg);\r
+ Connector end = connection.getEnd(seg);\r
+\r
+ double bestLength = Double.POSITIVE_INFINITY;\r
+ Path2D bestPath = null;\r
+ \r
+ for(int sDir : Constants.POSSIBLE_DIRECTIONS[begin.allowedDirections])\r
+ for(int tDir : Constants.POSSIBLE_DIRECTIONS[end.allowedDirections]) {\r
+ Path2D path = route(begin.x, begin.y, sDir, begin.parentObstacle,\r
+ end.x, end.y, tDir, end.parentObstacle);\r
+\r
+ double length = pathCost(path);\r
+ if(length < bestLength) {\r
+ bestLength = length;\r
+ bestPath = path;\r
+ }\r
+ }\r
+\r
+ if(bestPath != null)\r
+ connection.setPath(seg, bestPath);\r
+ }\r
+ }\r
+\r
+ final static AffineTransform IDENTITY = new AffineTransform();\r
+\r
+ static double pathCost(Path2D path) {\r
+ double length = 0.0;\r
+ PathIterator it = path.getPathIterator(IDENTITY);\r
+ double[] temp = new double[6];\r
+ double x=0.0, y=0.0;\r
+ double bendCount = 0.0;\r
+ while(!it.isDone()) {\r
+ bendCount += 1.0;\r
+ if(it.currentSegment(temp) != PathIterator.SEG_MOVETO)\r
+ length += Math.abs(x - temp[0] + y - temp[1]);\r
+ x = temp[0];\r
+ y = temp[1];\r
+ it.next();\r
+ }\r
+ //return length * (6.0 + bendCount);\r
+ return bendCount - 1.0 / length;\r
+ }\r
+\r
+}\r
--- /dev/null
+package org.simantics.sysdyn.ui.editor.routing;\r
+\r
+import java.awt.geom.Path2D;\r
+import java.util.ArrayList;\r
+\r
+import org.simantics.g2d.routing.Constants;\r
+\r
+public class SysdynLocalRouter {\r
+\r
+ static final double OFFSET = 1.0;\r
+ \r
+ double aMinX;\r
+ double aMinY;\r
+ double aMaxX;\r
+ double aMaxY;\r
+\r
+ double bMinX;\r
+ double bMinY;\r
+ double bMaxX;\r
+ double bMaxY;\r
+\r
+ double sx;\r
+ double sy;\r
+\r
+ double tx;\r
+ double ty;\r
+\r
+ int sourceDirection;\r
+ int targetDirection;\r
+\r
+ ArrayList<Double> points;\r
+ Path2D path;\r
+\r
+ public SysdynLocalRouter() {\r
+ }\r
+\r
+ /**\r
+ * Case where both source and target connection directions are to east.\r
+ */\r
+ void routeEast() {\r
+ if (bMinX >= aMaxX || tx >= 0 && !(bMaxY < aMinY || aMaxY < bMinY)) {\r
+ if (ty != 0.0) {\r
+ /* ______ ______\r
+ * | | | |\r
+ * | |----\ | |\r
+ * | | \--->| |\r
+ * |______| |______|\r
+ */\r
+ double mx = 0.5 * (aMaxX + bMinX);\r
+ point(mx, 0.0);\r
+ point(mx, ty);\r
+ } else\r
+ ; // Just a straight line\r
+ } else {\r
+ double x0 = bMinX;\r
+ double x1 = aMaxX;\r
+ double my;\r
+ /* ______\r
+ * | |\r
+ * | |\r
+ * /->| |\r
+ * | |______|\r
+ * |\r
+ * \-------------\\r
+ * ______ |\r
+ * | | |\r
+ * | |-/\r
+ * | |\r
+ * |______|\r
+ * \r
+ * If the elements are separated in Y-direction,\r
+ * route between the elements (this is always the shortest path).\r
+ */\r
+ if (bMaxY < aMinY)\r
+ my = 0.5 * (aMinY + bMaxY);\r
+ else if (aMaxY < bMinY)\r
+ my = 0.5 * (aMaxY + bMinY);\r
+ else {\r
+ /*\r
+ * /------------------------\\r
+ * | ______ ______ |\r
+ * | | | | | |\r
+ * | | | | |--+\r
+ * +->| | | | |\r
+ * | |______| |______| |\r
+ * | |\r
+ * \------------------------/\r
+ * \r
+ * or\r
+ * \r
+ * /-----------\\r
+ * | ______ |\r
+ * | | | |\r
+ * | | | |\r
+ * /--+->| | |\r
+ * | ___|______| |\r
+ * | | | |\r
+ * | | |-+---/\r
+ * | | | |\r
+ * | |______| |\r
+ * | |\r
+ * \----------/\r
+ * \r
+ * We may choose either lower or upper path.\r
+ */\r
+ double upperX0 = bMinX;\r
+ double upperX1 = aMaxX;\r
+ double lowerX0 = bMinX;\r
+ double lowerX1 = aMaxX;\r
+ double upperY = Math.min(aMinY, bMinY);\r
+ double lowerY = Math.max(aMaxY, bMaxY);\r
+\r
+ if (aMinX < bMinX) {\r
+ if (ty < 0.5 * (aMinY + aMaxY))\r
+ lowerX0 = aMinX;\r
+ else\r
+ upperX0 = aMinX;\r
+ }\r
+\r
+ if (bMaxX > aMaxX) {\r
+ if (ty < 0.5 * (aMinY + aMaxY))\r
+ upperX1 = bMaxX;\r
+ else\r
+ lowerX1 = bMaxX;\r
+ }\r
+\r
+ double upperLength = upperX1 - upperY + (upperX1 - upperX0)\r
+ + (ty - upperY) + (tx - upperX0);\r
+ double lowerLength = lowerX1 + lowerY + (lowerX1 - lowerX0)\r
+ + (lowerY - ty) + (tx - lowerX0);\r
+\r
+ if (upperLength < lowerLength) {\r
+ x0 = upperX0;\r
+ x1 = upperX1;\r
+ my = upperY;\r
+ } else {\r
+ x0 = lowerX0;\r
+ x1 = lowerX1;\r
+ my = lowerY;\r
+ }\r
+ }\r
+ point(x1, 0.0);\r
+ point(x1, my);\r
+ point(x0, my);\r
+ point(x0, ty);\r
+ }\r
+ }\r
+\r
+ void routeWest() {\r
+ if (tx >= 0.0) {\r
+ double fx = Math.max(aMaxX, bMaxX);\r
+ double mx = 0.5 * (aMaxX + bMinX);\r
+ if (bMinY >= 0.0 || bMaxY <= 0.0 || mx < 0.0) {\r
+ /* ______\r
+ * | |\r
+ * | |\r
+ * | |<-\\r
+ * ______ |______| |\r
+ * | | |\r
+ * | |-------------------/\r
+ * | |\r
+ * |______|\r
+ */\r
+ point(fx, 0.0);\r
+ }\r
+ else {\r
+ /* /-------------\\r
+ * | ______ |\r
+ * | | | |\r
+ * ______ | | | |\r
+ * | | | | |<-+\r
+ * | |----+ |______| |\r
+ * | | | |\r
+ * |______| \-------------/\r
+ * \r
+ * We may choose either upper or lower path\r
+ * by the path length.\r
+ */\r
+ double my = Math.abs(bMinY) + Math.abs(ty - bMinY) < Math\r
+ .abs(bMaxY) + Math.abs(ty - bMaxY) ? bMinY : bMaxY;\r
+ point(mx, 0.0);\r
+ point(mx, my);\r
+ point(fx, my);\r
+ }\r
+ point(fx, ty);\r
+ } else {\r
+ double fx = Math.max(aMaxX, bMaxX);\r
+ double mx = 0.5 * (aMinX + bMaxX);\r
+ point(fx, 0.0);\r
+ if (ty <= aMinY || ty >= aMaxY\r
+ || (tx >= mx && ty >= aMinY && ty <= aMaxY)) {\r
+ /* ______\r
+ * | |\r
+ * | |\r
+ * | |--\\r
+ * ______ |______| |\r
+ * | | |\r
+ * | |<------------------/\r
+ * | |\r
+ * |______|\r
+ */\r
+ point(fx, ty);\r
+ }\r
+ else {\r
+ /* /-------------\\r
+ * | ______ |\r
+ * | | | |\r
+ * ______ | | | |\r
+ * | | | | |--+\r
+ * | |<---+ |______| |\r
+ * | | | |\r
+ * |______| \-------------/\r
+ * \r
+ * We may choose either upper or lower path\r
+ * by the path length.\r
+ */\r
+ double my = Math.abs(aMinY) + Math.abs(ty - aMinY) < Math\r
+ .abs(aMaxY) + Math.abs(ty - aMaxY) ? aMinY : aMaxY;\r
+ point(fx, my);\r
+ point(mx, my);\r
+ point(mx, ty);\r
+ }\r
+ }\r
+ }\r
+\r
+ void routeSouth() {\r
+ if (tx > 0.0 && (bMinY >= 0.0 || (ty > 0.0 && bMinX <= aMaxX)))\r
+ point(tx, 0.0);\r
+ else if (bMinX > aMaxX) {\r
+ double mx = 0.5 * (aMaxX + bMinX);\r
+ point(mx, 0.0);\r
+ point(mx, bMinY);\r
+ point(tx, bMinY);\r
+ } else {\r
+ double fx = aMaxX;\r
+ double my = 0.5 * (aMaxY + bMinY);\r
+ if (my < aMaxY && (tx < aMinX || ty < aMinY)) {\r
+ my = Math.min(aMinY, bMinY);\r
+ if (bMaxX > aMaxX)\r
+ fx = bMaxX;\r
+ }\r
+ point(fx, 0.0);\r
+ point(fx, my);\r
+ point(tx, my);\r
+ }\r
+ }\r
+\r
+ double xx, xy, yx, yy;\r
+\r
+ void point(double x, double y) {\r
+ lineTo(x * xx + y * yx + sx, x * xy + y * yy + sy);\r
+ }\r
+\r
+ /*\r
+ * should draw only horizontal or vertical lines. Determine the offset and\r
+ * draw both lines.\r
+ */\r
+ void lineTo(double x, double y) {\r
+ double cx = path.getCurrentPoint().getX();\r
+ double cy = path.getCurrentPoint().getY();\r
+ \r
+ if (Math.abs(cx - x) < 1e-5) {\r
+ // Vertical line\r
+ if(points.size() % 2 == 0) {\r
+ points.add(points.get(points.size()-2));\r
+ }\r
+ points.add(y);\r
+ } else if (Math.abs(cy - y) < 1e-5) {\r
+ // Horizontal line\r
+ if(points.size() % 2 != 0) {\r
+ points.add(cy);\r
+ }\r
+ points.add(x);\r
+ }\r
+ path.lineTo(x, y);\r
+ }\r
+ void rotate() {\r
+ double temp;\r
+\r
+ temp = tx;\r
+ tx = ty;\r
+ ty = -temp;\r
+\r
+ temp = aMinX;\r
+ aMinX = aMinY;\r
+ aMinY = -aMaxX;\r
+ aMaxX = aMaxY;\r
+ aMaxY = -temp;\r
+\r
+ temp = bMinX;\r
+ bMinX = bMinY;\r
+ bMinY = -bMaxX;\r
+ bMaxX = bMaxY;\r
+ bMaxY = -temp;\r
+\r
+ temp = xx;\r
+ xx = -xy;\r
+ xy = temp;\r
+\r
+ temp = yx;\r
+ yx = -yy;\r
+ yy = temp;\r
+\r
+ --targetDirection;\r
+ if (targetDirection < 0)\r
+ targetDirection += 4;\r
+ --sourceDirection;\r
+ }\r
+\r
+ void flip() {\r
+ double temp;\r
+\r
+ ty = -ty;\r
+\r
+ temp = aMinY;\r
+ aMinY = -aMaxY;\r
+ aMaxY = -temp;\r
+\r
+ temp = bMinY;\r
+ bMinY = -bMaxY;\r
+ bMaxY = -temp;\r
+\r
+ yx = -yx;\r
+ yy = -yy;\r
+\r
+ targetDirection = (targetDirection + 2) % 4;\r
+ }\r
+\r
+ /*\r
+ * Puts source terminal to origo and rotates the situation so that the\r
+ * connection leaves to east. Finally, the case where target direction is to\r
+ * south is eliminated by optionally flipping the situation.\r
+ */\r
+ void canonicalize() {\r
+ aMinX -= sx;\r
+ aMinY -= sy;\r
+ aMaxX -= sx;\r
+ aMaxY -= sy;\r
+ bMinX -= sx;\r
+ bMinY -= sy;\r
+ bMaxX -= sx;\r
+ bMaxY -= sy;\r
+ tx -= sx;\r
+ ty -= sy;\r
+ xx = yy = 1.0;\r
+ xy = yx = 0.0;\r
+ while (sourceDirection > 0)\r
+ rotate();\r
+\r
+ if (targetDirection == Constants.SOUTH)\r
+ flip();\r
+ }\r
+\r
+ public void route() {\r
+ /*\r
+ * Three cases: 1. Obstacles share X-axis at some point 2. Obstacles\r
+ * share Y-Axis at some point 3. Obstacles don't share axis => Have to\r
+ * make corners.\r
+ */ \r
+ if (\r
+ aMinX > bMinX && aMinX < bMaxX ||\r
+ aMaxX > bMinX && aMaxX < bMaxX ||\r
+ aMinX < bMinX && aMaxX > bMaxX) {\r
+ // Obstacles share x-axis => no corner\r
+ double minX = aMinX > bMinX ? aMinX : bMinX;\r
+ double maxX = aMaxX < bMaxX ? aMaxX : bMaxX;\r
+ double middle = minX + (maxX - minX) / 2;\r
+ sx = middle;\r
+ tx = middle;\r
+ if (sy > ty) {\r
+ sy = aMinY;\r
+ ty = bMaxY;\r
+ } else {\r
+ sy = aMaxY;\r
+ ty = bMinY;\r
+ }\r
+ } else if (\r
+ aMinY > bMinY && aMinY < bMaxY || \r
+ aMaxY > bMinY && aMaxY < bMaxY ||\r
+ aMinY < bMinY && aMaxY > bMaxY) {\r
+ // Obstacles share y-axis => no corner\r
+ double minY = aMinY > bMinY ? aMinY : bMinY;\r
+ double maxY = aMaxY < bMaxY ? aMaxY : bMaxY;\r
+ double middle = minY + (maxY - minY) / 2;\r
+ sy = middle;\r
+ ty = middle;\r
+ if (sx > tx) {\r
+ sx = aMinX;\r
+ tx = bMaxX;\r
+ } else {\r
+ sx = aMaxX;\r
+ tx = bMinX;\r
+ }\r
+ } else {\r
+ sx = aMinX + (aMaxX - aMinX) / 2;\r
+ sy = aMinY + (aMaxY - aMinY) / 2;\r
+ tx = bMinX + (bMaxX - bMinX) / 2;\r
+ ty = bMinY + (bMaxY - bMinY) / 2;\r
+ // Move starting point to the edge of the start element\r
+ switch (sourceDirection) {\r
+ case Constants.WEST:\r
+ sx = aMinX;\r
+ break;\r
+ case Constants.EAST:\r
+ sx = aMaxX;\r
+ break;\r
+ case Constants.NORTH:\r
+ sy = aMinY;\r
+ break;\r
+ case Constants.SOUTH:\r
+ sy = aMaxY;\r
+ break;\r
+ }\r
+\r
+ // Move target point to the edge of the ending element\r
+ switch (targetDirection) {\r
+ case Constants.EAST:\r
+ tx = bMaxX;\r
+ break;\r
+ case Constants.WEST:\r
+ tx = bMinX;\r
+ break;\r
+ case Constants.NORTH:\r
+ ty = bMinY;\r
+ break;\r
+ case Constants.SOUTH:\r
+ ty = bMaxY;\r
+ break;\r
+ }\r
+ }\r
+\r
+ path = new Path2D.Double();\r
+ points = new ArrayList<Double>();\r
+\r
+ path.moveTo(sx, sy);\r
+ points.add(sx);\r
+ points.add(sy);\r
+\r
+ // Vertical and horizontal cases\r
+ if ((Math.abs(sx - tx) < 1e-5 && isVertical())\r
+ || (Math.abs(sy - ty) < 1e-5 && isHorizontal())) {\r
+ lineTo(tx, ty);\r
+ return;\r
+ }\r
+ \r
+\r
+ canonicalize();\r
+ switch (targetDirection) {\r
+ case Constants.EAST:\r
+ routeWest();\r
+ break;\r
+ case Constants.WEST:\r
+ routeEast();\r
+ break;\r
+ case Constants.NORTH:\r
+ routeSouth();\r
+ break;\r
+ }\r
+\r
+ point(tx, ty);\r
+\r
+ }\r
+ \r
+ private boolean isVertical() {\r
+ return\r
+ (sourceDirection == Constants.SOUTH && targetDirection == Constants.SOUTH)\r
+ ||\r
+ (sourceDirection == Constants.NORTH && targetDirection == Constants.NORTH);\r
+ }\r
+ \r
+ private boolean isHorizontal() {\r
+ return\r
+ (sourceDirection == Constants.EAST && targetDirection == Constants.EAST)\r
+ ||\r
+ (sourceDirection == Constants.WEST && targetDirection == Constants.WEST);\r
+ }\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2010 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.ui.elements2;\r
+\r
+import java.awt.BasicStroke;\r
+import java.awt.geom.Ellipse2D;\r
+import java.util.Collection;\r
+\r
+import org.simantics.db.Resource;\r
+import org.simantics.g2d.element.ElementClass;\r
+import org.simantics.g2d.element.handler.impl.BoundsOutline;\r
+import org.simantics.g2d.element.handler.impl.DefaultTransform;\r
+import org.simantics.g2d.element.handler.impl.ObjectTerminal;\r
+import org.simantics.g2d.element.handler.impl.OutlinePick;\r
+import org.simantics.g2d.element.handler.impl.SimpleElementLayers;\r
+import org.simantics.g2d.element.handler.impl.StaticObjectAdapter;\r
+import org.simantics.g2d.element.handler.impl.StaticSymbolImageInitializer;\r
+import org.simantics.g2d.element.handler.impl.StaticSymbolImpl;\r
+import org.simantics.g2d.element.handler.impl.TextColorImpl;\r
+import org.simantics.g2d.element.handler.impl.TextFontImpl;\r
+import org.simantics.g2d.element.handler.impl.TextImpl;\r
+import org.simantics.g2d.image.Image;\r
+import org.simantics.g2d.image.impl.ShapeImage;\r
+\r
+/**\r
+ * @author Tuukka Lehtonen\r
+ */\r
+public class AuxiliaryFactory extends SysdynElementFactory {\r
+\r
+ public static final Image AUX_STATIC_IMAGE = new ShapeImage(new Ellipse2D.Double(-5, -2, 10, 4), null, new BasicStroke(1), true);\r
+\r
+ @Override\r
+ protected ElementClass compileElementClass(Resource elementType, Collection<ObjectTerminal> terminals) {\r
+ return ElementClass.compile(\r
+ SimpleElementLayers.INSTANCE,\r
+ OutlinePick.INSTANCE,\r
+ TextImpl.INSTANCE,\r
+ TextColorImpl.BLACK,\r
+ TextFontImpl.DEFAULT,\r
+ DefaultTransform.INSTANCE,\r
+ new StaticObjectAdapter(elementType),\r
+ new StaticSymbolImpl(AUX_STATIC_IMAGE),\r
+ StaticSymbolImageInitializer.INSTANCE,\r
+ HoverTextElementHandler.INSTANCE,\r
+ BoundsOutline.INSTANCE,\r
+ new WholeElementTerminals(terminals)\r
+ ).setId(AuxiliaryFactory.class.getSimpleName());\r
+ }\r
+\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2010 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.ui.elements2;\r
+\r
+import java.awt.geom.AffineTransform;\r
+import org.simantics.g2d.element.ElementUtils;\r
+import org.simantics.g2d.element.IElement;\r
+import org.simantics.g2d.element.SceneGraphNodeKey;\r
+import org.simantics.g2d.element.handler.SceneGraph;\r
+import org.simantics.scenegraph.g2d.G2DParentNode;\r
+import org.simantics.utils.datastructures.Callback;\r
+import org.simantics.utils.datastructures.hints.IHintContext.Key;\r
+\r
+public class BorderSceneGraph implements SceneGraph, Callback<RectangleNode> {\r
+\r
+ public static final BorderSceneGraph INSTANCE = new BorderSceneGraph();\r
+\r
+ private static final long serialVersionUID = 5544256245734478634L;\r
+\r
+ private static final Key BORDER_NODE = new SceneGraphNodeKey(RectangleNode.class, "BORDER_NODE");\r
+\r
+ @Override\r
+ public void init(IElement e, G2DParentNode parent) {\r
+ RectangleNode node = ElementUtils.getOrCreateNode(e, parent, BORDER_NODE, "border", RectangleNode.class, this);\r
+\r
+ // Calculate borders from text node bounds.\r
+ node.init(ElementUtils.getElementBounds(e));\r
+ AffineTransform transform = ElementUtils.getTransform(e);\r
+ if(transform != null)\r
+ node.setTransform(transform);\r
+ }\r
+\r
+ @Override\r
+ public void run(RectangleNode node) {\r
+ node.setZIndex(-10);\r
+ }\r
+\r
+ @Override\r
+ public void cleanup(IElement e) {\r
+ ElementUtils.removePossibleNode(e, BORDER_NODE);\r
+ }\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2010 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.ui.elements2;\r
+\r
+import java.awt.BasicStroke;\r
+import java.awt.Color;\r
+import java.awt.Shape;\r
+import java.awt.geom.AffineTransform;\r
+import java.awt.geom.Path2D;\r
+import java.awt.geom.Rectangle2D;\r
+import java.util.Collection;\r
+\r
+import org.simantics.db.Resource;\r
+import org.simantics.g2d.canvas.ICanvasContext;\r
+import org.simantics.g2d.element.ElementClass;\r
+import org.simantics.g2d.element.ElementHints;\r
+import org.simantics.g2d.element.ElementUtils;\r
+import org.simantics.g2d.element.IElement;\r
+import org.simantics.g2d.element.SceneGraphNodeKey;\r
+import org.simantics.g2d.element.handler.HandleMouseEvent;\r
+import org.simantics.g2d.element.handler.InternalSize;\r
+import org.simantics.g2d.element.handler.SceneGraph;\r
+import org.simantics.g2d.element.handler.impl.BoundsOutline;\r
+import org.simantics.g2d.element.handler.impl.DefaultTransform;\r
+import org.simantics.g2d.element.handler.impl.HoverImpl;\r
+import org.simantics.g2d.element.handler.impl.ObjectTerminal;\r
+import org.simantics.g2d.element.handler.impl.OutlinePick;\r
+import org.simantics.g2d.element.handler.impl.SimpleElementLayers;\r
+import org.simantics.g2d.element.handler.impl.StaticObjectAdapter;\r
+import org.simantics.g2d.element.handler.impl.StaticSymbolImageInitializer;\r
+import org.simantics.g2d.element.handler.impl.StaticSymbolImpl;\r
+import org.simantics.g2d.element.handler.impl.TextColorImpl;\r
+import org.simantics.g2d.element.handler.impl.TextFontImpl;\r
+import org.simantics.g2d.element.handler.impl.TextImpl;\r
+import org.simantics.g2d.event.MouseEvent;\r
+import org.simantics.g2d.event.MouseEvent.MouseEnterEvent;\r
+import org.simantics.g2d.event.MouseEvent.MouseExitEvent;\r
+import org.simantics.g2d.image.Image;\r
+import org.simantics.g2d.image.impl.ShapeImage;\r
+import org.simantics.scenegraph.g2d.G2DParentNode;\r
+import org.simantics.scenegraph.g2d.nodes.ShapeNode;\r
+import org.simantics.utils.datastructures.hints.IHintListener;\r
+import org.simantics.utils.datastructures.hints.IHintObservable;\r
+import org.simantics.utils.datastructures.hints.IHintContext.Key;\r
+\r
+public class CloudFactory extends SysdynElementFactory {\r
+\r
+ public static final double CLOUD_SIZE_X = 5.0;\r
+ public static final double CLOUD_SIZE_Y = 3.0;\r
+ public static final double CLOUD_CURVES = 7;\r
+\r
+ private static final BasicStroke STROKE = new BasicStroke(1f);\r
+ public static final Image CLOUD_IMAGE = new ShapeImage(getCloudShape(), null, STROKE, true);\r
+\r
+ static Shape getCloudShape() {\r
+ Path2D path = new Path2D.Double();\r
+ double ox = CLOUD_SIZE_X;\r
+ double oy = 0.0;\r
+ double posX = 0;\r
+ double posY = 0;\r
+ path.moveTo(posX + ox, posY + oy);\r
+ for (int i = 1; i < CLOUD_CURVES + 1; ++i) {\r
+ double angle = (Math.PI * 2.0 / CLOUD_CURVES) * i;\r
+ double x = Math.cos(angle) * CLOUD_SIZE_X;\r
+ double y = Math.sin(angle) * CLOUD_SIZE_Y;\r
+ path.curveTo(\r
+ posX + (2*ox + x)*0.5, posY + (2*oy + y)*0.5,\r
+ posX + (ox + 2*x)*0.5, posY + (oy + 2*y)*0.5,\r
+ posX + x, posY + y);\r
+ ox = x;\r
+ oy = y;\r
+ }\r
+ return path;\r
+ }\r
+ \r
+ public static ElementClass createElementClass(Resource elementType, Collection<ObjectTerminal> terminals) {\r
+ return ElementClass.compile(\r
+ SimpleElementLayers.INSTANCE,\r
+ OutlinePick.INSTANCE,\r
+ TextImpl.INSTANCE,\r
+ TextColorImpl.BLACK,\r
+ TextFontImpl.DEFAULT,\r
+ DefaultTransform.INSTANCE,\r
+ new StaticObjectAdapter(elementType),\r
+ new StaticSymbolImpl(CLOUD_IMAGE),\r
+ StaticSymbolImageInitializer.INSTANCE,\r
+ CloudSceneGraph.INSTANCE,\r
+ HoverImpl.INSTANCE,\r
+ BoundsOutline.INSTANCE,\r
+ new WholeElementTerminals(terminals)\r
+ ).setId(CloudFactory.class.getSimpleName());\r
+ }\r
+\r
+ @Override\r
+ protected ElementClass compileElementClass(Resource elementType, Collection<ObjectTerminal> terminals) {\r
+ return createElementClass(elementType, terminals);\r
+ }\r
+\r
+ public static class CloudSceneGraph implements SceneGraph, InternalSize, HandleMouseEvent {\r
+\r
+ private static final long serialVersionUID = 5544256245734478634L;\r
+\r
+ public static final CloudSceneGraph INSTANCE = new CloudSceneGraph();\r
+\r
+ private static final Key NODE = new SceneGraphNodeKey(ShapeNode.class, "CLOUD_NODE");\r
+ \r
+ private IHintListener hoverHintListener;\r
+\r
+ @Override\r
+ public void init(IElement e, G2DParentNode parent) {\r
+ \r
+ HoverShapeNode node = ElementUtils.getOrCreateNode(e, parent, NODE, "cloud", HoverShapeNode.class);\r
+ \r
+ AffineTransform at = ElementUtils.getTransform(e);\r
+ \r
+ node.setStroke(STROKE);\r
+ node.setScaleStroke(true);\r
+ node.setColor(Color.BLACK);\r
+ node.setShape(getCloudShape());\r
+ \r
+ if(at != null)\r
+ node.setTransform(at);\r
+ \r
+ hoverHintListener = new IHintListener() {\r
+ \r
+ @Override\r
+ public void hintRemoved(IHintObservable sender, Key key, Object oldValue) {\r
+ \r
+ }\r
+ \r
+ @Override\r
+ public void hintChanged(IHintObservable sender, Key key, Object oldValue, Object newValue) {\r
+ IElement e = (IElement)sender;\r
+ HoverShapeNode shape = (HoverShapeNode) e.getHint(NODE);\r
+ if(shape == null) {\r
+ return;\r
+ }\r
+ shape.setHover(ElementUtils.isHovering(e));\r
+ }\r
+ };\r
+ e.addHintListener(hoverHintListener);\r
+ }\r
+\r
+ @Override\r
+ public void cleanup(IElement e) {\r
+ e.removeHintListener(hoverHintListener);\r
+ ElementUtils.removePossibleNode(e, NODE);\r
+ }\r
+\r
+ @Override\r
+ public Rectangle2D getBounds(IElement e, Rectangle2D size) {\r
+ if (size == null)\r
+ size = new Rectangle2D.Double();\r
+ size.setFrame(getCloudShape().getBounds2D());\r
+ return size;\r
+ }\r
+\r
+ @Override\r
+ public boolean handleMouseEvent(IElement e, ICanvasContext ctx, MouseEvent me) {\r
+ if (me instanceof MouseEnterEvent) {\r
+ e.setHint(ElementHints.KEY_HOVER, true);\r
+ return false;\r
+ } else if (me instanceof MouseExitEvent) {\r
+ e.setHint(ElementHints.KEY_HOVER, false);\r
+ return false;\r
+ }\r
+ return false;\r
+ }\r
+\r
+ }\r
+\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2010 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.ui.elements2;\r
+\r
+import org.simantics.databoard.Bindings;\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.Session;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.diagram.synchronization.IModificationQueue;\r
+import org.simantics.diagram.synchronization.ISynchronizationContext;\r
+import org.simantics.diagram.synchronization.graph.GraphSynchronizationHints;\r
+import org.simantics.diagram.synchronization.graph.RelatedPropertyModification;\r
+import org.simantics.diagram.synchronization.graph.ResourceSynchronizer;\r
+import org.simantics.g2d.element.ElementHints;\r
+import org.simantics.layer0.Layer0;\r
+import org.simantics.modeling.ModelingResources;\r
+import org.simantics.utils.datastructures.hints.IHintContext.Key;\r
+import org.simantics.utils.datastructures.hints.IHintObservable;\r
+\r
+/**\r
+ * @author Tuukka Lehtonen\r
+ */\r
+public class ComponentNameSynchronizer extends ResourceSynchronizer {\r
+\r
+ public static final ComponentNameSynchronizer INSTANCE = new ComponentNameSynchronizer();\r
+\r
+ private static final Key[] SYNCHRONIZED_HINTS = {\r
+ ElementHints.KEY_TEXT\r
+ };\r
+\r
+ @Override\r
+ public Key[] getSynchronizedHints() {\r
+ return SYNCHRONIZED_HINTS;\r
+ }\r
+\r
+ @Override\r
+ public boolean hintChanged(ISynchronizationContext context, IModificationQueue queue, Resource object, IHintObservable sender, Key key, Object oldValue, Object newValue) {\r
+ if (ElementHints.KEY_TEXT.equals(key)) {\r
+ Session session = context.get(GraphSynchronizationHints.SESSION);\r
+ Layer0 l0;\r
+ try {\r
+ l0 = Layer0.getInstance(session);\r
+ ModelingResources mr = session.getService(ModelingResources.class);\r
+ return queue.offer(new RelatedPropertyModification(object, mr.ElementToComponent, l0.HasName, l0.String, newValue, Bindings.STRING), null);\r
+ } catch (DatabaseException e) {\r
+ e.printStackTrace();\r
+ }\r
+ }\r
+ return false;\r
+ }\r
+\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2010 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.ui.elements2;\r
+\r
+import org.simantics.db.AsyncReadGraph;\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.common.adaption.ResourceAdapter;\r
+import org.simantics.db.procedure.AsyncProcedure;\r
+import org.simantics.diagram.adapter.DiagramClassAdapter;\r
+import org.simantics.g2d.diagram.DiagramClass;\r
+import org.simantics.g2d.diagram.DiagramHints;\r
+import org.simantics.g2d.diagram.IDiagram;\r
+import org.simantics.g2d.diagram.handler.LifeCycle;\r
+import org.simantics.g2d.routing.RouterFactory;\r
+\r
+/**\r
+ * @author Tuukka Lehtonen\r
+ */\r
+public class ConfigurationDiagramClassAdapter implements ResourceAdapter<DiagramClass> {\r
+\r
+ @Override\r
+ public void adapt(AsyncReadGraph g, Resource source, Resource r, AsyncProcedure<DiagramClass> procedure) {\r
+ procedure.execute(g, DiagramClassAdapter.INSTANCE.newClassWith(\r
+ Initializer.INSTANCE\r
+ ));\r
+ }\r
+\r
+ static class Initializer extends LifeCycle.Stub {\r
+ public static final Initializer INSTANCE = new Initializer();\r
+\r
+ @Override\r
+ public void onDiagramCreated(IDiagram diagram) {\r
+ diagram.setHint(DiagramHints.ROUTE_ALGORITHM, RouterFactory.create(false, false));\r
+ }\r
+ }\r
+\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2010 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.ui.elements2;\r
+\r
+import java.awt.event.MouseListener;\r
+import java.awt.event.MouseMotionListener;\r
+import java.awt.geom.Rectangle2D;\r
+import java.beans.PropertyChangeEvent;\r
+import java.beans.PropertyChangeListener;\r
+import java.lang.reflect.Field;\r
+import java.util.HashMap;\r
+\r
+import org.simantics.scenegraph.g2d.G2DNode;\r
+import org.simantics.scenegraph.utils.NodeUtil;\r
+\r
+abstract public class GraphPropertyNode extends G2DNode implements MouseListener, MouseMotionListener {\r
+\r
+ private static final long serialVersionUID = 245761992671850588L;\r
+\r
+ HashMap<String, Field> fields = new HashMap<String, Field>();\r
+\r
+ private PropertyChangeListener fieldListener = null;\r
+ \r
+ @Override\r
+ public void init() {\r
+ super.init();\r
+ NodeUtil.getEventDelegator(this).addMouseListener(this);\r
+ NodeUtil.getEventDelegator(this).addMouseMotionListener(this);\r
+ }\r
+ \r
+ @Override\r
+ public void cleanup() {\r
+ NodeUtil.getEventDelegator(this).removeMouseListener(this);\r
+ NodeUtil.getEventDelegator(this).removeMouseMotionListener(this);\r
+ super.cleanup();\r
+ }\r
+\r
+ protected GraphPropertyNode() {\r
+ for(Field f : getClass().getFields()) {\r
+// System.out.println("register field '" + f.getName() + "'");\r
+ fields.put(f.getName(), f);\r
+ }\r
+ }\r
+ \r
+ public void setFieldListener(PropertyChangeListener listener) {\r
+ this.fieldListener = listener;\r
+ }\r
+ \r
+ public void propertyChange(String field, Object value) {\r
+ }\r
+ \r
+ public void setProperty(String field, Object value) {\r
+ Field f = fields.get(field);\r
+ if(f == null) {\r
+ System.err.println("GraphPropertyNode tried to set undefined property '" + field + "'");\r
+ return;\r
+ }\r
+ try {\r
+ //System.out.println("setting field '" + field + "'");\r
+ f.set(this, value);\r
+ propertyChange(field, value);\r
+ } catch (IllegalArgumentException e) {\r
+ e.printStackTrace();\r
+ } catch (IllegalAccessException e) {\r
+ e.printStackTrace();\r
+ }\r
+ }\r
+ \r
+ public void commitProperty(String field, Object value) {\r
+ if(fieldListener != null) {\r
+ fieldListener.propertyChange(new PropertyChangeEvent(this, field, null, value));\r
+ }\r
+ }\r
+\r
+ boolean pressHit = false;\r
+ \r
+ public boolean hitTest(double x, double y, double tolerance) {\r
+ return false;\r
+ }\r
+\r
+ @Override\r
+ public Rectangle2D getBoundsInLocal() {\r
+ return null;\r
+ }\r
+ \r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2010 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.ui.elements2;\r
+\r
+import java.awt.AlphaComposite;\r
+import java.awt.BasicStroke;\r
+import java.awt.Color;\r
+import java.awt.Composite;\r
+import java.awt.Graphics2D;\r
+import java.awt.Shape;\r
+import java.awt.Stroke;\r
+\r
+import org.simantics.scenegraph.ISelectionPainterNode;\r
+import org.simantics.scenegraph.g2d.nodes.ShapeNode;\r
+import org.simantics.scenegraph.utils.NodeUtil;\r
+\r
+public class HoverShapeNode extends ShapeNode implements ISelectionPainterNode {\r
+\r
+ private static final long serialVersionUID = -4580969977763722602L;\r
+\r
+ transient public boolean hover = false;\r
+ \r
+ @Override\r
+ protected void renderShape(Graphics2D g2d, Shape s) {\r
+ boolean fill = Boolean.TRUE.equals(dynamicFill) ? true : this.fill;\r
+ if (fill)\r
+ g2d.fill(s);\r
+ \r
+ Color oldColor = g2d.getColor();\r
+ BasicStroke oldStroke = (BasicStroke)g2d.getStroke();\r
+ Composite oldComposite = g2d.getComposite();\r
+ \r
+ boolean selected = NodeUtil.isSelected(this, 1);\r
+ if (selected) {\r
+ float lineWidth = oldStroke.getLineWidth() * 5;\r
+ g2d.setStroke(new BasicStroke(lineWidth < 1.0f ? lineWidth : 1.0f));\r
+ g2d.setComposite(AlphaComposite.SrcAtop.derive(0.5f));\r
+ g2d.setColor(Color.RED);\r
+ g2d.draw(s);\r
+ g2d.setColor(oldColor);\r
+ }\r
+ \r
+ if(!selected && hover) {\r
+ g2d.setColor(Color.LIGHT_GRAY);\r
+ float lineWidth = oldStroke.getLineWidth() * 5;\r
+ g2d.setStroke(new BasicStroke(lineWidth < 1.0f ? lineWidth : 1.0f));\r
+ g2d.draw(s);\r
+\r
+ }\r
+\r
+ g2d.setColor(oldColor);\r
+ g2d.setStroke(oldStroke);\r
+ g2d.setComposite(oldComposite);\r
+ \r
+ Stroke stroke = dynamicStroke != null ? dynamicStroke : this.stroke;\r
+ if (stroke != null)\r
+ g2d.draw(s);\r
+ \r
+ }\r
+ \r
+ public void setHover(boolean hover) {\r
+ this.hover = hover;\r
+ repaint();\r
+ }\r
+\r
+\r
+\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2010 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.ui.elements2;\r
+\r
+import java.awt.geom.Rectangle2D;\r
+\r
+import org.simantics.g2d.element.IElement;\r
+import org.simantics.g2d.element.handler.InternalSize;\r
+import org.simantics.g2d.utils.Alignment;\r
+\r
+public class HoverTextElementHandler extends HoverTextElementNoBounds implements InternalSize {\r
+\r
+ private static final long serialVersionUID = 8800738238681432901L;\r
+ \r
+ public static final HoverTextElementHandler INSTANCE = new HoverTextElementHandler();\r
+\r
+ public HoverTextElementHandler() {\r
+ super();\r
+ }\r
+\r
+ public HoverTextElementHandler(double originX, double originY, Alignment horizontalAlignment) {\r
+ super(originX, originY, horizontalAlignment);\r
+ }\r
+\r
+ public HoverTextElementHandler(double originX, double originY, Alignment horizontalAlignment, double borderWidth) {\r
+ super(originX, originY, horizontalAlignment, borderWidth);\r
+ }\r
+\r
+ public HoverTextElementHandler(double originX, double originY, Alignment horizontalAlignment, double borderWidth,\r
+ double paddingX, double paddingY, boolean editable) {\r
+ super(originX, originY, horizontalAlignment, borderWidth, paddingX, paddingY, editable);\r
+ }\r
+\r
+ @Override\r
+ public Rectangle2D getBounds(IElement e, Rectangle2D size) {\r
+ HoverTextNode node = (HoverTextNode) e.getHint(SG_NODE);\r
+ if (size == null)\r
+ size = new Rectangle2D.Double();\r
+ if (node != null)\r
+ size.setRect(node.getBoundsInLocal());\r
+ else\r
+ size.setFrame(0, 0, 0, 0);\r
+ return size;\r
+ }\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2010 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.ui.elements2;\r
+\r
+import java.awt.Color;\r
+import java.awt.Font;\r
+import java.awt.geom.AffineTransform;\r
+\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.WriteGraph;\r
+import org.simantics.db.common.request.WriteRequest;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.diagram.elements.ITextListener;\r
+import org.simantics.diagram.elements.TextElementNoBounds;\r
+import org.simantics.diagram.elements.TextNode;\r
+import org.simantics.g2d.diagram.DiagramUtils;\r
+import org.simantics.g2d.diagram.IDiagram;\r
+import org.simantics.g2d.element.ElementHints;\r
+import org.simantics.g2d.element.ElementUtils;\r
+import org.simantics.g2d.element.IElement;\r
+import org.simantics.g2d.utils.Alignment;\r
+import org.simantics.modeling.ModelingResources;\r
+import org.simantics.scenegraph.g2d.G2DParentNode;\r
+import org.simantics.sysdyn.ui.utils.VariableNameUtils;\r
+import org.simantics.ui.SimanticsUI;\r
+import org.simantics.utils.datastructures.Callback;\r
+import org.simantics.utils.datastructures.hints.IHintListener;\r
+import org.simantics.utils.datastructures.hints.IHintObservable;\r
+import org.simantics.utils.datastructures.hints.IHintContext.Key;\r
+\r
+/**\r
+ * ElementHandler for text elements\r
+ * In-line editing supported.\r
+ * \r
+ * @author Marko Luukkainen <marko.luukkainen@vtt.fi>\r
+ */\r
+public class HoverTextElementNoBounds extends TextElementNoBounds {\r
+\r
+ private static final long serialVersionUID = -148784588840819612L;\r
+\r
+ public static final HoverTextElementNoBounds INSTANCE = new HoverTextElementNoBounds();\r
+\r
+ private IHintListener hoverHintListener;\r
+\r
+ public HoverTextElementNoBounds() {\r
+ super(0, 0, Alignment.LEADING, 0);\r
+ }\r
+\r
+ public HoverTextElementNoBounds(double originX, double originY, Alignment horizontalAlignment) {\r
+ super(originX, originY, horizontalAlignment, 0);\r
+ }\r
+\r
+ public HoverTextElementNoBounds(double originX, double originY, Alignment horizontalAlignment, double borderWidth) {\r
+ super(originX, originY, horizontalAlignment, borderWidth);\r
+ }\r
+\r
+ public HoverTextElementNoBounds(double originX, double originY, Alignment horizontalAlignment, double borderWidth, double paddingX, double paddingY, boolean editable) {\r
+ super(originX, originY, horizontalAlignment, borderWidth, paddingX, paddingY, editable);\r
+ }\r
+\r
+ @Override\r
+ public void init(final IElement e, G2DParentNode parent) {\r
+ HoverTextNode node = ElementUtils.getOrCreateNode(e, parent, SG_NODE, "text", HoverTextNode.class, new Callback<HoverTextNode>() {\r
+ @Override\r
+ public void run(HoverTextNode node) {\r
+ node.setTextListener(new ITextListener() {\r
+\r
+ String textBeforeEdit;\r
+ Resource component;\r
+\r
+ @Override\r
+ public void textChanged() {\r
+ TextNode node = (TextNode) e.getHint(SG_NODE);\r
+ if(!VariableNameUtils.isValid(component, node.getText(), false)) {\r
+ node.setColor(Color.RED);\r
+ } else {\r
+ node.setColor(Color.BLACK);\r
+ }\r
+\r
+\r
+ }\r
+\r
+ @Override\r
+ public void textEditingStarted() {\r
+ TextNode node = (TextNode) e.getHint(SG_NODE);\r
+ textBeforeEdit = node.getText();\r
+\r
+ if(component != null) return;\r
+ \r
+ Object o = e.getHint(ElementHints.KEY_OBJECT);\r
+ if(o != null && o instanceof Resource) {\r
+ final Resource element = (Resource)o;\r
+ SimanticsUI.getSession().asyncRequest(new WriteRequest() {\r
+\r
+ @Override\r
+ public void perform(WriteGraph graph) throws DatabaseException {\r
+ component = graph.getPossibleObject(element, ModelingResources.getInstance(graph).ElementToComponent);\r
+ }\r
+ });\r
+ }\r
+ }\r
+\r
+ @Override\r
+ public void textEditingCancelled() {\r
+ TextNode node = (TextNode) e.getHint(SG_NODE);\r
+ if (node != null) {\r
+ if(VariableNameUtils.isValid(component, node.getText(), false))\r
+ node.setColor(Color.BLACK);\r
+ endEdit(node);\r
+ }\r
+ }\r
+\r
+ @Override\r
+ public void textEditingEnded() {\r
+ TextNode node = (TextNode) e.getHint(SG_NODE);\r
+ if (node == null)\r
+ return;\r
+ String text = node.getText();\r
+ if(!VariableNameUtils.isValid(component, text, false)) {\r
+ text = textBeforeEdit;\r
+ node.setText(text);\r
+ if(VariableNameUtils.isValid(component, text, false))\r
+ node.setColor(Color.BLACK);\r
+ } else {\r
+ Object o = e.getHint(ElementHints.KEY_OBJECT);\r
+ final String textAfterEdit = text;\r
+ if(o != null && o instanceof Resource) {\r
+ SimanticsUI.getSession().asyncRequest(new WriteRequest() {\r
+ @Override\r
+ public void perform(WriteGraph graph) throws DatabaseException {\r
+ VariableNameUtils.renameInEquations(graph, component, textBeforeEdit, textAfterEdit);\r
+ }\r
+ });\r
+ }\r
+ }\r
+ ElementUtils.setText(e, text);\r
+ IDiagram diagram = ElementUtils.getDiagram(e);\r
+ DiagramUtils.synchronizeHintsToBackend(diagram, e);\r
+ endEdit(node);\r
+ }\r
+ });\r
+ }\r
+ });\r
+\r
+ //Font font = new Font("Tahoma", 0, 12);\r
+ Font font = ElementUtils.getTextFont(e);\r
+ Color color = ElementUtils.getTextColor(e);\r
+ Color fillColor = ElementUtils.getFillColor(e);\r
+ Color borderColor = ElementUtils.getBorderColor(e, Color.BLACK);\r
+ String text = ElementUtils.getText(e);\r
+ AffineTransform at = ElementUtils.getTransform(e);\r
+ node.init(text, font, color, originX, originY, 0.235);\r
+ node.setBackgroundColor(fillColor);\r
+ node.setBorderColor(borderColor);\r
+ node.setHorizontalAlignment((byte) horizontalAlignment.ordinal());\r
+ node.setPadding(paddingX, paddingY);\r
+ node.setBorderWidth((float) borderWidth);\r
+ node.setEditable(editable);\r
+ if(at != null)\r
+ node.setTransform(at);\r
+\r
+ this.hoverHintListener = new IHintListener() {\r
+ @Override\r
+ public void hintRemoved(IHintObservable sender, Key key, Object oldValue) {\r
+\r
+ }\r
+\r
+ @Override\r
+ public void hintChanged(IHintObservable sender, Key key, Object oldValue, Object newValue) {\r
+ if(key == ElementHints.KEY_HOVER) {\r
+ IElement e = (IElement)sender;\r
+ TextNode name = (TextNode) e.getHint(SG_NODE);\r
+ if(name != null)\r
+ name.setHover(Boolean.TRUE.equals(e.getHint(ElementHints.KEY_HOVER)));\r
+ }\r
+ }\r
+ };\r
+ e.addHintListener(hoverHintListener);\r
+ }\r
+\r
+ @Override\r
+ public void cleanup(IElement e) {\r
+ if(hoverHintListener != null)\r
+ e.removeHintListener(hoverHintListener);\r
+ ElementUtils.removePossibleNode(e, SG_NODE);\r
+ }\r
+}
\ No newline at end of file
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2010 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.ui.elements2;\r
+\r
+import java.awt.BasicStroke;\r
+import java.awt.Color;\r
+import java.awt.Graphics2D;\r
+import java.awt.geom.AffineTransform;\r
+import java.awt.geom.Rectangle2D;\r
+\r
+import org.simantics.diagram.elements.TextNode;\r
+import org.simantics.g2d.utils.Alignment;\r
+import org.simantics.scenegraph.ISelectionPainterNode;\r
+import org.simantics.scenegraph.utils.NodeUtil;\r
+\r
+public class HoverTextNode extends TextNode implements ISelectionPainterNode {\r
+\r
+ private static final long serialVersionUID = 3539499125943249895L;\r
+
+ private static transient ThreadLocal<Rectangle2D> tempBounds = new ThreadLocal<Rectangle2D>() {\r
+ @Override\r
+ protected Rectangle2D initialValue() {\r
+ return new Rectangle2D.Double();\r
+ }\r
+ };\r
+\r
+ @Override\r
+ public void render(Graphics2D g) {\r
+ if (text == null || font == null || color == null)\r
+ return;\r
+\r
+ AffineTransform ot = g.getTransform();\r
+ g.transform(transform);\r
+\r
+ boolean selected = NodeUtil.isSelected(this, 1);\r
+ if (!selected && hover){\r
+ BasicStroke oldStroke = (BasicStroke)g.getStroke();\r
+ Color oldColor = g.getColor();\r
+ g.setColor(Color.LIGHT_GRAY);\r
+ g.setStroke(new BasicStroke((float)(2.0f * scale)));\r
+ g.translate(x, y);\r
+ Rectangle2D r = expandBounds( alignBounds( getTightUnalignedBoundsInLocal( tempBounds.get() ) ) );\r
+ g.draw(r);\r
+ g.translate(-x, -y);\r
+ g.setColor(oldColor);\r
+ g.setStroke(oldStroke);\r
+ }\r
+\r
+ super.render(g, false);\r
+ g.setTransform(ot);\r
+ }\r
+\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2010 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.ui.elements2;\r
+\r
+import org.simantics.g2d.element.IElement;\r
+import org.simantics.g2d.element.handler.ElementHandler;\r
+\r
+public class Input implements ElementHandler {\r
+\r
+ private static final long serialVersionUID = -1526125969376635502L;\r
+ \r
+ public static final Input INSTANCE = new Input();\r
+ \r
+ public String getInputReference(IElement e) {\r
+ return e.getHint(SysdynElementHints.KEY_INPUT_REFERENCE);\r
+ }\r
+\r
+ \r
+ public void setInputReference(IElement e, String inputReference) {\r
+ if (inputReference != null)\r
+ e.setHint(SysdynElementHints.KEY_INPUT_REFERENCE, inputReference);\r
+ else\r
+ e.removeHint(SysdynElementHints.KEY_INPUT_REFERENCE);\r
+ }\r
+ \r
+\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2010 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.ui.elements2;\r
+\r
+import java.awt.BasicStroke;\r
+import java.awt.Color;\r
+import java.awt.Font;\r
+import java.awt.Shape;\r
+import java.awt.geom.AffineTransform;\r
+import java.awt.geom.Path2D;\r
+import java.awt.geom.Rectangle2D;\r
+import java.util.Collection;\r
+\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.db.layer0.exception.MissingVariableException;\r
+import org.simantics.db.layer0.variable.Variable;\r
+import org.simantics.db.layer0.variable.Variables;\r
+import org.simantics.diagram.elements.TextNode;\r
+import org.simantics.diagram.stubs.DiagramResource;\r
+import org.simantics.diagram.ui.DiagramModelHints;\r
+import org.simantics.g2d.canvas.ICanvasContext;\r
+import org.simantics.g2d.diagram.IDiagram;\r
+import org.simantics.g2d.element.ElementClass;\r
+import org.simantics.g2d.element.ElementUtils;\r
+import org.simantics.g2d.element.IElement;\r
+import org.simantics.g2d.element.SceneGraphNodeKey;\r
+import org.simantics.g2d.element.handler.InternalSize;\r
+import org.simantics.g2d.element.handler.impl.BoundsOutline;\r
+import org.simantics.g2d.element.handler.impl.DefaultTransform;\r
+import org.simantics.g2d.element.handler.impl.HoverImpl;\r
+import org.simantics.g2d.element.handler.impl.ObjectTerminal;\r
+import org.simantics.g2d.element.handler.impl.OutlinePick;\r
+import org.simantics.g2d.element.handler.impl.SimpleElementLayers;\r
+import org.simantics.g2d.element.handler.impl.StaticObjectAdapter;\r
+import org.simantics.g2d.element.handler.impl.StaticSymbolImageInitializer;\r
+import org.simantics.g2d.element.handler.impl.StaticSymbolImpl;\r
+import org.simantics.g2d.element.handler.impl.TextColorImpl;\r
+import org.simantics.g2d.element.handler.impl.TextFontImpl;\r
+import org.simantics.g2d.element.handler.impl.TextImpl;\r
+import org.simantics.g2d.image.Image;\r
+import org.simantics.g2d.image.impl.ShapeImage;\r
+import org.simantics.g2d.utils.Alignment;\r
+import org.simantics.layer0.Layer0;\r
+import org.simantics.modeling.ModelingResources;\r
+import org.simantics.scenegraph.g2d.G2DParentNode;\r
+import org.simantics.sysdyn.SysdynResource;\r
+import org.simantics.sysdyn.adapter.ChildVariable;\r
+import org.simantics.sysdyn.adapter.ConfigurationVariable;\r
+import org.simantics.sysdyn.adapter.RunVariable;\r
+import org.simantics.utils.datastructures.hints.IHintContext.Key;\r
+\r
+public class InputFactory extends SysdynElementFactory {\r
+\r
+ private static final BasicStroke STROKE = new BasicStroke(1f);\r
+ public static final Image INPUT_IMAGE = new ShapeImage(getInputShape(), null, STROKE, true);\r
+\r
+ static Shape getInputShape() {\r
+ Path2D path = new Path2D.Double();\r
+ path.moveTo(-6, -1);\r
+ path.lineTo(-1, -1);\r
+ path.lineTo(-1, -2.5);\r
+ path.lineTo(1.5, 0);\r
+ path.curveTo(1.5, -2.5, 6.5, -2.5, 6.5, 0);\r
+ path.curveTo(6.5, 2.5, 1.5, 2.5, 1.5, 0);\r
+ path.lineTo(-1, 2.5);\r
+ path.lineTo(-1, 1);\r
+ path.lineTo(-6, 1);\r
+ path.closePath();\r
+ return path;\r
+ }\r
+\r
+ @Override\r
+ protected ElementClass compileElementClass(Resource elementType, Collection<ObjectTerminal> terminals) {\r
+ return ElementClass.compile(\r
+ SimpleElementLayers.INSTANCE,\r
+ OutlinePick.INSTANCE,\r
+ TextImpl.INSTANCE,\r
+ TextColorImpl.BLACK,\r
+ TextFontImpl.DEFAULT,\r
+ DefaultTransform.INSTANCE,\r
+ new StaticObjectAdapter(elementType),\r
+ new StaticSymbolImpl(INPUT_IMAGE),\r
+ StaticSymbolImageInitializer.INSTANCE,\r
+ Input.INSTANCE,\r
+ new InputSceneGraph(0, 0, Alignment.LEADING),\r
+ BoundsOutline.INSTANCE,\r
+ HoverImpl.INSTANCE,\r
+ new WholeElementTerminals(terminals)\r
+ ).setId(InputFactory.class.getSimpleName());\r
+ }\r
+\r
+ @Override\r
+ public void load(ReadGraph graph, final ICanvasContext canvas, final IDiagram diagram, final Resource element, final IElement e) throws DatabaseException {\r
+ super.load(graph, canvas, diagram, element, e);\r
+ Layer0 l0 = Layer0.getInstance(graph);\r
+ ModelingResources mr = ModelingResources.getInstance(graph);\r
+ SysdynResource sr = SysdynResource.getInstance(graph);\r
+ Resource component = null;\r
+ Resource dependency = null;\r
+ Resource refersTo = null;\r
+ Resource module = null;\r
+ String moduleName = "";\r
+ String referenceName = "";\r
+ component = graph.getPossibleObject(element, mr.ElementToComponent);\r
+ if(component != null) \r
+ dependency = graph.getPossibleObject(component, sr.IsHeadOf);\r
+ if(dependency != null) {\r
+ refersTo = graph.getPossibleObject(dependency, sr.RefersTo);\r
+ if(refersTo != null) {\r
+ referenceName = (String) graph.getPossibleRelatedValue(refersTo, l0.HasName);\r
+ module = graph.getPossibleObject(dependency, sr.HasTail);\r
+ moduleName = (String) graph.getPossibleRelatedValue(module, l0.HasName);\r
+ }\r
+ } else {\r
+ Resource runtime = diagram.getHint((DiagramModelHints.KEY_DIAGRAM_RUNTIME_RESOURCE));\r
+ DiagramResource dr = DiagramResource.getInstance(graph);\r
+ String variable = (String)graph.getPossibleRelatedValue(runtime, dr.HasVariable);\r
+ if(variable == null)\r
+ return;\r
+ \r
+ \r
+ try {\r
+ Variable v = Variables.getVariable(graph, variable);\r
+ if(v instanceof ChildVariable) {\r
+ module = ((ChildVariable)v).getRepresents(graph);\r
+ }\r
+ if(module != null)\r
+ for(Resource dep : graph.getObjects(module, sr.IsHeadOf)) {\r
+ Resource reference = graph.getPossibleObject(dep, sr.RefersTo);\r
+ if(reference!= null && reference.equals(component)) {\r
+ refersTo = graph.getSingleObject(dep, sr.HasTail);\r
+ referenceName = (String) graph.getPossibleRelatedValue(refersTo, l0.HasName);\r
+ Variable parent = null;\r
+ if(v instanceof ChildVariable)\r
+ parent = ((ChildVariable)v).getParent(graph);\r
+ if(parent != null && !(parent instanceof RunVariable) && !(parent instanceof ConfigurationVariable)) {\r
+ String parentURI = parent.getURI(graph);\r
+ moduleName = (String) graph.getPossibleRelatedValue(graph.getResource(parentURI), l0.HasName);\r
+ }\r
+ break;\r
+ }\r
+ }\r
+ } catch (MissingVariableException mve) {\r
+ // DO nothing.\r
+ }\r
+ }\r
+\r
+ String inputReference = null;\r
+ if (moduleName != null && refersTo != null) {\r
+ inputReference = moduleName + "." + referenceName;\r
+ }\r
+ if (inputReference == null) {\r
+ inputReference = "";\r
+ }\r
+\r
+ SysdynElementUtils.setInputReference(e, inputReference);\r
+\r
+ Font font = ElementUtils.getTextFont(e);\r
+ font = font.deriveFont(font.getStyle() + Font.ITALIC);\r
+ ElementUtils.setTextFont(e, font);\r
+ ElementUtils.setHover(e, false);\r
+ }\r
+\r
+\r
+ public static class InputSceneGraph extends HoverTextElementNoBounds implements InternalSize {\r
+\r
+ private static final long serialVersionUID = -3713275157729126409L;\r
+ public static final Key INPUT_SG_NODE = new SceneGraphNodeKey(TextNode.class, "INPUT_SG_NODE");\r
+\r
+ private final double originX;\r
+ private final Alignment horizontalAlignment;\r
+\r
+ public InputSceneGraph(double originX, double originY, Alignment horizontalAlignment) {\r
+ super(originX, originY, horizontalAlignment, 0.0, 2.0, 2.0, true);\r
+ this.originX = originX;\r
+ this.horizontalAlignment = horizontalAlignment;\r
+ }\r
+\r
+ @Override\r
+ public void init(final IElement e, G2DParentNode parent) {\r
+ super.init(e, parent);\r
+ TextNode node = ElementUtils.getOrCreateNode(e, parent, INPUT_SG_NODE, "input", TextNode.class);\r
+ Font font = ElementUtils.getTextFont(e);\r
+ font = font.deriveFont((float) 10.0);\r
+ font = font.deriveFont(Font.ITALIC);\r
+ Color color = new Color(150, 150, 150);\r
+ Color fillColor = ElementUtils.getFillColor(e);\r
+ Color borderColor = ElementUtils.getBorderColor(e, Color.BLACK);\r
+ String text = SysdynElementUtils.getInputReference(e);\r
+ double scale = 0.235;\r
+ AffineTransform at = ElementUtils.getTransform(e);\r
+ node.init(text, font, color, originX, font.getSize2D() * scale, scale);\r
+ node.setBackgroundColor(fillColor);\r
+ node.setBorderColor(borderColor);\r
+ node.setHorizontalAlignment((byte) horizontalAlignment.ordinal());\r
+ node.setBorderWidth((float) 0);\r
+ node.setEditable(false);\r
+ node.setShowSelection(false);\r
+ \r
+ if(at != null)\r
+ node.setTransform(at);\r
+ }\r
+\r
+ @Override\r
+ public Rectangle2D getBounds(IElement e, Rectangle2D size) {\r
+ TextNode name = (TextNode) e.getHint(SG_NODE);\r
+ TextNode reference = (TextNode) e.getHint(INPUT_SG_NODE);\r
+ if (size == null)\r
+ size = new Rectangle2D.Double();\r
+ if (name != null)\r
+ size.setRect(name.getBoundsInLocal());\r
+ if(reference != null) {\r
+ if (reference.getBoundsInLocal().getWidth() > size.getWidth())\r
+ size.setRect(size.getX(), size.getY(), reference.getBoundsInLocal().getWidth(), size.getHeight());\r
+ }\r
+ else\r
+ size.setFrame(0, 0, 0, 0);\r
+ return size;\r
+ }\r
+\r
+ }\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2010 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.ui.elements2;\r
+\r
+import java.awt.BasicStroke;\r
+import java.awt.Font;\r
+import java.awt.geom.Rectangle2D;\r
+import java.util.Collection;\r
+\r
+import org.simantics.db.Resource;\r
+import org.simantics.g2d.element.ElementClass;\r
+import org.simantics.g2d.element.handler.impl.BoundsOutline;\r
+import org.simantics.g2d.element.handler.impl.DefaultTransform;\r
+import org.simantics.g2d.element.handler.impl.ObjectTerminal;\r
+import org.simantics.g2d.element.handler.impl.OutlinePick;\r
+import org.simantics.g2d.element.handler.impl.SimpleElementLayers;\r
+import org.simantics.g2d.element.handler.impl.StaticObjectAdapter;\r
+import org.simantics.g2d.element.handler.impl.StaticSymbolImageInitializer;\r
+import org.simantics.g2d.element.handler.impl.StaticSymbolImpl;\r
+import org.simantics.g2d.element.handler.impl.TextColorImpl;\r
+import org.simantics.g2d.element.handler.impl.TextFontImpl;\r
+import org.simantics.g2d.element.handler.impl.TextImpl;\r
+import org.simantics.g2d.image.Image;\r
+import org.simantics.g2d.image.impl.ShapeImage;\r
+import org.simantics.g2d.utils.Alignment;\r
+\r
+public class ModuleFactory extends SysdynElementFactory {\r
+\r
+ private static final BasicStroke STROKE = new BasicStroke(1f);\r
+ private static final Image DEFAULT_IMAGE = new ShapeImage(new Rectangle2D.Double(-5, -2.5, 10, 5), null, STROKE, true);\r
+\r
+ @Override\r
+ protected ElementClass compileElementClass(Resource elementType, Collection<ObjectTerminal> terminals) {\r
+ return ElementClass.compile(\r
+ SimpleElementLayers.INSTANCE,\r
+ OutlinePick.INSTANCE,\r
+ TextImpl.INSTANCE,\r
+ TextColorImpl.BLACK,\r
+ new TextFontImpl(new Font("arial", Font.PLAIN, 25)),\r
+ DefaultTransform.INSTANCE,\r
+ new StaticObjectAdapter(elementType),\r
+ new StaticSymbolImpl(DEFAULT_IMAGE),\r
+ StaticSymbolImageInitializer.INSTANCE,\r
+ new HoverTextElementHandler(0, 0, Alignment.LEADING, 1f , 7, 7, true),\r
+ BoundsOutline.INSTANCE,\r
+ new WholeElementTerminals(terminals)\r
+ ).setId(ModuleFactory.class.getSimpleName());\r
+ }\r
+\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2010 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.ui.elements2;\r
+\r
+import java.awt.BasicStroke;\r
+import java.awt.Color;\r
+import java.awt.Graphics2D;\r
+import java.awt.geom.AffineTransform;\r
+import java.awt.geom.Rectangle2D;\r
+import org.simantics.scenegraph.g2d.G2DNode;\r
+\r
+public class RectangleNode extends G2DNode {\r
+ \r
+ private static final long serialVersionUID = 654692698101485672L;\r
+\r
+ protected Rectangle2D bounds = null;\r
+\r
+ @SyncField("bounds")\r
+ public void init(Rectangle2D bounds) {\r
+ this.bounds = bounds;\r
+ }\r
+\r
+ @Override\r
+ public void render(Graphics2D g) {\r
+ if(bounds == null) return;\r
+ AffineTransform ot = g.getTransform();\r
+ \r
+ g.transform(transform);\r
+ g.setColor(Color.BLACK);\r
+ double scale = g.getTransform().getScaleX();\r
+ g.setStroke(new BasicStroke( (float)(1.0 / scale) ));\r
+\r
+ g.draw(bounds);\r
+ g.setTransform(ot);\r
+ }\r
+\r
+ @Override\r
+ public Rectangle2D getBoundsInLocal() {\r
+ return bounds;\r
+ }\r
+ \r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2010 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.ui.elements2;\r
+\r
+import java.awt.BasicStroke;\r
+import java.awt.geom.Rectangle2D;\r
+import java.util.Collection;\r
+\r
+import org.simantics.db.Resource;\r
+import org.simantics.g2d.element.ElementClass;\r
+import org.simantics.g2d.element.handler.impl.BoundsOutline;\r
+import org.simantics.g2d.element.handler.impl.DefaultTransform;\r
+import org.simantics.g2d.element.handler.impl.ObjectTerminal;\r
+import org.simantics.g2d.element.handler.impl.OutlinePick;\r
+import org.simantics.g2d.element.handler.impl.SimpleElementLayers;\r
+import org.simantics.g2d.element.handler.impl.StaticObjectAdapter;\r
+import org.simantics.g2d.element.handler.impl.StaticSymbolImageInitializer;\r
+import org.simantics.g2d.element.handler.impl.StaticSymbolImpl;\r
+import org.simantics.g2d.element.handler.impl.TextColorImpl;\r
+import org.simantics.g2d.element.handler.impl.TextFontImpl;\r
+import org.simantics.g2d.element.handler.impl.TextImpl;\r
+import org.simantics.g2d.image.Image;\r
+import org.simantics.g2d.image.impl.ShapeImage;\r
+import org.simantics.g2d.utils.Alignment;\r
+\r
+public class StockFactory extends SysdynElementFactory {\r
+\r
+ private static final BasicStroke STROKE = new BasicStroke(1f);\r
+ public static final Image STOCK_IMAGE = new ShapeImage(new Rectangle2D.Double(-5, -2.5, 10, 5), null, STROKE, true);\r
+\r
+ @Override\r
+ protected ElementClass compileElementClass(Resource elementType, Collection<ObjectTerminal> terminals) {\r
+ return ElementClass.compile(\r
+ SimpleElementLayers.INSTANCE,\r
+ OutlinePick.INSTANCE,\r
+ TextImpl.INSTANCE,\r
+ TextColorImpl.BLACK,\r
+ TextFontImpl.DEFAULT,\r
+ DefaultTransform.INSTANCE,\r
+ new StaticObjectAdapter(elementType),\r
+ new StaticSymbolImpl(STOCK_IMAGE),\r
+ StaticSymbolImageInitializer.INSTANCE,\r
+ new HoverTextElementHandler(0, 0, Alignment.LEADING, 1f),\r
+ BoundsOutline.INSTANCE,\r
+ new WholeElementTerminals(terminals)\r
+ ).setId(StockFactory.class.getSimpleName());\r
+ }\r
+\r
+}\r
--- /dev/null
+package org.simantics.sysdyn.ui.elements2;\r
+\r
+public class SysdynElementClasses {\r
+\r
+ public static final Object VALVE = new Object() {\r
+ public String toString() { return "VALVE"; }\r
+ };\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2010 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.ui.elements2;\r
+\r
+import java.awt.Font;\r
+import java.awt.geom.AffineTransform;\r
+import java.util.ArrayList;\r
+import java.util.Collection;\r
+import java.util.Collections;\r
+\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.common.utils.OrderedSetUtils;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.db.exception.ManyObjectsForFunctionalRelationException;\r
+import org.simantics.db.exception.ServiceException;\r
+import org.simantics.diagram.G2DUtils;\r
+import org.simantics.diagram.adapter.SyncElementFactory;\r
+import org.simantics.diagram.content.ResourceTerminal;\r
+import org.simantics.diagram.stubs.DiagramResource;\r
+import org.simantics.diagram.stubs.G2DResource;\r
+import org.simantics.diagram.synchronization.CompositeHintSynchronizer;\r
+import org.simantics.diagram.synchronization.IHintSynchronizer;\r
+import org.simantics.diagram.synchronization.SynchronizationHints;\r
+import org.simantics.diagram.synchronization.graph.DiagramGraphUtil;\r
+import org.simantics.diagram.synchronization.graph.TransformSynchronizer;\r
+import org.simantics.g2d.canvas.ICanvasContext;\r
+import org.simantics.g2d.diagram.IDiagram;\r
+import org.simantics.g2d.element.ElementClass;\r
+import org.simantics.g2d.element.ElementHints;\r
+import org.simantics.g2d.element.ElementUtils;\r
+import org.simantics.g2d.element.IElement;\r
+import org.simantics.g2d.element.handler.impl.ObjectTerminal;\r
+import org.simantics.layer0.Layer0;\r
+import org.simantics.modeling.ModelingResources;\r
+import org.simantics.structural.stubs.StructuralResource2;\r
+import org.simantics.sysdyn.SysdynResource;\r
+\r
+/**\r
+ * An ElementFactory that gathers common functionality for system dynamics symbols.\r
+ * Just implement {@link #compileElementClass(Resource, Collection)} to add a symbol.\r
+ * \r
+ * @author Tuukka Lehtonen\r
+ */\r
+public abstract class SysdynElementFactory extends SyncElementFactory {\r
+\r
+ public static final IHintSynchronizer SYNCHRONIZER = new CompositeHintSynchronizer(\r
+ ComponentNameSynchronizer.INSTANCE,\r
+ TransformSynchronizer.INSTANCE);\r
+\r
+ @Override\r
+ public void load(ReadGraph graph, final ICanvasContext canvas, final IDiagram diagram, final Resource element, final IElement e) throws DatabaseException {\r
+ Layer0 l0 = Layer0.getInstance(graph);\r
+ G2DResource g2d = G2DResource.getInstance(graph);\r
+ DiagramResource dr = DiagramResource.getInstance(graph);\r
+ ModelingResources mr = ModelingResources.getInstance(graph);\r
+\r
+ Resource component = graph.getPossibleObject(element, mr.ElementToComponent);\r
+ String text = null;\r
+ if (component != null) {\r
+ text = (String) graph.getPossibleRelatedValue(component, l0.HasName);\r
+ }\r
+ if (text == null)\r
+ text = "[empty]";\r
+\r
+ ElementUtils.setText(e, text);\r
+\r
+ if (graph.isInstanceOf(element, dr.FontProvider)) {\r
+ Resource fontResource = graph.getPossibleObject(element, g2d.HasFont);\r
+ if (fontResource != null)\r
+ ElementUtils.setTextFont(e, G2DUtils.getFont(graph, fontResource));\r
+ }\r
+ if (graph.isInstanceOf(element, dr.ColorProvider)) {\r
+ Resource colorResource = graph.getPossibleObject(element, g2d.HasColor);\r
+ if (colorResource != null)\r
+ ElementUtils.setTextColor(e, G2DUtils.getColor(graph, colorResource));\r
+ }\r
+\r
+ if (component != null && graph.hasStatement(component, SysdynResource.getInstance(graph).IsOutput)) {\r
+ Font font = ElementUtils.getTextFont(e);\r
+ font = font.deriveFont(Font.BOLD);\r
+ ElementUtils.setTextFont(e, font);\r
+ }\r
+\r
+ AffineTransform at = DiagramGraphUtil.getAffineTransform(graph, element);\r
+ ElementUtils.setTransform(e, at);\r
+\r
+ // This synchronizes only text and transformation (not font and color)\r
+ e.setHint(SynchronizationHints.HINT_SYNCHRONIZER, SYNCHRONIZER);\r
+ \r
+ e.setHint(ElementHints.KEY_HOVER, false);\r
+ }\r
+\r
+ @Override\r
+ public ElementClass create(ReadGraph graph, ICanvasContext canvas, IDiagram diagram, Resource elementType)\r
+ throws DatabaseException {\r
+ return compileElementClass(elementType, createTerminals(graph, elementType));\r
+ }\r
+ \r
+ public static Collection<ObjectTerminal> createTerminals(ReadGraph graph, Resource elementType) {\r
+\r
+ try {\r
+ StructuralResource2 sr = StructuralResource2.getInstance(graph);\r
+ DiagramResource dr = DiagramResource.getInstance(graph);\r
+\r
+ Resource definedByList = graph.getPossibleObject(elementType, sr.IsDefinedBy);\r
+ Collection<Resource> definedBy = Collections.emptyList();\r
+ if (definedByList != null)\r
+ definedBy = OrderedSetUtils.toList(graph, definedByList);\r
+ Collection<ObjectTerminal> terminals = new ArrayList<ObjectTerminal>(definedBy.size());\r
+ for (Resource r : definedBy) {\r
+ if (graph.isInstanceOf(r, dr.Terminal)) {\r
+ terminals.add(new ResourceTerminal(r));\r
+ }\r
+ }\r
+ return terminals;\r
+ } catch (ManyObjectsForFunctionalRelationException e) {\r
+ e.printStackTrace();\r
+ } catch (ServiceException e) {\r
+ e.printStackTrace();\r
+ } catch (DatabaseException e) {\r
+ e.printStackTrace();\r
+ }\r
+ return null;\r
+ }\r
+\r
+ /**\r
+ * @param elementType the type of the loaded element\r
+ * @param terminals the terminals of the element type being loaded\r
+ * @return an {@link ElementClass} representing the loaded element type\r
+ */\r
+ protected abstract ElementClass compileElementClass(Resource elementType, Collection<ObjectTerminal> terminals);\r
+\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2010 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.ui.elements2;\r
+\r
+import org.simantics.utils.datastructures.hints.IHintContext.Key;\r
+import org.simantics.utils.datastructures.hints.IHintContext.KeyOf;\r
+\r
+public class SysdynElementHints {\r
+\r
+ public static final Key KEY_INPUT_REFERENCE = new KeyOf(String.class, "INPUT_REFERENCE");\r
+ \r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2010 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.ui.elements2;\r
+\r
+import org.simantics.g2d.element.IElement;\r
+\r
+public class SysdynElementUtils {\r
+\r
+ \r
+ public static void setInputReference(IElement e, String inputReference)\r
+ {\r
+ Input i = e.getElementClass().getSingleItem(Input.class);\r
+ i.setInputReference(e, inputReference);\r
+ }\r
+\r
+ public static String getInputReference(IElement e)\r
+ {\r
+ Input i = e.getElementClass().getSingleItem(Input.class);\r
+ return i.getInputReference(e);\r
+ }\r
+ \r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2010 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.ui.elements2;\r
+\r
+import java.awt.BasicStroke;\r
+import java.awt.Color;\r
+import java.awt.geom.AffineTransform;\r
+import java.awt.geom.Path2D;\r
+import java.awt.geom.Rectangle2D;\r
+import java.util.Collection;\r
+\r
+import org.simantics.db.Resource;\r
+import org.simantics.g2d.element.ElementClass;\r
+import org.simantics.g2d.element.ElementHints;\r
+import org.simantics.g2d.element.ElementUtils;\r
+import org.simantics.g2d.element.IElement;\r
+import org.simantics.g2d.element.SceneGraphNodeKey;\r
+import org.simantics.g2d.element.handler.HandleMouseEvent;\r
+import org.simantics.g2d.element.handler.InternalSize;\r
+import org.simantics.g2d.element.handler.impl.BoundsOutline;\r
+import org.simantics.g2d.element.handler.impl.DefaultTransform;\r
+import org.simantics.g2d.element.handler.impl.HoverImpl;\r
+import org.simantics.g2d.element.handler.impl.ObjectTerminal;\r
+import org.simantics.g2d.element.handler.impl.OutlinePick;\r
+import org.simantics.g2d.element.handler.impl.SimpleElementLayers;\r
+import org.simantics.g2d.element.handler.impl.StaticObjectAdapter;\r
+import org.simantics.g2d.element.handler.impl.StaticSymbolImageInitializer;\r
+import org.simantics.g2d.element.handler.impl.StaticSymbolImpl;\r
+import org.simantics.g2d.element.handler.impl.TextColorImpl;\r
+import org.simantics.g2d.element.handler.impl.TextFontImpl;\r
+import org.simantics.g2d.element.handler.impl.TextImpl;\r
+import org.simantics.g2d.image.Image;\r
+import org.simantics.g2d.image.impl.ShapeImage;\r
+import org.simantics.g2d.utils.Alignment;\r
+import org.simantics.scenegraph.g2d.G2DParentNode;\r
+import org.simantics.scenegraph.g2d.nodes.ShapeNode;\r
+import org.simantics.utils.datastructures.hints.IHintListener;\r
+import org.simantics.utils.datastructures.hints.IHintObservable;\r
+import org.simantics.utils.datastructures.hints.IHintContext.Key;\r
+import org.simantics.utils.datastructures.hints.IHintContext.KeyOf;\r
+\r
+\r
+public class ValveFactory extends SysdynElementFactory {\r
+\r
+ public static final Key KEY_ROTATED = new KeyOf(Boolean.class, "ROTATED");\r
+\r
+ public static final double VALVE_SIZE = 2.5;\r
+\r
+ private static final BasicStroke STROKE = new BasicStroke(1f);\r
+ public static final Image VALVE_STATIC_IMAGE = new ShapeImage(createShape(VALVE_SIZE, false), null, STROKE, true);\r
+\r
+ /* (non-Javadoc)\r
+ * @see org.simantics.sysdyn.ui.elements2.SysdynElementFactory#compileElementClass(org.simantics.db.Resource, java.util.Collection)\r
+ */\r
+ @Override\r
+ protected ElementClass compileElementClass(Resource elementType, Collection<ObjectTerminal> terminals) {\r
+ return ElementClass.compile(\r
+ SimpleElementLayers.INSTANCE,\r
+ OutlinePick.INSTANCE,\r
+ TextImpl.INSTANCE,\r
+ TextColorImpl.BLACK,\r
+ TextFontImpl.DEFAULT,\r
+ DefaultTransform.INSTANCE,\r
+ new StaticObjectAdapter(elementType),\r
+ new StaticSymbolImpl(VALVE_STATIC_IMAGE),\r
+ StaticSymbolImageInitializer.INSTANCE,\r
+ HoverImpl.INSTANCE,\r
+ ValveSceneGraph.INSTANCE,\r
+ BoundsOutline.INSTANCE,\r
+ new WholeElementTerminals(terminals)\r
+ ).setId(ValveFactory.class.getSimpleName());\r
+ }\r
+ \r
+ /**\r
+ * @param valveSize\r
+ * @param rotated <code>true</code> for vertical valve, <code>false</code>\r
+ * for horizontal\r
+ * @return\r
+ */\r
+ private static Path2D createShape(double valveSize, boolean rotated) {\r
+ Path2D path = new Path2D.Double();\r
+ path.moveTo(-valveSize, -valveSize);\r
+ if(rotated) {\r
+ path.lineTo(-valveSize, +valveSize);\r
+ path.lineTo(+valveSize, -valveSize);\r
+ } else {\r
+ path.lineTo(+valveSize, -valveSize);\r
+ path.lineTo(-valveSize, +valveSize);\r
+ }\r
+ path.lineTo(+valveSize, +valveSize);\r
+ path.closePath();\r
+ return path;\r
+ }\r
+\r
+ public static class ValveSceneGraph extends HoverTextElementNoBounds implements InternalSize, HandleMouseEvent {\r
+\r
+ private static final long serialVersionUID = 5544256245734478634L;\r
+\r
+ public static final ValveSceneGraph INSTANCE = new ValveSceneGraph();\r
+\r
+ private static final Key NODE = new SceneGraphNodeKey(ShapeNode.class, "VALVE_NODE");\r
+ \r
+ private IHintListener hoverHintListener;\r
+\r
+ public ValveSceneGraph() {\r
+ super(0, VALVE_SIZE + 3.0, Alignment.CENTER);\r
+ }\r
+ @Override\r
+ public void init(IElement e, G2DParentNode parent) {\r
+ super.init(e, parent);\r
+ AffineTransform at = ElementUtils.getTransform(e);\r
+ final HoverShapeNode node = ElementUtils.getOrCreateNode(e, parent, NODE, "valve", HoverShapeNode.class);\r
+\r
+ // Calculate borders from text node bounds.\r
+ node.setStroke(STROKE);\r
+ node.setScaleStroke(true);\r
+ node.setColor(Color.BLACK);\r
+ node.setShape(createShape(VALVE_SIZE, Boolean.TRUE.equals(e.getHint(KEY_ROTATED))));\r
+ Boolean hover = e.getHint(ElementHints.KEY_HOVER); \r
+ node.setHover(hover != null ? hover : false);\r
+\r
+ if(at != null)\r
+ node.setTransform(at);\r
+ \r
+ hoverHintListener = new IHintListener() {\r
+ \r
+ @Override\r
+ public void hintRemoved(IHintObservable sender, Key key, Object oldValue) {\r
+ \r
+ }\r
+ \r
+ @Override\r
+ public void hintChanged(IHintObservable sender, Key key, Object oldValue, Object newValue) {\r
+ IElement e = (IElement)sender;\r
+ HoverShapeNode shape = (HoverShapeNode) e.getHint(NODE);\r
+ if(shape == null) {\r
+ return;\r
+ }\r
+ boolean hover = ElementUtils.isHovering(e);\r
+ shape.setHover(hover);\r
+ }\r
+ };\r
+ e.addHintListener(hoverHintListener);\r
+ }\r
+\r
+ @Override\r
+ public void cleanup(IElement e) {\r
+ e.removeHintListener(hoverHintListener);\r
+ ElementUtils.removePossibleNode(e, NODE);\r
+ }\r
+\r
+ @Override\r
+ public Rectangle2D getBounds(IElement e, Rectangle2D size) {\r
+ if (size == null)\r
+ size = new Rectangle2D.Double();\r
+ size.setFrame(createShape(VALVE_SIZE, Boolean.TRUE.equals(e.getHint(KEY_ROTATED))).getBounds2D());\r
+ double paddingX = 2.0;\r
+ double paddingY = 2.0;\r
+ size.setRect(size.getX() - paddingX, size.getY() -paddingY, size.getWidth() + paddingX + paddingX, size.getHeight() + paddingY + paddingY);\r
+ return size;\r
+ }\r
+\r
+ }\r
+\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2010 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.ui.elements2;\r
+\r
+import java.awt.Shape;\r
+import java.util.Collection;\r
+\r
+import org.simantics.g2d.diagram.handler.Topology.Terminal;\r
+import org.simantics.g2d.element.ElementUtils;\r
+import org.simantics.g2d.element.IElement;\r
+import org.simantics.g2d.element.handler.impl.ObjectTerminal;\r
+import org.simantics.g2d.element.handler.impl.Terminals;\r
+\r
+/**\r
+ * @author Tuukka Lehtonen\r
+ */\r
+public class WholeElementTerminals extends Terminals {\r
+\r
+ private static final long serialVersionUID = -8209833430671135001L;\r
+\r
+ public WholeElementTerminals(Collection<ObjectTerminal> ts) {\r
+ super(ts);\r
+ }\r
+\r
+ @Override\r
+ public Shape getTerminalShape(IElement node, Terminal t) {\r
+ // For each terminal, return the shape of the element.\r
+ return ElementUtils.getElementShapeOrBounds(node);\r
+ }\r
+\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2010 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.ui.elements2.connections;\r
+\r
+import java.awt.geom.Rectangle2D;\r
+\r
+public class Arcs {\r
+\r
+ public static final double PI2 = Math.PI*2.0;\r
+ \r
+ /**\r
+ * Returns angle + 2PI * n such that the\r
+ * result is between -PI and PI.\r
+ */\r
+ public static double normalizeAngle(double angle) {\r
+ return Math.IEEEremainder(angle, PI2);\r
+ }\r
+ \r
+ /**\r
+ * Returns true, if three normalized angles are clockwise oriented.\r
+ */\r
+ public static boolean areClockwiseOrdered(double angle1, double angle2, double angle3) {\r
+ //System.out.println(angle1 + " " + angle2 + " " + angle3);\r
+ return angle1 < angle2 \r
+ ? (angle2 < angle3 || angle3 < angle1)\r
+ : (angle2 < angle3 && angle3 < angle1)\r
+ ;\r
+ }\r
+ \r
+ /**\r
+ * Returns an angle in radians between straight line from (x0,y0) to (x2,y2)\r
+ * and an arc from (x0,y0) to (x2,y2) thru (x1,y1). The angle\r
+ * is measured at (x0,y0) and is between -PI and PI.\r
+ */\r
+ public static double angleOfArc(\r
+ double x0, double y0, \r
+ double x1, double y1,\r
+ double x2, double y2) {\r
+ double dx0 = x1-x0;\r
+ double dy0 = y1-y0;\r
+ double dx1 = x1-x2;\r
+ double dy1 = y1-y2;\r
+ double dx = x2-x0;\r
+ double dy = y2-y0;\r
+ // Length of cross product (p1-p0)x(p2-p0)\r
+ double dd = dx0*dy - dy0*dx; \r
+ \r
+ if(Math.abs(dd) < 1e-6) // Points are (almost) collinear\r
+ return 0.0;\r
+ else { \r
+ // (p1-p0)*(p1-p2) / dd\r
+ double offset = (dx0*dx1 + dy0*dy1) / dd;\r
+ double angle = Math.PI*0.5 - Math.atan(offset);\r
+ if(dd > 0.0)\r
+ angle = angle-Math.PI;\r
+ return angle;\r
+ \r
+ }\r
+ }\r
+ \r
+ private static double updateBestNextAngle(double curAngle, double bestAngle, double newAngle) {\r
+ if(newAngle < curAngle)\r
+ newAngle += PI2;\r
+ if(newAngle < bestAngle)\r
+ return newAngle;\r
+ return bestAngle; \r
+ } \r
+ \r
+ private static double updateBestPrevAngle(double curAngle, double bestAngle, double newAngle) {\r
+ if(newAngle > curAngle)\r
+ newAngle -= PI2;\r
+ if(newAngle > bestAngle)\r
+ return newAngle;\r
+ return bestAngle; \r
+ } \r
+ \r
+ public static double nextIntersectingAngle(double cx, double cy, double r,\r
+ double curAngle, Rectangle2D rect, boolean dir) {\r
+ if(!dir) {\r
+ double bestAngle = curAngle + PI2;\r
+ {\r
+ double dx = rect.getMinX() - cx;\r
+ if(Math.abs(dx) < r) {\r
+ double angle = normalizeAngle(Math.acos(dx / r));\r
+ bestAngle = updateBestNextAngle(curAngle, bestAngle, angle);\r
+ bestAngle = updateBestNextAngle(curAngle, bestAngle, -angle);\r
+ }\r
+ }\r
+ {\r
+ double dx = rect.getMaxX() - cx;\r
+ if(Math.abs(dx) < r) {\r
+ double angle = normalizeAngle(Math.acos(dx / r));\r
+ bestAngle = updateBestNextAngle(curAngle, bestAngle, angle);\r
+ bestAngle = updateBestNextAngle(curAngle, bestAngle, -angle);\r
+ }\r
+ }\r
+ {\r
+ double dy = cy - rect.getMinY();\r
+ if(Math.abs(dy) < r) {\r
+ double angle = Math.asin(dy / r);\r
+ bestAngle = updateBestNextAngle(curAngle, bestAngle, angle);\r
+ bestAngle = updateBestNextAngle(curAngle, bestAngle, \r
+ normalizeAngle(Math.PI-angle));\r
+ }\r
+ }\r
+ {\r
+ double dy = cy - rect.getMaxY();\r
+ if(Math.abs(dy) < r) {\r
+ double angle = Math.asin(dy / r);\r
+ bestAngle = updateBestNextAngle(curAngle, bestAngle, angle);\r
+ bestAngle = updateBestNextAngle(curAngle, bestAngle, \r
+ normalizeAngle(Math.PI-angle));\r
+ }\r
+ }\r
+ return normalizeAngle(bestAngle);\r
+ } \r
+ else {\r
+ double bestAngle = curAngle - PI2;\r
+ {\r
+ double dx = rect.getMinX() - cx;\r
+ if(Math.abs(dx) < r) {\r
+ double angle = normalizeAngle(Math.acos(dx / r));\r
+ bestAngle = updateBestPrevAngle(curAngle, bestAngle, angle);\r
+ bestAngle = updateBestPrevAngle(curAngle, bestAngle, -angle);\r
+ }\r
+ }\r
+ {\r
+ double dx = rect.getMaxX() - cx;\r
+ if(Math.abs(dx) < r) {\r
+ double angle = normalizeAngle(Math.acos(dx / r));\r
+ bestAngle = updateBestPrevAngle(curAngle, bestAngle, angle);\r
+ bestAngle = updateBestPrevAngle(curAngle, bestAngle, -angle);\r
+ }\r
+ }\r
+ {\r
+ double dy = cy - rect.getMinY();\r
+ if(Math.abs(dy) < r) {\r
+ double angle = Math.asin(dy / r);\r
+ bestAngle = updateBestPrevAngle(curAngle, bestAngle, angle);\r
+ bestAngle = updateBestPrevAngle(curAngle, bestAngle, \r
+ normalizeAngle(Math.PI-angle));\r
+ }\r
+ }\r
+ {\r
+ double dy = cy - rect.getMaxY();\r
+ if(Math.abs(dy) < r) {\r
+ double angle = Math.asin(dy / r);\r
+ bestAngle = updateBestPrevAngle(curAngle, bestAngle, angle);\r
+ bestAngle = updateBestPrevAngle(curAngle, bestAngle, \r
+ normalizeAngle(Math.PI-angle));\r
+ }\r
+ }\r
+ return normalizeAngle(bestAngle);\r
+ }\r
+ }\r
+ \r
+ public static boolean hitTest(Rectangle2D beginBounds, Rectangle2D endBounds, double angle, double x, double y, double tolerance) {\r
+ \r
+ boolean clockWise = angle > 0;\r
+ \r
+ double x0 = beginBounds.getCenterX();\r
+ double y0 = beginBounds.getCenterY();\r
+ double x1 = endBounds.getCenterX();\r
+ double y1 = endBounds.getCenterY();\r
+ \r
+ double offset = \r
+ Math.abs(angle) < 1.0e-6\r
+ ? 1e3 * Math.signum(angle)\r
+ : Math.tan(Math.PI*0.5-angle)*0.5;\r
+ double cx = 0.5*(x0+x1) + offset * (y1-y0);\r
+ double cy = 0.5*(y0+y1) + offset * (x0-x1);\r
+ double dx0 = x0 - cx;\r
+ double dy0 = y0 - cy;\r
+ double dx1 = x1 - cx;\r
+ double dy1 = y1 - cy;\r
+ double r = Math.sqrt(dx0*dx0 + dy0*dy0);\r
+ double angle0 = Arcs.nextIntersectingAngle(cx, cy, r, \r
+ Math.atan2(-dy0, dx0), beginBounds, angle < 0.0);\r
+ double angle1 = Arcs.nextIntersectingAngle(cx, cy, r, \r
+ Math.atan2(-dy1, dx1), endBounds, angle > 0.0);\r
+ \r
+ double dx = x-cx;\r
+ double dy = y-cy;\r
+ double dist = dx*dx + dy*dy;\r
+ \r
+// System.out.println("HitTest: x0=" + x0 + " y0=" + y0 + " y=" + y + " x=" + x + " dist=" + dist + " r2=" + r*r);\r
+ \r
+ if(dist < (r+tolerance)*(r+tolerance) &&\r
+ dist > (r-tolerance)*(r-tolerance)) {\r
+ double ang = Arcs.normalizeAngle(Math.atan2(-dy, dx));\r
+// System.out.println("test " + angle0 + " " + ang + " " + angle1);\r
+ if(Arcs.areClockwiseOrdered(angle0, ang, angle1) == clockWise) {\r
+// System.out.println("hit");\r
+ return true;\r
+ }\r
+ }\r
+ \r
+ return false;\r
+ \r
+ }\r
+ \r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2010 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.ui.elements2.connections;\r
+\r
+public class ConnectionClasses {\r
+\r
+ public static final Object CONNECTION = new Object() {\r
+ public String toString() { return "CONNECTION"; }\r
+ };\r
+\r
+ public static final Object FLAG = new Object() {\r
+ public String toString() { return "FLAG"; }\r
+ };\r
+\r
+ public static final Object FLOW = new Object() {\r
+ public String toString() { return "FLOW"; }\r
+ };\r
+\r
+ public static final Object DEPENDENCY = new Object() {\r
+ public String toString() { return "DEPENDENCY"; }\r
+ };\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2010 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.ui.elements2.connections;\r
+\r
+import java.util.HashMap;\r
+import java.util.concurrent.ConcurrentSkipListMap;\r
+import java.util.concurrent.atomic.AtomicInteger;\r
+\r
+import org.simantics.databoard.Bindings;\r
+import org.simantics.db.AsyncReadGraph;\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.db.procedure.AsyncMultiProcedure;\r
+import org.simantics.db.procedure.AsyncProcedure;\r
+import org.simantics.diagram.adapter.ElementFactoryAdapter;\r
+import org.simantics.diagram.stubs.DiagramResource;\r
+import org.simantics.g2d.canvas.ICanvasContext;\r
+import org.simantics.g2d.diagram.DiagramHints;\r
+import org.simantics.g2d.diagram.IDiagram;\r
+import org.simantics.g2d.element.ElementClass;\r
+import org.simantics.g2d.element.IElement;\r
+import org.simantics.g2d.element.handler.impl.StaticObjectAdapter;\r
+import org.simantics.layer0.Layer0;\r
+import org.simantics.sysdyn.ui.editor.routing.DependencyRouter;\r
+import org.simantics.utils.datastructures.Pair;\r
+\r
+/**\r
+ * An element class for single connection entity elements. A connection entity\r
+ * consists of connection edge segments and branch points as its children.\r
+ * \r
+ * @author Tuukka Lehtonen\r
+ */\r
+public class DependencyConnectionFactory extends ElementFactoryAdapter {\r
+\r
+ public static final ElementClass CLASS = SysdynConnectionClass.CLASS;\r
+\r
+ @Override\r
+ public void create(AsyncReadGraph graph, ICanvasContext canvas, IDiagram diagram, Resource elementType, final AsyncProcedure<ElementClass> procedure) {\r
+ DiagramResource dr = graph.getService(DiagramResource.class);\r
+ graph.forSingleType(elementType, dr.Connection, new AsyncProcedure<Resource>() {\r
+ @Override\r
+ public void exception(AsyncReadGraph graph, Throwable throwable) {\r
+ procedure.exception(graph, throwable);\r
+ }\r
+ @Override\r
+ public void execute(AsyncReadGraph graph, Resource connectionType) {\r
+ procedure.execute(graph, SysdynConnectionClass.CLASS.newClassWith(false, new StaticObjectAdapter(connectionType)));\r
+ }\r
+ });\r
+ }\r
+\r
+ @Override\r
+ public void load(AsyncReadGraph graph, ICanvasContext canvas, IDiagram diagram, final Resource elementResource,\r
+ final IElement element, final AsyncProcedure<IElement> procedure) {\r
+ \r
+ final AtomicInteger ready = new AtomicInteger(1);\r
+ final ConcurrentSkipListMap<String, Pair<Resource, Object>> properties = new ConcurrentSkipListMap<String, Pair<Resource, Object>>();\r
+ \r
+ element.setHint(DiagramHints.ROUTE_ALGORITHM, new DependencyRouter());\r
+\r
+ graph.forEachPredicate(elementResource, new AsyncMultiProcedure<Resource>() {\r
+\r
+ @Override\r
+ public void exception(AsyncReadGraph graph, Throwable throwable) {\r
+ throwable.printStackTrace();\r
+ }\r
+\r
+ @Override\r
+ public void execute(AsyncReadGraph graph, final Resource property) {\r
+ \r
+ ready.incrementAndGet();\r
+ Layer0 l0;\r
+ try {\r
+ l0 = Layer0.getInstance(graph.getSession());\r
+ } catch (DatabaseException e) {\r
+ e.printStackTrace();\r
+ return;\r
+ }\r
+ graph.forIsSubrelationOf(property, l0.HasProperty, new AsyncProcedure<Boolean>() {\r
+\r
+ @Override\r
+ public void exception(AsyncReadGraph graph, Throwable throwable) {\r
+ throwable.printStackTrace();\r
+ }\r
+\r
+ @Override\r
+ public void execute(AsyncReadGraph graph, final Boolean isProperty) {\r
+ \r
+ if(isProperty) {\r
+ \r
+ graph.forPossibleRelatedValue(elementResource, property, new AsyncProcedure<Object>() {\r
+\r
+ @Override\r
+ public void exception(AsyncReadGraph graph, Throwable throwable) {\r
+ throwable.printStackTrace();\r
+ }\r
+\r
+ @Override\r
+ public void execute(AsyncReadGraph graph, final Object value) {\r
+\r
+ Layer0 l0;\r
+ try {\r
+ l0 = Layer0.getInstance(graph.getSession());\r
+ } catch (DatabaseException e) {\r
+ e.printStackTrace();\r
+ return;\r
+ }\r
+ \r
+ graph.forPossibleRelatedValue(property, l0.HasName, Bindings.STRING, new AsyncProcedure<String>() {\r
+\r
+ @Override\r
+ public void exception(AsyncReadGraph graph, Throwable throwable) {\r
+ throwable.printStackTrace();\r
+ }\r
+\r
+ @Override\r
+ public void execute(AsyncReadGraph graph, String name) {\r
+ \r
+ properties.put(name, Pair.make(property, value));\r
+// System.out.println("load properties " + name + " => " + value);\r
+ if(ready.decrementAndGet() == 0) {\r
+ element.setHint(DiagramHints.PROPERTIES, new HashMap<String, Pair<Resource, Object>>(properties));\r
+ procedure.execute(graph, element);\r
+ }\r
+ \r
+ }\r
+ \r
+ });\r
+ \r
+ }\r
+ \r
+ });\r
+ \r
+ \r
+ } else {\r
+\r
+ if(ready.decrementAndGet() == 0) {\r
+ element.setHint(DiagramHints.PROPERTIES, new HashMap<String, Pair<Resource, Object>>(properties));\r
+ procedure.execute(graph, element);\r
+ }\r
+ \r
+ }\r
+ \r
+ }\r
+ \r
+ });\r
+ \r
+ }\r
+\r
+ @Override\r
+ public void finished(AsyncReadGraph graph) {\r
+ \r
+ if(ready.decrementAndGet() == 0) {\r
+ element.setHint(DiagramHints.PROPERTIES, new HashMap<String, Object>(properties));\r
+ procedure.execute(graph, element);\r
+ }\r
+ \r
+ }\r
+ \r
+ });\r
+ \r
+ }\r
+\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2010 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.ui.elements2.connections;\r
+\r
+import java.awt.BasicStroke;\r
+import java.awt.Color;\r
+import java.awt.Shape;\r
+import java.awt.Stroke;\r
+import java.awt.geom.Path2D;\r
+import java.awt.geom.Rectangle2D;\r
+import java.beans.PropertyChangeEvent;\r
+import java.beans.PropertyChangeListener;\r
+import java.util.Map;\r
+\r
+import org.simantics.db.Resource;\r
+import org.simantics.g2d.diagram.DiagramHints;\r
+import org.simantics.g2d.diagram.DiagramMutator;\r
+import org.simantics.g2d.diagram.DiagramUtils;\r
+import org.simantics.g2d.diagram.IDiagram;\r
+import org.simantics.g2d.diagram.handler.PickRequest.PickPolicy;\r
+import org.simantics.g2d.diagram.handler.Topology;\r
+import org.simantics.g2d.diagram.handler.Topology.Connection;\r
+import org.simantics.g2d.element.ElementClass;\r
+import org.simantics.g2d.element.ElementUtils;\r
+import org.simantics.g2d.element.IElement;\r
+import org.simantics.g2d.element.SceneGraphNodeKey;\r
+import org.simantics.g2d.element.handler.EdgeVisuals;\r
+import org.simantics.g2d.element.handler.EdgeVisuals.EdgeEnd;\r
+import org.simantics.g2d.element.handler.Pick;\r
+import org.simantics.g2d.element.handler.SceneGraph;\r
+import org.simantics.g2d.element.handler.TerminalLayout;\r
+import org.simantics.g2d.element.handler.Transform;\r
+import org.simantics.g2d.element.handler.impl.ConfigurableEdgeVisuals;\r
+import org.simantics.g2d.element.handler.impl.ConnectionSelectionOutline;\r
+import org.simantics.g2d.element.handler.impl.FillColorImpl;\r
+import org.simantics.g2d.element.handler.impl.ParentImpl;\r
+import org.simantics.g2d.element.handler.impl.SimpleElementLayers;\r
+import org.simantics.g2d.elementclass.connection.EdgeClass.EdgeHandler;\r
+import org.simantics.g2d.elementclass.connection.EdgeClass.FixedTransform;\r
+import org.simantics.scenegraph.g2d.G2DParentNode;\r
+import org.simantics.scenegraph.utils.NodeUtil;\r
+import org.simantics.sysdyn.ui.editor.routing.DependencyRouter;\r
+import org.simantics.utils.datastructures.Callback;\r
+import org.simantics.utils.datastructures.Pair;\r
+import org.simantics.utils.datastructures.hints.IHintContext.Key;\r
+\r
+public class DependencyEdgeClass {\r
+\r
+ public static class NodePick implements Pick {\r
+\r
+ private static final long serialVersionUID = 1L;\r
+\r
+ @Override\r
+ public boolean pickTest(IElement e, Shape s, PickPolicy policy) {\r
+ Rectangle2D pickRect = null;\r
+ if (s instanceof Rectangle2D)\r
+ pickRect = (Rectangle2D) s;\r
+ else\r
+ // FIXME: suboptimal, but works.\r
+ pickRect = s.getBounds2D();\r
+\r
+ DependencyNode node = e.getHint(SysdynEdgeSceneGraph.KEY_SG_NODE);\r
+ if(node == null) {\r
+ System.out.println("pickTest no node!");\r
+ return false;\r
+ }\r
+ return Arcs.hitTest(node.getBeginBounds(), node.getEndBounds(), node.getAngle(), pickRect.getCenterX(), pickRect.getCenterY(), 3.0);\r
+ \r
+ }\r
+\r
+ }\r
+ \r
+ // TODO scale, rotate, move, transform\r
+ public static final ElementClass CLASS =\r
+ ElementClass.compile(\r
+ SysdynEdgeSceneGraph.INSTANCE,\r
+ EdgeHandler.INSTANCE,\r
+ ConfigurableEdgeVisuals.DEFAULT,\r
+ FillColorImpl.BLACK,\r
+ FixedTransform.INSTANCE,\r
+ new NodePick(),\r
+ ConnectionSelectionOutline.INSTANCE,\r
+ SimpleElementLayers.INSTANCE,\r
+ ParentImpl.INSTANCE\r
+ ).setId("EdgeClass.STRAIGHT");\r
+\r
+ public static class SysdynEdgeSceneGraph implements SceneGraph {\r
+\r
+ private static final long serialVersionUID = 2914383071126238996L;\r
+\r
+ public static final SysdynEdgeSceneGraph INSTANCE = new SysdynEdgeSceneGraph();\r
+\r
+ public static final Stroke ARROW_STROKE = new BasicStroke(1.0f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER);\r
+\r
+ public static final Key KEY_SG_NODE = new SceneGraphNodeKey(DependencyNode.class, "EDGE_NODE");\r
+\r
+ @Override\r
+ public void init(IElement e, G2DParentNode parent) {\r
+ DependencyNode node = ElementUtils.getOrCreateNode(e, parent, KEY_SG_NODE, "edge_" + e.hashCode(), DependencyNode.class);\r
+ node.setAngle(0.1);\r
+ \r
+ update(e);\r
+ }\r
+\r
+ @Override\r
+ public void cleanup(IElement e) {\r
+ ElementUtils.removePossibleNode(e, KEY_SG_NODE);\r
+ }\r
+ \r
+ public void update(final IElement e) {\r
+ \r
+ DependencyNode node = e.getHint(KEY_SG_NODE);\r
+ if(node == null) return;\r
+ final IDiagram diagram = ElementUtils.peekDiagram(e);\r
+ \r
+ node.setFieldListener(new PropertyChangeListener() {\r
+\r
+ @Override\r
+ public void propertyChange(final PropertyChangeEvent event) {\r
+ \r
+ String field = event.getPropertyName();\r
+ Map<String, Pair<Resource, Object>> properties = e.getHint(DiagramHints.PROPERTIES);\r
+ if(properties == null) return;\r
+ final Pair<Resource, Object> property = properties.get(field);\r
+ if(property == null) return;\r
+\r
+ DiagramUtils.mutateDiagram(diagram, new Callback<DiagramMutator>() {\r
+ \r
+ @Override\r
+ public void run(DiagramMutator mutator) {\r
+ mutator.modifyProperty(e, property.first, event.getNewValue());\r
+ }\r
+ \r
+ });\r
+ \r
+ }\r
+ \r
+ });\r
+\r
+ EdgeVisuals vh = e.getElementClass().getSingleItem(EdgeVisuals.class);\r
+ Stroke stroke = vh.getStroke(e);\r
+ Color c = ElementUtils.getFillColor(e, Color.BLACK);\r
+\r
+ Shape beginTerminalShape = null;\r
+ Shape endTerminalShape = null;\r
+ if (diagram != null) {\r
+ Topology topology = diagram.getDiagramClass().getAtMostOneItemOfClass(Topology.class);\r
+ if (topology != null) {\r
+ Connection beginConnection = topology.getConnection(e, EdgeEnd.Begin);\r
+ Connection endConnection = topology.getConnection(e, EdgeEnd.End);\r
+ beginTerminalShape = getCanvasTerminalShape(beginConnection);\r
+ endTerminalShape = getCanvasTerminalShape(endConnection);\r
+ }\r
+ }\r
+ \r
+ if(beginTerminalShape == null || endTerminalShape == null) return;\r
+ \r
+ node.setBeginBounds(beginTerminalShape.getBounds2D());\r
+ node.setEndBounds(endTerminalShape.getBounds2D());\r
+ node.setStroke(stroke);\r
+ node.setColor(c);\r
+ node.setShapes(DependencyRouter.createArrowShape(node.getShapes(), node.getBeginBounds(), node.getEndBounds(), node.getAngle()));\r
+\r
+ Map<String, Pair<Resource, Object>> properties = e.getHint(DiagramHints.PROPERTIES);\r
+ if(properties != null) {\r
+ for(Map.Entry<String, Pair<Resource, Object>> entry : properties.entrySet()) {\r
+ NodeUtil.setPropertyIfSupported(entry.getKey(), entry.getValue().second, node); \r
+// node.setProperty(entry.getKey(), entry.getValue().second);\r
+// System.out.println("setProperty " + entry.getKey() + " => " + entry.getValue().second);\r
+ }\r
+ }\r
+ EdgeHandler eh = e.getElementClass().getAtMostOneItemOfClass(EdgeHandler.class);\r
+ Path2D path = eh.getPath(e);\r
+ if(path == null)\r
+ path = new Path2D.Double();\r
+ else\r
+ path.reset();\r
+ path.append(node.getShapes().first, false);\r
+ eh.setPath(e, path);\r
+\r
+ }\r
+\r
+ private static Shape getCanvasTerminalShape(Connection connection) {\r
+ if (connection != null && connection.node != null && connection.terminal != null) {\r
+ TerminalLayout layout = connection.node.getElementClass().getAtMostOneItemOfClass(TerminalLayout.class);\r
+ if (layout != null) {\r
+ //return layout.getTerminalShape(connection.node, connection.terminal);\r
+ Shape shp = layout.getTerminalShape(connection.node, connection.terminal);\r
+ Transform tr = connection.node.getElementClass().getAtMostOneItemOfClass(Transform.class);\r
+ if (tr == null)\r
+ return shp;\r
+\r
+ return tr.getTransform(connection.node).createTransformedShape(shp);\r
+ \r
+ }\r
+ }\r
+ return null;\r
+ }\r
+\r
+ }\r
+\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2010 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.ui.elements2.connections;\r
+\r
+import org.simantics.db.AsyncReadGraph;\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.procedure.AsyncProcedure;\r
+import org.simantics.diagram.adapter.ElementFactoryAdapter;\r
+import org.simantics.g2d.canvas.ICanvasContext;\r
+import org.simantics.g2d.diagram.IDiagram;\r
+import org.simantics.g2d.element.ElementClass;\r
+\r
+/**\r
+ * An element class factory for sysdyn dependency connection edge segments.\r
+ * \r
+ * @author Tuukka Lehtonen\r
+ */\r
+public class DependencyEdgeFactory extends ElementFactoryAdapter {\r
+\r
+ private static final ElementClass CLASS = DependencyEdgeClass.CLASS;\r
+\r
+ @Override\r
+ public void create(AsyncReadGraph graph, ICanvasContext canvas, IDiagram diagram, Resource elementType,\r
+ AsyncProcedure<ElementClass> procedure) {\r
+ procedure.execute(graph, CLASS);\r
+ }\r
+\r
+ @Override\r
+ public void getClass(AsyncReadGraph graph, ICanvasContext canvas, IDiagram diagram, Resource elementResource,\r
+ AsyncProcedure<ElementClass> procedure) {\r
+ throw new UnsupportedOperationException();\r
+ }\r
+\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2010 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.ui.elements2.connections;\r
+\r
+import java.awt.BasicStroke;\r
+import java.awt.Color;\r
+import java.awt.Graphics2D;\r
+import java.awt.Stroke;\r
+import java.awt.event.MouseEvent;\r
+import java.awt.event.MouseListener;\r
+import java.awt.event.MouseMotionListener;\r
+import java.awt.geom.Arc2D;\r
+import java.awt.geom.Path2D;\r
+import java.awt.geom.Rectangle2D;\r
+import java.beans.PropertyChangeEvent;\r
+import java.beans.PropertyChangeListener;\r
+\r
+import org.simantics.scenegraph.ISelectionPainterNode;\r
+import org.simantics.scenegraph.g2d.G2DNode;\r
+import org.simantics.scenegraph.g2d.events.ISGMouseEvent;\r
+import org.simantics.scenegraph.utils.NodeUtil;\r
+import org.simantics.sysdyn.ui.editor.routing.DependencyRouter;\r
+import org.simantics.utils.datastructures.Pair;\r
+\r
+public class DependencyNode extends G2DNode implements ISelectionPainterNode, MouseListener, MouseMotionListener {\r
+\r
+ private static final long serialVersionUID = 1294351381209071074L;\r
+\r
+ private static final BasicStroke STROKE = new BasicStroke(1.0f);\r
+\r
+ private Color color;\r
+ private Stroke stroke;\r
+ private Rectangle2D beginBounds;\r
+ private Rectangle2D endBounds;\r
+ private double angle = 0.1;\r
+ private transient Pair<Arc2D, Path2D> shapes = new Pair<Arc2D, Path2D>(new Arc2D.Double(), new Path2D.Double());\r
+\r
+ transient public boolean hover = false;\r
+\r
+ private transient PropertyChangeListener fieldListener = null;\r
+\r
+ @Override\r
+ public void init() {\r
+ super.init();\r
+ NodeUtil.getEventDelegator(this).addMouseListener(this);\r
+ NodeUtil.getEventDelegator(this).addMouseMotionListener(this);\r
+ }\r
+\r
+ @Override\r
+ public void cleanup() {\r
+ NodeUtil.getEventDelegator(this).removeMouseListener(this);\r
+ NodeUtil.getEventDelegator(this).removeMouseMotionListener(this);\r
+ super.cleanup();\r
+ }\r
+\r
+ public void setFieldListener(PropertyChangeListener listener) {\r
+ this.fieldListener = listener;\r
+ }\r
+\r
+ @ServerSide\r
+ public void commitProperty(String field, Object value) {\r
+ if(fieldListener != null) {\r
+ fieldListener.propertyChange(new PropertyChangeEvent(this, field, null, value));\r
+ }\r
+ }\r
+\r
+ @PropertySetter("color")\r
+ @SyncField("color")\r
+ public void setColor(Color color) {\r
+ this.color = color;\r
+ }\r
+\r
+ @PropertySetter("stroke")\r
+ @SyncField("stroke")\r
+ public void setStroke(Stroke stroke) {\r
+ this.stroke = stroke;\r
+ }\r
+\r
+ @PropertySetter("beginBounds")\r
+ @SyncField("beginBounds")\r
+ public void setBeginBounds(Rectangle2D beginBounds) {\r
+ this.beginBounds = beginBounds;\r
+ }\r
+\r
+ @PropertySetter("endBounds")\r
+ @SyncField("endBounds")\r
+ public void setEndBounds(Rectangle2D endBounds) {\r
+ this.endBounds = endBounds;\r
+ }\r
+\r
+ @PropertySetter("angle")\r
+ @SyncField("angle")\r
+ public void setAngle(Double angle) {\r
+ this.angle = angle.doubleValue();\r
+ if(this.beginBounds != null && this.endBounds != null)\r
+ this.shapes = DependencyRouter.createArrowShape(this.shapes, this.beginBounds, this.endBounds, this.angle);\r
+ }\r
+ \r
+ @PropertySetter("shapes")\r
+ @SyncField("shapes")\r
+ public void setShapes(Pair<Arc2D, Path2D> shapes) {\r
+ this.shapes = shapes;\r
+ }\r
+\r
+ public Color getColor() {\r
+ return color;\r
+ }\r
+\r
+ public Stroke getStroke() {\r
+ return stroke;\r
+ }\r
+\r
+ public Rectangle2D getBeginBounds() {\r
+ return beginBounds;\r
+ }\r
+\r
+ public Rectangle2D getEndBounds() {\r
+ return endBounds;\r
+ }\r
+\r
+ public double getAngle() {\r
+ return angle;\r
+ }\r
+ \r
+ public Pair<Arc2D, Path2D> getShapes() {\r
+ return shapes;\r
+ }\r
+ \r
+\r
+ \r
+ @Override\r
+ public void render(Graphics2D g) {\r
+ if(beginBounds == null || endBounds == null) return;\r
+\r
+ // Removed to let the global control handle rendering quality issues.\r
+ //g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);\r
+\r
+ boolean selected = NodeUtil.isSelected(this, 2);\r
+ if(selected) {\r
+ g.setColor(Color.PINK);\r
+ g.setStroke(STROKE);\r
+ g.draw(shapes.first);\r
+ g.fill(shapes.second);\r
+ if(color != null) g.setColor(color);\r
+ g.setStroke(stroke);\r
+ g.draw(shapes.first);\r
+ g.fill(shapes.second);\r
+ } else if (hover){\r
+ g.setColor(Color.LIGHT_GRAY);\r
+ g.setStroke(STROKE);\r
+ g.draw(shapes.first);\r
+ g.fill(shapes.second);\r
+ if(color != null) g.setColor(color);\r
+ g.setStroke(stroke);\r
+ g.draw(shapes.first);\r
+ g.fill(shapes.second);\r
+ } else {\r
+ if(color != null) g.setColor(color);\r
+ if(stroke != null) g.setStroke(stroke);\r
+ g.draw(shapes.first);\r
+ g.fill(shapes.second);\r
+ }\r
+\r
+ }\r
+\r
+ boolean pressHit = false;\r
+\r
+ private boolean hitTest(MouseEvent event, double tolerance) {\r
+ if(event instanceof ISGMouseEvent) {\r
+ if(beginBounds == null || endBounds == null) return false;\r
+\r
+ return Arcs.hitTest(beginBounds, endBounds, angle, ((ISGMouseEvent)event).getDoubleX(), ((ISGMouseEvent)event).getDoubleY(), tolerance);\r
+ } else {\r
+ return false;\r
+ }\r
+ }\r
+\r
+ @Override\r
+ public Rectangle2D getBoundsInLocal() {\r
+ return null;\r
+ }\r
+\r
+ @Override\r
+ public void mouseDragged(MouseEvent e) {\r
+ if(pressHit && e instanceof ISGMouseEvent) {\r
+ setAngle(Arcs.angleOfArc(\r
+ beginBounds.getCenterX(), beginBounds.getCenterY(),\r
+ ((ISGMouseEvent)e).getDoubleX(), ((ISGMouseEvent)e).getDoubleY(),\r
+ endBounds.getCenterX(), endBounds.getCenterY()));\r
+ }\r
+ }\r
+\r
+ @Override\r
+ public void mouseMoved(MouseEvent e) {\r
+ boolean hit = hitTest(e, 3.0);\r
+ if(hit != hover) {\r
+ hover = hit;\r
+ repaint();\r
+ }\r
+ }\r
+\r
+ @Override\r
+ public void mouseClicked(MouseEvent e) {\r
+ // TODO Auto-generated method stub\r
+\r
+ }\r
+\r
+ @Override\r
+ public void mousePressed(MouseEvent e) {\r
+ boolean hit = hitTest(e, 3.0);\r
+ pressHit = hit;\r
+ if(hit) {\r
+ commitProperty("angle", angle);\r
+ }\r
+\r
+ }\r
+\r
+ @Override\r
+ public void mouseReleased(MouseEvent e) {\r
+ boolean hit = hitTest(e, 3.0);\r
+ if(hit) {\r
+ commitProperty("angle", angle);\r
+ }\r
+ }\r
+\r
+ @Override\r
+ public void mouseEntered(MouseEvent e) {\r
+ // TODO Auto-generated method stub\r
+\r
+ }\r
+\r
+ @Override\r
+ public void mouseExited(MouseEvent e) {\r
+ // TODO Auto-generated method stub\r
+\r
+ }\r
+\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2010 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.ui.elements2.connections;\r
+\r
+import org.simantics.db.AsyncReadGraph;\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.procedure.AsyncProcedure;\r
+import org.simantics.diagram.adapter.ElementFactoryAdapter;\r
+import org.simantics.diagram.stubs.DiagramResource;\r
+import org.simantics.g2d.canvas.ICanvasContext;\r
+import org.simantics.g2d.diagram.DiagramHints;\r
+import org.simantics.g2d.diagram.IDiagram;\r
+import org.simantics.g2d.element.ElementClass;\r
+import org.simantics.g2d.element.IElement;\r
+import org.simantics.g2d.element.handler.impl.StaticObjectAdapter;\r
+import org.simantics.g2d.elementclass.connection.ConnectionClass;\r
+import org.simantics.sysdyn.ui.editor.routing.FlowRouter;\r
+\r
+/**\r
+ * An element class for single connection entity elements. A connection entity\r
+ * consists of connection edge segments and branch points as its children.\r
+ * \r
+ * @author Tuukka Lehtonen\r
+ */\r
+public class FlowConnectionFactory extends ElementFactoryAdapter {\r
+\r
+ public static final ElementClass CLASS = SysdynConnectionClass.CLASS;\r
+\r
+ @Override\r
+ public void create(AsyncReadGraph graph, ICanvasContext canvas, IDiagram diagram, Resource elementType, final AsyncProcedure<ElementClass> procedure) {\r
+ DiagramResource dr = graph.getService(DiagramResource.class);\r
+ graph.forSingleType(elementType, dr.Connection, new AsyncProcedure<Resource>() {\r
+ @Override\r
+ public void exception(AsyncReadGraph graph, Throwable throwable) {\r
+ procedure.exception(graph, throwable);\r
+ }\r
+ @Override\r
+ public void execute(AsyncReadGraph graph, Resource connectionType) {\r
+ procedure.execute(graph, ConnectionClass.CLASS.newClassWith(false, new StaticObjectAdapter(connectionType)));\r
+ }\r
+ });\r
+ }\r
+\r
+ @Override\r
+ public void load(AsyncReadGraph graph, ICanvasContext canvas, IDiagram diagram, Resource elementResource,\r
+ final IElement element, final AsyncProcedure<IElement> procedure) {\r
+ element.setHint(DiagramHints.ROUTE_ALGORITHM, new FlowRouter(false));\r
+ procedure.execute(graph, element);\r
+ }\r
+\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2010 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.ui.elements2.connections;\r
+\r
+import java.awt.Color;\r
+import java.awt.Stroke;\r
+import java.awt.geom.AffineTransform;\r
+import java.awt.geom.GeneralPath;\r
+import java.awt.geom.Path2D;\r
+import java.awt.geom.PathIterator;\r
+import java.awt.geom.Point2D;\r
+import java.awt.geom.Rectangle2D;\r
+import java.util.ArrayList;\r
+import java.util.Collection;\r
+import java.util.Iterator;\r
+import java.util.List;\r
+\r
+import org.simantics.g2d.diagram.DiagramHints;\r
+import org.simantics.g2d.diagram.IDiagram;\r
+import org.simantics.g2d.diagram.handler.Topology;\r
+import org.simantics.g2d.diagram.handler.Topology.Connection;\r
+import org.simantics.g2d.diagram.participant.pointertool.TerminalUtil;\r
+import org.simantics.g2d.element.ElementClass;\r
+import org.simantics.g2d.element.ElementUtils;\r
+import org.simantics.g2d.element.IElement;\r
+import org.simantics.g2d.element.handler.BendsHandler;\r
+import org.simantics.g2d.element.handler.EdgeVisuals;\r
+import org.simantics.g2d.element.handler.EdgeVisuals.ArrowType;\r
+import org.simantics.g2d.element.handler.EdgeVisuals.EdgeEnd;\r
+import org.simantics.g2d.element.handler.impl.ConfigurableEdgeVisuals;\r
+import org.simantics.g2d.element.handler.impl.ConnectionSelectionOutline;\r
+import org.simantics.g2d.element.handler.impl.FillColorImpl;\r
+import org.simantics.g2d.element.handler.impl.ParentImpl;\r
+import org.simantics.g2d.element.handler.impl.ShapePick;\r
+import org.simantics.g2d.element.handler.impl.SimpleElementLayers;\r
+import org.simantics.g2d.elementclass.BranchPoint;\r
+import org.simantics.g2d.elementclass.connection.EdgeClass.EdgeHandler;\r
+import org.simantics.g2d.elementclass.connection.EdgeClass.FixedTransform;\r
+import org.simantics.g2d.elementclass.connection.EdgeSceneGraph;\r
+import org.simantics.g2d.routing.ConnectionDirectionUtil;\r
+import org.simantics.g2d.routing.Constants;\r
+import org.simantics.g2d.routing.IRouter2;\r
+import org.simantics.g2d.utils.PathUtils;\r
+import org.simantics.scenegraph.g2d.G2DParentNode;\r
+import org.simantics.scenegraph.g2d.nodes.EdgeNode;\r
+import org.simantics.sysdyn.ui.editor.participant.SysdynConnectTool.SysdynConnection;\r
+import org.simantics.sysdyn.ui.editor.routing.FlowRouter;\r
+import org.simantics.sysdyn.ui.elements2.ValveFactory.ValveSceneGraph;\r
+\r
+public class FlowEdgeClass {\r
+\r
+ // TODO scale, rotate, move, transform\r
+ public static final ElementClass CLASS = ElementClass.compile(\r
+ FlowEdgeSceneGraph.INSTANCE, EdgeHandler.INSTANCE,\r
+ ConfigurableEdgeVisuals.DEFAULT, FillColorImpl.BLACK,\r
+ FixedTransform.INSTANCE, ShapePick.INSTANCE,\r
+ ConnectionSelectionOutline.INSTANCE, SimpleElementLayers.INSTANCE,\r
+ ParentImpl.INSTANCE).setId("FlowEdgeClass");\r
+\r
+ public static class FlowEdgeSceneGraph extends EdgeSceneGraph {\r
+\r
+ private static final long serialVersionUID = -8737581995034992604L;\r
+\r
+ public static final EdgeSceneGraph INSTANCE = new FlowEdgeSceneGraph();\r
+\r
+ @Override\r
+ public void init(IElement e, G2DParentNode parent) {\r
+ ElementUtils.getOrCreateNode(e, parent, KEY_SG_NODE,\r
+ "edge_" + e.hashCode(), FlowEdgeNode.class);\r
+ final IDiagram diagram = ElementUtils.peekDiagram(e);\r
+\r
+ boolean toValve = false;\r
+ if (diagram != null) {\r
+ Topology topology = diagram.getDiagramClass()\r
+ .getAtMostOneItemOfClass(Topology.class);\r
+ if (topology != null) {\r
+ Connection endConnection = topology.getConnection(e,\r
+ EdgeEnd.End);\r
+ toValve = endConnection.node.getElementClass()\r
+ .containsClass(ValveSceneGraph.class);\r
+ }\r
+ }\r
+\r
+ ConfigurableEdgeVisuals cev = e.getElementClass()\r
+ .getAtMostOneItemOfClass(ConfigurableEdgeVisuals.class);\r
+ if (cev != null) {\r
+ if (toValve)\r
+ cev.setArrowType(e, EdgeEnd.End, ArrowType.None);\r
+ else {\r
+ cev.setArrowType(e, EdgeEnd.End, ArrowType.Fill);\r
+ cev.setArrowSize(e, EdgeEnd.End, 2);\r
+ }\r
+ }\r
+\r
+ updateRoute(e);\r
+ update(e);\r
+\r
+ }\r
+\r
+ private static Path2D trimLineToArrows(Path2D line,\r
+ ArrowType endArrowType, double endArrowSize) {\r
+ Path2D result = new Path2D.Double();\r
+ PathIterator pi = line.getPathIterator(null);\r
+\r
+ double lineTo[] = new double[2];\r
+ double prevLine[] = new double[2];\r
+ double dummy[] = new double[2];\r
+\r
+ while (!pi.isDone()) {\r
+ int type = pi.currentSegment(lineTo);\r
+ pi.next();\r
+ int nextType = pi.currentSegment(dummy);\r
+\r
+ if (type == PathIterator.SEG_LINETO\r
+ && nextType == PathIterator.SEG_MOVETO) {\r
+ // this is the end of one line\r
+ if (endArrowType == ArrowType.Fill) {\r
+ double dx = (lineTo[0] - prevLine[0]);\r
+ double dy = (lineTo[1] - prevLine[1]);\r
+ double x2 = dx * dx;\r
+ double y2 = dy * dy;\r
+ double len = Math.sqrt(x2 + y2);\r
+ if (len > endArrowSize) {\r
+ double scale = endArrowSize / len;\r
+ lineTo[0] -= dx * scale;\r
+ lineTo[1] -= dy * scale;\r
+ }\r
+ }\r
+ }\r
+\r
+ if (type == 0) {\r
+ result.moveTo(lineTo[0], lineTo[1]);\r
+ } else if (type == 1) {\r
+ result.lineTo(lineTo[0], lineTo[1]);\r
+ } else {\r
+ throw new UnsupportedOperationException(\r
+ "invalid path segment type: " + type);\r
+ }\r
+ prevLine[0] = lineTo[0];\r
+ prevLine[1] = lineTo[1];\r
+\r
+ }\r
+\r
+ result.setWindingRule(line.getWindingRule());\r
+ return result;\r
+ }\r
+\r
+ private void updateRoute(final IElement e) {\r
+\r
+ final List<IElement> segments = new ArrayList<IElement>();\r
+ segments.add(e);\r
+\r
+ IRouter2 router = ElementUtils.getHintOrDefault(e,\r
+ DiagramHints.ROUTE_ALGORITHM, new FlowRouter());\r
+\r
+ router.route(new SysdynConnection() {\r
+\r
+ IDiagram diagram = ElementUtils.peekDiagram(e);\r
+\r
+ final Topology topology = diagram.getDiagramClass()\r
+ .getSingleItem(Topology.class);\r
+\r
+ @Override\r
+ public Connector getBegin(Object seg) {\r
+ IElement e = (IElement) seg;\r
+ Connection begin = topology.getConnection(e, EdgeEnd.Begin);\r
+ return getConnector(begin);\r
+ }\r
+\r
+ @Override\r
+ public Connector getEnd(Object seg) {\r
+ IElement e = (IElement) seg;\r
+ Connection end = topology.getConnection(e, EdgeEnd.End);\r
+ return getConnector(end);\r
+ }\r
+\r
+ private Connector getConnector(Connection connection) {\r
+ Connector c = new Connector();\r
+ c.allowedDirections = Constants.EAST_FLAG | Constants.WEST_FLAG\r
+ | Constants.NORTH_FLAG | Constants.SOUTH_FLAG;\r
+ \r
+ AffineTransform at = TerminalUtil.getTerminalPosOnDiagram(\r
+ connection.node, connection.terminal);\r
+ c.x = at.getTranslateX();\r
+ c.y = at.getTranslateY();\r
+\r
+ if (connection.node.getElementClass().containsClass(\r
+ ValveSceneGraph.class)) {\r
+ Rectangle2D bounds = ElementUtils\r
+ .getElementBoundsOnDiagram(connection.node)\r
+ .getBounds2D();\r
+ c.parentObstacle = new Rectangle2D.Double(bounds\r
+ .getCenterX() - FlowRouter.OFFSET, bounds\r
+ .getCenterY() - FlowRouter.OFFSET,\r
+ FlowRouter.OFFSET * 2, FlowRouter.OFFSET * 2);\r
+ c.allowedDirections = Constants.EAST_FLAG | Constants.WEST_FLAG;\r
+ } else {\r
+ c.parentObstacle = ElementUtils\r
+ .getElementBoundsOnDiagram(connection.node)\r
+ .getBounds2D();\r
+ \r
+ }\r
+\r
+ return c;\r
+ }\r
+\r
+ private int toAllowedDirections(BranchPoint.Direction direction) {\r
+ switch (direction) {\r
+ case Any:\r
+ return 0xf;\r
+ case Horizontal:\r
+ return Constants.EAST_FLAG | Constants.WEST_FLAG;\r
+ case Vertical:\r
+ return Constants.NORTH_FLAG | Constants.SOUTH_FLAG;\r
+ default:\r
+ throw new IllegalArgumentException(\r
+ "unrecognized direction: " + direction);\r
+ }\r
+ }\r
+\r
+ @Override\r
+ public Collection<? extends Object> getSegments() {\r
+ return segments;\r
+ }\r
+\r
+ @Override\r
+ public void setPath(Object seg, Path2D path) {\r
+ IElement e = (IElement) seg;\r
+ BendsHandler bends = e.getElementClass()\r
+ .getAtMostOneItemOfClass(BendsHandler.class);\r
+ AffineTransform elementTransform = ElementUtils\r
+ .getInvTransform(e);\r
+ path = (Path2D) path.clone();\r
+ path.transform(elementTransform);\r
+ bends.setPath(e, path);\r
+ }\r
+ });\r
+\r
+ }\r
+\r
+ public void update(final IElement e) {\r
+ EdgeNode node = e.getHint(KEY_SG_NODE);\r
+ if (node == null)\r
+ return;\r
+\r
+ EdgeVisuals vh = e.getElementClass().getSingleItem(\r
+ EdgeVisuals.class);\r
+ ArrowType at1 = vh.getArrowType(e, EdgeEnd.Begin);\r
+ ArrowType at2 = vh.getArrowType(e, EdgeEnd.End);\r
+ Stroke stroke = vh.getStroke(e);\r
+ // StrokeType strokeType = vh.getStrokeType(e);\r
+ double as1 = vh.getArrowSize(e, EdgeEnd.Begin);\r
+ double as2 = vh.getArrowSize(e, EdgeEnd.End);\r
+\r
+ Color c = ElementUtils.getFillColor(e, Color.BLACK);\r
+\r
+ // Get terminal shape for clipping the painted edge to its bounds.\r
+ IDiagram diagram = ElementUtils.peekDiagram(e);\r
+ if (diagram != null) {\r
+ Topology topology = diagram.getDiagramClass()\r
+ .getAtMostOneItemOfClass(Topology.class);\r
+ if (topology != null) {\r
+ Connection beginConnection = topology.getConnection(e,\r
+ EdgeEnd.Begin);\r
+ Connection endConnection = topology.getConnection(e,\r
+ EdgeEnd.End);\r
+ int beginBranchDegree = getBranchPointDegree(\r
+ beginConnection, topology);\r
+ int endBranchDegree = getBranchPointDegree(endConnection,\r
+ topology);\r
+ if (beginBranchDegree > 0 && beginBranchDegree < 3) {\r
+ at1 = ArrowType.None;\r
+ }\r
+ if (endBranchDegree > 0 && endBranchDegree < 3) {\r
+ at2 = ArrowType.None;\r
+ }\r
+ }\r
+ }\r
+\r
+ // Read bends\r
+ BendsHandler bh = e.getElementClass().getSingleItem(\r
+ BendsHandler.class);\r
+ Path2D line = bh.getPath(e);\r
+\r
+ boolean drawArrows = at1 != ArrowType.None || at2 != ArrowType.None;\r
+ // line = clipLineEnds(line, beginTerminalShape, endTerminalShape);\r
+\r
+ Point2D first = new Point2D.Double();\r
+ Point2D dir1 = new Point2D.Double();\r
+ Point2D last = new Point2D.Double();\r
+ Point2D dir2 = new Point2D.Double();\r
+ PathIterator pi = line.getPathIterator(null);\r
+ drawArrows &= getPathArrows(pi, first, dir1, last, dir2);\r
+\r
+ if (drawArrows) {\r
+ line = trimLineToArrows(line, at2, as2);\r
+ }\r
+\r
+ EdgeNode.ArrowType pat1 = convert(at1);\r
+ EdgeNode.ArrowType pat2 = convert(at2);\r
+\r
+ node.init(new GeneralPath(line), stroke, c, dir1, dir2, first,\r
+ last, as1, as2, pat1, pat2, null, null);\r
+ }\r
+\r
+ private boolean getPathArrows(PathIterator pi, Point2D begin,\r
+ Point2D beginDirection, Point2D end, Point2D endDirection) {\r
+\r
+ Iterator<double[]> i = PathUtils.toLineIterator(pi);\r
+\r
+ double first1[] = null, last1[] = null;\r
+ double first2[] = null, last2[] = null;\r
+\r
+ // double current[] = new double[2];\r
+\r
+ double[] previous = null;\r
+\r
+ while (i.hasNext()) {\r
+ double[] current = i.next();\r
+\r
+ // Start of the first path\r
+ if (first1 == null) {\r
+ first1 = current;\r
+ last1 = current;\r
+ }\r
+\r
+ // Command was moveTo => start of the second path\r
+ else if (previous != null\r
+ && (previous[2] != current[0] || previous[3] != current[1])) {\r
+ first2 = current;\r
+ last2 = current;\r
+ }\r
+\r
+ // first2 == null => still in the first line\r
+ else if (first2 == null) {\r
+ last1 = current;\r
+ }\r
+\r
+ // second path\r
+ else if (!i.hasNext()) {\r
+ last2 = current;\r
+ }\r
+\r
+ previous = current;\r
+ }\r
+\r
+ if (first1 == null || last1 == null || first2 == null\r
+ || last2 == null)\r
+ return false;\r
+\r
+ double[] first = { mean(first1[0], first2[0]),\r
+ mean(first1[1], first2[1]), mean(first1[2], first2[2]),\r
+ mean(first1[3], first2[3]) };\r
+ double[] last = { mean(last1[0], last2[0]),\r
+ mean(last1[1], last2[1]), mean(last1[2], last2[2]),\r
+ mean(last1[3], last2[3]) };\r
+\r
+ begin.setLocation(PathUtils.getLinePos(first, 0));\r
+ beginDirection.setLocation(PathUtils.getLineTangent(first, 0));\r
+ end.setLocation(PathUtils.getLinePos(last, 1));\r
+ Point2D endTangent = PathUtils.getLineTangent(last, 1);\r
+ endDirection.setLocation(-endTangent.getX(), -endTangent.getY());\r
+\r
+ return true;\r
+ }\r
+\r
+ private double mean(double c1, double c2) {\r
+ return c1 + (c2 - c1) / 2;\r
+ }\r
+\r
+ private static EdgeNode.ArrowType convert(ArrowType at) {\r
+ switch (at) {\r
+ case None:\r
+ return EdgeNode.ArrowType.None;\r
+ case Stroke:\r
+ return EdgeNode.ArrowType.Stroke;\r
+ case Fill:\r
+ return EdgeNode.ArrowType.Fill;\r
+ default:\r
+ throw new IllegalArgumentException("unsupported arrow type: "\r
+ + at);\r
+ }\r
+ }\r
+\r
+ private final Collection<Connection> connectionsTemp = new ArrayList<Connection>();\r
+\r
+ private int getBranchPointDegree(Connection connection,\r
+ Topology topology) {\r
+ if (connection != null && connection.node != null) {\r
+ if (connection.node.getElementClass().containsClass(\r
+ BranchPoint.class)) {\r
+ connectionsTemp.clear();\r
+ topology.getConnections(connection.node,\r
+ connection.terminal, connectionsTemp);\r
+ int degree = connectionsTemp.size();\r
+ connectionsTemp.clear();\r
+ return degree;\r
+ }\r
+ }\r
+ return -1;\r
+ }\r
+\r
+ }\r
+\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2010 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.ui.elements2.connections;\r
+\r
+import org.simantics.db.AsyncReadGraph;\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.procedure.AsyncProcedure;\r
+import org.simantics.diagram.adapter.ElementFactoryAdapter;\r
+import org.simantics.g2d.canvas.ICanvasContext;\r
+import org.simantics.g2d.diagram.IDiagram;\r
+import org.simantics.g2d.element.ElementClass;\r
+\r
+/**\r
+ * An element class factory for sysdyn flow connection edge segments.\r
+ * \r
+ * @author Tuukka Lehtonen\r
+ */\r
+public class FlowEdgeFactory extends ElementFactoryAdapter {\r
+\r
+ private static final ElementClass CLASS = FlowEdgeClass.CLASS;\r
+\r
+ @Override\r
+ public void create(AsyncReadGraph graph, ICanvasContext canvas, IDiagram diagram, Resource elementType,\r
+ AsyncProcedure<ElementClass> procedure) {\r
+ procedure.execute(graph, CLASS);\r
+ }\r
+\r
+ @Override\r
+ public void getClass(AsyncReadGraph graph, ICanvasContext canvas, IDiagram diagram, Resource elementResource,\r
+ AsyncProcedure<ElementClass> procedure) {\r
+ throw new UnsupportedOperationException();\r
+ }\r
+\r
+}\r
--- /dev/null
+package org.simantics.sysdyn.ui.elements2.connections;\r
+\r
+import java.awt.BasicStroke;\r
+import java.awt.Color;\r
+import java.awt.Graphics2D;\r
+import java.awt.Stroke;\r
+import java.awt.geom.AffineTransform;\r
+import java.awt.geom.GeneralPath;\r
+\r
+import org.simantics.scenegraph.ISelectionPainterNode;\r
+import org.simantics.scenegraph.g2d.nodes.EdgeNode;\r
+import org.simantics.scenegraph.utils.NodeUtil;\r
+\r
+public class FlowEdgeNode extends EdgeNode implements ISelectionPainterNode {\r
+ \r
+ private static final long serialVersionUID = -6774653631527343539L;\r
+\r
+ private static final BasicStroke SELECTION_STROKE = new BasicStroke(1.0f);\r
+ \r
+ @Override\r
+ public void render(Graphics2D g) {\r
+ if(color != null) g.setColor(color);\r
+ if(stroke == null || shape == null) return;\r
+\r
+ if(alphaComposite != null) {\r
+ g.setComposite(alphaComposite);\r
+ }\r
+\r
+ Stroke effectiveStroke = stroke;\r
+ if(dynamicStroke != null) {\r
+ effectiveStroke = dynamicStroke;\r
+ }\r
+\r
+ Color effectiveColor = color;\r
+ if(dynamicColor != null) {\r
+ effectiveColor = dynamicColor;\r
+ }\r
+\r
+ g.setStroke(effectiveStroke);\r
+\r
+ // Draw line\r
+ boolean selected = NodeUtil.isSelected(this, 2);\r
+ if(selected) {\r
+ g.setColor(Color.PINK);\r
+ g.setStroke(SELECTION_STROKE);\r
+ g.draw(shape);\r
+ }\r
+ g.setColor(effectiveColor);\r
+ g.setStroke(effectiveStroke);\r
+ g.draw(shape);\r
+\r
+ // Draw the ending arrow if necessary\r
+ if(last_at == ArrowType.Fill) {\r
+ AffineTransform at = g.getTransform();\r
+\r
+ g.setStroke(ARROW_STROKE);\r
+\r
+ double theta = Math.atan2(lastdir.getY(), lastdir.getX()) - Math.PI/2;\r
+ g.translate(last.getX(), last.getY());\r
+ g.rotate(theta);\r
+ g.scale(lastsize, lastsize);\r
+ g.fill(FLOW_ARROW);\r
+ g.setTransform(at);\r
+ }\r
+\r
+ }\r
+ \r
+ public transient final static GeneralPath FLOW_ARROW;\r
+\r
+ static {\r
+ FLOW_ARROW = new GeneralPath();\r
+ FLOW_ARROW.moveTo(-1f, 1.6f);\r
+ FLOW_ARROW.lineTo( 0f, 0f);\r
+ FLOW_ARROW.lineTo( 1f, 1.6f);\r
+ FLOW_ARROW.closePath();\r
+ }\r
+\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2010 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.ui.elements2.connections;\r
+\r
+import java.awt.BasicStroke;\r
+import java.awt.Color;\r
+import java.awt.Graphics2D;\r
+import java.awt.Stroke;\r
+import java.awt.geom.Path2D;\r
+import java.awt.geom.Rectangle2D;\r
+\r
+import org.simantics.scenegraph.ISelectionPainterNode;\r
+import org.simantics.scenegraph.g2d.G2DNode;\r
+import org.simantics.scenegraph.utils.NodeUtil;\r
+\r
+public class FlowNode extends G2DNode implements ISelectionPainterNode {\r
+\r
+ private static final long serialVersionUID = 328942356917631237L;\r
+\r
+ private static final BasicStroke STROKE = new BasicStroke(1.0f);\r
+\r
+ private Color color;\r
+ private Stroke stroke;\r
+ private Rectangle2D beginBounds;\r
+ private Rectangle2D endBounds;\r
+ private Path2D lines;\r
+ private Path2D arrow;\r
+\r
+ @PropertySetter("color")\r
+ @SyncField("color")\r
+ public void setColor(Color color) {\r
+ this.color = color;\r
+ }\r
+\r
+ @PropertySetter("stroke")\r
+ @SyncField("stroke")\r
+ public void setStroke(Stroke stroke) {\r
+ this.stroke = stroke;\r
+ }\r
+\r
+ @PropertySetter("beginBounds")\r
+ @SyncField("beginBounds")\r
+ public void setBeginBounds(Rectangle2D beginBounds) {\r
+ this.beginBounds = beginBounds;\r
+ }\r
+\r
+ @PropertySetter("endBounds")\r
+ @SyncField("endBounds")\r
+ public void setEndBounds(Rectangle2D endBounds) {\r
+ this.endBounds = endBounds;\r
+ }\r
+ \r
+ @PropertySetter("lines")\r
+ @SyncField("lines")\r
+ public void setLines(Path2D lines) {\r
+ this.lines = lines;\r
+ }\r
+ \r
+ @PropertySetter("arrow")\r
+ @SyncField("arrow")\r
+ public void setArrow(Path2D arrow) {\r
+ this.arrow = arrow;\r
+ }\r
+\r
+ public Color getColor() {\r
+ return color;\r
+ }\r
+\r
+ public Stroke getStroke() {\r
+ return stroke;\r
+ }\r
+\r
+ public Rectangle2D getBeginBounds() {\r
+ return beginBounds;\r
+ }\r
+\r
+ public Rectangle2D getEndBounds() {\r
+ return endBounds;\r
+ }\r
+\r
+ public Path2D getLines() {\r
+ return lines;\r
+ }\r
+ \r
+ public Path2D getArrow() {\r
+ return arrow;\r
+ }\r
+ \r
+ @Override\r
+ public void render(Graphics2D g) {\r
+ // Removed to let the global control handle rendering quality issues.\r
+ //g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);\r
+\r
+ /*\r
+ * There are two cases, first is from Stock|Cloud to Valve and second is from Valve to Stock|Cloud\r
+ * -In the first case there is no arrow and valve is endBounds\r
+ * -In the second case there is an arrow and valve is beginBounds\r
+ */\r
+\r
+ boolean selected = NodeUtil.isSelected(this, 2);\r
+ if(selected) {\r
+ g.setColor(Color.PINK);\r
+ g.setStroke(STROKE);\r
+ g.draw(lines);\r
+ if(color != null) g.setColor(color);\r
+ g.setStroke(stroke);\r
+ if(lines!= null) g.draw(lines);\r
+ if(arrow != null) g.fill(arrow);\r
+ } else {\r
+ if(color != null) g.setColor(color);\r
+ if(stroke != null) g.setStroke(stroke);\r
+ if(lines!= null) g.draw(lines);\r
+ if(arrow != null) g.fill(arrow);\r
+ }\r
+\r
+\r
+ }\r
+\r
+ @Override\r
+ public Rectangle2D getBoundsInLocal() {\r
+ return null;\r
+ }\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2010 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.ui.elements2.connections;\r
+\r
+import java.awt.Shape;\r
+import java.awt.Stroke;\r
+\r
+public class FlowStroke implements Stroke {\r
+ private Stroke stroke1, stroke2;\r
+\r
+ public FlowStroke( Stroke stroke1, Stroke stroke2 ) {\r
+ this.stroke1 = stroke1;\r
+ this.stroke2 = stroke2;\r
+ }\r
+\r
+ public Shape createStrokedShape( Shape shape ) {\r
+ return stroke2.createStrokedShape( stroke1.createStrokedShape( shape ) );\r
+ }\r
+ \r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2010 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.ui.elements2.connections;\r
+\r
+import java.awt.geom.Path2D;\r
+import java.awt.geom.Rectangle2D;\r
+\r
+public class Flows {\r
+ \r
+ public static double ARROW_LENGTH = 3.2;\r
+ public static double ARROW_WIDTH = 2;\r
+\r
+ static final double OFFSET = 1.0;\r
+ static final double ARROW_OFFSET = 3.2;\r
+\r
+ public static Path2D createArrow(Path2D arrow, Rectangle2D tail, Rectangle2D head) { \r
+\r
+ double x = tail.getCenterX();\r
+ double y = tail.getCenterY();\r
+\r
+ double cx = head.getCenterX();\r
+ double minx = head.getMinX();\r
+ double maxx = head.getMaxX();\r
+ double miny = head.getMinY();\r
+ double maxy = head.getMaxY();\r
+\r
+ if(arrow == null)\r
+ arrow = new Path2D.Double();\r
+ else\r
+ arrow.reset();\r
+ \r
+ // approach from top\r
+ if (y < miny) {\r
+ arrow.moveTo(cx, miny);\r
+ arrow.lineTo(cx + ARROW_WIDTH, miny - ARROW_LENGTH);\r
+ arrow.lineTo(cx - ARROW_WIDTH, miny - ARROW_LENGTH);\r
+ } \r
+\r
+ // approach from beneath\r
+ else if (y > maxy) {\r
+ arrow.moveTo(cx, maxy);\r
+ arrow.lineTo(cx + ARROW_WIDTH, maxy + ARROW_LENGTH);\r
+ arrow.lineTo(cx - ARROW_WIDTH, maxy + ARROW_LENGTH);\r
+ }\r
+\r
+ // approach from left\r
+ else if (x < minx) {\r
+ arrow.moveTo(minx, y);\r
+ arrow.lineTo(minx - ARROW_LENGTH, y - ARROW_WIDTH);\r
+ arrow.lineTo(minx - ARROW_LENGTH, y + ARROW_WIDTH);\r
+ }\r
+\r
+ // approach from right\r
+ else if (x > maxx) {\r
+ arrow.moveTo(maxx, y);\r
+ arrow.lineTo(maxx + ARROW_LENGTH, y - ARROW_WIDTH);\r
+ arrow.lineTo(maxx + ARROW_LENGTH, y + ARROW_WIDTH);\r
+ }\r
+ else\r
+ return null; // FIXME (HN) This is just a quick bugfix, didn't understand the logic completely \r
+\r
+ arrow.closePath();\r
+ \r
+ return arrow;\r
+ \r
+ }\r
+ \r
+ private static Path2D createLines(Path2D lines, boolean vertical, double ... coordinates) {\r
+ if(lines == null)\r
+ lines = new Path2D.Double();\r
+ else\r
+ lines.reset();\r
+ createOffsetLine(lines, vertical, OFFSET, coordinates);\r
+ createOffsetLine(lines, vertical, -OFFSET, coordinates);\r
+ return lines;\r
+ }\r
+\r
+ public static Path2D createLines(Path2D lines, boolean hasArrow, Rectangle2D valve, Rectangle2D node) {\r
+ double x0 = valve.getCenterX();\r
+ double y0 = valve.getCenterY(); \r
+ double x1 = node.getCenterX();\r
+ double y1 = node.getCenterY();\r
+ \r
+ double minY = hasArrow ? node.getMinY() - ARROW_OFFSET : node.getMinY();\r
+ double maxY = hasArrow ? node.getMaxY() + ARROW_OFFSET : node.getMaxY();\r
+ double minX = hasArrow ? node.getMinX() - ARROW_OFFSET : node.getMinX();\r
+ double maxX = hasArrow ? node.getMaxX() + ARROW_OFFSET : node.getMaxX();\r
+ \r
+ boolean rotated = false;\r
+ \r
+ if( rotated ) {\r
+ if(y1 > y0)\r
+ y0 += OFFSET;\r
+ else\r
+ y0 -= OFFSET;\r
+ if(node.getMinX() <= x0 && node.getMaxX() >= x0) {\r
+ if(y1 > y0)\r
+ return createLines(lines, true, y0, x0, minY);\r
+ else\r
+ return createLines(lines, true, y0, x0, maxY);\r
+ }\r
+ else {\r
+ if(x1 > x0)\r
+ return createLines(lines, true, y0, x0, y1, minX);\r
+ else\r
+ return createLines(lines, true, y0, x0, y1, maxX);\r
+ }\r
+ }\r
+ else {\r
+ if(x1 > x0)\r
+ x0 += OFFSET;\r
+ else\r
+ x0 -= OFFSET;\r
+ if(node.getMinY() <= y0 && node.getMaxY() >= y0) {\r
+ if(x1 > x0)\r
+ return createLines(lines, false, x0, y0, minX);\r
+ else\r
+ return createLines(lines, false, x0, y0, maxX);\r
+ }\r
+ else {\r
+ if(y1 > y0)\r
+ return createLines(lines, false, x0, y0, x1, minY);\r
+ else\r
+ return createLines(lines, false, x0, y0, x1, maxY);\r
+ }\r
+ }\r
+\r
+\r
+ }\r
+\r
+ public static Path2D createLine(Path2D path, boolean vertical, double ... coordinates) {\r
+ if(vertical)\r
+ path.moveTo(coordinates[1], coordinates[0]);\r
+ else\r
+ path.moveTo(coordinates[0], coordinates[1]);\r
+ for(int i=2;i<coordinates.length;++i, vertical = !vertical) {\r
+ if(vertical)\r
+ path.lineTo(coordinates[i-1], coordinates[i]);\r
+ else\r
+ path.lineTo(coordinates[i], coordinates[i-1]);\r
+ }\r
+ return path;\r
+ }\r
+ \r
+ public static Path2D createOffsetLine(Path2D path, boolean vertical, double offset, double ... coordinates) {\r
+ double[] newCoordinats = new double[coordinates.length];\r
+ newCoordinats[0] = coordinates[0];\r
+ newCoordinats[coordinates.length-1] = coordinates[coordinates.length-1];\r
+ for(int i=1;i<coordinates.length-1;++i) {\r
+ if(coordinates[i-1] < coordinates[i+1] ^ (i&1)==1)\r
+ newCoordinats[i] = coordinates[i]+offset;\r
+ else\r
+ newCoordinats[i] = coordinates[i]-offset;\r
+ }\r
+ return createLine(path, vertical, newCoordinats);\r
+ }\r
+ \r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2010 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.ui.elements2.connections;\r
+\r
+import java.awt.Composite;\r
+import java.awt.Shape;\r
+import java.awt.geom.AffineTransform;\r
+import java.awt.geom.Area;\r
+import java.awt.geom.Rectangle2D;\r
+import java.util.ArrayList;\r
+import java.util.Collection;\r
+import java.util.Collections;\r
+import java.util.HashSet;\r
+import java.util.List;\r
+import java.util.Map;\r
+import java.util.Set;\r
+\r
+import org.simantics.db.Resource;\r
+import org.simantics.g2d.connection.ConnectionEntity;\r
+import org.simantics.g2d.connection.ConnectionEntity.ConnectionEvent;\r
+import org.simantics.g2d.connection.ConnectionEntity.ConnectionListener;\r
+import org.simantics.g2d.connection.handler.ConnectionHandler;\r
+import org.simantics.g2d.diagram.DiagramHints;\r
+import org.simantics.g2d.diagram.handler.PickRequest.PickPolicy;\r
+import org.simantics.g2d.diagram.handler.Topology.Connection;\r
+import org.simantics.g2d.element.ElementClass;\r
+import org.simantics.g2d.element.ElementHints;\r
+import org.simantics.g2d.element.ElementUtils;\r
+import org.simantics.g2d.element.IElement;\r
+import org.simantics.g2d.element.handler.Children;\r
+import org.simantics.g2d.element.handler.InternalSize;\r
+import org.simantics.g2d.element.handler.Outline;\r
+import org.simantics.g2d.element.handler.Pick;\r
+import org.simantics.g2d.element.handler.Pick2;\r
+import org.simantics.g2d.element.handler.SceneGraph;\r
+import org.simantics.g2d.element.handler.SelectionOutline;\r
+import org.simantics.g2d.element.handler.Transform;\r
+import org.simantics.g2d.element.handler.impl.ConnectionSelectionOutline;\r
+import org.simantics.g2d.element.handler.impl.ParentImpl;\r
+import org.simantics.g2d.element.handler.impl.SimpleElementLayers;\r
+import org.simantics.g2d.element.handler.impl.TextImpl;\r
+import org.simantics.g2d.elementclass.connection.EdgeClass.FixedTransform;\r
+import org.simantics.g2d.utils.GeometryUtils;\r
+import org.simantics.scenegraph.g2d.G2DParentNode;\r
+import org.simantics.scenegraph.g2d.IG2DNode;\r
+import org.simantics.scenegraph.g2d.nodes.SingleElementNode;\r
+import org.simantics.utils.datastructures.ListenerList;\r
+import org.simantics.utils.datastructures.Pair;\r
+import org.simantics.utils.datastructures.hints.IHintContext.Key;\r
+import org.simantics.utils.datastructures.hints.IHintContext.KeyOf;\r
+\r
+/**\r
+ * An element class for single connection entity elements. A sysdyn connection\r
+ * entity consists of a single edge. Sysdyn connections can't be branched.\r
+ * \r
+ * @author Tuukka Lehtonen\r
+ */\r
+public class SysdynConnectionClass {\r
+\r
+ public static final ElementClass CLASS =\r
+ ElementClass.compile(\r
+ TextImpl.INSTANCE,\r
+ FixedTransform.INSTANCE,\r
+ ConnectionPick.INSTANCE,\r
+ ConnectionBounds.INSTANCE,\r
+ ConnectionSelectionOutline.INSTANCE,\r
+ ConnectionHandlerImpl.INSTANCE,\r
+ ConnectionChildren.INSTANCE,\r
+ ParentImpl.INSTANCE,\r
+ ConnectionSceneGraph.INSTANCE,\r
+ SimpleElementLayers.INSTANCE\r
+ ).setId(SysdynConnectionClass.class.getSimpleName());\r
+\r
+ private static class ThreadLocalList extends ThreadLocal<List<IElement>> {\r
+ @Override\r
+ protected java.util.List<IElement> initialValue() {\r
+ return new ArrayList<IElement>();\r
+ }\r
+ };\r
+\r
+ private static final ThreadLocal<List<IElement>> perThreadSceneGraphList = new ThreadLocalList();\r
+ private static final ThreadLocal<List<IElement>> perThreadBoundsList = new ThreadLocalList();\r
+ private static final ThreadLocal<List<IElement>> perThreadShapeList = new ThreadLocalList();\r
+ private static final ThreadLocal<List<IElement>> perThreadPickList = new ThreadLocalList();\r
+\r
+ static class ConnectionHandlerImpl implements ConnectionHandler {\r
+\r
+ public static final ConnectionHandlerImpl INSTANCE = new ConnectionHandlerImpl();\r
+\r
+ private static final long serialVersionUID = 3267139233182458330L;\r
+\r
+ @Override\r
+ public Collection<IElement> getBranchPoints(IElement connection, Collection<IElement> result) {\r
+ ConnectionEntity entity = connection.getHint(ElementHints.KEY_CONNECTION_ENTITY);\r
+ if (entity == null)\r
+ return Collections.emptySet();\r
+ return entity.getBranchPoints(result);\r
+ }\r
+\r
+ @Override\r
+ public Collection<IElement> getChildren(IElement connection, Collection<IElement> result) {\r
+ ConnectionEntity entity = connection.getHint(ElementHints.KEY_CONNECTION_ENTITY);\r
+ if (entity == null)\r
+ return Collections.emptySet();\r
+ result = entity.getSegments(result);\r
+ return entity.getBranchPoints(result);\r
+ }\r
+\r
+ @Override\r
+ public Collection<IElement> getSegments(IElement connection, Collection<IElement> result) {\r
+ ConnectionEntity entity = connection.getHint(ElementHints.KEY_CONNECTION_ENTITY);\r
+ if (entity == null)\r
+ return Collections.emptySet();\r
+ return entity.getSegments(result);\r
+ }\r
+\r
+ @Override\r
+ public Collection<Connection> getTerminalConnections(IElement connection, Collection<Connection> result) {\r
+ ConnectionEntity entity = connection.getHint(ElementHints.KEY_CONNECTION_ENTITY);\r
+ if (entity == null)\r
+ return Collections.emptySet();\r
+ return entity.getTerminalConnections(result);\r
+ }\r
+\r
+ @Override\r
+ public IElement newBranchPoint(IElement connection) {\r
+ ConnectionEntity entity = connection.getHint(ElementHints.KEY_CONNECTION_ENTITY);\r
+ if (entity == null)\r
+ throw new IllegalArgumentException("element '" + connection + "' is not a connection element");\r
+ return entity.newBranchPoint();\r
+ }\r
+\r
+ @Override\r
+ public IElement newEdge(IElement connection) {\r
+ ConnectionEntity entity = connection.getHint(ElementHints.KEY_CONNECTION_ENTITY);\r
+ if (entity == null)\r
+ throw new IllegalArgumentException("element '" + connection + "' is not a connection element");\r
+ return entity.newEdge();\r
+ }\r
+\r
+ @Override\r
+ public void removeBranchPoint(IElement connection, IElement branchPoint) {\r
+ ConnectionEntity entity = connection.getHint(ElementHints.KEY_CONNECTION_ENTITY);\r
+ if (entity == null)\r
+ throw new IllegalArgumentException("element '" + connection + "' is not a connection element");\r
+ entity.removeBranchPoint(branchPoint);\r
+ }\r
+\r
+ @Override\r
+ public void removeEdge(IElement connection, IElement edge) {\r
+ ConnectionEntity entity = connection.getHint(ElementHints.KEY_CONNECTION_ENTITY);\r
+ if (entity == null)\r
+ throw new IllegalArgumentException("element '" + connection + "' is not a connection element");\r
+ entity.removeEdge(edge);\r
+ }\r
+ }\r
+\r
+ static final class ConnectionSceneGraph implements SceneGraph {\r
+\r
+ public static final ConnectionSceneGraph INSTANCE = new ConnectionSceneGraph();\r
+\r
+ private static final long serialVersionUID = 4232871859964883266L;\r
+\r
+ @Override\r
+ public void init(IElement connection, G2DParentNode parent) {\r
+ ConnectionEntity ce = connection.getHint(ElementHints.KEY_CONNECTION_ENTITY);\r
+ if (ce == null)\r
+ return;\r
+\r
+ // Painting is single-threaded, it is OK to use a single thread-local collection here.\r
+ List<IElement> children = perThreadSceneGraphList.get();\r
+ children.clear();\r
+ ce.getSegments(children);\r
+ ce.getBranchPoints(children);\r
+ //new Exception("painting connection entity " + ce.hashCode() + " with " + children.size() + " segments and branch points").printStackTrace();\r
+ if (children.isEmpty())\r
+ return;\r
+\r
+ Set<SingleElementNode> tmp = new HashSet<SingleElementNode>();\r
+\r
+ Map<String, Pair<Resource, Object>> properties = connection.getHint(DiagramHints.PROPERTIES);\r
+ \r
+ int zIndex = 0;\r
+ for (IElement child : children) {\r
+ \r
+ ElementClass ec = child.getElementClass();\r
+\r
+ Transform transform = child.getElementClass().getSingleItem(Transform.class);\r
+ assert (transform != null);\r
+ AffineTransform at2 = transform.getTransform(child);\r
+ if (at2 == null)\r
+ continue;\r
+\r
+ if(properties != null)\r
+ child.setHint(DiagramHints.PROPERTIES, properties);\r
+ \r
+ SingleElementNode holder = child.getHint(ElementHints.KEY_SG_NODE);\r
+ if (holder == null) {\r
+ holder = parent.addNode(ElementUtils.generateNodeId(child), SingleElementNode.class);\r
+ child.setHint(ElementHints.KEY_SG_NODE, holder);\r
+ }\r
+ holder.setZIndex(++zIndex);\r
+\r
+ Composite composite = child.getHint(ElementHints.KEY_COMPOSITE);\r
+\r
+ holder.setTransform((AffineTransform) at2.clone());\r
+ holder.setComposite(composite);\r
+ holder.setVisible(true);\r
+\r
+ // New node handler\r
+ for (SceneGraph n : ec.getItemsByClass(SceneGraph.class)) {\r
+ n.init(child, holder);\r
+ }\r
+ tmp.add(holder);\r
+ }\r
+\r
+ // Hide unaccessed nodes (but don't remove)\r
+ for (IG2DNode node : parent.getNodes()) {\r
+ if (node instanceof SingleElementNode) {\r
+ if (!tmp.contains(node)) {\r
+ ((SingleElementNode)node).setVisible(false);\r
+ }\r
+ } else {\r
+ //System.out.println("WHAT IS THIS: ");\r
+ //NodeDebug.printSceneGraph(((Node) node));\r
+ }\r
+ }\r
+\r
+ // Don't leave dangling references behind.\r
+ children.clear();\r
+ }\r
+\r
+ @Override\r
+ public void cleanup(IElement e) {\r
+ }\r
+ }\r
+\r
+ static final class ConnectionBounds implements InternalSize, Outline {\r
+\r
+ public static final ConnectionBounds INSTANCE = new ConnectionBounds();\r
+\r
+ private static final long serialVersionUID = 4232871859964883266L;\r
+\r
+ @Override\r
+ public Rectangle2D getBounds(IElement e, Rectangle2D size) {\r
+ ConnectionEntity ce = e.getHint(ElementHints.KEY_CONNECTION_ENTITY);\r
+ if (ce == null)\r
+ return size;\r
+\r
+ Collection<IElement> parts = perThreadBoundsList.get();\r
+ parts.clear();\r
+ parts = ce.getSegments(parts);\r
+ if (parts.isEmpty())\r
+ return size;\r
+\r
+ parts = ce.getBranchPoints(parts);\r
+\r
+ Rectangle2D temp = null;\r
+ for (IElement part : parts) {\r
+ if (ElementUtils.isHidden(part))\r
+ continue;\r
+\r
+ // Using on-diagram coordinates because neither connections nor\r
+ // edges have a non-identity transform which means that\r
+ // coordinates are always absolute. Therefore branch point\r
+ // bounds also need to be calculated in absolute coordinates.\r
+ Rectangle2D bounds = ElementUtils.getElementBoundsOnDiagram(part, size);\r
+ if (bounds == null)\r
+ continue;\r
+\r
+// System.out.println("InternalSize BOUNDS: " + size + " for part " + part + " " + part.getElementClass());\r
+ if (temp == null) {\r
+ temp = new Rectangle2D.Double();\r
+ temp.setRect(bounds);\r
+ } else\r
+ Rectangle2D.union(temp, bounds, temp);\r
+ //System.out.println("InternalSize Combined BOUNDS: " + temp);\r
+ }\r
+ if (temp != null) {\r
+ if (size == null)\r
+ size = temp;\r
+ else\r
+ size.setRect(temp);\r
+ }\r
+\r
+ // Don't leave dangling references behind.\r
+ parts.clear();\r
+\r
+ return size;\r
+ }\r
+\r
+ private Shape getSelectionShape(IElement forPart) {\r
+ for (SelectionOutline so : forPart.getElementClass().getItemsByClass(SelectionOutline.class)) {\r
+ Shape shape = so.getSelectionShape(forPart);\r
+ if (shape != null)\r
+ return shape;\r
+ }\r
+ // Using on-diagram coordinates because neither connections nor\r
+ // edges have a non-identity transform which means that\r
+ // coordinates are always absolute. Therefore branch point\r
+ // shape also needs to be calculated in absolute coordinates.\r
+ Shape shape = ElementUtils.getElementShapeOrBoundsOnDiagram(forPart);\r
+ return shape;\r
+ //return shape.getBounds2D();\r
+ }\r
+\r
+ @Override\r
+ public Shape getElementShape(IElement e) {\r
+ ConnectionEntity ce = e.getHint(ElementHints.KEY_CONNECTION_ENTITY);\r
+ if (ce == null)\r
+ return new Rectangle2D.Double();\r
+\r
+ Collection<IElement> parts = perThreadShapeList.get();\r
+ parts.clear();\r
+ parts = ce.getSegments(parts);\r
+ if (parts.isEmpty())\r
+ return new Rectangle2D.Double();\r
+ parts = ce.getBranchPoints(parts);\r
+\r
+ if (parts.size() == 1) {\r
+ Shape shape = getSelectionShape(parts.iterator().next());\r
+ //System.out.println("Outline SHAPE: " + shape);\r
+ //System.out.println("Outline BOUNDS: " + shape.getBounds2D());\r
+ return shape;\r
+ }\r
+\r
+ //System.out.println("Outline: " + e);\r
+ Area area = new Area();\r
+ for (IElement part : parts) {\r
+ //System.out.println(part);\r
+\r
+ Shape shape = getSelectionShape(part);\r
+\r
+ Rectangle2D bounds = shape.getBounds2D();\r
+// System.out.println(" shape: " + shape);\r
+// System.out.println(" bounds: " + bounds);\r
+\r
+ if (bounds.isEmpty()) {\r
+ double w = bounds.getWidth();\r
+ double h = bounds.getHeight();\r
+ if (w <= 0.0 && h <= 0.0)\r
+ continue;\r
+\r
+ // Need to expand shape in either width or height to make it visible.\r
+ final double exp = 0.1;\r
+ if (w <= 0.0)\r
+ shape = GeometryUtils.expandRectangle(bounds, 0, 0, exp, exp);\r
+ else if (h <= 0.0)\r
+ shape = GeometryUtils.expandRectangle(bounds, exp, exp, 0, 0);\r
+ }\r
+\r
+ //System.out.println(" final shape: " + shape);\r
+ //shape = bounds;\r
+\r
+ Area a = null;\r
+ if (shape instanceof Area)\r
+ a = (Area) shape;\r
+ else\r
+ a = new Area(shape);\r
+ area.add(a);\r
+ }\r
+\r
+ // Don't leave dangling references behind.\r
+ parts.clear();\r
+\r
+ //System.out.println(" connection area outline: " + area);\r
+ //System.out.println(" connection area outline bounds: " + area.getBounds2D());\r
+ return area;\r
+ }\r
+ }\r
+\r
+ public static class ConnectionPick implements Pick2 {\r
+\r
+ public final static ConnectionPick INSTANCE = new ConnectionPick();\r
+\r
+ private static final long serialVersionUID = 1L;\r
+\r
+ @Override\r
+ public boolean pickTest(IElement e, Shape s, PickPolicy policy) {\r
+ ConnectionEntity ce = e.getHint(ElementHints.KEY_CONNECTION_ENTITY);\r
+ if (ce == null)\r
+ return false;\r
+\r
+ // Primarily pick branch points and then edges.\r
+ Collection<IElement> parts = perThreadPickList.get();\r
+ parts.clear();\r
+ parts = ce.getBranchPoints(parts);\r
+ parts = ce.getSegments(parts);\r
+ if (parts.isEmpty())\r
+ return false;\r
+\r
+ for (IElement part : parts) {\r
+ for (Pick pick : part.getElementClass().getItemsByClass(Pick.class)) {\r
+// System.out.println("TESTING: " + part + " : " + s + " : " + policy);\r
+ if (pick.pickTest(part, s, policy)) {\r
+ //System.out.println(" HIT!");\r
+ return true;\r
+ }\r
+ }\r
+ }\r
+\r
+ parts.clear();\r
+\r
+ return false;\r
+ }\r
+\r
+ @Override\r
+ public int pick(IElement e, Shape s, PickPolicy policy, Collection<IElement> result) {\r
+ int oldResultSize = result.size();\r
+\r
+// new Exception("SysdynConnectionClass.pick: " + e + " : " + s + " : " + policy).printStackTrace();\r
+ \r
+ ConnectionEntity ce = e.getHint(ElementHints.KEY_CONNECTION_ENTITY);\r
+ if (ce == null)\r
+ return 0;\r
+\r
+ // Primarily pick branch points and then edges.\r
+ List<IElement> parts = perThreadPickList.get();\r
+ parts.clear();\r
+\r
+ ce.getSegments(parts);\r
+ int edges = parts.size();\r
+ ce.getBranchPoints(parts);\r
+ int branchPoints = parts.size() - edges;\r
+\r
+ boolean singleEdge = branchPoints == 0 && edges == 1;\r
+\r
+ if (parts.isEmpty())\r
+ return 0;\r
+\r
+ // See whether the whole connection is to be picked..\r
+ boolean pickConnection = false;\r
+ wholeConnectionPick:\r
+ for (Outline outline : e.getElementClass().getItemsByClass(Outline.class)) {\r
+ Shape elementShape = outline.getElementShape(e);\r
+ if (elementShape == null)\r
+ continue;\r
+\r
+ switch (policy) {\r
+ case PICK_CONTAINED_OBJECTS:\r
+ if (GeometryUtils.contains(s, elementShape)) {\r
+ pickConnection = true;\r
+ break wholeConnectionPick;\r
+ }\r
+ break;\r
+ case PICK_INTERSECTING_OBJECTS:\r
+ if (GeometryUtils.intersects(s, elementShape)) {\r
+ pickConnection = true;\r
+ break wholeConnectionPick;\r
+ }\r
+ break;\r
+ }\r
+ }\r
+\r
+ ArrayList<IElement> picks = null;\r
+\r
+ // Pick connection segments\r
+ for (int i = 0; i < edges; ++i) {\r
+ IElement part = parts.get(i);\r
+ for (Pick pick : part.getElementClass().getItemsByClass(Pick.class)) {\r
+// System.out.println("TESTING SEGMENT: " + part + " : " + s + " : " + policy);\r
+ if (pick.pickTest(part, s, policy)) {\r
+// System.out.println(" HIT!");\r
+ if (picks == null)\r
+ picks = new ArrayList<IElement>(4);\r
+ picks.add(e);\r
+ break;\r
+ }\r
+ }\r
+ }\r
+\r
+ // Pick the whole connection ?\r
+ if (pickConnection) {\r
+ if (picks == null)\r
+ picks = new ArrayList<IElement>(4);\r
+ picks.add(e);\r
+ }\r
+\r
+ // Pick branch/route points\r
+ for (int i = edges; i < parts.size(); ++i) {\r
+ IElement part = parts.get(i);\r
+ for (Pick pick : part.getElementClass().getItemsByClass(Pick.class)) {\r
+ //System.out.println("TESTING BRANCHPOINT: " + part + " : " + s + " : " + policy);\r
+ if (pick.pickTest(part, s, policy)) {\r
+ //System.out.println(" HIT!");\r
+ if (picks == null)\r
+ picks = new ArrayList<IElement>(4);\r
+ picks.add(part);\r
+ break;\r
+ }\r
+ }\r
+ }\r
+\r
+ if (picks != null) {\r
+ // Add the discovered pickable children to the result after the\r
+ // parent to make the parent the primary pickable.\r
+ // Skip the children if there is only one child.\r
+ if (!singleEdge) {\r
+ result.addAll(picks);\r
+ } else {\r
+ result.add(e);\r
+ }\r
+ }\r
+\r
+ parts.clear();\r
+\r
+// System.out.println("pick result size = " + result.size());\r
+\r
+ return result.size() - oldResultSize;\r
+ }\r
+ }\r
+\r
+ private static final Key CHILD_LISTENERS = new KeyOf(ListenerList.class, "CHILD_LISTENERS");\r
+\r
+ public static class ConnectionChildren implements Children, ConnectionListener {\r
+\r
+ public final static ConnectionChildren INSTANCE = new ConnectionChildren();\r
+\r
+ private static final long serialVersionUID = 1L;\r
+\r
+ @Override\r
+ public Collection<IElement> getChildren(IElement element, Collection<IElement> result) {\r
+ ConnectionEntity ce = element.getHint(ElementHints.KEY_CONNECTION_ENTITY);\r
+ if (ce == null) {\r
+ if (result == null)\r
+ result = new ArrayList<IElement>(0);\r
+ return result;\r
+ }\r
+ result = ce.getSegments(result);\r
+ result = ce.getBranchPoints(result);\r
+ return result;\r
+ }\r
+\r
+ @Override\r
+ public void addChildListener(IElement element, ChildListener listener) {\r
+ ListenerList<ChildListener> ll = null;\r
+ synchronized (element) {\r
+ ll = element.getHint(CHILD_LISTENERS);\r
+ if (ll == null) {\r
+ ll = new ListenerList<ChildListener>(ChildListener.class);\r
+ element.setHint(CHILD_LISTENERS, ll);\r
+ ConnectionEntity entity = element.getHint(ElementHints.KEY_CONNECTION_ENTITY);\r
+ entity.setListener(this);\r
+ }\r
+ }\r
+ ll.add(listener);\r
+ }\r
+\r
+ @Override\r
+ public void removeChildListener(IElement element, ChildListener listener) {\r
+ synchronized (element) {\r
+ ListenerList<ChildListener> ll = element.getHint(CHILD_LISTENERS);\r
+ if (ll == null)\r
+ return;\r
+ ll.remove(listener);\r
+ if (ll.isEmpty()) {\r
+ ConnectionEntity entity = element.getHint(ElementHints.KEY_CONNECTION_ENTITY);\r
+ entity.setListener(null);\r
+ }\r
+ }\r
+ }\r
+\r
+ @Override\r
+ public void connectionChanged(ConnectionEvent event) {\r
+ fireChildrenChanged(event);\r
+ }\r
+\r
+ private void fireChildrenChanged(ConnectionEvent event) {\r
+ ListenerList<ChildListener> ll = event.connection.getHint(CHILD_LISTENERS);\r
+ if (ll == null)\r
+ return;\r
+ ChildEvent ce = new ChildEvent(event.connection, event.removedParts, event.addedParts);\r
+ for (ChildListener cl : ll.getListeners()) {\r
+ cl.elementChildrenChanged(ce);\r
+ }\r
+ }\r
+\r
+ }\r
+\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2010 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.ui.handlers;\r
+\r
+import org.eclipse.core.commands.AbstractHandler;\r
+import org.eclipse.core.commands.ExecutionEvent;\r
+import org.eclipse.core.commands.ExecutionException;\r
+import org.simantics.project.IProject;\r
+import org.simantics.simulation.experiment.IExperiment;\r
+import org.simantics.simulation.project.IExperimentManager;\r
+import org.simantics.ui.SimanticsUI;\r
+\r
+public class DisposeExperiment extends AbstractHandler {\r
+\r
+ @Override\r
+ public Object execute(ExecutionEvent event) throws ExecutionException {\r
+ IProject project = SimanticsUI.getProject();\r
+ IExperimentManager manager = \r
+ project.getHint(IExperimentManager.KEY_EXPERIMENT_MANAGER);\r
+ IExperiment experiment = manager.getActiveExperiment();\r
+ if (experiment != null)\r
+ experiment.shutdown();\r
+ return null;\r
+ }\r
+\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2011 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.ui.handlers;\r
+\r
+import java.io.FileOutputStream;\r
+import java.io.IOException;\r
+\r
+import org.eclipse.core.commands.AbstractHandler;\r
+import org.eclipse.core.commands.ExecutionEvent;\r
+import org.eclipse.core.commands.ExecutionException;\r
+import org.eclipse.core.runtime.Platform;\r
+import org.eclipse.jface.viewers.ISelection;\r
+import org.eclipse.swt.widgets.DirectoryDialog;\r
+import org.eclipse.swt.widgets.Shell;\r
+import org.eclipse.ui.handlers.HandlerUtil;\r
+import org.simantics.databoard.Bindings;\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.common.request.ReadRequest;\r
+import org.simantics.db.common.utils.NameUtils;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.sysdyn.SysdynResource;\r
+import org.simantics.ui.SimanticsUI;\r
+import org.simantics.ui.utils.ResourceAdaptionUtils;\r
+\r
+public class ExportExternalFunctionFilesHandler extends AbstractHandler {\r
+\r
+ @Override\r
+ public Object execute(ExecutionEvent event) throws ExecutionException {\r
+\r
+ \r
+ Shell shell = HandlerUtil.getActiveShellChecked(event);\r
+ ISelection sel = HandlerUtil.getCurrentSelection(event);\r
+ final Resource[] resources = ResourceAdaptionUtils.toResources(sel);\r
+ if (resources.length < 1)\r
+ return null;\r
+\r
+ DirectoryDialog dd = new DirectoryDialog(shell);\r
+ dd.setFilterPath(Platform.getLocation().toOSString());\r
+ dd.setText("Export files to...");\r
+ dd.setMessage("Select a directory");\r
+ final String dir = dd.open();\r
+ if (dir == null) {\r
+ return null;\r
+ }\r
+\r
+ SimanticsUI.getSession().asyncRequest(new ReadRequest() {\r
+\r
+ @Override\r
+ public void run(ReadGraph graph) throws DatabaseException {\r
+ SysdynResource sr = SysdynResource.getInstance(graph);\r
+ for(Resource r : resources) {\r
+ try {\r
+ String name = NameUtils.getSafeName(graph, r);\r
+ FileOutputStream fos = new FileOutputStream(dir + "\\" + name);\r
+ byte[] fileBArray = graph.getPossibleRelatedValue(r, sr.HasExternalFile, Bindings.BYTE_ARRAY);\r
+ fos.write(fileBArray);\r
+ fos.close();\r
+ } catch (IOException e) {\r
+ e.printStackTrace();\r
+ }\r
+ }\r
+ \r
+ }\r
+ });\r
+\r
+ return null;\r
+ }\r
+\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2011 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.ui.handlers;\r
+\r
+import java.io.File;\r
+import java.io.IOException;\r
+import java.util.ArrayList;\r
+\r
+import org.eclipse.core.commands.AbstractHandler;\r
+import org.eclipse.core.commands.ExecutionEvent;\r
+import org.eclipse.core.commands.ExecutionException;\r
+import org.eclipse.core.runtime.Platform;\r
+import org.eclipse.jface.viewers.ISelection;\r
+import org.eclipse.swt.SWT;\r
+import org.eclipse.swt.widgets.FileDialog;\r
+import org.eclipse.swt.widgets.Shell;\r
+import org.eclipse.ui.handlers.HandlerUtil;\r
+import org.simantics.databoard.Bindings;\r
+import org.simantics.databoard.Files;\r
+import org.simantics.databoard.binding.error.RuntimeBindingConstructionException;\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.common.primitiverequest.PossibleRelatedValue;\r
+import org.simantics.db.common.request.ReadRequest;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.db.layer0.util.TransferableGraphRequest2;\r
+import org.simantics.db.request.Read;\r
+import org.simantics.graph.representation.TransferableGraph1;\r
+import org.simantics.layer0.Layer0;\r
+import org.simantics.ui.SimanticsUI;\r
+import org.simantics.ui.utils.ResourceAdaptionUtils;\r
+import org.simantics.utils.datastructures.Pair;\r
+\r
+public class ExportFunctionLibrary extends AbstractHandler {\r
+\r
+ @Override\r
+ public Object execute(ExecutionEvent event) throws ExecutionException {\r
+\r
+ ISelection sel = HandlerUtil.getCurrentSelection(event);\r
+ final Resource functionLibrary = ResourceAdaptionUtils.toSingleResource(sel);\r
+ if(functionLibrary == null) return null;\r
+ \r
+ String name = null;\r
+ try {\r
+ name = SimanticsUI.getSession().syncRequest(new Read<String>() {\r
+\r
+ @Override\r
+ public String perform(ReadGraph graph) throws DatabaseException {\r
+ if (!graph.hasStatement(functionLibrary, Layer0.getInstance(graph).PartOf))\r
+ return null;\r
+ Layer0 l0 = Layer0.getInstance(graph);\r
+ String name = graph.syncRequest(new PossibleRelatedValue<String>(functionLibrary, l0.HasName, Bindings.STRING ));\r
+ return name;\r
+ \r
+ }\r
+ \r
+ });\r
+ } catch (DatabaseException e1) {\r
+ e1.printStackTrace();\r
+ }\r
+ if(name == null) return null;\r
+ \r
+ Shell shell = HandlerUtil.getActiveShellChecked(event);\r
+ FileDialog fd = new FileDialog(shell, SWT.SAVE);\r
+ fd.setText("Export..");\r
+ fd.setFileName(name);\r
+ fd.setFilterPath(Platform.getLocation().toOSString());\r
+ String[] filterExt = {"*.tg"};\r
+ fd.setFilterExtensions(filterExt);\r
+ final String selected = fd.open();\r
+ if(selected == null) return null;\r
+ \r
+ \r
+ SimanticsUI.getSession().asyncRequest(new ReadRequest() {\r
+ \r
+ @Override\r
+ public void run(ReadGraph graph) throws DatabaseException {\r
+ Layer0 l0 = Layer0.getInstance(graph);\r
+ String name = graph.syncRequest(new PossibleRelatedValue<String>(functionLibrary, l0.HasName, Bindings.STRING ));\r
+ ArrayList<Pair<Resource, String>> roots = new ArrayList<Pair<Resource, String>>();\r
+ roots.add(Pair.make(functionLibrary, name));\r
+ TransferableGraph1 tg = graph.syncRequest(new TransferableGraphRequest2(roots, functionLibrary));\r
+\r
+ try {\r
+ Files.createFile(new File(selected), Bindings.getBindingUnchecked(TransferableGraph1.class), tg);\r
+ } catch (RuntimeBindingConstructionException e) {\r
+ e.printStackTrace();\r
+ } catch (IOException e) {\r
+ e.printStackTrace();\r
+ }\r
+\r
+ \r
+ }\r
+ });\r
+\r
+ return null;\r
+ }\r
+\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2010 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.ui.handlers;\r
+\r
+import java.io.File;\r
+import java.io.IOException;\r
+import java.util.ArrayList;\r
+\r
+import org.eclipse.core.commands.AbstractHandler;\r
+import org.eclipse.core.commands.ExecutionEvent;\r
+import org.eclipse.core.commands.ExecutionException;\r
+import org.eclipse.core.runtime.Platform;\r
+import org.eclipse.jface.viewers.ISelection;\r
+import org.eclipse.swt.SWT;\r
+import org.eclipse.swt.widgets.FileDialog;\r
+import org.eclipse.swt.widgets.Shell;\r
+import org.eclipse.ui.handlers.HandlerUtil;\r
+import org.simantics.databoard.Bindings;\r
+import org.simantics.databoard.Files;\r
+import org.simantics.databoard.binding.error.RuntimeBindingConstructionException;\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.common.primitiverequest.PossibleRelatedValue;\r
+import org.simantics.db.common.request.ReadRequest;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.db.layer0.util.TransferableGraphRequest2;\r
+import org.simantics.db.request.Read;\r
+import org.simantics.graph.representation.TransferableGraph1;\r
+import org.simantics.layer0.Layer0;\r
+import org.simantics.ui.SimanticsUI;\r
+import org.simantics.ui.utils.ResourceAdaptionUtils;\r
+import org.simantics.utils.datastructures.Pair;\r
+\r
+public class ExportModelHandler extends AbstractHandler {\r
+\r
+ @Override\r
+ public Object execute(ExecutionEvent event) throws ExecutionException {\r
+ ISelection sel = HandlerUtil.getCurrentSelection(event);\r
+ final Resource model = ResourceAdaptionUtils.toSingleResource(sel);\r
+ if(model == null) return null;\r
+ \r
+ // FIXME: Model browser doesn't change its selection even if the selected object is removed,\r
+ // so you can try to export a removed model \r
+ String name = null;\r
+ try {\r
+ name = SimanticsUI.getSession().syncRequest(new Read<String>() {\r
+\r
+ @Override\r
+ public String perform(ReadGraph graph) throws DatabaseException {\r
+ if (!graph.hasStatement(model, Layer0.getInstance(graph).PartOf))\r
+ return null;\r
+ Layer0 l0 = Layer0.getInstance(graph);\r
+ String name = graph.syncRequest(new PossibleRelatedValue<String>(model, l0.HasName, Bindings.STRING ));\r
+ return name;\r
+ \r
+ }\r
+ \r
+ });\r
+ } catch (DatabaseException e1) {\r
+ e1.printStackTrace();\r
+ }\r
+ if(name == null) return null;\r
+ \r
+ Shell shell = HandlerUtil.getActiveShellChecked(event);\r
+ FileDialog fd = new FileDialog(shell, SWT.SAVE);\r
+ fd.setText("Export..");\r
+ fd.setFileName(name);\r
+ fd.setFilterPath(Platform.getLocation().toOSString());\r
+ String[] filterExt = {"*.tg"};\r
+ fd.setFilterExtensions(filterExt);\r
+ final String selected = fd.open();\r
+ if(selected == null) return null;\r
+ \r
+ \r
+ SimanticsUI.getSession().asyncRequest(new ReadRequest() {\r
+ \r
+ @Override\r
+ public void run(ReadGraph graph) throws DatabaseException {\r
+ Layer0 l0 = Layer0.getInstance(graph);\r
+ String name = graph.syncRequest(new PossibleRelatedValue<String>(model, l0.HasName, Bindings.STRING ));\r
+ ArrayList<Pair<Resource, String>> roots = new ArrayList<Pair<Resource, String>>();\r
+ roots.add(Pair.make(model, name));\r
+ TransferableGraph1 tg = graph.syncRequest(new TransferableGraphRequest2(roots, model));\r
+\r
+ try {\r
+ Files.createFile(new File(selected), Bindings.getBindingUnchecked(TransferableGraph1.class), tg);\r
+ } catch (RuntimeBindingConstructionException e) {\r
+ e.printStackTrace();\r
+ } catch (IOException e) {\r
+ e.printStackTrace();\r
+ }\r
+\r
+ \r
+ }\r
+ });\r
+\r
+ return null;\r
+ }\r
+\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2011 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.ui.handlers;\r
+\r
+import java.io.File;\r
+import java.io.FileInputStream;\r
+import java.io.IOException;\r
+\r
+import org.eclipse.core.commands.AbstractHandler;\r
+import org.eclipse.core.commands.ExecutionEvent;\r
+import org.eclipse.core.commands.ExecutionException;\r
+import org.eclipse.core.runtime.Platform;\r
+import org.eclipse.swt.SWT;\r
+import org.eclipse.swt.widgets.FileDialog;\r
+import org.eclipse.swt.widgets.Shell;\r
+import org.eclipse.ui.handlers.HandlerUtil;\r
+import org.simantics.databoard.Bindings;\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.WriteGraph;\r
+import org.simantics.db.common.request.WriteRequest;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.layer0.Layer0;\r
+import org.simantics.layer0.utils.direct.GraphUtils;\r
+import org.simantics.sysdyn.SysdynResource;\r
+import org.simantics.sysdyn.manager.FunctionUtils;\r
+import org.simantics.ui.SimanticsUI;\r
+import org.simantics.utils.datastructures.Pair;\r
+\r
+public class ImportExternalFunctionFilesHandler extends AbstractHandler {\r
+\r
+ public static final String[] C_EXTENSIONS = {"*.c","*.h","*.a","*.o"};\r
+ @Override\r
+ public Object execute(ExecutionEvent event) throws ExecutionException {\r
+ Shell shell = HandlerUtil.getActiveShellChecked(event);\r
+ Pair<String, String[]> selected = importFiles(shell, "Import...", C_EXTENSIONS);\r
+ if(selected.second == null || selected.second.length < 1) return null;\r
+\r
+ SimanticsUI.getSession().asyncRequest(new WriteRequest() {\r
+ \r
+ @Override\r
+ public void perform(WriteGraph graph) throws DatabaseException {\r
+ // TODO: include files to database\r
+ }\r
+ });\r
+ \r
+ return null;\r
+ }\r
+ \r
+ /**\r
+ * Import \r
+ * \r
+ * @param shell\r
+ * @return\r
+ */\r
+ public static Pair<String, String[]> importFiles(Shell shell, String text, String[] filter) {\r
+ FileDialog fd = new FileDialog(shell, SWT.OPEN);\r
+ fd.setText(text);\r
+ fd.setFilterPath(Platform.getLocation().toOSString());\r
+ fd.setFilterExtensions(filter);\r
+ fd.open();\r
+ return new Pair<String, String[]>(fd.getFilterPath(), fd.getFileNames());\r
+ }\r
+ \r
+ public static void addFilesToFunction(WriteGraph graph, Resource function, Pair<String, String[]> files) throws DatabaseException {\r
+ SysdynResource sr = SysdynResource.getInstance(graph);\r
+ Layer0 l0 = Layer0.getInstance(graph);\r
+ \r
+ if(!graph.isInstanceOf(function, sr.SysdynModelicaFunction))\r
+ return;\r
+\r
+ for(String filename : files.second) {\r
+ File file = new File(files.first, filename);\r
+ \r
+ String name = file.getName();\r
+ \r
+ Resource externalFile = GraphUtils.create2(graph, \r
+ sr.ExternalFunctionFile,\r
+ l0.PartOf, function,\r
+ l0.HasName, name);\r
+ \r
+ try {\r
+ byte[] fileBArray = new byte[(int)file.length()];\r
+ FileInputStream fis = new FileInputStream(file);\r
+ fis.read(fileBArray);\r
+ graph.claimLiteral(externalFile, sr.HasExternalFile, fileBArray, Bindings.BYTE_ARRAY);\r
+ \r
+ FunctionUtils.createExternalFunctionFile(graph, externalFile);\r
+ } catch (IOException e) {\r
+ e.printStackTrace();\r
+ }\r
+\r
+ }\r
+ \r
+ }\r
+\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2011 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.ui.handlers;\r
+\r
+import java.io.File;\r
+import java.io.IOException;\r
+\r
+import org.eclipse.core.commands.AbstractHandler;\r
+import org.eclipse.core.commands.ExecutionEvent;\r
+import org.eclipse.core.commands.ExecutionException;\r
+import org.eclipse.core.runtime.Platform;\r
+import org.eclipse.jface.viewers.ISelection;\r
+import org.eclipse.swt.SWT;\r
+import org.eclipse.swt.widgets.FileDialog;\r
+import org.eclipse.swt.widgets.Shell;\r
+import org.eclipse.ui.handlers.HandlerUtil;\r
+import org.simantics.databoard.Bindings;\r
+import org.simantics.databoard.Files;\r
+import org.simantics.databoard.binding.error.RuntimeBindingConstructionException;\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.WriteGraph;\r
+import org.simantics.db.WriteOnlyGraph;\r
+import org.simantics.db.common.request.ReadRequest;\r
+import org.simantics.db.common.request.WriteRequest;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.db.exception.ResourceNotFoundException;\r
+import org.simantics.db.layer0.adapter.impl.DefaultPasteHandler;\r
+import org.simantics.db.layer0.adapter.impl.DefaultPasteImportAdvisor;\r
+import org.simantics.db.request.Read;\r
+import org.simantics.graph.representation.Root;\r
+import org.simantics.graph.representation.TransferableGraph1;\r
+import org.simantics.layer0.Layer0;\r
+import org.simantics.layer0.utils.direct.GraphUtils;\r
+import org.simantics.sysdyn.SysdynResource;\r
+import org.simantics.sysdyn.manager.FunctionUtils;\r
+import org.simantics.ui.SimanticsUI;\r
+import org.simantics.ui.utils.ResourceAdaptionUtils;\r
+\r
+public class ImportFunctionLibrary extends AbstractHandler {\r
+\r
+ @Override\r
+ public Object execute(ExecutionEvent event) throws ExecutionException {\r
+ Resource project = SimanticsUI.getProject().get();\r
+ if(project == null) return null;\r
+\r
+ ISelection sel = HandlerUtil.getCurrentSelection(event);\r
+ final Resource functionLibrary = ResourceAdaptionUtils.toSingleResource(sel);\r
+ if(functionLibrary == null) return null;\r
+ \r
+ Shell shell = HandlerUtil.getActiveShellChecked(event);\r
+ FileDialog fd = new FileDialog(shell, SWT.OPEN);\r
+ fd.setText("Import Function Library");\r
+ fd.setFilterPath(Platform.getLocation().toOSString());\r
+ String[] filterExt = {"*.tg"};\r
+ fd.setFilterExtensions(filterExt);\r
+ String selected = fd.open();\r
+ if(selected == null) return null;\r
+\r
+ TransferableGraph1 tg = null;\r
+ try {\r
+ tg = (TransferableGraph1)Files.readFile(new File(selected), Bindings.getBindingUnchecked(TransferableGraph1.class));\r
+ } catch (RuntimeBindingConstructionException e) {\r
+ e.printStackTrace();\r
+ } catch (IOException e) {\r
+ e.printStackTrace();\r
+ }\r
+ if(tg == null) return null;\r
+\r
+ \r
+ try {\r
+ Boolean hasSharedOntologies;\r
+ hasSharedOntologies = SimanticsUI.getSession().syncRequest(new Read<Boolean>() {\r
+\r
+ @Override\r
+ public Boolean perform(ReadGraph graph) throws DatabaseException {\r
+ try {\r
+ graph.getResource("http://SharedOntologies");\r
+ } catch (ResourceNotFoundException e) {\r
+ return false;\r
+ } \r
+ return true;\r
+ }\r
+ });\r
+\r
+ if(!hasSharedOntologies) {\r
+ SimanticsUI.getSession().syncRequest(new WriteRequest() {\r
+\r
+ @Override\r
+ public void perform(WriteGraph graph) throws DatabaseException {\r
+ Layer0 l0 = Layer0.getInstance(graph);\r
+ GraphUtils.create2(graph, l0.Library, \r
+ l0.HasName, "SharedOntologies",\r
+ l0.PartOf, graph.getResource("http:/"));\r
+ }\r
+ });\r
+\r
+ }\r
+ } catch (DatabaseException e) {\r
+ e.printStackTrace();\r
+ return null;\r
+ }\r
+\r
+ \r
+ SysdynFunctionLibraryImportAdvisor ia = new SysdynFunctionLibraryImportAdvisor(functionLibrary);\r
+ try {\r
+ DefaultPasteHandler.defaultExecute(tg, functionLibrary, ia);\r
+ } catch (Exception e) {\r
+ e.printStackTrace();\r
+ }\r
+ \r
+ SimanticsUI.getSession().asyncRequest(new ReadRequest() {\r
+ \r
+ @Override\r
+ public void run(ReadGraph graph) throws DatabaseException {\r
+ FunctionUtils.updateFunctionFileForLibrary(graph, functionLibrary);\r
+ }\r
+ });\r
+ return null;\r
+ }\r
+ \r
+ private class SysdynFunctionLibraryImportAdvisor extends DefaultPasteImportAdvisor {\r
+\r
+ \r
+ Resource model = null;\r
+ \r
+ public SysdynFunctionLibraryImportAdvisor(Resource library) {\r
+ super(library);\r
+ }\r
+ \r
+ @Override\r
+ public void analyzeType(ReadGraph graph, Root root) throws DatabaseException {\r
+ if(root.type.equals(SysdynResource.URIs.SharedFunctionOntology)) {\r
+ library = null;\r
+ try {\r
+ SysdynResource sr = SysdynResource.getInstance(graph);\r
+ Layer0 l0 = Layer0.getInstance(graph);\r
+ Resource r = library;\r
+ while(!graph.isInstanceOf(r, sr.SysdynModel) && graph.isInstanceOf(r, l0.Ontology))\r
+ r = graph.getSingleObject(r, l0.PartOf);\r
+ if(graph.isInstanceOf(r, sr.SysdynModel))\r
+ model = r;\r
+ \r
+ library = graph.getResource("http://SharedOntologies");\r
+ } catch (ResourceNotFoundException e) {\r
+ e.printStackTrace();\r
+ }\r
+ }\r
+ }\r
+ \r
+ @Override\r
+ public Resource createRoot(WriteOnlyGraph graph, Root root) throws DatabaseException {\r
+ Layer0 l0 = graph.getService(Layer0.class);\r
+ this.root = graph.newResource();\r
+ graph.claim(library, l0.ConsistsOf, l0.PartOf, this.root);\r
+ String name = root.name;\r
+ String newName = nameMappings.get(name);\r
+ graph.addLiteral(this.root, l0.HasName, l0.NameOf, l0.String, newName, Bindings.STRING);\r
+ if(model != null && root.type.equals(SysdynResource.URIs.SharedFunctionOntology)) {\r
+ graph.claim(model, l0.IsLinkedTo, l0.IsLinkedTo_Inverse, this.root);\r
+ }\r
+ return this.root;\r
+\r
+ }\r
+ \r
+ }\r
+\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2011 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.ui.handlers;\r
+\r
+import java.io.File;\r
+\r
+import org.eclipse.core.commands.AbstractHandler;\r
+import org.eclipse.core.commands.ExecutionEvent;\r
+import org.eclipse.core.commands.ExecutionException;\r
+import org.eclipse.swt.SWT;\r
+import org.eclipse.swt.widgets.FileDialog;\r
+import org.eclipse.swt.widgets.Shell;\r
+import org.eclipse.ui.handlers.HandlerUtil;\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.WriteGraph;\r
+import org.simantics.db.common.request.WriteRequest;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.sysdyn.mdlImport.MdlParser;\r
+import org.simantics.sysdyn.mdlImport.mdlElements.Model;\r
+import org.simantics.ui.SimanticsUI;\r
+\r
+public class ImportMdlHandler extends AbstractHandler {\r
+\r
+ @Override\r
+ public Object execute(ExecutionEvent event) throws ExecutionException {\r
+ \r
+ final Resource project = SimanticsUI.getProject().get();\r
+ if(project == null) return null;\r
+\r
+ Shell shell = HandlerUtil.getActiveShellChecked(event);\r
+ FileDialog fd = new FileDialog(shell, SWT.OPEN);\r
+ fd.setText("Import .mdl");\r
+ fd.setFilterPath("D:\\DATA\\Openprod\\vensim-malleja");\r
+ String[] filterExt = {"*.mdl"};\r
+ fd.setFilterExtensions(filterExt);\r
+ String selected = fd.open();\r
+ if(selected == null) return null;\r
+\r
+ File file = new File(selected);\r
+ if(!file.isFile()) return null;\r
+ \r
+ final Model model = MdlParser.parse(file);\r
+ \r
+ SimanticsUI.getSession().asyncRequest(new WriteRequest() {\r
+ \r
+ @Override\r
+ public void perform(WriteGraph graph) throws DatabaseException {\r
+ model.write(graph, project);\r
+ }\r
+ });\r
+ \r
+ return null;\r
+ }\r
+\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2010 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.ui.handlers;\r
+\r
+import java.io.File;\r
+import java.io.IOException;\r
+import java.util.HashSet;\r
+\r
+import org.eclipse.core.commands.AbstractHandler;\r
+import org.eclipse.core.commands.ExecutionEvent;\r
+import org.eclipse.core.commands.ExecutionException;\r
+import org.eclipse.core.runtime.Platform;\r
+import org.eclipse.swt.SWT;\r
+import org.eclipse.swt.widgets.FileDialog;\r
+import org.eclipse.swt.widgets.Shell;\r
+import org.eclipse.ui.handlers.HandlerUtil;\r
+import org.simantics.databoard.Bindings;\r
+import org.simantics.databoard.Files;\r
+import org.simantics.databoard.binding.error.RuntimeBindingConstructionException;\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.WriteGraph;\r
+import org.simantics.db.common.request.WriteRequest;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.db.layer0.adapter.impl.DefaultPasteHandler;\r
+import org.simantics.db.layer0.adapter.impl.DefaultPasteImportAdvisor;\r
+import org.simantics.graph.representation.TransferableGraph1;\r
+import org.simantics.layer0.Layer0;\r
+import org.simantics.layer0.utils.direct.GraphUtils;\r
+import org.simantics.modeling.ModelingResources;\r
+import org.simantics.simulation.ontology.SimulationResource;\r
+import org.simantics.structural.stubs.StructuralResource2;\r
+import org.simantics.sysdyn.SysdynResource;\r
+import org.simantics.sysdyn.ui.utils.OldTransferableGraph1;\r
+import org.simantics.ui.SimanticsUI;\r
+\r
+public class ImportModelHandler extends AbstractHandler {\r
+\r
+ @Override\r
+ public Object execute(ExecutionEvent event) throws ExecutionException {\r
+ \r
+ Resource project = SimanticsUI.getProject().get();\r
+ if(project == null) return null;\r
+\r
+ Shell shell = HandlerUtil.getActiveShellChecked(event);\r
+ FileDialog fd = new FileDialog(shell, SWT.OPEN);\r
+ fd.setText("Import...");\r
+ fd.setFilterPath(Platform.getLocation().toOSString());\r
+ String[] filterExt = {"*.tg"};\r
+ fd.setFilterExtensions(filterExt);\r
+ String selected = fd.open();\r
+ if(selected == null) return null;\r
+\r
+ TransferableGraph1 tg = null;\r
+ try {\r
+ tg = (TransferableGraph1)Files.readFile(new File(selected), Bindings.getBindingUnchecked(TransferableGraph1.class));\r
+ } catch (RuntimeBindingConstructionException e) {\r
+ e.printStackTrace();\r
+ } catch (IOException e) { \r
+ try {\r
+ OldTransferableGraph1 otg = (OldTransferableGraph1)Files.readFile(new File(selected), Bindings.getBindingUnchecked(OldTransferableGraph1.class));\r
+ tg = new TransferableGraph1(otg.resourceCount, otg.identities, otg.statements, otg.values);\r
+ } catch (RuntimeBindingConstructionException e1) {\r
+ e1.printStackTrace();\r
+ } catch (IOException e1) {\r
+ e1.printStackTrace();\r
+ }\r
+ }\r
+ if(tg == null) return null;\r
+ \r
+ try {\r
+ \r
+ DefaultPasteImportAdvisor ia = new DefaultPasteImportAdvisor(project);\r
+ DefaultPasteHandler.defaultExecute(tg, SimanticsUI.getProject().get(), ia);\r
+\r
+ \r
+ // Fix changes made to old ontology versions\r
+ final Resource root = ia.getRoot();\r
+ SimanticsUI.getSession().syncRequest(new WriteRequest() {\r
+ \r
+ @Override\r
+ public void perform(WriteGraph graph) throws DatabaseException {\r
+ updateOldConfigurationToBaseRealization(graph, root);\r
+ addDefaultOntologyLinks(graph, root);\r
+ addURIsToDiagrams(graph, root);\r
+ }\r
+ });\r
+ } catch (DatabaseException e) {\r
+ e.printStackTrace();\r
+ } catch (Exception e) {\r
+ e.printStackTrace();\r
+ }\r
+ \r
+ return null;\r
+ }\r
+ \r
+ /**\r
+ * In old versions base realization was separate. Newer versions use configuration as base realization. \r
+ * @param graph WriteGraph\r
+ * @param model Imported model\r
+ */\r
+ private static void updateOldConfigurationToBaseRealization(WriteGraph graph, Resource model) {\r
+ Layer0 l0 = Layer0.getInstance(graph);\r
+ try {\r
+ Resource configuration = graph.getPossibleObject(model, SimulationResource.getInstance(graph).HasConfiguration);\r
+ if(configuration != null && !graph.hasStatement(configuration, l0.IsBaseRealizationOf, model))\r
+ graph.claim(configuration, l0.IsBaseRealizationOf, model);\r
+ } catch (DatabaseException e) {\r
+ e.printStackTrace();\r
+ }\r
+ \r
+ }\r
+ \r
+ /**\r
+ * Links should be exported and imported automatically. If it has failed, the \r
+ * default ontology links sysdyn and layer0 are added.\r
+ * \r
+ * @param graph WriteGraph\r
+ * @param model Imported model\r
+ */\r
+ \r
+ private static void addDefaultOntologyLinks(WriteGraph graph, Resource model) {\r
+ try {\r
+ Layer0 l0 = Layer0.getInstance(graph);\r
+ // The links should be exported and imported automatically\r
+ Resource sysdyn = graph.getResource("http://www.simantics.org/Sysdyn-1.0");\r
+ Resource layer0 = graph.getResource("http://www.simantics.org/Layer0-1.0");\r
+ if(!graph.hasStatement(model, l0.IsLinkedTo, sysdyn))\r
+ graph.claim(model, l0.IsLinkedTo, sysdyn);\r
+ if(!graph.hasStatement(model, l0.IsLinkedTo, layer0))\r
+ graph.claim(model, l0.IsLinkedTo, layer0);\r
+ } catch (DatabaseException e) {\r
+ e.printStackTrace();\r
+ }\r
+ }\r
+ \r
+ \r
+ private static void addURIsToDiagrams(WriteGraph graph, Resource model) {\r
+ Layer0 l0 = Layer0.getInstance(graph);\r
+ SimulationResource simu = SimulationResource.getInstance(graph);\r
+ ModelingResources mr = ModelingResources.getInstance(graph);\r
+ SysdynResource sr = SysdynResource.getInstance(graph);\r
+ StructuralResource2 sr2 = StructuralResource2.getInstance(graph);\r
+ try {\r
+ HashSet<Resource> configurations = new HashSet<Resource>();\r
+ \r
+ Resource configuration = graph.getPossibleObject(model, simu.HasConfiguration);\r
+ if(configuration != null) \r
+ configurations.add(configuration);\r
+ \r
+ for(Resource r : graph.getObjects(model, l0.ConsistsOf)) {\r
+ if(graph.isInheritedFrom(r, sr.Module)) {\r
+ Resource moduleConfiguration = graph.getPossibleObject(r, sr2.IsDefinedBy);\r
+ if(moduleConfiguration != null)\r
+ configurations.add(moduleConfiguration);\r
+ }\r
+ }\r
+ \r
+ for(Resource conf : configurations) {\r
+ Resource configurationDiagram = graph.getPossibleObject(conf, mr.CompositeToDiagram);\r
+ if(configurationDiagram != null && !graph.hasStatement(configurationDiagram, l0.PartOf)) {\r
+ GraphUtils.create2(graph, l0.Library, \r
+ l0.HasName, "__CONTAINER__",\r
+ l0.PartOf, conf,\r
+ l0.ConsistsOf, configurationDiagram);\r
+ }\r
+ }\r
+ \r
+ } catch (DatabaseException e) {\r
+ e.printStackTrace();\r
+ }\r
+ }\r
+}\r
--- /dev/null
+package org.simantics.sysdyn.ui.handlers;\r
+\r
+import org.eclipse.core.commands.AbstractHandler;\r
+import org.eclipse.core.commands.ExecutionEvent;\r
+import org.eclipse.core.commands.ExecutionException;\r
+import org.eclipse.jface.viewers.ISelection;\r
+import org.eclipse.ui.handlers.HandlerUtil;\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.WriteGraph;\r
+import org.simantics.db.common.request.WriteRequest;\r
+import org.simantics.db.common.utils.OrderedSetUtils;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.layer0.Layer0;\r
+import org.simantics.layer0.utils.direct.GraphUtils;\r
+import org.simantics.modeling.ModelingResources;\r
+import org.simantics.structural.stubs.StructuralResource2;\r
+import org.simantics.sysdyn.SysdynResource;\r
+import org.simantics.ui.SimanticsUI;\r
+import org.simantics.ui.utils.AdaptionUtils;\r
+\r
+public class NewEnumerationNodeHandler extends AbstractHandler {\r
+\r
+ @Override\r
+ public Object execute(ExecutionEvent event) throws ExecutionException {\r
+\r
+ ISelection sel = HandlerUtil.getCurrentSelection(event);\r
+ \r
+ final Resource resource = AdaptionUtils.adaptToSingle(sel, Resource.class);\r
+ \r
+ SimanticsUI.getSession().asyncRequest(new WriteRequest() {\r
+\r
+ @Override\r
+ public void perform(WriteGraph g) throws DatabaseException {\r
+ SysdynResource sr = SysdynResource.getInstance(g);\r
+ Layer0 l0 = Layer0.getInstance(g);\r
+ \r
+ Resource configuration = null;\r
+ if(g.isInstanceOf(resource, sr.Configuration)) {\r
+ configuration = resource;\r
+ } else if(g.isInheritedFrom(resource, sr.ModuleSymbol)) {\r
+ Resource module = g.getPossibleObject(resource,ModelingResources.getInstance(g).SymbolToComponentType);\r
+ configuration = g.getPossibleObject(module, StructuralResource2.getInstance(g).IsDefinedBy);\r
+ } else {\r
+ Resource instanceOf = g.getSingleObject(resource, l0.InstanceOf);\r
+ if(g.isInheritedFrom(instanceOf, sr.Module)) {\r
+ configuration = g.getPossibleObject(instanceOf, StructuralResource2.getInstance(g).IsDefinedBy);\r
+ } else {\r
+ return;\r
+ }\r
+ }\r
+\r
+ Resource enumerationIndexes = OrderedSetUtils.create(g, sr.EnumerationIndexes);\r
+ \r
+ Resource enumeration = GraphUtils.create2(g, \r
+ sr.Enumeration,\r
+ l0.HasName, "Enumeration",\r
+ sr.HasEnumerationIndexes, enumerationIndexes);\r
+ \r
+ g.claim(configuration, l0.ConsistsOf, enumeration);\r
+ \r
+ }\r
+ });\r
+ return null;\r
+ }\r
+\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2010 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.ui.handlers;\r
+\r
+import org.eclipse.core.commands.AbstractHandler;\r
+import org.eclipse.core.commands.ExecutionEvent;\r
+import org.eclipse.core.commands.ExecutionException;\r
+import org.eclipse.jface.viewers.ISelection;\r
+import org.eclipse.ui.handlers.HandlerUtil;\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.WriteGraph;\r
+import org.simantics.db.common.request.WriteRequest;\r
+import org.simantics.db.common.utils.NameUtils;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.layer0.Layer0;\r
+import org.simantics.layer0.utils.direct.GraphUtils;\r
+import org.simantics.simulation.ontology.SimulationResource;\r
+import org.simantics.sysdyn.ui.browser.nodes.ExperimentsFolder;\r
+import org.simantics.ui.SimanticsUI;\r
+import org.simantics.ui.utils.AdaptionUtils;\r
+\r
+public class NewExperimentNodeHandler extends AbstractHandler {\r
+\r
+ @Override\r
+ public Object execute(ExecutionEvent event) throws ExecutionException {\r
+ System.out.println("New Experiment");\r
+\r
+ ISelection sel = HandlerUtil.getCurrentSelection(event);\r
+ \r
+ ExperimentsFolder node = AdaptionUtils.adaptToSingle(sel, ExperimentsFolder.class);\r
+ if (node == null)\r
+ return null;\r
+\r
+ final Resource model = node.data;\r
+\r
+ SimanticsUI.getSession().asyncRequest(new WriteRequest() {\r
+\r
+ @Override\r
+ public void perform(WriteGraph g) throws DatabaseException {\r
+ Layer0 l0 = Layer0.getInstance(g);\r
+ Resource report = GraphUtils.create2(g, l0.Report, l0.HasDocumentation, "===Report===");\r
+\r
+ String name = NameUtils.findFreshName(g, "Experiment", model, l0.ConsistsOf, "%s%d");\r
+\r
+ @SuppressWarnings("unused")\r
+ Resource experiment = GraphUtils.create2(g, SimulationResource.getInstance(g).Experiment,\r
+ l0.HasName, name,\r
+ l0.HasLabel, name,\r
+ l0.HasReportFactory, report,\r
+ l0.PartOf, model);\r
+ }\r
+ });\r
+ return null;\r
+ }\r
+\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2011 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.ui.handlers;\r
+\r
+import org.eclipse.core.commands.AbstractHandler;\r
+import org.eclipse.core.commands.ExecutionEvent;\r
+import org.eclipse.core.commands.ExecutionException;\r
+import org.eclipse.jface.viewers.ISelection;\r
+import org.eclipse.ui.handlers.HandlerUtil;\r
+import org.simantics.browsing.ui.common.node.AbstractNode;\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.WriteGraph;\r
+import org.simantics.db.common.request.WriteRequest;\r
+import org.simantics.db.common.utils.NameUtils;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.layer0.Layer0;\r
+import org.simantics.layer0.utils.direct.GraphUtils;\r
+import org.simantics.sysdyn.SysdynResource;\r
+import org.simantics.sysdyn.manager.FunctionUtils;\r
+import org.simantics.ui.SimanticsUI;\r
+import org.simantics.ui.utils.AdaptionUtils;\r
+\r
+public class NewFunctionHandler extends AbstractHandler {\r
+\r
+ @Override\r
+ public Object execute(ExecutionEvent event) throws ExecutionException {\r
+\r
+ ISelection sel = HandlerUtil.getCurrentSelection(event);\r
+ \r
+ @SuppressWarnings("unchecked")\r
+ AbstractNode<Resource> node = AdaptionUtils.adaptToSingle(sel, AbstractNode.class);\r
+ if (node == null)\r
+ return null;\r
+\r
+ final Resource data = node.data;\r
+\r
+ SimanticsUI.getSession().asyncRequest(new WriteRequest() {\r
+\r
+ @Override\r
+ public void perform(WriteGraph g) throws DatabaseException {\r
+ Layer0 l0 = Layer0.getInstance(g);\r
+ SysdynResource sr = SysdynResource.getInstance(g);\r
+\r
+ Resource library = null;\r
+ if(g.isInstanceOf(data, sr.SysdynModel) || g.isInstanceOf(data, l0.Library))\r
+ library = data;\r
+ else if (g.isInstanceOf(data, sr.SysdynModelicaFunction))\r
+ library = g.getPossibleObject(data, l0.PartOf);\r
+ \r
+ if(library == null)\r
+ return;\r
+ \r
+ \r
+ String name = NameUtils.findFreshName(g, "Function", library, l0.ConsistsOf, "%s%d");\r
+\r
+ GraphUtils.create2(g, sr.SysdynModelicaFunction,\r
+ l0.HasName, name,\r
+ l0.HasDescription, "",\r
+ sr.HasModelicaFunctionCode, "",\r
+ l0.PartOf, library);\r
+ \r
+ FunctionUtils.updateFunctionFileForLibrary(g, library);\r
+ }\r
+ });\r
+ \r
+ return null;\r
+ }\r
+\r
+\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2011 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.ui.handlers;\r
+\r
+import org.eclipse.core.commands.AbstractHandler;\r
+import org.eclipse.core.commands.ExecutionEvent;\r
+import org.eclipse.core.commands.ExecutionException;\r
+import org.eclipse.jface.viewers.ISelection;\r
+import org.eclipse.ui.handlers.HandlerUtil;\r
+import org.simantics.browsing.ui.common.node.AbstractNode;\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.WriteGraph;\r
+import org.simantics.db.common.request.WriteRequest;\r
+import org.simantics.db.common.utils.NameUtils;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.db.exception.ResourceNotFoundException;\r
+import org.simantics.layer0.Layer0;\r
+import org.simantics.layer0.utils.direct.GraphUtils;\r
+import org.simantics.sysdyn.SysdynResource;\r
+import org.simantics.sysdyn.manager.FunctionUtils;\r
+import org.simantics.ui.SimanticsUI;\r
+import org.simantics.ui.utils.AdaptionUtils;\r
+\r
+public class NewFunctionLibraryHandler extends AbstractHandler {\r
+\r
+ @Override\r
+ public Object execute(ExecutionEvent event) throws ExecutionException {\r
+\r
+ ISelection sel = HandlerUtil.getCurrentSelection(event);\r
+ \r
+ @SuppressWarnings("unchecked")\r
+ AbstractNode<Resource> node = AdaptionUtils.adaptToSingle(sel, AbstractNode.class);\r
+ if (node == null)\r
+ return null;\r
+\r
+ createLibrary(node.data, false);\r
+ return null;\r
+ }\r
+ \r
+ /**\r
+ * Create function library. Shared libraries are created to root, local libraries to the model. \r
+ * Shared libraries can be used in other models in the project.\r
+ * \r
+ * @param model The initial location of the command\r
+ * @param shared Shared libraries are created to root, local libraries to the model.\r
+ */\r
+ protected void createLibrary(final Resource model, final boolean shared) {\r
+ SimanticsUI.getSession().asyncRequest(new WriteRequest() {\r
+\r
+ @Override\r
+ public void perform(WriteGraph g) throws DatabaseException {\r
+ Layer0 l0 = Layer0.getInstance(g);\r
+ SysdynResource sr = SysdynResource.getInstance(g);\r
+\r
+ if(!(g.isInstanceOf(model, sr.SysdynModel) ||\r
+ g.isInstanceOf(model, sr.SysdynModelicaFunctionLibrary) ||\r
+ g.isInstanceOf(model, sr.SharedFunctionOntology)))\r
+ return;\r
+\r
+ Resource root = model;\r
+\r
+ String name = "FunctionLibrary";\r
+ Resource libraryType = sr.SysdynModelicaFunctionLibrary;\r
+ \r
+ if(shared) {\r
+ \r
+ try {\r
+ root = g.getResource("http://SharedOntologies");\r
+ } catch (ResourceNotFoundException e) {\r
+ root = g.getResource("http:/");\r
+ root = GraphUtils.create2(g, l0.Library, \r
+ l0.HasName, "SharedOntologies",\r
+ l0.PartOf, root);\r
+ }\r
+ \r
+ name = "Shared" + name;\r
+ libraryType = sr.SharedFunctionOntology;\r
+ }\r
+\r
+ name = NameUtils.findFreshName(g, name, root, l0.ConsistsOf, "%s%d");\r
+ \r
+ Resource functionLibrary = GraphUtils.create2(g, libraryType,\r
+ l0.HasName, name,\r
+ l0.HasDescription, "",\r
+ l0.PartOf, root);\r
+ \r
+ if(shared)\r
+ g.claim(model, l0.IsLinkedTo, functionLibrary);\r
+\r
+ FunctionUtils.updateFunctionFileForLibrary(g, functionLibrary);\r
+ }\r
+ });\r
+ }\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2010 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.ui.handlers;\r
+\r
+import org.eclipse.core.commands.AbstractHandler;\r
+import org.eclipse.core.commands.ExecutionEvent;\r
+import org.eclipse.core.commands.ExecutionException;\r
+import org.eclipse.jface.viewers.ISelection;\r
+import org.eclipse.ui.handlers.HandlerUtil;\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.WriteGraph;\r
+import org.simantics.db.common.request.WriteRequest;\r
+import org.simantics.db.common.utils.NameUtils;\r
+import org.simantics.db.common.utils.OrderedSetUtils;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.db.layer0.adapter.Template;\r
+import org.simantics.diagram.stubs.DiagramResource;\r
+import org.simantics.layer0.Layer0;\r
+import org.simantics.layer0.utils.direct.GraphUtils;\r
+import org.simantics.modeling.ModelingResources;\r
+import org.simantics.structural.stubs.StructuralResource2;\r
+import org.simantics.sysdyn.SysdynResource;\r
+import org.simantics.sysdyn.ui.browser.nodes.ModulesNode;\r
+import org.simantics.ui.SimanticsUI;\r
+import org.simantics.ui.utils.AdaptionUtils;\r
+import org.simantics.utils.datastructures.ArrayMap;\r
+\r
+public class NewModuleNodeHandler extends AbstractHandler {\r
+\r
+ @Override\r
+ public Object execute(ExecutionEvent event) throws ExecutionException {\r
+ \r
+ ISelection sel = HandlerUtil.getCurrentSelection(event);\r
+ \r
+ ModulesNode node = AdaptionUtils.adaptToSingle(sel, ModulesNode.class);\r
+ if (node == null)\r
+ return null;\r
+\r
+ final Resource model = node.data; \r
+ \r
+ SimanticsUI.getSession().asyncRequest(new WriteRequest() {\r
+ \r
+ @Override\r
+ public void perform(WriteGraph g) throws DatabaseException {\r
+ // Same as in SysdynProject.java. Should use the same code, not copy.\r
+ SysdynResource sr = SysdynResource.getInstance(g);\r
+ Layer0 l0 = Layer0.getInstance(g);\r
+ ModelingResources mr = ModelingResources.getInstance(g);\r
+ StructuralResource2 sr2 = StructuralResource2.getInstance(g);\r
+ DiagramResource dr = DiagramResource.getInstance(g);\r
+ \r
+ String name = NameUtils.findFreshName(g, "ModuleType", model, l0.ConsistsOf, "%s%d");\r
+ \r
+ Resource moduleType = g.newResource();\r
+ g.claimLiteral(moduleType, l0.HasName, name);\r
+ g.claim(moduleType, l0.Inherits, sr.Module);\r
+ g.claim(moduleType, l0.PartOf, model);\r
+ \r
+ Resource configuration = GraphUtils.create2(g, \r
+ sr.Configuration,\r
+ l0.HasName, name + "Configuration",\r
+ l0.PartOf, model);\r
+ \r
+ g.claim(moduleType, sr2.IsDefinedBy , configuration);\r
+ \r
+ Resource diagram = g.newResource();\r
+ g.adapt(sr.ConfigurationDiagramTemplate, Template.class).apply(g,\r
+ ArrayMap\r
+ .keys("", "diagram", "name")\r
+ .values(configuration, diagram, "Diagrammi")\r
+ );\r
+ \r
+ \r
+ // Remove default mapping and add sysdyn mapping\r
+ for(Resource trigger : g.getObjects(diagram, l0.HasTrigger)) {\r
+ if(g.isInstanceOf(trigger, mr.DiagramToCompositeMapping)) {\r
+ g.deny(diagram, l0.HasTrigger, trigger);\r
+ }\r
+ }\r
+ Resource mapping = g.newResource();\r
+ g.claim(mapping, l0.InstanceOf, null, sr.DiagramToCompositeMapping);\r
+ g.claim(diagram, l0.HasTrigger, mapping);\r
+ \r
+ Resource moduleSymbol = g.newResource();\r
+ g.claimLiteral(moduleSymbol, l0.HasName, name + " Symbol");\r
+ g.claimLiteral(moduleSymbol, l0.HasLabel, name);\r
+ g.claim(moduleSymbol, l0.Inherits, sr.ModuleSymbol);\r
+ g.claim(moduleSymbol, mr.SymbolToComponentType, moduleType);\r
+ g.claim(moduleSymbol, l0.PartOf, model);\r
+ \r
+ Resource terminal = g.newResource();\r
+ g.claim(terminal, l0.InstanceOf, sr.SysdynTerminal);\r
+ Resource connectionVariable = g.newResource();\r
+ g.claim(connectionVariable, l0.InstanceOf, sr2.ConnectionVariable);\r
+ g.claim(connectionVariable, sr2.Binds, sr.IsHeadOfTerminal);\r
+ g.claim(connectionVariable, sr2.IsParameterOf, moduleSymbol);\r
+ g.claim(terminal, dr.HasConnectionVariable, connectionVariable);\r
+ \r
+ \r
+ Resource terminal2 = g.newResource();\r
+ g.claim(terminal2, l0.InstanceOf, sr.SysdynTerminal);\r
+ Resource connectionVariable2 = g.newResource();\r
+ g.claim(connectionVariable2, l0.InstanceOf, sr2.ConnectionVariable);\r
+ g.claim(connectionVariable2, sr2.Binds, sr.IsTailOfTerminal);\r
+ g.claim(connectionVariable2, sr2.IsParameterOf, moduleSymbol);\r
+ g.claim(terminal2, dr.HasConnectionVariable, connectionVariable2);\r
+ \r
+ g.claim(moduleSymbol, sr2.IsDefinedBy, OrderedSetUtils.create(g, sr2.Composite, terminal, terminal2));\r
+ \r
+ \r
+ }\r
+ });\r
+ return null;\r
+ }\r
+\r
+\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2011 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.ui.handlers;\r
+\r
+import org.eclipse.core.commands.ExecutionEvent;\r
+import org.eclipse.core.commands.ExecutionException;\r
+import org.eclipse.jface.viewers.ISelection;\r
+import org.eclipse.ui.handlers.HandlerUtil;\r
+import org.simantics.browsing.ui.common.node.AbstractNode;\r
+import org.simantics.db.Resource;\r
+import org.simantics.ui.utils.AdaptionUtils;\r
+\r
+public class NewSharedFunctionLibraryHandler extends NewFunctionLibraryHandler {\r
+\r
+ @Override\r
+ public Object execute(ExecutionEvent event) throws ExecutionException {\r
+\r
+ ISelection sel = HandlerUtil.getCurrentSelection(event);\r
+ \r
+ @SuppressWarnings("unchecked")\r
+ AbstractNode<Resource> node = AdaptionUtils.adaptToSingle(sel, AbstractNode.class);\r
+ if (node == null)\r
+ return null;\r
+\r
+ createLibrary(node.data, true);\r
+ return null;\r
+ }\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2010 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.ui.handlers;\r
+\r
+import org.eclipse.core.commands.AbstractHandler;\r
+import org.eclipse.core.commands.ExecutionEvent;\r
+import org.eclipse.core.commands.ExecutionException;\r
+import org.eclipse.jface.dialogs.MessageDialog;\r
+import org.eclipse.jface.viewers.ISelection;\r
+import org.eclipse.swt.widgets.Shell;\r
+import org.eclipse.ui.handlers.HandlerUtil;\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.WriteGraph;\r
+import org.simantics.db.common.request.WriteRequest;\r
+import org.simantics.db.exception.CancelTransactionException;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.db.layer0.util.RemoverUtil;\r
+import org.simantics.ui.SimanticsUI;\r
+import org.simantics.ui.utils.ResourceAdaptionUtils;\r
+import org.simantics.utils.ui.ExceptionUtils;\r
+\r
+/**\r
+ * @author Tuukka Lehtonen\r
+ */\r
+public class RemoveNodeHandler extends AbstractHandler {\r
+\r
+ @Override\r
+ public Object execute(ExecutionEvent event) throws ExecutionException {\r
+ Shell shell = HandlerUtil.getActiveShellChecked(event);\r
+ ISelection sel = HandlerUtil.getCurrentSelection(event);\r
+ Resource[] resources = ResourceAdaptionUtils.toResources(sel);\r
+ if (resources.length == 0)\r
+ return null;\r
+\r
+ MessageDialog dialog = new MessageDialog(shell, "Remove Item", null, "Are you sure?", 0,\r
+ new String[] { "OK", "Cancel" }, 0);\r
+ dialog.create();\r
+ if (dialog.open() == 0)\r
+ deleteItem(resources);\r
+\r
+ return null;\r
+ }\r
+\r
+ private void deleteItem(final Resource[] resources) {\r
+ try {\r
+ SimanticsUI.getSession().syncRequest(new WriteRequest() {\r
+ @Override\r
+ public void perform(WriteGraph graph) throws DatabaseException, CancelTransactionException {\r
+ for (Resource r : resources)\r
+ RemoverUtil.remove(graph, r);\r
+ }\r
+ });\r
+ } catch (DatabaseException e) {\r
+ ExceptionUtils.logAndShowError(e);\r
+ }\r
+ }\r
+\r
+}
\ No newline at end of file
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2010 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.ui.handlers;\r
+\r
+import org.eclipse.core.commands.AbstractHandler;\r
+import org.eclipse.core.commands.ExecutionEvent;\r
+import org.eclipse.core.commands.ExecutionException;\r
+import org.eclipse.jface.viewers.ISelection;\r
+import org.eclipse.ui.IWorkbenchPart;\r
+import org.eclipse.ui.handlers.HandlerUtil;\r
+import org.simantics.browsing.ui.GraphExplorer;\r
+import org.simantics.browsing.ui.NodeContext;\r
+import org.simantics.browsing.ui.common.ColumnKeys;\r
+import org.simantics.utils.ui.ISelectionUtils;\r
+\r
+public class RenameNodeHandler extends AbstractHandler {\r
+\r
+ @Override\r
+ public Object execute(ExecutionEvent event) throws ExecutionException {\r
+ ISelection sel = HandlerUtil.getCurrentSelection(event);\r
+ NodeContext ctx = ISelectionUtils.filterSingleSelection(sel, NodeContext.class);\r
+ if (ctx == null)\r
+ return null;\r
+\r
+ IWorkbenchPart part = HandlerUtil.getActivePart(event);\r
+ if (part == null)\r
+ return null;\r
+\r
+ GraphExplorer graphExplorer = (GraphExplorer) part.getAdapter(GraphExplorer.class);\r
+ if (graphExplorer != null)\r
+ graphExplorer.startEditing(ctx, ColumnKeys.SINGLE);\r
+\r
+ return null;\r
+ }\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2010 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.ui.handlers;\r
+\r
+\r
+import java.util.Map;\r
+\r
+import org.eclipse.core.commands.AbstractHandler;\r
+import org.eclipse.core.commands.ExecutionEvent;\r
+import org.eclipse.core.commands.ExecutionException;\r
+import org.eclipse.ui.commands.IElementUpdater;\r
+import org.eclipse.ui.menus.UIElement;\r
+import org.simantics.simulation.experiment.ExperimentState;\r
+import org.simantics.simulation.experiment.IDynamicExperiment;\r
+import org.simantics.simulation.experiment.IExperiment;\r
+import org.simantics.simulation.project.IExperimentManager;\r
+import org.simantics.sysdyn.manager.SysdynExperiment;\r
+import org.simantics.ui.SimanticsUI;\r
+\r
+public class RunBasicExperiment extends AbstractHandler implements IElementUpdater {\r
+ \r
+ public static final String COMMAND = "org.simantics.sysdyn.ui.run";\r
+ \r
+ @Override\r
+ public Object execute(ExecutionEvent event) throws ExecutionException {\r
+ IExperimentManager manager = \r
+ SimanticsUI.getProject().getHint(IExperimentManager.KEY_EXPERIMENT_MANAGER);\r
+ IExperiment experiment = manager.getActiveExperiment();\r
+ if(experiment instanceof IDynamicExperiment)\r
+ ((IDynamicExperiment)experiment).simulate(true);\r
+ return null;\r
+ }\r
+\r
+ @SuppressWarnings("rawtypes")\r
+ @Override\r
+ public void updateElement(UIElement element, Map parameters) {\r
+ IExperimentManager manager = \r
+ SimanticsUI.getProject().getHint(IExperimentManager.KEY_EXPERIMENT_MANAGER);\r
+ IExperiment experiment = manager.getActiveExperiment();\r
+ if(experiment instanceof SysdynExperiment) {\r
+ ExperimentState state = experiment.getState();\r
+ if(state == ExperimentState.RUNNING) {\r
+ this.setBaseEnabled(false);\r
+ } else {\r
+ this.setBaseEnabled(true);\r
+ }\r
+ } \r
+ }\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2010 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.ui.handlers;\r
+\r
+import org.eclipse.core.commands.AbstractHandler;\r
+import org.eclipse.core.commands.ExecutionEvent;\r
+import org.eclipse.core.commands.ExecutionException;\r
+import org.simantics.simulation.experiment.IDynamicExperiment;\r
+import org.simantics.simulation.experiment.IExperiment;\r
+import org.simantics.simulation.project.IExperimentManager;\r
+import org.simantics.ui.SimanticsUI;\r
+\r
+public class SaveResultsHandler extends AbstractHandler {\r
+\r
+ @Override\r
+ public Object execute(ExecutionEvent event) throws ExecutionException {\r
+ IExperimentManager manager = \r
+ SimanticsUI.getProject().getHint(IExperimentManager.KEY_EXPERIMENT_MANAGER);\r
+ IExperiment experiment = manager.getActiveExperiment();\r
+ if(experiment instanceof IDynamicExperiment) {\r
+ ((IDynamicExperiment)experiment).saveState();\r
+ }\r
+ return null;\r
+ }\r
+\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2010 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.ui.handlers;\r
+\r
+import org.eclipse.core.commands.AbstractHandler;\r
+import org.eclipse.core.commands.ExecutionEvent;\r
+import org.eclipse.core.commands.ExecutionException;\r
+import org.eclipse.jface.viewers.ISelection;\r
+import org.eclipse.ui.PartInitException;\r
+import org.eclipse.ui.PlatformUI;\r
+import org.eclipse.ui.handlers.HandlerUtil;\r
+import org.simantics.databoard.Bindings;\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.common.request.ReadRequest;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.db.layer0.variable.Variable;\r
+import org.simantics.db.layer0.variable.Variables;\r
+import org.simantics.diagram.stubs.DiagramResource;\r
+import org.simantics.modeling.ComponentUtils;\r
+import org.simantics.modeling.ModelingResources;\r
+import org.simantics.structural.stubs.StructuralResource2;\r
+import org.simantics.sysdyn.SysdynResource;\r
+import org.simantics.sysdyn.ui.editor.DiagramViewer;\r
+import org.simantics.ui.SimanticsUI;\r
+import org.simantics.ui.utils.ResourceAdaptionUtils;\r
+import org.simantics.ui.workbench.ResourceEditorInput2;\r
+import org.simantics.utils.ui.workbench.WorkbenchUtils;\r
+\r
+\r
+public class ShowModuleHandler extends AbstractHandler {\r
+\r
+ private static final String EDITOR_ID = "org.simantics.sysdyn.ui.diagramViewer";\r
+\r
+ @Override\r
+ public Object execute(ExecutionEvent event) throws ExecutionException {\r
+ \r
+ ISelection s = HandlerUtil.getCurrentSelectionChecked(event);\r
+ final Resource resources[] = ResourceAdaptionUtils.toResources(s);\r
+ final DiagramViewer viewer = (DiagramViewer)HandlerUtil.getActiveEditor(event);\r
+ \r
+ SimanticsUI.getSession().asyncRequest(new ReadRequest() {\r
+ \r
+ @Override\r
+ public void run(ReadGraph graph) throws DatabaseException {\r
+\r
+ DiagramResource dr = DiagramResource.getInstance(graph);\r
+ Resource runtime = viewer.getRuntime();\r
+ String uri = graph.getPossibleRelatedValue(runtime, dr.HasVariable, Bindings.STRING);\r
+ Variable parent = Variables.getVariable(graph, uri);\r
+ Resource model = Variables.getModel(graph, parent);\r
+ final String modelURI = graph.getURI(model);\r
+ \r
+ for(Resource element : resources) {\r
+\r
+ ModelingResources mr = ModelingResources.getInstance(graph);\r
+ SysdynResource sr = SysdynResource.getInstance(graph);\r
+ StructuralResource2 st = StructuralResource2.getInstance(graph);\r
+ \r
+ final Resource component = graph.getPossibleObject(element, mr.ElementToComponent);\r
+ final Resource componentType = graph.getPossibleType(component, sr.Module);\r
+ final Resource configuration = graph.getPossibleObject(componentType, st.IsDefinedBy);\r
+ final Resource diagram = ComponentUtils.getPossibleCompositeDiagram(graph, configuration);\r
+\r
+ Variable variable = parent.browsePossible(graph, component);\r
+ final String finalRvi = Variables.getRVI(graph, variable);\r
+ \r
+ PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() {\r
+\r
+ @Override\r
+ public void run() {\r
+ try {\r
+ String editorId = EDITOR_ID;\r
+ WorkbenchUtils.openEditor(editorId, new ResourceEditorInput2(editorId, diagram, modelURI, finalRvi));\r
+ } catch (PartInitException e) {\r
+ e.printStackTrace();\r
+ }\r
+ }\r
+ });\r
+ \r
+ /*\r
+ \r
+ \r
+ final Resource diagram = ComponentUtils.getPossibleCompositeDiagram(graph, configuration);\r
+ \r
+ if(diagram == null) return;\r
+ \r
+ String finalRvi = uri + "/" + graph.getPossibleRelatedValue(component, l0.HasName, Bindings.STRING);\r
+ \r
+ // This is ugly but it has to be done like this because WorkModel example has too PartOfs\r
+ Resource rootLibrary = graph.getPossibleObject(model, l0.PartOf);\r
+ while(!graph.getObjects(rootLibrary, l0.PartOf).isEmpty()) {\r
+ for(Resource possibleLibrary : graph.getObjects(rootLibrary, l0.PartOf)){\r
+ if(graph.isInstanceOf(possibleLibrary, l0.Library)) {\r
+ rootLibrary = possibleLibrary;\r
+ break;\r
+ }\r
+ }\r
+ }\r
+ Variable rootVariable = graph.adapt(rootLibrary, Variable.class);\r
+ \r
+ String moduleUri = modelURI + "/BaseRealization" + finalRvi;\r
+ Variable var = rootVariable.browsePossible(graph, moduleUri.substring(6));\r
+ if(var == null) {\r
+ finalRvi = "";\r
+ }\r
+ final String rvi = finalRvi;\r
+ \r
+ PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() {\r
+\r
+ @Override\r
+ public void run() {\r
+ // for (Triple<Resource, String, String> in : ins) {\r
+ try {\r
+ String editorId = EDITOR_ID;\r
+// System.out.println("Activating diagram: model=" + modelURI + " rvi='" + rvi + "'");\r
+ System.out.println("SHOW MODULE: " + modelURI + ", " + rvi);\r
+ WorkbenchUtils.openEditor(editorId, new ResourceEditorInput2(editorId, diagram, modelURI, rvi));\r
+ } catch (PartInitException e) {\r
+ // TODO Auto-generated catch block\r
+ e.printStackTrace();\r
+ }\r
+ // }\r
+ }\r
+ });\r
+ */\r
+ \r
+ }\r
+ \r
+ }\r
+ });\r
+ \r
+ return null;\r
+ }\r
+ \r
+\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2010 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.ui.handlers;\r
+\r
+import java.util.concurrent.Semaphore;\r
+\r
+import org.eclipse.core.runtime.IProgressMonitor;\r
+import org.eclipse.core.runtime.IStatus;\r
+import org.eclipse.core.runtime.Status;\r
+import org.eclipse.core.runtime.jobs.Job;\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.RequestProcessor;\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.common.utils.NameUtils;\r
+import org.simantics.db.exception.AdaptionException;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.db.request.Read;\r
+import org.simantics.message.MessageService;\r
+import org.simantics.project.IProject;\r
+import org.simantics.simulation.experiment.IExperiment;\r
+import org.simantics.simulation.model.ExperimentLoadingFailed;\r
+import org.simantics.simulation.project.IExperimentActivationListener;\r
+import org.simantics.simulation.project.IExperimentManager;\r
+import org.simantics.sysdyn.ui.listeners.SysdynExperimentManagerListener;\r
+import org.simantics.utils.DataContainer;\r
+import org.simantics.utils.ui.ErrorLogger;\r
+import org.simantics.utils.ui.ExceptionUtils;\r
+import org.simantics.utils.ui.dialogs.ShowMessage;\r
+\r
+public class SysdynExperimentActivator {\r
+ /**\r
+ * @param project\r
+ * @param experimentManager\r
+ * @param experiment\r
+ */\r
+ public static void scheduleActivation(RequestProcessor processor, final IProject project, final IExperimentManager experimentManager, final Resource experiment) {\r
+ String jobName = "Activate Experiment";\r
+ String experimentName = getName(processor, experiment);\r
+ if (experimentName != null)\r
+ jobName += " '" + experimentName + "'";\r
+ /*\r
+ // Shut down the previous active experiment\r
+ IExperiment activeExperiment = experimentManager.getActiveExperiment();\r
+ if (experiment != null)\r
+ activeExperiment.shutdown();\r
+ */\r
+ // Activate a new experiment\r
+ scheduleActivation(jobName, project, experimentManager, experiment);\r
+ }\r
+\r
+ /**\r
+ * @param project\r
+ * @param experimentManager\r
+ * @param experiment\r
+ */\r
+ public static void scheduleActivation(String jobName, final IProject project, final IExperimentManager experimentManager, final Resource experiment) {\r
+ new Job(jobName) {\r
+ @Override\r
+ protected IStatus run(final IProgressMonitor monitor) {\r
+ return SysdynExperimentActivator.activate(monitor, project, experimentManager, experiment);\r
+ }\r
+ }.schedule();\r
+ }\r
+\r
+ public static IStatus activate(IProgressMonitor monitor, IProject project, IExperimentManager experimentManager, Resource experiment) {\r
+ return new SysdynExperimentActivator().activateExperiment(monitor, project, experimentManager, experiment);\r
+ }\r
+\r
+ private static String getName(RequestProcessor processor, final Resource resource) {\r
+ try {\r
+ return processor.syncRequest(new Read<String>() {\r
+ @Override\r
+ public String perform(ReadGraph graph) throws DatabaseException {\r
+ try {\r
+ return graph.adapt(resource, String.class);\r
+ } catch (AdaptionException e) {\r
+ return NameUtils.getSafeName(graph, resource);\r
+ }\r
+ }\r
+ });\r
+ } catch (DatabaseException e) {\r
+ ErrorLogger.defaultLogWarning(e);\r
+ return null;\r
+ }\r
+ }\r
+\r
+ private IStatus activateExperiment(final IProgressMonitor monitor, final IProject project, final IExperimentManager manager, final Resource experimentResource) {\r
+ monitor.beginTask("Activating experiment", IProgressMonitor.UNKNOWN);\r
+ try {\r
+ SysdynExperimentManagerListener.listenManager(manager);\r
+ IExperiment experiment = manager.getActiveExperiment();\r
+ if(experiment != null) {\r
+ experiment.shutdown();\r
+ }\r
+ final Semaphore activated = new Semaphore(0);\r
+ final DataContainer<Throwable> problem = new DataContainer<Throwable>();\r
+ manager.startExperiment(experimentResource, new IExperimentActivationListener() {\r
+\r
+ @Override\r
+ public void onExperimentActivated(final IExperiment experiment) {\r
+ MessageService.defaultLog(new org.eclipse.core.runtime.Status(IStatus.INFO, "org.simantics.simulation.ui", 0, "Activated experiment " + experiment.getIdentifier() , null));\r
+ activated.release();\r
+ }\r
+ @Override\r
+ public void onFailure(Throwable e) {\r
+ problem.set(e);\r
+ activated.release();\r
+ }\r
+ @Override\r
+ public void onMessage(IStatus message) {\r
+ MessageService.getDefault().log(message);\r
+ /*ILogger logger = MessageService.getDefault();\r
+ MultiStatus init = new MultiStatus(Activator.PLUGIN_ID, 0, "Activating experiment", null);\r
+ for (String msg : messages) {\r
+ init.add(new Status(IStatus.INFO, Activator.PLUGIN_ID, msg));\r
+ }\r
+ logger.log(init);*/\r
+ }\r
+ }, true);\r
+ try {\r
+ activated.acquire();\r
+ Throwable t = problem.get();\r
+ if (t != null) {\r
+ if (t instanceof ExperimentLoadingFailed) {\r
+ ErrorLogger.defaultLogError(t);\r
+ ShowMessage.showError("Experiment Activation Failed", t.getMessage());\r
+ } else {\r
+ ExceptionUtils.logAndShowError(t);\r
+ }\r
+ }\r
+\r
+ return Status.OK_STATUS;\r
+ //return new Status(IStatus.ERROR, Activator.PLUGIN_ID, "Experiment activation failed, see exception for details.", problem.get());\r
+ } catch (InterruptedException e) {\r
+ return Status.CANCEL_STATUS;\r
+ }\r
+ } finally {\r
+ monitor.done();\r
+ }\r
+ }\r
+\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2010 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.ui.handlers;\r
+\r
+import org.eclipse.core.commands.AbstractHandler;\r
+import org.eclipse.core.commands.ExecutionEvent;\r
+import org.eclipse.core.commands.ExecutionException;\r
+import org.eclipse.jface.viewers.ISelection;\r
+import org.eclipse.ui.handlers.HandlerUtil;\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.WriteGraph;\r
+import org.simantics.db.common.request.WriteRequest;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.simulation.ontology.SimulationResource;\r
+import org.simantics.sysdyn.SysdynResource;\r
+import org.simantics.ui.SimanticsUI;\r
+import org.simantics.ui.utils.ResourceAdaptionUtils;\r
+\r
+public class ToggleResultActivation extends AbstractHandler {\r
+\r
+ @Override\r
+ public Object execute(ExecutionEvent event) throws ExecutionException {\r
+ ISelection sel = HandlerUtil.getCurrentSelection(event);\r
+ Resource[] resources = ResourceAdaptionUtils.toResources(sel);\r
+ if (resources.length == 0)\r
+ return null;\r
+\r
+ toggleActivation(resources);\r
+\r
+ return null;\r
+ }\r
+\r
+ public static void toggleActivation(final Resource[] resources) {\r
+ try {\r
+ SimanticsUI.getSession().syncRequest(new WriteRequest() {\r
+\r
+ @Override\r
+ public void perform(WriteGraph graph) throws DatabaseException {\r
+ SysdynResource sr = SysdynResource.getInstance(graph);\r
+ SimulationResource SIMU = SimulationResource.getInstance(graph);\r
+ for(Resource r : resources) {\r
+ if(graph.isInstanceOf(r, sr.Result)) {\r
+ if (graph.hasStatement(r, SIMU.IsActive)) {\r
+ graph.denyStatement(r, SIMU.IsActive, r);\r
+ } else {\r
+ graph.claim(r, SIMU.IsActive, r);\r
+ }\r
+ }\r
+ }\r
+ }\r
+\r
+ });\r
+ } catch (DatabaseException e) {\r
+\r
+ }\r
+ }\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2010 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.ui.handlers;\r
+\r
+\r
+import java.util.Map;\r
+\r
+import org.eclipse.core.commands.AbstractHandler;\r
+import org.eclipse.core.commands.Command;\r
+import org.eclipse.core.commands.ExecutionEvent;\r
+import org.eclipse.core.commands.ExecutionException;\r
+import org.eclipse.core.commands.State;\r
+import org.eclipse.ui.PlatformUI;\r
+import org.eclipse.ui.commands.ICommandService;\r
+import org.eclipse.ui.commands.IElementUpdater;\r
+import org.eclipse.ui.menus.UIElement;\r
+import org.simantics.simulation.experiment.IExperiment;\r
+import org.simantics.simulation.project.IExperimentManager;\r
+import org.simantics.sysdyn.manager.SysdynExperiment;\r
+import org.simantics.ui.SimanticsUI;\r
+\r
+public class ToggleSimulation extends AbstractHandler implements IElementUpdater {\r
+\r
+ public static final String COMMAND = "org.simantics.sysdyn.ui.toggleSimulation";\r
+ public static final String STATE = "org.simantics.sysdyn.ui.toggleSimulation.state";\r
+\r
+ @Override\r
+ public Object execute(ExecutionEvent event) throws ExecutionException {\r
+ ICommandService service = (ICommandService) PlatformUI.getWorkbench().getService(ICommandService.class);\r
+ Command command = service.getCommand(COMMAND);\r
+ State state = command.getState(STATE);\r
+ Boolean value = (Boolean) state.getValue();\r
+ value = !value;\r
+ state.setValue(value);\r
+ service.refreshElements(RunBasicExperiment.COMMAND, null);\r
+ \r
+ IExperimentManager manager = \r
+ SimanticsUI.getProject().getHint(IExperimentManager.KEY_EXPERIMENT_MANAGER);\r
+ IExperiment experiment = manager.getActiveExperiment();\r
+ if(experiment instanceof SysdynExperiment) {\r
+ if(getState()) {\r
+ ((SysdynExperiment)experiment).toggleSimulation(true);\r
+ } else {\r
+ ((SysdynExperiment)experiment).toggleSimulation(false);\r
+ }\r
+ }\r
+ \r
+ \r
+ return null;\r
+ }\r
+\r
+ public static Boolean getState() {\r
+ ICommandService service = (ICommandService) PlatformUI.getWorkbench().getService(ICommandService.class);\r
+ Command command = service.getCommand(COMMAND);\r
+ State state = command.getState(STATE);\r
+ return (Boolean)state.getValue();\r
+ }\r
+\r
+ @SuppressWarnings("rawtypes")\r
+ @Override\r
+ public void updateElement(UIElement element, Map parameters) {\r
+ ICommandService commandService =\r
+ (ICommandService) PlatformUI.getWorkbench().getService(ICommandService.class);\r
+ Command command = commandService.getCommand(COMMAND);\r
+ boolean checked = (Boolean) command.getState(STATE).getValue();\r
+ element.setChecked(checked);\r
+ }\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2010 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.ui.handlers;\r
+\r
+import org.eclipse.core.commands.ExecutionEvent;\r
+import org.eclipse.core.commands.ExecutionException;\r
+import org.eclipse.jface.dialogs.MessageDialog;\r
+import org.eclipse.jface.viewers.ISelection;\r
+import org.eclipse.swt.widgets.Shell;\r
+import org.eclipse.ui.handlers.HandlerUtil;\r
+import org.simantics.db.Resource;\r
+import org.simantics.modeling.ui.modelBrowser.handlers.DeleteNodeHandler;\r
+import org.simantics.ui.utils.ResourceAdaptionUtils;\r
+\r
+public class UnlinkNodeHandler2 extends DeleteNodeHandler {\r
+\r
+ @Override\r
+ public Object execute(ExecutionEvent event) throws ExecutionException {\r
+ Shell shell = HandlerUtil.getActiveShellChecked(event);\r
+ ISelection sel = HandlerUtil.getCurrentSelection(event);\r
+ Resource[] resources = ResourceAdaptionUtils.toResources(sel);\r
+ if (resources.length == 0)\r
+ return null;\r
+\r
+ MessageDialog dialog = new MessageDialog(shell, "Remove Item", null, "Are you sure?", 0,\r
+ new String[] { "OK", "Cancel" }, 0);\r
+ dialog.create();\r
+ if (dialog.open() == 0) {\r
+ //TODO: deletenodehandler for all resources\r
+ super.execute(event);\r
+ }\r
+ return null;\r
+ }\r
+ \r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2010 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.ui.listeners;\r
+\r
+import org.eclipse.core.commands.Command;\r
+import org.eclipse.core.commands.State;\r
+import org.eclipse.ui.PlatformUI;\r
+import org.eclipse.ui.commands.ICommandService;\r
+import org.eclipse.ui.contexts.IContextActivation;\r
+import org.simantics.simulation.experiment.ExperimentState;\r
+import org.simantics.simulation.experiment.IExperimentListener;\r
+import org.simantics.sysdyn.ui.handlers.RunBasicExperiment;\r
+import org.simantics.sysdyn.ui.handlers.ToggleSimulation;\r
+\r
+public class SysdynExperimentListener implements IExperimentListener {\r
+\r
+ IContextActivation contextActivation;\r
+\r
+ @Override\r
+ public void stateChanged(final ExperimentState state) {\r
+ PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() {\r
+\r
+ @Override\r
+ public void run() {\r
+ ICommandService commandService =\r
+ (ICommandService) PlatformUI.getWorkbench().getService(ICommandService.class);\r
+ Command command = commandService.getCommand(ToggleSimulation.COMMAND);\r
+ State buttonState = command.getState(ToggleSimulation.STATE);\r
+ \r
+ switch(state) {\r
+ case DISPOSED:\r
+ buttonState.setValue(false); \r
+ break;\r
+ }\r
+ commandService.refreshElements(command.getId(), null); \r
+ commandService.refreshElements(RunBasicExperiment.COMMAND, null);\r
+ }\r
+ \r
+ });\r
+ }\r
+\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2010 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.ui.listeners;\r
+\r
+import java.util.ArrayList;\r
+import java.util.Collection;\r
+import java.util.HashSet;\r
+import java.util.Set;\r
+\r
+import org.eclipse.ui.IWorkbench;\r
+import org.eclipse.ui.PlatformUI;\r
+import org.eclipse.ui.contexts.IContextActivation;\r
+import org.eclipse.ui.contexts.IContextService;\r
+import org.simantics.simulation.experiment.IExperiment;\r
+import org.simantics.simulation.project.IExperimentManager;\r
+import org.simantics.simulation.project.IExperimentManagerListener;\r
+\r
+public class SysdynExperimentManagerListener implements IExperimentManagerListener{\r
+\r
+ public static final String BASIC_EXPERIMENT_CONTEXT = "org.simantics.sysdyn.ui.basicExperiment";\r
+ \r
+ static Set<IExperimentManager> managers = \r
+ new HashSet<IExperimentManager>();\r
+ \r
+ IExperimentManager manager;\r
+ \r
+ Collection<IContextActivation> contextActivations = \r
+ new ArrayList<IContextActivation>();\r
+ \r
+ public SysdynExperimentManagerListener(IExperimentManager manager) {\r
+ this.manager = manager;\r
+ }\r
+\r
+ public static void listenManager(IExperimentManager manager) {\r
+ synchronized(managers) {\r
+ if(managers.contains(manager))\r
+ return;\r
+ SysdynExperimentManagerListener listener = \r
+ new SysdynExperimentManagerListener(manager);\r
+ manager.addListener(listener);\r
+ managers.add(manager);\r
+ }\r
+ }\r
+ \r
+ @Override\r
+ public void activeExperimentLoaded(final IExperiment experiment) { \r
+ experiment.addListener(new SysdynExperimentListener());\r
+\r
+ PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() {\r
+\r
+ @Override\r
+ public void run() {\r
+ IContextService contextService =\r
+ (IContextService)PlatformUI.getWorkbench()\r
+ .getActiveWorkbenchWindow().getService(IContextService.class);\r
+ synchronized(contextActivations) {\r
+ contextActivations.add(contextService.activateContext(BASIC_EXPERIMENT_CONTEXT));\r
+ }\r
+ }\r
+ \r
+ });\r
+ }\r
+\r
+ @Override\r
+ public void activeExperimentUnloaded() {\r
+ \r
+ synchronized(contextActivations) {\r
+ final Collection<IContextActivation> oldContextActivations = \r
+ contextActivations;\r
+ \r
+ contextActivations = new ArrayList<IContextActivation>();\r
+ \r
+ final IWorkbench workbench = PlatformUI.getWorkbench();\r
+ workbench.getDisplay().asyncExec(new Runnable() {\r
+ \r
+ @Override\r
+ public void run() {\r
+ if (workbench.isClosing())\r
+ return;\r
+ \r
+ IContextService contextService =\r
+ (IContextService)workbench.getActiveWorkbenchWindow().getService(IContextService.class);\r
+ contextService.deactivateContexts(oldContextActivations); \r
+ }\r
+ \r
+ });\r
+ }\r
+ \r
+ }\r
+\r
+ @Override\r
+ public void managerDisposed() {\r
+ synchronized(managers) {\r
+ managers.remove(manager);\r
+ }\r
+ }\r
+\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2010 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.ui.modelica;\r
+\r
+import java.util.HashSet;\r
+import java.util.Set;\r
+\r
+import org.eclipse.jface.text.IDocument;\r
+import org.eclipse.jface.text.TextAttribute;\r
+import org.eclipse.jface.text.presentation.IPresentationReconciler;\r
+import org.eclipse.jface.text.presentation.PresentationReconciler;\r
+import org.eclipse.jface.text.rules.DefaultDamagerRepairer;\r
+import org.eclipse.jface.text.rules.ICharacterScanner;\r
+import org.eclipse.jface.text.rules.IRule;\r
+import org.eclipse.jface.text.rules.IToken;\r
+import org.eclipse.jface.text.rules.RuleBasedScanner;\r
+import org.eclipse.jface.text.rules.Token;\r
+import org.eclipse.jface.text.source.ISourceViewer;\r
+import org.eclipse.jface.text.source.SourceViewerConfiguration;\r
+import org.eclipse.swt.SWT;\r
+import org.eclipse.swt.graphics.Color;\r
+\r
+public class ModelicaSourceViewerConfiguration extends SourceViewerConfiguration {\r
+\r
+ public IPresentationReconciler getPresentationReconciler(\r
+ ISourceViewer sourceViewer) {\r
+ PresentationReconciler pr = new PresentationReconciler();\r
+ DefaultDamagerRepairer ddr = new DefaultDamagerRepairer(\r
+ new RuleBasedScanner() { \r
+ {\r
+ setRules(new IRule[] {new IRule() {\r
+\r
+ @Override\r
+ public IToken evaluate(ICharacterScanner scanner) {\r
+ int ch;\r
+ try {\r
+ scanner.unread();\r
+ ch = scanner.read();\r
+ } catch (Throwable t) {\r
+ ch = -1;\r
+ }\r
+ if (ch <= 0 || !isIdentifierChar((char) ch)) {\r
+ ch = scanner.read();\r
+ if(isIdentifierChar((char)ch)) {\r
+ StringBuilder b = new StringBuilder();\r
+ do {\r
+ b.append((char)ch);\r
+ ch = scanner.read();\r
+ } while(isIdentifierChar((char) ch));\r
+ String str = b.toString();\r
+ if(keywords.contains(str))\r
+ return getModelicaKeywordToken();\r
+ }\r
+ scanner.unread();\r
+ }\r
+ return Token.UNDEFINED;\r
+ } \r
+ \r
+ }});\r
+ } \r
+ }\r
+ );\r
+ pr.setRepairer(ddr, IDocument.DEFAULT_CONTENT_TYPE);\r
+ pr.setDamager(ddr, IDocument.DEFAULT_CONTENT_TYPE);\r
+ return pr;\r
+ }\r
+ \r
+ static boolean isIdentifierChar(char c) {\r
+ return \r
+ (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') \r
+ || (c >= '0' && c <= '9') || c == '_';\r
+ }\r
+ \r
+ static final Set<String> keywords = new HashSet<String>();\r
+ \r
+ static {\r
+ keywords.add("within");\r
+ keywords.add("final");\r
+ keywords.add("public");\r
+ keywords.add("protected");\r
+ keywords.add("connect");\r
+ keywords.add("when");\r
+ keywords.add("then");\r
+ keywords.add("elsewhen");\r
+ keywords.add("if");\r
+ keywords.add("end");\r
+ keywords.add("elseif");\r
+ keywords.add("else");\r
+ keywords.add("for");\r
+ keywords.add("while");\r
+ keywords.add("loop");\r
+ keywords.add("der");\r
+ keywords.add("enumeration");\r
+ keywords.add("extends");\r
+ keywords.add("class");\r
+ keywords.add("partial");\r
+ keywords.add("encapsulated");\r
+ keywords.add("model");\r
+ keywords.add("record");\r
+ keywords.add("block");\r
+ keywords.add("expandable");\r
+ keywords.add("connector");\r
+ keywords.add("type");\r
+ keywords.add("package");\r
+ keywords.add("function");\r
+ keywords.add("import");\r
+ keywords.add("external");\r
+ keywords.add("constrainedby");\r
+ keywords.add("redeclare");\r
+ keywords.add("replaceable");\r
+ keywords.add("flow");\r
+ keywords.add("discrete");\r
+ keywords.add("parameter");\r
+ keywords.add("constant");\r
+ keywords.add("input");\r
+ keywords.add("output");\r
+ keywords.add("annotation");\r
+ keywords.add("false");\r
+ keywords.add("true");\r
+ keywords.add("each");\r
+ keywords.add("initial");\r
+ keywords.add("algorithm");\r
+ keywords.add("equation");\r
+ keywords.add("or");\r
+ keywords.add("and");\r
+ keywords.add("not");\r
+ keywords.add("break");\r
+ keywords.add("return"); \r
+ }\r
+\r
+ static IToken modelicaKeywordToken = null;\r
+ public IToken getModelicaKeywordToken() {\r
+ if(modelicaKeywordToken == null) {\r
+ modelicaKeywordToken = \r
+ new Token(\r
+ new TextAttribute(\r
+ new Color(null, 127, 0, 85),\r
+ new Color(null, 255, 255, 255),\r
+ SWT.BOLD\r
+ ));\r
+ }\r
+ return modelicaKeywordToken;\r
+ }\r
+ \r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2010 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.ui.modelica;\r
+\r
+import org.eclipse.core.runtime.CoreException;\r
+import org.eclipse.core.runtime.IProgressMonitor;\r
+import org.eclipse.jface.operation.IRunnableContext;\r
+import org.eclipse.jface.text.Document;\r
+import org.eclipse.jface.text.IDocument;\r
+import org.eclipse.jface.text.PaintManager;\r
+import org.eclipse.jface.text.source.AnnotationModel;\r
+import org.eclipse.jface.text.source.AnnotationPainter;\r
+import org.eclipse.jface.text.source.DefaultCharacterPairMatcher;\r
+import org.eclipse.jface.text.source.IAnnotationModel;\r
+import org.eclipse.jface.text.source.MatchingCharacterPainter;\r
+import org.eclipse.swt.graphics.Color;\r
+import org.eclipse.swt.graphics.RGB;\r
+import org.eclipse.swt.widgets.Display;\r
+import org.eclipse.ui.PlatformUI;\r
+import org.eclipse.ui.editors.text.TextEditor;\r
+import org.eclipse.ui.texteditor.AbstractDocumentProvider;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.sysdyn.modelica.ModelicaWriter;\r
+import org.simantics.sysdyn.representation.Configuration;\r
+import org.simantics.sysdyn.representation.LoadRepresentation;\r
+import org.simantics.ui.SimanticsUI;\r
+import org.simantics.ui.workbench.ResourceEditorInput;\r
+\r
+\r
+public class SysdynModelicaEditor extends TextEditor {\r
+\r
+ AnnotationModel annotationModel = new AnnotationModel();\r
+ AnnotationPainter apainter;\r
+ \r
+ public SysdynModelicaEditor() {\r
+ super();\r
+ showOverviewRuler();\r
+ setDocumentProvider(new AbstractDocumentProvider() {\r
+\r
+ @Override\r
+ protected IAnnotationModel createAnnotationModel(Object element)\r
+ throws CoreException {\r
+ return annotationModel;\r
+ }\r
+\r
+ @Override\r
+ protected IDocument createDocument(Object element)\r
+ throws CoreException {\r
+ try {\r
+ Configuration configuration =\r
+ LoadRepresentation.loadConfiguration(SimanticsUI.getSession(), ((ResourceEditorInput)element).getResource());\r
+ ModelicaWriter writer = new ModelicaWriter();\r
+ writer.write(configuration);\r
+ \r
+ return new Document(writer.toString());\r
+ } catch (DatabaseException e) {\r
+ e.printStackTrace();\r
+ throw new CoreException(STATUS_ERROR);\r
+ } \r
+ }\r
+\r
+ @Override\r
+ protected void doSaveDocument(IProgressMonitor monitor,\r
+ Object element, IDocument document, boolean overwrite)\r
+ throws CoreException {\r
+ }\r
+\r
+ @Override\r
+ protected IRunnableContext getOperationRunner(\r
+ IProgressMonitor monitor) {\r
+ return PlatformUI.getWorkbench().getActiveWorkbenchWindow();\r
+ }\r
+ \r
+ @Override\r
+ public boolean isModifiable(Object element) {\r
+ return false;\r
+ }\r
+ \r
+ @Override\r
+ public boolean isReadOnly(Object element) {\r
+ return true;\r
+ }\r
+ \r
+ }); \r
+ \r
+ setSourceViewerConfiguration(new ModelicaSourceViewerConfiguration());\r
+ \r
+ }\r
+ \r
+ @Override\r
+ protected void createActions() {\r
+ super.createActions();\r
+ \r
+ PaintManager paintManager = new PaintManager(getSourceViewer());\r
+ MatchingCharacterPainter matchingCharacterPainter = new MatchingCharacterPainter(getSourceViewer(),\r
+ new DefaultCharacterPairMatcher( new char[] {'(', ')', '{', '}', '[', ']'} ));\r
+ matchingCharacterPainter.setColor(new Color(Display.getCurrent(), new RGB(160, 160, 160)));\r
+ paintManager.addPainter(matchingCharacterPainter);\r
+ }\r
+ \r
+ \r
+}\r
+\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2010 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.ui.modelica;\r
+\r
+import org.eclipse.ui.part.EditorActionBarContributor;\r
+\r
+public class TextEditorActionBarContributor extends EditorActionBarContributor {\r
+\r
+ public TextEditorActionBarContributor() {\r
+ // TODO Auto-generated constructor stub\r
+ }\r
+\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2010 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.ui.project;\r
+\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.Session;\r
+import org.simantics.db.VirtualGraphContext;\r
+import org.simantics.db.WriteGraph;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.db.layer0.realization.RealizationVirtualGraph;\r
+import org.simantics.db.layer0.realization.ResourceData;\r
+import org.simantics.simulation.ontology.SimulationResource;\r
+import org.simantics.sysdyn.SysdynResource;\r
+\r
+public class DefaultRealizationVirtualGraph extends RealizationVirtualGraph {\r
+\r
+ public DefaultRealizationVirtualGraph(Session session, Resource model) throws DatabaseException {\r
+ super(session, model, SysdynResource.getInstance(session).DefaultRealization);\r
+ }\r
+ \r
+ @Override\r
+ public void initialize(final VirtualGraphContext context, WriteGraph graph) throws DatabaseException {\r
+ \r
+ Resource configuration = graph.getSingleObject(model, SimulationResource.getInstance(graph).HasConfiguration);\r
+\r
+ Resource defaultsResource = graph.newResource();\r
+ int modelNode = context.getIndex(model);\r
+ int defaultsNode = context.getIndex(defaultsResource);\r
+ graph.claim(model, L0.ConsistsOf, null, defaultsResource);\r
+ graph.claim(model, L0.HasBaseRealization, null, defaultsResource);\r
+ \r
+// undiscovered.put(defaultsNode, new ResourceData(modelNode, configuration, L0.Realization, "BaseRealization", null, null));\r
+ \r
+ }\r
+ \r
+\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2010 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.ui.project;\r
+\r
+import java.util.List;\r
+\r
+import org.simantics.databoard.Bindings;\r
+import org.simantics.databoard.Datatypes;\r
+import org.simantics.databoard.binding.Binding;\r
+import org.simantics.databoard.type.Datatype;\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.WriteGraph;\r
+import org.simantics.db.common.utils.OrderedSetUtils;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.db.layer0.variable.ResourceVariable;\r
+import org.simantics.layer0.Layer0;\r
+import org.simantics.sysdyn.SysdynResource;\r
+\r
+public class DefaultVariable extends ResourceVariable {\r
+\r
+ public DefaultVariable(Resource resource) {\r
+ super(resource);\r
+ }\r
+\r
+ @SuppressWarnings("unchecked")\r
+ @Override\r
+ public <T> T getValue(ReadGraph graph) throws DatabaseException {\r
+ Layer0 b = Layer0.getInstance(graph);\r
+ SysdynResource sr = SysdynResource.getInstance(graph);\r
+ Resource represents = graph.getPossibleObject(resource, b.Represents);\r
+ if(represents == null) return null;\r
+ //FIXME: doesn't support multiple expressions\r
+ Resource expressions = graph.getPossibleObject(represents, sr.HasExpressions);\r
+ if(expressions == null) return null;\r
+ List<Resource> expressionList = OrderedSetUtils.toList(graph, expressions);\r
+ Resource expression = expressionList.get(0);\r
+ if(expression == null) return null;\r
+ if(!graph.isInstanceOf(expression, sr.ParameterExpression)) return null;\r
+ String text = graph.getPossibleRelatedValue(expression, sr.HasEquation);\r
+ if(text == null) return null;\r
+ Double value = Double.parseDouble(text); \r
+ return (T)value;\r
+ }\r
+\r
+ @Override\r
+ public <T> T getValue(ReadGraph graph, Binding binding) throws DatabaseException {\r
+ if(!Bindings.DOUBLE.equals(binding)) return null;\r
+ return getValue(graph);\r
+ }\r
+ \r
+ @Override\r
+ public void setValue(WriteGraph graph, Object object, Binding binding) throws DatabaseException {\r
+ Layer0 l0 = Layer0.getInstance(graph);\r
+ SysdynResource sr = SysdynResource.getInstance(graph);\r
+// if(!Bindings.DOUBLE.equals(binding)) return;\r
+// if(!MutableDoubleBinding.INSTANCE.equals(binding)) return;\r
+ Resource represents = graph.getPossibleObject(resource, l0.Represents);\r
+ if(represents == null) return;\r
+ //FIXME: doesn't support multiple expressions\r
+ Resource expressions = graph.getPossibleObject(represents, sr.HasExpressions);\r
+ if(expressions == null) return;\r
+ List<Resource> expressionList = OrderedSetUtils.toList(graph, expressions);\r
+ Resource expression = expressionList.get(0);\r
+ if(expression == null) return;\r
+ if(!graph.isInstanceOf(expression, sr.ParameterExpression)) return;\r
+ graph.claimLiteral(expression, sr.HasEquation, object.toString(), Bindings.STRING);\r
+ }\r
+ \r
+ @SuppressWarnings("unchecked")\r
+ @Override\r
+ public <T> T getInterface(ReadGraph graph, Class<T> clazz)\r
+ throws DatabaseException {\r
+ if(Datatype.class.equals(clazz)) return (T)Datatypes.DOUBLE;\r
+ return super.getInterface(graph, clazz);\r
+ }\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2010 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.ui.project;\r
+\r
+import java.util.Collection;\r
+import java.util.HashSet;\r
+\r
+import org.simantics.databoard.Bindings;\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.Session;\r
+import org.simantics.db.VirtualGraph;\r
+import org.simantics.db.VirtualGraphContext;\r
+import org.simantics.db.WriteGraph;\r
+import org.simantics.db.common.procedure.single.SingleSetSyncListener;\r
+import org.simantics.db.common.request.WriteRequest;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.db.layer0.adapter.RuntimeValuations;\r
+import org.simantics.db.layer0.realization.RealizationVirtualGraph;\r
+import org.simantics.db.layer0.realization.ResourceData;\r
+import org.simantics.db.layer0.util.RemoverUtil;\r
+import org.simantics.db.request.Read;\r
+import org.simantics.layer0.Layer0;\r
+import org.simantics.simulation.ontology.SimulationResource;\r
+import org.simantics.sysdyn.SysdynResource;\r
+import org.simantics.utils.datastructures.Pair;\r
+\r
+public class HistoryRealizationVirtualGraph extends RealizationVirtualGraph {\r
+\r
+ public HistoryRealizationVirtualGraph(Session session, Resource model) throws DatabaseException {\r
+ super(session, model, SysdynResource.getInstance(session).HistoryRealization);\r
+ }\r
+\r
+ @Override\r
+ public void initialize(final VirtualGraphContext context, WriteGraph graph) throws DatabaseException {\r
+\r
+ graph.asyncRequest(new Read<Collection<Resource>>() {\r
+\r
+ @Override\r
+ public Collection<Resource> perform(ReadGraph graph) throws DatabaseException {\r
+// System.out.println("Compute runs starts");\r
+ HashSet<Resource> result = new HashSet<Resource>();\r
+ Layer0 l0 = Layer0.getInstance(graph);\r
+ SimulationResource SIMU = SimulationResource.getInstance(graph);\r
+ for(Resource config : graph.getObjects(model, l0.ConsistsOf)) {\r
+ if(graph.isInstanceOf(config, SIMU.Experiment)) {\r
+ for(Resource run : graph.getObjects(config, l0.ConsistsOf)) {\r
+ if(graph.isInstanceOf(run, SIMU.Run)) {\r
+ result.add(run);\r
+ }\r
+ }\r
+ }\r
+ }\r
+ return result;\r
+ }\r
+\r
+ }, new SingleSetSyncListener<Resource>() {\r
+\r
+ @Override\r
+ public void add(ReadGraph graph, final Resource run) throws DatabaseException {\r
+\r
+ final Layer0 l0 = Layer0.getInstance(graph);\r
+ final String experimentName = graph.getPossibleRelatedValue(run, l0.HasName, Bindings.STRING);\r
+\r
+ RuntimeValuations vs = graph.getService(RuntimeValuations.class);\r
+ if(vs.supports(experimentName)) {\r
+\r
+ graph.asyncRequest(new Read<Collection<Pair<String, Resource>>>() {\r
+\r
+ @Override\r
+ public Collection<Pair<String, Resource>> perform(ReadGraph graph) throws DatabaseException {\r
+ HashSet<Pair<String, Resource>> result = new HashSet<Pair<String, Resource>>();\r
+ Resource configuration = graph.getPossibleObject(model, SimulationResource.getInstance(graph).HasConfiguration);\r
+ for(Resource part : graph.getObjects(configuration, l0.ConsistsOf)) {\r
+ String partName = graph.getPossibleRelatedValue(part, l0.HasName, Bindings.STRING);\r
+ result.add(new Pair<String, Resource>(partName, part));\r
+ }\r
+ return result;\r
+ }\r
+ }, new SingleSetSyncListener<Pair<String, Resource>>() {\r
+\r
+ @Override\r
+ public void add(ReadGraph graph, final Pair<String, Resource> part) throws DatabaseException {\r
+ graph.getSession().asyncRequest(new WriteRequest(graph.getService(VirtualGraph.class)) {\r
+ @Override\r
+ public void perform(WriteGraph graph) throws DatabaseException {\r
+ int runNode = context.getIndex(run);\r
+ if(part.first != null) {\r
+ Resource partResource = graph.newResource();\r
+ int partNode = context.getIndex(partResource);\r
+ graph.claim(run, l0.ConsistsOf, null, partResource);\r
+// undiscovered.put(partNode, new ResourceData(runNode, part.second, valuation, part.first, experimentName, null));\r
+ }\r
+ }\r
+ });\r
+ }\r
+\r
+ @Override\r
+ public void remove(ReadGraph graph, final Pair<String, Resource> part) throws DatabaseException {\r
+ graph.getSession().asyncRequest(new WriteRequest(graph.getService(VirtualGraph.class)) {\r
+ @Override\r
+ public void perform(WriteGraph graph) throws DatabaseException {\r
+ Integer key = null;\r
+ for(int k : undiscovered.keySet()) {\r
+ ResourceData rd = undiscovered.get(k);\r
+// if (rd.name.equals(part.first) && rd.structureResource.equals(part.second)) {\r
+// key = k;\r
+// break;\r
+// }\r
+ }\r
+ if(key != null) {\r
+ Resource r = context.getResource(key);\r
+ RemoverUtil.remove(graph, r);\r
+ undiscovered.remove(key);\r
+ }\r
+ }\r
+ });\r
+ }\r
+\r
+ @Override\r
+ public boolean isDisposed() {\r
+ return false;\r
+ }\r
+\r
+ });\r
+ \r
+ }\r
+\r
+ }\r
+\r
+ @Override\r
+ public void exception(ReadGraph graph, Throwable throwable) {\r
+ throwable.printStackTrace();\r
+ }\r
+\r
+ @Override\r
+ public boolean isDisposed() {\r
+ return false;\r
+ }\r
+\r
+ });\r
+\r
+\r
+ }\r
+\r
+\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2010 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.ui.project;\r
+\r
+import java.util.ArrayList;\r
+\r
+import org.simantics.databoard.Accessors;\r
+import org.simantics.databoard.Bindings;\r
+import org.simantics.databoard.accessor.Accessor;\r
+import org.simantics.databoard.accessor.RecordAccessor;\r
+import org.simantics.databoard.accessor.error.AccessorConstructionException;\r
+import org.simantics.databoard.accessor.error.AccessorException;\r
+import org.simantics.databoard.binding.error.RuntimeBindingConstructionException;\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.db.layer0.variable.ResourceVariable;\r
+import org.simantics.db.layer0.variable.Variables;\r
+import org.simantics.simulation.ontology.SimulationResource;\r
+import org.simantics.sysdyn.manager.SysdynDataSet;\r
+import org.simantics.sysdyn.manager.SysdynModel;\r
+import org.simantics.sysdyn.manager.SysdynModelManager;\r
+import org.simantics.sysdyn.manager.SysdynResult;\r
+\r
+public class HistoryVariable extends ResourceVariable {\r
+\r
+ public HistoryVariable(Resource resource) {\r
+ super(resource);\r
+ }\r
+ \r
+// @Override\r
+// public <T> T getInterface(ReadGraph graph, Class<T> clazz) throws DatabaseException {\r
+// if(Accessor.class.equals(clazz)) {\r
+//\r
+// SimulationResource SIMU = SimulationResource.getInstance(graph);\r
+// Resource model = Variables.getModel(graph, this);\r
+// Resource configuration = graph.getPossibleObject(model, SIMU.HasConfiguration);\r
+// SysdynModel sm = SysdynModelManager.getInstance(graph.getSession()).getModel(graph, configuration);\r
+// SysdynResult sr = sm.getSysdynResult();\r
+// String rvi = Variables.getRVI(graph, this);\r
+// System.out.println("HistoryVariable rvi='" + rvi + "'");\r
+// rvi = rvi.substring(1).replace("/", ".");\r
+// SysdynDataSet ds = sr.getDataSet(rvi);\r
+// \r
+// try {\r
+// return (T)Accessors.getAccessor(Bindings.getBindingUnchecked(SysdynDataSet.class), ds);\r
+// } catch (RuntimeBindingConstructionException e) {\r
+// e.printStackTrace();\r
+// } catch (AccessorConstructionException e) {\r
+// e.printStackTrace();\r
+// }\r
+// return null;\r
+// \r
+// }\r
+// return super.getInterface(graph, clazz);\r
+// }\r
+ \r
+ @SuppressWarnings("unchecked")\r
+ @Override\r
+ public <T> T getInterface(ReadGraph graph, Class<T> clazz) throws DatabaseException {\r
+ if(RecordAccessor.class.equals(clazz) || Accessor.class.equals(clazz)) {\r
+ SimulationResource SIMU = SimulationResource.getInstance(graph);\r
+ Resource model = Variables.getModel(graph, this);\r
+ Resource configuration = graph.getPossibleObject(model, SIMU.HasConfiguration);\r
+ final SysdynModel sm = SysdynModelManager.getInstance(graph.getSession()).getModel(graph, configuration);\r
+ SysdynResult sr = new SysdynResult(sm.getSimulationResult()); // TODO: copy or not to copy ...\r
+ \r
+ String tmp = Variables.getRVI(graph, this);\r
+ System.out.println("HistoryVariable rvi='" + tmp + "'");\r
+ final String rvi = tmp.substring(1).replace("/", ".");\r
+ SysdynDataSet ds = sr.getDataSet(rvi);\r
+ if(ds == null) ds = new SysdynDataSet("", "", new ArrayList<Double>(), new ArrayList<Double>()); // We need a dataset, so if not set, create it\r
+ try {\r
+ final RecordAccessor ac = (RecordAccessor)Accessors.getAccessor(Bindings.getBindingUnchecked(SysdynDataSet.class), ds);\r
+ \r
+ sm.addResultListener(new Runnable() { // FIXME: remove listener at some point..\r
+ @Override\r
+ public void run() {\r
+ SysdynResult sr = new SysdynResult(sm.getSimulationResult());\r
+ SysdynDataSet ds = sr.getDataSet(rvi);\r
+ if(ds == null) return;\r
+ try {\r
+ if(ds.result == null) ds.result = "";\r
+ ac.setValue(Bindings.getBindingUnchecked(SysdynDataSet.class), ds);\r
+ } catch (RuntimeBindingConstructionException e) {\r
+ // TODO Auto-generated catch block\r
+ e.printStackTrace();\r
+ } catch (AccessorException e) {\r
+ // TODO Auto-generated catch block\r
+ e.printStackTrace();\r
+ }\r
+ }});\r
+ return (T)ac;\r
+ } catch (RuntimeBindingConstructionException e) {\r
+ e.printStackTrace();\r
+ } catch (AccessorConstructionException e) {\r
+ e.printStackTrace();\r
+ }\r
+ return null;\r
+ \r
+ }\r
+ return super.getInterface(graph, clazz);\r
+ }\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2010 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.ui.project;\r
+\r
+import org.eclipse.ui.IPageLayout;\r
+import org.eclipse.ui.IPerspectiveFactory;\r
+\r
+public class SysdynPerspectiveFactory implements IPerspectiveFactory {\r
+\r
+ @Override\r
+ public void createInitialLayout(IPageLayout layout) {\r
+ layout.setEditorAreaVisible(true);\r
+ }\r
+\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2010 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.ui.project;\r
+\r
+import java.io.File;\r
+import java.util.HashMap;\r
+\r
+import org.eclipse.core.runtime.Platform;\r
+import org.eclipse.core.runtime.preferences.IEclipsePreferences;\r
+import org.eclipse.core.runtime.preferences.InstanceScope;\r
+import org.eclipse.swt.widgets.Shell;\r
+import org.eclipse.ui.PartInitException;\r
+import org.osgi.service.prefs.BackingStoreException;\r
+import org.simantics.databoard.Bindings;\r
+import org.simantics.databoard.accessor.Accessor;\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.Session;\r
+import org.simantics.db.WriteGraph;\r
+import org.simantics.db.common.request.Queries;\r
+import org.simantics.db.common.request.WriteRequest;\r
+import org.simantics.db.common.utils.NameUtils;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.db.layer0.adapter.RuntimeValuations;\r
+import org.simantics.db.layer0.adapter.Template;\r
+import org.simantics.db.layer0.adapter.TrendVariable;\r
+import org.simantics.db.layer0.service.ActivationManager;\r
+import org.simantics.db.request.Read;\r
+import org.simantics.db.service.GraphChangeListenerSupport;\r
+import org.simantics.db.service.LifecycleSupport;\r
+import org.simantics.db.service.VirtualGraphSupport;\r
+import org.simantics.layer0.Layer0;\r
+import org.simantics.layer0.utils.direct.GraphUtils;\r
+import org.simantics.modeling.ModelingResources;\r
+import org.simantics.modeling.ModelingUtils;\r
+import org.simantics.modeling.services.CaseInsensitiveComponentNamingStrategy2;\r
+import org.simantics.modeling.services.ComponentNamingStrategy;\r
+import org.simantics.modeling.ui.features.EditorNamingService2;\r
+import org.simantics.project.IProject;\r
+import org.simantics.project.ProjectElementType;\r
+import org.simantics.project.ProjectElements;\r
+import org.simantics.project.ProjectKeys;\r
+import org.simantics.project.exception.ProjectException;\r
+import org.simantics.project.features.AbstractProjectFeature;\r
+import org.simantics.project.ontology.ProjectResource;\r
+import org.simantics.simulation.experiment.IExperiment;\r
+import org.simantics.simulation.ontology.SimulationResource;\r
+import org.simantics.simulation.project.IExperimentManager;\r
+import org.simantics.sysdyn.SysdynResource;\r
+import org.simantics.sysdyn.ui.Activator;\r
+import org.simantics.ui.SimanticsUI;\r
+import org.simantics.ui.workbench.IEditorNamingService;\r
+import org.simantics.ui.workbench.action.ChooseActionRequest;\r
+import org.simantics.ui.workbench.project.UIModelManager;\r
+import org.simantics.ui.workbench.project.UIModelManagerBase;\r
+import org.simantics.ui.workbench.project.UIModelManagerBase.WriteRunnable;\r
+import org.simantics.utils.datastructures.ArrayMap;\r
+import org.simantics.utils.datastructures.Callback;\r
+import org.simantics.utils.ui.ErrorLogger;\r
+import org.simantics.utils.ui.workbench.WorkbenchUtils;\r
+\r
+public class SysdynProject extends AbstractProjectFeature {\r
+ private static final String DEFAULT_PERSPECTIVE = "org.simantics.sysdyn.ui.perspective";\r
+\r
+ private static final String FIRST_SYSDYN_PROJECT = "firstSysdynProject";\r
+\r
+ class ModelManager extends UIModelManagerBase {\r
+ @Override\r
+ public void create(ProjectElementType kind, Shell parentShell, Session session, Resource container,\r
+ Callback<Resource> callback, Callback<Throwable> errorCallback) {\r
+\r
+ if (ProjectElements.MODEL.equals(kind)) {\r
+ request(session, container, callback, errorCallback, CREATE_MODEL);\r
+ return;\r
+ }\r
+\r
+ super.create(kind, parentShell, session, container, callback, errorCallback);\r
+ }\r
+\r
+ /**\r
+ * \r
+ * \r
+ * @see org.simantics.ui.workbench.project.UIModelManager#openEditor(org.simantics.db.Session, java.lang.String)\r
+ */\r
+ @Override\r
+ public void openEditor(Session session, String uri) throws PartInitException {\r
+ try {\r
+ Resource resource = session.syncRequest(Queries.resource(uri));\r
+ session.syncRequest(new ChooseActionRequest(null, resource, WorkbenchUtils.getCurrentPerspectiveId()));\r
+ } catch (DatabaseException e) {\r
+ LifecycleSupport ls = session.getService(LifecycleSupport.class);\r
+ throw new PartInitException("Failed to open editor for URI '" + uri + "' with session '" + ls.getSessionReference() + "', see exception for details.", e);\r
+ }\r
+ }\r
+ }\r
+\r
+ private final WriteRunnable CREATE_MODEL = new WriteRunnable() {\r
+ @Override\r
+ public void run(WriteGraph g, Resource library, Callback<Resource> callback, Callback<Throwable> errorCallback) {\r
+ try {\r
+ Layer0 l0 = Layer0.getInstance(g);\r
+ SysdynResource sr = SysdynResource.getInstance(g);\r
+ ModelingUtils mu = new ModelingUtils(g);\r
+\r
+ String modelName = NameUtils.findFreshName(g, "Model", SimanticsUI.getProject().get(), l0.ConsistsOf, "%s%d");\r
+\r
+ Resource model = g.newResource();\r
+ g.claimLiteral(model, l0.HasName, modelName);\r
+ g.claimLiteral(model, l0.HasLabel, modelName);\r
+ g.claim(model, l0.InstanceOf, sr.SysdynModel);\r
+ g.claim(model, l0.PartOf, SimanticsUI.getProject().get());\r
+\r
+ Resource conf = GraphUtils.create2(g,\r
+ sr.Configuration,\r
+ l0.PartOf, model,\r
+ l0.IsBaseRealizationOf, model,\r
+ l0.HasName, modelName\r
+ );\r
+ \r
+ Resource diagram = g.newResource();\r
+ g.adapt(sr.ConfigurationDiagramTemplate, Template.class).apply(g,\r
+ ArrayMap\r
+ .keys("", "diagram", "name")\r
+ .values(conf, diagram, "Diagrammi")\r
+ );\r
+\r
+ g.claim(model, mu.SIMU.HasConfiguration, conf);\r
+\r
+ ModelingResources mr = ModelingResources.getInstance(g);\r
+ // Remove default mapping and add sysdyn mapping\r
+ for(Resource trigger : g.getObjects(diagram, l0.HasTrigger)) {\r
+ if(g.isInstanceOf(trigger, mr.DiagramToCompositeMapping)) {\r
+ g.deny(diagram, l0.HasTrigger, trigger);\r
+ }\r
+ }\r
+ Resource mapping = g.newResource();\r
+ g.claim(mapping, l0.InstanceOf, null, sr.DiagramToCompositeMapping);\r
+ g.claim(diagram, l0.HasTrigger, mapping);\r
+\r
+ Resource report = GraphUtils.create2(g, l0.Report, l0.HasDocumentation, "===Report===");\r
+\r
+ GraphUtils.create2(g, mu.SIMU.Experiment,\r
+ l0.HasName, "Experiment",\r
+ l0.HasLabel, "Experiment",\r
+ l0.HasReportFactory, report,\r
+ l0.PartOf, model);\r
+\r
+ ProjectResource PROJ = ProjectResource.getInstance(g);\r
+ for(Resource dep : g.getObjects(library, l0.IsLinkedTo)) {\r
+ if(g.isInstanceOf(dep, PROJ.NamespaceRequirement)) {\r
+ for(Resource req : g.getObjects(dep, PROJ.RequiresNamespace)) {\r
+ String uri = g.getPossibleValue(req, Bindings.STRING);\r
+ if(uri != null) {\r
+ Resource target = g.getResource(uri);\r
+ if(target != null) {\r
+ g.claim(model, l0.IsLinkedTo, null, target);\r
+ }\r
+ }\r
+ }\r
+ }\r
+ }\r
+\r
+ \r
+ callback.run(model);\r
+ } catch(Exception e) {\r
+ errorCallback.run(e);\r
+ }\r
+ }\r
+ };\r
+\r
+ ModelManager mm;\r
+\r
+ @Override\r
+ public void configure() throws ProjectException {\r
+ final IProject project = getProject();\r
+ final Session session = getSession();\r
+\r
+ getProjectElement().setHint(ProjectKeys.DEFAULT_PERSPECTIVE, DEFAULT_PERSPECTIVE);\r
+\r
+ getProjectElement().setHint(IEditorNamingService.KEY_EDITOR_NAMING_SERVICE, new EditorNamingService2());\r
+\r
+ mm = new ModelManager();\r
+ getProjectElement().setHint(UIModelManager.KEY_MODEL_MANAGER, mm);\r
+\r
+ // Install naming strategy for model components.\r
+ GraphChangeListenerSupport changeSupport = session.peekService(GraphChangeListenerSupport.class);\r
+ if (changeSupport != null) {\r
+ getProjectElement().setHint(ComponentNamingStrategy.PROJECT_KEY, new CaseInsensitiveComponentNamingStrategy2(changeSupport, "%s%d"));\r
+ }\r
+\r
+ try {\r
+\r
+ Resource projectResource = project.get();\r
+\r
+ session.registerService(RuntimeValuations.class, new RuntimeValuations() {\r
+\r
+ @Override\r
+ public boolean supports(String valuation) {\r
+\r
+ IExperimentManager expMan = project.getHint(IExperimentManager.KEY_EXPERIMENT_MANAGER);\r
+ IExperiment experiment = expMan.getExperiment(valuation);\r
+\r
+ return experiment != null;\r
+\r
+ }\r
+\r
+ @Override\r
+ public Accessor getAccessor(String variableIdentityPrefix, String valuation, String suffix) {\r
+ return null;\r
+ }\r
+\r
+ @Override\r
+ public TrendVariable getVariable(String variableIdentityPrefix, String valuation, String suffix) {\r
+\r
+ return null;\r
+\r
+ }\r
+\r
+ });\r
+\r
+\r
+\r
+ ActivationManager activationManager = session.getService(ActivationManager.class);\r
+ if (activationManager != null) {\r
+ activationManager.activate(session, projectResource);\r
+ }\r
+\r
+\r
+ VirtualGraphSupport support = session.getService(VirtualGraphSupport.class);\r
+\r
+ support.getWorkspacePersistent("experiments");\r
+\r
+ } catch (DatabaseException e) {\r
+\r
+ throw new ProjectException(e);\r
+\r
+ }\r
+\r
+\r
+ cleanProjectFolder(session, project.get());\r
+\r
+\r
+ // Open cheatsheets view on the first time the user creates a sysdyn project\r
+ // for a particular workspace.\r
+ IEclipsePreferences prefs = new InstanceScope().getNode(Activator.PLUGIN_ID);\r
+ boolean firstSysdynProject = prefs.getBoolean(FIRST_SYSDYN_PROJECT, true);\r
+ if (firstSysdynProject) {\r
+ // This should not be here\r
+// Display.getDefault().asyncExec(new Runnable() {\r
+// @Override\r
+// public void run() {\r
+// new OpenCheatSheetAction(CHEATSHEET_ID).run();\r
+// }});\r
+\r
+ // Make a note that the user has created a sysdyn project.\r
+ try {\r
+ prefs.putBoolean(FIRST_SYSDYN_PROJECT, false);\r
+ prefs.flush();\r
+ } catch (BackingStoreException e) {\r
+ ErrorLogger.defaultLogError(e);\r
+ }\r
+ }\r
+ }\r
+\r
+ @Override\r
+ public void deconfigure() throws ProjectException {\r
+ if (getProjectElement().getHint(UIModelManager.KEY_MODEL_MANAGER) == mm)\r
+ getProjectElement().removeHint(UIModelManager.KEY_MODEL_MANAGER);\r
+ mm = null;\r
+\r
+ getProjectElement().removeHint(ComponentNamingStrategy.PROJECT_KEY);\r
+ }\r
+\r
+ public void cleanProjectFolder(Session session, final Resource projectResource) throws ProjectException {\r
+ String projectName = null;\r
+ final HashMap<String, Resource> resultPaths = new HashMap<String, Resource>();\r
+ try {\r
+ projectName = session.syncRequest(new Read<String>() {\r
+\r
+ @Override\r
+ public String perform(ReadGraph graph) throws DatabaseException {\r
+ Layer0 l0 = Layer0.getInstance(graph);\r
+ SimulationResource SIMU = SimulationResource.getInstance(graph);\r
+ SysdynResource sr = SysdynResource.getInstance(graph);\r
+ for(Resource model : graph.getObjects(projectResource, l0.ConsistsOf)) {\r
+ if(graph.isInstanceOf(model, sr.SysdynModel)){\r
+ for(Resource experiment : graph.getObjects(model, l0.ConsistsOf)) {\r
+ if(graph.isInstanceOf(experiment, SIMU.Experiment)) {\r
+ for(Resource result : graph.getObjects(experiment, sr.HasResult)) {\r
+ String resultFile = (String)graph.getPossibleRelatedValue(result, sr.HasResultFile);\r
+ if(result != null) resultPaths.put(resultFile, result);\r
+ }\r
+ }\r
+ }\r
+ }\r
+ }\r
+ return graph.getPossibleRelatedValue(projectResource, l0.HasName);\r
+\r
+ }\r
+ });\r
+ } catch (DatabaseException e) {\r
+ throw new ProjectException(e);\r
+ }\r
+\r
+ if(projectName != null) {\r
+ File root = new File(Platform.getLocation().toOSString(), "www.simantics.org");\r
+ if(!root.isDirectory()) return;\r
+ File projectRoot = new File(root, projectName);\r
+ if(!projectRoot.isDirectory()) return;\r
+ File[] files = projectRoot.listFiles();\r
+\r
+ for(File file : files) {\r
+ if(resultPaths.get(file.getAbsolutePath()) == null) {\r
+ file.delete();\r
+ } else {\r
+ resultPaths.remove(file.getAbsolutePath());\r
+ }\r
+ }\r
+\r
+ if (!resultPaths.keySet().isEmpty()) {\r
+ session.asyncRequest(new WriteRequest() {\r
+\r
+ @Override\r
+ public void perform(WriteGraph graph) throws DatabaseException {\r
+ Layer0 l0 = Layer0.getInstance(graph);\r
+ for(String key : resultPaths.keySet()) {\r
+ Resource result = resultPaths.get(key);\r
+ graph.deny(result, l0.PartOf);\r
+ graph.deny(result, graph.getInverse(SysdynResource.getInstance(graph).HasResult));\r
+ }\r
+ }\r
+ }) ;\r
+ }\r
+ }\r
+ }\r
+\r
+}\r
--- /dev/null
+package org.simantics.sysdyn.ui.properties;\r
+\r
+import java.util.ArrayList;\r
+import java.util.List;\r
+\r
+import org.eclipse.jface.layout.GridDataFactory;\r
+import org.eclipse.jface.layout.GridLayoutFactory;\r
+import org.eclipse.jface.viewers.ISelection;\r
+import org.eclipse.jface.viewers.ISelectionProvider;\r
+import org.eclipse.jface.viewers.IStructuredSelection;\r
+import org.eclipse.swt.SWT;\r
+import org.eclipse.swt.widgets.Composite;\r
+import org.eclipse.swt.widgets.Control;\r
+import org.eclipse.swt.widgets.Label;\r
+import org.eclipse.swt.widgets.Tree;\r
+import org.eclipse.ui.IWorkbenchSite;\r
+import org.simantics.browsing.ui.swt.AdaptableHintContext;\r
+import org.simantics.browsing.ui.swt.SingleSelectionInputSource;\r
+import org.simantics.browsing.ui.swt.widgets.Button;\r
+import org.simantics.browsing.ui.swt.widgets.GraphExplorerComposite;\r
+import org.simantics.browsing.ui.swt.widgets.impl.SelectionListenerImpl;\r
+import org.simantics.browsing.ui.swt.widgets.impl.Widget;\r
+import org.simantics.browsing.ui.swt.widgets.impl.WidgetSupport;\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.WriteGraph;\r
+import org.simantics.db.common.utils.OrderedSetUtils;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.db.management.ISessionContext;\r
+import org.simantics.sysdyn.SysdynResource;\r
+import org.simantics.sysdyn.ui.properties.widgets.ColumnKeys;\r
+import org.simantics.utils.datastructures.ArrayMap;\r
+\r
+public class ArrayIndexesTab extends LabelPropertyTabContributor implements Widget{\r
+\r
+ GraphExplorerComposite availableEnumerationsExplorer;\r
+ GraphExplorerComposite usedEnumerationsExplorer;\r
+ \r
+ @Override\r
+ public void createControls(Composite body, IWorkbenchSite site,\r
+ ISessionContext context, WidgetSupport support) {\r
+ support.register(this);\r
+ \r
+ GridLayoutFactory.fillDefaults().numColumns(4).applyTo(body);\r
+ \r
+ \r
+ Composite available = new Composite(body, SWT.NONE);\r
+ GridLayoutFactory.fillDefaults().applyTo(available);\r
+ GridDataFactory.fillDefaults().grab(true, true).applyTo(available);\r
+ Label label = new Label(available, SWT.None);\r
+ label.setText("Available Enumerations");\r
+ availableEnumerationsExplorer = new GraphExplorerComposite(ArrayMap.keys(\r
+ "displaySelectors", "displayFilter").values(false, false), site, available, SWT.FULL_SELECTION | SWT.BORDER | SWT.MULTI);\r
+ \r
+ availableEnumerationsExplorer\r
+ .setBrowseContexts("http://www.simantics.org/Sysdyn-1.0/AvailableVariableIndexes");\r
+ availableEnumerationsExplorer.setColumns(ColumnKeys.ENUMERATION_TABLE_COLUMNS);\r
+ availableEnumerationsExplorer.setInputSource(new SingleSelectionInputSource(\r
+ Resource.class));\r
+\r
+ availableEnumerationsExplorer.finish();\r
+\r
+ GridDataFactory.fillDefaults().grab(true, true).applyTo(\r
+ availableEnumerationsExplorer);\r
+ \r
+ Control c = availableEnumerationsExplorer.getExplorerControl();\r
+ if (c instanceof Tree)\r
+ ((Tree) c).setLinesVisible(true);\r
+ \r
+ \r
+ Button add = new Button(body, support, SWT.NONE);\r
+ add.setText(" -> ");\r
+ \r
+ add.addSelectionListener(new SelectionListenerImpl<Resource>(context) {\r
+\r
+ @Override\r
+ public void apply(WriteGraph graph, Resource input)\r
+ throws DatabaseException {\r
+ SysdynResource sr = SysdynResource.getInstance(graph);\r
+ Resource arrayIndexes = graph.getPossibleObject(input, sr.HasArrayIndexes);\r
+\r
+ List<Resource> enumerationResources = getSelectedResources(availableEnumerationsExplorer);\r
+ \r
+ if(arrayIndexes == null) {\r
+ arrayIndexes = OrderedSetUtils.create(graph, sr.ArrayIndexes, enumerationResources);\r
+ graph.claim(input, sr.HasArrayIndexes, arrayIndexes);\r
+ } else {\r
+ OrderedSetUtils.addAll(graph, arrayIndexes, enumerationResources);\r
+ }\r
+ \r
+ \r
+ }\r
+ });\r
+ \r
+ Composite used = new Composite(body, SWT.NONE);\r
+ GridLayoutFactory.fillDefaults().applyTo(used);\r
+ GridDataFactory.fillDefaults().grab(true, true).applyTo(used);\r
+ label = new Label(used, SWT.None);\r
+ label.setText("Used Enumerations");\r
+ \r
+ usedEnumerationsExplorer = new GraphExplorerComposite(ArrayMap.keys(\r
+ "displaySelectors", "displayFilter").values(false, false), site, used, SWT.FULL_SELECTION | SWT.BORDER);\r
+ \r
+ usedEnumerationsExplorer\r
+ .setBrowseContexts("http://www.simantics.org/Sysdyn-1.0/UsedVariableIndexes");\r
+ usedEnumerationsExplorer.setColumns(ColumnKeys.ENUMERATION_TABLE_COLUMNS);\r
+ usedEnumerationsExplorer.setInputSource(new SingleSelectionInputSource(\r
+ Resource.class));\r
+\r
+ usedEnumerationsExplorer.finish();\r
+\r
+ GridDataFactory.fillDefaults().grab(true, true).applyTo(\r
+ usedEnumerationsExplorer);\r
+ \r
+ Control c2 = usedEnumerationsExplorer.getExplorerControl();\r
+ if (c2 instanceof Tree)\r
+ ((Tree) c2).setLinesVisible(true);\r
+ \r
+ Composite buttons = new Composite(body, SWT.None);\r
+ GridLayoutFactory.fillDefaults().applyTo(buttons);\r
+ \r
+ Button up = new Button(buttons, support, SWT.NONE);\r
+ up.setText("Up");\r
+ up.addSelectionListener(new SelectionListenerImpl<Resource>(context) {\r
+ @Override\r
+ public void apply(WriteGraph graph, Resource input)\r
+ throws DatabaseException {\r
+ SysdynResource sr = SysdynResource.getInstance(graph);\r
+ Resource arrayIndexes = graph.getPossibleObject(input, sr.HasArrayIndexes);\r
+ if(arrayIndexes == null)\r
+ return;\r
+ \r
+ List<Resource> enumerationResources = getSelectedResources(usedEnumerationsExplorer);\r
+ if(enumerationResources.size() != 1)\r
+ return;\r
+ Resource enumeration = enumerationResources.get(0);\r
+ Resource prev = OrderedSetUtils.prev(graph, arrayIndexes, enumeration);\r
+ if(prev.equals(arrayIndexes))\r
+ return;\r
+ \r
+ OrderedSetUtils.remove(graph, arrayIndexes, enumeration);\r
+ OrderedSetUtils.addBefore(graph, arrayIndexes, prev, enumeration);\r
+ }\r
+ });\r
+ \r
+ Button down = new Button(buttons, support, SWT.NONE);\r
+ down.setText("Down");\r
+ down.addSelectionListener(new SelectionListenerImpl<Resource>(context) {\r
+ @Override\r
+ public void apply(WriteGraph graph, Resource input)\r
+ throws DatabaseException {\r
+ SysdynResource sr = SysdynResource.getInstance(graph);\r
+ Resource arrayIndexes = graph.getPossibleObject(input, sr.HasArrayIndexes);\r
+ if(arrayIndexes == null)\r
+ return;\r
+ \r
+ List<Resource> enumerationResources = getSelectedResources(usedEnumerationsExplorer);\r
+ if(enumerationResources.size() != 1)\r
+ return;\r
+ Resource enumeration = enumerationResources.get(0);\r
+ Resource next = OrderedSetUtils.next(graph, arrayIndexes, enumeration);\r
+ if(next.equals(arrayIndexes))\r
+ return;\r
+ OrderedSetUtils.remove(graph, arrayIndexes, enumeration);\r
+ OrderedSetUtils.addAfter(graph, arrayIndexes, next, enumeration);\r
+ }\r
+ });\r
+ \r
+ \r
+ Button remove = new Button(buttons, support, SWT.NONE);\r
+ remove.setText("Remove");\r
+ remove.addSelectionListener(new SelectionListenerImpl<Resource>(context) {\r
+ @Override\r
+ public void apply(WriteGraph graph, Resource input)\r
+ throws DatabaseException {\r
+ SysdynResource sr = SysdynResource.getInstance(graph);\r
+ Resource arrayIndexes = graph.getPossibleObject(input, sr.HasArrayIndexes);\r
+ if(arrayIndexes == null)\r
+ return;\r
+ \r
+ List<Resource> enumerationResources = getSelectedResources(usedEnumerationsExplorer);\r
+ if(enumerationResources.size() != 1)\r
+ return;\r
+ Resource enumeration = enumerationResources.get(0);\r
+ OrderedSetUtils.remove(graph, arrayIndexes, enumeration);\r
+ }\r
+ });\r
+ }\r
+ \r
+ \r
+ private List<Resource> getSelectedResources(GraphExplorerComposite explorer) {\r
+ List<Resource> result = new ArrayList<Resource>();\r
+ \r
+ ISelection selection = ((ISelectionProvider) explorer\r
+ .getAdapter(ISelectionProvider.class)).getSelection();\r
+ if (selection == null)\r
+ return result;\r
+ IStructuredSelection iss = (IStructuredSelection) selection;\r
+ @SuppressWarnings("unchecked")\r
+ List<AdaptableHintContext> selections = iss.toList();\r
+ for(AdaptableHintContext ahc : selections) {\r
+ Resource resource = (Resource) ahc.getAdapter(Resource.class);\r
+ result.add(resource);\r
+ }\r
+ return result;\r
+ }\r
+\r
+\r
+ @Override\r
+ public void setInput(ISessionContext context, Object input) {\r
+ availableEnumerationsExplorer.setInput(context, input);\r
+ usedEnumerationsExplorer.setInput(context, input);\r
+ }\r
+\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2010 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.ui.properties;\r
+\r
+import java.util.HashMap;\r
+import java.util.Map;\r
+\r
+import org.eclipse.jface.dialogs.IInputValidator;\r
+import org.eclipse.jface.layout.GridDataFactory;\r
+import org.eclipse.jface.layout.GridLayoutFactory;\r
+import org.eclipse.swt.SWT;\r
+import org.eclipse.swt.widgets.Composite;\r
+import org.eclipse.swt.widgets.Label;\r
+import org.eclipse.ui.IWorkbenchSite;\r
+import org.simantics.browsing.ui.swt.widgets.StringPropertyFactory;\r
+import org.simantics.browsing.ui.swt.widgets.TrackedCombo;\r
+import org.simantics.browsing.ui.swt.widgets.TrackedText;\r
+import org.simantics.browsing.ui.swt.widgets.impl.ReadFactoryImpl;\r
+import org.simantics.browsing.ui.swt.widgets.impl.TextModifyListenerImpl;\r
+import org.simantics.browsing.ui.swt.widgets.impl.WidgetSupport;\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.WriteGraph;\r
+import org.simantics.db.common.utils.NameUtils;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.db.management.ISessionContext;\r
+import org.simantics.layer0.Layer0;\r
+import org.simantics.sysdyn.SysdynResource;\r
+import org.simantics.sysdyn.ui.properties.widgets.factories.ComboStringPropertyModifier;\r
+import org.simantics.sysdyn.ui.properties.widgets.factories.DoublePropertyFactory;\r
+import org.simantics.sysdyn.ui.properties.widgets.factories.DoublePropertyModifier;\r
+import org.simantics.sysdyn.ui.utils.VariableNameUtils;\r
+\r
+public class ConfigurationTab extends LabelPropertyTabContributor {\r
+\r
+ private class ModelLabelModifier extends TextModifyListenerImpl<Resource> {\r
+\r
+ public ModelLabelModifier(ISessionContext context, String propertyURI) {\r
+ }\r
+ \r
+ @Override\r
+ public void applyText(WriteGraph graph, Resource issue, String text) throws DatabaseException {\r
+ Layer0 l0 = Layer0.getInstance(graph);\r
+ graph.claimLiteral(issue, l0.HasLabel, text);\r
+ String safeName = NameUtils.findFreshName(graph, text, graph.getSingleObject(issue, l0.PartOf), l0.ConsistsOf, "%s%d");\r
+ graph.claimLiteral(issue, l0.HasName, safeName);\r
+ }\r
+ \r
+ }\r
+ \r
+ \r
+ @Override\r
+ public void createControls(Composite body, IWorkbenchSite site, ISessionContext context, WidgetSupport support) {\r
+ Composite composite = new Composite(body, SWT.NONE);\r
+ GridDataFactory.fillDefaults().grab(true, true).applyTo(composite);\r
+ GridLayoutFactory.fillDefaults().margins(3, 3).numColumns(2).applyTo(composite);\r
+\r
+ Label label = new Label(composite, SWT.NONE);\r
+ label.setText("Name");\r
+ \r
+ TrackedText name = new TrackedText(composite, support, SWT.BORDER);\r
+ name.setTextFactory(new StringPropertyFactory(Layer0.URIs.HasLabel));\r
+ name.addModifyListener(new ModelLabelModifier(context, Layer0.URIs.HasLabel));\r
+ name.setInputValidator(new IInputValidator() {\r
+ \r
+ @Override\r
+ public String isValid(String newText) {\r
+ if (!VariableNameUtils.isValid(newText))\r
+ return "Sorry but spaces and special characters are not allowed for names right now";\r
+ return null;\r
+ }\r
+ });\r
+\r
+ GridDataFactory.fillDefaults().hint(200, SWT.DEFAULT).applyTo(name.getWidget());\r
+\r
+ label = new Label(composite, SWT.NONE);\r
+ label.setText("Start time");\r
+\r
+ TrackedText startTime = new TrackedText(composite, support, SWT.BORDER | SWT.RIGHT);\r
+ startTime.setTextFactory(new DoublePropertyFactory(SysdynResource.URIs.HasStartTime));\r
+ startTime.addModifyListener(new DoublePropertyModifier(context, SysdynResource.URIs.HasStartTime));\r
+ startTime.setInputValidator(new DoubleValidator());\r
+ GridDataFactory.fillDefaults().hint(200, SWT.DEFAULT).applyTo(startTime.getWidget());\r
+\r
+ label = new Label(composite, SWT.NONE);\r
+ label.setText("Stop time");\r
+\r
+ TrackedText stopTime = new TrackedText(composite, support, SWT.BORDER | SWT.RIGHT);\r
+ stopTime.setTextFactory(new DoublePropertyFactory(SysdynResource.URIs.HasStopTime));\r
+ stopTime.addModifyListener(new DoublePropertyModifier(context, SysdynResource.URIs.HasStopTime));\r
+ stopTime.setInputValidator(new DoubleValidator());\r
+ GridDataFactory.fillDefaults().hint(200, SWT.DEFAULT).applyTo(stopTime.getWidget());\r
+\r
+ label = new Label(composite, SWT.NONE);\r
+ label.setText("Step length\n(empty = default)");\r
+\r
+ TrackedText outputInterval = new TrackedText(composite, support, SWT.BORDER | SWT.RIGHT);\r
+ outputInterval.setTextFactory(new DoublePropertyFactory(SysdynResource.URIs.HasOutputInterval));\r
+ outputInterval.addModifyListener(new DoublePropertyModifier(context, SysdynResource.URIs.HasOutputInterval));\r
+ outputInterval.setInputValidator(new DoubleValidator());\r
+ GridDataFactory.fillDefaults().hint(200, SWT.DEFAULT).applyTo(outputInterval.getWidget());\r
+ \r
+ label = new Label(composite, SWT.NONE);\r
+ label.setText("Method");\r
+ \r
+ TrackedCombo method = new TrackedCombo(composite, support, SWT.DROP_DOWN | SWT.BORDER | SWT.READ_ONLY);\r
+ method.setItemFactory(new ReadFactoryImpl<Resource, Map<String,Object>>() {\r
+\r
+ @Override\r
+ public Map<String, Object> perform(ReadGraph graph, final Resource input) throws DatabaseException {\r
+\r
+ Map<String, Object> map = new HashMap<String, Object>();\r
+ map.put("euler", "euler");\r
+ map.put("rungekutta", "rungekutta");\r
+ map.put("dassl", "dassl");\r
+ map.put("dassl2", "dassl2");\r
+ map.put("inline-euler", "inline-euler");\r
+ map.put("inline-rungekutta", "inline-rungekutta");\r
+ return map;\r
+ }\r
+ });\r
+ \r
+ method.setSelectionFactory(new ReadFactoryImpl<Resource, String>() {\r
+\r
+ @Override\r
+ public String perform(ReadGraph graph, final Resource input) throws DatabaseException {\r
+ return graph.getRelatedValue(input, SysdynResource.getInstance(graph).HasSolver);\r
+ }\r
+ });\r
+ \r
+ method.addModifyListener(new ComboStringPropertyModifier<Resource>() {\r
+\r
+ @Override\r
+ public void applyText(WriteGraph graph, Resource input, String text)\r
+ throws DatabaseException {\r
+ graph.claimLiteral(input, SysdynResource.getInstance(graph).HasSolver, text);\r
+ }\r
+ });\r
+ \r
+ label = new Label(composite, SWT.NONE);\r
+ label.setText("Tolerance");\r
+\r
+ TrackedText tolerance = new TrackedText(composite, support, SWT.BORDER | SWT.RIGHT);\r
+ tolerance.setTextFactory(new DoublePropertyFactory(SysdynResource.URIs.HasTolerance));\r
+ tolerance.addModifyListener(new DoublePropertyModifier(context, SysdynResource.URIs.HasTolerance));\r
+ tolerance.setInputValidator(new DoubleValidator());\r
+ GridDataFactory.fillDefaults().hint(200, SWT.DEFAULT).applyTo(tolerance.getWidget());\r
+\r
+ \r
+ }\r
+\r
+ private class DoubleValidator implements IInputValidator {\r
+\r
+ @Override\r
+ public String isValid(String newText) {\r
+ for(int i = 0; i < newText.length(); i++){\r
+ if(!Character.isDigit(newText.charAt(i))){\r
+ if(newText.charAt(i) != '.') {\r
+ return "Invalid character '" + newText.charAt(i) + "'";\r
+ } else if(newText.indexOf('.') != newText.lastIndexOf('.')) {\r
+ return "There can be only one '.'";\r
+ }\r
+ }\r
+ }\r
+ return null;\r
+ }\r
+ } \r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2010 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.ui.properties;\r
+\r
+import org.eclipse.jface.layout.GridDataFactory;\r
+import org.eclipse.jface.layout.GridLayoutFactory;\r
+import org.eclipse.swt.SWT;\r
+import org.eclipse.swt.widgets.Composite;\r
+import org.eclipse.ui.IWorkbenchSite;\r
+import org.simantics.browsing.ui.swt.widgets.StringPropertyFactory;\r
+import org.simantics.browsing.ui.swt.widgets.StringPropertyModifier;\r
+import org.simantics.browsing.ui.swt.widgets.TrackedText;\r
+import org.simantics.browsing.ui.swt.widgets.impl.WidgetSupport;\r
+import org.simantics.db.management.ISessionContext;\r
+import org.simantics.layer0.Layer0;\r
+\r
+public class DependencyTab extends LabelPropertyTabContributor {\r
+\r
+ @Override\r
+ public void createControls(Composite body, IWorkbenchSite site, ISessionContext context, WidgetSupport support) {\r
+ Composite composite = new Composite(body, SWT.NONE);\r
+ GridDataFactory.fillDefaults().grab(true, true).applyTo(composite);\r
+ GridLayoutFactory.fillDefaults().margins(3, 3).numColumns(6).applyTo(composite);\r
+ TrackedText nameText = new TrackedText(composite, support, SWT.BORDER);\r
+ nameText.setTextFactory(new StringPropertyFactory(Layer0.URIs.HasName));\r
+ nameText.addModifyListener(new StringPropertyModifier(context, Layer0.URIs.HasName));\r
+ GridDataFactory.fillDefaults().grab(true, false).applyTo(nameText.getWidget());\r
+ }\r
+\r
+\r
+}\r
--- /dev/null
+package org.simantics.sysdyn.ui.properties;\r
+\r
+import java.util.List;\r
+\r
+import org.eclipse.jface.layout.GridDataFactory;\r
+import org.eclipse.jface.layout.GridLayoutFactory;\r
+import org.eclipse.jface.viewers.ISelectionProvider;\r
+import org.eclipse.jface.viewers.IStructuredSelection;\r
+import org.eclipse.swt.SWT;\r
+import org.eclipse.swt.events.SelectionEvent;\r
+import org.eclipse.swt.events.SelectionListener;\r
+import org.eclipse.swt.widgets.Composite;\r
+import org.eclipse.swt.widgets.Control;\r
+import org.eclipse.swt.widgets.Event;\r
+import org.eclipse.swt.widgets.Listener;\r
+import org.eclipse.swt.widgets.Tree;\r
+import org.eclipse.swt.widgets.TreeItem;\r
+import org.eclipse.ui.IWorkbenchSite;\r
+import org.simantics.browsing.ui.NodeContext;\r
+import org.simantics.browsing.ui.swt.SingleSelectionInputSource;\r
+import org.simantics.browsing.ui.swt.widgets.Button;\r
+import org.simantics.browsing.ui.swt.widgets.GraphExplorerComposite;\r
+import org.simantics.browsing.ui.swt.widgets.StringPropertyFactory;\r
+import org.simantics.browsing.ui.swt.widgets.Table;\r
+import org.simantics.browsing.ui.swt.widgets.TrackedText;\r
+import org.simantics.browsing.ui.swt.widgets.impl.Widget;\r
+import org.simantics.browsing.ui.swt.widgets.impl.WidgetSupport;\r
+import org.simantics.databoard.Bindings;\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.WriteGraph;\r
+import org.simantics.db.common.request.ReadRequest;\r
+import org.simantics.db.common.request.WriteRequest;\r
+import org.simantics.db.common.utils.OrderedSetUtils;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.db.layer0.variable.Variable;\r
+import org.simantics.db.layer0.variable.Variables;\r
+import org.simantics.db.management.ISessionContext;\r
+import org.simantics.db.request.Read;\r
+import org.simantics.layer0.Layer0;\r
+import org.simantics.layer0.utils.direct.GraphUtils;\r
+import org.simantics.simulation.ontology.SimulationResource;\r
+import org.simantics.sysdyn.SysdynResource;\r
+import org.simantics.sysdyn.manager.SysdynModel;\r
+import org.simantics.sysdyn.manager.SysdynModelManager;\r
+import org.simantics.sysdyn.ui.properties.widgets.arrays.EnumerationIndexNode;\r
+import org.simantics.sysdyn.ui.properties.widgets.arrays.ReplaceableIndexesWidget;\r
+import org.simantics.sysdyn.ui.properties.widgets.factories.VariableNamePropertyModifier;\r
+import org.simantics.sysdyn.ui.properties.widgets.factories.VariableNameValidator;\r
+import org.simantics.ui.SimanticsUI;\r
+import org.simantics.ui.utils.AdaptionUtils;\r
+import org.simantics.utils.datastructures.ArrayMap;\r
+\r
+public class EnumerationTab extends LabelPropertyTabContributor implements Widget {\r
+\r
+ GraphExplorerComposite indexExplorer;\r
+ \r
+ Button showAll;\r
+ Variable variable;\r
+ \r
+ Table table;\r
+ @Override\r
+ public void createControls(Composite body, IWorkbenchSite site,\r
+ final ISessionContext context, WidgetSupport support) {\r
+\r
+ support.register(this);\r
+ \r
+ Composite container = new Composite(body, SWT.None);\r
+ GridDataFactory.fillDefaults().grab(true, true).applyTo(container);\r
+ GridLayoutFactory.fillDefaults().margins(3, 3).numColumns(4).applyTo(container);\r
+\r
+ TrackedText nameText = new TrackedText(container, support, SWT.BORDER);\r
+ nameText.setTextFactory(new StringPropertyFactory(Layer0.URIs.HasName));\r
+ nameText.addModifyListener(new VariableNamePropertyModifier(context, Layer0.URIs.HasName));\r
+ nameText.setInputValidator(new VariableNameValidator(support));\r
+ GridDataFactory.fillDefaults().grab(true, false).span(4,1).applyTo(nameText.getWidget());\r
+ \r
+ indexExplorer = new GraphExplorerComposite(ArrayMap.keys(\r
+ "displaySelectors", "displayFilter").values(false, false), site, container, support, SWT.FULL_SELECTION | SWT.BORDER | SWT.MULTI | SWT.CHECK);\r
+ \r
+ indexExplorer\r
+ .setBrowseContexts("http://www.simantics.org/Sysdyn-1.0/EnumerationIndexes");\r
+ indexExplorer.setInputSource(new SingleSelectionInputSource(\r
+ Resource.class));\r
+ ((Tree)indexExplorer.getExplorerControl()).addListener(SWT.Selection, new Listener () {\r
+ \r
+ @Override\r
+ public void handleEvent (Event event) {\r
+ if(event.detail == SWT.CHECK) {\r
+ final TreeItem item = (TreeItem)event.item;\r
+ final boolean checked = item.getChecked();\r
+ NodeContext context = (NodeContext)item.getData();\r
+ final EnumerationIndexNode node = (EnumerationIndexNode) context.getAdapter(EnumerationIndexNode.class);\r
+ node.setShowInChartsSelected(checked);\r
+ \r
+ SimanticsUI.getSession().asyncRequest(new ReadRequest() {\r
+ @Override\r
+ public void run(ReadGraph graph) throws DatabaseException {\r
+ updateModelResults(graph);\r
+ }\r
+ });\r
+ }\r
+ }\r
+ });\r
+ \r
+\r
+ indexExplorer.finish();\r
+\r
+ GridDataFactory.fillDefaults().grab(true, true).span(4, 1).applyTo(\r
+ indexExplorer);\r
+ \r
+ Control c = indexExplorer.getExplorerControl();\r
+ if (c instanceof Tree)\r
+ ((Tree) c).setLinesVisible(true);\r
+\r
+\r
+ final Button add = new Button(container, support, SWT.None);\r
+ add.setText("Add");\r
+ add.addSelectionListener(new addEnumerationIndexListener(support));\r
+\r
+ final Button remove = new Button(container, support, SWT.None);\r
+ remove.setText("Remove");\r
+ remove.addSelectionListener(new removeEnumerationIndexListener(support));\r
+ \r
+ ReplaceableIndexesWidget externalIndexes = new ReplaceableIndexesWidget(container, support, SWT.NULL);\r
+ GridDataFactory.fillDefaults().applyTo(externalIndexes.getWidget());\r
+ \r
+ showAll = new Button(container, support, SWT.CHECK);\r
+ showAll.setText("Show all in charts");\r
+ showAll.addSelectionListener(new ShowAllIndexesListener(support));\r
+ \r
+ }\r
+\r
+ private class addEnumerationIndexListener implements SelectionListener, Widget {\r
+\r
+ Resource enumerationIndexes;\r
+\r
+ public addEnumerationIndexListener(WidgetSupport support) {\r
+ support.register(this);\r
+ }\r
+\r
+ @Override\r
+ public void setInput(ISessionContext context, Object input) {\r
+ final Resource enumeration = AdaptionUtils.adaptToSingle(input, Resource.class);\r
+ try {\r
+ context.getSession().syncRequest(new ReadRequest() {\r
+\r
+ @Override\r
+ public void run(ReadGraph graph) throws DatabaseException {\r
+ enumerationIndexes = graph.getSingleObject(enumeration, SysdynResource.getInstance(graph).HasEnumerationIndexes);\r
+ }\r
+ });\r
+ } catch (DatabaseException e) {\r
+ e.printStackTrace();\r
+ }\r
+ }\r
+\r
+ @Override\r
+ public void widgetSelected(SelectionEvent e) {\r
+ try {\r
+ SimanticsUI.getSession().syncRequest(new WriteRequest() {\r
+\r
+ @Override\r
+ public void perform(WriteGraph graph) throws DatabaseException {\r
+ SysdynResource sr = SysdynResource.getInstance(graph);\r
+ Layer0 l0 = Layer0.getInstance(graph);\r
+\r
+\r
+ Resource ei = GraphUtils.create2(graph, \r
+ sr.EnumerationIndex,\r
+ l0.HasName, "index");\r
+ OrderedSetUtils.add(graph, enumerationIndexes, ei);\r
+ }\r
+ });\r
+ } catch (DatabaseException e1) {\r
+ e1.printStackTrace();\r
+ }\r
+\r
+ }\r
+\r
+ @Override\r
+ public void widgetDefaultSelected(SelectionEvent e) {\r
+\r
+ }\r
+\r
+ }\r
+\r
+ private class removeEnumerationIndexListener implements SelectionListener, Widget {\r
+\r
+ Resource enumerationIndexes;\r
+\r
+ public removeEnumerationIndexListener(WidgetSupport support) {\r
+ support.register(this);\r
+ }\r
+\r
+ @Override\r
+ public void setInput(ISessionContext context, Object input) {\r
+ final Resource enumeration = AdaptionUtils.adaptToSingle(input, Resource.class);\r
+ try {\r
+ context.getSession().syncRequest(new ReadRequest() {\r
+\r
+ @Override\r
+ public void run(ReadGraph graph) throws DatabaseException {\r
+ enumerationIndexes = graph.getSingleObject(enumeration, SysdynResource.getInstance(graph).HasEnumerationIndexes);\r
+ }\r
+ });\r
+ } catch (DatabaseException e) {\r
+ e.printStackTrace();\r
+ }\r
+ }\r
+\r
+ @Override\r
+ public void widgetSelected(SelectionEvent e) {\r
+ ISelectionProvider selectionProvider = (ISelectionProvider)indexExplorer.getAdapter(ISelectionProvider.class);\r
+ final IStructuredSelection selection = (IStructuredSelection)selectionProvider.getSelection();\r
+\r
+ try {\r
+ SimanticsUI.getSession().syncRequest(new WriteRequest() {\r
+\r
+ @Override\r
+ public void perform(WriteGraph graph) throws DatabaseException {\r
+ for(Object o : selection.toList()) {\r
+ Resource r = AdaptionUtils.adaptToSingle(o, Resource.class);\r
+ if(r == null)\r
+ continue;\r
+ OrderedSetUtils.remove(graph, enumerationIndexes, r);\r
+ }\r
+ }\r
+ });\r
+ } catch (DatabaseException e1) {\r
+ e1.printStackTrace();\r
+ }\r
+ \r
+\r
+ }\r
+\r
+ @Override\r
+ public void widgetDefaultSelected(SelectionEvent e) {\r
+\r
+ }\r
+\r
+ }\r
+ \r
+ private class ShowAllIndexesListener implements SelectionListener, Widget {\r
+\r
+ Resource enumerationIndexes;\r
+\r
+ public ShowAllIndexesListener(WidgetSupport support) {\r
+ support.register(this);\r
+ }\r
+\r
+ @Override\r
+ public void setInput(ISessionContext context, Object input) {\r
+ final Resource enumeration = AdaptionUtils.adaptToSingle(input, Resource.class);\r
+ \r
+ context.getSession().asyncRequest(new Read<Boolean>() {\r
+\r
+ @Override\r
+ public Boolean perform(ReadGraph graph)\r
+ throws DatabaseException {\r
+ SysdynResource sr = SysdynResource.getInstance(graph);\r
+ enumerationIndexes = graph.getSingleObject(enumeration, sr.HasEnumerationIndexes);\r
+ List<Resource> indexes = OrderedSetUtils.toList(graph, enumerationIndexes);\r
+ for(Resource index : indexes) {\r
+ Boolean show = graph.getPossibleRelatedValue(index, sr.ShowEnumerationIndexInCharts, Bindings.BOOLEAN);\r
+ if(!Boolean.TRUE.equals(show))\r
+ return false;\r
+ }\r
+ return true;\r
+ }\r
+ \r
+ }, new org.simantics.db.procedure.Listener<Boolean>() {\r
+\r
+ @Override\r
+ public void execute(final Boolean result) {\r
+ showAll.getWidget().getDisplay().asyncExec(new Runnable() {\r
+\r
+ @Override\r
+ public void run() {\r
+ showAll.getWidget().setSelection(result.booleanValue());\r
+ }\r
+ });\r
+ }\r
+ \r
+\r
+ @Override\r
+ public void exception(Throwable t) {\r
+ t.printStackTrace();\r
+ }\r
+\r
+ @Override\r
+ public boolean isDisposed() {\r
+ if(showAll == null)\r
+ return true;\r
+ return showAll.getWidget().isDisposed();\r
+ }\r
+ });\r
+ \r
+ }\r
+\r
+ @Override\r
+ public void widgetSelected(SelectionEvent e) {\r
+ final boolean selected = showAll.getWidget().getSelection();\r
+ try {\r
+ SimanticsUI.getSession().syncRequest(new WriteRequest() {\r
+\r
+ @Override\r
+ public void perform(WriteGraph graph) throws DatabaseException {\r
+ SysdynResource sr = SysdynResource.getInstance(graph);\r
+ List<Resource> indexes = OrderedSetUtils.toList(graph, enumerationIndexes);\r
+ for(Resource index : indexes) {\r
+ Boolean show = graph.getPossibleRelatedValue(index, sr.ShowEnumerationIndexInCharts, Bindings.BOOLEAN);\r
+ if(selected && !Boolean.TRUE.equals(show)) {\r
+ graph.claimLiteral(index, sr.ShowEnumerationIndexInCharts, true, Bindings.BOOLEAN);\r
+ } else if(!selected && !Boolean.FALSE.equals(show)) {\r
+ graph.claimLiteral(index, sr.ShowEnumerationIndexInCharts, false, Bindings.BOOLEAN);\r
+ }\r
+ }\r
+ \r
+ updateModelResults(graph);\r
+ }\r
+ });\r
+ } catch (DatabaseException e1) {\r
+ e1.printStackTrace();\r
+ }\r
+ \r
+\r
+ }\r
+\r
+ @Override\r
+ public void widgetDefaultSelected(SelectionEvent e) {\r
+\r
+ }\r
+\r
+ }\r
+ \r
+ private void updateModelResults(ReadGraph graph) {\r
+ try {\r
+ if(variable != null ) {\r
+ Resource modelResource = Variables.getModel(graph, variable);\r
+ if(modelResource != null) {\r
+ Resource configuration = graph.getSingleObject(\r
+ modelResource, \r
+ SimulationResource.getInstance(graph).HasConfiguration);\r
+ SysdynModel model = SysdynModelManager.getInstance(graph.getSession()).getModel(graph, configuration);\r
+ // update results in graphs\r
+ model.resultChanged();\r
+ }\r
+ }\r
+ } catch (DatabaseException e) {\r
+ e.printStackTrace();\r
+ }\r
+ }\r
+\r
+ @Override\r
+ public void setInput(ISessionContext context, Object input) {\r
+ variable = AdaptionUtils.adaptToSingle(input, Variable.class);\r
+ }\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2010 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.ui.properties;\r
+\r
+import java.util.Collection;\r
+import java.util.HashMap;\r
+import java.util.Iterator;\r
+import java.util.List;\r
+import java.util.Map;\r
+\r
+import org.eclipse.jface.layout.GridDataFactory;\r
+import org.eclipse.jface.layout.GridLayoutFactory;\r
+import org.eclipse.jface.viewers.StructuredSelection;\r
+import org.eclipse.swt.SWT;\r
+import org.eclipse.swt.custom.StyledText;\r
+import org.eclipse.swt.custom.VerifyKeyListener;\r
+import org.eclipse.swt.events.FocusEvent;\r
+import org.eclipse.swt.events.FocusListener;\r
+import org.eclipse.swt.events.ModifyEvent;\r
+import org.eclipse.swt.events.ModifyListener;\r
+import org.eclipse.swt.events.MouseEvent;\r
+import org.eclipse.swt.events.MouseListener;\r
+import org.eclipse.swt.events.VerifyEvent;\r
+import org.eclipse.swt.graphics.Point;\r
+import org.eclipse.swt.widgets.Composite;\r
+import org.eclipse.swt.widgets.Label;\r
+import org.eclipse.swt.widgets.Table;\r
+import org.eclipse.swt.widgets.TableItem;\r
+import org.eclipse.ui.IWorkbenchPartReference;\r
+import org.eclipse.ui.IWorkbenchSite;\r
+import org.simantics.browsing.ui.platform.PropertyPageView;\r
+import org.simantics.browsing.ui.swt.widgets.Button;\r
+import org.simantics.browsing.ui.swt.widgets.TrackedCombo;\r
+import org.simantics.browsing.ui.swt.widgets.impl.ComboModifyListenerImpl;\r
+import org.simantics.browsing.ui.swt.widgets.impl.ReadFactoryImpl;\r
+import org.simantics.browsing.ui.swt.widgets.impl.SelectionListenerImpl;\r
+import org.simantics.browsing.ui.swt.widgets.impl.TextModifyListener;\r
+import org.simantics.browsing.ui.swt.widgets.impl.TrackedModifyEvent;\r
+import org.simantics.browsing.ui.swt.widgets.impl.Widget;\r
+import org.simantics.browsing.ui.swt.widgets.impl.WidgetSupport;\r
+import org.simantics.browsing.ui.swt.widgets.impl.WidgetSupportImpl;\r
+import org.simantics.db.AsyncReadGraph;\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.Session;\r
+import org.simantics.db.VirtualGraph;\r
+import org.simantics.db.WriteGraph;\r
+import org.simantics.db.common.request.WriteRequest;\r
+import org.simantics.db.common.request.WriteResultRequest;\r
+import org.simantics.db.common.utils.OrderedSetUtils;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.db.management.ISessionContext;\r
+import org.simantics.db.procedure.AsyncListener;\r
+import org.simantics.db.request.Read;\r
+import org.simantics.db.service.VirtualGraphSupport;\r
+import org.simantics.layer0.Layer0;\r
+import org.simantics.sysdyn.SysdynResource;\r
+import org.simantics.sysdyn.ui.properties.widgets.ArrayExpressionCombo;\r
+import org.simantics.sysdyn.ui.properties.widgets.ExpressionTypes;\r
+import org.simantics.sysdyn.ui.properties.widgets.ExpressionTypes.ExpressionType;\r
+import org.simantics.sysdyn.ui.properties.widgets.ExpressionWidget;\r
+import org.simantics.sysdyn.ui.properties.widgets.IsOutputWidget;\r
+import org.simantics.sysdyn.ui.properties.widgets.ShortcutTabWidget;\r
+import org.simantics.sysdyn.ui.properties.widgets.factories.VariableNameValidator;\r
+import org.simantics.ui.SimanticsUI;\r
+import org.simantics.ui.utils.AdaptionUtils;\r
+import org.simantics.utils.datastructures.Pair;\r
+\r
+public class EquationTab extends LabelPropertyTabContributor implements Widget {\r
+\r
+ TrackedCombo expressionTypeCombo, unitCombo, arrayEquationCombo;\r
+ ShortcutTabWidget shortcutTabWidget;\r
+ ExpressionWidget expressionWidget;\r
+ org.eclipse.ui.IPartListener2 focusLostListener; \r
+ IWorkbenchSite site;\r
+ WidgetSupport support;\r
+ Button deleteExpression, newExpression;\r
+\r
+ WidgetSupportImpl expressionSupport = new WidgetSupportImpl();\r
+\r
+ @Override\r
+ public void createControls(Composite body, IWorkbenchSite site, ISessionContext context, WidgetSupport support) {\r
+ this.site = site;\r
+ this.support = support;\r
+ support.register(this);\r
+\r
+ Composite composite = new Composite(body, SWT.NONE);\r
+ GridDataFactory.fillDefaults().grab(true, true).applyTo(composite);\r
+ GridLayoutFactory.fillDefaults().margins(3, 3).numColumns(2).applyTo(composite);\r
+\r
+ Composite nameAndEquations = new Composite(composite, SWT.NONE);\r
+ GridDataFactory.fillDefaults().grab(true, false).applyTo(nameAndEquations);\r
+ GridLayoutFactory.fillDefaults().numColumns(2).applyTo(nameAndEquations);\r
+\r
+ Composite nameComposite = new Composite(nameAndEquations, SWT.NONE);\r
+ GridLayoutFactory.fillDefaults().numColumns(3).applyTo(nameComposite);\r
+ GridDataFactory.fillDefaults().grab(true, false).applyTo(nameComposite);\r
+\r
+ arrayEquationCombo = new ArrayExpressionCombo(nameComposite, support, SWT.DROP_DOWN | SWT.BORDER);\r
+ arrayEquationCombo.setInputValidator(new VariableNameValidator(support));\r
+ GridDataFactory.fillDefaults().grab(true, false).applyTo(arrayEquationCombo.getWidget());\r
+ \r
+ deleteExpression = new Button(nameComposite, support, SWT.NONE);\r
+ deleteExpression.setText("Delete");\r
+ GridDataFactory.fillDefaults().applyTo(deleteExpression.getWidget());\r
+\r
+ newExpression = new Button(nameComposite, support, SWT.NONE);\r
+ newExpression.setText("New");\r
+ GridDataFactory.fillDefaults().applyTo(newExpression.getWidget());\r
+ /*\r
+ TrackedText nameText = new TrackedText(nameAndEquations, support, SWT.BORDER);\r
+ nameText.setTextFactory(new StringPropertyFactory(Layer0.URIs.HasName));\r
+ nameText.addModifyListener(new VariableNamePropertyModifier(context, Layer0.URIs.HasName));\r
+ nameText.setInputValidator(new VariableNameValidator(support));\r
+ GridDataFactory.fillDefaults().grab(true, false).span(2,1).applyTo(nameText.getWidget());\r
+ */\r
+\r
+ shortcutTabWidget = new ShortcutTabWidget(composite, support, SWT.NONE);\r
+ GridDataFactory.fillDefaults().span(1, 3).grab(false, true).applyTo(shortcutTabWidget.getWidget());\r
+\r
+\r
+ Composite TypeAndUnit = new Composite(composite, SWT.NONE);\r
+ GridDataFactory.fillDefaults().grab(true, false).applyTo(TypeAndUnit);\r
+ GridLayoutFactory.fillDefaults().numColumns(5).applyTo(TypeAndUnit);\r
+\r
+ Label label = new Label(TypeAndUnit, SWT.SINGLE );\r
+ label.setText("Type:");\r
+ GridDataFactory.fillDefaults().align(SWT.END, SWT.CENTER).applyTo(label);\r
+\r
+ expressionTypeCombo = new TrackedCombo(TypeAndUnit, support, SWT.DROP_DOWN | SWT.BORDER | SWT.READ_ONLY);\r
+ GridDataFactory.fillDefaults().applyTo(expressionTypeCombo.getWidget());\r
+\r
+ label = new Label(TypeAndUnit, SWT.SINGLE );\r
+ label.setText("Unit:");\r
+ GridDataFactory.fillDefaults().align(SWT.END, SWT.CENTER).applyTo(label);\r
+\r
+\r
+ unitCombo = new TrackedCombo(TypeAndUnit, support, SWT.DROP_DOWN | SWT.BORDER);\r
+ GridDataFactory.fillDefaults().applyTo(unitCombo.getWidget());\r
+\r
+ IsOutputWidget isOutput = new IsOutputWidget(TypeAndUnit, support, SWT.NULL);\r
+ GridDataFactory.fillDefaults().grab(true, false).align(SWT.END, SWT.FILL).applyTo(isOutput.getWidget());\r
+\r
+\r
+ Composite expressionComposite = new Composite(composite, SWT.NONE);\r
+ GridDataFactory.fillDefaults().grab(true, true).applyTo(expressionComposite);\r
+ expressionWidget = new ExpressionWidget(expressionComposite, expressionSupport, SWT.NONE);\r
+ expressionWidget.setVariableTable(shortcutTabWidget.getVariableTable());\r
+\r
+ addListeners(context);\r
+ }\r
+\r
+ @Override\r
+ public void setInput(ISessionContext context, final Object input) {\r
+ final Resource variable = AdaptionUtils.adaptToSingle(input, Resource.class);\r
+ Resource expression = null;\r
+ try {\r
+ expression = SimanticsUI.getSession().syncRequest(new Read<Resource>() {\r
+\r
+ @Override\r
+ public Resource perform(ReadGraph graph) throws DatabaseException {\r
+ return getActiveExpression(graph, AdaptionUtils.adaptToSingle(input, Resource.class));\r
+ }\r
+ });\r
+ } catch (DatabaseException e) {\r
+ e.printStackTrace();\r
+ }\r
+ // No expressions -> creating a new ordered set expressions and the active expression\r
+ if(expression == null && variable != null) {\r
+ try {\r
+ expression = SimanticsUI.getSession().syncRequest(new WriteResultRequest<Resource>() {\r
+\r
+ @Override\r
+ public Resource perform(WriteGraph graph)\r
+ throws DatabaseException {\r
+ SysdynResource sr = SysdynResource.getInstance(graph);\r
+ Layer0 l0 = Layer0.getInstance(graph);\r
+ Resource expressions = OrderedSetUtils.create(graph, sr.Expressions);\r
+ graph.claim(variable, sr.HasExpressions, expressions);\r
+ final Resource expression = graph.newResource();\r
+\r
+ if(graph.isInstanceOf(variable, sr.Auxiliary) ||\r
+ graph.isInstanceOf(variable, sr.Valve)) {\r
+ graph.claim(expression, l0.InstanceOf, null, sr.NormalExpression);\r
+ graph.claimLiteral(expression, sr.HasEquation, "");\r
+ }\r
+ else if(graph.isInstanceOf(variable, sr.Stock)) {\r
+ graph.claim(expression, l0.InstanceOf, null, sr.StockExpression);\r
+ graph.claimLiteral(expression, sr.HasInitialEquation, "");\r
+ }\r
+ OrderedSetUtils.add(graph, expressions, expression);\r
+\r
+ VirtualGraphSupport support = graph.getService(VirtualGraphSupport.class);\r
+ final Session session = graph.getSession();\r
+ session.asyncRequest(new WriteRequest(support.getWorkspacePersistent("expressions")) {\r
+ @Override\r
+ public void perform(WriteGraph graph) throws DatabaseException {\r
+ VirtualGraph runtime = graph.getService(VirtualGraph.class);\r
+ session.asyncRequest(new WriteRequest(runtime) {\r
+ @Override\r
+ public void perform(WriteGraph graph) throws DatabaseException {\r
+ SysdynResource sr = SysdynResource.getInstance(graph);\r
+ if(graph.hasStatement(variable, sr.HasActiveExpression))\r
+ graph.deny(variable, sr.HasActiveExpression);\r
+ graph.claim(variable, sr.HasActiveExpression, expression);\r
+ }\r
+ }\r
+ );\r
+ }\r
+ });\r
+ return expression;\r
+ }\r
+ });\r
+ } catch (DatabaseException e) {\r
+ e.printStackTrace();\r
+ }\r
+ }\r
+\r
+\r
+ SimanticsUI.getSession().asyncRequest(new Read<Pair<Boolean, Boolean>>() {\r
+\r
+ @Override\r
+ public Pair<Boolean, Boolean> perform(ReadGraph graph) throws DatabaseException {\r
+ SysdynResource sr = SysdynResource.getInstance(graph);\r
+ Resource expressions = graph.getPossibleObject(variable, sr.HasExpressions);\r
+ if(expressions == null) {\r
+ return new Pair<Boolean, Boolean>(false, false);\r
+ }\r
+ List<Resource> expressionList = OrderedSetUtils.toList(graph, expressions);\r
+ if(expressionList.isEmpty()) {\r
+ return new Pair<Boolean, Boolean>(false, false);\r
+ }\r
+\r
+ boolean canAdd = true;\r
+ boolean canDelete = false;\r
+ if(expressionList.size() > 1)\r
+ canDelete = true;\r
+ String defaultRange = ArrayExpressionCombo.getDefaultRange(graph, variable);\r
+\r
+ for(Resource expression : expressionList) {\r
+ String range = graph.getPossibleRelatedValue(expression, sr.HasArrayRange);\r
+ if(range == null || range.equals("") || range.equals(defaultRange)) {\r
+ canAdd = false;\r
+ break;\r
+ }\r
+ }\r
+ return new Pair<Boolean, Boolean>(canAdd, canDelete);\r
+ }\r
+ }, new AsyncListener<Pair<Boolean, Boolean>>() {\r
+\r
+ @Override\r
+ public void execute(AsyncReadGraph graph,\r
+ final Pair<Boolean, Boolean> result) {\r
+ newExpression.getWidget().getDisplay().asyncExec(new Runnable() {\r
+ \r
+ @Override\r
+ public void run() {\r
+ if(!newExpression.getWidget().isDisposed())\r
+ newExpression.getWidget().setEnabled(result.first);\r
+ if(!deleteExpression.getWidget().isDisposed())\r
+ deleteExpression.getWidget().setEnabled(result.second); \r
+ }\r
+ });\r
+\r
+ }\r
+\r
+ @Override\r
+ public void exception(AsyncReadGraph graph, Throwable throwable) {\r
+ throwable.printStackTrace();\r
+ }\r
+\r
+ @Override\r
+ public boolean isDisposed() {\r
+ return newExpression.getWidget().isDisposed() || deleteExpression.getWidget().isDisposed();\r
+ }\r
+ });\r
+\r
+ StructuredSelection ss = new StructuredSelection(expression);\r
+ expressionSupport.fireInput(context, ss);\r
+ }\r
+\r
+ private void addListeners(ISessionContext context) {\r
+\r
+ shortcutTabWidget.addDependencyListener(new Runnable() {\r
+ \r
+ @Override\r
+ public void run() {\r
+ expressionWidget.validateFields();\r
+ }\r
+ });\r
+ \r
+ deleteExpression.addSelectionListener(new SelectionListenerImpl<Resource>(context) {\r
+\r
+ @Override\r
+ public void apply(WriteGraph graph, final Resource input)\r
+ throws DatabaseException {\r
+\r
+ SysdynResource sr = SysdynResource.getInstance(graph);\r
+ Resource activeExpression = graph.getPossibleObject(input, sr.HasActiveExpression);\r
+ if(activeExpression == null)\r
+ return;\r
+\r
+ Resource expressionList = OrderedSetUtils.getSingleOwnerList(graph, activeExpression);\r
+ if(OrderedSetUtils.toList(graph, expressionList).size() <= 1)\r
+ return;\r
+\r
+ Resource prev = OrderedSetUtils.prev(graph, expressionList, activeExpression);\r
+ OrderedSetUtils.remove(graph, expressionList, activeExpression);\r
+ if(prev.equals(expressionList)) {\r
+ Iterator<Resource> iterator = OrderedSetUtils.iterator(graph, expressionList);\r
+ prev = iterator.next();\r
+ }\r
+\r
+ final Resource newActive = prev;\r
+ VirtualGraphSupport support = graph.getService(VirtualGraphSupport.class);\r
+ final Session session = graph.getSession();\r
+ session.asyncRequest(new WriteRequest(support.getWorkspacePersistent("expressions")) {\r
+ @Override\r
+ public void perform(WriteGraph graph) throws DatabaseException {\r
+ VirtualGraph runtime = graph.getService(VirtualGraph.class);\r
+ session.asyncRequest(new WriteRequest(runtime) {\r
+ @Override\r
+ public void perform(WriteGraph graph) throws DatabaseException {\r
+ SysdynResource sr = SysdynResource.getInstance(graph);\r
+ if(graph.hasStatement(input, sr.HasActiveExpression))\r
+ graph.deny(input, sr.HasActiveExpression);\r
+ graph.claim(input, sr.HasActiveExpression, newActive);\r
+ }\r
+ }\r
+ );\r
+ }\r
+ });\r
+ }\r
+ });\r
+\r
+ newExpression.addSelectionListener(new SelectionListenerImpl<Resource>(context) {\r
+\r
+ @Override\r
+ public void apply(WriteGraph graph, Resource input)\r
+ throws DatabaseException {\r
+ SysdynResource sr = SysdynResource.getInstance(graph);\r
+ Layer0 l0 = Layer0.getInstance(graph);\r
+\r
+ Resource expressions = graph.getPossibleObject(input, sr.HasExpressions);\r
+ if(expressions == null) {\r
+ return;\r
+ }\r
+ Resource activeExpression = graph.getPossibleObject(input, sr.HasActiveExpression);\r
+ Resource newExpression = graph.newResource();\r
+ if(activeExpression != null) {\r
+ graph.claim(newExpression, l0.InstanceOf, graph.getSingleObject(activeExpression, l0.InstanceOf));\r
+ if(graph.isInstanceOf(newExpression, sr.StockExpression)) {\r
+ graph.claimLiteral(newExpression, sr.HasInitialEquation, "");\r
+ }\r
+ } else {\r
+ graph.claim(newExpression, l0.InstanceOf, sr.NormalExpression);\r
+ }\r
+ OrderedSetUtils.add(graph, expressions, newExpression);\r
+ }\r
+ });\r
+\r
+ expressionTypeCombo.setItemFactory(new ReadFactoryImpl<Resource, Map<String,Object>>() {\r
+\r
+ @Override\r
+ public Map<String, Object> perform(ReadGraph graph, final Resource input) throws DatabaseException {\r
+\r
+ Map<String, Object> map = new HashMap<String, Object>();\r
+ SysdynResource sr = SysdynResource.getInstance(graph);\r
+\r
+ final ExpressionType[] expressionTypes;\r
+ if(graph.isInstanceOf(input, sr.Auxiliary))\r
+ expressionTypes = ExpressionTypes.auxiliaryExpressions;\r
+ else if(graph.isInstanceOf(input, sr.Stock))\r
+ expressionTypes = ExpressionTypes.stockExpressions;\r
+ else if(graph.isInstanceOf(input, sr.Valve))\r
+ expressionTypes = ExpressionTypes.valveExpressions;\r
+ else\r
+ expressionTypes = new ExpressionType[] {};\r
+\r
+ for(ExpressionType et : expressionTypes) {\r
+ map.put(et.toString(), et);\r
+ }\r
+ return map;\r
+ }\r
+ });\r
+\r
+ expressionTypeCombo.setSelectionFactory(new ReadFactoryImpl<Resource, String>() {\r
+\r
+ @Override\r
+ public String perform(ReadGraph graph, final Resource input) throws DatabaseException {\r
+ Resource activeExpression = getActiveExpression(graph, input);\r
+ if(activeExpression == null)\r
+ return null;\r
+ return ExpressionTypes.getExpressionType(graph, activeExpression).toString();\r
+ }\r
+ });\r
+\r
+ expressionTypeCombo.addModifyListener(new TextModifyListener() {\r
+\r
+ @Override\r
+ public void modifyText(TrackedModifyEvent e) {\r
+ expressionWidget.displayExpression(e.getText(), false);\r
+ expressionWidget.save(); \r
+ }\r
+ });\r
+\r
+\r
+ unitCombo.setItemFactory(new ReadFactoryImpl<Resource, Map<String,Object>>() {\r
+\r
+ @Override\r
+ public Map<String, Object> perform(ReadGraph graph, final Resource input) throws DatabaseException {\r
+ Map<String, Object> map = new HashMap<String, Object>();\r
+\r
+ SysdynResource sr = SysdynResource.getInstance(graph);\r
+ Layer0 l0 = Layer0.getInstance(graph);\r
+ Resource model = graph.getPossibleObject(input, l0.PartOf);\r
+ if (model != null) {\r
+ Collection<Resource> variables = graph.getObjects(model, l0.ConsistsOf);\r
+ for(Resource v : variables) {\r
+ Object unit = graph.getPossibleRelatedValue(v, sr.HasUnit);\r
+ if (unit != null && !map.keySet().contains((String) unit)) {\r
+ map.put((String)unit, (String)unit);\r
+\r
+ }\r
+ }\r
+ }\r
+ return map;\r
+ }\r
+ });\r
+ unitCombo.setSelectionFactory(new ReadFactoryImpl<Resource, String>() {\r
+\r
+ @Override\r
+ public String perform(ReadGraph graph, final Resource input) throws DatabaseException {\r
+ String unit = graph.getPossibleRelatedValue(input, SysdynResource.getInstance(graph).HasUnit);\r
+ if(unit == null)\r
+ return "";\r
+ else \r
+ return unit;\r
+ }\r
+ });\r
+\r
+ unitCombo.addModifyListener(new ComboModifyListenerImpl<Resource>() {\r
+\r
+ @Override\r
+ public void applyText(WriteGraph graph, Resource input, String text) throws DatabaseException {\r
+ graph.claimLiteral(input, SysdynResource.getInstance(graph).HasUnit, text);\r
+ }\r
+ });\r
+\r
+\r
+ shortcutTabWidget.addMouseListener(new MouseListener(){\r
+\r
+ @Override\r
+ public void mouseDoubleClick(MouseEvent e) {\r
+ Table table = (Table)e.widget;\r
+ TableItem item = table.getItem(new Point(e.x, e.y));\r
+ if(item != null) {\r
+ final String var = (String)item.getData();\r
+ table.getDisplay().asyncExec(new Runnable() {\r
+\r
+ @Override\r
+ public void run() {\r
+ if(expressionWidget!= null) {\r
+ expressionWidget.getExpression().replaceSelection(var);\r
+ expressionWidget.getExpression().focus();\r
+ expressionWidget.validateFieldsTimed();\r
+ }\r
+ }\r
+ });\r
+ }\r
+ }\r
+\r
+ @Override\r
+ public void mouseDown(MouseEvent e) {\r
+ expressionWidget.getExpression().focus();\r
+ }\r
+\r
+ @Override\r
+ public void mouseUp(MouseEvent e) {\r
+ }\r
+\r
+ });\r
+ shortcutTabWidget.addFocusListener(new FocusListener() {\r
+\r
+ @Override\r
+ public void focusGained(FocusEvent e) { \r
+ }\r
+\r
+ @Override\r
+ public void focusLost(FocusEvent e) {\r
+ ((Table)e.widget).deselectAll();\r
+ }\r
+\r
+ });\r
+\r
+ expressionWidget.addModifyListener(new ModifyListener() {\r
+\r
+ @Override\r
+ public void modifyText(ModifyEvent e) {\r
+ expressionWidget.validateFieldsTimed();\r
+ }\r
+ });\r
+\r
+ expressionWidget.addVerifyKeyListener(new VerifyKeyListener() {\r
+\r
+ @Override\r
+ public void verifyKey(VerifyEvent event) {\r
+ if(event.keyCode == SWT.CR || event.keyCode == SWT.KEYPAD_CR) {\r
+ if((event.stateMask & SWT.SHIFT) == 0) {\r
+ event.doit = false;\r
+ ((StyledText)event.widget).getParent().forceFocus();\r
+ expressionWidget.save();\r
+ }\r
+ }\r
+ }\r
+ });\r
+\r
+ if(focusLostListener == null) {\r
+ focusLostListener = new org.eclipse.ui.IPartListener2()\r
+ {\r
+ public void partInputChanged(IWorkbenchPartReference partRef) {}\r
+ public void partVisible(IWorkbenchPartReference partRef) {}\r
+ public void partHidden(IWorkbenchPartReference partRef) {}\r
+ public void partOpened(IWorkbenchPartReference partRef) {}\r
+ public void partDeactivated(IWorkbenchPartReference partRef)\r
+ {\r
+ if(partRef.getPart(false) instanceof PropertyPageView) {\r
+ PropertyPageView ppv = (PropertyPageView)partRef.getPart(false);\r
+ if(ppv.getCurrentPage() instanceof SysdynPropertyPage) {\r
+ // Save expressions\r
+ if(expressionWidget != null) {\r
+ expressionWidget.save();\r
+ }\r
+ site.getPage().removePartListener(this);\r
+ }\r
+ }\r
+ }\r
+ public void partClosed(IWorkbenchPartReference partRef) {}\r
+ public void partBroughtToTop(IWorkbenchPartReference partRef) {}\r
+ public void partActivated(IWorkbenchPartReference partRef) {}\r
+ };\r
+ site.getPage().addPartListener(focusLostListener);\r
+ }\r
+ }\r
+\r
+ @Override\r
+ public void dispose() {\r
+ if(focusLostListener != null && site != null)\r
+ site.getPage().removePartListener(focusLostListener);\r
+ super.dispose();\r
+ }\r
+\r
+ private Resource getActiveExpression(ReadGraph graph, Resource variable) throws DatabaseException {\r
+ SysdynResource sr = SysdynResource.getInstance(graph);\r
+ Resource expression = graph.getPossibleObject(variable, sr.HasActiveExpression);\r
+ if(expression == null) {\r
+ Resource expressions = graph.getPossibleObject(variable, sr.HasExpressions);\r
+ if(expressions == null) {\r
+ return null;\r
+ }\r
+ List<Resource> expressionList = OrderedSetUtils.toList(graph, expressions);\r
+ if(expressionList.isEmpty()) {\r
+ return null;\r
+ }\r
+ expression = expressionList.get(0);\r
+ }\r
+ return expression;\r
+ }\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2010 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.ui.properties;\r
+\r
+import org.eclipse.swt.widgets.Composite;\r
+import org.eclipse.ui.IWorkbenchSite;\r
+import org.simantics.browsing.ui.swt.widgets.impl.WidgetSupport;\r
+import org.simantics.db.management.ISessionContext;\r
+\r
+public class ExperimentTab extends LabelPropertyTabContributor {\r
+\r
+ @Override\r
+ public void createControls(Composite body, IWorkbenchSite site, ISessionContext context, WidgetSupport support) {\r
+ \r
+ }\r
+\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2011 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.ui.properties;\r
+\r
+import org.eclipse.jface.layout.GridDataFactory;\r
+import org.eclipse.jface.layout.GridLayoutFactory;\r
+import org.eclipse.swt.SWT;\r
+import org.eclipse.swt.widgets.Composite;\r
+import org.eclipse.swt.widgets.Control;\r
+import org.eclipse.swt.widgets.Shell;\r
+import org.eclipse.swt.widgets.Tree;\r
+import org.eclipse.ui.IWorkbenchSite;\r
+import org.simantics.browsing.ui.swt.SingleSelectionInputSource;\r
+import org.simantics.browsing.ui.swt.widgets.Button;\r
+import org.simantics.browsing.ui.swt.widgets.GraphExplorerComposite;\r
+import org.simantics.browsing.ui.swt.widgets.impl.SelectionListenerImpl;\r
+import org.simantics.browsing.ui.swt.widgets.impl.Widget;\r
+import org.simantics.browsing.ui.swt.widgets.impl.WidgetSupport;\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.WriteGraph;\r
+import org.simantics.db.common.request.WriteRequest;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.db.management.ISessionContext;\r
+import org.simantics.sysdyn.ui.handlers.ImportExternalFunctionFilesHandler;\r
+import org.simantics.ui.SimanticsUI;\r
+import org.simantics.utils.datastructures.ArrayMap;\r
+import org.simantics.utils.datastructures.Pair;\r
+\r
+public class ExternalFilesTab extends LabelPropertyTabContributor implements Widget {\r
+\r
+ GraphExplorerComposite externalFilesExplorer;\r
+ Button importButton; \r
+ \r
+ @Override\r
+ public void createControls(Composite body, IWorkbenchSite site,\r
+ final ISessionContext context, WidgetSupport support) {\r
+ support.register(this);\r
+ \r
+ Composite composite = new Composite(body, SWT.NONE);\r
+ GridDataFactory.fillDefaults().grab(true, true).applyTo(composite);\r
+ GridLayoutFactory.fillDefaults().margins(3, 3).applyTo(composite);\r
+ \r
+ externalFilesExplorer = new GraphExplorerComposite(ArrayMap.keys(\r
+ "displaySelectors", "displayFilter").values(false, false), site, composite, SWT.FULL_SELECTION | SWT.BORDER | SWT.MULTI);\r
+ \r
+ externalFilesExplorer\r
+ .setBrowseContexts("http://www.simantics.org/Sysdyn-1.0/ExternalFiles");\r
+ externalFilesExplorer.setInputSource(new SingleSelectionInputSource(\r
+ Resource.class));\r
+\r
+ externalFilesExplorer.setContextMenuId("#ExternalFunctionFileBrowser");\r
+ externalFilesExplorer.finish();\r
+\r
+ GridDataFactory.fillDefaults().grab(true, true).applyTo(\r
+ externalFilesExplorer);\r
+ \r
+ Control c = externalFilesExplorer.getExplorerControl();\r
+ if (c instanceof Tree)\r
+ ((Tree) c).setLinesVisible(true);\r
+ \r
+ importButton = new Button(composite, support, SWT.NONE);\r
+ importButton.setText("Import");\r
+ importButton.addSelectionListener(new SelectionListenerImpl<Resource>(context) {\r
+\r
+ @Override\r
+ public void apply(WriteGraph graph, final Resource input)\r
+ throws DatabaseException {\r
+ \r
+ importButton.getWidget().getDisplay().asyncExec(new Runnable() {\r
+ \r
+ @Override\r
+ public void run() {\r
+ Shell shell = importButton.getWidget().getShell();\r
+ \r
+ final Pair<String, String[]> importedFiles = ImportExternalFunctionFilesHandler.importFiles(shell, "Import files", ImportExternalFunctionFilesHandler.C_EXTENSIONS);\r
+ \r
+ SimanticsUI.getSession().asyncRequest(new WriteRequest() {\r
+ \r
+ @Override\r
+ public void perform(WriteGraph graph) throws DatabaseException {\r
+ ImportExternalFunctionFilesHandler.addFilesToFunction(graph, input, importedFiles);\r
+ }\r
+ });\r
+ }\r
+ });\r
+ \r
+ \r
+ }\r
+ });\r
+ \r
+ }\r
+\r
+ @Override\r
+ public void setInput(ISessionContext context, Object input) {\r
+ externalFilesExplorer.setInput(context, input);\r
+ }\r
+\r
+\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2011 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.ui.properties;\r
+\r
+import org.eclipse.jface.layout.GridDataFactory;\r
+import org.eclipse.jface.layout.GridLayoutFactory;\r
+import org.eclipse.swt.SWT;\r
+import org.eclipse.swt.widgets.Composite;\r
+import org.eclipse.ui.IWorkbenchSite;\r
+import org.simantics.browsing.ui.swt.widgets.StringPropertyFactory;\r
+import org.simantics.browsing.ui.swt.widgets.StringPropertyModifier;\r
+import org.simantics.browsing.ui.swt.widgets.TrackedText;\r
+import org.simantics.browsing.ui.swt.widgets.impl.WidgetSupport;\r
+import org.simantics.db.management.ISessionContext;\r
+import org.simantics.layer0.Layer0;\r
+\r
+public class FunctionLibraryTab extends LabelPropertyTabContributor {\r
+\r
+ @Override\r
+ public void createControls(Composite body, IWorkbenchSite site,\r
+ ISessionContext context, WidgetSupport support) {\r
+ Composite composite = new Composite(body, SWT.NONE);\r
+ GridDataFactory.fillDefaults().grab(true, true).applyTo(composite);\r
+ GridLayoutFactory.fillDefaults().margins(3, 3).applyTo(composite);\r
+\r
+\r
+ TrackedText nameText = new TrackedText(composite, support, SWT.BORDER);\r
+ nameText.setTextFactory(new StringPropertyFactory(Layer0.URIs.HasName));\r
+ nameText.addModifyListener(new StringPropertyModifier(context, Layer0.URIs.HasName));\r
+ GridDataFactory.fillDefaults().grab(true, false).applyTo(nameText.getWidget());\r
+\r
+\r
+ TrackedText information = new TrackedText(composite, support, SWT.BORDER | SWT.MULTI | SWT.V_SCROLL | SWT.WRAP);\r
+ information.setTextFactory(new StringPropertyFactory(Layer0.URIs.HasDescription));\r
+ information.addModifyListener(new StringPropertyModifier(context, Layer0.URIs.HasDescription));\r
+ GridDataFactory.fillDefaults().grab(true, true).applyTo(information.getWidget());\r
+ }\r
+\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2011 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.ui.properties;\r
+\r
+import org.eclipse.jface.layout.GridDataFactory;\r
+import org.eclipse.jface.layout.GridLayoutFactory;\r
+import org.eclipse.swt.SWT;\r
+import org.eclipse.swt.widgets.Composite;\r
+import org.eclipse.swt.widgets.Group;\r
+import org.eclipse.ui.IWorkbenchSite;\r
+import org.simantics.browsing.ui.swt.widgets.Label;\r
+import org.simantics.browsing.ui.swt.widgets.StringPropertyFactory;\r
+import org.simantics.browsing.ui.swt.widgets.StringPropertyModifier;\r
+import org.simantics.browsing.ui.swt.widgets.TrackedText;\r
+import org.simantics.browsing.ui.swt.widgets.impl.TextModifyListenerImpl;\r
+import org.simantics.browsing.ui.swt.widgets.impl.WidgetSupport;\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.WriteGraph;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.db.management.ISessionContext;\r
+import org.simantics.layer0.Layer0;\r
+import org.simantics.sysdyn.SysdynResource;\r
+import org.simantics.sysdyn.manager.FunctionUtils;\r
+import org.simantics.sysdyn.ui.properties.widgets.FunctionLabelFactory;\r
+\r
+public class FunctionTab extends LabelPropertyTabContributor {\r
+\r
+ @Override\r
+ public void createControls(Composite body, IWorkbenchSite site,\r
+ ISessionContext context, WidgetSupport support) {\r
+ \r
+ Composite composite = new Composite(body, SWT.NONE);\r
+ GridDataFactory.fillDefaults().grab(true, true).applyTo(composite);\r
+ GridLayoutFactory.fillDefaults().numColumns(2).margins(3, 3).applyTo(composite);\r
+\r
+ TrackedText nameText = new TrackedText(composite, support, SWT.BORDER);\r
+ nameText.setTextFactory(new StringPropertyFactory(Layer0.URIs.HasName));\r
+ nameText.addModifyListener(new StringPropertyModifier(context, Layer0.URIs.HasName));\r
+ nameText.addModifyListener(new TextModifyListenerImpl<Resource>() {\r
+\r
+ @Override\r
+ public void applyText(WriteGraph graph, Resource input, String text)\r
+ throws DatabaseException {\r
+ Resource library = graph.getSingleObject(input, Layer0.getInstance(graph).PartOf);\r
+ FunctionUtils.updateFunctionFileForLibrary(graph, library);\r
+ }\r
+ });\r
+ GridDataFactory.fillDefaults().span(2, 1).grab(true, false).applyTo(nameText.getWidget());\r
+ \r
+ \r
+ Group modelicaGroup = new Group(composite, SWT.SHADOW_ETCHED_IN);\r
+ modelicaGroup.setText("Modelica code");\r
+ GridDataFactory.fillDefaults().grab(true, true).applyTo(modelicaGroup);\r
+ GridLayoutFactory.fillDefaults().spacing(0, 0).margins(3, 3).applyTo(modelicaGroup);\r
+ \r
+ Label startLabel = new Label(modelicaGroup, support, SWT.NONE);\r
+ startLabel.setTextFactory(new FunctionLabelFactory(Layer0.URIs.HasName, false));\r
+ TrackedText modelicaCode = new TrackedText(modelicaGroup, support, SWT.MULTI | SWT.BORDER | SWT.V_SCROLL | SWT.WRAP);\r
+ modelicaCode.setTextFactory(new StringPropertyFactory(SysdynResource.URIs.HasModelicaFunctionCode));\r
+ modelicaCode.addModifyListener(new StringPropertyModifier(context, SysdynResource.URIs.HasModelicaFunctionCode));\r
+ modelicaCode.addModifyListener(new TextModifyListenerImpl<Resource>() {\r
+\r
+ @Override\r
+ public void applyText(WriteGraph graph, Resource input, String text)\r
+ throws DatabaseException {\r
+ Resource library = graph.getSingleObject(input, Layer0.getInstance(graph).PartOf);\r
+ FunctionUtils.updateFunctionFileForLibrary(graph, library);\r
+ }\r
+ });\r
+ \r
+ GridDataFactory.fillDefaults().grab(true, true).applyTo(modelicaCode.getWidget());\r
+ Label endLabel = new Label(modelicaGroup, support, SWT.NONE);\r
+ endLabel.setTextFactory(new FunctionLabelFactory(Layer0.URIs.HasName, true));\r
+\r
+ Group documentationGroup = new Group(composite, SWT.SHADOW_ETCHED_IN);\r
+ documentationGroup.setText("Documentation");\r
+ GridDataFactory.fillDefaults().grab(true, true).applyTo(documentationGroup);\r
+ GridLayoutFactory.fillDefaults().spacing(0, 0).margins(3, 3).applyTo(documentationGroup);\r
+\r
+ TrackedText information = new TrackedText(documentationGroup, support, SWT.MULTI | SWT.V_SCROLL | SWT.WRAP);\r
+ information.setTextFactory(new StringPropertyFactory(Layer0.URIs.HasDescription));\r
+ information.addModifyListener(new StringPropertyModifier(context, Layer0.URIs.HasDescription));\r
+ GridDataFactory.fillDefaults().grab(true, true).applyTo(information.getWidget());\r
+ }\r
+\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2010 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.ui.properties;\r
+\r
+\r
+import org.eclipse.jface.dialogs.IInputValidator;\r
+import org.eclipse.jface.layout.GridDataFactory;\r
+import org.eclipse.jface.layout.GridLayoutFactory;\r
+import org.eclipse.swt.SWT;\r
+import org.eclipse.swt.widgets.Composite;\r
+import org.eclipse.swt.widgets.Label;\r
+import org.eclipse.ui.IWorkbenchSite;\r
+import org.simantics.browsing.ui.swt.widgets.StringPropertyFactory;\r
+import org.simantics.browsing.ui.swt.widgets.TrackedText;\r
+import org.simantics.browsing.ui.swt.widgets.impl.WidgetSupport;\r
+import org.simantics.db.management.ISessionContext;\r
+import org.simantics.layer0.Layer0;\r
+import org.simantics.sysdyn.SysdynResource;\r
+import org.simantics.sysdyn.ui.properties.widgets.IsOutputWidget;\r
+import org.simantics.sysdyn.ui.properties.widgets.factories.DoublePropertyFactory;\r
+import org.simantics.sysdyn.ui.properties.widgets.factories.DoublePropertyModifier;\r
+import org.simantics.sysdyn.ui.properties.widgets.factories.VariableNamePropertyModifier;\r
+import org.simantics.sysdyn.ui.properties.widgets.factories.VariableNameValidator;\r
+\r
+public class InputVariableTab extends LabelPropertyTabContributor {\r
+\r
+ \r
+ @Override\r
+ public void createControls(Composite body, IWorkbenchSite site, ISessionContext context, WidgetSupport support) {\r
+ Composite composite = new Composite(body, SWT.NONE);\r
+ GridDataFactory.fillDefaults().hint(200, SWT.DEFAULT).grab(false, true).applyTo(composite);\r
+ GridLayoutFactory.fillDefaults().margins(3, 3).applyTo(composite);\r
+\r
+ TrackedText nameText = new TrackedText(composite, support, SWT.BORDER);\r
+ nameText.setTextFactory(new StringPropertyFactory(Layer0.URIs.HasName));\r
+ nameText.addModifyListener(new VariableNamePropertyModifier(context, Layer0.URIs.HasName));\r
+ nameText.setInputValidator(new VariableNameValidator(support));\r
+ GridDataFactory.fillDefaults().grab(true, false).applyTo(nameText.getWidget());\r
+\r
+ Composite defaultValueComposite = new Composite(composite, SWT.NONE);\r
+ GridDataFactory.fillDefaults().grab(false, true).applyTo(defaultValueComposite);\r
+ GridLayoutFactory.fillDefaults().numColumns(2).applyTo(defaultValueComposite);\r
+ \r
+ Label label = new Label(defaultValueComposite, SWT.NULL);\r
+ label.setText("Default Value:");\r
+ \r
+ TrackedText defaultValue = new TrackedText(defaultValueComposite, support, SWT.RIGHT | SWT.BORDER);\r
+ defaultValue.setTextFactory(new DoublePropertyFactory(SysdynResource.URIs.HasDefaultInputValue));\r
+ defaultValue.addModifyListener(new DoublePropertyModifier(context, SysdynResource.URIs.HasDefaultInputValue));\r
+ defaultValue.setInputValidator(new DoubleValidator());\r
+ GridDataFactory.fillDefaults().grab(true, false).applyTo(defaultValue.getWidget());\r
+\r
+ new IsOutputWidget(composite, support, SWT.NULL);\r
+ }\r
+\r
+ private class DoubleValidator implements IInputValidator {\r
+\r
+ @Override\r
+ public String isValid(String newText) {\r
+ for(int i = 0; i < newText.length(); i++){\r
+ if(!Character.isDigit(newText.charAt(i))){\r
+ if(newText.charAt(i) != '.') {\r
+ return "Invalid character '" + newText.charAt(i) + "'";\r
+ } else if(newText.indexOf('.') != newText.lastIndexOf('.')) {\r
+ return "There can be only one '.'";\r
+ }\r
+ }\r
+ }\r
+ return null;\r
+ }\r
+ }\r
+}\r
--- /dev/null
+package org.simantics.sysdyn.ui.properties;\r
+\r
+import org.eclipse.jface.viewers.ISelection;\r
+import org.simantics.browsing.ui.swt.PropertyTabContributorImpl;\r
+import org.simantics.db.AsyncReadGraph;\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.db.procedure.AsyncListener;\r
+import org.simantics.db.request.Read;\r
+import org.simantics.layer0.Layer0;\r
+import org.simantics.ui.SimanticsUI;\r
+import org.simantics.ui.utils.AdaptionUtils;\r
+import org.simantics.utils.datastructures.Callback;\r
+\r
+public abstract class LabelPropertyTabContributor extends PropertyTabContributorImpl {\r
+\r
+ \r
+ public void updatePartName(ISelection forSelection, final Callback<String> updateCallback) {\r
+ final Resource r = AdaptionUtils.adaptToSingle(forSelection, Resource.class);\r
+ if(r == null) {\r
+ updateCallback.run("Selection properties");\r
+ return;\r
+ }\r
+ \r
+ try {\r
+ SimanticsUI.getSession().syncRequest(new Read<String>() {\r
+\r
+ @Override\r
+ public String perform(ReadGraph graph) throws DatabaseException {\r
+ Layer0 l0 = Layer0.getInstance(graph);\r
+ String label = graph.getPossibleRelatedValue(r, l0.HasLabel);\r
+ if(label != null)\r
+ return label;\r
+ label = graph.getPossibleRelatedValue(r, l0.HasName);\r
+ if(label != null)\r
+ return label;\r
+ return "No name for selection";\r
+ }\r
+ }, new AsyncListener<String>() {\r
+\r
+ @Override\r
+ public void execute(AsyncReadGraph graph, String result) {\r
+ updateCallback.run(result);\r
+ }\r
+\r
+ @Override\r
+ public void exception(AsyncReadGraph graph, Throwable throwable) {\r
+ \r
+ }\r
+\r
+ @Override\r
+ public boolean isDisposed() {\r
+ return false;\r
+ }\r
+ });\r
+ } catch (DatabaseException e) {\r
+ updateCallback.run("Selection error in LabelPropertyTabContributor");\r
+ e.printStackTrace();\r
+ }\r
+ \r
+ }\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2010 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.ui.properties;\r
+\r
+import org.eclipse.jface.layout.GridDataFactory;\r
+import org.eclipse.jface.layout.GridLayoutFactory;\r
+import org.eclipse.swt.SWT;\r
+import org.eclipse.swt.widgets.Composite;\r
+import org.eclipse.swt.widgets.Label;\r
+import org.eclipse.ui.IWorkbenchSite;\r
+import org.simantics.browsing.ui.swt.widgets.TrackedText;\r
+import org.simantics.browsing.ui.swt.widgets.impl.WidgetSupport;\r
+import org.simantics.db.management.ISessionContext;\r
+import org.simantics.sysdyn.SysdynResource;\r
+import org.simantics.sysdyn.ui.properties.widgets.ChartTableWidget;\r
+import org.simantics.sysdyn.ui.properties.widgets.ChartWidget;\r
+import org.simantics.sysdyn.ui.properties.widgets.factories.DoublePropertyFactory;\r
+import org.simantics.sysdyn.ui.properties.widgets.factories.DoublePropertyModifier;\r
+\r
+public class LookupTableTab extends LabelPropertyTabContributor {\r
+ \r
+ @Override\r
+ public void createControls(Composite body, IWorkbenchSite site, ISessionContext context, WidgetSupport support) {\r
+\r
+ \r
+ Composite baseContainer = new Composite(body, SWT.NONE);\r
+ GridLayoutFactory.fillDefaults().margins(3, 3).numColumns(3).applyTo(baseContainer);\r
+ GridDataFactory.fillDefaults().grab(true, true).applyTo(baseContainer);\r
+\r
+ Composite Ycontainer = new Composite(baseContainer, SWT.NONE);\r
+ GridLayoutFactory.fillDefaults().applyTo(Ycontainer);\r
+ GridDataFactory.fillDefaults().grab(false, true).applyTo(Ycontainer);\r
+\r
+ TrackedText maxYText = new TrackedText(Ycontainer, support, SWT.BORDER);\r
+ maxYText.setTextFactory(new DoublePropertyFactory(SysdynResource.URIs.HasMaxY));\r
+ maxYText.addModifyListener(new DoublePropertyModifier(context, SysdynResource.URIs.HasMaxY));\r
+\r
+ Label l = new Label(Ycontainer, SWT.NONE);\r
+ GridDataFactory.fillDefaults().align(SWT.CENTER, SWT.CENTER).grab(false, true).applyTo(l);\r
+\r
+ TrackedText minYText = new TrackedText(Ycontainer, support, SWT.BORDER);\r
+ minYText.setTextFactory(new DoublePropertyFactory(SysdynResource.URIs.HasMinY));\r
+ minYText.addModifyListener(new DoublePropertyModifier(context, SysdynResource.URIs.HasMinY));\r
+\r
+\r
+ Composite chartContainer = new Composite(baseContainer, SWT.NONE);\r
+ GridLayoutFactory.fillDefaults().numColumns(2).applyTo(chartContainer);\r
+ GridDataFactory.fillDefaults().grab(true, true).applyTo(chartContainer);\r
+\r
+ @SuppressWarnings("unused")\r
+ ChartWidget chartWidget = new ChartWidget(chartContainer, support, SWT.NONE);\r
+ \r
+ Composite chartTableContainer = new Composite(baseContainer, SWT.NONE);\r
+ GridLayoutFactory.fillDefaults().applyTo(chartTableContainer);\r
+ GridDataFactory.fillDefaults().grab(false, true).span(1, 2).applyTo(chartTableContainer); \r
+ \r
+ @SuppressWarnings("unused")\r
+ ChartTableWidget chartTableWidget = new ChartTableWidget(chartTableContainer, support, SWT.NONE);\r
+ \r
+ l = new Label(baseContainer, SWT.NONE);\r
+\r
+ Composite Xcontainer = new Composite(baseContainer, SWT.NONE);\r
+ GridLayoutFactory.fillDefaults().numColumns(3).applyTo(Xcontainer);\r
+ GridDataFactory.fillDefaults().grab(true, false).applyTo(Xcontainer);\r
+\r
+ TrackedText minXText = new TrackedText(Xcontainer, support, SWT.BORDER);\r
+ minXText.setTextFactory(new DoublePropertyFactory(SysdynResource.URIs.HasMinX));\r
+ minXText.addModifyListener(new DoublePropertyModifier(context, SysdynResource.URIs.HasMinX));\r
+\r
+ l = new Label(Xcontainer, SWT.NONE);\r
+ GridDataFactory.fillDefaults().align(SWT.CENTER, SWT.CENTER).grab(true, false).applyTo(l);\r
+\r
+ TrackedText maxXText = new TrackedText(Xcontainer, support, SWT.BORDER);\r
+ maxXText.setTextFactory(new DoublePropertyFactory(SysdynResource.URIs.HasMaxX));\r
+ maxXText.addModifyListener(new DoublePropertyModifier(context, SysdynResource.URIs.HasMaxX));\r
+\r
+ }\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2010 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.ui.properties;\r
+\r
+import org.eclipse.swt.widgets.Composite;\r
+import org.eclipse.ui.IWorkbenchSite;\r
+import org.simantics.browsing.ui.swt.widgets.impl.WidgetSupport;\r
+import org.simantics.db.management.ISessionContext;\r
+\r
+public class ModelTab extends LabelPropertyTabContributor {\r
+\r
+ @Override\r
+ public void createControls(Composite body, IWorkbenchSite site, ISessionContext context, WidgetSupport support) {\r
+ \r
+ }\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2010 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.ui.properties;\r
+\r
+import java.util.ArrayList;\r
+\r
+import org.eclipse.jface.viewers.ArrayContentProvider;\r
+import org.eclipse.jface.viewers.TableViewerColumn;\r
+import org.eclipse.swt.SWT;\r
+import org.eclipse.swt.widgets.Composite;\r
+import org.eclipse.ui.IWorkbenchSite;\r
+import org.simantics.browsing.ui.swt.widgets.impl.WidgetSupport;\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.common.request.ObjectsWithType;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.db.management.ISessionContext;\r
+import org.simantics.layer0.Layer0;\r
+import org.simantics.structural.stubs.StructuralResource2;\r
+import org.simantics.sysdyn.SysdynResource;\r
+import org.simantics.sysdyn.ui.properties.widgets.ModuleInputEditingSupport;\r
+import org.simantics.sysdyn.ui.properties.widgets.ReferenceRow;\r
+import org.simantics.sysdyn.ui.properties.widgets.ReferenceRowLabelProvider;\r
+import org.simantics.sysdyn.ui.properties.widgets.ReferenceTable;\r
+import org.simantics.sysdyn.ui.properties.widgets.RowProvider;\r
+\r
+public class ModuleInputTab extends LabelPropertyTabContributor {\r
+\r
+ public static final String FIRSTCOLUMN = "Input in Module";\r
+ public static final String SECONDCOLUMN = "Refers to output";\r
+ \r
+ @Override\r
+ public void createControls(Composite body, IWorkbenchSite site, ISessionContext context, WidgetSupport support) {\r
+ ReferenceTable referenceTable = new ReferenceTable(body, support, SWT.NONE);\r
+ \r
+ String[] titles = { FIRSTCOLUMN, SECONDCOLUMN};\r
+ int[] bounds = { 100, 100, 100, 100 };\r
+ for (int i = 0; i < titles.length; i++) {\r
+ TableViewerColumn column = new TableViewerColumn(referenceTable.getTableViewer(), SWT.NONE);\r
+ column.getColumn().setText(titles[i]);\r
+ column.getColumn().setWidth(bounds[i]);\r
+ column.getColumn().setResizable(true);\r
+ column.getColumn().setMoveable(false);\r
+ // enable editing support\r
+ column.setEditingSupport(new ModuleInputEditingSupport(referenceTable.getTableViewer(), i));\r
+ }\r
+ referenceTable.setContentProvider (new ArrayContentProvider());\r
+ referenceTable.setLabelProvider (new ReferenceRowLabelProvider());\r
+ \r
+ RowProvider rp = new RowProvider() {\r
+ \r
+ @Override\r
+ public ArrayList<ReferenceRow> getRows(ReadGraph graph, Resource module) throws DatabaseException {\r
+ Layer0 l0 = Layer0.getInstance(graph);\r
+ SysdynResource sr = SysdynResource.getInstance(graph);\r
+ StructuralResource2 sr2 = StructuralResource2.getInstance(graph);\r
+ ArrayList<ReferenceRow> result = new ArrayList<ReferenceRow>();\r
+ Resource instanceOf = graph.getPossibleObject(module, l0.InstanceOf);\r
+ if(instanceOf == null) return result;\r
+ Resource configuration = graph.getSingleObject(instanceOf, sr2.IsDefinedBy);\r
+ for(Resource input : graph.syncRequest(new ObjectsWithType(configuration, l0.ConsistsOf, sr.Input))) {\r
+ Resource dependency = null;\r
+ for(Resource dep : graph.getObjects(module, sr.IsHeadOf)) {\r
+ Resource refersTo = graph.getPossibleObject(dep, sr.RefersTo);\r
+ if(refersTo != null && refersTo.equals(input)) {\r
+ dependency = dep;\r
+ break;\r
+ }\r
+ }\r
+ ReferenceRow rr = new ReferenceRow(module, dependency, input); \r
+ result.add(rr);\r
+ }\r
+ return result;\r
+ }\r
+ };\r
+ referenceTable.setRowProvider(rp);\r
+ }\r
+\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2010 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.ui.properties;\r
+\r
+import java.util.ArrayList;\r
+\r
+import org.eclipse.jface.viewers.ArrayContentProvider;\r
+import org.eclipse.jface.viewers.TableViewerColumn;\r
+import org.eclipse.swt.SWT;\r
+import org.eclipse.swt.widgets.Composite;\r
+import org.eclipse.ui.IWorkbenchSite;\r
+import org.simantics.browsing.ui.swt.widgets.impl.WidgetSupport;\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.common.request.ObjectsWithType;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.db.management.ISessionContext;\r
+import org.simantics.layer0.Layer0;\r
+import org.simantics.structural.stubs.StructuralResource2;\r
+import org.simantics.sysdyn.SysdynResource;\r
+import org.simantics.sysdyn.ui.properties.widgets.ModuleOutputEditingSupport;\r
+import org.simantics.sysdyn.ui.properties.widgets.ReferenceRow;\r
+import org.simantics.sysdyn.ui.properties.widgets.ReferenceRowLabelProvider;\r
+import org.simantics.sysdyn.ui.properties.widgets.ReferenceTable;\r
+import org.simantics.sysdyn.ui.properties.widgets.RowProvider;\r
+\r
+public class ModuleOutputTab extends LabelPropertyTabContributor {\r
+\r
+ public static final String FIRSTCOLUMN = "Output in module";\r
+ public static final String SECONDCOLUMN = "Referes to input";\r
+ \r
+ @Override\r
+ public void createControls(Composite body, IWorkbenchSite site, ISessionContext context, WidgetSupport support) {\r
+ ReferenceTable referenceTable = new ReferenceTable(body, support, SWT.NONE);\r
+ \r
+ String[] titles = { FIRSTCOLUMN, SECONDCOLUMN};\r
+ int[] bounds = { 100, 100, 100, 100 };\r
+ for (int i = 0; i < titles.length; i++) {\r
+ TableViewerColumn column = new TableViewerColumn(referenceTable.getTableViewer(), SWT.NONE);\r
+ column.getColumn().setText(titles[i]);\r
+ column.getColumn().setWidth(bounds[i]);\r
+ column.getColumn().setResizable(true);\r
+ column.getColumn().setMoveable(false);\r
+ // enable editing support\r
+ column.setEditingSupport(new ModuleOutputEditingSupport(referenceTable.getTableViewer(), i));\r
+ }\r
+ referenceTable.setContentProvider (new ArrayContentProvider());\r
+ referenceTable.setLabelProvider (new ReferenceRowLabelProvider());\r
+ \r
+ RowProvider rp = new RowProvider() {\r
+ \r
+ @Override\r
+ public ArrayList<ReferenceRow> getRows(ReadGraph graph, Resource module) throws DatabaseException {\r
+ Layer0 l0 = Layer0.getInstance(graph);\r
+ SysdynResource sr = SysdynResource.getInstance(graph);\r
+ StructuralResource2 sr2 = StructuralResource2.getInstance(graph);\r
+ ArrayList<ReferenceRow> result = new ArrayList<ReferenceRow>();\r
+ Resource instanceOf = graph.getPossibleObject(module, l0.InstanceOf);\r
+ if(instanceOf == null) return result;\r
+ Resource configuration = graph.getSingleObject(instanceOf, sr2.IsDefinedBy);\r
+ for(Resource variable : graph.syncRequest(new ObjectsWithType(configuration, l0.ConsistsOf, sr.Variable))) {\r
+ if(!graph.hasStatement(variable, sr.IsOutput)) continue;\r
+ \r
+ Resource dependency = null;\r
+ for(Resource dep : graph.getObjects(module, sr.IsTailOf)) {\r
+ Resource refersTo = graph.getPossibleObject(dep, sr.RefersTo);\r
+ if(refersTo != null && refersTo.equals(variable)) {\r
+ dependency = dep;\r
+ break;\r
+ }\r
+ }\r
+ ReferenceRow rr = new ReferenceRow(module, dependency, variable); \r
+ result.add(rr);\r
+ }\r
+ return result;\r
+ }\r
+ };\r
+ referenceTable.setRowProvider(rp);\r
+ }\r
+}
\ No newline at end of file
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2010 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.ui.properties;\r
+\r
+import org.eclipse.jface.layout.GridDataFactory;\r
+import org.eclipse.jface.layout.GridLayoutFactory;\r
+import org.eclipse.swt.SWT;\r
+import org.eclipse.swt.widgets.Composite;\r
+import org.eclipse.swt.widgets.Control;\r
+import org.eclipse.swt.widgets.Label;\r
+import org.eclipse.swt.widgets.Tree;\r
+import org.eclipse.ui.IWorkbenchSite;\r
+import org.simantics.browsing.ui.swt.SingleSelectionInputSource;\r
+import org.simantics.browsing.ui.swt.widgets.GraphExplorerComposite;\r
+import org.simantics.browsing.ui.swt.widgets.StringPropertyFactory;\r
+import org.simantics.browsing.ui.swt.widgets.StringPropertyModifier;\r
+import org.simantics.browsing.ui.swt.widgets.TrackedText;\r
+import org.simantics.browsing.ui.swt.widgets.impl.Widget;\r
+import org.simantics.browsing.ui.swt.widgets.impl.WidgetSupport;\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.management.ISessionContext;\r
+import org.simantics.layer0.Layer0;\r
+import org.simantics.sysdyn.ui.properties.widgets.ColumnKeys;\r
+import org.simantics.utils.datastructures.ArrayMap;\r
+\r
+public class ModuleTab extends LabelPropertyTabContributor implements Widget {\r
+\r
+ GraphExplorerComposite enumerationRedeclarationExplorer;\r
+ \r
+ @Override\r
+ public void createControls(Composite body, IWorkbenchSite site, ISessionContext context, WidgetSupport support) {\r
+ support.register(this);\r
+ \r
+ Composite composite = new Composite(body, SWT.NONE);\r
+ GridDataFactory.fillDefaults().grab(true, true).applyTo(composite);\r
+ GridLayoutFactory.fillDefaults().margins(3, 3).applyTo(composite);\r
+ TrackedText nameText = new TrackedText(composite, support, SWT.BORDER);\r
+ nameText.setTextFactory(new StringPropertyFactory(Layer0.URIs.HasName));\r
+ nameText.addModifyListener(new StringPropertyModifier(context, Layer0.URIs.HasName));\r
+ GridDataFactory.fillDefaults().grab(true, false).applyTo(nameText.getWidget());\r
+ \r
+ Label label = new Label(composite, SWT.NONE);\r
+ label.setText("Replaceable enumerations");\r
+ enumerationRedeclarationExplorer = new GraphExplorerComposite(ArrayMap.keys(\r
+ "displaySelectors", "displayFilter").values(false, false), site, composite, SWT.FULL_SELECTION | SWT.BORDER | SWT.MULTI);\r
+ \r
+ enumerationRedeclarationExplorer\r
+ .setBrowseContexts("http://www.simantics.org/Sysdyn-1.0/EnumerationReplacement");\r
+ enumerationRedeclarationExplorer.setColumns(ColumnKeys.ENUMERATION_REDECLARATION_COLUMNS);\r
+ enumerationRedeclarationExplorer.setInputSource(new SingleSelectionInputSource(\r
+ Resource.class));\r
+\r
+ enumerationRedeclarationExplorer.finish();\r
+\r
+ GridDataFactory.fillDefaults().grab(true, true).applyTo(\r
+ enumerationRedeclarationExplorer);\r
+ \r
+ Control c = enumerationRedeclarationExplorer.getExplorerControl();\r
+ if (c instanceof Tree)\r
+ ((Tree) c).setLinesVisible(true);\r
+ \r
+ }\r
+ \r
+ \r
+ @Override\r
+ public void setInput(ISessionContext context, Object input) {\r
+ enumerationRedeclarationExplorer.setInput(context, input);\r
+ }\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2010 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.ui.properties;\r
+\r
+import org.eclipse.jface.layout.GridDataFactory;\r
+import org.eclipse.jface.layout.GridLayoutFactory;\r
+import org.eclipse.swt.SWT;\r
+import org.eclipse.swt.widgets.Composite;\r
+import org.eclipse.ui.IWorkbenchSite;\r
+import org.simantics.browsing.ui.swt.widgets.StringPropertyFactory;\r
+import org.simantics.browsing.ui.swt.widgets.StringPropertyModifier;\r
+import org.simantics.browsing.ui.swt.widgets.TrackedText;\r
+import org.simantics.browsing.ui.swt.widgets.impl.WidgetSupport;\r
+import org.simantics.db.management.ISessionContext;\r
+import org.simantics.layer0.Layer0;\r
+\r
+public class ModuleTypeTab extends LabelPropertyTabContributor {\r
+\r
+ @Override\r
+ public void createControls(Composite body, IWorkbenchSite site, ISessionContext context, WidgetSupport support) {\r
+ Composite composite = new Composite(body, SWT.NONE);\r
+ GridDataFactory.fillDefaults().grab(true, true).applyTo(composite);\r
+ GridLayoutFactory.fillDefaults().margins(3, 3).numColumns(6).applyTo(composite);\r
+ TrackedText nameText = new TrackedText(composite, support, SWT.BORDER);\r
+ nameText.setTextFactory(new StringPropertyFactory(Layer0.URIs.HasName));\r
+ nameText.addModifyListener(new StringPropertyModifier(context, Layer0.URIs.HasName));\r
+ GridDataFactory.fillDefaults().grab(true, false).applyTo(nameText.getWidget());\r
+ }\r
+\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2010 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.ui.properties;\r
+\r
+import org.eclipse.swt.widgets.Composite;\r
+import org.eclipse.ui.IWorkbenchSite;\r
+import org.simantics.browsing.ui.swt.widgets.impl.WidgetSupport;\r
+import org.simantics.db.management.ISessionContext;\r
+\r
+public class ReferenceDependencyTab extends LabelPropertyTabContributor {\r
+\r
+ @Override\r
+ public void createControls(Composite body, IWorkbenchSite site, ISessionContext context, WidgetSupport support) {\r
+ }\r
+\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2010 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.ui.properties;\r
+\r
+import java.util.ArrayList;\r
+import java.util.Collection;\r
+import java.util.Collections;\r
+import java.util.List;\r
+\r
+import org.eclipse.jface.viewers.ISelection;\r
+import org.simantics.browsing.ui.SelectionProcessor;\r
+import org.simantics.browsing.ui.swt.ComparableTabContributor;\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.common.utils.OrderedSetUtils;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.db.exception.ManyObjectsForFunctionalRelationException;\r
+import org.simantics.db.exception.ServiceException;\r
+import org.simantics.diagram.stubs.DiagramResource;\r
+import org.simantics.layer0.Layer0;\r
+import org.simantics.modeling.ModelingResources;\r
+import org.simantics.simulation.ontology.SimulationResource;\r
+import org.simantics.sysdyn.SysdynResource;\r
+import org.simantics.sysdyn.ui.browser.nodes.SharedFunctionsFolder;\r
+import org.simantics.ui.utils.AdaptionUtils;\r
+\r
+public class ResourceSelectionProcessor implements SelectionProcessor<Object, ReadGraph> {\r
+\r
+ @Override\r
+ public Collection<?> process(Object selection, ReadGraph backend) {\r
+ Collection<ComparableTabContributor> tabs = new ArrayList<ComparableTabContributor>();\r
+ SysdynResource sr = SysdynResource.getInstance(backend);\r
+ DiagramResource dr = DiagramResource.getInstance(backend);\r
+ ModelingResources mr = ModelingResources.getInstance(backend);\r
+ SimulationResource simu = SimulationResource.getInstance(backend);\r
+\r
+ try {\r
+ // Many elements \r
+ if (selection instanceof ArrayList<?> && ((ArrayList<?>) selection).size() > 1) {\r
+ List<Resource> independentVariables = new ArrayList<Resource>();\r
+ Resource model = null;\r
+ for(Object o : (ArrayList<?>)selection) {\r
+ Resource r = AdaptionUtils.adaptToSingle(o, Resource.class);\r
+ if(r != null && backend.isInstanceOf(r, sr.IndependentVariable)) {\r
+ if(model == null)\r
+ model = backend.getSingleObject(r, Layer0.getInstance(backend).PartOf);\r
+ if(model.equals( backend.getSingleObject(r, Layer0.getInstance(backend).PartOf)))\r
+ independentVariables.add(r);\r
+ }\r
+ }\r
+\r
+ tabs.add(new ComparableTabContributor(\r
+ new ArrayIndexesTab(),\r
+ 1,\r
+ independentVariables,\r
+ "Indexes"));\r
+ \r
+ return tabs;\r
+ }\r
+\r
+\r
+ // Single element\r
+ Resource r = AdaptionUtils.adaptToSingle(selection, Resource.class);\r
+ \r
+ if(r == null) {\r
+ SharedFunctionsFolder sff = AdaptionUtils.adaptToSingle(selection, SharedFunctionsFolder.class);\r
+ if (sff != null) {\r
+ return Collections.singleton(new ComparableTabContributor(\r
+ new SharedFunctionLibrariesTab(),\r
+ 2,\r
+ sff.data,\r
+ "Shared Functions"));\r
+ }\r
+ \r
+ return Collections.emptyList();\r
+ }\r
+\r
+\r
+ if (backend.isInstanceOf(r, dr.Element)) {\r
+ Resource component = backend.getPossibleObject(r, mr.ElementToComponent);\r
+ if (component != null) {\r
+ r = component;\r
+ } else {\r
+ Resource connection = backend.getPossibleObject(r, mr.DiagramConnectionToConnection);\r
+ if(connection != null)\r
+ r = connection;\r
+ }\r
+ }\r
+ if (backend.isInstanceOf(r, sr.IndependentVariable)) {\r
+\r
+\r
+ Resource activeExpression = backend.getPossibleObject(r, sr.HasActiveExpression);\r
+ Resource expression = null;\r
+ if(activeExpression != null)\r
+ expression = activeExpression;\r
+ else if (backend.hasStatement(r, sr.HasExpressions)){\r
+ Resource expressions = backend.getPossibleObject(r, sr.HasExpressions);\r
+ List<Resource> expressionList = OrderedSetUtils.toList(backend, expressions);\r
+ if(expressionList.isEmpty()) {\r
+ System.err.println("expressionList is empty for " + r);\r
+ return Collections.emptyList();\r
+ }\r
+ expression = expressionList.get(0);\r
+ }\r
+ tabs.add(new ComparableTabContributor(\r
+ new EquationTab(),\r
+ 3,\r
+ r,\r
+ "Equation"));\r
+ if(expression != null && backend.isInstanceOf(expression, sr.WithLookupExpression)) {\r
+ tabs.add(new ComparableTabContributor(\r
+ new LookupTableTab(),\r
+ 2,\r
+ expression,\r
+ "Lookup Table"));\r
+ }\r
+\r
+ tabs.add(new ComparableTabContributor(\r
+ new ArrayIndexesTab(),\r
+ 1,\r
+ r,\r
+ "Indexes"));\r
+\r
+ tabs.add(new ComparableTabContributor(\r
+ new VariableInformationTab(),\r
+ 0,\r
+ r,\r
+ "Additional Information"));\r
+ return tabs;\r
+ }\r
+ if (backend.isInstanceOf(r, sr.Input)) {\r
+ tabs.add(new ComparableTabContributor(\r
+ new InputVariableTab(),\r
+ 2,\r
+ r,\r
+ "Input"));\r
+ \r
+ tabs.add(new ComparableTabContributor(\r
+ new ArrayIndexesTab(),\r
+ 1,\r
+ r,\r
+ "Indexes"));\r
+\r
+ tabs.add(new ComparableTabContributor(\r
+ new VariableInformationTab(),\r
+ 0,\r
+ r,\r
+ "Additional Information"));\r
+ return tabs;\r
+ }\r
+ if (backend.isInstanceOf(r, sr.Enumeration)) {\r
+ Object s = AdaptionUtils.adaptToSingle(selection, ISelection.class);\r
+ if(s == null)\r
+ s = r;\r
+ // give either variable or the actual resource\r
+ return Collections.singleton(new ComparableTabContributor(\r
+ new EnumerationTab(),\r
+ 2,\r
+ s,\r
+ "Enumeration"));\r
+ }\r
+ if ( backend.isInstanceOf(r, sr.Configuration) || backend.isInstanceOf(r, sr.SysdynModel)) {\r
+ if(!backend.isInstanceOf(r, sr.SysdynModel))\r
+ r = backend.getPossibleObject(r, SimulationResource.getInstance(backend).IsConfigurationOf);\r
+ if (r != null)\r
+ return Collections.singleton(\r
+ new ComparableTabContributor(\r
+ new ConfigurationTab(),\r
+ 0,\r
+ r,\r
+ "Model Properties"));\r
+ }\r
+ if (backend.isInstanceOf(r, sr.Module)){\r
+ tabs.add(new ComparableTabContributor(\r
+ new ModuleTab(),\r
+ 3,\r
+ r,\r
+ "Module Properties"));\r
+ tabs.add(new ComparableTabContributor(\r
+ new ModuleInputTab(),\r
+ 2,\r
+ r,\r
+ "Inputs"));\r
+ tabs.add(new ComparableTabContributor(\r
+ new ModuleOutputTab(),\r
+ 1,\r
+ r,\r
+ "Outputs"));\r
+ return tabs;\r
+ }\r
+ if (backend.isInstanceOf(r, simu.Experiment))\r
+ return Collections.singleton(\r
+ new ComparableTabContributor(\r
+ new ExperimentTab(),\r
+ 0,\r
+ r,\r
+ "Experiment Properties"));\r
+ if (backend.isInstanceOf(r, sr.SysdynModel))\r
+ return Collections.singleton(\r
+ new ComparableTabContributor(\r
+ new ModelTab(),\r
+ 0,\r
+ r,\r
+ "Model Properties"));\r
+ if (backend.isInstanceOf(r, sr.Result))\r
+ return Collections.singleton(\r
+ new ComparableTabContributor(\r
+ new ResultTab(),\r
+ 0,\r
+ r,\r
+ "Result Properties"));\r
+ if (backend.isInstanceOf(r, sr.Dependency))\r
+ if (backend.hasStatement(r, sr.RefersTo))\r
+ return Collections.singleton(\r
+ new ComparableTabContributor(\r
+ new ReferenceDependencyTab(),\r
+ 0,\r
+ r,\r
+ "Reference Properties"));\r
+ else\r
+ return Collections.singleton(\r
+ new ComparableTabContributor(\r
+ new DependencyTab(),\r
+ 0,\r
+ r,\r
+ "Dependency Properties"));\r
+ if (backend.isInheritedFrom(r, sr.ModuleSymbol)) {\r
+ r = backend.getPossibleObject(r, mr.SymbolToComponentType);\r
+ if(r != null)\r
+ return Collections.singleton(\r
+ new ComparableTabContributor(\r
+ new ModuleTypeTab(),\r
+ 0,\r
+ r,\r
+ "Module Type Properties"));\r
+ }\r
+ \r
+ if (backend.isInstanceOf(r, sr.SysdynModelicaFunction)) {\r
+ tabs.add(new ComparableTabContributor(\r
+ new FunctionTab(),\r
+ 2,\r
+ r,\r
+ "Function"));\r
+ tabs.add(new ComparableTabContributor(\r
+ new ExternalFilesTab(),\r
+ 1,\r
+ r,\r
+ "External files"));\r
+ return tabs;\r
+ }\r
+ \r
+ if (backend.isInstanceOf(r, sr.SysdynModelicaFunctionLibrary)) {\r
+ Object s = AdaptionUtils.adaptToSingle(selection, ISelection.class);\r
+ if(s == null)\r
+ s = r;\r
+ // give either variable or the actual resource\r
+ return Collections.singleton(new ComparableTabContributor(\r
+ new FunctionLibraryTab(),\r
+ 2,\r
+ s,\r
+ "Function library"));\r
+ }\r
+ \r
+ } catch (ServiceException e) {\r
+ e.printStackTrace();\r
+ } catch (ManyObjectsForFunctionalRelationException e) {\r
+ e.printStackTrace();\r
+ } catch (DatabaseException e) {\r
+ e.printStackTrace();\r
+ }\r
+ return Collections.emptyList();\r
+ }\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2010 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.ui.properties;\r
+\r
+import org.eclipse.swt.widgets.Composite;\r
+import org.eclipse.ui.IWorkbenchSite;\r
+import org.simantics.browsing.ui.swt.widgets.impl.WidgetSupport;\r
+import org.simantics.db.management.ISessionContext;\r
+\r
+public class ResultTab extends LabelPropertyTabContributor {\r
+\r
+ @Override\r
+ public void createControls(Composite body, IWorkbenchSite site, ISessionContext context, WidgetSupport support) {\r
+ \r
+ }\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2011 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.ui.properties;\r
+\r
+import java.util.ArrayList;\r
+import java.util.Iterator;\r
+import java.util.List;\r
+\r
+import org.eclipse.core.runtime.IAdaptable;\r
+import org.eclipse.jface.layout.GridDataFactory;\r
+import org.eclipse.jface.layout.GridLayoutFactory;\r
+import org.eclipse.jface.viewers.ISelection;\r
+import org.eclipse.jface.viewers.ISelectionProvider;\r
+import org.eclipse.jface.viewers.IStructuredSelection;\r
+import org.eclipse.swt.SWT;\r
+import org.eclipse.swt.widgets.Composite;\r
+import org.eclipse.swt.widgets.Label;\r
+import org.eclipse.ui.IWorkbenchSite;\r
+import org.simantics.browsing.ui.NodeContext;\r
+import org.simantics.browsing.ui.swt.AdaptableHintContext;\r
+import org.simantics.browsing.ui.swt.SingleSelectionInputSource;\r
+import org.simantics.browsing.ui.swt.widgets.Button;\r
+import org.simantics.browsing.ui.swt.widgets.GraphExplorerComposite;\r
+import org.simantics.browsing.ui.swt.widgets.impl.SelectionListenerImpl;\r
+import org.simantics.browsing.ui.swt.widgets.impl.Widget;\r
+import org.simantics.browsing.ui.swt.widgets.impl.WidgetSupport;\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.WriteGraph;\r
+import org.simantics.db.common.request.WriteRequest;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.db.management.ISessionContext;\r
+import org.simantics.layer0.Layer0;\r
+import org.simantics.sysdyn.ui.browser.nodes.SharedFunctionLibraryNode;\r
+import org.simantics.ui.SimanticsUI;\r
+import org.simantics.ui.utils.AdaptionUtils;\r
+import org.simantics.utils.datastructures.ArrayMap;\r
+\r
+public class SharedFunctionLibrariesTab extends LabelPropertyTabContributor implements Widget {\r
+ \r
+ GraphExplorerComposite availableSharedFunctionLibraries;\r
+ GraphExplorerComposite usedSharedFunctionLibraries;\r
+ Resource model;\r
+\r
+ @Override\r
+ public void createControls(Composite body, IWorkbenchSite site, ISessionContext context, WidgetSupport support) {\r
+ support.register(this);\r
+ \r
+ GridLayoutFactory.fillDefaults().numColumns(4).applyTo(body);\r
+ \r
+ \r
+ Composite available = new Composite(body, SWT.NONE);\r
+ GridLayoutFactory.fillDefaults().applyTo(available);\r
+ GridDataFactory.fillDefaults().grab(true, true).applyTo(available);\r
+ Label label = new Label(available, SWT.None);\r
+ label.setText("Available Shared Function Libraries");\r
+ availableSharedFunctionLibraries = new GraphExplorerComposite(ArrayMap.keys(\r
+ "displaySelectors", "displayFilter").values(false, false), site, available, SWT.FULL_SELECTION | SWT.BORDER | SWT.MULTI) {\r
+ \r
+ @Override\r
+ protected void handleDrop(Object data, NodeContext target) {\r
+ if (!(data instanceof IStructuredSelection))\r
+ return;\r
+ \r
+ IStructuredSelection iss = (IStructuredSelection)data;\r
+ if (iss == null || iss.isEmpty())\r
+ return;\r
+ \r
+ for (Iterator<?> iterator = iss.iterator(); iterator.hasNext();) {\r
+ Object o = iterator.next();\r
+ if(o instanceof IAdaptable) {\r
+ IAdaptable a = (IAdaptable)o;\r
+ final SharedFunctionLibraryNode node = (SharedFunctionLibraryNode)a.getAdapter(SharedFunctionLibraryNode.class);\r
+ if(node != null) {\r
+ SimanticsUI.getSession().asyncRequest(new WriteRequest() {\r
+\r
+ @Override\r
+ public void perform(WriteGraph graph) throws DatabaseException {\r
+ if(getModel() != null && node.data != null)\r
+ graph.deny(getModel(), Layer0.getInstance(graph).IsLinkedTo, node.data); \r
+ }\r
+ });\r
+ }\r
+ }\r
+ }\r
+ }\r
+ };\r
+ \r
+ availableSharedFunctionLibraries\r
+ .setBrowseContexts("http://www.simantics.org/Sysdyn-1.0/AvailableSharedFunctionLibraries");\r
+ availableSharedFunctionLibraries.setInputSource(new SingleSelectionInputSource(\r
+ Resource.class));\r
+\r
+ availableSharedFunctionLibraries.finish();\r
+\r
+ GridDataFactory.fillDefaults().grab(true, true).applyTo(\r
+ availableSharedFunctionLibraries);\r
+ \r
+ Composite middleButtons = new Composite(body, SWT.NONE);\r
+ GridLayoutFactory.fillDefaults().applyTo(middleButtons);\r
+ GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(false, true).applyTo(middleButtons);\r
+ \r
+ Button add = new Button(middleButtons, support, SWT.NONE);\r
+ add.setText(" -> ");\r
+ \r
+ add.addSelectionListener(new SelectionListenerImpl<Resource>(context) {\r
+\r
+ @Override\r
+ public void apply(WriteGraph graph, Resource input)\r
+ throws DatabaseException {\r
+ Layer0 l0 = Layer0.getInstance(graph);\r
+ List<Resource> selectedLibraries = getSelectedResources(availableSharedFunctionLibraries);\r
+ for(Resource library : selectedLibraries) {\r
+ graph.claim(input, l0.IsLinkedTo, library);\r
+ }\r
+ }\r
+ });\r
+ \r
+ Button remove = new Button(middleButtons, support, SWT.NONE);\r
+ remove.setText(" <- ");\r
+ \r
+ remove.addSelectionListener(new SelectionListenerImpl<Resource>(context) {\r
+\r
+ @Override\r
+ public void apply(WriteGraph graph, Resource input)\r
+ throws DatabaseException {\r
+ Layer0 l0 = Layer0.getInstance(graph);\r
+ List<Resource> selectedLibraries = getSelectedResources(usedSharedFunctionLibraries);\r
+ for(Resource library : selectedLibraries) {\r
+ graph.deny(input, l0.IsLinkedTo, library);\r
+ }\r
+ }\r
+ });\r
+ \r
+ \r
+ Composite used = new Composite(body, SWT.NONE);\r
+ GridLayoutFactory.fillDefaults().applyTo(used);\r
+ GridDataFactory.fillDefaults().grab(true, true).applyTo(used);\r
+ label = new Label(used, SWT.None);\r
+ label.setText("Selected Shared Function Libraries");\r
+ \r
+ usedSharedFunctionLibraries = new GraphExplorerComposite(ArrayMap.keys(\r
+ "displaySelectors", "displayFilter").values(false, false), site, used, SWT.FULL_SELECTION | SWT.BORDER | SWT.MULTI) {\r
+ \r
+ @Override\r
+ protected void handleDrop(Object data, NodeContext target) {\r
+ if (!(data instanceof IStructuredSelection))\r
+ return;\r
+ \r
+ IStructuredSelection iss = (IStructuredSelection)data;\r
+ if (iss == null || iss.isEmpty())\r
+ return;\r
+ \r
+ for (Iterator<?> iterator = iss.iterator(); iterator.hasNext();) {\r
+ Object o = iterator.next();\r
+ if(o instanceof IAdaptable) {\r
+ IAdaptable a = (IAdaptable)o;\r
+ final SharedFunctionLibraryNode node = (SharedFunctionLibraryNode)a.getAdapter(SharedFunctionLibraryNode.class);\r
+ if(node != null) {\r
+ SimanticsUI.getSession().asyncRequest(new WriteRequest() {\r
+\r
+ @Override\r
+ public void perform(WriteGraph graph) throws DatabaseException {\r
+ if(getModel() != null && node.data != null)\r
+ graph.claim(getModel(), Layer0.getInstance(graph).IsLinkedTo, node.data); \r
+ }\r
+ });\r
+ }\r
+ }\r
+ }\r
+ }\r
+ };\r
+ \r
+ usedSharedFunctionLibraries\r
+ .setBrowseContexts("http://www.simantics.org/Sysdyn-1.0/SelectedSharedFunctionLibraries");\r
+ usedSharedFunctionLibraries.setInputSource(new SingleSelectionInputSource(\r
+ Resource.class));\r
+\r
+ usedSharedFunctionLibraries.finish();\r
+\r
+ GridDataFactory.fillDefaults().grab(true, true).applyTo(\r
+ usedSharedFunctionLibraries);\r
+ }\r
+ \r
+ \r
+ private List<Resource> getSelectedResources(GraphExplorerComposite explorer) {\r
+ List<Resource> result = new ArrayList<Resource>();\r
+ \r
+ ISelection selection = ((ISelectionProvider) explorer\r
+ .getAdapter(ISelectionProvider.class)).getSelection();\r
+ if (selection == null)\r
+ return result;\r
+ IStructuredSelection iss = (IStructuredSelection) selection;\r
+ @SuppressWarnings("unchecked")\r
+ List<AdaptableHintContext> selections = iss.toList();\r
+ for(AdaptableHintContext ahc : selections) {\r
+ Resource resource = (Resource) ahc.getAdapter(Resource.class);\r
+ result.add(resource);\r
+ }\r
+ return result;\r
+ }\r
+\r
+ private Resource getModel() {\r
+ return model;\r
+ }\r
+\r
+ @Override\r
+ public void setInput(ISessionContext context, Object input) {\r
+ availableSharedFunctionLibraries.setInput(context, input);\r
+ usedSharedFunctionLibraries.setInput(context, input);\r
+ this.model = AdaptionUtils.adaptToSingle(input, Resource.class);\r
+ }\r
+\r
+}\r
+\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2010 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.ui.properties;\r
+\r
+import java.util.Set;\r
+\r
+import org.eclipse.ui.IWorkbenchPartSite;\r
+import org.simantics.browsing.ui.swt.StandardPropertyPage;\r
+\r
+public class SysdynPropertyPage extends StandardPropertyPage {\r
+\r
+ public SysdynPropertyPage(IWorkbenchPartSite site, Set<String> set) {\r
+ super(site, set);\r
+ }\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2010 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.ui.properties;\r
+\r
+import org.eclipse.jface.dialogs.IInputValidator;\r
+import org.eclipse.jface.layout.GridDataFactory;\r
+import org.eclipse.jface.layout.GridLayoutFactory;\r
+import org.eclipse.swt.SWT;\r
+import org.eclipse.swt.widgets.Composite;\r
+import org.eclipse.swt.widgets.Group;\r
+import org.eclipse.swt.widgets.Label;\r
+import org.eclipse.ui.IWorkbenchSite;\r
+import org.simantics.browsing.ui.swt.widgets.StringPropertyFactory;\r
+import org.simantics.browsing.ui.swt.widgets.StringPropertyModifier;\r
+import org.simantics.browsing.ui.swt.widgets.TrackedText;\r
+import org.simantics.browsing.ui.swt.widgets.impl.WidgetSupport;\r
+import org.simantics.db.management.ISessionContext;\r
+import org.simantics.layer0.Layer0;\r
+import org.simantics.sysdyn.SysdynResource;\r
+import org.simantics.sysdyn.ui.properties.widgets.factories.DoublePropertyFactory;\r
+import org.simantics.sysdyn.ui.properties.widgets.factories.DoublePropertyModifier;\r
+\r
+public class VariableInformationTab extends LabelPropertyTabContributor {\r
+\r
+ @Override\r
+ public void createControls(Composite body, IWorkbenchSite site, ISessionContext context, WidgetSupport support) {\r
+ Composite composite = new Composite(body, SWT.NONE);\r
+ GridDataFactory.fillDefaults().grab(true, true).applyTo(composite);\r
+ GridLayoutFactory.fillDefaults().margins(3, 3).applyTo(composite);\r
+\r
+ Group informationGroup = new Group(composite, SWT.SHADOW_ETCHED_IN);\r
+ informationGroup.setText("Information");\r
+ GridDataFactory.fillDefaults().grab(false, true).applyTo(informationGroup);\r
+ GridLayoutFactory.fillDefaults().margins(3, 3).applyTo(informationGroup);\r
+\r
+ TrackedText information = new TrackedText(informationGroup, support, SWT.MULTI | SWT.BORDER);\r
+ information.setTextFactory(new StringPropertyFactory(Layer0.URIs.HasDescription));\r
+ information.addModifyListener(new StringPropertyModifier(context, Layer0.URIs.HasDescription));\r
+ GridDataFactory.fillDefaults().grab(true, true).applyTo(information.getWidget());\r
+\r
+ Group rangeGroup = new Group(composite, SWT.SHADOW_ETCHED_IN);\r
+ rangeGroup.setText("Range");\r
+ GridDataFactory.fillDefaults().applyTo(rangeGroup);\r
+ GridLayoutFactory.fillDefaults().margins(3, 3).numColumns(6).applyTo(rangeGroup);\r
+\r
+ Label label = new Label(rangeGroup, SWT.NONE);\r
+ label.setText("Start");\r
+\r
+ TrackedText rangeStart = new TrackedText(rangeGroup, support, SWT.RIGHT | SWT.BORDER);\r
+ rangeStart.setTextFactory(new DoublePropertyFactory(SysdynResource.URIs.HasRangeStart));\r
+ rangeStart.addModifyListener(new DoublePropertyModifier(context, SysdynResource.URIs.HasRangeStart));\r
+ rangeStart.setInputValidator(new DoubleValidator());\r
+ GridDataFactory.fillDefaults().grab(true, false).applyTo(rangeStart.getWidget());\r
+\r
+\r
+ label = new Label(rangeGroup, SWT.NONE);\r
+ label.setText("End");\r
+\r
+\r
+ TrackedText rangeEnd = new TrackedText(rangeGroup, support, SWT.RIGHT | SWT.BORDER);\r
+ rangeEnd.setTextFactory(new DoublePropertyFactory(SysdynResource.URIs.HasRangeEnd));\r
+ rangeEnd.addModifyListener(new DoublePropertyModifier(context, SysdynResource.URIs.HasRangeEnd));\r
+ rangeEnd.setInputValidator(new DoubleValidator());\r
+ GridDataFactory.fillDefaults().grab(true, false).applyTo(rangeEnd.getWidget());\r
+\r
+ label = new Label(rangeGroup, SWT.NONE);\r
+ label.setText("Step");\r
+\r
+ TrackedText rangeStep = new TrackedText(rangeGroup, support, SWT.RIGHT | SWT.BORDER);\r
+ rangeStep.setTextFactory(new DoublePropertyFactory(SysdynResource.URIs.HasRangeStep));\r
+ rangeStep.addModifyListener(new DoublePropertyModifier(context, SysdynResource.URIs.HasRangeStep));\r
+ rangeStep.setInputValidator(new DoubleValidator());\r
+ GridDataFactory.fillDefaults().grab(true, false).applyTo(rangeStep.getWidget());\r
+\r
+ }\r
+\r
+ private class DoubleValidator implements IInputValidator {\r
+\r
+ @Override\r
+ public String isValid(String newText) {\r
+ for(int i = 0; i < newText.length(); i++){\r
+ if(!Character.isDigit(newText.charAt(i))){\r
+ if(newText.charAt(i) != '.') {\r
+ return "Invalid character '" + newText.charAt(i) + "'";\r
+ } else if(newText.indexOf('.') != newText.lastIndexOf('.')) {\r
+ return "There can be only one '.'";\r
+ }\r
+ }\r
+ }\r
+ return null;\r
+ }\r
+ }\r
+\r
+}\r
--- /dev/null
+package org.simantics.sysdyn.ui.properties.widgets;\r
+\r
+import java.util.ArrayList;\r
+import java.util.Iterator;\r
+import java.util.Map;\r
+import java.util.StringTokenizer;\r
+import java.util.LinkedHashMap;\r
+\r
+import org.eclipse.swt.widgets.Combo;\r
+import org.eclipse.swt.widgets.Composite;\r
+import org.simantics.browsing.ui.swt.widgets.TrackedCombo;\r
+import org.simantics.browsing.ui.swt.widgets.impl.ComboModifyListenerImpl;\r
+import org.simantics.browsing.ui.swt.widgets.impl.ReadFactoryImpl;\r
+import org.simantics.browsing.ui.swt.widgets.impl.TrackedModifyEvent;\r
+import org.simantics.browsing.ui.swt.widgets.impl.Widget;\r
+import org.simantics.browsing.ui.swt.widgets.impl.WidgetSupport;\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.Session;\r
+import org.simantics.db.VirtualGraph;\r
+import org.simantics.db.WriteGraph;\r
+import org.simantics.db.common.request.WriteRequest;\r
+import org.simantics.db.common.utils.NameUtils;\r
+import org.simantics.db.common.utils.OrderedSetUtils;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.db.management.ISessionContext;\r
+import org.simantics.db.procedure.Listener;\r
+import org.simantics.db.service.VirtualGraphSupport;\r
+import org.simantics.layer0.Layer0;\r
+import org.simantics.sysdyn.SysdynResource;\r
+import org.simantics.sysdyn.ui.utils.VariableNameUtils;\r
+\r
+public class ArrayExpressionCombo extends TrackedCombo {\r
+\r
+ int lastSelectedIndex = -2;\r
+\r
+ public ArrayExpressionCombo(Composite parent, WidgetSupport support,\r
+ int style) {\r
+ super(parent, support, style);\r
+\r
+ /*\r
+ this.setInputValidator(new VariableNameValidator(support));\r
+ */\r
+\r
+ this.setItemFactory(new ReadFactoryImpl<Resource, Map<String, Object>>() {\r
+\r
+ @Override\r
+ public Map<String, Object> perform(ReadGraph graph, final Resource input) throws DatabaseException {\r
+ Map<String, Object> map = new LinkedHashMap<String, Object>();\r
+ if(input == null) {\r
+ return map;\r
+ }\r
+\r
+ Layer0 l0 = Layer0.getInstance(graph);\r
+ String name = graph.getPossibleRelatedValue(input, l0.HasName);\r
+ if(name == null)\r
+ return map;\r
+\r
+ SysdynResource sr = SysdynResource.getInstance(graph);\r
+\r
+ String defaultRange = getDefaultRange(graph, input);\r
+ for(Resource expression : getExpressions(graph, input)) {\r
+ String arrayRange = graph.getPossibleRelatedValue(expression, sr.HasArrayRange); \r
+ if(arrayRange != null) {\r
+ map.put(name + arrayRange, expression);\r
+ } else if(defaultRange != null) {\r
+ map.put(name + defaultRange, expression);\r
+ } else {\r
+ map.put(name, expression);\r
+ }\r
+ }\r
+ if(map.isEmpty()) {\r
+ map.put(name, input);\r
+ }\r
+ return map;\r
+ }\r
+\r
+ });\r
+\r
+\r
+ this.setSelectionFactory(new ReadFactoryImpl<Resource, String>() {\r
+\r
+ @Override\r
+ public String perform(ReadGraph graph, final Resource input) throws DatabaseException {\r
+ String name = graph.getPossibleRelatedValue(input, Layer0.getInstance(graph).HasName);\r
+ if(name == null)\r
+ return "";\r
+ \r
+ String defaultRange = getDefaultRange(graph, input);\r
+ if(defaultRange == null)\r
+ return name;\r
+\r
+ SysdynResource sr = SysdynResource.getInstance(graph);\r
+\r
+ Resource activeExpression = graph.getPossibleObject(input, sr.HasActiveExpression);\r
+ Resource expression;\r
+ if(activeExpression == null) {\r
+ ArrayList<Resource> expressions = getExpressions(graph, input);\r
+ if(expressions == null || expressions.isEmpty())\r
+ return name;\r
+ expression = expressions.get(0);\r
+ } else {\r
+ expression = activeExpression;\r
+ }\r
+ String range = graph.getPossibleRelatedValue(expression, sr.HasArrayRange);\r
+ if(range != null)\r
+ return name + range;\r
+ else\r
+ return name + defaultRange;\r
+ }\r
+ });\r
+\r
+ this.addModifyListener(new NameAndArrayRangeModifyListener(support));\r
+ }\r
+\r
+\r
+ @Override\r
+ public void setInput(ISessionContext context, Object input) {\r
+ super.setInput(context, input);\r
+\r
+ if(selectionFactory != null) {\r
+ selectionFactory.listen(context, input, new Listener<String>() {\r
+\r
+ @Override\r
+ public void execute(final String result) {\r
+ if(getWidget().isDisposed()) return;\r
+ getWidget().getDisplay().asyncExec(new Runnable() {\r
+ \r
+ @Override\r
+ public void run() {\r
+ Combo combo = getWidget();\r
+ if(combo != null && !combo.isDisposed() && result != null) {\r
+ Object o = getWidget().getData(result);\r
+ if(o != null)\r
+ lastSelectedIndex = (Integer)o;\r
+ }\r
+ \r
+ }\r
+ });\r
+ }\r
+\r
+ @Override\r
+ public void exception(Throwable t) {\r
+ t.printStackTrace();\r
+ }\r
+\r
+ @Override\r
+ public boolean isDisposed() {\r
+ return getWidget().isDisposed();\r
+ }\r
+\r
+ });\r
+ }\r
+ }\r
+\r
+ private ArrayList<Resource> getExpressions(ReadGraph graph, Resource variable) throws DatabaseException {\r
+ SysdynResource sr = SysdynResource.getInstance(graph);\r
+ Resource hasExpressions = graph.getPossibleObject(variable, sr.HasExpressions);\r
+ if(hasExpressions == null)\r
+ return new ArrayList<Resource>();\r
+ else\r
+ return new ArrayList<Resource>(OrderedSetUtils.toList(graph, hasExpressions));\r
+ }\r
+\r
+ public static String getDefaultRange(ReadGraph graph, Resource variable) throws DatabaseException {\r
+ SysdynResource sr = SysdynResource.getInstance(graph);\r
+ Resource hasArrayIndexes = graph.getPossibleObject(variable, sr.HasArrayIndexes);\r
+\r
+ if(hasArrayIndexes == null)\r
+ return null;\r
+\r
+ Iterator<Resource> iterator = OrderedSetUtils.iterator(graph, hasArrayIndexes);\r
+ if(!iterator.hasNext())\r
+ return null;\r
+\r
+ StringBuilder sb = new StringBuilder();\r
+ sb.append("[");\r
+\r
+ while(iterator.hasNext()) {\r
+ sb.append(NameUtils.getSafeName(graph, iterator.next()));\r
+ if(iterator.hasNext()) {\r
+ sb.append(", ");\r
+ }\r
+ }\r
+ sb.append("]");\r
+ return sb.toString();\r
+ }\r
+\r
+ private class NameAndArrayRangeModifyListener extends ComboModifyListenerImpl<Resource> implements Widget {\r
+\r
+ Resource lastExpression; \r
+\r
+ public NameAndArrayRangeModifyListener(WidgetSupport support) {\r
+ support.register(this);\r
+ }\r
+\r
+ @Override\r
+ public void setInput(ISessionContext context, Object input) {\r
+ super.setInput(context, input);\r
+ }\r
+\r
+ @Override\r
+ public void modifyText(TrackedModifyEvent e) {\r
+\r
+ Combo combo = (Combo)e.getWidget();\r
+ LinkedHashMap<?, ?> data = (LinkedHashMap<?, ?>) combo.getData();\r
+\r
+ Resource expression = (Resource) data.get(combo.getText());\r
+ if(expression != null) {\r
+ lastExpression = expression;\r
+ lastSelectedIndex = combo.getSelectionIndex();\r
+ } else {\r
+ for(Object key : data.keySet()) {\r
+ int index = lastSelectedIndex < 0 ? 0 : lastSelectedIndex;\r
+ if((Integer)combo.getData((String)key) == index) {\r
+ lastExpression = (Resource) data.get((String)key);\r
+ break;\r
+ }\r
+ }\r
+ }\r
+\r
+ super.modifyText(e);\r
+ }\r
+\r
+ @Override\r
+ public void applyText(WriteGraph graph, final Resource variable, String text)\r
+ throws DatabaseException {\r
+ StringTokenizer st = new StringTokenizer(text, "[]");\r
+ final String newName = st.nextToken();\r
+ String range = null;\r
+ if(st.hasMoreTokens()) {\r
+ range = st.nextToken();\r
+ }\r
+ String originalName = graph.getRelatedValue(variable, Layer0.getInstance(graph).HasName);\r
+ if(!originalName.equals(newName)) {\r
+ VariableNameUtils.renameInEquations(graph, variable, originalName, newName);\r
+ graph.claimLiteral(variable, Layer0.getInstance(graph).HasName, newName);\r
+ }\r
+\r
+ SysdynResource sr = SysdynResource.getInstance(graph);\r
+\r
+ if(range != null && lastExpression != null) {\r
+ String oldRange = graph.getPossibleRelatedValue(lastExpression, sr.HasArrayRange);\r
+ if(oldRange == null || !range.equals(oldRange)) {\r
+ graph.claimLiteral(lastExpression, sr.HasArrayRange, "[" + range + "]");\r
+ }\r
+ }\r
+\r
+ Resource activeExpression = graph.getPossibleObject(variable, sr.HasActiveExpression);\r
+\r
+ if(lastExpression != null && !lastExpression.equals(activeExpression)) {\r
+ VirtualGraphSupport support = graph.getService(VirtualGraphSupport.class);\r
+ final Session session = graph.getSession();\r
+ session.asyncRequest(new WriteRequest(support.getWorkspacePersistent("expressions")) {\r
+ @Override\r
+ public void perform(WriteGraph graph) throws DatabaseException {\r
+ VirtualGraph runtime = graph.getService(VirtualGraph.class);\r
+ session.asyncRequest(new WriteRequest(runtime) {\r
+ @Override\r
+ public void perform(WriteGraph graph) throws DatabaseException {\r
+ SysdynResource sr = SysdynResource.getInstance(graph);\r
+ if(graph.hasStatement(variable, sr.HasActiveExpression))\r
+ graph.deny(variable, sr.HasActiveExpression);\r
+ graph.claim(variable, sr.HasActiveExpression, lastExpression);\r
+ }\r
+ }\r
+ );\r
+ }\r
+ });\r
+ }\r
+ }\r
+ }\r
+}\r
+\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2010 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.ui.properties.widgets;\r
+\r
+import java.awt.event.MouseEvent;\r
+import java.awt.geom.Point2D;\r
+import java.io.StringReader;\r
+import java.util.ArrayList;\r
+import java.util.Collections;\r
+import java.util.Iterator;\r
+\r
+import org.eclipse.jface.layout.GridDataFactory;\r
+import org.eclipse.jface.layout.GridLayoutFactory;\r
+import org.eclipse.jface.viewers.ISelection;\r
+import org.eclipse.swt.SWT;\r
+import org.eclipse.swt.events.FocusEvent;\r
+import org.eclipse.swt.events.FocusListener;\r
+import org.eclipse.swt.events.KeyEvent;\r
+import org.eclipse.swt.events.KeyListener;\r
+import org.eclipse.swt.events.MouseListener;\r
+import org.eclipse.swt.events.SelectionEvent;\r
+import org.eclipse.swt.events.SelectionListener;\r
+import org.eclipse.swt.widgets.Button;\r
+import org.eclipse.swt.widgets.Composite;\r
+import org.eclipse.swt.widgets.Event;\r
+import org.eclipse.swt.widgets.Table;\r
+import org.eclipse.swt.widgets.TableItem;\r
+import org.eclipse.swt.widgets.Text;\r
+import org.simantics.browsing.ui.swt.widgets.impl.Widget;\r
+import org.simantics.browsing.ui.swt.widgets.impl.WidgetSupport;\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.WriteGraph;\r
+import org.simantics.db.common.request.WriteRequest;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.db.management.ISessionContext;\r
+import org.simantics.db.procedure.Listener;\r
+import org.simantics.db.request.Read;\r
+import org.simantics.sysdyn.SysdynResource;\r
+import org.simantics.sysdyn.tableParser.ParseException;\r
+import org.simantics.sysdyn.tableParser.TableParser;\r
+import org.simantics.sysdyn.tableParser.Token;\r
+import org.simantics.sysdyn.ui.properties.widgets.expressions.LookupInputOutputTable;\r
+import org.simantics.sysdyn.ui.properties.widgets.expressions.LookupInputOutputTable.InputOutput;\r
+import org.simantics.ui.SimanticsUI;\r
+import org.simantics.utils.ui.ISelectionUtils;\r
+\r
+public class ChartTableWidget implements Widget {\r
+\r
+ Text input, output;\r
+ Button add;\r
+ LookupInputOutputTable table;\r
+ Resource expression;\r
+\r
+ public ChartTableWidget(Composite parent, WidgetSupport support, int style) {\r
+ support.register(this);\r
+ Composite valueTableComposite = new Composite(parent, SWT.NONE);\r
+ GridDataFactory.fillDefaults().grab(true, true).applyTo(valueTableComposite);\r
+ GridLayoutFactory.fillDefaults().numColumns(3).applyTo(valueTableComposite);\r
+\r
+ table = new LookupInputOutputTable(valueTableComposite, SWT.NONE);\r
+ GridDataFactory.fillDefaults().span(3, 1).grab(false, true).applyTo(table);\r
+ table.getTableViewer().getTable().addMouseListener(new MouseListener() {\r
+\r
+ @Override\r
+ public void mouseUp(org.eclipse.swt.events.MouseEvent e) {\r
+ if(e.button == MouseEvent.BUTTON3) {\r
+ Table t = (Table)e.widget;\r
+ TableItem item = (TableItem)t.getItem(new org.eclipse.swt.graphics.Point(e.x, e.y));\r
+ table.removeItem(t.indexOf(item));\r
+ tableModified();\r
+ }\r
+ }\r
+ @Override\r
+ public void mouseDown(org.eclipse.swt.events.MouseEvent e) { }\r
+ @Override\r
+ public void mouseDoubleClick(org.eclipse.swt.events.MouseEvent e) { }\r
+ });\r
+\r
+ input = new Text(valueTableComposite, SWT.BORDER | SWT.RIGHT);\r
+ input.setText("");\r
+ output = new Text(valueTableComposite, SWT.BORDER | SWT.RIGHT);\r
+ output.setText("");\r
+\r
+ add = new Button(valueTableComposite, SWT.None);\r
+ add.setText("Add");\r
+ add.addSelectionListener(new SelectionListener() {\r
+\r
+ @Override\r
+ public void widgetSelected(SelectionEvent e) {\r
+ try {\r
+ Double in = Double.parseDouble(input.getText());\r
+ Double out = Double.parseDouble(output.getText());\r
+ table.addLocation(new Point2D.Double(in, out));\r
+ tableModified();\r
+ } catch (NumberFormatException e1) {\r
+ }\r
+ input.setText("");\r
+ output.setText("");\r
+ }\r
+\r
+ @Override\r
+ public void widgetDefaultSelected(SelectionEvent e) {}\r
+ });\r
+\r
+ FocusListener flistener = new FocusListener() {\r
+ @Override\r
+ public void focusGained(FocusEvent e) {\r
+ Text text = (Text)e.widget;\r
+ text.setSelection(0, text.getCharCount());\r
+ }\r
+ @Override\r
+ public void focusLost(FocusEvent e) { }\r
+ };\r
+\r
+\r
+ KeyListener listener = new KeyListener() {\r
+\r
+ @Override\r
+ public void keyPressed(KeyEvent e) {\r
+ if (e.keyCode == SWT.CR || e.keyCode == SWT.KEYPAD_CR) {\r
+ try {\r
+ Double in = Double.parseDouble(input.getText());\r
+ Double out = Double.parseDouble(output.getText());\r
+ table.addLocation(new Point2D.Double(in, out));\r
+ tableModified();\r
+ } catch (NumberFormatException e1) {\r
+ if(input.getText().isEmpty() && output.getText().isEmpty()) {\r
+ add.forceFocus();\r
+ return;\r
+ }\r
+ }\r
+ input.setText("");\r
+ output.setText("");\r
+ input.setFocus();\r
+ } \r
+ }\r
+\r
+ @Override\r
+ public void keyReleased(KeyEvent e) { }\r
+\r
+ };\r
+\r
+ input.addFocusListener(flistener);\r
+ input.addKeyListener(listener);\r
+ output.addFocusListener(flistener);\r
+ output.addKeyListener(listener);\r
+ }\r
+\r
+ @Override\r
+ public void setInput(ISessionContext context, Object input) {\r
+\r
+ expression = ISelectionUtils.filterSingleSelection((ISelection)input, Resource.class);\r
+\r
+\r
+ try {\r
+ SimanticsUI.getSession().syncRequest(new Read<String>() {\r
+\r
+ @Override\r
+ public String perform(ReadGraph graph) throws DatabaseException {\r
+ SysdynResource sr = SysdynResource.getInstance(graph);\r
+ if(!graph.isInstanceOf(expression, sr.WithLookupExpression))\r
+ return null;\r
+ return graph.getPossibleRelatedValue(expression, sr.HasLookup);\r
+ }\r
+ }, new Listener<String>() {\r
+\r
+ @Override\r
+ public void exception(Throwable t) {\r
+ t.printStackTrace();\r
+ }\r
+\r
+ @Override\r
+ public void execute(String lookup) {\r
+ if(lookup == null) return;\r
+ TableParser parser = new TableParser(new StringReader(""));\r
+ parser.ReInit(new StringReader(lookup));\r
+ table.clearTable();\r
+ try {\r
+ parser.table();\r
+ ArrayList<Token> xTokens = parser.getXTokens();\r
+ ArrayList<Token> yTokens = parser.getYTokens();\r
+ for(int i = 0; i < xTokens.size(); i++) {\r
+ table.addLocation(new Point2D.Double(\r
+ Double.parseDouble(xTokens.get(i).image), \r
+ Double.parseDouble(yTokens.get(i).image)));\r
+ }\r
+ } catch (ParseException e1) {\r
+ }\r
+ }\r
+\r
+ @Override\r
+ public boolean isDisposed() {\r
+ return table.isDisposed();\r
+ }\r
+\r
+ });\r
+ } catch (DatabaseException e) {\r
+ e.printStackTrace();\r
+ }\r
+\r
+ table.addListener(SWT.Modify, new org.eclipse.swt.widgets.Listener() {\r
+\r
+ @Override\r
+ public void handleEvent(Event event) {\r
+ tableModified();\r
+ }\r
+ });\r
+ }\r
+ \r
+ \r
+ @SuppressWarnings("unchecked")\r
+ private void tableModified() {\r
+ StringBuilder b = new StringBuilder();\r
+ b.append("{");\r
+ ArrayList<InputOutput> inputOutputList = (ArrayList<InputOutput>)table.getTableViewer().getInput();\r
+ Collections.sort(inputOutputList, table.new InputOutputComparator());\r
+ Iterator<InputOutput> iterator = inputOutputList.iterator();\r
+ while(iterator.hasNext()){\r
+ InputOutput io = iterator.next();\r
+ b.append("{" + io.getInput(String.class) + "," + io.getOutput(String.class) + "}");\r
+ if(iterator.hasNext())\r
+ b.append(",");\r
+ }\r
+ b.append("}");\r
+ final String table = b.toString();\r
+\r
+ SimanticsUI.getSession().asyncRequest(new WriteRequest() {\r
+\r
+ @Override\r
+ public void perform(WriteGraph graph) throws DatabaseException {\r
+ SysdynResource sr = SysdynResource.getInstance(graph);\r
+ graph.claimLiteral(expression, sr.HasLookup, table);\r
+ }\r
+ });\r
+ }\r
+\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2010 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.ui.properties.widgets;\r
+\r
+import java.awt.BasicStroke;\r
+import java.awt.Color;\r
+import java.awt.GridLayout;\r
+import java.awt.geom.Ellipse2D;\r
+import java.io.StringReader;\r
+import java.util.ArrayList;\r
+import java.util.Iterator;\r
+\r
+import javax.swing.JComponent;\r
+import javax.swing.JPanel;\r
+\r
+import org.eclipse.jface.layout.GridDataFactory;\r
+import org.eclipse.jface.viewers.ISelection;\r
+import org.eclipse.swt.SWT;\r
+import org.eclipse.swt.widgets.Composite;\r
+import org.jfree.chart.ChartFactory;\r
+import org.jfree.chart.JFreeChart;\r
+import org.jfree.chart.axis.ValueAxis;\r
+import org.jfree.chart.plot.PlotOrientation;\r
+import org.jfree.chart.plot.XYPlot;\r
+import org.jfree.chart.renderer.xy.XYLineAndShapeRenderer;\r
+import org.jfree.data.general.SeriesChangeEvent;\r
+import org.jfree.data.general.SeriesChangeListener;\r
+import org.jfree.data.xy.XYDataItem;\r
+import org.jfree.data.xy.XYDataset;\r
+import org.jfree.data.xy.XYSeries;\r
+import org.jfree.data.xy.XYSeriesCollection;\r
+import org.simantics.browsing.ui.swt.widgets.impl.Widget;\r
+import org.simantics.browsing.ui.swt.widgets.impl.WidgetSupport;\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.WriteGraph;\r
+import org.simantics.db.common.request.WriteRequest;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.db.management.ISessionContext;\r
+import org.simantics.db.procedure.Listener;\r
+import org.simantics.db.request.Read;\r
+import org.simantics.sysdyn.SysdynResource;\r
+import org.simantics.sysdyn.tableParser.ParseException;\r
+import org.simantics.sysdyn.tableParser.TableParser;\r
+import org.simantics.sysdyn.tableParser.Token;\r
+import org.simantics.sysdyn.ui.properties.widgets.expressions.LookupChartPanel;\r
+import org.simantics.ui.SimanticsUI;\r
+import org.simantics.utils.ui.ISelectionUtils;\r
+import org.simantics.utils.ui.SWTAWTComponent;\r
+\r
+public class ChartWidget implements Widget {\r
+\r
+ JFreeChart chart;\r
+ LookupChartPanel chartPanel;\r
+ SWTAWTComponent swtawtcomponent;\r
+\r
+ public ChartWidget(Composite parent, WidgetSupport support, int style) {\r
+ support.register(this);\r
+ chartPanel = new LookupChartPanel(createChart());\r
+ chartPanel.setMouseZoomable(true, false);\r
+ chartPanel.setDomainZoomable(false);\r
+ chartPanel.setRangeZoomable(false);\r
+\r
+ swtawtcomponent = new SWTAWTComponent(parent, SWT.BORDER) {\r
+ @Override\r
+ protected JComponent createSwingComponent() {\r
+ JPanel panel = new JPanel();\r
+ panel.setLayout(new GridLayout(1, 1));\r
+ panel.add(chartPanel);\r
+ panel.doLayout();\r
+ return panel;\r
+ }\r
+ };\r
+ GridDataFactory.fillDefaults().grab(true, true).applyTo(swtawtcomponent);\r
+ swtawtcomponent.populate();\r
+\r
+ }\r
+\r
+ @Override\r
+ public void setInput(ISessionContext context, Object input) {\r
+\r
+ final Resource expression = ISelectionUtils.filterSingleSelection((ISelection)input, Resource.class);\r
+\r
+ class Auxiliary {\r
+ Double minX, minY, maxX, maxY;\r
+ String table;\r
+ }\r
+\r
+ try {\r
+ SimanticsUI.getSession().syncRequest(new Read<Auxiliary>() {\r
+\r
+ @Override\r
+ public Auxiliary perform(ReadGraph graph) throws DatabaseException {\r
+ SysdynResource sr = SysdynResource.getInstance(graph);\r
+ if(!graph.isInstanceOf(expression, sr.WithLookupExpression))\r
+ return null;\r
+ Auxiliary auxiliary = new Auxiliary();\r
+ auxiliary.minX = graph.getPossibleRelatedValue(expression, sr.HasMinX);\r
+ auxiliary.maxX = graph.getPossibleRelatedValue(expression, sr.HasMaxX);\r
+ auxiliary.minY = graph.getPossibleRelatedValue(expression, sr.HasMinY);\r
+ auxiliary.maxY = graph.getPossibleRelatedValue(expression, sr.HasMaxY);\r
+ auxiliary.table = graph.getPossibleRelatedValue(expression, sr.HasLookup);\r
+ return auxiliary;\r
+ }\r
+ }, new Listener<Auxiliary>() {\r
+\r
+ @Override\r
+ public void exception(Throwable t) {\r
+ t.printStackTrace();\r
+ }\r
+\r
+ @Override\r
+ public void execute(Auxiliary result) {\r
+ if(result == null) return;\r
+ XYDataset dataset = createDataset(result.table);\r
+ chartPanel.resetChart(dataset);\r
+ chartPanel.addSeriesChangeListener(new _SeriesChangeListener(expression));\r
+ \r
+ XYPlot plot = (XYPlot) chart.getPlot();\r
+ ValueAxis rangeAxis = plot.getRangeAxis();\r
+ rangeAxis.setAutoRange(false);\r
+ if(result.minY == null) result.minY = rangeAxis.getLowerBound();\r
+ if(result.maxY == null) result.maxY = rangeAxis.getUpperBound();\r
+ rangeAxis.setRange(result.minY, result.maxY);\r
+ ValueAxis domainAxis = plot.getDomainAxis();\r
+ domainAxis.setAutoRange(false);\r
+ if(result.minX == null) result.minX = domainAxis.getLowerBound();\r
+ if(result.maxX == null) result.maxX = domainAxis.getUpperBound();\r
+ domainAxis.setRange(result.minX, result.maxX);\r
+\r
+ }\r
+\r
+ @Override\r
+ public boolean isDisposed() {\r
+ return swtawtcomponent.isDisposed();\r
+ }\r
+\r
+ });\r
+ } catch (DatabaseException e) {\r
+ e.printStackTrace();\r
+ }\r
+ }\r
+\r
+ private JFreeChart createChart() {\r
+ XYDataset dataset = createDataset(null);\r
+ chart = ChartFactory.createXYLineChart(null, null, null,\r
+ dataset, PlotOrientation.VERTICAL, false, true, false);\r
+ XYPlot plot = (XYPlot) chart.getPlot();\r
+ XYLineAndShapeRenderer renderer\r
+ = (XYLineAndShapeRenderer) plot.getRenderer();\r
+ renderer.setBaseShapesVisible(true);\r
+ renderer.setDrawOutlines(true);\r
+ renderer.setUseFillPaint(true);\r
+ renderer.setBaseFillPaint(Color.white);\r
+ renderer.setSeriesStroke(0, new BasicStroke(3.0f));\r
+ renderer.setSeriesOutlineStroke(0, new BasicStroke(2.0f));\r
+ renderer.setSeriesShape(0, new Ellipse2D.Double(-5.0, -5.0, 10.0, 10.0));\r
+ return chart;\r
+ }\r
+\r
+ public XYDataset createDataset(String table) {\r
+ XYSeries series = new XYSeries("Series");\r
+ \r
+ if(table != null) {\r
+ TableParser parser = new TableParser(new StringReader(""));\r
+ parser.ReInit(new StringReader(table));\r
+ try {\r
+ parser.table();\r
+ ArrayList<Token> xTokens = parser.getXTokens();\r
+ ArrayList<Token> yTokens = parser.getYTokens();\r
+ for(int i = 0; i < xTokens.size(); i++) {\r
+ series.add(\r
+ Double.parseDouble(xTokens.get(i).image), \r
+ Double.parseDouble(yTokens.get(i).image));\r
+ }\r
+ } catch (ParseException e1) {\r
+ }\r
+ }\r
+ \r
+ XYSeriesCollection dataset = new XYSeriesCollection();\r
+ dataset.addSeries(series);\r
+ return dataset;\r
+ }\r
+\r
+ public LookupChartPanel getChartPanel() {\r
+ return this.chartPanel;\r
+ }\r
+\r
+ public JFreeChart getChart() {\r
+ return this.chart;\r
+ }\r
+\r
+ private class _SeriesChangeListener implements SeriesChangeListener {\r
+\r
+ Resource expression;\r
+ \r
+ public _SeriesChangeListener(Resource expression) {\r
+ this.expression = expression;\r
+ }\r
+ @Override\r
+ public void seriesChanged(SeriesChangeEvent event) {\r
+ if(chartPanel.isDragging()) return;\r
+\r
+ StringBuilder b = new StringBuilder();\r
+ b.append("{");\r
+ XYSeriesCollection collection = (XYSeriesCollection) ((XYPlot)chart.getPlot()).getDataset();\r
+ XYSeries series = collection.getSeries(0);\r
+ if(series.isEmpty())\r
+ return;\r
+ Iterator<?> iterator = series.getItems().iterator();\r
+ while(iterator.hasNext()){\r
+ XYDataItem item = (XYDataItem)iterator.next();\r
+ b.append("{" + item.getX() + "," + item.getY() + "}");\r
+ if(iterator.hasNext())\r
+ b.append(",");\r
+ }\r
+ b.append("}");\r
+ final String table = b.toString();\r
+\r
+ SimanticsUI.getSession().asyncRequest(new WriteRequest() {\r
+\r
+ @Override\r
+ public void perform(WriteGraph graph) throws DatabaseException {\r
+ SysdynResource sr = SysdynResource.getInstance(graph);\r
+ graph.claimLiteral(expression, sr.HasLookup, table);\r
+ }\r
+ });\r
+\r
+ }\r
+ }\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2011 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.ui.properties.widgets;\r
+\r
+import org.simantics.browsing.ui.Column;\r
+import org.simantics.browsing.ui.Column.Align;\r
+\r
+public class ColumnKeys {\r
+ \r
+ public static final String ENUMERATION = "Enumeration";\r
+ public static final String INDEXES = "Indexes";\r
+ public static final String SHOW_IN_CHARTS = "ShowInCharts";\r
+ public static final String REPLACED_WITH = "Replaced with";\r
+ \r
+ public static String[] ENUMERATION_COLUMNS_KEYS = { ENUMERATION, INDEXES };\r
+ public static Column[] ENUMERATION_TABLE_COLUMNS = new Column[] {\r
+ new Column(ENUMERATION, Align.LEFT, 100, "Enumeration", false),\r
+ new Column(INDEXES, Align.LEFT, 100, "Indexes", true),\r
+ };\r
+ \r
+\r
+ public static String[] ENUMERATION_INDEX_COLUMNS_KEYS = { ENUMERATION, SHOW_IN_CHARTS };\r
+ public static Column[] ENUMERATION_INDEX_TABLE_COLUMNS = new Column[] {\r
+ new Column(ENUMERATION, Align.LEFT, 100, "Enumeration", true),\r
+ new Column(SHOW_IN_CHARTS, Align.LEFT, 20, "Show in charts", false),\r
+ };\r
+ \r
+ public static String[] ENUMERATION_REDECLARATION_KEYS = { ENUMERATION, REPLACED_WITH };\r
+ public static Column[] ENUMERATION_REDECLARATION_COLUMNS = new Column[] {\r
+ new Column(ENUMERATION, Align.LEFT, 200, "Enumeration in module", false),\r
+ new Column(REPLACED_WITH, Align.LEFT, 200, "Replaced with", true),\r
+ };\r
+ \r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2010 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.ui.properties.widgets;\r
+\r
+import java.util.List;\r
+\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.common.utils.OrderedSetUtils;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.db.request.Read;\r
+import org.simantics.sysdyn.SysdynResource;\r
+import org.simantics.ui.SimanticsUI;\r
+\r
+public class ExpressionTypes {\r
+\r
+ public static enum ExpressionType {Auxiliary, Parameter, Constant, Lookup, WithLookup, Stock, Delay, Empty};\r
+\r
+ public static ExpressionType[] auxiliaryExpressions = new ExpressionType[] {\r
+ ExpressionType.Auxiliary, \r
+ ExpressionType.Parameter, \r
+ ExpressionType.Constant, \r
+ // ExpressionType.Lookup, \r
+ ExpressionType.WithLookup};\r
+\r
+ public static ExpressionType[] valveExpressions = new ExpressionType[] {\r
+ ExpressionType.Auxiliary, \r
+ ExpressionType.Parameter, \r
+ ExpressionType.Constant, \r
+ ExpressionType.WithLookup};\r
+\r
+ public static ExpressionType[] stockExpressions = new ExpressionType[] {\r
+ ExpressionType.Stock};\r
+\r
+ public static ExpressionType getExpressionType(final Resource expression) {\r
+ try {\r
+ return SimanticsUI.getSession().syncRequest(new Read<ExpressionType>() {\r
+\r
+ @Override\r
+ public ExpressionType perform(ReadGraph graph) throws DatabaseException {\r
+ return getExpressionType(graph, expression);\r
+ }\r
+ });\r
+ } catch (DatabaseException e) {\r
+ e.printStackTrace();\r
+ return null;\r
+ }\r
+\r
+ }\r
+ \r
+ public static ExpressionType getExpressionType(ReadGraph graph, final Resource expression) throws DatabaseException {\r
+ ExpressionType et = null;\r
+ SysdynResource sr = SysdynResource.getInstance(graph);\r
+ if(graph.isInstanceOf(expression, sr.NormalExpression)) {\r
+ et = ExpressionType.Auxiliary;\r
+ } else if (graph.isInstanceOf(expression, sr.StockExpression)) {\r
+ et = ExpressionType.Stock;\r
+ } else if (graph.isInstanceOf(expression, sr.ParameterExpression)) {\r
+ et = ExpressionType.Parameter;\r
+ } else if (graph.isInstanceOf(expression, sr.ConstantExpression)) {\r
+ et = ExpressionType.Constant;\r
+ } else if (graph.isInstanceOf(expression, sr.DelayExpression)) {\r
+ et = ExpressionType.Delay;\r
+ } else if (graph.isInstanceOf(expression, sr.LookupExpression)) {\r
+ et = ExpressionType.Lookup;\r
+ } else if (graph.isInstanceOf(expression, sr.WithLookupExpression)) {\r
+ et = ExpressionType.WithLookup;\r
+ } else {\r
+ et = ExpressionType.Empty;\r
+ }\r
+ return et;\r
+ }\r
+\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2010 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.ui.properties.widgets;\r
+\r
+import java.awt.event.ActionEvent;\r
+import java.awt.event.ActionListener;\r
+import java.util.Collection;\r
+import java.util.HashMap;\r
+import java.util.Map;\r
+\r
+import javax.swing.Timer;\r
+\r
+import org.eclipse.swt.custom.VerifyKeyListener;\r
+import org.eclipse.swt.events.FocusListener;\r
+import org.eclipse.swt.events.ModifyListener;\r
+import org.eclipse.swt.widgets.Composite;\r
+import org.eclipse.swt.widgets.Control;\r
+import org.eclipse.swt.widgets.Table;\r
+import org.simantics.browsing.ui.swt.widgets.impl.Widget;\r
+import org.simantics.browsing.ui.swt.widgets.impl.WidgetSupport;\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.common.utils.OrderedSetUtils;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.db.management.ISessionContext;\r
+import org.simantics.db.request.Read;\r
+import org.simantics.layer0.Layer0;\r
+import org.simantics.sysdyn.SysdynResource;\r
+import org.simantics.sysdyn.ui.properties.widgets.ExpressionTypes.ExpressionType;\r
+import org.simantics.sysdyn.ui.properties.widgets.expressions.AuxiliaryExpression;\r
+import org.simantics.sysdyn.ui.properties.widgets.expressions.ConstantExpression;\r
+import org.simantics.sysdyn.ui.properties.widgets.expressions.DelayExpression;\r
+import org.simantics.sysdyn.ui.properties.widgets.expressions.EmptyExpression;\r
+import org.simantics.sysdyn.ui.properties.widgets.expressions.IExpression;\r
+import org.simantics.sysdyn.ui.properties.widgets.expressions.LookupExpression;\r
+import org.simantics.sysdyn.ui.properties.widgets.expressions.ParameterExpression;\r
+import org.simantics.sysdyn.ui.properties.widgets.expressions.StockExpression;\r
+import org.simantics.sysdyn.ui.properties.widgets.expressions.WithLookupExpression;\r
+import org.simantics.sysdyn.ui.utils.ExpressionUtils;\r
+import org.simantics.ui.SimanticsUI;\r
+import org.simantics.ui.utils.AdaptionUtils;\r
+\r
+public class ExpressionWidget implements Widget {\r
+\r
+ private Resource expr;\r
+ private Composite parent;\r
+ private Map<String, Object> data;\r
+ private IExpression expression;\r
+ private ModifyListener modifyListener;\r
+ private FocusListener focusListener;\r
+ private Table variableTable;\r
+ private VerifyKeyListener verifyKeyListener;\r
+ private Timer updateChartTimer;\r
+ private static int VALIDATION_DELAY_TIME = 500;\r
+\r
+ public ExpressionWidget(Composite parent, WidgetSupport support, int style) {\r
+ support.register(this);\r
+ this.parent = parent;\r
+ this.data = new HashMap<String, Object>();\r
+ \r
+ updateChartTimer = new Timer(VALIDATION_DELAY_TIME, new ActionListener() {\r
+\r
+ @Override\r
+ public void actionPerformed(ActionEvent e) {\r
+ if(variableTable == null || variableTable.isDisposed())\r
+ return;\r
+ variableTable.getDisplay().asyncExec(new Runnable() {\r
+ \r
+ @Override\r
+ public void run() {\r
+ validateFields();\r
+ }\r
+ });\r
+ }\r
+ });\r
+ updateChartTimer.setRepeats(false);\r
+ }\r
+\r
+ @Override\r
+ public void setInput(ISessionContext context, Object input) { \r
+ expr = AdaptionUtils.adaptToSingle(input, Resource.class);\r
+ ExpressionType et = ExpressionTypes.getExpressionType(expr);\r
+ displayExpression(et.toString(), true);\r
+ }\r
+\r
+ public void displayExpression(String expressionType, boolean original) {\r
+ if(expressionType == null) {\r
+ return;\r
+ }\r
+\r
+ if(this.expression != null) expression.updateData(data);\r
+ ExpressionType et = ExpressionType.valueOf(expressionType);\r
+ IExpression exp = null;\r
+ switch (et) {\r
+ case Auxiliary: \r
+ exp = new AuxiliaryExpression(); break;\r
+ case Parameter: \r
+ exp = new ParameterExpression(); break;\r
+ case Constant: \r
+ exp = new ConstantExpression(); break;\r
+ case Lookup: \r
+ exp = new LookupExpression(); break;\r
+ case WithLookup: \r
+ exp = new WithLookupExpression(expr); break;\r
+ case Stock: \r
+ exp = new StockExpression(); break;\r
+ case Delay: \r
+ exp = new DelayExpression(); break;\r
+ default: \r
+ exp = new EmptyExpression();\r
+ }\r
+\r
+ if (exp != null) {\r
+ for(Control c : parent.getChildren()) {\r
+ c.dispose();\r
+ } \r
+\r
+ if(original) \r
+ exp.readData(expr, data);\r
+\r
+ exp.createExpressionFields(parent, data);\r
+ if(modifyListener != null)\r
+ exp.addModifyListener(modifyListener);\r
+ if(focusListener != null)\r
+ exp.addFocusListener(focusListener);\r
+ if(verifyKeyListener != null)\r
+ exp.addVerifyKeyListener(verifyKeyListener);\r
+ this.expression = exp;\r
+ this.parent.layout();\r
+ validateFieldsTimed();\r
+\r
+ save();\r
+ } \r
+ }\r
+\r
+ public IExpression getExpression() {\r
+ return expression;\r
+ }\r
+\r
+ public void setVariableTable(Table table) {\r
+ this.variableTable = table;\r
+ }\r
+\r
+\r
+ public void validateFieldsTimed() { \r
+ validateFieldsTimed(VALIDATION_DELAY_TIME);\r
+ }\r
+ \r
+ public void validateFieldsTimed(int delay) {\r
+ updateChartTimer.setDelay(delay);\r
+ if(!updateChartTimer.isRunning())\r
+ updateChartTimer.start();\r
+ else\r
+ updateChartTimer.restart();\r
+ }\r
+ \r
+ \r
+ public void validateFields() {\r
+ if(this.variableTable == null) return;\r
+ \r
+ try {\r
+ Resource variable = SimanticsUI.getSession().syncRequest(new Read<Resource>() {\r
+\r
+ @Override\r
+ public Resource perform(ReadGraph graph) throws DatabaseException {\r
+ SysdynResource sr = SysdynResource.getInstance(graph);\r
+ Layer0 l0 = Layer0.getInstance(graph);\r
+ Collection<Resource> expressionLists = OrderedSetUtils.getOwnerLists(graph, expr, l0.OrderedSet);\r
+ Resource variable = null;\r
+ if(expressionLists.size() == 1)\r
+ variable = graph.getPossibleObject(expressionLists.iterator().next(), sr.HasExpressions_Inverse);\r
+ return variable;\r
+ }\r
+ });\r
+ if(variable != null)\r
+ ExpressionUtils.validateExpressionFields(variable, expression, variableTable);\r
+ } catch (DatabaseException e) {\r
+ // TODO Auto-generated catch block\r
+ e.printStackTrace();\r
+ }\r
+\r
+ }\r
+\r
+ public void addModifyListener(ModifyListener listener) {\r
+ this.modifyListener = listener;\r
+ }\r
+\r
+ public void addVerifyKeyListener(VerifyKeyListener listener) {\r
+ this.verifyKeyListener = listener;\r
+ }\r
+\r
+ public void addFocusListener(FocusListener listener) {\r
+ this.focusListener = listener;\r
+ }\r
+\r
+ public void save() {\r
+ if(this.expression != null)\r
+ this.expression.save(expr, data);\r
+ }\r
+\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2011 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.ui.properties.widgets;\r
+\r
+import org.simantics.browsing.ui.swt.widgets.impl.ReadFactoryImpl;\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.utils.datastructures.Quad;\r
+\r
+\r
+\r
+public class FunctionLabelFactory extends ReadFactoryImpl<Resource, String> {\r
+\r
+ private final String propertyURI;\r
+ private boolean end;\r
+ \r
+ public FunctionLabelFactory(String propertyURI, boolean end) {\r
+ this.propertyURI = propertyURI;\r
+ this.end = end;\r
+ }\r
+\r
+ @Override\r
+ public Object getIdentity(Object inputContents) {\r
+ return new Quad<Resource, String, Object, Boolean>((Resource) inputContents, propertyURI, getClass(), end);\r
+ }\r
+\r
+ \r
+ @Override\r
+ public String perform(ReadGraph graph, Resource resource) throws DatabaseException {\r
+ String value = graph.getPossibleRelatedValue(resource, graph.getResource(propertyURI));\r
+ if(end) {\r
+ return "end " + value + ";";\r
+ } else {\r
+ return "function " + value;\r
+ }\r
+ }\r
+ \r
+ \r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2010 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.ui.properties.widgets;\r
+\r
+import org.eclipse.jface.viewers.ISelection;\r
+import org.eclipse.jface.viewers.IStructuredSelection;\r
+import org.eclipse.swt.SWT;\r
+import org.eclipse.swt.widgets.Button;\r
+import org.eclipse.swt.widgets.Composite;\r
+import org.simantics.browsing.ui.swt.widgets.impl.SelectionListenerImpl;\r
+import org.simantics.browsing.ui.swt.widgets.impl.Widget;\r
+import org.simantics.browsing.ui.swt.widgets.impl.WidgetSupport;\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.WriteGraph;\r
+import org.simantics.db.common.request.ReadRequest;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.db.management.ISessionContext;\r
+import org.simantics.sysdyn.SysdynResource;\r
+import org.simantics.utils.ui.ISelectionUtils;\r
+\r
+public class IsOutputWidget implements Widget{\r
+ \r
+ Resource variable = null; \r
+ org.simantics.browsing.ui.swt.widgets.Button isOutputButton;\r
+ \r
+ public IsOutputWidget(Composite parent, WidgetSupport support, int style) {\r
+ support.register(this);\r
+ isOutputButton = new org.simantics.browsing.ui.swt.widgets.Button(parent, support, style |= SWT.CHECK);\r
+ isOutputButton.setText("Is Output");\r
+ }\r
+\r
+ @Override\r
+ public void setInput(ISessionContext context, Object input) {\r
+ if(input instanceof ISelection) {\r
+ ISelection selection = (ISelection)input;\r
+ if(selection instanceof IStructuredSelection) {\r
+ Resource resource = ISelectionUtils.filterSingleSelection(selection, Resource.class);\r
+ if(resource != null) {\r
+ variable = resource;\r
+ }\r
+ }\r
+ }\r
+ \r
+ if(variable == null) return;\r
+ \r
+ try {\r
+ context.getSession().syncRequest(new ReadRequest() {\r
+ \r
+ @Override\r
+ public void run(ReadGraph graph) throws DatabaseException {\r
+ SysdynResource sr = SysdynResource.getInstance(graph);\r
+ final boolean isOutput = graph.hasStatement(variable, sr.IsOutput);\r
+ final Button button = getWidget();\r
+ button.getDisplay().asyncExec(new Runnable() {\r
+ \r
+ @Override\r
+ public void run() {\r
+ if(button.isDisposed()) return;\r
+ \r
+ if(isOutput)\r
+ button.setSelection(true);\r
+ else\r
+ button.setSelection(false);\r
+ }\r
+ });\r
+\r
+ \r
+ }\r
+ });\r
+ } catch (DatabaseException e) {\r
+ e.printStackTrace();\r
+ }\r
+ \r
+ isOutputButton.addSelectionListener(new SelectionListenerImpl<Resource>(context) {\r
+\r
+ @Override\r
+ public void apply(WriteGraph graph, Resource input) throws DatabaseException {\r
+ SysdynResource sr = SysdynResource.getInstance(graph);\r
+ if(graph.hasStatement(input, sr.IsOutput)) {\r
+ graph.deny(input, sr.IsOutput);\r
+ } else {\r
+ graph.claim(input, SysdynResource.getInstance(graph).IsOutput, null, input);\r
+ }\r
+ }\r
+ });\r
+ }\r
+ \r
+ public Button getWidget() {\r
+ return isOutputButton.getWidget();\r
+ }\r
+\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2010 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.ui.properties.widgets;\r
+\r
+import java.util.HashMap;\r
+\r
+import org.eclipse.jface.viewers.CellEditor;\r
+import org.eclipse.jface.viewers.ComboBoxCellEditor;\r
+import org.eclipse.jface.viewers.EditingSupport;\r
+import org.eclipse.jface.viewers.TableViewer;\r
+import org.eclipse.jface.viewers.TextCellEditor;\r
+import org.eclipse.swt.SWT;\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.common.request.ObjectsWithType;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.db.request.Read;\r
+import org.simantics.layer0.Layer0;\r
+import org.simantics.sysdyn.SysdynResource;\r
+import org.simantics.ui.SimanticsUI;\r
+\r
+public class ModuleInputEditingSupport extends EditingSupport {\r
+ private CellEditor editor;\r
+ private int column;\r
+ private HashMap<String, Resource> optionResources;\r
+ private String[] options;\r
+ private TableViewer tableViewer;\r
+\r
+ public ModuleInputEditingSupport(TableViewer viewer, int column) {\r
+ super(viewer);\r
+ this.tableViewer = (TableViewer)viewer;\r
+ this.column = column;\r
+ }\r
+\r
+ @Override\r
+ protected boolean canEdit(Object element) {\r
+ switch (this.column) {\r
+ case 0: return false;\r
+ default: return true;\r
+ }\r
+ }\r
+\r
+ \r
+ @Override\r
+ protected CellEditor getCellEditor(Object element) {\r
+ // Create the correct editor based on the column index\r
+ switch (column) {\r
+ case 0: \r
+ editor = new TextCellEditor(this.tableViewer.getTable());\r
+ case 1:\r
+ ReferenceRow row = (ReferenceRow)element;\r
+ final Resource module = row.getModule();\r
+ final Resource inputVariable = row.getVariable();\r
+\r
+ optionResources = new HashMap<String, Resource>();\r
+ try {\r
+ optionResources = SimanticsUI.getSession().syncRequest(new Read<HashMap<String, Resource>>() {\r
+\r
+ @Override\r
+ public HashMap<String, Resource> perform(ReadGraph graph) throws DatabaseException {\r
+ Layer0 l0 = Layer0.getInstance(graph);\r
+ SysdynResource sr = SysdynResource.getInstance(graph);\r
+ HashMap<String, Resource> result = new HashMap<String, Resource>();\r
+ for(Resource dependency : graph.syncRequest(new ObjectsWithType(module, sr.IsHeadOf, sr.Dependency))) {\r
+ if(graph.getPossibleObject(dependency, sr.RefersTo) == null ||\r
+ graph.getPossibleObject(dependency, sr.RefersTo).equals(inputVariable)) {\r
+ Resource output = graph.getSingleObject(dependency, sr.HasTail);\r
+ result.put((String)graph.getRelatedValue(output, l0.HasName), dependency);\r
+ }\r
+ }\r
+ return result;\r
+ }\r
+ });\r
+ } catch (DatabaseException e) {\r
+ e.printStackTrace();\r
+ }\r
+\r
+ options = optionResources.keySet().toArray(new String[optionResources.keySet().size() + 1]);\r
+ options[optionResources.keySet().size()] = "";\r
+ ComboBoxCellEditor ceditor = new ComboBoxCellEditor(this.tableViewer.getTable(), options, SWT.READ_ONLY);\r
+ ceditor.setActivationStyle(1);\r
+ editor = ceditor;\r
+ break;\r
+ default:\r
+ editor = null;\r
+ }\r
+\r
+ return editor;\r
+ }\r
+\r
+ @Override\r
+ protected Object getValue(Object element) {\r
+ ReferenceRow referenceRow = (ReferenceRow) element;\r
+\r
+ switch (this.column) {\r
+ case 0:\r
+ return referenceRow.getName();\r
+ case 1:\r
+ String refersToName = referenceRow.getValue();\r
+ if (refersToName == null) return options.length - 1;\r
+ for(int i = 0; i < options.length ; i++) {\r
+ if(refersToName.equals(options[i])) return i;\r
+ }\r
+ return options[options.length - 1];\r
+ default:\r
+ break;\r
+ }\r
+ return null;\r
+ }\r
+\r
+ @Override\r
+ protected void setValue(Object element, Object value) {\r
+ ReferenceRow referenceRow = (ReferenceRow) element;\r
+ String valueString = String.valueOf(value);\r
+ switch (this.column) {\r
+ case 0:\r
+ break;\r
+ case 1:\r
+ referenceRow.setRefersTo(optionResources.get(options[Integer.parseInt(valueString)]));\r
+ break;\r
+ default:\r
+ break;\r
+ }\r
+\r
+ getViewer().update(element, null);\r
+ }\r
+\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2010 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.ui.properties.widgets;\r
+\r
+import java.util.HashMap;\r
+\r
+import org.eclipse.jface.viewers.CellEditor;\r
+import org.eclipse.jface.viewers.ComboBoxCellEditor;\r
+import org.eclipse.jface.viewers.EditingSupport;\r
+import org.eclipse.jface.viewers.TableViewer;\r
+import org.eclipse.jface.viewers.TextCellEditor;\r
+import org.eclipse.swt.SWT;\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.common.request.ObjectsWithType;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.db.request.Read;\r
+import org.simantics.layer0.Layer0;\r
+import org.simantics.sysdyn.SysdynResource;\r
+import org.simantics.ui.SimanticsUI;\r
+\r
+public class ModuleOutputEditingSupport extends EditingSupport {\r
+ private CellEditor editor;\r
+ private int column;\r
+ private HashMap<String, Resource> optionResources;\r
+ private String[] options;\r
+ private TableViewer tableViewer;\r
+\r
+ public ModuleOutputEditingSupport(TableViewer viewer, int column) {\r
+ super(viewer);\r
+ this.tableViewer = (TableViewer)viewer;\r
+ this.column = column;\r
+ }\r
+\r
+ @Override\r
+ protected boolean canEdit(Object element) {\r
+ switch (this.column) {\r
+ case 0: return false;\r
+ default: return true;\r
+ }\r
+ }\r
+\r
+ \r
+ @Override\r
+ protected CellEditor getCellEditor(Object element) {\r
+ // Create the correct editor based on the column index\r
+ switch (column) {\r
+ case 0: \r
+ editor = new TextCellEditor(this.tableViewer.getTable());\r
+ case 1:\r
+ ReferenceRow row = (ReferenceRow)element;\r
+ final Resource module = row.getModule();\r
+ final Resource outputVariable = row.getVariable();\r
+\r
+ optionResources = new HashMap<String, Resource>();\r
+ try {\r
+ optionResources = SimanticsUI.getSession().syncRequest(new Read<HashMap<String, Resource>>() {\r
+\r
+ @Override\r
+ public HashMap<String, Resource> perform(ReadGraph graph) throws DatabaseException {\r
+ Layer0 l0 = Layer0.getInstance(graph);\r
+ SysdynResource sr = SysdynResource.getInstance(graph);\r
+ HashMap<String, Resource> result = new HashMap<String, Resource>();\r
+ for(Resource dependency : graph.syncRequest(new ObjectsWithType(module, sr.IsTailOf, sr.Dependency))) {\r
+ if(graph.getPossibleObject(dependency, sr.RefersTo) == null ||\r
+ graph.getPossibleObject(dependency, sr.RefersTo).equals(outputVariable)) {\r
+ Resource input = graph.getSingleObject(dependency, sr.HasHead);\r
+ result.put((String)graph.getRelatedValue(input, l0.HasName), dependency);\r
+ }\r
+ }\r
+ return result;\r
+ }\r
+ });\r
+ } catch (DatabaseException e) {\r
+ e.printStackTrace();\r
+ }\r
+\r
+ options = optionResources.keySet().toArray(new String[optionResources.keySet().size() + 1]);\r
+ options[optionResources.keySet().size()] = "";\r
+ ComboBoxCellEditor ceditor = new ComboBoxCellEditor(this.tableViewer.getTable(), options, SWT.READ_ONLY);\r
+ ceditor.setActivationStyle(1);\r
+ editor = ceditor;\r
+ break;\r
+ default:\r
+ editor = null;\r
+ }\r
+\r
+ return editor;\r
+ }\r
+\r
+ @Override\r
+ protected Object getValue(Object element) {\r
+ ReferenceRow referenceRow = (ReferenceRow) element;\r
+\r
+ switch (this.column) {\r
+ case 0:\r
+ return referenceRow.getName();\r
+ case 1:\r
+ String refersToName = referenceRow.getValue();\r
+ if (refersToName == null) return options.length - 1;\r
+ for(int i = 0; i < options.length ; i++) {\r
+ if(refersToName.equals(options[i])) return i;\r
+ }\r
+ return options[options.length - 1];\r
+ default:\r
+ break;\r
+ }\r
+ return null;\r
+ }\r
+\r
+ @Override\r
+ protected void setValue(Object element, Object value) {\r
+ ReferenceRow referenceRow = (ReferenceRow) element;\r
+ String valueString = String.valueOf(value);\r
+ switch (this.column) {\r
+ case 0:\r
+ break;\r
+ case 1:\r
+ referenceRow.setRefersTo(optionResources.get(options[Integer.parseInt(valueString)]));\r
+ break;\r
+ default:\r
+ break;\r
+ }\r
+\r
+ getViewer().update(element, null);\r
+ }\r
+\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2010 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.ui.properties.widgets;\r
+\r
+import org.simantics.databoard.Bindings;\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.WriteGraph;\r
+import org.simantics.db.common.request.WriteRequest;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.db.request.Read;\r
+import org.simantics.layer0.Layer0;\r
+import org.simantics.sysdyn.SysdynResource;\r
+import org.simantics.ui.SimanticsUI;\r
+\r
+public class ReferenceRow {\r
+\r
+ Resource variable, module, dependency;\r
+ String name;\r
+\r
+ public ReferenceRow(Resource module, Resource dependency, Resource variable) {\r
+ this.module = module;\r
+ this.variable = variable;\r
+ this.dependency = dependency;\r
+ }\r
+\r
+\r
+ public Resource getModule() {\r
+ return this.module;\r
+ }\r
+\r
+ public Resource getVariable() {\r
+ return this.variable;\r
+ }\r
+\r
+ public Resource getDependency() {\r
+ return this.dependency;\r
+ }\r
+\r
+ public String getName() {\r
+ String name = null;\r
+ try {\r
+ name = SimanticsUI.getSession().syncRequest(new Read<String>() {\r
+\r
+ @Override\r
+ public String perform(ReadGraph graph) throws DatabaseException {\r
+ return (String)graph.getRelatedValue(getVariable(), Layer0.getInstance(graph).HasName);\r
+ }\r
+ });\r
+ } catch (DatabaseException e) {\r
+ e.printStackTrace();\r
+ }\r
+ return name;\r
+ }\r
+\r
+ public String getValue() {\r
+ if(dependency == null) return "";\r
+\r
+ String value = null;\r
+ try {\r
+ value = SimanticsUI.getSession().syncRequest(new Read<String>() {\r
+\r
+ @Override\r
+ public String perform(ReadGraph graph) throws DatabaseException {\r
+ Layer0 l0 = Layer0.getInstance(graph);\r
+ SysdynResource sr = SysdynResource.getInstance(graph);\r
+ Resource valueResource = graph.getPossibleObject(dependency, sr.HasTail);\r
+ if(!graph.isInstanceOf(valueResource, sr.Variable))\r
+ valueResource = graph.getPossibleObject(dependency, sr.HasHead);\r
+ if(!graph.isInstanceOf(valueResource, sr.Variable))\r
+ return "";\r
+ return (String)graph.getRelatedValue(valueResource, l0.HasName, Bindings.STRING);\r
+ }\r
+ });\r
+ } catch (DatabaseException e) {\r
+ e.printStackTrace();\r
+ }\r
+ return value;\r
+ }\r
+\r
+ public void setRefersTo(final Resource dependency) {\r
+ if(dependency != null && dependency.equals(this.dependency)) return;\r
+ SimanticsUI.getSession().asyncRequest(new WriteRequest() {\r
+ @Override\r
+ public void perform(WriteGraph graph) throws DatabaseException {\r
+ SysdynResource sr = SysdynResource.getInstance(graph);\r
+ if(getDependency() != null && graph.hasStatement(getDependency(), sr.RefersTo))\r
+ graph.deny(getDependency(), sr.RefersTo);\r
+ setDependency(null);\r
+ if(dependency != null) {\r
+ setDependency(dependency);\r
+ graph.claim(getDependency(), SysdynResource.getInstance(graph).RefersTo, getVariable());\r
+ }\r
+ }\r
+ });\r
+ }\r
+\r
+ private void setDependency(Resource dependency) {\r
+ this.dependency = dependency;\r
+ }\r
+}\r
+\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2010 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.ui.properties.widgets;\r
+\r
+import org.eclipse.jface.viewers.ITableLabelProvider;\r
+import org.eclipse.jface.viewers.LabelProvider;\r
+import org.eclipse.swt.graphics.Image;\r
+\r
+public class ReferenceRowLabelProvider extends LabelProvider implements ITableLabelProvider {\r
+\r
+ @Override\r
+ public Image getColumnImage(Object element, int columnIndex) {\r
+ return null;\r
+ }\r
+\r
+ @Override\r
+ public String getColumnText(Object element, int columnIndex) {\r
+ ReferenceRow referenceRow = (ReferenceRow) element;\r
+ switch (columnIndex) {\r
+ case 0:\r
+ return referenceRow.getName();\r
+ case 1:\r
+ return referenceRow.getValue();\r
+ default:\r
+ throw new RuntimeException("Should not happen");\r
+ }\r
+ }\r
+}
\ No newline at end of file
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2010 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.ui.properties.widgets;\r
+\r
+import java.util.ArrayList;\r
+import org.eclipse.jface.layout.GridDataFactory;\r
+import org.eclipse.jface.layout.GridLayoutFactory;\r
+import org.eclipse.jface.viewers.IBaseLabelProvider;\r
+import org.eclipse.jface.viewers.IContentProvider;\r
+import org.eclipse.jface.viewers.ISelection;\r
+import org.eclipse.jface.viewers.TableViewer;\r
+import org.eclipse.jface.viewers.Viewer;\r
+import org.eclipse.jface.viewers.ViewerComparator;\r
+import org.eclipse.swt.SWT;\r
+import org.eclipse.swt.widgets.Composite;\r
+import org.eclipse.swt.widgets.Table;\r
+import org.simantics.browsing.ui.swt.widgets.impl.Widget;\r
+import org.simantics.browsing.ui.swt.widgets.impl.WidgetSupport;\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.db.management.ISessionContext;\r
+import org.simantics.db.procedure.Listener;\r
+import org.simantics.db.request.Read;\r
+import org.simantics.ui.SimanticsUI;\r
+import org.simantics.utils.ui.ISelectionUtils;\r
+\r
+public class ReferenceTable implements Widget{\r
+\r
+ private TableViewer tableViewer;\r
+ private RowProvider rowProvider;\r
+\r
+ public static final String FIRSTCOLUMN = "Inputs";\r
+ public static final String SECONDCOLUMN = "Outputs";\r
+ \r
+ public ReferenceTable(Composite parent, WidgetSupport support, int style) {\r
+ support.register(this);\r
+\r
+ Composite base = new Composite(parent, style);\r
+ GridLayoutFactory.fillDefaults().applyTo(base);\r
+ GridDataFactory.fillDefaults().grab(true, true).applyTo(base);\r
+\r
+ Table table = new Table(base, SWT.BORDER|SWT.SINGLE|SWT.FULL_SELECTION);\r
+ GridDataFactory.fillDefaults().grab(true, true).applyTo(table);\r
+ table.setHeaderVisible (true);\r
+ table.setLinesVisible(true);\r
+ table.getVerticalBar().setVisible(true);\r
+\r
+ tableViewer = new TableViewer (table);\r
+ tableViewer.setComparator(new ReferenceRowComparator());\r
+ }\r
+\r
+ public TableViewer getTableViewer() {\r
+ return this.tableViewer;\r
+ }\r
+\r
+ public void setRowProvider(RowProvider rowProvider) {\r
+ this.rowProvider = rowProvider;\r
+ }\r
+ \r
+ public void setContentProvider(IContentProvider provider) {\r
+ tableViewer.setContentProvider(provider);\r
+ }\r
+ \r
+ public void setLabelProvider(IBaseLabelProvider labelProvider) {\r
+ tableViewer.setLabelProvider(labelProvider);\r
+ }\r
+\r
+ @Override\r
+ public void setInput(ISessionContext context, Object input) {\r
+ final Resource module = ISelectionUtils.filterSingleSelection((ISelection)input, Resource.class);\r
+ if(this.rowProvider != null) {\r
+ try {\r
+ SimanticsUI.getSession().syncRequest(new Read<ArrayList<ReferenceRow>>() {\r
+\r
+ @Override\r
+ public ArrayList<ReferenceRow> perform(ReadGraph graph) throws DatabaseException {\r
+ return rowProvider.getRows(graph, module);\r
+ }\r
+ } , new Listener<ArrayList<ReferenceRow>>() {\r
+\r
+ @Override\r
+ public boolean isDisposed() {\r
+ if(tableViewer != null && tableViewer.getTable() != null)\r
+ return getTableViewer().getTable().isDisposed();\r
+ else\r
+ return true;\r
+ }\r
+\r
+ @Override\r
+ public void execute(final ArrayList<ReferenceRow> result) {\r
+ if(!isDisposed())\r
+ getTableViewer().getTable().getDisplay().asyncExec(new Runnable() {\r
+ \r
+ @Override\r
+ public void run() {\r
+ if(!isDisposed())\r
+ getTableViewer().setInput(result);\r
+ }\r
+ });\r
+ }\r
+\r
+ @Override\r
+ public void exception(Throwable t) {\r
+ }\r
+ }\r
+ );\r
+ } catch (DatabaseException e) {\r
+ e.printStackTrace();\r
+ }\r
+ }\r
+ }\r
+\r
+ private class ReferenceRowComparator extends ViewerComparator {\r
+ @Override\r
+ public int compare(Viewer viewer, Object e1, Object e2) {\r
+ ReferenceRow rr1 = (ReferenceRow)e1;\r
+ ReferenceRow rr2 = (ReferenceRow)e2;\r
+ return rr1.getName().compareTo(rr2.getName());\r
+ }\r
+ }\r
+\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2010 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.ui.properties.widgets;\r
+\r
+import java.util.ArrayList;\r
+\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.exception.DatabaseException;\r
+\r
+public abstract class RowProvider { \r
+ public abstract ArrayList<ReferenceRow> getRows(ReadGraph graph, Resource module) throws DatabaseException;\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2010 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.ui.properties.widgets;\r
+\r
+import java.util.ArrayList;\r
+import java.util.Collection;\r
+import java.util.HashSet;\r
+import java.util.concurrent.CopyOnWriteArrayList;\r
+\r
+import org.eclipse.jface.layout.GridDataFactory;\r
+import org.eclipse.jface.layout.GridLayoutFactory;\r
+import org.eclipse.jface.viewers.IStructuredSelection;\r
+import org.eclipse.swt.SWT;\r
+import org.eclipse.swt.events.FocusListener;\r
+import org.eclipse.swt.events.MouseListener;\r
+import org.eclipse.swt.widgets.Composite;\r
+import org.eclipse.swt.widgets.TabFolder;\r
+import org.eclipse.swt.widgets.TabItem;\r
+import org.eclipse.swt.widgets.Table;\r
+import org.eclipse.swt.widgets.TableItem;\r
+import org.simantics.browsing.ui.swt.widgets.impl.Widget;\r
+import org.simantics.browsing.ui.swt.widgets.impl.WidgetSupport;\r
+import org.simantics.db.AsyncReadGraph;\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.db.management.ISessionContext;\r
+import org.simantics.db.procedure.AsyncListener;\r
+import org.simantics.db.request.Read;\r
+import org.simantics.layer0.Layer0;\r
+import org.simantics.sysdyn.SysdynResource;\r
+import org.simantics.ui.SimanticsUI;\r
+import org.simantics.utils.ui.ISelectionUtils;\r
+\r
+public class ShortcutTabWidget implements Widget {\r
+\r
+ TabFolder tabFolder;\r
+ TabItem variables;\r
+ TabItem functions;\r
+ Table variableTable;\r
+ Table functionTable;\r
+ Composite composite;\r
+ \r
+ CopyOnWriteArrayList<Runnable> dependencyListeners =\r
+ new CopyOnWriteArrayList<Runnable>();\r
+\r
+ public ShortcutTabWidget(Composite parent, WidgetSupport support, int style) {\r
+ if(support!=null)\r
+ support.register(this);\r
+\r
+ composite = new Composite(parent, style);\r
+ GridLayoutFactory.fillDefaults().numColumns(2).applyTo(composite);\r
+ \r
+ tabFolder = new TabFolder (composite, SWT.NONE);\r
+ GridDataFactory.fillDefaults().grab(false, true).applyTo(tabFolder);\r
+ GridLayoutFactory.fillDefaults().applyTo(tabFolder);\r
+ variables = new TabItem(tabFolder, SWT.NULL);\r
+ variables.setText("Variables");\r
+ variableTable = new Table (tabFolder, SWT.SINGLE | SWT.BORDER | SWT.FULL_SELECTION);\r
+\r
+ variables.setControl(variableTable);\r
+\r
+ functions = new TabItem(tabFolder, SWT.NULL);\r
+ functions.setText("Functions"); \r
+ functionTable = new Table (tabFolder, SWT.SINGLE | SWT.BORDER | SWT.FULL_SELECTION);\r
+ TableItem item = new TableItem(functionTable, SWT.NONE);\r
+ item.setText("min()");\r
+ item.setData("min({ })");\r
+ item = new TableItem(functionTable, SWT.NONE);\r
+ item.setText("max()");\r
+ item.setData("max({ })");\r
+ item = new TableItem(functionTable, SWT.NONE);\r
+ item.setText("abs()");\r
+ item.setData("abs({ })");\r
+ item = new TableItem(functionTable, SWT.NONE);\r
+ item.setText("if then else");\r
+ item.setData("if then else");\r
+ item = new TableItem(functionTable, SWT.NONE);\r
+ item.setText("xidz()");\r
+ item.setData("xidz( number, divisor , x)");\r
+ item = new TableItem(functionTable, SWT.NONE);\r
+ item.setText("interpolate()");\r
+ item.setData("interpolate( x, table)"); \r
+ item = new TableItem(functionTable, SWT.NONE);\r
+ item.setText("delay()");\r
+ item.setData("delay( expression, delayTime)"); \r
+ functions.setControl(functionTable);\r
+ }\r
+\r
+ public Composite getWidget() {\r
+ return composite;\r
+ }\r
+ \r
+ @Override\r
+ public void setInput(ISessionContext context, Object input) {\r
+ if(input instanceof IStructuredSelection) {\r
+ final Resource variable = ISelectionUtils.filterSingleSelection((IStructuredSelection)input, Resource.class);\r
+ if(variable != null) {\r
+ \r
+ SimanticsUI.getSession().asyncRequest(new Read<HashSet<String>>() {\r
+\r
+ @Override\r
+ public HashSet<String> perform(ReadGraph graph)\r
+ throws DatabaseException {\r
+ return getDependencies(graph, variable);\r
+ }\r
+ }, new AsyncListener<HashSet<String>>() {\r
+\r
+ @Override\r
+ public void execute(AsyncReadGraph graph,\r
+ HashSet<String> result) {\r
+ \r
+ final HashSet<String> dependencies = result;\r
+ variableTable.getDisplay().asyncExec(new Runnable() {\r
+ \r
+ @Override\r
+ public void run() {\r
+ if(variableTable.isDisposed()) return;\r
+ \r
+ TableItem[] items = variableTable.getItems();\r
+ \r
+ // Remove deleted dependencies and create the list of current dependencies (itemStrings)\r
+ ArrayList<String> itemStrings = new ArrayList<String>();\r
+ for(TableItem i : items) {\r
+ String text = i.getText();\r
+ if(dependencies.contains(text))\r
+ itemStrings.add(text);\r
+ else\r
+ variableTable.remove(variableTable.indexOf(i));\r
+ }\r
+ \r
+ // Add all new dependencies\r
+ TableItem item;\r
+ for(String d : dependencies) {\r
+ if(!itemStrings.contains(d)) {\r
+ item = new TableItem(variableTable, SWT.NONE);\r
+ item.setText(d);\r
+ item.setData(d);\r
+ }\r
+ }\r
+ \r
+ synchronized(dependencyListeners) {\r
+ for(Runnable listener : dependencyListeners)\r
+ listener.run();\r
+ } \r
+ }\r
+ });\r
+ }\r
+\r
+ @Override\r
+ public void exception(AsyncReadGraph graph,\r
+ Throwable throwable) {\r
+ throwable.printStackTrace();\r
+ }\r
+\r
+ @Override\r
+ public boolean isDisposed() {\r
+ return variableTable.isDisposed();\r
+ }\r
+ });\r
+ }\r
+ }\r
+ }\r
+\r
+ // Returns the names of the related variables (dependencies)\r
+ private HashSet<String> getDependencies(ReadGraph graph, Resource r) throws DatabaseException {\r
+ HashSet<String> variables = new HashSet<String>();\r
+ if(graph != null && r != null) {\r
+ SysdynResource sr = SysdynResource.getInstance(graph);\r
+ Layer0 l0 = Layer0.getInstance(graph);\r
+\r
+ Collection<Resource> dependencies = graph.getObjects(r, sr.IsHeadOf);\r
+\r
+ for(Resource d : dependencies) {\r
+ if(graph.isInstanceOf(d, sr.Dependency)) {\r
+ Resource tail = graph.getPossibleObject(d, sr.HasTail);\r
+ if(tail != null) {\r
+ Object name = graph.getPossibleRelatedValue(tail, l0.HasName);\r
+ if(name != null)\r
+ variables.add((String)name);\r
+ }\r
+ }\r
+ }\r
+ }\r
+ return variables;\r
+ }\r
+ \r
+ public void addFocusListener(FocusListener listener) {\r
+ this.functionTable.addFocusListener(listener);\r
+ this.variableTable.addFocusListener(listener);\r
+ }\r
+ \r
+ public void addMouseListener(MouseListener listener) {\r
+ this.functionTable.addMouseListener(listener);\r
+ this.variableTable.addMouseListener(listener);\r
+ }\r
+ \r
+ public void addDependencyListener(Runnable listener) {\r
+ synchronized(dependencyListeners) {\r
+ dependencyListeners.add(listener);\r
+ }\r
+ }\r
+\r
+ public void removeDependencyListener(Runnable listener) {\r
+ synchronized(dependencyListeners) {\r
+ dependencyListeners.remove(listener);\r
+ }\r
+ }\r
+ \r
+ public Table getVariableTable() {\r
+ return variableTable;\r
+ }\r
+\r
+\r
+}\r
--- /dev/null
+package org.simantics.sysdyn.ui.properties.widgets.arrays;\r
+\r
+import java.util.ArrayList;\r
+import java.util.Collection;\r
+\r
+import org.simantics.browsing.ui.common.node.AbstractNode;\r
+import org.simantics.browsing.ui.graph.impl.contributor.viewpoint.ViewpointContributorImpl;\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.common.request.ObjectsWithType;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.layer0.Layer0;\r
+import org.simantics.sysdyn.SysdynResource;\r
+\r
+public class AvailableEnumerations extends ViewpointContributorImpl<Resource> {\r
+\r
+ @Override\r
+ public Collection<?> getContribution(ReadGraph graph, Resource input)\r
+ throws DatabaseException {\r
+ if(input == null) return null;\r
+ Layer0 l0 = Layer0.getInstance(graph);\r
+ Resource configuration = graph.getPossibleObject(input, l0.PartOf);\r
+ ArrayList<AbstractNode<Resource>> result = new ArrayList<AbstractNode<Resource>>();\r
+ SysdynResource sr = SysdynResource.getInstance(graph);\r
+ if(configuration == null) \r
+ return result;\r
+ for(Resource r : graph.syncRequest(new ObjectsWithType(configuration, l0.ConsistsOf, sr.Enumeration))) {\r
+ result.add(new EnumerationNode(r));\r
+ }\r
+ return result;\r
+ }\r
+\r
+ @Override\r
+ public String getViewpointId() {\r
+ return "Used enumerations";\r
+ }\r
+\r
+\r
+}\r
--- /dev/null
+package org.simantics.sysdyn.ui.properties.widgets.arrays;\r
+\r
+\r
+import java.util.ArrayList;\r
+import java.util.List;\r
+\r
+import org.eclipse.swt.SWT;\r
+import org.eclipse.swt.events.SelectionAdapter;\r
+import org.eclipse.swt.events.SelectionEvent;\r
+import org.eclipse.swt.widgets.Combo;\r
+import org.eclipse.swt.widgets.Composite;\r
+import org.simantics.browsing.ui.NodeContext;\r
+import org.simantics.browsing.ui.common.modifiers.EnumeratedValue;\r
+import org.simantics.browsing.ui.common.modifiers.Enumeration;\r
+import org.simantics.browsing.ui.content.Labeler.CustomModifier;\r
+import org.simantics.db.Session;\r
+import org.simantics.db.WriteGraph;\r
+import org.simantics.db.common.request.WriteRequest;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.utils.ObjectUtils;\r
+\r
+public abstract class ComboBoxModifier<T> implements CustomModifier {\r
+\r
+ private final Enumeration<T> enumeration;\r
+ private final EnumeratedValue<T> value;\r
+ private final List<String> values;\r
+ private final Session session;\r
+ private Combo combo;\r
+ int select;\r
+\r
+ public ComboBoxModifier(Session session, Enumeration<T> enumeration, T value) {\r
+ this(session, enumeration, enumeration.find(value));\r
+ }\r
+\r
+ public ComboBoxModifier(Session session, Enumeration<T> enumeration,\r
+ EnumeratedValue<T> value) {\r
+ if (session == null)\r
+ throw new NullPointerException("null session");\r
+ if (enumeration == null)\r
+ throw new NullPointerException("null enumeration");\r
+ if (enumeration.size() == 0)\r
+ throw new IllegalArgumentException("");\r
+\r
+ this.enumeration = enumeration;\r
+ this.value = value;\r
+ this.session = session;\r
+\r
+ select = 0;\r
+ boolean found = false;\r
+ \r
+ this.values = new ArrayList<String>();\r
+ for (EnumeratedValue<T> v : enumeration.values()) {\r
+ values.add(v.getName());\r
+ \r
+ if(v == value) \r
+ found = true;\r
+ \r
+ if(found == false)\r
+ select++;\r
+ }\r
+ }\r
+\r
+ @Override\r
+ public Object createControl(Object parentControl, Object controlItem,\r
+ int columnIndex, NodeContext context) {\r
+\r
+ combo = new Combo((Composite) parentControl, SWT.DROP_DOWN\r
+ | SWT.BORDER | SWT.READ_ONLY);\r
+\r
+ for (String item : values) {\r
+ combo.add(item);\r
+ }\r
+ \r
+ combo.addSelectionListener(new SelectionAdapter() {\r
+ @Override\r
+ public void widgetSelected(SelectionEvent e) {\r
+ String index = ((Combo) e.getSource()).getText();\r
+ modify(index);\r
+ }\r
+ });\r
+ \r
+ combo.select(select);\r
+ \r
+ return combo;\r
+\r
+ }\r
+\r
+ @Override\r
+ public String getValue() {\r
+ return enumeration.values().get(0).getName();\r
+ }\r
+\r
+ @Override\r
+ public final String isValid(String label) {\r
+ if (enumeration.findByName(label) == null)\r
+ return "Value '" + label + "' is not among the enumerated values " + enumeration.values();\r
+ return null;\r
+ }\r
+\r
+ @Override\r
+ public void modify(String label) {\r
+ \r
+ int index = values.indexOf(label);\r
+ if (index == -1)\r
+ throw new IllegalArgumentException("Cannot modify enumeration with value '" + label + "', not among the enumerated values " + values);\r
+ \r
+ EnumeratedValue<T> oldEnumValue = value;\r
+ EnumeratedValue<T> newEnumValue = enumeration.values().get(index);\r
+ \r
+ final T oldObject = oldEnumValue != null ? oldEnumValue.getObject() : null;\r
+ final T newObject = newEnumValue != null ? newEnumValue.getObject() : null;\r
+ \r
+ if (ObjectUtils.objectEquals(oldObject, newObject))\r
+ return;\r
+\r
+ try {\r
+ session.getSession().syncRequest(new WriteRequest() {\r
+ @Override\r
+ public void perform(WriteGraph graph) throws DatabaseException {\r
+ modifyWithObject(graph, oldObject, newObject);\r
+ }\r
+ });\r
+ } catch (DatabaseException e) {\r
+ handleException(e);\r
+ }\r
+ \r
+ combo.dispose(); \r
+ }\r
+ \r
+ protected abstract void modifyWithObject(WriteGraph graph, T oldEnumObject, T enumObject) throws DatabaseException;\r
+ \r
+ protected void handleException(DatabaseException e) {\r
+ throw new RuntimeException(e);\r
+ }\r
+\r
+}\r
--- /dev/null
+package org.simantics.sysdyn.ui.properties.widgets.arrays;\r
+\r
+import org.simantics.browsing.ui.graph.contributor.labeler.LabelerContributor;\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.layer0.Layer0;\r
+\r
+public class EnumerationIndexLabeler extends LabelerContributor<EnumerationIndexNode>{\r
+\r
+ @Override\r
+ public String getLabel(ReadGraph graph, EnumerationIndexNode index) throws DatabaseException {\r
+ Resource r = index.data;\r
+ if(r == null) return "Null resource";\r
+ String name = graph.getPossibleRelatedValue(r, Layer0.getInstance(graph).HasName);\r
+ return name == null ? "No name" : name;\r
+ }\r
+\r
+\r
+}\r
--- /dev/null
+package org.simantics.sysdyn.ui.properties.widgets.arrays;\r
+\r
+import org.simantics.browsing.ui.common.node.AbstractNode;\r
+import org.simantics.browsing.ui.common.node.IDoubleClickableNode;\r
+import org.simantics.browsing.ui.common.node.IModifiableNode;\r
+import org.simantics.browsing.ui.content.Labeler.Modifier;\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.WriteGraph;\r
+import org.simantics.db.common.request.WriteRequest;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.db.request.Read;\r
+import org.simantics.layer0.Layer0;\r
+import org.simantics.sysdyn.SysdynResource;\r
+import org.simantics.sysdyn.ui.utils.VariableNameUtils;\r
+import org.simantics.ui.SimanticsUI;\r
+\r
+public class EnumerationIndexNode extends AbstractNode<Resource> implements IModifiableNode, IDoubleClickableNode {\r
+\r
+ public EnumerationIndexNode(Resource resource) {\r
+ super(resource);\r
+ }\r
+ \r
+ @Override\r
+ public Modifier getModifier(String columnId) {\r
+ Modifier modifier = new Modifier() {\r
+\r
+ @Override\r
+ public String getValue() {\r
+ Read<String> request =\r
+ new Read<String>() {\r
+\r
+ @Override\r
+ public String perform(ReadGraph graph) throws DatabaseException {\r
+ String name = graph.getPossibleRelatedValue(data, Layer0.getInstance(graph).HasName);\r
+ return name != null ? name : "";\r
+ }\r
+\r
+ };\r
+ try {\r
+ return SimanticsUI.getSession().syncRequest(request);\r
+ } catch (DatabaseException e) {\r
+ e.printStackTrace();\r
+ return "";\r
+ }\r
+ }\r
+\r
+ @Override\r
+ public String isValid(String label) {\r
+ if(!VariableNameUtils.isValid(label))\r
+ return "Not valid";\r
+ return null;\r
+ }\r
+\r
+ @Override\r
+ public void modify(final String label) {\r
+ SimanticsUI.getSession().asyncRequest(new WriteRequest() {\r
+ @Override\r
+ public void perform(WriteGraph graph) throws DatabaseException {\r
+ graph.claimLiteral(data, Layer0.getInstance(graph).HasName, label);\r
+ }\r
+ });\r
+ }\r
+\r
+ };\r
+ \r
+ return modifier;\r
+ \r
+ \r
+ \r
+ \r
+ }\r
+\r
+ @Override\r
+ public boolean handleDoubleClick() {\r
+ return true;\r
+ }\r
+ \r
+ public void setShowInChartsSelected(final boolean selected) {\r
+ try {\r
+ SimanticsUI.getSession().syncRequest(new WriteRequest() {\r
+ @Override\r
+ public void perform(WriteGraph graph) throws DatabaseException {\r
+ SysdynResource sr = SysdynResource.getInstance(graph);\r
+ graph.claimLiteral(data, sr.ShowEnumerationIndexInCharts, selected);\r
+ }\r
+ });\r
+ } catch (DatabaseException e) {\r
+ e.printStackTrace();\r
+ }\r
+ }\r
+\r
+}\r
--- /dev/null
+package org.simantics.sysdyn.ui.properties.widgets.arrays;\r
+\r
+import java.util.ArrayList;\r
+import java.util.Collection;\r
+\r
+import org.simantics.browsing.ui.common.node.AbstractNode;\r
+import org.simantics.browsing.ui.graph.impl.contributor.viewpoint.ViewpointContributorImpl;\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.common.utils.OrderedSetUtils;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.sysdyn.SysdynResource;\r
+\r
+public class EnumerationIndexes extends ViewpointContributorImpl<Resource> {\r
+\r
+ @Override\r
+ public Collection<?> getContribution(ReadGraph graph, Resource input)\r
+ throws DatabaseException {\r
+ if(input == null) \r
+ return null;\r
+ SysdynResource sr = SysdynResource.getInstance(graph);\r
+ if(!graph.isInstanceOf(input, sr.Enumeration))\r
+ return null;\r
+ Resource enumerationIndexList = graph.getPossibleObject(input, sr.HasEnumerationIndexes);\r
+ if(enumerationIndexList == null)\r
+ return null;\r
+ ArrayList<AbstractNode<Resource>> result = new ArrayList<AbstractNode<Resource>>();\r
+ for(Resource r : OrderedSetUtils.toList(graph, enumerationIndexList)) {\r
+ result.add(new EnumerationIndexNode(r));\r
+ }\r
+ return result;\r
+ }\r
+\r
+ @Override\r
+ public String getViewpointId() {\r
+ return "Enumeration indexes";\r
+ }\r
+\r
+\r
+}\r
--- /dev/null
+package org.simantics.sysdyn.ui.properties.widgets.arrays;\r
+\r
+import java.util.HashMap;\r
+import java.util.ListIterator;\r
+import java.util.Map;\r
+\r
+import org.simantics.browsing.ui.graph.impl.contributor.labeler.ColumnLabelerContributorImpl;\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.common.utils.NameUtils;\r
+import org.simantics.db.common.utils.OrderedSetUtils;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.sysdyn.SysdynResource;\r
+import org.simantics.sysdyn.ui.properties.widgets.ColumnKeys;\r
+\r
+public class EnumerationLabeler extends ColumnLabelerContributorImpl<EnumerationNode>{\r
+\r
+ @Override\r
+ public Map<String, String> getLabel(ReadGraph graph, EnumerationNode input)\r
+ throws DatabaseException {\r
+ \r
+ String name = NameUtils.getSafeName(graph, input.data);\r
+ HashMap<String, String> map = new HashMap<String, String>();\r
+ map.put(ColumnKeys.ENUMERATION, name);\r
+ \r
+ SysdynResource sr = SysdynResource.getInstance(graph);\r
+ \r
+ Resource enumerationIndexes = graph.getPossibleObject(input.data, sr.HasEnumerationIndexes);\r
+ ListIterator<Resource> indexes = OrderedSetUtils.iterator(graph, enumerationIndexes);\r
+ StringBuilder sb = new StringBuilder();\r
+ sb.append("[");\r
+ while(indexes.hasNext()) {\r
+ Resource i = indexes.next();\r
+ sb.append(NameUtils.getSafeName(graph, i));\r
+ if(indexes.hasNext())\r
+ sb.append(", ");\r
+ }\r
+ sb.append("]");\r
+ \r
+ Boolean relaceable = graph.getPossibleRelatedValue(input.data, sr.IsReplaceable);\r
+ if(Boolean.TRUE.equals(relaceable)) {\r
+ sb.append(" Replaceable");\r
+ }\r
+ \r
+ map.put(ColumnKeys.INDEXES, sb.toString());\r
+ \r
+ return map;\r
+ }\r
+\r
+\r
+\r
+}\r
--- /dev/null
+package org.simantics.sysdyn.ui.properties.widgets.arrays;\r
+\r
+import org.simantics.browsing.ui.common.node.AbstractNode;\r
+import org.simantics.db.Resource;\r
+\r
+public class EnumerationNode extends AbstractNode<Resource> {\r
+\r
+ public EnumerationNode(Resource resource) {\r
+ super(resource);\r
+ }\r
+\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2011 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.ui.properties.widgets.arrays;\r
+\r
+import java.util.ArrayList;\r
+\r
+import org.simantics.browsing.ui.common.modifiers.EnumeratedValue;\r
+import org.simantics.browsing.ui.common.modifiers.Enumeration;\r
+import org.simantics.browsing.ui.common.node.AbstractNode;\r
+import org.simantics.browsing.ui.common.node.IModifiableNode;\r
+import org.simantics.browsing.ui.content.Labeler.Modifier;\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.WriteGraph;\r
+import org.simantics.db.common.request.ObjectsWithType;\r
+import org.simantics.db.common.utils.NameUtils;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.db.request.Read;\r
+import org.simantics.layer0.Layer0;\r
+import org.simantics.layer0.utils.direct.GraphUtils;\r
+import org.simantics.sysdyn.SysdynResource;\r
+import org.simantics.sysdyn.ui.properties.widgets.ColumnKeys;\r
+import org.simantics.ui.SimanticsUI;\r
+\r
+public class RedeclarationNode extends AbstractNode<Resource> implements IModifiableNode {\r
+\r
+ private Resource module;\r
+ \r
+ public RedeclarationNode(ReadGraph graph, final Resource module, Resource enumeration) {\r
+ super(enumeration);\r
+ this.module = module;\r
+ }\r
+ \r
+ /**\r
+ * \r
+ * @param graph\r
+ * @return\r
+ */\r
+ public Resource getReplacingEnumeration(ReadGraph graph) {\r
+ SysdynResource sr = SysdynResource.getInstance(graph);\r
+ Resource result = null;\r
+ try {\r
+ Resource redeclaration = getRedeclaration(graph);\r
+ if(redeclaration != null) {\r
+ result = graph.getSingleObject(redeclaration, sr.ReplacingEnumeration);\r
+ }\r
+ } catch(DatabaseException e) {\r
+ e.printStackTrace();\r
+ }\r
+ \r
+ return result;\r
+ }\r
+ \r
+\r
+ public Resource getModule() {\r
+ return module;\r
+ }\r
+\r
+ public void setModule(Resource module) {\r
+ this.module = module;\r
+ }\r
+\r
+ public Resource getRedeclaration(ReadGraph graph) {\r
+ try {\r
+ SysdynResource sr = SysdynResource.getInstance(graph);\r
+ for(Resource redeclaration : graph.syncRequest(new ObjectsWithType(module, sr.HasRedeclaration, sr.Redeclaration))) {\r
+ Resource replacedEnumeration = graph.getPossibleObject(redeclaration, sr.ReplacedEnumeration);\r
+ if(replacedEnumeration != null && replacedEnumeration.equals(getReplacedEnumeration())) {\r
+ return redeclaration;\r
+ }\r
+ }\r
+ } catch (DatabaseException e) {\r
+ e.printStackTrace();\r
+ }\r
+ return null;\r
+ }\r
+\r
+ public void setRedeclaration(WriteGraph graph, Resource redeclaration) {\r
+ try {\r
+ SysdynResource sr = SysdynResource.getInstance(graph);\r
+ Resource oldRedeclaration = getRedeclaration(graph);\r
+ if(oldRedeclaration != null || redeclaration == null) {\r
+ graph.deny(module, sr.HasRedeclaration, oldRedeclaration);\r
+ }\r
+ \r
+ if(redeclaration != null)\r
+ graph.claim(module, sr.HasRedeclaration, redeclaration);\r
+ \r
+ } catch (DatabaseException e) {\r
+ e.printStackTrace();\r
+ }\r
+ }\r
+\r
+ public Resource getReplacedEnumeration() {\r
+ return this.data;\r
+ }\r
+\r
+ @Override\r
+ public Modifier getModifier(String columnId) {\r
+ \r
+ if(!ColumnKeys.REPLACED_WITH.equals(columnId))\r
+ return null;\r
+ \r
+ ComboBoxModifier<Resource> cbm = null;\r
+ \r
+ try {\r
+ cbm = SimanticsUI.getSession().syncRequest(new Read<ComboBoxModifier<Resource>>() {\r
+ \r
+ @Override\r
+ public ComboBoxModifier<Resource> perform(ReadGraph graph) throws DatabaseException {\r
+ SysdynResource sr = SysdynResource.getInstance(graph);\r
+ Layer0 l0 = Layer0.getInstance(graph);\r
+ \r
+ ArrayList<EnumeratedValue<Resource>> values = new ArrayList<EnumeratedValue<Resource>>();\r
+ \r
+ \r
+ Resource configuration = graph.getSingleObject(module, l0.PartOf);\r
+ \r
+ for(Resource enumeration : graph.syncRequest(new ObjectsWithType(configuration, l0.ConsistsOf, sr.Enumeration))) {\r
+ String name = NameUtils.getSafeName(graph, enumeration);\r
+ values.add(new EnumeratedValue<Resource>(name, enumeration)); \r
+ }\r
+\r
+ if(values.size() == 0)\r
+ return null;\r
+ \r
+ values.add(0, new EnumeratedValue<Resource>("", null));\r
+ Enumeration<Resource> enumeration = new Enumeration<Resource>(values); \r
+ \r
+ ComboBoxModifier<Resource> cbm = new ComboBoxModifier<Resource>(graph.getSession(), enumeration, getReplacingEnumeration(graph)) {\r
+ \r
+ @Override\r
+ protected void modifyWithObject(WriteGraph graph, Resource oldEnumObject,\r
+ Resource enumObject) throws DatabaseException {\r
+ \r
+ if(enumObject == null) {\r
+ setRedeclaration(graph, null);\r
+ } else if(!enumObject.equals(oldEnumObject)) {\r
+ SysdynResource sr = SysdynResource.getInstance(graph);\r
+ Resource redeclaration = GraphUtils.create2(graph, \r
+ sr.Redeclaration, \r
+ sr.ReplacedEnumeration, getReplacedEnumeration(),\r
+ sr.ReplacingEnumeration, enumObject);\r
+ setRedeclaration(graph, redeclaration);\r
+ }\r
+ \r
+ }\r
+ };\r
+ \r
+ return cbm;\r
+ \r
+ }\r
+ });\r
+ } catch (DatabaseException e) {\r
+ // TODO Auto-generated catch block\r
+ e.printStackTrace();\r
+ }\r
+\r
+ return cbm;\r
+ }\r
+ \r
+ \r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2011 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.ui.properties.widgets.arrays;\r
+\r
+import java.util.ArrayList;\r
+import java.util.Collection;\r
+\r
+import org.simantics.browsing.ui.graph.impl.contributor.viewpoint.ViewpointContributorImpl;\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.common.request.ObjectsWithType;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.layer0.Layer0;\r
+import org.simantics.structural.stubs.StructuralResource2;\r
+import org.simantics.sysdyn.SysdynResource;\r
+\r
+public class ReplaceableEnumerations extends ViewpointContributorImpl<Resource> {\r
+ \r
+ @Override\r
+ public Collection<?> getContribution(ReadGraph graph, Resource input)\r
+ throws DatabaseException {\r
+ ArrayList<RedeclarationNode> result = new ArrayList<RedeclarationNode>();\r
+ if(input == null)\r
+ return result;\r
+ \r
+ SysdynResource sr = SysdynResource.getInstance(graph);\r
+ Layer0 l0 = Layer0.getInstance(graph);\r
+ StructuralResource2 sr2 = StructuralResource2.getInstance(graph);\r
+ \r
+ Resource moduleType = graph.getSingleObject(input, l0.InstanceOf);\r
+ Resource configuration = graph.getSingleObject(moduleType, sr2.IsDefinedBy);\r
+ \r
+ for(Resource r : graph.syncRequest(new ObjectsWithType(configuration, l0.ConsistsOf, sr.Enumeration))) {\r
+ if(Boolean.TRUE.equals(graph.getRelatedValue(r, sr.IsReplaceable)))\r
+ result.add(new RedeclarationNode(graph, input, r));\r
+ }\r
+ \r
+ return result;\r
+ }\r
+\r
+ @Override\r
+ public String getViewpointId() {\r
+ return "Replaceable enumerations";\r
+ }\r
+\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2011 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.ui.properties.widgets.arrays;\r
+\r
+import java.util.HashMap;\r
+import java.util.Map;\r
+\r
+import org.simantics.browsing.ui.graph.impl.contributor.labeler.ColumnLabelerContributorImpl;\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.common.utils.NameUtils;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.sysdyn.ui.properties.widgets.ColumnKeys;\r
+\r
+public class ReplaceableEnumerationsLabeler extends ColumnLabelerContributorImpl<RedeclarationNode>{\r
+\r
+ @Override\r
+ public Map<String, String> getLabel(ReadGraph graph, RedeclarationNode input)\r
+ throws DatabaseException {\r
+ HashMap<String, String> map = new HashMap<String, String>();\r
+ \r
+ String name = NameUtils.getSafeName(graph, input.data);\r
+ map.put(ColumnKeys.ENUMERATION, name);\r
+ \r
+ Resource replacingEnumeration = input.getReplacingEnumeration(graph); \r
+ String replacingEnumerationName = "";\r
+ if(replacingEnumeration != null)\r
+ replacingEnumerationName = NameUtils.getSafeName(graph, replacingEnumeration);\r
+ \r
+ map.put(ColumnKeys.REPLACED_WITH, replacingEnumerationName);\r
+ return map;\r
+ }\r
+\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2011 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.ui.properties.widgets.arrays;\r
+\r
+import org.eclipse.jface.viewers.ISelection;\r
+import org.eclipse.jface.viewers.IStructuredSelection;\r
+import org.eclipse.swt.SWT;\r
+import org.eclipse.swt.events.SelectionListener;\r
+import org.eclipse.swt.widgets.Button;\r
+import org.eclipse.swt.widgets.Composite;\r
+import org.simantics.browsing.ui.swt.widgets.impl.SelectionListenerImpl;\r
+import org.simantics.browsing.ui.swt.widgets.impl.Widget;\r
+import org.simantics.browsing.ui.swt.widgets.impl.WidgetSupport;\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.WriteGraph;\r
+import org.simantics.db.common.request.ReadRequest;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.db.management.ISessionContext;\r
+import org.simantics.sysdyn.SysdynResource;\r
+import org.simantics.utils.ui.ISelectionUtils;\r
+\r
+public class ReplaceableIndexesWidget implements Widget {\r
+ \r
+ Resource variable = null; \r
+ boolean selected = false;\r
+ org.simantics.browsing.ui.swt.widgets.Button isReplaceableButton;\r
+ \r
+ public ReplaceableIndexesWidget(Composite parent, WidgetSupport support, int style) {\r
+ support.register(this);\r
+ isReplaceableButton = new org.simantics.browsing.ui.swt.widgets.Button(parent, support, style |= SWT.CHECK);\r
+ isReplaceableButton.setText("Can be replaced by parent module");\r
+ }\r
+\r
+ @Override\r
+ public void setInput(ISessionContext context, Object input) {\r
+ if(input instanceof ISelection) {\r
+ ISelection selection = (ISelection)input;\r
+ if(selection instanceof IStructuredSelection) {\r
+ Resource resource = ISelectionUtils.filterSingleSelection(selection, Resource.class);\r
+ if(resource != null) {\r
+ variable = resource;\r
+ }\r
+ }\r
+ }\r
+ \r
+ if(variable == null) return;\r
+ \r
+ try {\r
+ context.getSession().syncRequest(new ReadRequest() {\r
+ \r
+ @Override\r
+ public void run(ReadGraph graph) throws DatabaseException {\r
+ SysdynResource sr = SysdynResource.getInstance(graph);\r
+ final Boolean replaceable = graph.getPossibleRelatedValue(variable, sr.IsReplaceable);\r
+ if(replaceable != null)\r
+ selected = replaceable;\r
+ final Button button = getWidget();\r
+ button.getDisplay().asyncExec(new Runnable() {\r
+ \r
+ @Override\r
+ public void run() {\r
+ if(button.isDisposed()) return;\r
+ \r
+ if(replaceable)\r
+ button.setSelection(true);\r
+ else\r
+ button.setSelection(false);\r
+ }\r
+ });\r
+\r
+ \r
+ }\r
+ });\r
+ } catch (DatabaseException e) {\r
+ e.printStackTrace();\r
+ }\r
+ \r
+ isReplaceableButton.addSelectionListener(new SelectionListenerImpl<Resource>(context) {\r
+\r
+ @Override\r
+ public void apply(WriteGraph graph, Resource input) throws DatabaseException {\r
+ SysdynResource sr = SysdynResource.getInstance(graph);\r
+ Boolean replaceable = graph.getPossibleRelatedValue(input, sr.IsReplaceable);\r
+ if(Boolean.TRUE.equals(replaceable)) {\r
+ graph.claimLiteral(input, sr.IsReplaceable, false);\r
+ selected = false;\r
+ } else {\r
+ graph.claimLiteral(input, sr.IsReplaceable, true);\r
+ selected = true;\r
+ }\r
+ }\r
+ });\r
+ }\r
+ \r
+ public Button getWidget() {\r
+ return isReplaceableButton.getWidget();\r
+ }\r
+ \r
+ public boolean getSelection() {\r
+ return selected;\r
+ }\r
+ \r
+ public void addSelectionListener(SelectionListener listener) {\r
+ isReplaceableButton.addSelectionListener(listener);\r
+ }\r
+\r
+}\r
--- /dev/null
+package org.simantics.sysdyn.ui.properties.widgets.arrays;\r
+\r
+import org.simantics.browsing.ui.CheckedState;\r
+import org.simantics.browsing.ui.graph.contributor.labeler.CheckedStateContributor;\r
+import org.simantics.databoard.Bindings;\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.sysdyn.SysdynResource;\r
+\r
+public class ShowInChartsCheckBox extends CheckedStateContributor<EnumerationIndexNode> {\r
+\r
+ @Override\r
+ public CheckedState getState(ReadGraph graph, EnumerationIndexNode input)\r
+ throws DatabaseException {\r
+ SysdynResource sr = SysdynResource.getInstance(graph);\r
+ Boolean selected = graph.getPossibleRelatedValue(input.data, sr.ShowEnumerationIndexInCharts, Bindings.BOOLEAN);\r
+ return selected ? CheckedState.CHECKED : CheckedState.NOT_CHECKED;\r
+ }\r
+ \r
+}\r
+\r
--- /dev/null
+package org.simantics.sysdyn.ui.properties.widgets.arrays;\r
+\r
+import java.util.ArrayList;\r
+import java.util.Collection;\r
+\r
+import org.simantics.browsing.ui.common.node.AbstractNode;\r
+import org.simantics.browsing.ui.graph.impl.contributor.viewpoint.ViewpointContributorImpl;\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.common.utils.OrderedSetUtils;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.sysdyn.SysdynResource;\r
+\r
+public class UsedEnumerations extends ViewpointContributorImpl<Resource> {\r
+\r
+ @Override\r
+ public Collection<?> getContribution(ReadGraph graph, Resource input)\r
+ throws DatabaseException {\r
+ SysdynResource sr = SysdynResource.getInstance(graph);\r
+ \r
+ ArrayList<AbstractNode<Resource>> result = new ArrayList<AbstractNode<Resource>>();\r
+ \r
+ Resource arrayIndexes = graph.getPossibleObject(input, sr.HasArrayIndexes);\r
+ if(arrayIndexes == null) {\r
+ return result;\r
+ }\r
+ for(Resource r : OrderedSetUtils.toList(graph, arrayIndexes)) {\r
+ result.add(new EnumerationNode(r));\r
+ }\r
+ return result;\r
+ }\r
+\r
+ @Override\r
+ public String getViewpointId() {\r
+ return "Available enumerations";\r
+ }\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2010 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.ui.properties.widgets.arrays;\r
+\r
+import java.util.ArrayList;\r
+import java.util.Collection;\r
+import java.util.List;\r
+\r
+import org.simantics.browsing.ui.common.node.AbstractNode;\r
+import org.simantics.browsing.ui.graph.impl.contributor.viewpoint.ViewpointContributorImpl;\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.exception.DatabaseException;\r
+\r
+public class UsedEnumerationsManyVariables extends ViewpointContributorImpl<List<Resource>> {\r
+\r
+ @Override\r
+ public Collection<?> getContribution(ReadGraph graph, List<Resource> input)\r
+ throws DatabaseException {\r
+ \r
+ ArrayList<AbstractNode<Resource>> result = new ArrayList<AbstractNode<Resource>>();\r
+\r
+// SysdynResource sr = SysdynResource.getInstance(graph);\r
+\r
+// Resource arrayIndexes = graph.getPossibleObject(input, sr.HasArrayIndexes);\r
+// if(arrayIndexes == null) {\r
+// return result;\r
+// }\r
+// for(Resource r : OrderedSetUtils.toList(graph, arrayIndexes)) {\r
+// result.add(new EnumerationNode(r));\r
+// }\r
+ return result;\r
+ }\r
+\r
+ @Override\r
+ public String getViewpointId() {\r
+ return "Available enumerations";\r
+ }\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2010 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.ui.properties.widgets.expressions;\r
+\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.db.request.Read;\r
+import org.simantics.sysdyn.SysdynResource;\r
+import org.simantics.ui.SimanticsUI;\r
+\r
+public class AuxiliaryExpression extends BasicExpression {\r
+\r
+ public AuxiliaryExpression() {\r
+ try {\r
+ this.expressionType = SimanticsUI.getSession().syncRequest(new Read<Resource>() {\r
+\r
+ @Override\r
+ public Resource perform(ReadGraph graph) throws DatabaseException {\r
+ return SysdynResource.getInstance(graph).NormalExpression;\r
+ }\r
+ });\r
+ } catch (DatabaseException e) {\r
+ e.printStackTrace();\r
+ }\r
+ }\r
+\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2010 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.ui.properties.widgets.expressions;\r
+\r
+import java.util.Arrays;\r
+import java.util.List;\r
+import java.util.Map;\r
+\r
+import org.eclipse.jface.layout.GridDataFactory;\r
+import org.eclipse.jface.layout.GridLayoutFactory;\r
+import org.eclipse.jface.text.BadLocationException;\r
+import org.eclipse.jface.text.IDocument;\r
+import org.eclipse.swt.SWT;\r
+import org.eclipse.swt.custom.VerifyKeyListener;\r
+import org.eclipse.swt.events.FocusListener;\r
+import org.eclipse.swt.events.KeyListener;\r
+import org.eclipse.swt.events.ModifyListener;\r
+import org.eclipse.swt.graphics.Point;\r
+import org.eclipse.swt.widgets.Composite;\r
+import org.eclipse.swt.widgets.Label;\r
+import org.simantics.databoard.Bindings;\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.VirtualGraph;\r
+import org.simantics.db.WriteGraph;\r
+import org.simantics.db.common.request.WriteRequest;\r
+import org.simantics.db.common.utils.OrderedSetUtils;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.db.request.Read;\r
+import org.simantics.layer0.utils.direct.GraphUtils;\r
+import org.simantics.sysdyn.SysdynResource;\r
+import org.simantics.sysdyn.ui.utils.ExpressionUtils;\r
+import org.simantics.ui.SimanticsUI;\r
+\r
+public class BasicExpression implements IExpression {\r
+\r
+ private ExpressionField expression;\r
+ protected Resource expressionType;\r
+\r
+ @Override\r
+ public void createExpressionFields(Composite parent, Map<String, Object> data) {\r
+ GridLayoutFactory.fillDefaults().numColumns(2).applyTo(parent);\r
+ String equation = data.get("equation") != null ? (String)data.get("equation") : "";\r
+\r
+ Label l = new Label(parent, SWT.NONE);\r
+ l.setText("=");\r
+\r
+ expression = new ExpressionField(parent, SWT.BORDER);\r
+ expression.setExpression(equation);\r
+ GridDataFactory.fillDefaults().grab(true, true).applyTo(expression);\r
+\r
+ }\r
+\r
+ @Override\r
+ public void focus() {\r
+ this.expression.focus();\r
+\r
+ }\r
+\r
+ @Override\r
+ public List<ExpressionField> getExpressionFields() {\r
+ return Arrays.asList(this.expression);\r
+ }\r
+\r
+ @Override\r
+ public void readData(final Resource expression, Map<String, Object> data) {\r
+ String equation = null;\r
+ if (expression != null && data.get("equation") == null) {\r
+ try {\r
+ equation = SimanticsUI.getSession().syncRequest(new Read<String>() {\r
+\r
+ @Override\r
+ public String perform(ReadGraph graph) throws DatabaseException {\r
+ SysdynResource sr = SysdynResource.getInstance(graph);\r
+ if (expression != null) {\r
+ String equation = graph.getPossibleRelatedValue(expression, sr.HasEquation);\r
+ if(equation != null)\r
+ return equation;\r
+ }\r
+ \r
+ return "";\r
+ \r
+ }\r
+\r
+ });\r
+ } catch (DatabaseException e1) {\r
+ e1.printStackTrace();\r
+ }\r
+ data.put("equation", equation);\r
+ }\r
+ }\r
+\r
+ @Override\r
+ public void replaceSelection(String var) {\r
+ if(expression != null) {\r
+ IDocument doc = expression.getDocument();\r
+ try {\r
+ Point selection = expression.getSelection();\r
+ doc.replace(selection.x, selection.y, var);\r
+ expression.setSelection(selection.x + var.length());\r
+ } catch (BadLocationException e) {\r
+ e.printStackTrace();\r
+ }\r
+ }\r
+ }\r
+\r
+ @Override\r
+ public void save(final Resource expression, Map<String, Object> data) {\r
+ final String currentText = this.expression.getExpression();\r
+ final String oldEquation = (String)data.get("equation");\r
+ if(oldEquation == null || \r
+ (currentText != null && expressionType != null)) {\r
+ data.put("equation", currentText);\r
+ SimanticsUI.getSession().asyncRequest(new WriteRequest() {\r
+ @Override\r
+ public void perform(WriteGraph g)\r
+ throws DatabaseException {\r
+ SysdynResource sr = SysdynResource.getInstance(g);\r
+ if(ExpressionUtils.isParameter(currentText)) {\r
+ if(!expressionType.equals(sr.ConstantExpression))\r
+ expressionType = sr.ParameterExpression;\r
+ } else {\r
+ expressionType = sr.NormalExpression;\r
+ }\r
+ if (oldEquation != null \r
+ && expression != null \r
+ && g.isInstanceOf(expression, expressionType) \r
+ && currentText.equals(oldEquation)) {\r
+ return;\r
+ }\r
+ \r
+ if(!g.isInstanceOf(expression, expressionType)) {\r
+ Resource ownerList = OrderedSetUtils.getSingleOwnerList(g, expression);\r
+ final Resource newExpression = GraphUtils.create2(g, expressionType, \r
+ sr.HasEquation, currentText);\r
+ String arrayRange = g.getPossibleRelatedValue(expression, sr.HasArrayRange, Bindings.STRING);\r
+ if(arrayRange != null)\r
+ g.claimLiteral(newExpression, sr.HasArrayRange, arrayRange);\r
+ \r
+ OrderedSetUtils.replace(g, ownerList, expression, newExpression);\r
+ \r
+ final Resource activefor = g.getPossibleObject(expression, sr.HasActiveExpression_Inverse);\r
+ VirtualGraph runtime = g.getService(VirtualGraph.class);\r
+ g.syncRequest(new WriteRequest(runtime) {\r
+ @Override\r
+ public void perform(WriteGraph graph) throws DatabaseException {\r
+ SysdynResource sr = SysdynResource.getInstance(graph);\r
+ if(activefor != null) {\r
+ if(graph.hasStatement(activefor, sr.HasActiveExpression))\r
+ graph.deny(activefor, sr.HasActiveExpression);\r
+ graph.claim(activefor, sr.HasActiveExpression, newExpression);\r
+ }\r
+ }\r
+ }\r
+ );\r
+ } else {\r
+ g.claimLiteral(expression, sr.HasEquation, currentText);\r
+ }\r
+ }\r
+\r
+ });\r
+ }\r
+ }\r
+\r
+ @Override\r
+ public void updateData(Map<String, Object> data) {\r
+ if(this.expression != null && this.expression.getExpression() != null)\r
+ data.put("equation", this.expression.getExpression());\r
+ }\r
+\r
+ @Override\r
+ public void addKeyListener(KeyListener listener) {\r
+ this.expression.getSourceViewer().getTextWidget().addKeyListener(listener);\r
+\r
+ }\r
+\r
+ @Override\r
+ public void addModifyListener(ModifyListener listener) {\r
+ this.expression.getSourceViewer().getTextWidget().addModifyListener(listener);\r
+\r
+ }\r
+\r
+ @Override\r
+ public void addFocusListener(FocusListener listener) {\r
+ this.expression.getSourceViewer().getTextWidget().addFocusListener(listener);\r
+ }\r
+\r
+ @Override\r
+ public void addVerifyKeyListener(VerifyKeyListener listener) {\r
+ this.expression.getSourceViewer().getTextWidget().addVerifyKeyListener(listener);\r
+ }\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2010 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.ui.properties.widgets.expressions;\r
+\r
+import java.util.HashMap;\r
+\r
+import org.eclipse.jface.text.source.ISharedTextColors;\r
+import org.eclipse.swt.graphics.Color;\r
+import org.eclipse.swt.graphics.RGB;\r
+import org.eclipse.swt.widgets.Display;\r
+\r
+public class ColorManager implements ISharedTextColors {\r
+\r
+ protected HashMap<RGB, Color> colorTable = new HashMap<RGB, Color>();\r
+\r
+ @Override\r
+ public void dispose() {\r
+ for(Color c : colorTable.values())\r
+ c.dispose();\r
+ colorTable.clear();\r
+ }\r
+\r
+ @Override\r
+ public Color getColor(RGB rgb) {\r
+ Color color = colorTable.get(rgb);\r
+ if (color == null) {\r
+ color = new Color(Display.getCurrent(), rgb);\r
+ colorTable.put(rgb, color);\r
+ }\r
+ return color;\r
+\r
+\r
+ }\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2010 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.ui.properties.widgets.expressions;\r
+\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.db.request.Read;\r
+import org.simantics.sysdyn.SysdynResource;\r
+import org.simantics.ui.SimanticsUI;\r
+\r
+public class ConstantExpression extends BasicExpression {\r
+\r
+ public ConstantExpression() {\r
+ try {\r
+ this.expressionType = SimanticsUI.getSession().syncRequest(new Read<Resource>() {\r
+\r
+ @Override\r
+ public Resource perform(ReadGraph graph) throws DatabaseException {\r
+ return SysdynResource.getInstance(graph).ConstantExpression;\r
+ }\r
+ });\r
+ } catch (DatabaseException e) {\r
+ e.printStackTrace();\r
+ }\r
+ }\r
+}
\ No newline at end of file
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2010 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.ui.properties.widgets.expressions;\r
+\r
+import java.util.List;\r
+import java.util.Map;\r
+\r
+import org.eclipse.swt.custom.VerifyKeyListener;\r
+import org.eclipse.swt.events.FocusListener;\r
+import org.eclipse.swt.events.KeyListener;\r
+import org.eclipse.swt.events.ModifyListener;\r
+import org.eclipse.swt.widgets.Composite;\r
+import org.simantics.db.Resource;\r
+\r
+public class DelayExpression implements IExpression {\r
+\r
+ @Override\r
+ public void createExpressionFields(Composite parent, Map<String, Object> data) {\r
+ // TODO Auto-generated method stub\r
+ \r
+ }\r
+\r
+ @Override\r
+ public void focus() {\r
+ // TODO Auto-generated method stub\r
+ \r
+ }\r
+\r
+ @Override\r
+ public List<ExpressionField> getExpressionFields() {\r
+ // TODO Auto-generated method stub\r
+ return null;\r
+ }\r
+\r
+ @Override\r
+ public void readData(Resource variable, Map<String, Object> data) {\r
+ // TODO Auto-generated method stub\r
+ \r
+ }\r
+\r
+ @Override\r
+ public void replaceSelection(String var) {\r
+ // TODO Auto-generated method stub\r
+ \r
+ }\r
+\r
+ @Override\r
+ public void save(Resource variable, Map<String, Object> data) {\r
+ // TODO Auto-generated method stub\r
+ \r
+ }\r
+\r
+ @Override\r
+ public void updateData(Map<String, Object> data) {\r
+ // TODO Auto-generated method stub\r
+ \r
+ }\r
+\r
+ @Override\r
+ public void addKeyListener(KeyListener listener) {\r
+ // TODO Auto-generated method stub\r
+ \r
+ }\r
+\r
+ @Override\r
+ public void addModifyListener(ModifyListener listener) {\r
+ // TODO Auto-generated method stub\r
+ \r
+ }\r
+\r
+ @Override\r
+ public void addFocusListener(FocusListener listener) {\r
+ // TODO Auto-generated method stub\r
+ \r
+ }\r
+\r
+ @Override\r
+ public void addVerifyKeyListener(VerifyKeyListener listener) {\r
+ // TODO Auto-generated method stub\r
+ \r
+ }\r
+\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2010 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.ui.properties.widgets.expressions;\r
+\r
+import java.util.List;\r
+import java.util.Map;\r
+\r
+import org.eclipse.swt.custom.VerifyKeyListener;\r
+import org.eclipse.swt.events.FocusListener;\r
+import org.eclipse.swt.events.KeyListener;\r
+import org.eclipse.swt.events.ModifyListener;\r
+import org.eclipse.swt.widgets.Composite;\r
+import org.simantics.db.Resource;\r
+\r
+public class EmptyExpression implements IExpression {\r
+\r
+ @Override\r
+ public void createExpressionFields(Composite parent, Map<String, Object> data) {\r
+ // TODO Auto-generated method stub\r
+ \r
+ }\r
+\r
+ @Override\r
+ public void focus() {\r
+ // TODO Auto-generated method stub\r
+ \r
+ }\r
+\r
+ @Override\r
+ public List<ExpressionField> getExpressionFields() {\r
+ // TODO Auto-generated method stub\r
+ return null;\r
+ }\r
+\r
+ @Override\r
+ public void readData(Resource variable, Map<String, Object> data) {\r
+ // TODO Auto-generated method stub\r
+ \r
+ }\r
+\r
+ @Override\r
+ public void replaceSelection(String var) {\r
+ // TODO Auto-generated method stub\r
+ \r
+ }\r
+\r
+ @Override\r
+ public void save(Resource variable, Map<String, Object> data) {\r
+ // TODO Auto-generated method stub\r
+ \r
+ }\r
+\r
+ @Override\r
+ public void updateData(Map<String, Object> data) {\r
+ // TODO Auto-generated method stub\r
+ \r
+ }\r
+\r
+ @Override\r
+ public void addKeyListener(KeyListener listener) {\r
+ // TODO Auto-generated method stub\r
+ \r
+ }\r
+\r
+ @Override\r
+ public void addModifyListener(ModifyListener listener) {\r
+ // TODO Auto-generated method stub\r
+ \r
+ }\r
+\r
+ @Override\r
+ public void addFocusListener(FocusListener listener) {\r
+ // TODO Auto-generated method stub\r
+ \r
+ }\r
+\r
+ @Override\r
+ public void addVerifyKeyListener(VerifyKeyListener listener) {\r
+ // TODO Auto-generated method stub\r
+ \r
+ }\r
+\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2010 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.ui.properties.widgets.expressions;\r
+\r
+import java.util.List;\r
+\r
+import org.eclipse.jface.layout.GridDataFactory;\r
+import org.eclipse.jface.layout.GridLayoutFactory;\r
+import org.eclipse.jface.text.BadLocationException;\r
+import org.eclipse.jface.text.Document;\r
+import org.eclipse.jface.text.IDocument;\r
+import org.eclipse.jface.text.PaintManager;\r
+import org.eclipse.jface.text.Position;\r
+import org.eclipse.jface.text.source.Annotation;\r
+import org.eclipse.jface.text.source.AnnotationModel;\r
+import org.eclipse.jface.text.source.AnnotationPainter;\r
+import org.eclipse.jface.text.source.DefaultCharacterPairMatcher;\r
+import org.eclipse.jface.text.source.IAnnotationAccess;\r
+import org.eclipse.jface.text.source.MatchingCharacterPainter;\r
+import org.eclipse.jface.text.source.SourceViewer;\r
+import org.eclipse.swt.SWT;\r
+import org.eclipse.swt.custom.StyledText;\r
+import org.eclipse.swt.events.KeyEvent;\r
+import org.eclipse.swt.events.KeyListener;\r
+import org.eclipse.swt.graphics.Color;\r
+import org.eclipse.swt.graphics.RGB;\r
+import org.eclipse.swt.widgets.Composite;\r
+import org.eclipse.swt.widgets.Display;\r
+import org.eclipse.ui.texteditor.DefaultMarkerAnnotationAccess;\r
+import org.eclipse.swt.graphics.Point;\r
+import org.simantics.sysdyn.expressionParser.Token;\r
+\r
+public class ExpressionField extends Composite {\r
+\r
+ protected SourceViewer _sourceViewer;\r
+ protected IDocument _document;\r
+ protected AnnotationModel _annotationModel;\r
+ \r
+ String oldExpression;\r
+\r
+ ColorManager cManager = new ColorManager();\r
+\r
+ IAnnotationAccess annotationAccess = new DefaultMarkerAnnotationAccess();\r
+\r
+ public ExpressionField(Composite parent, int style) {\r
+ super(parent, style);\r
+ \r
+ GridLayoutFactory.fillDefaults().applyTo(this);\r
+ \r
+ int styles = SWT.V_SCROLL\r
+ | SWT.MULTI\r
+ | SWT.FULL_SELECTION\r
+ | SWT.WRAP;\r
+\r
+ _document = new Document();\r
+ _document.set("");\r
+\r
+ _annotationModel = new AnnotationModel();\r
+ _annotationModel.connect(_document);\r
+\r
+ _sourceViewer = new SourceViewer(this,\r
+\r
+ null,\r
+ null,\r
+ true,\r
+ styles);\r
+ _sourceViewer.configure(new ExpressionFieldConfiguration(cManager));\r
+\r
+ AnnotationPainter painter = new AnnotationPainter(_sourceViewer, annotationAccess);\r
+ _sourceViewer.addPainter(painter);\r
+\r
+ painter.addAnnotationType("MissingLink");\r
+ painter.setAnnotationTypeColor("MissingLink", new Color(this.getDisplay(), 255,0,0));\r
+ painter.addAnnotationType("NoSuchVariable");\r
+ painter.setAnnotationTypeColor("NoSuchVariable", new Color(this.getDisplay(), 255,0,0));\r
+ \r
+ _sourceViewer.setDocument(_document, _annotationModel);\r
+\r
+ GridDataFactory.fillDefaults().grab(true, true).applyTo(_sourceViewer.getControl());\r
+// _sourceViewer.getControl().setLayoutData(new GridData(SWT.FILL,\r
+// SWT.FILL,\r
+// true,\r
+// true)); \r
+\r
+ PaintManager paintManager = new PaintManager(_sourceViewer);\r
+ MatchingCharacterPainter matchingCharacterPainter = new MatchingCharacterPainter(_sourceViewer,\r
+ new DefaultCharacterPairMatcher( new char[] {'(', ')', '{', '}', '[', ']'} ));\r
+ matchingCharacterPainter.setColor(new Color(Display.getCurrent(), new RGB(160, 160, 160)));\r
+ paintManager.addPainter(matchingCharacterPainter);\r
+ \r
+ \r
+ _sourceViewer.getTextWidget().addKeyListener(new KeyListener() {\r
+\r
+ @Override\r
+ public void keyReleased(KeyEvent e) {\r
+ }\r
+\r
+ @Override\r
+ public void keyPressed(KeyEvent e) {\r
+ if(e.keyCode == SWT.ESC && getExpression() != null) {\r
+ ((StyledText)e.widget).setText(oldExpression);\r
+ ((StyledText)e.widget).setSelection(getExpression().length());\r
+ } \r
+ }\r
+ });\r
+ \r
+ }\r
+\r
+ public SourceViewer getSourceViewer() {\r
+ return this._sourceViewer;\r
+ }\r
+\r
+ public void setMissingLinkAnnotations(List<Position> positions){\r
+ for(Position p : positions) {\r
+ Annotation annotation = new Annotation(false);\r
+ annotation.setType("MissingLink");\r
+ annotation.setText("No link to this variable");\r
+ _annotationModel.addAnnotation(annotation, p); \r
+ }\r
+ }\r
+ \r
+ public void setNoSuchVariableAnnotations(List<Position> positions){\r
+ for(Position p : positions) {\r
+ Annotation annotation = new Annotation(false);\r
+ annotation.setType("NoSuchVariable");\r
+ annotation.setText("No such variable in model");\r
+ _annotationModel.addAnnotation(annotation, p); \r
+ }\r
+ }\r
+\r
+ public void setSyntaxError(Token token, String message){\r
+ setSyntaxError(token.image, message, token.beginLine, token.beginColumn, token.endLine, token.endColumn);\r
+ }\r
+ \r
+ public void setSyntaxError(org.simantics.sysdyn.tableParser.Token token, String message){\r
+ setSyntaxError(token.image, message, token.beginLine, token.beginColumn, token.endLine, token.endColumn);\r
+ }\r
+ \r
+ public void setSyntaxError(String image, String message, int beginLine, int beginColumn, int endLine, int endColumn) {\r
+ int start = 0;\r
+ int offset = this._document.getLength();\r
+ if(image != null && this._document.getLength() > 0) {\r
+ try {\r
+ start = this._document.getLineOffset(beginLine - 1) + beginColumn - 1;\r
+ offset = this._document.getLineOffset(endLine - 1) + endColumn - start;\r
+ } catch (BadLocationException e) {\r
+ e.printStackTrace();\r
+ }\r
+ }\r
+ setSyntaxError(start, offset, "MissingLink", message == null ? "Syntax Error" : message);\r
+ }\r
+ \r
+ public void setSyntaxError(int start, int offset, String type, String text) {\r
+ Annotation annotation = new Annotation(false);\r
+ annotation.setType(type);\r
+ annotation.setText(text);\r
+ Position p = new Position(start, offset);\r
+ _annotationModel.addAnnotation(annotation, p); \r
+ }\r
+\r
+ public void resetAnnotations() {\r
+ _annotationModel.removeAllAnnotations();\r
+ }\r
+ public void setExpression(String expression) {\r
+ _document.set(expression);\r
+ this.oldExpression = expression;\r
+ }\r
+\r
+ public String getExpression() {\r
+ return this._document.get();\r
+ }\r
+\r
+ public Point getSelection() {\r
+ return _sourceViewer.getSelectedRange();\r
+ }\r
+\r
+ public void setSelection(int selection) {\r
+ this._sourceViewer.setSelectedRange(selection, 0);\r
+ }\r
+\r
+ public IDocument getDocument() {\r
+ return _document;\r
+ }\r
+\r
+ public void focus() {\r
+ this._sourceViewer.getTextWidget().forceFocus();\r
+ }\r
+\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2010 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.ui.properties.widgets.expressions;\r
+\r
+import org.eclipse.jface.text.DefaultTextHover;\r
+import org.eclipse.jface.text.IDocument;\r
+import org.eclipse.jface.text.ITextHover;\r
+import org.eclipse.jface.text.TextAttribute;\r
+import org.eclipse.jface.text.presentation.IPresentationReconciler;\r
+import org.eclipse.jface.text.presentation.PresentationReconciler;\r
+import org.eclipse.jface.text.rules.DefaultDamagerRepairer;\r
+import org.eclipse.jface.text.rules.IRule;\r
+import org.eclipse.jface.text.rules.ITokenScanner;\r
+import org.eclipse.jface.text.rules.IWordDetector;\r
+import org.eclipse.jface.text.rules.MultiLineRule;\r
+import org.eclipse.jface.text.rules.RuleBasedScanner;\r
+import org.eclipse.jface.text.rules.Token;\r
+import org.eclipse.jface.text.rules.WordRule;\r
+import org.eclipse.jface.text.source.DefaultAnnotationHover;\r
+import org.eclipse.jface.text.source.IAnnotationHover;\r
+import org.eclipse.jface.text.source.ISourceViewer;\r
+import org.eclipse.jface.text.source.SourceViewerConfiguration;\r
+import org.eclipse.swt.SWT;\r
+import org.eclipse.swt.graphics.RGB;\r
+import org.simantics.sysdyn.ui.utils.VariableNameUtils;\r
+\r
+public class ExpressionFieldConfiguration extends SourceViewerConfiguration {\r
+\r
+\r
+ ColorManager colorManager;\r
+\r
+ public ExpressionFieldConfiguration(ColorManager colorManager) {\r
+ super();\r
+ this.colorManager = colorManager;\r
+ }\r
+\r
+ public String[] getConfiguredContentTypes(ISourceViewer sourceViewer) {\r
+ return new String[] {\r
+ IDocument.DEFAULT_CONTENT_TYPE\r
+ };\r
+ }\r
+\r
+ public IPresentationReconciler getPresentationReconciler(ISourceViewer sourceViewer) {\r
+ PresentationReconciler reconciler = new PresentationReconciler();\r
+\r
+ DefaultDamagerRepairer dr = new DefaultDamagerRepairer(getSclTokenScanner());\r
+\r
+ reconciler.setRepairer(dr, IDocument.DEFAULT_CONTENT_TYPE);\r
+ reconciler.setDamager(dr, IDocument.DEFAULT_CONTENT_TYPE);\r
+\r
+ return reconciler;\r
+ }\r
+\r
+\r
+ ITokenScanner getSclTokenScanner() {\r
+ RuleBasedScanner scanner = new RuleBasedScanner();\r
+\r
+ final Token reserved = new Token(\r
+ new TextAttribute(\r
+ colorManager.getColor(new RGB(127, 0, 85)),\r
+ null,\r
+ SWT.BOLD\r
+ ));\r
+ final Token defaultToken = new Token(new TextAttribute(colorManager.getColor(new RGB(0, 0, 0))));\r
+\r
+ final Token comment = new Token(new TextAttribute(colorManager.getColor(new RGB(63, 127, 95))));\r
+\r
+\r
+ WordRule reservedWord = new WordRule(new IWordDetector() { \r
+ @Override\r
+ public boolean isWordStart(char c) {\r
+ return Character.isLetter(c);\r
+ }\r
+\r
+ @Override\r
+ public boolean isWordPart(char c) {\r
+ return Character.isLetter(c);\r
+ }\r
+ }, defaultToken);\r
+ \r
+\r
+ for(String s : VariableNameUtils.keywords) {\r
+ reservedWord.addWord(s, reserved);\r
+ }\r
+\r
+ IRule[] rules = new IRule[] {\r
+ reservedWord,\r
+ new MultiLineRule("/*", "*/", comment)\r
+ };\r
+ scanner.setRules(rules);\r
+\r
+ return scanner; \r
+ }\r
+\r
+ @Override\r
+ public ITextHover getTextHover(ISourceViewer sourceViewer, String contentType) {\r
+ return new DefaultTextHover(sourceViewer);\r
+ }\r
+\r
+ @Override\r
+ public IAnnotationHover getAnnotationHover(ISourceViewer sourceViewer) {\r
+ return new DefaultAnnotationHover();\r
+ }\r
+\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2010 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.ui.properties.widgets.expressions;\r
+\r
+import java.util.List;\r
+import java.util.Map;\r
+\r
+import org.eclipse.swt.custom.VerifyKeyListener;\r
+import org.eclipse.swt.events.FocusListener;\r
+import org.eclipse.swt.events.KeyListener;\r
+import org.eclipse.swt.events.ModifyListener;\r
+import org.eclipse.swt.widgets.Composite;\r
+import org.simantics.db.Resource;\r
+\r
+public interface IExpression {\r
+\r
+ public void createExpressionFields(Composite parent, Map<String, Object> data);\r
+\r
+ public void readData(final Resource expression, Map<String, Object> data);\r
+\r
+ public void save(final Resource expression, Map<String, Object> data);\r
+\r
+ public void focus();\r
+\r
+ public void replaceSelection(String var);\r
+\r
+ public void updateData(Map<String, Object> data);\r
+\r
+ public List<ExpressionField> getExpressionFields();\r
+ \r
+ public void addModifyListener(ModifyListener listener);\r
+ \r
+ public void addKeyListener(KeyListener listener);\r
+ \r
+ public void addVerifyKeyListener(VerifyKeyListener listener);\r
+\r
+ public void addFocusListener(FocusListener listener);\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2010 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.ui.properties.widgets.expressions;\r
+\r
+import java.awt.Point;\r
+import java.awt.event.MouseEvent;\r
+import java.awt.geom.Point2D;\r
+import java.awt.geom.Rectangle2D;\r
+\r
+import org.jfree.chart.ChartPanel;\r
+import org.jfree.chart.ChartRenderingInfo;\r
+import org.jfree.chart.JFreeChart;\r
+import org.jfree.chart.axis.ValueAxis;\r
+import org.jfree.chart.entity.ChartEntity;\r
+import org.jfree.chart.entity.PlotEntity;\r
+import org.jfree.chart.entity.XYItemEntity;\r
+import org.jfree.chart.plot.XYPlot;\r
+import org.jfree.data.general.SeriesChangeListener;\r
+import org.jfree.data.xy.XYDataset;\r
+import org.jfree.data.xy.XYSeries;\r
+import org.jfree.data.xy.XYSeriesCollection;\r
+\r
+@SuppressWarnings("serial")\r
+public class LookupChartPanel extends ChartPanel {\r
+\r
+ private XYItemEntity dragPrevEntity;\r
+ private boolean drawing;\r
+ private XYSeries series; \r
+ private JFreeChart chart;\r
+ private SeriesChangeListener changeListener;\r
+\r
+ public LookupChartPanel(JFreeChart chart) {\r
+ super(chart);\r
+ this.chart = chart;\r
+ XYSeriesCollection collection = (XYSeriesCollection) ((XYPlot)chart.getPlot()).getDataset();\r
+ series = collection.getSeries(0); \r
+ }\r
+\r
+ public void mouseDragged(MouseEvent e)\r
+ {\r
+ if(dragPrevEntity != null) {\r
+\r
+ int item = dragPrevEntity.getItem();\r
+ XYPlot plot = (XYPlot)chart.getPlot();\r
+ ValueAxis rangeAxis = plot.getRangeAxis();\r
+ ValueAxis domainAxis = plot.getDomainAxis();\r
+ Point2D location = getLocationOnChart(getMouseLocation(e));\r
+ Number prevX = item == 0 ? null : series.getX(item - 1);\r
+ Number nextX = item == series.getItemCount() - 1 ? null : series.getX(item + 1);\r
+\r
+\r
+ if(series.indexOf(location.getX()) >= 0 && series.indexOf(location.getX()) != item)\r
+ return;\r
+ else if (prevX != null && location.getX() < prevX.doubleValue())\r
+ location.setLocation(series.getX(item).doubleValue(), location.getY());\r
+ else if (nextX != null && location.getX() > nextX.doubleValue())\r
+ location.setLocation(series.getX(item).doubleValue(), location.getY());\r
+ else if (location.getX() > domainAxis.getUpperBound())\r
+ location.setLocation(domainAxis.getUpperBound(), location.getY());\r
+ else if (location.getX() < domainAxis.getLowerBound()) \r
+ location.setLocation(domainAxis.getLowerBound(), location.getY()); \r
+\r
+ if (location.getY() > rangeAxis.getUpperBound())\r
+ location.setLocation(location.getX(), rangeAxis.getUpperBound());\r
+ else if (location.getY() < rangeAxis.getLowerBound()) \r
+ location.setLocation(location.getX(), rangeAxis.getLowerBound()); \r
+\r
+ removeItemFromSeries(dragPrevEntity.getItem());\r
+ addLocationToSeries(location);\r
+ } else {\r
+ ChartEntity currEntity = this.getEntityForPoint(e.getX(),e.getY());\r
+ if(!drawing && currEntity instanceof XYItemEntity) {\r
+ dragPrevEntity = ((XYItemEntity)currEntity);\r
+ } else if (currEntity instanceof PlotEntity){\r
+ drawing = true;\r
+ Point2D locationOnChart = getLocationOnChart(getMouseLocation(e));\r
+ int item = series.indexOf(locationOnChart.getX());\r
+ if (item >= 0) {\r
+ Point2D location = new Point2D.Double(series.getX(item).doubleValue(), series.getY(item).doubleValue());\r
+ Point2D javaLocation = getLocationOnJava2D(location);\r
+ removeItemFromSeries(item);\r
+ addLocationToSeries(getLocationOnChart(new Point2D.Double(javaLocation.getX(), e.getY())));\r
+ }\r
+ }\r
+ }\r
+\r
+ }\r
+\r
+ public void mouseReleased(MouseEvent e) {\r
+ if(isDragging()) {\r
+ dragPrevEntity = null;\r
+ if(changeListener != null)\r
+ changeListener.seriesChanged(null);\r
+ }\r
+ drawing = false;\r
+\r
+ }\r
+\r
+ public void mouseClicked(MouseEvent e)\r
+ {\r
+ if(e.getButton() == MouseEvent.BUTTON1) {\r
+ addLocationToSeries(getLocationOnChart(getMouseLocation(e)));\r
+ } else if (e.getButton() == MouseEvent.BUTTON3) {\r
+ ChartEntity entity = this.getEntityForPoint(e.getX(),e.getY());\r
+ if(entity instanceof XYItemEntity) {\r
+ XYItemEntity xyentity = ((XYItemEntity)entity);\r
+ removeItemFromSeries(xyentity.getItem());\r
+ }\r
+ }\r
+ } \r
+\r
+ private Point2D getLocationOnChart(Point2D coordinates) {\r
+ XYPlot plot = (XYPlot)chart.getPlot();\r
+ ChartRenderingInfo info = getChartRenderingInfo();\r
+ Rectangle2D dataArea = info.getPlotInfo().getDataArea();\r
+ double chartX = plot.getDomainAxis().java2DToValue(coordinates.getX(), dataArea,\r
+ plot.getDomainAxisEdge());\r
+ double chartY = plot.getRangeAxis().java2DToValue(coordinates.getY(), dataArea,\r
+ plot.getRangeAxisEdge());\r
+ return new Point2D.Double(chartX, chartY);\r
+ }\r
+\r
+ private Point2D getLocationOnJava2D(Point2D location) {\r
+ XYPlot plot = (XYPlot)chart.getPlot();\r
+ ChartRenderingInfo info = getChartRenderingInfo();\r
+ Rectangle2D dataArea = info.getPlotInfo().getDataArea();\r
+ double javaX = plot.getDomainAxis().valueToJava2D(location.getX(), dataArea,\r
+ plot.getDomainAxisEdge());\r
+ double javaY = plot.getRangeAxis().valueToJava2D(location.getY(), dataArea,\r
+ plot.getRangeAxisEdge());\r
+ return new Point2D.Double(javaX, javaY);\r
+ }\r
+\r
+ public void addLocationToSeries(Point2D location) {\r
+ if(series.indexOf(location.getX()) < 0) {\r
+ series.add(location.getX(), location.getY());\r
+ }\r
+ }\r
+\r
+ public void removeItemFromSeries(int item){\r
+ series.remove(item);\r
+ }\r
+ \r
+ public void resetChart(XYDataset dataset) {\r
+ XYPlot plot = (XYPlot)chart.getPlot();\r
+ plot.setDataset(dataset);\r
+ XYSeriesCollection collection = (XYSeriesCollection) plot.getDataset();\r
+ series = collection.getSeries(0); \r
+ }\r
+\r
+ private Point2D getMouseLocation(MouseEvent e) {\r
+ int mouseX = e.getX();\r
+ int mouseY = e.getY();\r
+ Point2D p = translateScreenToJava2D(\r
+ new Point(mouseX, mouseY));\r
+ return p;\r
+ }\r
+\r
+ public void addSeriesChangeListener(SeriesChangeListener listener) {\r
+ this.changeListener = listener;\r
+ this.series.addChangeListener(changeListener);\r
+ }\r
+\r
+ public boolean isDragging() {\r
+ return dragPrevEntity != null;\r
+ }\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2010 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.ui.properties.widgets.expressions;\r
+\r
+import java.util.List;\r
+import java.util.Map;\r
+\r
+import org.eclipse.swt.custom.VerifyKeyListener;\r
+import org.eclipse.swt.events.FocusListener;\r
+import org.eclipse.swt.events.KeyListener;\r
+import org.eclipse.swt.events.ModifyListener;\r
+import org.eclipse.swt.widgets.Composite;\r
+import org.simantics.db.Resource;\r
+\r
+public class LookupExpression implements IExpression {\r
+\r
+ @Override\r
+ public void focus() {\r
+ // TODO Auto-generated method stub\r
+ \r
+ }\r
+\r
+ @Override\r
+ public List<ExpressionField> getExpressionFields() {\r
+ // TODO Auto-generated method stub\r
+ return null;\r
+ }\r
+\r
+ @Override\r
+ public void readData(final Resource variable, Map<String, Object> data) {\r
+ // TODO Auto-generated method stub\r
+ \r
+ }\r
+\r
+ @Override\r
+ public void replaceSelection(String var) {\r
+ // TODO Auto-generated method stub\r
+ \r
+ }\r
+\r
+ @Override\r
+ public void save(final Resource variable, Map<String, Object> data) {\r
+ // TODO Auto-generated method stub\r
+ \r
+ }\r
+\r
+ @Override\r
+ public void updateData(Map<String, Object> data) {\r
+ // TODO Auto-generated method stub\r
+ \r
+ }\r
+\r
+ @Override\r
+ public void createExpressionFields(Composite parent, Map<String, Object> data) {\r
+ // TODO Auto-generated method stub\r
+ \r
+ }\r
+\r
+ @Override\r
+ public void addKeyListener(KeyListener listener) {\r
+ // TODO Auto-generated method stub\r
+ \r
+ }\r
+\r
+ @Override\r
+ public void addModifyListener(ModifyListener listener) {\r
+ // TODO Auto-generated method stub\r
+ \r
+ }\r
+\r
+ @Override\r
+ public void addFocusListener(FocusListener listener) {\r
+ // TODO Auto-generated method stub\r
+ \r
+ }\r
+\r
+ @Override\r
+ public void addVerifyKeyListener(VerifyKeyListener listener) {\r
+ // TODO Auto-generated method stub\r
+ \r
+ }\r
+\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2010 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.ui.properties.widgets.expressions;\r
+\r
+import java.awt.geom.Point2D;\r
+import java.util.ArrayList;\r
+import java.util.Comparator;\r
+import java.util.List;\r
+\r
+import org.eclipse.jface.layout.GridDataFactory;\r
+import org.eclipse.jface.layout.GridLayoutFactory;\r
+import org.eclipse.jface.viewers.ArrayContentProvider;\r
+import org.eclipse.jface.viewers.CellEditor;\r
+import org.eclipse.jface.viewers.ICellModifier;\r
+import org.eclipse.jface.viewers.ITableLabelProvider;\r
+import org.eclipse.jface.viewers.LabelProvider;\r
+import org.eclipse.jface.viewers.TableViewer;\r
+import org.eclipse.jface.viewers.TextCellEditor;\r
+import org.eclipse.jface.viewers.Viewer;\r
+import org.eclipse.jface.viewers.ViewerComparator;\r
+import org.eclipse.swt.SWT;\r
+import org.eclipse.swt.graphics.Image;\r
+import org.eclipse.swt.widgets.Composite;\r
+import org.eclipse.swt.widgets.Event;\r
+import org.eclipse.swt.widgets.Item;\r
+import org.eclipse.swt.widgets.Listener;\r
+import org.eclipse.swt.widgets.Table;\r
+import org.eclipse.swt.widgets.TableColumn;\r
+\r
+public class LookupInputOutputTable extends Composite {\r
+\r
+ public static final String INPUT = "Input";\r
+ public static final String OUTPUT = "Output";\r
+ public static final String[] PROPS = { INPUT, OUTPUT };\r
+\r
+ private Table table;\r
+ private TableViewer tableViewer;\r
+ private List<InputOutput> tableRows;\r
+\r
+ public LookupInputOutputTable(Composite parent, int style) {\r
+ super(parent, style);\r
+\r
+ GridLayoutFactory.fillDefaults().applyTo(this);\r
+ GridDataFactory.fillDefaults().grab(true, true).applyTo(this);\r
+ table = new Table(this, SWT.BORDER|SWT.SINGLE|SWT.FULL_SELECTION);\r
+ GridDataFactory.fillDefaults().grab(true, true).applyTo(table);\r
+ table.setHeaderVisible (true);\r
+ table.setLinesVisible(true);\r
+ table.getVerticalBar().setVisible(true);\r
+ TableColumn column1 = new TableColumn (table, SWT.LEFT);\r
+ column1.setText (INPUT);\r
+ column1.setWidth (85);\r
+\r
+ TableColumn column2 = new TableColumn (table, SWT.LEFT);\r
+ column2.setText (OUTPUT);\r
+ column2.setWidth (85);\r
+\r
+ // Create the viewer and connect it to the view\r
+ tableViewer = new TableViewer (table);\r
+\r
+ tableViewer.setContentProvider (new ArrayContentProvider());\r
+ tableViewer.setLabelProvider (new InputOutputLabelProvider());\r
+ tableViewer.setCellModifier(new InputOutputCellModifier());\r
+\r
+ tableRows = new ArrayList<InputOutput>(); \r
+ tableViewer.setInput(tableRows);\r
+\r
+ CellEditor[] editors = new CellEditor[2];\r
+ editors[0] = new TextCellEditor(table);\r
+ editors[1] = new TextCellEditor(table);\r
+ tableViewer.setCellEditors(editors);\r
+ tableViewer.setColumnProperties(PROPS);\r
+\r
+ }\r
+\r
+ private class InputOutputLabelProvider extends LabelProvider implements ITableLabelProvider {\r
+ public Image getColumnImage (Object element, int columnIndex) {\r
+ return null;\r
+ }\r
+ public String getColumnText (Object element, int columnIndex) {\r
+ if(element instanceof InputOutput) {\r
+ InputOutput io = (InputOutput)element;\r
+ switch (columnIndex) {\r
+ case 0: return (String)io.getInput(String.class);\r
+ case 1: return (String)io.getOutput(String.class);\r
+ }\r
+ }\r
+ return "";\r
+ }\r
+ }\r
+\r
+ public void addLocation(Point2D location) {\r
+ tableRows.add(new InputOutput(location.getX(), location.getY()));\r
+ tableViewer.getTable().getDisplay().asyncExec(new Runnable() {\r
+\r
+ @Override\r
+ public void run() {\r
+ refresh();\r
+ }\r
+ });\r
+\r
+ }\r
+\r
+ public void removeItem(int index) {\r
+ tableRows.remove(index);\r
+ tableViewer.getTable().getDisplay().asyncExec(new Runnable() {\r
+\r
+ @Override\r
+ public void run() {\r
+ refresh();\r
+ }\r
+ });\r
+ }\r
+\r
+ public void clearTable() {\r
+ this.tableRows.clear();\r
+ tableViewer.getTable().getDisplay().asyncExec(new Runnable() {\r
+\r
+ @Override\r
+ public void run() {\r
+ refresh();\r
+ }\r
+ });\r
+ }\r
+\r
+\r
+ public class InputOutput {\r
+ private double input, output;\r
+\r
+ public InputOutput(double input, double output) {\r
+ this.input = input;\r
+ this.output = output;\r
+ }\r
+\r
+ /**\r
+ * \r
+ * @param clazz String.class or Double.class\r
+ * @return input as string or double or null if asked for something else\r
+ */\r
+ @SuppressWarnings("rawtypes")\r
+ public Object getInput(Class clazz) {\r
+ if(clazz == String.class) {\r
+ return "" + input;\r
+ } else if (clazz == Double.class) {\r
+ return input;\r
+ }\r
+ return null;\r
+ }\r
+\r
+ public Double setInput(String input) {\r
+ try {\r
+ this.input = Double.parseDouble(input);\r
+ return this.input;\r
+ } catch (NumberFormatException e) {\r
+ return null;\r
+ }\r
+ }\r
+\r
+ public void setInput(double input) {\r
+ this.input = input;\r
+ }\r
+\r
+ /**\r
+ * \r
+ * @param clazz String.class or Double.class\r
+ * @return output as string or double or null if asked for something else\r
+ */\r
+ @SuppressWarnings("rawtypes")\r
+ public Object getOutput(Class clazz) {\r
+ if(clazz == String.class) {\r
+ return "" + output;\r
+ } else if (clazz == Double.class) {\r
+ return output;\r
+ }\r
+ return null;\r
+ }\r
+\r
+ public void setOutput(String output) {\r
+ try {\r
+ this.output = Double.parseDouble(output);\r
+ } catch (NumberFormatException e) {\r
+\r
+ }\r
+ }\r
+\r
+ public void setOutput(double output) {\r
+ this.output = output;\r
+ }\r
+\r
+ }\r
+\r
+ public class InputOutputComparator extends ViewerComparator implements Comparator<InputOutput>{\r
+ @Override\r
+ public int compare(Viewer viewer, Object e1, Object e2) {\r
+ if ((e1 instanceof InputOutput) &&\r
+ (e2 instanceof InputOutput)) {\r
+ return compare((InputOutput)e1, (InputOutput)e2);\r
+ } else {\r
+ return 0;\r
+ }\r
+ }\r
+\r
+ @Override\r
+ public int compare(InputOutput e1, InputOutput e2) {\r
+ InputOutput io1 = (InputOutput)e1;\r
+ InputOutput io2 = (InputOutput)e2;\r
+ Double d1 = (Double)io1.getInput((Double.class));\r
+ Double d2 = (Double)io2.getInput((Double.class));\r
+ return d1.compareTo(d2);\r
+ }\r
+ }\r
+\r
+ public TableViewer getTableViewer() {\r
+ return this.tableViewer;\r
+ }\r
+\r
+ public void refresh() {\r
+ if(!tableViewer.getTable().isDisposed()) {\r
+ tableViewer.setComparator(new InputOutputComparator());\r
+ tableViewer.refresh();\r
+ }\r
+ }\r
+\r
+ class InputOutputCellModifier implements ICellModifier {\r
+\r
+ public InputOutputCellModifier() {}\r
+\r
+ public boolean canModify(Object element, String property) {\r
+ return true;\r
+ }\r
+\r
+ public Object getValue(Object element, String property) {\r
+ InputOutput io = (InputOutput)element;\r
+ if (LookupInputOutputTable.INPUT.equals(property))\r
+ return (String)io.getInput(String.class);\r
+ else if (LookupInputOutputTable.OUTPUT.equals(property))\r
+ return (String)io.getOutput(String.class);\r
+ else\r
+ return null;\r
+ }\r
+\r
+ public void modify(Object element, String property, Object value) {\r
+ if (element instanceof Item) element = ((Item) element).getData();\r
+\r
+ InputOutput io = (InputOutput)element;\r
+\r
+ if (LookupInputOutputTable.INPUT.equals(property)) {\r
+ io.setInput((String)value);\r
+ } else if (LookupInputOutputTable.OUTPUT.equals(property)) {\r
+ io.setOutput((String)value);\r
+ }\r
+ tableModified();\r
+ refresh();\r
+ }\r
+ }\r
+\r
+ private void tableModified() {\r
+ tableViewer.getTable().getDisplay().asyncExec(new Runnable() {\r
+\r
+ @Override\r
+ public void run() {\r
+ for (Listener listener : getListeners(SWT.Modify)) {\r
+ Event e = new Event();\r
+ listener.handleEvent(e);\r
+ }\r
+ }\r
+ });\r
+\r
+ }\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2010 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.ui.properties.widgets.expressions;\r
+\r
+\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.db.request.Read;\r
+import org.simantics.sysdyn.SysdynResource;\r
+import org.simantics.ui.SimanticsUI;\r
+\r
+public class ParameterExpression extends BasicExpression {\r
+ \r
+\r
+ public ParameterExpression() {\r
+ try {\r
+ this.expressionType = SimanticsUI.getSession().syncRequest(new Read<Resource>() {\r
+\r
+ @Override\r
+ public Resource perform(ReadGraph graph) throws DatabaseException {\r
+ return SysdynResource.getInstance(graph).ParameterExpression;\r
+ }\r
+ });\r
+ } catch (DatabaseException e) {\r
+ e.printStackTrace();\r
+ }\r
+ }\r
+\r
+\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2010 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.ui.properties.widgets.expressions;\r
+\r
+import java.util.Arrays;\r
+import java.util.List;\r
+import java.util.Map;\r
+\r
+import org.eclipse.jface.layout.GridDataFactory;\r
+import org.eclipse.jface.layout.GridLayoutFactory;\r
+import org.eclipse.jface.text.BadLocationException;\r
+import org.eclipse.jface.text.IDocument;\r
+import org.eclipse.swt.SWT;\r
+import org.eclipse.swt.custom.VerifyKeyListener;\r
+import org.eclipse.swt.events.FocusListener;\r
+import org.eclipse.swt.events.KeyListener;\r
+import org.eclipse.swt.events.ModifyListener;\r
+import org.eclipse.swt.graphics.Point;\r
+import org.eclipse.swt.widgets.Composite;\r
+import org.eclipse.swt.widgets.Label;\r
+import org.eclipse.swt.widgets.Text;\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.WriteGraph;\r
+import org.simantics.db.common.request.WriteRequest;\r
+import org.simantics.db.common.utils.OrderedSetUtils;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.db.request.Read;\r
+import org.simantics.layer0.Layer0;\r
+import org.simantics.sysdyn.SysdynResource;\r
+import org.simantics.sysdyn.manager.SysdynModel;\r
+import org.simantics.sysdyn.manager.SysdynModelManager;\r
+import org.simantics.sysdyn.representation.Stock;\r
+import org.simantics.sysdyn.representation.Valve;\r
+import org.simantics.ui.SimanticsUI;\r
+\r
+public class StockExpression implements IExpression {\r
+\r
+ private Text integral;\r
+ private ExpressionField expression;\r
+\r
+ @Override\r
+ public void createExpressionFields(Composite parent, Map<String, Object> data) {\r
+ GridLayoutFactory.fillDefaults().numColumns(2).applyTo(parent);\r
+ String initialEquation = data.get("initialEquation") != null ? (String)data.get("initialEquation") : "";\r
+ String integralEquation = data.get("integral") != null ? (String)data.get("integral") : "";\r
+\r
+\r
+ Label label = new Label(parent, SWT.NONE);\r
+ label.setText("Integral");\r
+\r
+ integral = new Text(parent, SWT.MULTI | SWT.V_SCROLL | SWT.BORDER);\r
+ integral.setEditable(false);\r
+ integral.setText(integralEquation);\r
+ GridDataFactory.fillDefaults().grab(true, true).applyTo(integral);\r
+\r
+\r
+ label = new Label(parent, SWT.NONE);\r
+ label.setText("Initial\nValue");\r
+\r
+ expression = new ExpressionField(parent, SWT.BORDER);\r
+ expression.setExpression(initialEquation);\r
+\r
+ GridDataFactory.fillDefaults().grab(true, true).applyTo(expression);\r
+\r
+ }\r
+\r
+ @Override\r
+ public void focus() {\r
+ this.expression.focus();\r
+ }\r
+\r
+ @Override\r
+ public List<ExpressionField> getExpressionFields() {\r
+ return Arrays.asList(this.expression);\r
+ }\r
+\r
+ @Override\r
+ public void readData(final Resource expression, Map<String, Object> data) {\r
+ String initialEquation = null;\r
+\r
+ if (expression != null && data.get("initialEquation") == null) {\r
+ try {\r
+ initialEquation = SimanticsUI.getSession().syncRequest(new Read<String>() {\r
+\r
+ @Override\r
+ public String perform(ReadGraph graph) throws DatabaseException {\r
+ SysdynResource sr = SysdynResource.getInstance(graph);\r
+ if (graph.isInstanceOf(expression, sr.StockExpression)) {\r
+ return graph.getRelatedValue(expression, sr.HasInitialEquation);\r
+ } else {\r
+ return "";\r
+ }\r
+ }\r
+\r
+ });\r
+ } catch (DatabaseException e1) {\r
+ e1.printStackTrace();\r
+ }\r
+ data.put("initialEquation", initialEquation);\r
+ }\r
+\r
+ data.put("integral", getIntegral(expression));\r
+\r
+ }\r
+\r
+ @Override\r
+ public void replaceSelection(String var) {\r
+ if(expression != null) {\r
+ IDocument doc = expression.getDocument();\r
+ try {\r
+ Point selection = expression.getSelection();\r
+ doc.replace(selection.x, selection.y, var);\r
+ expression.setSelection(selection.x + var.length());\r
+ } catch (BadLocationException e) {\r
+ e.printStackTrace();\r
+ }\r
+ }\r
+ }\r
+\r
+ @Override\r
+ public void save(final Resource expression, Map<String, Object> data) {\r
+ final String currentText = this.expression.getExpression();\r
+ if(currentText != null) {\r
+ SimanticsUI.getSession().asyncRequest(new WriteRequest() {\r
+\r
+ @Override\r
+ public void perform(WriteGraph g)\r
+ throws DatabaseException {\r
+ SysdynResource sr = SysdynResource.getInstance(g);\r
+ Layer0 l0 = Layer0.getInstance(g);\r
+ \r
+ if(!g.isInstanceOf(expression, sr.StockExpression)) {\r
+ Resource expressionList = g.getSingleObject(expression, l0.HasNext);\r
+ Resource temp = g.newResource();\r
+ OrderedSetUtils.replace(g, expressionList, expression, temp);\r
+ for(Resource predicate : g.getPredicates(expression)) {\r
+ g.deny(expression, predicate);\r
+ }\r
+ g.claim(expression, l0.InstanceOf, null, sr.StockExpression);\r
+ OrderedSetUtils.replace(g, expressionList, temp, expression);\r
+ }\r
+ g.claimLiteral(expression, sr.HasInitialEquation, currentText);\r
+ }\r
+\r
+ });\r
+ }\r
+ this.expression.setExpression(currentText);\r
+ }\r
+\r
+ @Override\r
+ public void updateData(Map<String, Object> data) {\r
+ if(this.expression != null && this.expression.getExpression() != null)\r
+ data.put("initialEquation", this.expression.getExpression());\r
+ if(this.integral != null && this.integral.getText() != null)\r
+ data.put("integral", this.integral.getText());\r
+ }\r
+\r
+\r
+ private String getIntegral(final Resource expression) {\r
+ \r
+ String integral = "";\r
+ if(expression == null)\r
+ return integral;\r
+ try {\r
+ integral = SimanticsUI.getSession().syncRequest(new Read<String>() {\r
+\r
+ @Override\r
+ public String perform(ReadGraph graph) throws DatabaseException {\r
+ SysdynResource sr = SysdynResource.getInstance(graph);\r
+ Layer0 l0 = Layer0.getInstance(graph);\r
+ \r
+ // find the variable\r
+ Resource expressionList = OrderedSetUtils.getSingleOwnerList(graph, expression);\r
+ Resource variable = graph.getPossibleObject(expressionList, sr.HasExpressions_Inverse);\r
+ if(variable == null)\r
+ return "";\r
+ \r
+ SysdynModelManager sdm = SysdynModelManager.getInstance(graph.getSession());\r
+ SysdynModel model = sdm.getModel(graph, graph.getSingleObject(variable, l0.PartOf));\r
+ model.update(graph);\r
+ \r
+ Stock stock = (Stock)model.getElement(variable);\r
+ \r
+ String range = graph.getPossibleRelatedValue(expression, sr.HasArrayRange);\r
+ if(range == null)\r
+ range = "";\r
+\r
+ StringBuilder builder = new StringBuilder();\r
+ builder.append("");\r
+ for(Valve in : stock.getIncomingValves()) {\r
+ builder.append(" + " + in.getName() + range);\r
+ }\r
+ for(Valve out : stock.getOutgoingValves()) {\r
+ builder.append(" - " + out.getName() + range);\r
+ }\r
+ if (builder.indexOf(" + ") == 0)\r
+ builder.delete(0, 3);\r
+ \r
+ return builder.toString().trim();\r
+ }\r
+\r
+ });\r
+ } catch (DatabaseException e) {\r
+ e.printStackTrace();\r
+ }\r
+ return integral;\r
+ }\r
+\r
+ @Override\r
+ public void addKeyListener(KeyListener listener) {\r
+ this.expression.getSourceViewer().getTextWidget().addKeyListener(listener);\r
+\r
+ }\r
+\r
+ @Override\r
+ public void addModifyListener(ModifyListener listener) {\r
+ this.expression.getSourceViewer().getTextWidget().addModifyListener(listener);\r
+\r
+ }\r
+\r
+ @Override\r
+ public void addFocusListener(FocusListener listener) {\r
+ this.expression.getSourceViewer().getTextWidget().addFocusListener(listener);\r
+ }\r
+ \r
+ @Override\r
+ public void addVerifyKeyListener(VerifyKeyListener listener) {\r
+ this.expression.getSourceViewer().getTextWidget().addVerifyKeyListener(listener);\r
+ }\r
+\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2010 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.ui.properties.widgets.expressions;\r
+\r
+import java.awt.BasicStroke;\r
+import java.awt.Frame;\r
+import java.awt.event.ActionEvent;\r
+import java.awt.event.ActionListener;\r
+import java.awt.geom.Point2D;\r
+import java.io.StringReader;\r
+import java.util.ArrayList;\r
+import java.util.Arrays;\r
+import java.util.List;\r
+import java.util.Map;\r
+\r
+import javax.swing.Timer;\r
+\r
+import org.eclipse.jface.layout.GridDataFactory;\r
+import org.eclipse.jface.layout.GridLayoutFactory;\r
+import org.eclipse.jface.text.BadLocationException;\r
+import org.eclipse.jface.text.IDocument;\r
+import org.eclipse.swt.SWT;\r
+import org.eclipse.swt.awt.SWT_AWT;\r
+import org.eclipse.swt.custom.VerifyKeyListener;\r
+import org.eclipse.swt.events.FocusAdapter;\r
+import org.eclipse.swt.events.FocusEvent;\r
+import org.eclipse.swt.events.FocusListener;\r
+import org.eclipse.swt.events.KeyListener;\r
+import org.eclipse.swt.events.ModifyEvent;\r
+import org.eclipse.swt.events.ModifyListener;\r
+import org.eclipse.swt.graphics.Point;\r
+import org.eclipse.swt.widgets.Composite;\r
+import org.eclipse.swt.widgets.Label;\r
+import org.jfree.chart.ChartFactory;\r
+import org.jfree.chart.ChartPanel;\r
+import org.jfree.chart.JFreeChart;\r
+import org.jfree.chart.plot.PlotOrientation;\r
+import org.jfree.data.xy.XYDataset;\r
+import org.jfree.data.xy.XYSeries;\r
+import org.jfree.data.xy.XYSeriesCollection;\r
+import org.simantics.databoard.Bindings;\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.VirtualGraph;\r
+import org.simantics.db.WriteGraph;\r
+import org.simantics.db.common.request.WriteRequest;\r
+import org.simantics.db.common.utils.OrderedSetUtils;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.db.procedure.Listener;\r
+import org.simantics.db.request.Read;\r
+import org.simantics.layer0.utils.direct.GraphUtils;\r
+import org.simantics.sysdyn.SysdynResource;\r
+import org.simantics.sysdyn.tableParser.ParseException;\r
+import org.simantics.sysdyn.tableParser.TableParser;\r
+import org.simantics.sysdyn.tableParser.Token;\r
+import org.simantics.ui.SimanticsUI;\r
+\r
+public class WithLookupExpression implements IExpression {\r
+\r
+ private ExpressionField expression;\r
+ private ExpressionField lookup;\r
+ private ExpressionField lastSelectedText = expression;\r
+ private Timer updateChartTimer;\r
+\r
+ private ChartPanel smallPanel;\r
+ private Frame smallFrame;\r
+\r
+ private Resource expr;\r
+\r
+ public WithLookupExpression(Resource expression) {\r
+ this.expr = expression;\r
+ }\r
+\r
+ @Override\r
+ public void createExpressionFields(Composite parent, final Map<String, Object> data) {\r
+ GridLayoutFactory.fillDefaults().numColumns(3).applyTo(parent);\r
+\r
+ updateChartTimer = new Timer(1000, new ActionListener() {\r
+\r
+ @Override\r
+ public void actionPerformed(ActionEvent e) {\r
+ updateChart();\r
+ }\r
+ });\r
+ updateChartTimer.setRepeats(false);\r
+\r
+ String equation = data.get("equation") != null ? (String)data.get("equation") : "";\r
+ String lookupTable = data.get("lookup") != null ? (String)data.get("lookup") : "";\r
+\r
+ Label l = new Label(parent, SWT.NONE);\r
+ l.setText("With\nLookup");\r
+\r
+ expression = new ExpressionField(parent, SWT.BORDER);\r
+ expression.setExpression(equation);\r
+ GridDataFactory.fillDefaults().grab(true, true).applyTo(expression);\r
+\r
+ expression.getSourceViewer().getTextWidget().addFocusListener(new FocusAdapter() {\r
+\r
+ @Override\r
+ public void focusLost(FocusEvent e) {\r
+ lastSelectedText = expression;\r
+ }\r
+ });\r
+\r
+ Composite chartContainer = new Composite(parent, SWT.NONE);\r
+ createChart(chartContainer, data);\r
+\r
+\r
+ l = new Label(parent, SWT.NONE);\r
+ l.setText("Lookup\ntable");\r
+\r
+ lookup = new ExpressionField(parent, SWT.BORDER);\r
+ lookup.setExpression(lookupTable);\r
+ GridDataFactory.fillDefaults().grab(true, true).applyTo(lookup);\r
+\r
+ lookup.getSourceViewer().getTextWidget().addFocusListener(new FocusAdapter() {\r
+\r
+ @Override\r
+ public void focusLost(FocusEvent e) {\r
+ lastSelectedText = lookup;\r
+ save(expr, data);\r
+ }\r
+ });\r
+\r
+ lookup.getSourceViewer().getTextWidget().addModifyListener(new ModifyListener() {\r
+\r
+ @Override\r
+ public void modifyText(ModifyEvent e) {\r
+ if(!updateChartTimer.isRunning())\r
+ updateChartTimer.start();\r
+ else\r
+ updateChartTimer.restart();\r
+ }\r
+ });\r
+\r
+\r
+ SimanticsUI.getSession().asyncRequest(new Read<String>() {\r
+\r
+ @Override\r
+ public String perform(ReadGraph graph) throws DatabaseException {\r
+ SysdynResource sr = SysdynResource.getInstance(graph);\r
+ String result = "";\r
+ if (expr != null && graph.isInstanceOf(expr, sr.WithLookupExpression)) {\r
+ result = graph.getPossibleRelatedValue(expr, sr.HasLookup);\r
+ }\r
+ return result;\r
+ }\r
+ }, new Listener<String>() {\r
+\r
+ @Override\r
+ public void exception(Throwable t) {\r
+ t.printStackTrace();\r
+ }\r
+\r
+ @Override\r
+ public void execute(final String result) {\r
+ if(lookup != null)\r
+ lookup.getDisplay().asyncExec(new Runnable() {\r
+\r
+ @Override\r
+ public void run() {\r
+ lookup.setExpression(result); \r
+ }\r
+ });\r
+ updateChart();\r
+ }\r
+\r
+ @Override\r
+ public boolean isDisposed() {\r
+ if(lookup != null && !lookup.isDisposed()) {\r
+ return false;\r
+ }\r
+ return true;\r
+ }\r
+ });\r
+\r
+ updateChart();\r
+ }\r
+\r
+ @Override\r
+ public void focus() {\r
+ if(this.lastSelectedText != null) this.lastSelectedText.focus(); \r
+ }\r
+\r
+ @Override\r
+ public List<ExpressionField> getExpressionFields() {\r
+ return Arrays.asList(this.expression, this.lookup);\r
+ }\r
+\r
+ @Override\r
+ public void readData(final Resource expression, Map<String, Object> data) {\r
+\r
+ class Auxiliary {\r
+ String equation, lookup;\r
+ }\r
+\r
+ Auxiliary results = null;\r
+\r
+ if (data.get("equation") == null) {\r
+ try {\r
+ results = SimanticsUI.getSession().syncRequest(new Read<Auxiliary>() {\r
+\r
+ @Override\r
+ public Auxiliary perform(ReadGraph graph) throws DatabaseException {\r
+ Auxiliary results = new Auxiliary();\r
+ SysdynResource sr = SysdynResource.getInstance(graph);\r
+ if (expression != null && graph.isInstanceOf(expression, sr.WithLookupExpression)) {\r
+ results.equation = graph.getPossibleRelatedValue(expression, sr.HasEquation);\r
+ results.lookup = graph.getPossibleRelatedValue(expression, sr.HasLookup);\r
+ } else {\r
+ results.equation = "";\r
+ results.lookup = "";\r
+ }\r
+ return results;\r
+ }\r
+ });\r
+ } catch (DatabaseException e1) {\r
+ e1.printStackTrace();\r
+ }\r
+ data.put("equation", results.equation == null ? "" : results.equation);\r
+ data.put("lookup", results.lookup == null ? "" : results.lookup);\r
+ }\r
+\r
+ }\r
+\r
+ @Override\r
+ public void replaceSelection(String var) {\r
+ if(lastSelectedText != null) {\r
+ IDocument doc = lastSelectedText.getDocument();\r
+ try {\r
+ Point selection = lastSelectedText.getSelection();\r
+ doc.replace(selection.x, selection.y, var);\r
+ lastSelectedText.setSelection(selection.x + var.length());\r
+ } catch (BadLocationException e) {\r
+ e.printStackTrace();\r
+ }\r
+ } \r
+ }\r
+\r
+ @Override\r
+ public void save(final Resource expression, Map<String, Object> data) {\r
+ final String currentExpression = this.expression.getExpression();\r
+ final String currentLookupTable = lookup.getExpression();\r
+ String oldExpression = (String)data.get("equation");\r
+ String oldLookupTable = (String)data.get("lookup");\r
+\r
+ if(oldExpression == null || oldLookupTable == null ||\r
+ (currentExpression != null && currentLookupTable != null\r
+ && (!currentExpression.equals(oldExpression) || \r
+ !currentLookupTable.equals(oldLookupTable)))) {\r
+ data.putAll(data);\r
+ data.put("equation", currentExpression);\r
+ data.put("lookup", currentLookupTable);\r
+ SimanticsUI.getSession().asyncRequest(new WriteRequest() {\r
+ @Override\r
+ public void perform(WriteGraph g)\r
+ throws DatabaseException {\r
+ SysdynResource sr = SysdynResource.getInstance(g);\r
+ if(!g.isInstanceOf(expr, sr.WithLookupExpression)) {\r
+ \r
+ \r
+ Resource ownerList = OrderedSetUtils.getSingleOwnerList(g, expression);\r
+ final Resource newExpression = GraphUtils.create2(g, sr.WithLookupExpression,\r
+ sr.HasMinX, 0.0,\r
+ sr.HasMaxX, 10.0,\r
+ sr.HasMinY, 0.0,\r
+ sr.HasMaxY, 10.0);\r
+ String arrayRange = g.getPossibleRelatedValue(expression, sr.HasArrayRange, Bindings.STRING);\r
+ if(arrayRange != null)\r
+ g.claimLiteral(newExpression, sr.HasArrayRange, arrayRange);\r
+ \r
+ OrderedSetUtils.replace(g, ownerList, expr, newExpression);\r
+ final Resource activefor = g.getPossibleObject(expression, sr.HasActiveExpression_Inverse);\r
+ VirtualGraph runtime = g.getService(VirtualGraph.class);\r
+ g.syncRequest(new WriteRequest(runtime) {\r
+ @Override\r
+ public void perform(WriteGraph graph) throws DatabaseException {\r
+ SysdynResource sr = SysdynResource.getInstance(graph);\r
+ if(graph.hasStatement(activefor, sr.HasActiveExpression))\r
+ graph.deny(activefor, sr.HasActiveExpression);\r
+ graph.claim(activefor, sr.HasActiveExpression, newExpression);\r
+ }\r
+ }\r
+ );\r
+ expr = newExpression;\r
+ \r
+ }\r
+ g.claimLiteral(expr, sr.HasEquation, currentExpression);\r
+ g.claimLiteral(expr, sr.HasLookup, currentLookupTable);\r
+ }\r
+ });\r
+ }\r
+\r
+ }\r
+\r
+ @Override\r
+ public void updateData(Map<String, Object> data) {\r
+ if(this.expression != null && this.expression.getExpression() != null)\r
+ data.put("equation", this.expression.getExpression());\r
+ if(this.lookup != null && this.lookup.getExpression() != null)\r
+ data.put("lookup", this.lookup.getExpression()); \r
+ }\r
+\r
+ @Override\r
+ public void addKeyListener(KeyListener listener) {\r
+ this.expression.getSourceViewer().getTextWidget().addKeyListener(listener);\r
+ this.lookup.getSourceViewer().getTextWidget().addKeyListener(listener);\r
+ }\r
+ \r
+ @Override\r
+ public void addVerifyKeyListener(VerifyKeyListener listener) {\r
+ this.expression.getSourceViewer().getTextWidget().addVerifyKeyListener(listener);\r
+ this.lookup.getSourceViewer().getTextWidget().addVerifyKeyListener(listener);\r
+ }\r
+\r
+ @Override\r
+ public void addModifyListener(ModifyListener listener) {\r
+ this.expression.getSourceViewer().getTextWidget().addModifyListener(listener);\r
+ this.lookup.getSourceViewer().getTextWidget().addModifyListener(listener);\r
+ }\r
+\r
+ @Override\r
+ public void addFocusListener(FocusListener listener) {\r
+ this.expression.getSourceViewer().getTextWidget().addFocusListener(listener);\r
+ this.lookup.getSourceViewer().getTextWidget().addFocusListener(listener);\r
+ }\r
+\r
+ private void createChart(Composite composite, final Map<String, Object> data) {\r
+ GridLayoutFactory.fillDefaults().applyTo(composite);\r
+ GridDataFactory.fillDefaults().span(1, 2).hint(150, SWT.DEFAULT).applyTo(composite);\r
+ final Composite chartComposite = new Composite(composite, \r
+ SWT.NO_BACKGROUND | SWT.EMBEDDED);\r
+ GridDataFactory.fillDefaults().grab(true, true).applyTo(chartComposite);\r
+ smallFrame = SWT_AWT.new_Frame(chartComposite);\r
+\r
+ XYDataset dataset = new XYSeriesCollection(new XYSeries("Lookup Table"));\r
+ JFreeChart chart = createChart(dataset);\r
+ smallPanel = new ChartPanel(chart);\r
+ smallFrame.add(smallPanel);\r
+\r
+ }\r
+\r
+ private static JFreeChart createChart(XYDataset dataset) {\r
+ JFreeChart chart = ChartFactory.createXYLineChart(\r
+ null,\r
+ null,\r
+ null,\r
+ dataset,\r
+ PlotOrientation.VERTICAL,\r
+ true,\r
+ true,\r
+ false\r
+ );\r
+ chart.removeLegend();\r
+ chart.getXYPlot().getDomainAxis().setTickLabelsVisible(true);\r
+ chart.getXYPlot().getDomainAxis().setAxisLineVisible(false);\r
+ chart.getXYPlot().getDomainAxis().setTickMarksVisible(true);\r
+ chart.getXYPlot().getRangeAxis().setTickLabelsVisible(true);\r
+ chart.getXYPlot().getRangeAxis().setAxisLineVisible(false);\r
+ chart.getXYPlot().getRangeAxis().setTickMarksVisible(true);\r
+ chart.getXYPlot().getRenderer().setSeriesStroke(0, new BasicStroke(3.0f));\r
+ return chart;\r
+ }\r
+\r
+ private void updateChart() {\r
+ ArrayList<Point2D> dataPoints = new ArrayList<Point2D>();\r
+ TableParser parser = new TableParser(new StringReader(""));\r
+ parser.ReInit(new StringReader(lookup.getExpression()));\r
+ try {\r
+ parser.table();\r
+ ArrayList<Token> xTokens = parser.getXTokens();\r
+ ArrayList<Token> yTokens = parser.getYTokens();\r
+ for(int i = 0; i < xTokens.size(); i++) {\r
+ dataPoints.add(new Point2D.Double(\r
+ Double.parseDouble(xTokens.get(i).image), \r
+ Double.parseDouble(yTokens.get(i).image)));\r
+ }\r
+ } catch (ParseException e1) {\r
+ this.lookup.setSyntaxError(e1.currentToken, "Syntax Error");\r
+ System.out.println("MESSAGE: " + e1.getMessage());\r
+ return;\r
+ }\r
+\r
+ XYSeries series = new XYSeries("Lookup Table");\r
+ for(Point2D point : dataPoints) {\r
+ series.add(point.getX(), point.getY());\r
+ }\r
+ XYSeriesCollection dataset = new XYSeriesCollection(series);\r
+ smallPanel.getChart().getXYPlot().setDataset(dataset);\r
+ }\r
+\r
+\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2011 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.ui.properties.widgets.externalFiles;\r
+\r
+import org.eclipse.jface.resource.ImageDescriptor;\r
+import org.simantics.browsing.ui.swt.ImagerContributor;\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.exception.DatabaseException;\r
+\r
+public class ExternalFileImager extends ImagerContributor<ExternalFileNode> {\r
+\r
+ @Override\r
+ public ImageDescriptor getDescriptor(ReadGraph graph, ExternalFileNode input)\r
+ throws DatabaseException {\r
+ return null;\r
+ }\r
+\r
+\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2011 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.ui.properties.widgets.externalFiles;\r
+\r
+import org.simantics.browsing.ui.graph.impl.contributor.labeler.LabelerContributorImpl;\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.common.utils.NameUtils;\r
+import org.simantics.db.exception.DatabaseException;\r
+\r
+public class ExternalFileLabeler extends LabelerContributorImpl<ExternalFileNode>{\r
+\r
+ @Override\r
+ public String getLabel(ReadGraph graph, ExternalFileNode input)\r
+ throws DatabaseException {\r
+ return NameUtils.getSafeName(graph, input.data);\r
+ }\r
+\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2011 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.ui.properties.widgets.externalFiles;\r
+\r
+import org.simantics.browsing.ui.common.node.AbstractNode;\r
+import org.simantics.browsing.ui.common.node.DeleteException;\r
+import org.simantics.browsing.ui.common.node.IDeletableNode;\r
+import org.simantics.browsing.ui.common.node.IModifiableNode;\r
+import org.simantics.browsing.ui.content.Labeler.Modifier;\r
+import org.simantics.browsing.ui.graph.impl.LabelModifier;\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.WriteGraph;\r
+import org.simantics.db.common.request.WriteRequest;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.db.request.Write;\r
+import org.simantics.layer0.Layer0;\r
+import org.simantics.sysdyn.manager.FunctionUtils;\r
+import org.simantics.ui.SimanticsUI;\r
+\r
+public class ExternalFileNode extends AbstractNode<Resource> implements IModifiableNode, IDeletableNode {\r
+\r
+ public ExternalFileNode(Resource data) {\r
+ super(data);\r
+ }\r
+\r
+ @Override\r
+ public Modifier getModifier(String columnId) {\r
+ try {\r
+ final Resource hasName = Layer0.getInstance(SimanticsUI.getSession()).HasName;\r
+ LabelModifier modifier = new LabelModifier(SimanticsUI.getSession(), data, hasName) {\r
+ @Override\r
+ public String isValid(String label) {\r
+ if (label.isEmpty())\r
+ return "Empty label not allowed";\r
+ if (label.contains(" "))\r
+ return "Spaces are not allowed";\r
+ return null;\r
+ }\r
+\r
+ @Override\r
+ protected Write getWriteRequest(final String label) {\r
+ return new WriteRequest() {\r
+ @Override\r
+ public void perform(WriteGraph g) throws DatabaseException {\r
+ FunctionUtils.removeExternalFunctionFile(g, data);\r
+ g.claimLiteral(data, hasName, label);\r
+ FunctionUtils.createExternalFunctionFile(g, data);\r
+ }\r
+ };\r
+ }\r
+ };\r
+ return modifier;\r
+ } catch (DatabaseException e) {\r
+ e.printStackTrace();\r
+ }\r
+ return null;\r
+ }\r
+\r
+ @Override\r
+ public void delete() throws DeleteException {\r
+ SimanticsUI.getSession().asyncRequest(new WriteRequest() {\r
+\r
+ @Override\r
+ public void perform(WriteGraph graph) throws DatabaseException {\r
+ Layer0 l0 = Layer0.getInstance(graph);\r
+ Resource function = graph.getSingleObject(data, l0.PartOf);\r
+ if(function != null) {\r
+ graph.deny(data, l0.PartOf, function);\r
+ }\r
+ FunctionUtils.removeExternalFunctionFile(graph, data);\r
+ }\r
+ });\r
+ }\r
+\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2011 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.ui.properties.widgets.externalFiles;\r
+\r
+import java.util.ArrayList;\r
+import java.util.Collection;\r
+\r
+import org.simantics.browsing.ui.graph.impl.contributor.viewpoint.ViewpointContributorImpl;\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.common.request.ObjectsWithType;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.layer0.Layer0;\r
+import org.simantics.sysdyn.SysdynResource;\r
+\r
+public class ExternalFiles extends ViewpointContributorImpl<Resource> {\r
+\r
+ @Override\r
+ public Collection<?> getContribution(ReadGraph graph, Resource input)\r
+ throws DatabaseException {\r
+ \r
+ if(input == null) \r
+ return null;\r
+ SysdynResource sr = SysdynResource.getInstance(graph);\r
+ Layer0 l0 = Layer0.getInstance(graph);\r
+ \r
+ ArrayList<ExternalFileNode> result = new ArrayList<ExternalFileNode>();\r
+ for(Resource r : graph.syncRequest(new ObjectsWithType(input, l0.ConsistsOf, sr.ExternalFunctionFile))) {\r
+ result.add(new ExternalFileNode(r));\r
+ }\r
+ \r
+ return result;\r
+ }\r
+\r
+ @Override\r
+ public String getViewpointId() {\r
+ return "External Files";\r
+ }\r
+ \r
+\r
+\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2010 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.ui.properties.widgets.factories;\r
+\r
+import org.eclipse.jface.viewers.ISelection;\r
+import org.eclipse.swt.widgets.Combo;\r
+import org.simantics.browsing.ui.swt.widgets.impl.TextModifyListener;\r
+import org.simantics.browsing.ui.swt.widgets.impl.TrackedModifyEvent;\r
+import org.simantics.browsing.ui.swt.widgets.impl.Widget;\r
+import org.simantics.db.WriteGraph;\r
+import org.simantics.db.common.request.WriteRequest;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.db.management.ISessionContext;\r
+import org.simantics.utils.ReflectionUtils;\r
+import org.simantics.utils.ui.ISelectionUtils;\r
+\r
+abstract public class ComboStringPropertyModifier<T> implements TextModifyListener, Widget {\r
+\r
+ private ISessionContext context;\r
+ private Object lastInput = null;\r
+ \r
+ final private Class<?> clazz;\r
+ \r
+ public ComboStringPropertyModifier() {\r
+ clazz = ReflectionUtils.getSingleParameterType(getClass());\r
+ }\r
+ \r
+ @Override\r
+ public void setInput(ISessionContext context, Object input) {\r
+ this.context = context;\r
+ lastInput = input;\r
+ }\r
+\r
+ @Override\r
+ public void modifyText(TrackedModifyEvent e) {\r
+ Combo text = (Combo)e.getWidget();\r
+ final String textValue = text.getText();\r
+ final Object input = lastInput;\r
+ \r
+ try {\r
+ context.getSession().syncRequest(new WriteRequest() {\r
+\r
+ @SuppressWarnings("unchecked")\r
+ @Override\r
+ public void perform(WriteGraph graph) throws DatabaseException {\r
+\r
+ T single = (T) ISelectionUtils.filterSingleSelection((ISelection)input, clazz);\r
+ applyText(graph, single, textValue);\r
+ \r
+ }\r
+ \r
+ });\r
+ } catch (DatabaseException e1) {\r
+ e1.printStackTrace();\r
+ }\r
+ \r
+ }\r
+ \r
+ abstract public void applyText(WriteGraph graph, T input, String text) throws DatabaseException;\r
+\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2010 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.ui.properties.widgets.factories;\r
+\r
+import org.simantics.browsing.ui.swt.widgets.impl.ReadFactoryImpl;\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.utils.datastructures.Triple;\r
+\r
+public class DoublePropertyFactory extends ReadFactoryImpl<Resource, String> {\r
+\r
+ final private String propertyURI;\r
+ \r
+ public DoublePropertyFactory(String propertyURI) {\r
+ this.propertyURI = propertyURI;\r
+ }\r
+\r
+ @Override\r
+ public Object getIdentity(Object inputContents) {\r
+ return new Triple<Resource, String, Object>((Resource)inputContents, propertyURI, getClass());\r
+ }\r
+ \r
+ @Override\r
+ public String perform(ReadGraph graph, Resource issue) throws DatabaseException {\r
+ \r
+ Double value = graph.getPossibleRelatedValue(issue, graph.getResource(propertyURI));\r
+ if (value != null)\r
+ return value.toString();\r
+ else\r
+ return "";\r
+ }\r
+ \r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2010 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.ui.properties.widgets.factories;\r
+\r
+import org.simantics.browsing.ui.swt.widgets.impl.TextModifyListenerImpl;\r
+import org.simantics.databoard.Bindings;\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.WriteGraph;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.db.management.ISessionContext;\r
+\r
+public class DoublePropertyModifier extends TextModifyListenerImpl<Resource> {\r
+\r
+ final private String propertyURI;\r
+ \r
+ public DoublePropertyModifier(ISessionContext context, String propertyURI) {\r
+ this.propertyURI = propertyURI;\r
+ }\r
+\r
+ @Override\r
+ public void applyText(WriteGraph graph, Resource input, String text) throws DatabaseException {\r
+ if (text == null || text.equals("")) {\r
+ if(graph.hasStatement(input, graph.getResource(propertyURI)))\r
+ graph.deny(input, graph.getResource(propertyURI));\r
+ } else {\r
+ graph.claimLiteral(input, graph.getResource(propertyURI), Double.parseDouble(text), Bindings.DOUBLE);\r
+ }\r
+ }\r
+\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2010 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.ui.properties.widgets.factories;\r
+\r
+import org.simantics.browsing.ui.swt.widgets.impl.TextModifyListenerImpl;\r
+import org.simantics.databoard.Bindings;\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.WriteGraph;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.db.management.ISessionContext;\r
+import org.simantics.layer0.Layer0;\r
+import org.simantics.sysdyn.ui.utils.VariableNameUtils;\r
+\r
+public class VariableNamePropertyModifier extends TextModifyListenerImpl<Resource> {\r
+\r
+ final private String propertyURI;\r
+\r
+ public VariableNamePropertyModifier(ISessionContext context, String propertyURI) {\r
+ this.propertyURI = propertyURI;\r
+ }\r
+\r
+ /**\r
+ * Overrides the original applyText. Renames variables also in equations in the same configuration.\r
+ */\r
+ @Override\r
+ public void applyText(WriteGraph graph, Resource variable, String text) throws DatabaseException {\r
+ \r
+ // TODO: separate possible array indexes\r
+ \r
+ // TODO: add enumerations to the variable\r
+ String originalName = graph.getRelatedValue(variable, Layer0.getInstance(graph).HasName);\r
+ VariableNameUtils.renameInEquations(graph, variable, originalName, text);\r
+ graph.claimLiteral(variable, graph.getResource(propertyURI), text, Bindings.STRING);\r
+ }\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2010 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.ui.properties.widgets.factories;\r
+\r
+import org.eclipse.jface.dialogs.IInputValidator;\r
+import org.eclipse.jface.viewers.ISelection;\r
+import org.simantics.browsing.ui.swt.widgets.impl.Widget;\r
+import org.simantics.browsing.ui.swt.widgets.impl.WidgetSupport;\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.management.ISessionContext;\r
+import org.simantics.sysdyn.ui.utils.VariableNameUtils;\r
+import org.simantics.utils.ui.ISelectionUtils;\r
+\r
+public class VariableNameValidator implements IInputValidator, Widget {\r
+\r
+ private Resource lastInput = null;\r
+ \r
+ public VariableNameValidator(WidgetSupport support) {\r
+ support.register(this);\r
+ }\r
+ \r
+ /**\r
+ * Checks that the syntax of the given name is valid and there \r
+ * are no other components that have the same name in the configuration.\r
+ */\r
+ @Override\r
+ public String isValid(final String newText) {\r
+ if (!VariableNameUtils.isValid(lastInput, newText, true))\r
+ return "Not valid";\r
+ else\r
+ return null;\r
+ /*\r
+ if(lastInput == null) return null;\r
+ String result = null;\r
+ try {\r
+ result = SimanticsUI.getSession().syncRequest(new Read<String>(){\r
+\r
+ @Override\r
+ public String perform(ReadGraph graph) throws DatabaseException {\r
+ if(VariableNameUtils.nameIsTaken(graph, lastInput, newText)) {\r
+ return "Name is taken.";\r
+ }\r
+ return null;\r
+ }\r
+ \r
+ }) ;\r
+ } catch (DatabaseException e) {\r
+ e.printStackTrace();\r
+ }\r
+ return result;\r
+ */\r
+\r
+ }\r
+\r
+ @Override\r
+ public void setInput(ISessionContext context, Object input) {\r
+ lastInput = ISelectionUtils.filterSingleSelection((ISelection)input, Resource.class);\r
+ }\r
+\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2011 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.ui.properties.widgets.functions;\r
+\r
+import java.util.ArrayList;\r
+import java.util.Collection;\r
+\r
+import org.simantics.browsing.ui.common.node.AbstractNode;\r
+import org.simantics.browsing.ui.graph.contributor.viewpoint.ViewpointContributor;\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.common.request.ObjectsWithType;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.layer0.Layer0;\r
+import org.simantics.sysdyn.SysdynResource;\r
+import org.simantics.sysdyn.ui.browser.nodes.SharedFunctionLibraryNode;\r
+\r
+public class SelectedSharedFunctionLibraries extends ViewpointContributor<Resource> {\r
+\r
+ @Override\r
+ public Collection<?> getContribution(ReadGraph graph, Resource input)\r
+ throws DatabaseException {\r
+ ArrayList<AbstractNode<Resource>> result = new ArrayList<AbstractNode<Resource>>();\r
+\r
+ \r
+ for(Resource sharedLibrary : graph.syncRequest(new ObjectsWithType(\r
+ input, \r
+ Layer0.getInstance(graph).IsLinkedTo, \r
+ SysdynResource.getInstance(graph).SharedFunctionOntology)))\r
+ {\r
+ result.add(new SharedFunctionLibraryNode(sharedLibrary));\r
+ }\r
+ \r
+ return result;\r
+ }\r
+\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2011 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.ui.properties.widgets.functions;\r
+\r
+import java.util.ArrayList;\r
+import java.util.Collection;\r
+\r
+import org.simantics.browsing.ui.common.node.AbstractNode;\r
+import org.simantics.browsing.ui.graph.contributor.viewpoint.ViewpointContributor;\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.common.request.ObjectsWithType;\r
+import org.simantics.db.common.utils.NameUtils;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.layer0.Layer0;\r
+import org.simantics.sysdyn.SysdynResource;\r
+import org.simantics.sysdyn.ui.browser.nodes.SharedFunctionLibraryNode;\r
+\r
+public class SharedFunctionLibraries extends ViewpointContributor<Resource> {\r
+\r
+ @Override\r
+ public Collection<?> getContribution(ReadGraph graph, Resource input)\r
+ throws DatabaseException {\r
+ Layer0 l0 = Layer0.getInstance(graph);\r
+ SysdynResource sr = SysdynResource.getInstance(graph);\r
+ \r
+ ArrayList<AbstractNode<Resource>> result = new ArrayList<AbstractNode<Resource>>();\r
+\r
+ // Find shared ontologies. graph.getPossibleResource("http://SharedOntologies") does not update if it was null for the first time.\r
+ Resource sharedOntologies = null;\r
+ Resource root = input;\r
+ while(graph.getPossibleObject(root, l0.PartOf) != null)\r
+ root = graph.getPossibleObject(root, l0.PartOf);\r
+ \r
+ for(Resource r : graph.getObjects(root, l0.ConsistsOf)) {\r
+ if("SharedOntologies".equals(NameUtils.getSafeName(graph, r))) {\r
+ sharedOntologies = r;\r
+ break;\r
+ }\r
+ }\r
+ \r
+ if(sharedOntologies == null) {\r
+ return result;\r
+ }\r
+ \r
+ // Find all shared function ontologies. \r
+ // (Don't know why ObjectsWithType works only the first time, then gives nothing) \r
+ ArrayList<Resource> sharedFunctionLibraries = new ArrayList<Resource>();\r
+ for(Resource r : graph.getObjects(sharedOntologies, l0.ConsistsOf)) {\r
+ if(graph.isInstanceOf(r, sr.SharedFunctionOntology))\r
+ sharedFunctionLibraries.add(r);\r
+ }\r
+\r
+ // Find all shared function ontologies that have already been selected\r
+ Collection<Resource> selectedSharedFunctionLibraries = graph.syncRequest(new ObjectsWithType(\r
+ input, l0.IsLinkedTo, sr.SharedFunctionOntology));\r
+\r
+ // Remove all selected ontologies from the shared function ontologies\r
+ sharedFunctionLibraries.removeAll(selectedSharedFunctionLibraries);\r
+\r
+ for(Resource ontology : sharedFunctionLibraries) {\r
+ result.add(new SharedFunctionLibraryNode(ontology));\r
+ }\r
+\r
+ return result;\r
+ }\r
+\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2010 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.ui.property;\r
+\r
+import java.util.ArrayList;\r
+import java.util.Collection;\r
+\r
+import org.simantics.browsing.ui.graph.contributor.viewpoint.ViewpointContributor;\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.db.layer0.variable.Variable;\r
+\r
+public class OperationModelContributor extends ViewpointContributor<OperationModelNode> {\r
+\r
+ @Override\r
+ public Collection<?> getContribution(ReadGraph graph, OperationModelNode model) throws DatabaseException {\r
+ \r
+ Variable modelVariable = model.data;\r
+ Variable config = modelVariable.getChild(graph, "BaseRealization");\r
+ ArrayList<Variable> result = new ArrayList<Variable>();\r
+ result.addAll(config.browseChildren(graph));\r
+ return result;\r
+ \r
+ }\r
+\r
+ @Override\r
+ public String getViewpointId() {\r
+ return "Standard";\r
+ }\r
+\r
+}
\ No newline at end of file
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2010 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.ui.property;\r
+\r
+import java.util.Map;\r
+\r
+import org.simantics.browsing.ui.common.ColumnKeys;\r
+import org.simantics.browsing.ui.graph.contributor.labeler.ColumnLabelerContributor;\r
+import org.simantics.databoard.Bindings;\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.utils.datastructures.ArrayMap;\r
+\r
+public class OperationModelLabels extends ColumnLabelerContributor<OperationModelNode> {\r
+\r
+ @Override\r
+ public Map<String, String> getLabel(ReadGraph graph, OperationModelNode model) throws DatabaseException {\r
+\r
+ String label = model.data.getPropertyValue(graph, "Name", Bindings.STRING);\r
+\r
+ return new ArrayMap<String, String>(new String[] { ColumnKeys.SINGLE } , new String[] { label });\r
+\r
+ }\r
+\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2010 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.ui.property;\r
+\r
+import org.simantics.browsing.ui.common.ColumnKeys;\r
+import org.simantics.browsing.ui.common.imagers.ImageURLs;\r
+import org.simantics.browsing.ui.common.imagers.SingleImageURLs;\r
+import org.simantics.browsing.ui.common.node.AbstractNode;\r
+import org.simantics.db.layer0.variable.Variable;\r
+import org.simantics.sysdyn.ui.Activator;\r
+\r
+public class OperationModelNode extends AbstractNode<Variable> {\r
+\r
+ public OperationModelNode(Variable data) {\r
+ super(data);\r
+ }\r
+\r
+ @Override\r
+ protected ImageURLs getImageURLs() {\r
+ return new SingleImageURLs(ColumnKeys.SINGLE, Activator.getDefaultResource("icons/chart_organisation.png"));\r
+ }\r
+ \r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2010 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.ui.property;\r
+\r
+import java.util.ArrayList;\r
+import java.util.Collection;\r
+\r
+import org.simantics.browsing.ui.Tester;\r
+import org.simantics.browsing.ui.graph.contributor.viewpoint.ViewpointContributor;\r
+import org.simantics.browsing.ui.graph.tester.GraphTesters;\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.common.request.ObjectsWithType;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.db.layer0.variable.Variable;\r
+import org.simantics.layer0.Layer0;\r
+import org.simantics.project.ontology.ProjectResource;\r
+import org.simantics.simulation.ontology.SimulationResource;\r
+\r
+public class OperationProjectContributor extends ViewpointContributor<Resource> {\r
+\r
+ @Override\r
+ public Collection<?> getContribution(ReadGraph graph, Resource project) throws DatabaseException {\r
+\r
+ ArrayList<OperationModelNode> result = new ArrayList<OperationModelNode>();\r
+ for(Resource model : graph.syncRequest(new ObjectsWithType(project, Layer0.getInstance(graph).ConsistsOf, SimulationResource.getInstance(graph).Model))) {\r
+ result.add(new OperationModelNode(graph.adapt(model, Variable.class)));\r
+ }\r
+ return result;\r
+ \r
+ }\r
+ \r
+ @Override\r
+ public Tester getNodeContextTester() {\r
+ \r
+ return GraphTesters.type(ProjectResource.URIs.Project);\r
+ }\r
+\r
+ @Override\r
+ public String getViewpointId() {\r
+ return "Standard";\r
+ }\r
+\r
+}
\ No newline at end of file
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2010 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.ui.property;\r
+\r
+import java.util.ArrayList;\r
+import java.util.Collection;\r
+\r
+import org.simantics.browsing.ui.graph.impl.contributor.viewpoint.ViewpointContributorImpl;\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.db.layer0.variable.Variable;\r
+\r
+public class OperationVariableContributor extends ViewpointContributorImpl<Variable> {\r
+\r
+ @Override\r
+ public Collection<?> getContribution(ReadGraph graph, Variable input) throws DatabaseException {\r
+ ArrayList<Variable> result = new ArrayList<Variable>();\r
+ result.addAll(input.browseProperties(graph));\r
+ result.addAll(input.browseChildren(graph));\r
+ return result;\r
+ }\r
+ \r
+ @Override\r
+ public String getViewpointId() {\r
+ return "Properties";\r
+ }\r
+\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2010 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.ui.property;\r
+\r
+import org.eclipse.jface.resource.ImageDescriptor;\r
+import org.simantics.browsing.ui.swt.ImagerContributor;\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.db.layer0.variable.Variable;\r
+import org.simantics.modeling.ui.Activator;\r
+\r
+public class OperationVariableImager extends ImagerContributor<Variable> {\r
+\r
+ @Override\r
+ public ImageDescriptor getDescriptor(ReadGraph graph, Variable var) throws DatabaseException {\r
+ return Activator.BULLET_GREEN_ICON;\r
+ }\r
+\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2010 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.ui.property;\r
+\r
+import java.util.Map;\r
+\r
+import org.simantics.browsing.ui.common.ColumnKeys;\r
+import org.simantics.browsing.ui.graph.contributor.labeler.ColumnLabelerContributor;\r
+import org.simantics.databoard.Bindings;\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.db.layer0.variable.Variable;\r
+import org.simantics.utils.datastructures.ArrayMap;\r
+\r
+public class OperationVariableLabels extends ColumnLabelerContributor<Variable> {\r
+\r
+ @Override\r
+ public Map<String, String> getLabel(ReadGraph graph, Variable variable) throws DatabaseException {\r
+\r
+ String label = variable.getPropertyValue(graph, "Name", Bindings.STRING);\r
+\r
+ return new ArrayMap<String, String>(new String[] { ColumnKeys.SINGLE } , new String[] { label });\r
+\r
+ }\r
+\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2010 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.ui.trend;\r
+\r
+import org.eclipse.core.commands.AbstractHandler;\r
+import org.eclipse.core.commands.Command;\r
+import org.eclipse.core.commands.ExecutionEvent;\r
+import org.eclipse.core.commands.ExecutionException;\r
+import org.eclipse.core.commands.State;\r
+import org.eclipse.ui.PlatformUI;\r
+import org.eclipse.ui.commands.ICommandService;\r
+\r
+\r
+public class PinTrend extends AbstractHandler {\r
+\r
+ public static final String COMMAND = "org.simantics.sysdyn.ui.trend.view.pin";\r
+ public static final String STATE = "org.simantics.sysdyn.ui.trend.view.pin.state";\r
+ \r
+ @Override\r
+ public Object execute(ExecutionEvent event) throws ExecutionException {\r
+ ICommandService service = (ICommandService) PlatformUI.getWorkbench().getService(ICommandService.class);\r
+ Command command = service.getCommand(COMMAND);\r
+ State state = command.getState(STATE);\r
+ Boolean value = (Boolean) state.getValue();\r
+ value = !value;\r
+ state.setValue(value);\r
+\r
+ return null;\r
+ }\r
+ \r
+ public static Boolean getState() {\r
+ ICommandService service = (ICommandService) PlatformUI.getWorkbench().getService(ICommandService.class);\r
+ Command command = service.getCommand(COMMAND);\r
+ State state = command.getState(STATE);\r
+ return (Boolean)state.getValue();\r
+ }\r
+\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2010 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.ui.trend;\r
+\r
+import java.awt.Frame;\r
+import java.util.Collection;\r
+\r
+import javax.swing.SwingUtilities;\r
+\r
+import org.eclipse.swt.SWT;\r
+import org.eclipse.swt.awt.SWT_AWT;\r
+import org.eclipse.swt.widgets.Composite;\r
+import org.eclipse.ui.part.ViewPart;\r
+import org.jfree.chart.ChartPanel;\r
+import org.jfree.chart.JFreeChart;\r
+import org.jfree.chart.axis.NumberAxis;\r
+import org.jfree.chart.plot.XYPlot;\r
+import org.jfree.chart.renderer.xy.XYLineAndShapeRenderer;\r
+import org.jfree.data.xy.AbstractXYDataset;\r
+import org.simantics.sysdyn.manager.SysdynDataSet;\r
+import org.simantics.sysdyn.ui.viewUtils.SysdynDatasetSelectionListener;\r
+import org.simantics.utils.ui.jface.ActiveSelectionProvider;\r
+\r
+public class TrendView extends ViewPart {\r
+\r
+ Frame frame;\r
+ ChartPanel panel;\r
+ SysdynDatasets sysdynDatasets = new SysdynDatasets();\r
+\r
+\r
+ @SuppressWarnings("serial")\r
+ class SysdynDatasets extends AbstractXYDataset {\r
+\r
+ SysdynDataSet[] sets = new SysdynDataSet[0];\r
+\r
+ public void setDatasets(SysdynDataSet[] sets) {\r
+ this.sets = sets;\r
+ fireDatasetChanged();\r
+ }\r
+\r
+ @Override\r
+ public Number getY(int series, int item) {\r
+ return sets[series].values.get(item);\r
+ }\r
+\r
+ @Override\r
+ public Number getX(int series, int item) {\r
+ return sets[series].times.get(item);\r
+ }\r
+\r
+ @Override\r
+ public int getItemCount(int series) {\r
+ return sets[series].times.size();\r
+ }\r
+\r
+ @Override\r
+ public Comparable<String> getSeriesKey(int series) {\r
+ SysdynDataSet sds = sets[series];\r
+ if(sds.result == null)\r
+ return sds.name;\r
+ else\r
+ return sds.name + " : " + sds.result;\r
+ }\r
+\r
+ @Override\r
+ public int getSeriesCount() {\r
+ return sets.length;\r
+ }\r
+\r
+ }\r
+\r
+ @Override\r
+ public void createPartControl(Composite parent) {\r
+ final ActiveSelectionProvider selectionProvider = new ActiveSelectionProvider();\r
+ getSite().setSelectionProvider(selectionProvider);\r
+\r
+ final Composite composite = new Composite(parent,\r
+ SWT.NO_BACKGROUND | SWT.EMBEDDED);\r
+ frame = SWT_AWT.new_Frame(composite);\r
+\r
+ SwingUtilities.invokeLater(new Runnable() {\r
+\r
+ @Override\r
+ public void run() {\r
+ XYPlot plot = new XYPlot(\r
+ sysdynDatasets,\r
+ new NumberAxis("time"),\r
+ new NumberAxis("x"),\r
+ new XYLineAndShapeRenderer(true, false)\r
+ );\r
+\r
+ JFreeChart chart = new JFreeChart(plot);\r
+ panel = new ChartPanel(chart);\r
+ frame.add(panel);\r
+\r
+ panel.requestFocus();\r
+ }\r
+\r
+ });\r
+\r
+ getSite().getWorkbenchWindow().getSelectionService().addPostSelectionListener(new SysdynDatasetSelectionListener() {\r
+\r
+ @Override\r
+ protected void selectionChanged(final Collection<SysdynDataSet> activeDatasets) {\r
+ SwingUtilities.invokeLater(new Runnable() {\r
+\r
+ @Override\r
+ public void run() {\r
+ sysdynDatasets.setDatasets(activeDatasets.toArray(new SysdynDataSet[activeDatasets.size()]));\r
+ }\r
+\r
+ });\r
+ }\r
+ });\r
+\r
+ }\r
+\r
+ @Override\r
+ public void setFocus() {\r
+ if(panel != null)\r
+ panel.requestFocus();\r
+ }\r
+\r
+\r
+}\r
--- /dev/null
+package org.simantics.sysdyn.ui.utils;\r
+\r
+import java.util.ArrayList;\r
+import java.util.HashMap;\r
+import java.util.Map;\r
+\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.sysdyn.manager.SysdynModel;\r
+import org.simantics.sysdyn.representation.Enumeration;\r
+import org.simantics.sysdyn.representation.EnumerationIndex;\r
+import org.simantics.sysdyn.representation.IElement;\r
+import org.simantics.sysdyn.representation.Variable;\r
+\r
+public class ArrayVariableUtils {\r
+\r
+\r
+ /**\r
+ * Checks if the given range elements can be applied to the given variable.\r
+ * \r
+ * @param graph ReadGraph\r
+ * @param variable Resource of the variable \r
+ * @param range Range elements in the correct order. Elements are separated in range definition by ',' \r
+ * @return true if range is valid, false if not\r
+ * @throws DatabaseException\r
+ */\r
+ public static Map<Integer, String> isRangeValid(ReadGraph graph, Variable variable, String[] elements) throws DatabaseException {\r
+ if(variable == null)\r
+ return null;\r
+ Map<Integer, String> result = new HashMap<Integer, String>();\r
+ // Not an array variable\r
+ if(variable.getArrayIndexes() == null) {\r
+ for(int i = 0; i < elements.length ; i++)\r
+ result.put(i, "Variable is not an array variable");\r
+ return result;\r
+ }\r
+ ArrayList<Enumeration> enumerations = variable.getArrayIndexes().getEnumerations();\r
+ // Too many elements\r
+ if(elements.length > enumerations.size()) {\r
+ result.put( enumerations.size(), "Too many elements");\r
+ } else if(elements.length < enumerations.size()) {\r
+ result.put( elements.length > 0 ? elements.length - 1 : 0, "Too few elements");\r
+ }\r
+ \r
+ \r
+ for(int i = 0; i < elements.length && i < enumerations.size(); i++) {\r
+ if(elements[i].trim().equals(":"))\r
+ continue;\r
+ if(elements[i].indexOf(":") != elements[i].lastIndexOf(":")) {\r
+ result.put( i, "Too many ':' elements");\r
+ continue;\r
+ }\r
+\r
+ String[] rangeComponents = elements[i].split(":");\r
+ if(rangeComponents.length > 2){\r
+ result.put( i, "Too many ':' elements");\r
+ continue;\r
+ }\r
+ // Single range component, equals to the enumeration at that index\r
+ if(rangeComponents.length == 1 && rangeComponents[0].trim().equals(enumerations.get(i).getName()))\r
+ continue;\r
+ // one or two range components, they all equal to individual indexes in the enumeration\r
+ for(String r : rangeComponents) {\r
+ r = r.trim();\r
+ boolean componentIsValid = false;\r
+ for(EnumerationIndex ei : enumerations.get(i).getEnumerationIndexes()) {\r
+ if(ei.getName().equals(r)) {\r
+ componentIsValid = true;\r
+ break;\r
+ }\r
+ }\r
+ if(!componentIsValid)\r
+ result.put( i, "Invalid range");\r
+ }\r
+ }\r
+ if(result.isEmpty())\r
+ return null;\r
+ else\r
+ return result;\r
+ }\r
+\r
+ /**\r
+ * Checks if the given range can be applied to the given variable.\r
+ * \r
+ * @param graph ReadGraph\r
+ * @param variable Resource of the variable \r
+ * @param range Range WITHOUT [ and ] brackets\r
+ * @return true if range is valid, false if not\r
+ * @throws DatabaseException\r
+ */\r
+ public static boolean isRangeValid(ReadGraph graph, Resource variable, String range) throws DatabaseException {\r
+ if(variable == null)\r
+ return true;\r
+ String[] elements = range.split(",");\r
+ SysdynModel model = ModelUtils.getModel(graph, variable);\r
+ if(model == null)\r
+ return false;\r
+ IElement e = model.getElement(variable);\r
+ if(e != null && e instanceof Variable) {\r
+ Variable v = (Variable) e;\r
+ Map<Integer, String> result = isRangeValid(graph, v, elements);\r
+ if(result == null)\r
+ return true;\r
+ else\r
+ return false;\r
+ } else {\r
+ return false;\r
+ }\r
+ }\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2010 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.ui.utils;\r
+\r
+import java.io.StringReader;\r
+import java.util.ArrayList;\r
+import java.util.HashMap;\r
+import java.util.HashSet;\r
+import java.util.Iterator;\r
+import java.util.List;\r
+import java.util.Map;\r
+import java.util.Set;\r
+\r
+import org.eclipse.jface.text.Position;\r
+import org.eclipse.swt.custom.StyledText;\r
+import org.eclipse.swt.graphics.Color;\r
+import org.eclipse.swt.widgets.Table;\r
+import org.eclipse.swt.widgets.TableItem;\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.db.request.Read;\r
+import org.simantics.layer0.Layer0;\r
+import org.simantics.sysdyn.SysdynResource;\r
+import org.simantics.sysdyn.expressionParser.ExpressionParser;\r
+import org.simantics.sysdyn.expressionParser.ParseException;\r
+import org.simantics.sysdyn.expressionParser.Token;\r
+import org.simantics.sysdyn.expressionParser.TokenMgrError;\r
+import org.simantics.sysdyn.manager.SysdynModel;\r
+import org.simantics.sysdyn.manager.SysdynModelManager;\r
+import org.simantics.sysdyn.representation.Configuration;\r
+import org.simantics.sysdyn.representation.Enumeration;\r
+import org.simantics.sysdyn.representation.EnumerationIndex;\r
+import org.simantics.sysdyn.representation.IElement;\r
+import org.simantics.sysdyn.representation.Variable;\r
+import org.simantics.sysdyn.ui.properties.widgets.expressions.ExpressionField;\r
+import org.simantics.sysdyn.ui.properties.widgets.expressions.IExpression;\r
+import org.simantics.sysdyn.ui.properties.widgets.expressions.StockExpression;\r
+import org.simantics.ui.SimanticsUI;\r
+\r
+public class ExpressionUtils {\r
+\r
+ /**\r
+ * Determines if the given expression is a parameter expression. Parameters are numbers.\r
+ * If the expression contains anything other than numbers, it is not a parameter.\r
+ * \r
+ * @param expression The expression to be checked\r
+ * @return is the expression a parameter\r
+ */\r
+ static public boolean isParameter(String expression) {\r
+ try {\r
+ /*\r
+ StringTokenizer st = new StringTokenizer(expression, "{}[],;");\r
+ while(st.hasMoreTokens()) {\r
+ Double.parseDouble(st.nextToken().trim());\r
+ }\r
+ */\r
+ Double.parseDouble(expression.trim());\r
+ return true;\r
+ } catch (NumberFormatException e) {\r
+ return false;\r
+ }\r
+ }\r
+\r
+ /**\r
+ * Validates the expressionfield of a given IExpression\r
+ * \r
+ * @param expression The expression whose fields are validated\r
+ * @param connectedVariables Table items from the shortcut widget. (Items needed so that they can be coloured)\r
+ * @param configuration configuration where the variable is located\r
+ */\r
+ static public void validateExpressionFields(final Resource variable, IExpression expression, Table variableTable) {\r
+\r
+ Resource configuration = null;\r
+ try {\r
+ configuration = SimanticsUI.getSession().syncRequest(new Read<Resource>() {\r
+\r
+ @Override\r
+ public Resource perform(ReadGraph graph) throws DatabaseException {\r
+ SysdynResource sr = SysdynResource.getInstance(graph);\r
+ Resource configuration = variable;\r
+ while (configuration != null) {\r
+ configuration = graph.getPossibleObject(configuration, Layer0.getInstance(graph).PartOf);\r
+\r
+ if(configuration == null || graph.isInstanceOf(configuration, sr.Configuration)) {\r
+ break;\r
+ }\r
+ }\r
+ return configuration;\r
+ }\r
+ });\r
+ } catch (DatabaseException e) {\r
+ e.printStackTrace();\r
+ return;\r
+ }\r
+\r
+ if(configuration == null)\r
+ return;\r
+\r
+ ExpressionParser parser = new ExpressionParser(new StringReader(""));\r
+ Set<String> variables = new HashSet<String>();\r
+ HashMap<ExpressionField, HashMap<String, List<Token>>> references = new HashMap<ExpressionField, HashMap<String, List<Token>>>();\r
+ final HashMap<ExpressionField, HashMap<String, List<List<Token>>>> ranges = new HashMap<ExpressionField, HashMap<String, List<List<Token>>>>();\r
+ HashMap<ExpressionField, HashMap<Token, List<Token>>> forIndices = new HashMap<ExpressionField, HashMap<Token, List<Token>>>();\r
+ HashMap<ExpressionField, HashMap<String, List<Token>>> enumerationReferences = new HashMap<ExpressionField, HashMap<String, List<Token>>>();\r
+ \r
+ // Build references and variable array\r
+ for(ExpressionField ef : expression.getExpressionFields()) {\r
+ ef.resetAnnotations();\r
+ String textString = ef.getExpression();\r
+ parser.ReInit(new StringReader(textString));\r
+ try {\r
+ parser.expr();\r
+ HashMap<String, List<Token>> refs = parser.getReferences();\r
+ references.put(ef, refs);\r
+ variables.addAll(refs.keySet());\r
+\r
+ HashMap<String, List<List<Token>>> rangs = parser.getRanges();\r
+ ranges.put(ef, rangs);\r
+ \r
+ HashMap<Token, List<Token>> fInds = parser.getForIndices();\r
+ forIndices.put(ef, fInds);\r
+ \r
+ \r
+ HashMap<String, List<Token>> enumRefs = parser.getEnumerationReferences();\r
+ enumerationReferences.put(ef, enumRefs);\r
+ \r
+ } catch (ParseException e1) {\r
+ ef.setSyntaxError(e1.currentToken, "Syntax Error");\r
+ } catch (TokenMgrError err) {\r
+ ef.setSyntaxError(0, textString.length(), "MissingLink", "Expression contains unsupported characters");\r
+ }\r
+ }\r
+\r
+\r
+ final HashMap<String, Variable> modelVariables = new HashMap<String, Variable>();\r
+\r
+ if(!variables.isEmpty()) {\r
+ Set<String> noSuchVariables = new HashSet<String>();\r
+ SysdynModelManager sdm = SysdynModelManager.getInstance(SimanticsUI.getSession());\r
+ SysdynModel model = sdm.getModel(configuration);\r
+ try {\r
+ model.update();\r
+ } catch (DatabaseException e1) {\r
+ e1.printStackTrace();\r
+ }\r
+\r
+ Configuration conf = model.getConfiguration();\r
+ ArrayList<IElement> elements = conf.getElements();\r
+ for(IElement e : elements) {\r
+ if(e instanceof Variable) {\r
+ Variable v = (Variable) e;\r
+ modelVariables.put(v.getName(), v);\r
+ }\r
+ }\r
+\r
+ // VARIABLE NAMES\r
+\r
+ for(String v : variables) {\r
+ if(!modelVariables.keySet().contains(v)) {\r
+ noSuchVariables.add(v);\r
+ }\r
+ }\r
+\r
+ if(!noSuchVariables.isEmpty()) {\r
+ // remove no such variables from variable list\r
+ for(String s : noSuchVariables)\r
+ variables.remove(s);\r
+ // create annotations\r
+ HashMap<ExpressionField ,ArrayList<Position>> positions = getPositionsForVariables(references, noSuchVariables);\r
+ for(ExpressionField ef : positions.keySet()) {\r
+ ef.setNoSuchVariableAnnotations(positions.get(ef));\r
+ }\r
+ } \r
+ }\r
+\r
+ // Check that the variables that exist have connections and the connected variables have references in the expressions\r
+ if(!(expression instanceof StockExpression)) { \r
+ \r
+ if(variableTable != null && !variableTable.isDisposed()) {\r
+ TableItem[] connectedVariables = variableTable.getItems();\r
+ for(TableItem ti : connectedVariables) {\r
+ if(!variables.contains(ti.getText())) {\r
+ ti.setForeground(new Color(ti.getDisplay(), 255, 0, 0));\r
+ } else {\r
+ ti.setForeground(new Color(ti.getDisplay(), 0, 0, 0));\r
+ variables.remove(ti.getText());\r
+ }\r
+ }\r
+ }\r
+ \r
+ // Remove all enumerations, they cannot have connections\r
+ for(String name : modelVariables.keySet()) {\r
+ if(modelVariables.get(name) instanceof Enumeration && variables.contains(name)) {\r
+ variables.remove(name);\r
+ }\r
+ }\r
+\r
+ if(!variables.isEmpty()) {\r
+ HashMap<ExpressionField ,ArrayList<Position>> positions = getPositionsForVariables(references, variables);\r
+ for(ExpressionField ef : positions.keySet()) {\r
+ ef.setMissingLinkAnnotations(positions.get(ef));\r
+ }\r
+\r
+ }\r
+ } \r
+\r
+\r
+\r
+ HashMap<ExpressionField, HashMap<Token, String>> errors = new HashMap<ExpressionField, HashMap<Token, String>>();\r
+ HashMap<Token, String> result = null;\r
+\r
+ for(final ExpressionField ef : ranges.keySet()) {\r
+ \r
+ // RANGES\r
+ try {\r
+ result = SimanticsUI.getSession().syncRequest(new Read<HashMap<Token, String>>() {\r
+\r
+ @Override\r
+ public HashMap<Token, String> perform(ReadGraph graph) throws DatabaseException {\r
+ HashMap<Token, String> result = new HashMap<Token, String>();\r
+ for(String s : ranges.get(ef).keySet()) {\r
+ if(ranges.get(ef).containsKey(s)) {\r
+ for(List<Token> l : ranges.get(ef).get(s)) {\r
+ String[] ss = new String[l.size()];\r
+ for(int i = 0; i < l.size(); i++) {\r
+ ss[i] = l.get(i).image;\r
+ }\r
+ Map<Integer, String> invalidRanges = ArrayVariableUtils.isRangeValid(graph, modelVariables.get(s), ss);\r
+ if(invalidRanges != null && !invalidRanges.isEmpty()) {\r
+ for(Integer i : invalidRanges.keySet()) {\r
+ result.put(l.get(i), invalidRanges.get(i));\r
+ }\r
+ }\r
+ }\r
+ }\r
+ } \r
+ return result;\r
+ }\r
+ });\r
+ } catch (DatabaseException e) {\r
+ e.printStackTrace();\r
+ }\r
+ \r
+ // FOR-INDICES\r
+ \r
+ HashMap<Token, List<Token>> indexList = forIndices.get(ef);\r
+ for(Token t : indexList.keySet()) {\r
+ boolean isFound = false;\r
+ for(Token rt : indexList.get(t)) {\r
+ if(rt.image.equals(t.image)) {\r
+ isFound = true;\r
+ // remove range token from invalid ranges\r
+ result.remove(rt);\r
+ break;\r
+ }\r
+ }\r
+ if(!isFound) {\r
+ result.put(t, "Invalid index");\r
+ }\r
+ }\r
+ \r
+ // ENUMERATION REFERENCES IN FOR-LOOPS\r
+ HashMap<String, List<Token>> enumRefList = enumerationReferences.get(ef);\r
+ for(String enumeration : enumRefList.keySet()) {\r
+ for(Token et : enumRefList.get(enumeration)) {\r
+ Variable v = modelVariables.get(enumeration);\r
+ if(v != null && v instanceof Enumeration) {\r
+ boolean isFound = false;\r
+ Enumeration e = (Enumeration)v;\r
+ \r
+ // TODO: add .elements and .size \r
+ if(enumeration.equals(et.image)) {\r
+ // The full enumeration\r
+ isFound = true;\r
+ } else {\r
+ for(EnumerationIndex ei : e.getEnumerationIndexes()) {\r
+ if(ei.getName().equals(et.image)) {\r
+ isFound = true;\r
+ break;\r
+ }\r
+ }\r
+ }\r
+ \r
+ if(!isFound) {\r
+ StringBuilder sb = new StringBuilder();\r
+ sb.append("Enumeration ");\r
+ sb.append(enumeration);\r
+ sb.append(" has no such index.\nAvailable indexes are: ");\r
+ Iterator<EnumerationIndex> iterator = e.getEnumerationIndexes().iterator();\r
+ while(iterator.hasNext()) {\r
+ sb.append(iterator.next().getName());\r
+ if(iterator.hasNext()) \r
+ sb.append(", ");\r
+ }\r
+ result.put(et, sb.toString());\r
+ }\r
+ \r
+ \r
+ } else {\r
+ result.put(et, "No such enumeration (" + enumeration + ")");\r
+ }\r
+ }\r
+ }\r
+ \r
+ errors.put(ef, result);\r
+\r
+ \r
+ } \r
+ \r
+\r
+ \r
+ \r
+ \r
+ \r
+ for(ExpressionField ef : ranges.keySet()) {\r
+ HashMap<Token, String> tokens = errors.get(ef);\r
+ if(tokens == null || tokens.isEmpty()) continue;\r
+ for(Token t : tokens.keySet()) {\r
+ ef.setSyntaxError(t, tokens.get(t));\r
+ }\r
+ }\r
+ \r
+ }\r
+\r
+ @SuppressWarnings("unchecked")\r
+ static private HashMap<ExpressionField ,ArrayList<Position>> getPositionsForVariables(HashMap<ExpressionField, HashMap<String, List<Token>>> references, Set<String> variables) {\r
+ HashMap<ExpressionField ,ArrayList<Position>> result = new HashMap<ExpressionField ,ArrayList<Position>>();\r
+ for(String s : variables) {\r
+ List<Token> tlist = new ArrayList<Token>();\r
+ for(ExpressionField ef : references.keySet()) {\r
+ ArrayList<Position> positions = new ArrayList<Position>();\r
+ tlist = references.get(ef).get(s);\r
+ if(tlist != null)\r
+ for(Token t : tlist) {\r
+ StyledText st = ef.getSourceViewer().getTextWidget();\r
+ int start = st.getOffsetAtLine(t.beginLine - 1) + t.beginColumn - 1;\r
+ int offset = st.getOffsetAtLine(t.endLine - 1) + t.endColumn - start;\r
+ positions.add(new Position(\r
+ start,\r
+ offset));\r
+ }\r
+ if(result.keySet().contains(ef)) {\r
+ result.get(ef).addAll((ArrayList<Position>)positions.clone());\r
+ } else {\r
+ result.put(ef, (ArrayList<Position>)positions.clone());\r
+ }\r
+ }\r
+ }\r
+ return result;\r
+ }\r
+}\r
--- /dev/null
+package org.simantics.sysdyn.ui.utils;\r
+\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.layer0.Layer0;\r
+import org.simantics.sysdyn.manager.SysdynModel;\r
+import org.simantics.sysdyn.manager.SysdynModelManager;\r
+import org.simantics.ui.SimanticsUI;\r
+\r
+public class ModelUtils {\r
+\r
+ /**\r
+ * Returns the SysdynModel where the given variable is located\r
+ * \r
+ * @param graph ReadGraph\r
+ * @param variable Variable whose model is wanted\r
+ * @return SysdynModel where variable is located\r
+ * @throws DatabaseException\r
+ */\r
+ public static SysdynModel getModel(ReadGraph graph, Resource variable) throws DatabaseException {\r
+ Layer0 l0 = Layer0.getInstance(graph);\r
+ Resource configuration = graph.getPossibleObject(variable, l0.PartOf);\r
+ if(configuration == null)\r
+ return null;\r
+ SysdynModelManager sdm = SysdynModelManager.getInstance(SimanticsUI.getSession());\r
+ SysdynModel model = sdm.getModel(graph, configuration);\r
+ try {\r
+ model.update(graph);\r
+ } catch (DatabaseException e1) {\r
+ e1.printStackTrace();\r
+ }\r
+ return model;\r
+ }\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2010 Association for Decentralized Information Management\r
+ * in Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.ui.utils;\r
+\r
+import org.simantics.databoard.Bindings;\r
+import org.simantics.databoard.binding.Binding;\r
+import org.simantics.databoard.serialization.Serializer;\r
+import org.simantics.graph.representation.External;\r
+import org.simantics.graph.representation.Identity;\r
+import org.simantics.graph.representation.Internal;\r
+import org.simantics.graph.representation.Root;\r
+import org.simantics.graph.representation.TransferableGraph1;\r
+import org.simantics.graph.representation.Value;\r
+\r
+\r
+/**\r
+ * Transferable graph datatype. \r
+ * See <a href="https://www.simantics.org/wiki/index.php/Graph_exchange_format">specification</a>. \r
+ * @author Hannu Niemistö\r
+ */\r
+public class OldTransferableGraph1 {\r
+ public static Binding BINDING = Bindings.getBindingUnchecked(TransferableGraph1.class);\r
+ public static Serializer SERIALIZER = Bindings.getSerializerUnchecked(BINDING);\r
+ \r
+ public int resourceCount;\r
+ public Identity[] identities; \r
+ public int[] statements;\r
+ public Value[] values; \r
+ \r
+ public OldTransferableGraph1() {\r
+ }\r
+ \r
+ public OldTransferableGraph1(int resourceCount, Identity[] identities,\r
+ int[] statements, Value[] values) {\r
+ this.resourceCount = resourceCount;\r
+ this.identities = identities;\r
+ this.statements = statements;\r
+ this.values = values;\r
+ }\r
+\r
+ public void print() {\r
+ System.out.println("Identities");\r
+ for(Identity id : identities) {\r
+ System.out.print(" " + id.resource + " = ");\r
+ if(id.definition instanceof Root) {\r
+ Root def = (Root)id.definition;\r
+ System.out.println("ROOT(" + def.name + ")");\r
+ }\r
+ else if(id.definition instanceof External) {\r
+ External def = (External)id.definition;\r
+ System.out.println("EXTERNAL(" + def.parent + ", " + def.name + ")");\r
+ }\r
+ else if(id.definition instanceof Internal) {\r
+ Internal def = (Internal)id.definition;\r
+ System.out.println("INTERNAL(" + def.parent + ", " + def.name + ")");\r
+ }\r
+ }\r
+ System.out.println("Statements:");\r
+ for(int i=0;i<statements.length;i+=4)\r
+ System.out.println(" " + \r
+ statements[i] + " " +\r
+ statements[i+1] + " " +\r
+ statements[i+2] + " " +\r
+ statements[i+3]\r
+ );\r
+ }\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2010 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.ui.utils;\r
+\r
+import java.util.HashSet;\r
+import java.util.List;\r
+import java.util.Set;\r
+import java.util.StringTokenizer;\r
+import java.util.regex.Matcher;\r
+import java.util.regex.Pattern;\r
+\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.WriteGraph;\r
+import org.simantics.db.common.utils.OrderedSetUtils;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.db.request.Read;\r
+import org.simantics.layer0.Layer0;\r
+import org.simantics.sysdyn.SysdynResource;\r
+import org.simantics.sysdyn.manager.SysdynModel;\r
+import org.simantics.sysdyn.representation.Configuration;\r
+import org.simantics.sysdyn.representation.IElement;\r
+import org.simantics.sysdyn.representation.Variable;\r
+import org.simantics.ui.SimanticsUI;\r
+\r
+public class VariableNameUtils {\r
+\r
+ /**\r
+ * Replaces variable names in all the expressions in the defined configuration. \r
+ * Replace doesn't have to replace words in other configurations than the configuration where the renamed variable is\r
+ * because input variables handle the transitions between configurations (modules).\r
+ * \r
+ * @param graph WriteGraph\r
+ * @param configuration The configuration where the renamed variable is located\r
+ * @param originalName The original name of the variable\r
+ * @param newName New name of the variable\r
+ */\r
+ public static void renameInEquations(WriteGraph graph, Resource variable, String originalName, String newName) throws DatabaseException {\r
+ /*FIXME: \r
+ * How this works when range used in equations has the same string as\r
+ * the renamed variable? Should it be possible? \r
+ */ \r
+ Layer0 l0 = Layer0.getInstance(graph);\r
+ SysdynResource sr = SysdynResource.getInstance(graph);\r
+ Resource configuration = graph.getSingleObject(variable, l0.PartOf);\r
+ for(Resource r : graph.getObjects(configuration, l0.ConsistsOf)) {\r
+ if(graph.isInstanceOf(r, sr.IndependentVariable)) {\r
+ Resource expressions = graph.getPossibleObject(r, sr.HasExpressions);\r
+ if(expressions == null) continue;\r
+ List<Resource> expressionList = OrderedSetUtils.toList(graph, expressions);\r
+ for(Resource s : expressionList) {\r
+ for(Resource p : graph.getPredicates(s)) {\r
+ Resource o = graph.getPossibleObject(s, p);\r
+ if(o != null && graph.isInstanceOf(o, l0.String) && !p.equals(sr.HasArrayRange)) {\r
+ String string = graph.getRelatedValue(s, p);\r
+ String replaced = replaceAllWords(string, originalName, newName);\r
+ graph.claimLiteral(s, p, replaced);\r
+ }\r
+ }\r
+ }\r
+ }\r
+ }\r
+ }\r
+\r
+ private static String replaceAllWords(String original, String find, String replacement) {\r
+ if(!original.contains(find)) return original;\r
+ StringBuilder result = new StringBuilder(original.length());\r
+ String delimiters = "+-*/(){}[],.: ";\r
+ StringTokenizer st = new StringTokenizer(original, delimiters, true);\r
+ while (st.hasMoreTokens()) {\r
+ String w = st.nextToken();\r
+ if (w.equals(find)) {\r
+ result.append(replacement);\r
+ } else {\r
+ result.append(w);\r
+ }\r
+ }\r
+ return result.toString();\r
+ }\r
+\r
+\r
+ private static boolean nameIsTaken(ReadGraph graph, Resource variable, String name) throws DatabaseException {\r
+ if(variable == null)\r
+ return false;\r
+ SysdynModel model = ModelUtils.getModel(graph, variable);\r
+ if(model == null)\r
+ return true;\r
+ Configuration configuration = model.getConfiguration();\r
+ IElement current = model.getElement(variable);\r
+ for(IElement e : configuration.getElements()) {\r
+ if(e instanceof Variable) {\r
+ Variable v = (Variable) e;\r
+ if(!v.equals(current) && v.getName().equals(name)) {\r
+ return true;\r
+ }\r
+ }\r
+ }\r
+ return false;\r
+ }\r
+\r
+ /**\r
+ * Checks that the syntax of the given name is valid and there \r
+ * are no other variables that have the same name in the configuration\r
+ * \r
+ * @param graph ReadGraph\r
+ * @param variable The variable that is being renamed\r
+ * @param name The new name of the variable\r
+ * @return\r
+ * @throws DatabaseException\r
+ */\r
+ public static boolean isValid(ReadGraph graph, Resource variable, String name, boolean hasRange) throws DatabaseException {\r
+ if(name.length() < 1)\r
+ return false;\r
+ if(hasRange) {\r
+ String range = null;\r
+ if(name.contains("[")) {\r
+ StringTokenizer st = new StringTokenizer(name, "[]", true);\r
+ if(st.countTokens() != 4)\r
+ return false;\r
+ name = st.nextToken();\r
+ if(!st.nextToken().equals("[")) return false;\r
+ range = st.nextToken();\r
+ if(!st.nextToken().equals("]")) return false;\r
+ }\r
+ if(range != null && !ArrayVariableUtils.isRangeValid(graph, variable, range)) return false;\r
+ }\r
+ if(nameIsTaken(graph, variable, name)) return false;\r
+ if(!isValid(name)) return false;\r
+ return true;\r
+ }\r
+\r
+ \r
+ /**\r
+ * Checks that the syntax of the given name is valid and there \r
+ * are no other variables that have the same name in the configuration\r
+ * \r
+ * @param variable The variable that is being renamed\r
+ * @param name The new name of the variable\r
+ * @return\r
+ * @throws DatabaseException\r
+ */\r
+ public static boolean isValid(final Resource variable, final String name, final boolean hasRange) {\r
+ boolean result = false;\r
+ try {\r
+ result = SimanticsUI.getSession().syncRequest(new Read<Boolean>() {\r
+\r
+ @Override\r
+ public Boolean perform(ReadGraph graph) throws DatabaseException {\r
+ return isValid(graph, variable, name, hasRange);\r
+ }\r
+\r
+ });\r
+ } catch (DatabaseException e) {\r
+ e.printStackTrace();\r
+ }\r
+ return result;\r
+ }\r
+\r
+ /**\r
+ * Checks that the syntax of the given name is valid \r
+ * and that it is not a keyword in Modelica.\r
+ * \r
+ * @param name\r
+ * @return\r
+ */\r
+ public static boolean isValid(String name) {\r
+ String lowerCase = name.toLowerCase();\r
+ Pattern p = Pattern.compile("[a-zA-Z0-9]++");\r
+ Matcher m = p.matcher(lowerCase);\r
+ if (!m.matches() || keywords.contains(name))\r
+ return false;\r
+ else\r
+ return true;\r
+ }\r
+\r
+ public static final Set<String> keywords = new HashSet<String>();\r
+\r
+ static {\r
+ keywords.add("algorithm");\r
+ keywords.add("discrete");\r
+ keywords.add("false");\r
+ keywords.add("model");\r
+ keywords.add("redeclare");\r
+ keywords.add("and");\r
+ keywords.add("each");\r
+ keywords.add("final");\r
+ keywords.add("not");\r
+ keywords.add("replaceable");\r
+ keywords.add("annotation");\r
+ keywords.add("else");\r
+ keywords.add("flow");\r
+ keywords.add("operator");\r
+ keywords.add("return");\r
+ keywords.add("assert");\r
+ keywords.add("elseif");\r
+ keywords.add("for");\r
+ keywords.add("or");\r
+ keywords.add("stream");\r
+ keywords.add("block");\r
+ keywords.add("elsewhen");\r
+ keywords.add("function");\r
+ keywords.add("outer");\r
+ keywords.add("then");\r
+ keywords.add("break");\r
+ keywords.add("encapsulated");\r
+ keywords.add("if");\r
+ keywords.add("output");\r
+ keywords.add("true");\r
+ keywords.add("class");\r
+ keywords.add("end");\r
+ keywords.add("import");\r
+ keywords.add("package");\r
+ keywords.add("type");\r
+ keywords.add("connect");\r
+ keywords.add("enumeration");\r
+ keywords.add("in");\r
+ keywords.add("parameter");\r
+ keywords.add("when");\r
+ keywords.add("connector");\r
+ keywords.add("equation");\r
+ keywords.add("initial");\r
+ keywords.add("partial");\r
+ keywords.add("while");\r
+ keywords.add("constant");\r
+ keywords.add("expandable");\r
+ keywords.add("inner");\r
+ keywords.add("protected");\r
+ keywords.add("within");\r
+ keywords.add("constrainedby");\r
+ keywords.add("extends");\r
+ keywords.add("input");\r
+ keywords.add("public");\r
+ keywords.add("der");\r
+ keywords.add("external");\r
+ keywords.add("loop");\r
+ keywords.add("record");\r
+ keywords.add("time");\r
+ }\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2010 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.ui.values;\r
+\r
+import java.util.ArrayList;\r
+import java.util.Collection;\r
+import java.util.List;\r
+\r
+import org.eclipse.jface.layout.GridDataFactory;\r
+import org.eclipse.jface.layout.GridLayoutFactory;\r
+import org.eclipse.swt.SWT;\r
+import org.eclipse.swt.layout.GridData;\r
+import org.eclipse.swt.widgets.Composite;\r
+import org.eclipse.swt.widgets.Event;\r
+import org.eclipse.swt.widgets.Listener;\r
+import org.eclipse.swt.widgets.Table;\r
+import org.eclipse.swt.widgets.TableColumn;\r
+import org.eclipse.swt.widgets.TableItem;\r
+import org.eclipse.ui.ISelectionListener;\r
+import org.eclipse.ui.part.ViewPart;\r
+import org.simantics.sysdyn.manager.SysdynDataSet;\r
+import org.simantics.sysdyn.ui.viewUtils.SysdynDatasetSelectionListener;\r
+\r
+public class ValueView extends ViewPart {\r
+\r
+ private boolean disposed;\r
+ private Composite baseComposite;\r
+ private ISelectionListener selectionListener;\r
+ private Table table;\r
+\r
+ @Override\r
+ public void createPartControl(Composite parent) {\r
+\r
+ disposed = false;\r
+ GridLayoutFactory.fillDefaults().margins(3, 3).applyTo(parent);\r
+ baseComposite = new Composite(parent, \r
+ SWT.NO_BACKGROUND | SWT.EMBEDDED);\r
+ GridLayoutFactory.fillDefaults().applyTo(baseComposite);\r
+ GridDataFactory.fillDefaults().grab(true, true).applyTo(baseComposite);\r
+\r
+ table = new Table (baseComposite, SWT.MULTI | SWT.BORDER | SWT.FULL_SELECTION);\r
+ GridDataFactory.fillDefaults().grab(true, true).applyTo(table);\r
+ table.setLinesVisible (true);\r
+ table.setHeaderVisible (true);\r
+ GridData data = new GridData(SWT.FILL, SWT.FILL, true, true);\r
+ data.heightHint = 200;\r
+ table.setLayoutData(data);\r
+\r
+\r
+ selectionListener = new SysdynDatasetSelectionListener() {\r
+\r
+ @Override\r
+ protected void selectionChanged(final Collection<SysdynDataSet> activeDatasets) {\r
+ if(disposed) return;\r
+ table.getDisplay().asyncExec(new Runnable() {\r
+\r
+ @Override\r
+ public void run() {\r
+ updateTable(activeDatasets);\r
+ }\r
+ });\r
+ }\r
+ }; \r
+ getSite().getWorkbenchWindow().getSelectionService().addPostSelectionListener(selectionListener);\r
+\r
+ }\r
+\r
+ private void updateTable(Collection<SysdynDataSet> activeDatasets) {\r
+\r
+ if(activeDatasets.isEmpty() || !(activeDatasets instanceof ArrayList)) return;\r
+ \r
+ // Clear the old table\r
+ table.removeAll();\r
+ if(table.getColumnCount() > 0) {\r
+ for(int i = table.getColumnCount() - 1; i>=0; i--) {\r
+ table.getColumn(i).dispose();\r
+ }\r
+ }\r
+ \r
+ // Create new columns\r
+ ArrayList<SysdynDataSet> datasets = (ArrayList<SysdynDataSet>) activeDatasets;\r
+ \r
+ ArrayList<String> titleList = new ArrayList<String>();\r
+ titleList.add("Time");\r
+ List<Double> times = null;\r
+ for (int i=0; i<datasets.size(); i++) {\r
+ String name = datasets.get(i).name;\r
+ if(datasets.get(i).result != null)\r
+ name += " : " + datasets.get(i).result;\r
+ titleList.add(name);\r
+ if(times == null || datasets.get(i).values.size() > times.size()) {\r
+ times = datasets.get(i).times;\r
+ }\r
+ }\r
+\r
+ \r
+ Listener sortListener = new Listener() {\r
+ public void handleEvent(Event e) {\r
+ TableItem[] items = table.getItems();\r
+ TableColumn column = (TableColumn)e.widget;\r
+ \r
+ TableColumn sortColumn = table.getSortColumn();\r
+ int dir = table.getSortDirection();\r
+ if (sortColumn == column) {\r
+ dir = dir == SWT.UP ? SWT.DOWN : SWT.UP;\r
+ } else {\r
+ table.setSortColumn(column);\r
+ dir = SWT.UP;\r
+ }\r
+ \r
+ int index = 0;\r
+ while(index < table.getColumnCount()) {\r
+ if(table.getColumn(index) == column)\r
+ break;\r
+ index++;\r
+ }\r
+ for (int i = 1; i < items.length; i++) {\r
+ String v1 = items[i].getText(index);\r
+ if(v1.contains("*"))\r
+ v1 = v1.substring(0, v1.indexOf("*"));\r
+ Double value1;\r
+ try {\r
+ value1 = Double.parseDouble(v1);\r
+ } catch(NumberFormatException ne) {\r
+ continue;\r
+ }\r
+ for (int j = 0; j < i; j++){\r
+ String v2 = items[j].getText(index);\r
+ if(v2.contains("*"))\r
+ v2 = v2.substring(0, v2.indexOf("*"));\r
+ Double value2;\r
+ try {\r
+ value2 = Double.parseDouble(v2);\r
+ } catch(NumberFormatException ne) {\r
+ continue;\r
+ }\r
+ int result = value1.compareTo(value2);\r
+ if (dir == SWT.UP && result < 0 || dir == SWT.DOWN && result > 0) {\r
+ int columns = table.getColumnCount();\r
+ String[] values = new String[columns];\r
+ for(int k = 0; k < columns; k++) {\r
+ values[k] = items[i].getText(k);\r
+ }\r
+ items[i].dispose();\r
+ TableItem item = new TableItem(table, SWT.NONE, j);\r
+ item.setText(values);\r
+ items = table.getItems();\r
+ break;\r
+ }\r
+ }\r
+ }\r
+ table.setSortColumn(column);\r
+ table.setSortDirection(dir);\r
+ }\r
+ };\r
+\r
+\r
+ \r
+ String[] titles = titleList.toArray(new String[titleList.size()]);\r
+ \r
+ for (int i=0; i<titles.length; i++) {\r
+ TableColumn column = new TableColumn (table, SWT.NONE);\r
+ column.setText (titles [i]);\r
+ column.addListener(SWT.Selection, sortListener);\r
+ column.setMoveable(true);\r
+ } \r
+ \r
+ table.setSortColumn(table.getColumn(0));\r
+ table.setSortDirection(SWT.UP);\r
+ \r
+ // add results\r
+ \r
+ for (int i=0; i<times.size(); i++) {\r
+ TableItem item = new TableItem (table, SWT.NONE);\r
+ item.setText(0, times.get(i).toString());\r
+ for(int j=0; j<datasets.size(); j++) {\r
+ String approximation = approximate(times.get(i), i, datasets.get(j));\r
+ item.setText (j + 1 /* time is at column 0 */, approximation);\r
+ }\r
+ }\r
+ \r
+ for (int i=0; i<titles.length; i++) {\r
+ table.getColumn (i).pack ();\r
+ } \r
+\r
+ }\r
+\r
+ \r
+ private String approximate(Double time, int index, SysdynDataSet dataset) {\r
+ \r
+ // time out of datasets range\r
+ if(time > dataset.times.get(dataset.times.size() - 1) ||\r
+ time < dataset.times.get(0)) {\r
+ return "---";\r
+ }\r
+ \r
+ // Make sure the index is within times array\r
+ if(index >= dataset.times.size())\r
+ index = dataset.times.size() - 1;\r
+\r
+ // times match, no approximation needed\r
+ if(dataset.times.contains(time)) {\r
+ return dataset.values.get(dataset.times.indexOf(time)).toString();\r
+ }\r
+\r
+ // Search the position on datasets' timeline\r
+ int dir = table.getSortDirection();\r
+ while(dataset.times.get(index) > time) {\r
+ index = dir == SWT.UP ? index - 1 : index + 1;\r
+ }\r
+ while(dataset.times.get(index) <= time)\r
+ index = dir == SWT.UP ? index + 1 : index - 1;\r
+ \r
+ int a = dir == SWT.UP ? index - 1 : index;\r
+ int b = dir == SWT.UP ? index : index - 1;\r
+ \r
+ return dataset.values.get(a) + \r
+ (dataset.values.get(b) - dataset.values.get(a)) * \r
+ (time - dataset.times.get(a)) /\r
+ (dataset.times.get(b) - dataset.times.get(a)) + "*"; \r
+ }\r
+\r
+ @Override\r
+ public void setFocus() {\r
+ // TODO Auto-generated method stub\r
+\r
+ }\r
+\r
+ @Override\r
+ public void dispose() {\r
+ super.dispose();\r
+ getSite().getWorkbenchWindow().getSelectionService().removePostSelectionListener(selectionListener);\r
+ disposed = true;\r
+ }\r
+\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2010 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.ui.viewUtils;\r
+\r
+import java.util.ArrayList;\r
+import java.util.Collection;\r
+import java.util.HashMap;\r
+import java.util.HashSet;\r
+import java.util.List;\r
+import java.util.Set;\r
+\r
+import org.eclipse.jface.viewers.ISelection;\r
+import org.eclipse.jface.viewers.IStructuredSelection;\r
+import org.eclipse.ui.ISelectionListener;\r
+import org.eclipse.ui.IWorkbenchPart;\r
+import org.simantics.databoard.Bindings;\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.Session;\r
+import org.simantics.db.common.request.ObjectsWithType;\r
+import org.simantics.db.common.request.ReadRequest;\r
+import org.simantics.db.common.utils.OrderedSetUtils;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.db.layer0.SelectionHints;\r
+import org.simantics.db.layer0.exception.MissingVariableException;\r
+import org.simantics.db.layer0.variable.Variable;\r
+import org.simantics.db.layer0.variable.Variables;\r
+import org.simantics.diagram.stubs.DiagramResource;\r
+import org.simantics.layer0.Layer0;\r
+import org.simantics.modeling.ModelingUtils;\r
+import org.simantics.simulation.ontology.SimulationResource;\r
+import org.simantics.sysdyn.SysdynResource;\r
+import org.simantics.sysdyn.manager.SysdynDataSet;\r
+import org.simantics.sysdyn.manager.SysdynModel;\r
+import org.simantics.sysdyn.manager.SysdynModelManager;\r
+import org.simantics.sysdyn.manager.SysdynResult;\r
+import org.simantics.sysdyn.ui.trend.PinTrend;\r
+import org.simantics.ui.SimanticsUI;\r
+import org.simantics.utils.ui.ISelectionUtils;\r
+\r
+public abstract class SysdynDatasetSelectionListener implements ISelectionListener {\r
+ \r
+ protected abstract void selectionChanged(Collection<SysdynDataSet> activeDatasets);\r
+ \r
+ HashMap<SysdynModel, Runnable> resultListeners = new HashMap<SysdynModel, Runnable>();\r
+\r
+ @Override\r
+ public void selectionChanged(IWorkbenchPart part, final ISelection selection) {\r
+ if(selection.isEmpty() || Boolean.TRUE.equals(PinTrend.getState()))\r
+ return;\r
+ if(selection instanceof IStructuredSelection) {\r
+ if(!resultListeners.isEmpty()) {\r
+ for(SysdynModel model : resultListeners.keySet())\r
+ model.removeResultListener(resultListeners.get(model));\r
+ resultListeners.clear();\r
+ }\r
+ \r
+ Session session = SimanticsUI.peekSession();\r
+ if (session == null)\r
+ return;\r
+\r
+ session.asyncRequest(new ReadRequest() {\r
+ @Override\r
+ public void run(ReadGraph graph) throws DatabaseException {\r
+ \r
+ Collection<Variable> vars = ISelectionUtils.filterSetSelection(selection, Variable.class);\r
+ \r
+ if(vars.isEmpty()) {\r
+ Set<Resource> ress = ISelectionUtils.filterSetSelection(selection, Resource.class);\r
+ List<Resource> runtimes = ISelectionUtils.getPossibleKeys(selection, SelectionHints.KEY_VARIABLE_RESOURCE, Resource.class);\r
+ if(runtimes.isEmpty())\r
+ return;\r
+ Resource runtime = runtimes.get(0);\r
+ \r
+ for(Resource resource : ress) {\r
+ Variable variable = getVariable(graph, resource, runtime);\r
+ if(variable != null)\r
+ vars.add(variable);\r
+ }\r
+ }\r
+ \r
+ updateDatasets(graph, vars);\r
+ addResultListeners(graph, vars);\r
+ }\r
+ });\r
+ }\r
+ }\r
+ \r
+ \r
+ private void addResultListeners(ReadGraph graph, final Collection<Variable> variables) throws DatabaseException {\r
+ if(variables.size() < 1) return;\r
+ \r
+ HashSet<SysdynModel> models = new HashSet<SysdynModel>(); \r
+ for(Variable variable : variables) {\r
+ Resource model = Variables.getModel(graph, variable);\r
+ if(model != null) {\r
+ models.add(getSysdynModel(graph, model));\r
+ }\r
+ }\r
+ \r
+ Runnable listener = new Runnable() {\r
+ @Override\r
+ public void run() {\r
+ Session session = SimanticsUI.peekSession();\r
+ if (session == null)\r
+ return;\r
+ \r
+ session.asyncRequest(new ReadRequest() {\r
+ \r
+ @Override\r
+ public void run(ReadGraph graph) throws DatabaseException {\r
+ updateDatasets(graph, variables);\r
+ }\r
+ });\r
+ }\r
+ };\r
+ \r
+ for(SysdynModel model : models) {\r
+ model.addResultListener(listener);\r
+ resultListeners.put(model, listener);\r
+ }\r
+ }\r
+ \r
+ private void updateDatasets(ReadGraph graph, Collection<Variable> variables) throws DatabaseException {\r
+\r
+ ArrayList<SysdynDataSet> datasets = new ArrayList<SysdynDataSet>();\r
+ for(Variable variable : variables) {\r
+ Collection<SysdynDataSet> activeDataSets = loadAllActive(graph, variable);\r
+ if(activeDataSets != null && !activeDataSets.isEmpty())\r
+ datasets.addAll(activeDataSets);\r
+ }\r
+ selectionChanged(datasets);\r
+\r
+ }\r
+\r
+\r
+ protected Collection<SysdynDataSet> loadAllActive(ReadGraph g, Variable variable) throws DatabaseException {\r
+ ArrayList<SysdynDataSet> dataSets = new ArrayList<SysdynDataSet>();\r
+ HashMap<String, String> rvis = new HashMap<String, String>();\r
+\r
+ String rvi = Variables.getRVI(g, variable).replace("/", "."); \r
+ if(rvi.length() > 1)\r
+ rvi = rvi.substring(1);\r
+\r
+ Resource r = variable.getPropertyValue(g, Variables.REPRESENTS);\r
+ \r
+ SysdynResource sr = SysdynResource.getInstance(g);\r
+ Resource arrayIndexes = g.getPossibleObject(r, sr.HasArrayIndexes);\r
+ if(arrayIndexes == null) {\r
+ rvis.put(rvi, rvi);\r
+ } else {\r
+ List<Resource> arrayIndexList= OrderedSetUtils.toList(g, arrayIndexes);\r
+ resolveActiveArrayIndexes(g, variable, arrayIndexList);\r
+ \r
+ if(arrayIndexList.size() > 0)\r
+ traverseIndexes(g, rvi, rvis, arrayIndexList);\r
+ else\r
+ rvis.put(rvi, rvi);\r
+ }\r
+ \r
+ Resource modelResource = Variables.getModel(g, variable);\r
+ SysdynModel model = getSysdynModel(g, modelResource);\r
+ \r
+ if(model == null)\r
+ return dataSets;\r
+ \r
+ Collection<SysdynResult> activeResults = model.getActiveResults(g);\r
+ for(SysdynResult sysdynResult : activeResults) {\r
+ for(String currvi : rvis.keySet()) {\r
+ SysdynDataSet sds = sysdynResult.getDataSet(currvi);\r
+ if(sds != null) {\r
+ sds.name = rvis.get(currvi);\r
+ dataSets.add(sds);\r
+ }\r
+ }\r
+ }\r
+ return dataSets;\r
+\r
+ }\r
+ \r
+ private static List<Resource> resolveActiveArrayIndexes(ReadGraph graph, Variable variable, List<Resource> enumerations) {\r
+ try {\r
+ Layer0 l0 = Layer0.getInstance(graph);\r
+ SysdynResource sr = SysdynResource.getInstance(graph);\r
+ String uri = variable.getURI(graph);\r
+ uri = uri.substring(0, uri.lastIndexOf("/"));\r
+ Variable v = Variables.getPossibleVariable(graph, uri);\r
+ if(v != null) {\r
+ Variable rp = (Variable)v.getProperty(graph, Variables.REPRESENTS);\r
+ Resource module = rp.getValue(graph);\r
+ if(module != null && graph.isInheritedFrom(graph.getSingleObject(module, l0.InstanceOf), sr.Module)) {\r
+ \r
+ boolean somethingIsReplaced = false;\r
+ for(Resource redeclaration : graph.syncRequest(new ObjectsWithType(module, sr.HasRedeclaration, sr.Redeclaration))) {\r
+ Resource replaced = graph.getSingleObject(redeclaration, sr.ReplacedEnumeration);\r
+ if(enumerations.contains(replaced)) {\r
+ enumerations.add(enumerations.indexOf(replaced), graph.getSingleObject(redeclaration, sr.ReplacingEnumeration));\r
+ enumerations.remove(replaced);\r
+ somethingIsReplaced = true;\r
+ }\r
+ }\r
+ \r
+ if(somethingIsReplaced) {\r
+ resolveActiveArrayIndexes(graph, v, enumerations);\r
+ }\r
+ }\r
+ }\r
+ } catch (DatabaseException e) {\r
+ e.printStackTrace();\r
+ \r
+ }\r
+ return enumerations;\r
+ }\r
+ \r
+ private void traverseIndexes(ReadGraph g, String rvi, HashMap<String, String> rvis, List<Resource> arrayIndexes) throws DatabaseException {\r
+ traverseIndexes(g, rvi, rvis, arrayIndexes, arrayIndexes.get(0), "", "");\r
+ }\r
+ \r
+ private void traverseIndexes(ReadGraph g, String rvi, HashMap<String, String> rvis, List<Resource> arrayIndexes, Resource currentEnumeration, String indexesSoFar, String indexNamesSoFar) throws DatabaseException {\r
+ SysdynResource sr = SysdynResource.getInstance(g);\r
+ Resource enumerationIndexes = g.getPossibleObject(currentEnumeration, sr.HasEnumerationIndexes);\r
+ if(enumerationIndexes == null)\r
+ return;\r
+ List<Resource> indexes = OrderedSetUtils.toList(g, enumerationIndexes);\r
+ for(int i = 0; i < indexes.size(); i++) {\r
+ Boolean b = g.getPossibleRelatedValue(indexes.get(i), sr.ShowEnumerationIndexInCharts, Bindings.BOOLEAN);\r
+ if(Boolean.TRUE.equals(b)) {\r
+ int arrayIndex = arrayIndexes.indexOf(currentEnumeration);\r
+ String name = g.getRelatedValue(indexes.get(i), Layer0.getInstance(g).HasName);\r
+ if(arrayIndex < arrayIndexes.size() - 1)\r
+ traverseIndexes(g, rvi, rvis, arrayIndexes, arrayIndexes.get(arrayIndex + 1), \r
+ indexesSoFar + (i + 1) +",", indexNamesSoFar + (name) +",");\r
+ else {\r
+ rvis.put(\r
+ rvi + "[" + indexesSoFar + (i + 1) + "]", \r
+ rvi + "[" + indexNamesSoFar + (name) + "]");\r
+ }\r
+ }\r
+ }\r
+ }\r
+ \r
+ private Variable getVariable(ReadGraph g, Resource element, Resource runtime) throws DatabaseException {\r
+ SysdynResource sr = SysdynResource.getInstance(g);\r
+ DiagramResource dr = DiagramResource.getInstance(g);\r
+ if(runtime == null) return null;\r
+ Resource resource = ModelingUtils.getPossibleElementCorrespondendence(g, element);\r
+ if(resource == null || !g.isInstanceOf(resource, sr.Variable)) return null;\r
+ String variableURI = g.getPossibleRelatedValue(runtime, dr.HasVariable);\r
+ try {\r
+ Variable compositeVariable = Variables.getVariable(g, variableURI);\r
+ return compositeVariable.browsePossible(g, resource);\r
+ } catch (MissingVariableException e) {\r
+ return null;\r
+ }\r
+ }\r
+ \r
+ private SysdynModel getSysdynModel(ReadGraph g, Resource model) throws DatabaseException {\r
+ Resource configuration = g.getPossibleObject(model, SimulationResource.getInstance(g).HasConfiguration);\r
+ return SysdynModelManager.getInstance(g.getSession()).getModel(g, configuration);\r
+ }\r
+\r
+}\r
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>\r
+<?pde version="3.5"?>\r
+\r
+<product name="Simantics System Dynamic Tool" uid="sysdyn" id="org.simantics.sysdyn.ui.product" application="org.simantics.workbench.application" version="1.0" useFeatures="true" includeLaunchers="true">\r
+\r
+ <configIni use="default">\r
+ </configIni>\r
+\r
+ <launcherArgs>\r
+ <programArgs>-fixerrors</programArgs>\r
+ <vmArgs>-ea -Xmx768M -Xshare:off</vmArgs>\r
+ <vmArgsMac>-XstartOnFirstThread -Dorg.eclipse.swt.internal.carbon.smallFonts</vmArgsMac>\r
+ </launcherArgs>\r
+\r
+ <windowImages/>\r
+\r
+ <launcher name="Simantics-Sysdyn">\r
+ <solaris/>\r
+ <win useIco="false">\r
+ <bmp/>\r
+ </win>\r
+ </launcher>\r
+\r
+ <vm>\r
+ </vm>\r
+\r
+ <license>\r
+ <url>http://www.eclipse.org/legal/epl-v10.html</url>\r
+ <text>\r
+ Eclipse Public License - v 1.0
+
+THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS ECLIPSE PUBLIC LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT.
+
+1. DEFINITIONS
+
+"Contribution" means:
+
+a) in the case of the initial Contributor, the initial code and documentation distributed under this Agreement, and
+b) in the case of each subsequent Contributor:
+i) changes to the Program, and
+ii) additions to the Program;
+where such changes and/or additions to the Program originate from and are distributed by that particular Contributor. A Contribution 'originates' from a Contributor if it was added to the Program by such Contributor itself or anyone acting on such Contributor's behalf. Contributions do not include additions to the Program which: (i) are separate modules of software distributed in conjunction with the Program under their own license agreement, and (ii) are not derivative works of the Program.
+"Contributor" means any person or entity that distributes the Program.
+
+"Licensed Patents" mean patent claims licensable by a Contributor which are necessarily infringed by the use or sale of its Contribution alone or when combined with the Program.
+
+"Program" means the Contributions distributed in accordance with this Agreement.
+
+"Recipient" means anyone who receives the Program under this Agreement, including all Contributors.
+
+2. GRANT OF RIGHTS
+
+a) Subject to the terms of this Agreement, each Contributor hereby grants Recipient a non-exclusive, worldwide, royalty-free copyright license to reproduce, prepare derivative works of, publicly display, publicly perform, distribute and sublicense the Contribution of such Contributor, if any, and such derivative works, in source code and object code form.
+b) Subject to the terms of this Agreement, each Contributor hereby grants Recipient a non-exclusive, worldwide, royalty-free patent license under Licensed Patents to make, use, sell, offer to sell, import and otherwise transfer the Contribution of such Contributor, if any, in source code and object code form. This patent license shall apply to the combination of the Contribution and the Program if, at the time the Contribution is added by the Contributor, such addition of the Contribution causes such combination to be covered by the Licensed Patents. The patent license shall not apply to any other combinations which include the Contribution. No hardware per se is licensed hereunder.
+c) Recipient understands that although each Contributor grants the licenses to its Contributions set forth herein, no assurances are provided by any Contributor that the Program does not infringe the patent or other intellectual property rights of any other entity. Each Contributor disclaims any liability to Recipient for claims brought by any other entity based on infringement of intellectual property rights or otherwise. As a condition to exercising the rights and licenses granted hereunder, each Recipient hereby assumes sole responsibility to secure any other intellectual property rights needed, if any. For example, if a third party patent license is required to allow Recipient to distribute the Program, it is Recipient's responsibility to acquire that license before distributing the Program.
+d) Each Contributor represents that to its knowledge it has sufficient copyright rights in its Contribution, if any, to grant the copyright license set forth in this Agreement.
+3. REQUIREMENTS
+
+A Contributor may choose to distribute the Program in object code form under its own license agreement, provided that:
+
+a) it complies with the terms and conditions of this Agreement; and
+b) its license agreement:
+i) effectively disclaims on behalf of all Contributors all warranties and conditions, express and implied, including warranties or conditions of title and non-infringement, and implied warranties or conditions of merchantability and fitness for a particular purpose;
+ii) effectively excludes on behalf of all Contributors all liability for damages, including direct, indirect, special, incidental and consequential damages, such as lost profits;
+iii) states that any provisions which differ from this Agreement are offered by that Contributor alone and not by any other party; and
+iv) states that source code for the Program is available from such Contributor, and informs licensees how to obtain it in a reasonable manner on or through a medium customarily used for software exchange.
+When the Program is made available in source code form:
+
+a) it must be made available under this Agreement; and
+b) a copy of this Agreement must be included with each copy of the Program.
+Contributors may not remove or alter any copyright notices contained within the Program.
+
+Each Contributor must identify itself as the originator of its Contribution, if any, in a manner that reasonably allows subsequent Recipients to identify the originator of the Contribution.
+
+4. COMMERCIAL DISTRIBUTION
+
+Commercial distributors of software may accept certain responsibilities with respect to end users, business partners and the like. While this license is intended to facilitate the commercial use of the Program, the Contributor who includes the Program in a commercial product offering should do so in a manner which does not create potential liability for other Contributors. Therefore, if a Contributor includes the Program in a commercial product offering, such Contributor ("Commercial Contributor") hereby agrees to defend and indemnify every other Contributor ("Indemnified Contributor") against any losses, damages and costs (collectively "Losses") arising from claims, lawsuits and other legal actions brought by a third party against the Indemnified Contributor to the extent caused by the acts or omissions of such Commercial Contributor in connection with its distribution of the Program in a commercial product offering. The obligations in this section do not apply to any claims or Losses relating to any actual or alleged intellectual property infringement. In order to qualify, an Indemnified Contributor must: a) promptly notify the Commercial Contributor in writing of such claim, and b) allow the Commercial Contributor to control, and cooperate with the Commercial Contributor in, the defense and any related settlement negotiations. The Indemnified Contributor may participate in any such claim at its own expense.
+
+For example, a Contributor might include the Program in a commercial product offering, Product X. That Contributor is then a Commercial Contributor. If that Commercial Contributor then makes performance claims, or offers warranties related to Product X, those performance claims and warranties are such Commercial Contributor's responsibility alone. Under this section, the Commercial Contributor would have to defend claims against the other Contributors related to those performance claims and warranties, and if a court requires any other Contributor to pay any damages as a result, the Commercial Contributor must pay those damages.
+
+5. NO WARRANTY
+
+EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is solely responsible for determining the appropriateness of using and distributing the Program and assumes all risks associated with its exercise of rights under this Agreement , including but not limited to the risks and costs of program errors, compliance with applicable laws, damage to or loss of data, programs or equipment, and unavailability or interruption of operations.
+
+6. DISCLAIMER OF LIABILITY
+
+EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+
+7. GENERAL
+
+If any provision of this Agreement is invalid or unenforceable under applicable law, it shall not affect the validity or enforceability of the remainder of the terms of this Agreement, and without further action by the parties hereto, such provision shall be reformed to the minimum extent necessary to make such provision valid and enforceable.
+
+If Recipient institutes patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Program itself (excluding combinations of the Program with other software or hardware) infringes such Recipient's patent(s), then such Recipient's rights granted under Section 2(b) shall terminate as of the date such litigation is filed.
+
+All Recipient's rights under this Agreement shall terminate if it fails to comply with any of the material terms or conditions of this Agreement and does not cure such failure in a reasonable period of time after becoming aware of such noncompliance. If all Recipient's rights under this Agreement terminate, Recipient agrees to cease use and distribution of the Program as soon as reasonably practicable. However, Recipient's obligations under this Agreement and any licenses granted by Recipient relating to the Program shall continue and survive.
+
+Everyone is permitted to copy and distribute copies of this Agreement, but in order to avoid inconsistency the Agreement is copyrighted and may only be modified in the following manner. The Agreement Steward reserves the right to publish new versions (including revisions) of this Agreement from time to time. No one other than the Agreement Steward has the right to modify this Agreement. The Eclipse Foundation is the initial Agreement Steward. The Eclipse Foundation may assign the responsibility to serve as the Agreement Steward to a suitable separate entity. Each new version of the Agreement will be given a distinguishing version number. The Program (including Contributions) may always be distributed subject to the version of the Agreement under which it was received. In addition, after a new version of the Agreement is published, Contributor may elect to distribute the Program (including its Contributions) under the new version. Except as expressly stated in Sections 2(a) and 2(b) above, Recipient receives no rights or licenses to the intellectual property of any Contributor under this Agreement, whether expressly, by implication, estoppel or otherwise. All rights in the Program not expressly granted under this Agreement are reserved.
+
+This Agreement is governed by the laws of the State of New York and the intellectual property laws of the United States of America. No party to this Agreement will bring a legal action under this Agreement more than one year after the cause of action arose. Each party waives its rights to a jury trial in any resulting litigation.\r
+ </text>\r
+ </license>\r
+\r
+ <plugins>\r
+ </plugins>\r
+\r
+ <features>\r
+ <feature id="org.simantics.sysdyn" version="1.0.0.qualifier"/>\r
+ </features>\r
+\r
+\r
+</product>\r
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>\r
+<classpath>\r
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>\r
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>\r
+ <classpathentry kind="src" path="src"/>\r
+ <classpathentry kind="output" path="bin"/>\r
+</classpath>\r
--- /dev/null
+syntax: regexp\r
+^bin/\r
+\r
+syntax: glob\r
+*.svn/*
\ No newline at end of file
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>\r
+<projectDescription>\r
+ <name>org.simantics.sysdyn</name>\r
+ <comment></comment>\r
+ <projects>\r
+ </projects>\r
+ <buildSpec>\r
+ <buildCommand>\r
+ <name>org.eclipse.jdt.core.javabuilder</name>\r
+ <arguments>\r
+ </arguments>\r
+ </buildCommand>\r
+ <buildCommand>\r
+ <name>org.eclipse.pde.ManifestBuilder</name>\r
+ <arguments>\r
+ </arguments>\r
+ </buildCommand>\r
+ <buildCommand>\r
+ <name>org.eclipse.pde.SchemaBuilder</name>\r
+ <arguments>\r
+ </arguments>\r
+ </buildCommand>\r
+ </buildSpec>\r
+ <natures>\r
+ <nature>org.eclipse.pde.PluginNature</nature>\r
+ <nature>org.eclipse.jdt.core.javanature</nature>\r
+ </natures>\r
+</projectDescription>\r
--- /dev/null
+#Mon Nov 16 15:37:44 EET 2009\r
+eclipse.preferences.version=1\r
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled\r
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6\r
+org.eclipse.jdt.core.compiler.compliance=1.6\r
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error\r
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error\r
+org.eclipse.jdt.core.compiler.source=1.6\r
--- /dev/null
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: Simantics System Dynamics
+Bundle-SymbolicName: org.simantics.sysdyn
+Bundle-Version: 1.0.0.qualifier
+Bundle-RequiredExecutionEnvironment: JavaSE-1.6
+Require-Bundle: org.simantics.objmap;bundle-version="0.1.0",
+ org.simantics.db;bundle-version="0.6.2",
+ org.simantics.modelica;bundle-version="1.0.0",
+ org.simantics.db.common;bundle-version="0.8.0",
+ org.simantics.simulation;bundle-version="1.0.0",
+ org.simantics.data;bundle-version="0.6.3",
+ org.eclipse.ui.console;bundle-version="3.4.0",
+ org.eclipse.core.runtime;bundle-version="3.5.0",
+ org.eclipse.jface;bundle-version="3.5.2",
+ org.simantics.project;bundle-version="1.0.0",
+ org.simantics.layer0.utils;bundle-version="0.8.0",
+ org.simantics.layer0;bundle-version="1.0.0",
+ org.simantics.structural.ontology;bundle-version="1.0.0",
+ org.simantics.sysdyn.ontology;bundle-version="1.0.0",
+ org.simantics.modeling;bundle-version="1.1.1",
+ org.simantics.diagram;bundle-version="1.1.1",
+ org.simantics.diagram.ontology;bundle-version="1.1.1",
+ org.simantics.scl.runtime;bundle-version="0.1.3",
+ org.simantics.db.layer0;bundle-version="1.1.0"
+Export-Package: org.simantics.sysdyn,
+ org.simantics.sysdyn.expressionParser,
+ org.simantics.sysdyn.manager,
+ org.simantics.sysdyn.mdlImport,
+ org.simantics.sysdyn.mdlImport.mdlElements,
+ org.simantics.sysdyn.modelica,
+ org.simantics.sysdyn.representation,
+ org.simantics.sysdyn.representation.visitors,
+ org.simantics.sysdyn.simulation,
+ org.simantics.sysdyn.tableParser,
+ org.simantics.sysdyn.adapter
+Bundle-Activator: org.simantics.sysdyn.Activator
+Bundle-ActivationPolicy: lazy
+Import-Package: org.eclipse.ui
+Bundle-Vendor: VTT Technical Reserarch Centre of Finland
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>\r
+<!--\r
+ Copyright (c) 2010 Association for Decentralized Information Management in\r
+ Industry THTH ry.\r
+ All rights reserved. This program and the accompanying materials\r
+ are made available under the terms of the Eclipse Public License v1.0\r
+ which accompanies this distribution, and is available at\r
+ http://www.eclipse.org/legal/epl-v10.html\r
+ \r
+ Contributors:\r
+ VTT Technical Research Centre of Finland - initial API and implementation\r
+ -->\r
+\r
+<adapters> \r
+ <target\r
+ interface="org.simantics.simulation.model.IModel">\r
+ <type\r
+ uri="http://www.simantics.org/Sysdyn-1.0/SysdynModel"\r
+ class="org.simantics.sysdyn.manager.SysdynModel">\r
+ <this />\r
+ </type>\r
+ </target>\r
+ \r
+ <target interface="org.simantics.db.layer0.variable.Variable">\r
+ <type uri="http://www.simantics.org/Sysdyn-1.0/Configuration"\r
+ class="org.simantics.sysdyn.adapter.ConfigurationVariable" >\r
+ <this />\r
+ </type>\r
+ <type uri="http://www.simantics.org/Simulation-1.0/Run"\r
+ class="org.simantics.sysdyn.adapter.RunVariable" >\r
+ <this />\r
+ </type>\r
+ </target>\r
+ \r
+ <target interface="org.simantics.db.layer0.variable.Variable">\r
+ <adapter uri="http://www.simantics.org/Sysdyn-1.0/Variable"\r
+ contextClass="org.simantics.db.layer0.variable.Variable"\r
+ adapterClass="org.simantics.sysdyn.adapter.ChildVariableAdapter"/>\r
+ <adapter uri="http://www.simantics.org/Sysdyn-1.0/Module"\r
+ contextClass="org.simantics.db.layer0.variable.Variable"\r
+ adapterClass="org.simantics.sysdyn.adapter.ChildVariableAdapter"/>\r
+ \r
+ </target>\r
+ \r
+</adapters>
\ No newline at end of file
--- /dev/null
+###############################################################################\r
+# Copyright (c) 2010 Association for Decentralized Information Management in\r
+# Industry THTH ry.\r
+# All rights reserved. This program and the accompanying materials\r
+# are made available under the terms of the Eclipse Public License v1.0\r
+# which accompanies this distribution, and is available at\r
+# http://www.eclipse.org/legal/epl-v10.html\r
+#\r
+# Contributors:\r
+# VTT Technical Research Centre of Finland - initial API and implementation\r
+###############################################################################\r
+source.. = src/\r
+output.. = bin/\r
+bin.includes = META-INF/,\\r
+ .,\\r
+ adapters.xml\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2010 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn;\r
+\r
+import java.io.File;\r
+\r
+import org.osgi.framework.BundleActivator;\r
+import org.osgi.framework.BundleContext;\r
+\r
+public class Activator implements BundleActivator {\r
+\r
+ private static BundleContext bundleContext;\r
+ \r
+ @Override\r
+ public void start(BundleContext context) throws Exception {\r
+ bundleContext = context;\r
+ File modelsDir = Activator.getBundleContext().getDataFile("models");\r
+ if (!modelsDir.exists()) {\r
+ modelsDir.mkdir();\r
+ }\r
+ }\r
+\r
+ @Override\r
+ public void stop(BundleContext context) throws Exception {\r
+ File modelsDir = Activator.getBundleContext().getDataFile("models");\r
+ if (modelsDir.exists()) {\r
+ recursiveDelete(modelsDir);\r
+ }\r
+ }\r
+\r
+ public static BundleContext getBundleContext() {\r
+ return bundleContext;\r
+ }\r
+ \r
+ private static boolean recursiveDelete(File fileOrDir) {\r
+ if(fileOrDir.isDirectory())\r
+ for(File innerFile: fileOrDir.listFiles())\r
+ if(!recursiveDelete(innerFile))\r
+ return false;\r
+ return fileOrDir.delete();\r
+ }\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2011 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.adapter;\r
+\r
+import java.util.List;\r
+\r
+import org.simantics.databoard.Bindings;\r
+import org.simantics.databoard.Datatypes;\r
+import org.simantics.databoard.binding.Binding;\r
+import org.simantics.databoard.type.Datatype;\r
+import org.simantics.databoard.util.ObjectUtils;\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.WriteGraph;\r
+import org.simantics.db.common.utils.OrderedSetUtils;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.db.layer0.variable.AbstractChildVariable;\r
+import org.simantics.db.layer0.variable.Variable;\r
+import org.simantics.layer0.Layer0;\r
+import org.simantics.sysdyn.SysdynResource;\r
+\r
+public class ChildVariable extends AbstractChildVariable {\r
+\r
+ protected Variable parent;\r
+ protected Resource resource;\r
+ \r
+ public ChildVariable(Variable parent, Resource resource) {\r
+ this.parent = parent;\r
+ this.resource = resource;\r
+ }\r
+ \r
+ // FIXME: Support properties! This is just for the system to work like it used to. \r
+ @Override\r
+ public <T> T getValue(ReadGraph graph) throws DatabaseException {\r
+ SysdynResource sr = SysdynResource.getInstance(graph);\r
+ if(this.resource == null) return null;\r
+ //FIXME: doesn't support multiple expressions\r
+ Resource expressions = graph.getPossibleObject(this.resource, sr.HasExpressions);\r
+ if(expressions == null) return null;\r
+ List<Resource> expressionList = OrderedSetUtils.toList(graph, expressions);\r
+ Resource expression = expressionList.get(0);\r
+ if(expression == null) return null;\r
+ if(!graph.isInstanceOf(expression, sr.ParameterExpression)) return null;\r
+ String text = graph.getPossibleRelatedValue(expression, sr.HasEquation);\r
+ if(text == null) return null;\r
+ Double value = Double.parseDouble(text); \r
+ return (T)value;\r
+ }\r
+ \r
+ // FIXME: Support properties! This is just for the system to work like it used to. \r
+ @Override\r
+ public void setValue(WriteGraph graph, Object object, Binding binding) throws DatabaseException {\r
+ SysdynResource sr = SysdynResource.getInstance(graph);\r
+ if(this.resource == null) return;\r
+ //FIXME: doesn't support multiple expressions\r
+ Resource expressions = graph.getPossibleObject(this.resource, sr.HasExpressions);\r
+ if(expressions == null) return;\r
+ List<Resource> expressionList = OrderedSetUtils.toList(graph, expressions);\r
+ Resource expression = expressionList.get(0);\r
+ if(expression == null) return;\r
+ if(!graph.isInstanceOf(expression, sr.ParameterExpression)) return;\r
+ graph.claimLiteral(expression, sr.HasEquation, object.toString(), Bindings.STRING);\r
+ }\r
+ \r
+ // FIXME: Support properties! This is just for the system to work like it used to. \r
+ @Override\r
+ public <T> T getInterface(ReadGraph graph, Class<T> clazz) throws DatabaseException {\r
+ if(Datatype.class.equals(clazz)) {\r
+ return (T)Datatypes.DOUBLE;\r
+ }\r
+ return super.getInterface(graph, clazz);\r
+ }\r
+ \r
+ /*\r
+ * \r
+ * \r
+ */\r
+ \r
+ \r
+ @Override\r
+ public Variable getParent(ReadGraph graph) throws DatabaseException {\r
+ if(parent == null)\r
+ return null; // TODO is this correct thing to do?\r
+ else\r
+ return parent; \r
+ }\r
+ \r
+ @Override\r
+ public Resource getRepresents(ReadGraph graph) throws DatabaseException {\r
+ Layer0 L0 = Layer0.getInstance(graph);\r
+ Resource represents = graph.getPossibleObject(resource, L0.Represents);\r
+ if(represents != null) return represents;\r
+ else return resource;\r
+ }\r
+ \r
+ @Override\r
+ public String getName(ReadGraph graph) throws DatabaseException {\r
+ return graph.getRelatedValue(resource, graph.getService(Layer0.class).HasName, Bindings.STRING);\r
+ }\r
+ \r
+ \r
+ @Override\r
+ public String getSerialized(ReadGraph graph) throws DatabaseException {\r
+ return getURI(graph);\r
+ }\r
+ \r
+ @Override\r
+ public String getURI(ReadGraph graph) throws DatabaseException {\r
+ if(parent == null)\r
+ return getName(graph);\r
+ else\r
+ return parent.getURI(graph) + "/" + encodeString(getName(graph));\r
+ }\r
+ \r
+ \r
+ @Override\r
+ public int hashCode() {\r
+ final int prime = 31;\r
+ int result = 1;\r
+ result = prime * result + resource.hashCode();\r
+ result = prime * result + ObjectUtils.hashCode(parent);\r
+ return result;\r
+ }\r
+\r
+ @Override\r
+ public boolean equals(Object obj) {\r
+ if (this == obj)\r
+ return true;\r
+ if (obj == null)\r
+ return false;\r
+ if (getClass() != obj.getClass())\r
+ return false;\r
+ ChildVariable other = (ChildVariable) obj;\r
+ if (!resource.equals(other.resource))\r
+ return false;\r
+ return ObjectUtils.objectEquals(parent, other.parent);\r
+ }\r
+ \r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2011 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.adapter;\r
+\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.common.adaption.SimpleContextualAdapter;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.db.layer0.variable.Variable;\r
+import org.simantics.sysdyn.SysdynResource;\r
+\r
+public class ChildVariableAdapter extends SimpleContextualAdapter<Variable, Variable>{\r
+\r
+ @Override\r
+ public Variable adapt(ReadGraph g, Resource source, Variable context) throws DatabaseException {\r
+ if(context instanceof HistoryVariable) {\r
+ return new HistoryVariable(context, source);\r
+ } else {\r
+ if(g.isInstanceOf(source, SysdynResource.getInstance(g).Module))\r
+ return new ModuleVariable(context, source); \r
+ else \r
+ return new ChildVariable(context, source);\r
+ }\r
+ }\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2011 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.adapter;\r
+\r
+import java.util.ArrayList;\r
+import java.util.Collection;\r
+import java.util.Map;\r
+\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.common.uri.UnescapedChildMapOfResource;\r
+import org.simantics.db.exception.AdaptionException;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.db.layer0.variable.StandardGraphChildVariable;\r
+import org.simantics.db.layer0.variable.Variable;\r
+\r
+public class ConfigurationVariable extends StandardGraphChildVariable {\r
+\r
+ public ConfigurationVariable(Resource resource) {\r
+ super(resource);\r
+ }\r
+\r
+ @Override\r
+ public Variable getPossibleChild(ReadGraph graph, String name) throws DatabaseException {\r
+ Map<String, Resource> children = graph.syncRequest(new UnescapedChildMapOfResource(resource));\r
+ Resource child = children.get(name);\r
+ if(child == null) {\r
+ return getPossibleSpecialChild(graph, name);\r
+ }\r
+ else return graph.adaptContextual(child, this, Variable.class, Variable.class);\r
+ }\r
+\r
+\r
+ @Override\r
+ public Collection<Variable> browseChildren(ReadGraph graph) throws DatabaseException {\r
+ ArrayList<Variable> result = new ArrayList<Variable>();\r
+ for(Resource child : graph.syncRequest(new UnescapedChildMapOfResource(resource)).values()) {\r
+ try {\r
+ result.add(graph.adaptContextual(child, this, Variable.class, Variable.class));\r
+ } catch (AdaptionException e) {\r
+ }\r
+ }\r
+ collectSpecialChildren(graph, result);\r
+ return result;\r
+ }\r
+ \r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2011 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.adapter;\r
+\r
+import java.util.ArrayList;\r
+import java.util.Collection;\r
+import java.util.Map;\r
+\r
+import org.simantics.databoard.Accessors;\r
+import org.simantics.databoard.Bindings;\r
+import org.simantics.databoard.accessor.Accessor;\r
+import org.simantics.databoard.accessor.RecordAccessor;\r
+import org.simantics.databoard.accessor.error.AccessorConstructionException;\r
+import org.simantics.databoard.accessor.error.AccessorException;\r
+import org.simantics.databoard.binding.error.RuntimeBindingConstructionException;\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.common.uri.UnescapedChildMapOfResource;\r
+import org.simantics.db.common.utils.NameUtils;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.db.layer0.exception.MissingVariableException;\r
+import org.simantics.db.layer0.variable.Variable;\r
+import org.simantics.db.layer0.variable.Variables;\r
+import org.simantics.layer0.Layer0;\r
+import org.simantics.simulation.ontology.SimulationResource;\r
+import org.simantics.structural.stubs.StructuralResource2;\r
+import org.simantics.sysdyn.SysdynResource;\r
+import org.simantics.sysdyn.manager.SysdynDataSet;\r
+import org.simantics.sysdyn.manager.SysdynModel;\r
+import org.simantics.sysdyn.manager.SysdynModelManager;\r
+import org.simantics.sysdyn.manager.SysdynResult;\r
+\r
+public class HistoryVariable extends ChildVariable {\r
+\r
+ public HistoryVariable(Variable parent, Resource resource) {\r
+ super(parent, resource);\r
+ }\r
+ \r
+ \r
+ @SuppressWarnings("unchecked")\r
+ @Override\r
+ public <T> T getInterface(ReadGraph graph, Class<T> clazz) throws DatabaseException {\r
+ if(RecordAccessor.class.equals(clazz) || Accessor.class.equals(clazz)) {\r
+ SimulationResource SIMU = SimulationResource.getInstance(graph);\r
+ Resource model = Variables.getModel(graph, this);\r
+ Resource configuration = graph.getPossibleObject(model, SIMU.HasConfiguration);\r
+ final SysdynModel sm = SysdynModelManager.getInstance(graph.getSession()).getModel(graph, configuration);\r
+ SysdynResult sr = new SysdynResult(sm.getSimulationResult()); // TODO: copy or not to copy ...\r
+ \r
+ String tmp = Variables.getRVI(graph, this);\r
+ System.out.println("HistoryVariable rvi='" + tmp + "'");\r
+ final String rvi = tmp.substring(1).replace("/", ".");\r
+ SysdynDataSet ds = sr.getDataSet(rvi);\r
+ if(ds == null) ds = new SysdynDataSet("", "", new ArrayList<Double>(), new ArrayList<Double>()); // We need a dataset, so if not set, create it\r
+ try {\r
+ final RecordAccessor ac = (RecordAccessor)Accessors.getAccessor(Bindings.getBindingUnchecked(SysdynDataSet.class), ds);\r
+ \r
+ sm.addResultListener(new Runnable() { // FIXME: remove listener at some point..\r
+ @Override\r
+ public void run() {\r
+ SysdynResult sr = new SysdynResult(sm.getSimulationResult());\r
+ SysdynDataSet ds = sr.getDataSet(rvi);\r
+ if(ds == null) return;\r
+ try {\r
+ if(ds.result == null) ds.result = "";\r
+ ac.setValue(Bindings.getBindingUnchecked(SysdynDataSet.class), ds);\r
+ } catch (RuntimeBindingConstructionException e) {\r
+ // TODO Auto-generated catch block\r
+ e.printStackTrace();\r
+ } catch (AccessorException e) {\r
+ // TODO Auto-generated catch block\r
+ e.printStackTrace();\r
+ }\r
+ }});\r
+ return (T)ac;\r
+ } catch (RuntimeBindingConstructionException e) {\r
+ e.printStackTrace();\r
+ } catch (AccessorConstructionException e) {\r
+ e.printStackTrace();\r
+ }\r
+ return null;\r
+ \r
+ }\r
+ return super.getInterface(graph, clazz);\r
+ }\r
+ \r
+ \r
+ @Override\r
+ public Variable getChild(ReadGraph graph, String name) throws DatabaseException {\r
+ SysdynResource sr = SysdynResource.getInstance(graph);\r
+ Layer0 l0 = Layer0.getInstance(graph);\r
+ Resource instanceOf = graph.getSingleObject(this.resource, l0.InstanceOf);\r
+ if(graph.isInheritedFrom(instanceOf, sr.Module)) {\r
+ StructuralResource2 sr2 = StructuralResource2.getInstance(graph);\r
+ if(instanceOf == null)\r
+ throw new MissingVariableException("No instanceof for resource " + NameUtils.getSafeName(graph, resource));\r
+ Resource configuration = graph.getPossibleObject(instanceOf, sr2.IsDefinedBy);\r
+ if(configuration == null)\r
+ throw new MissingVariableException("No configuration for " + NameUtils.getSafeName(graph, instanceOf));\r
+ Map<String, Resource> children = graph.syncRequest(new UnescapedChildMapOfResource(configuration));\r
+ Resource child = children.get(name);\r
+ return graph.adaptContextual(child, this, Variable.class, Variable.class);\r
+ } else {\r
+ return super.getChild(graph, name);\r
+ }\r
+ }\r
+\r
+\r
+ @Override\r
+ public Collection<Variable> browseChildren(ReadGraph graph) throws DatabaseException {\r
+ SysdynResource sr = SysdynResource.getInstance(graph);\r
+ StructuralResource2 sr2 = StructuralResource2.getInstance(graph);\r
+ Layer0 l0 = Layer0.getInstance(graph);\r
+ Resource instanceOf = graph.getPossibleObject(this.resource, l0.InstanceOf);\r
+ if(graph.isInheritedFrom(instanceOf, sr.Module)) {\r
+ ArrayList<Variable> result = new ArrayList<Variable>();\r
+ if(instanceOf == null)\r
+ return result;\r
+ Resource configuration = graph.getPossibleObject(instanceOf, sr2.IsDefinedBy);\r
+ if(configuration == null)\r
+ return result;\r
+\r
+ for(Resource child : graph.syncRequest(new UnescapedChildMapOfResource(configuration)).values())\r
+ result.add(graph.adaptContextual(child, this, Variable.class, Variable.class));\r
+ return result;\r
+ } else {\r
+ return super.browseChildren(graph);\r
+ }\r
+ } \r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2011 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.adapter;\r
+\r
+import java.util.ArrayList;\r
+import java.util.Collection;\r
+import java.util.Map;\r
+\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.common.uri.UnescapedChildMapOfResource;\r
+import org.simantics.db.common.utils.NameUtils;\r
+import org.simantics.db.exception.AdaptionException;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.db.layer0.exception.MissingVariableException;\r
+import org.simantics.db.layer0.variable.Variable;\r
+import org.simantics.layer0.Layer0;\r
+import org.simantics.structural.stubs.StructuralResource2;\r
+\r
+public class ModuleVariable extends ChildVariable {\r
+\r
+ public ModuleVariable(Variable parent, Resource resource) {\r
+ super(parent, resource);\r
+ }\r
+\r
+ @Override\r
+ public Variable getPossibleChild(ReadGraph graph, String name) throws DatabaseException {\r
+ Layer0 l0 = Layer0.getInstance(graph);\r
+ StructuralResource2 sr2 = StructuralResource2.getInstance(graph);\r
+ Resource instanceOf = graph.getPossibleObject(this.resource, l0.InstanceOf);\r
+ if(instanceOf == null)\r
+ throw new MissingVariableException("No instanceof for resource " + NameUtils.getSafeName(graph, resource));\r
+ Resource configuration = graph.getPossibleObject(instanceOf, sr2.IsDefinedBy);\r
+ if(configuration == null)\r
+ throw new MissingVariableException("No configuration for " + NameUtils.getSafeName(graph, instanceOf));\r
+ Map<String, Resource> children = graph.syncRequest(new UnescapedChildMapOfResource(configuration));\r
+ Resource child = children.get(name);\r
+ return graph.adaptContextual(child, this, Variable.class, Variable.class);\r
+ }\r
+\r
+\r
+ @Override\r
+ public Collection<Variable> browseChildren(ReadGraph graph) throws DatabaseException {\r
+ StructuralResource2 sr2 = StructuralResource2.getInstance(graph);\r
+ Layer0 l0 = Layer0.getInstance(graph);\r
+ ArrayList<Variable> result = new ArrayList<Variable>();\r
+ \r
+ Resource instanceOf = graph.getPossibleObject(this.resource, l0.InstanceOf);\r
+ if(instanceOf == null)\r
+ return result;\r
+ Resource configuration = graph.getPossibleObject(instanceOf, sr2.IsDefinedBy);\r
+ if(configuration == null)\r
+ return result;\r
+ \r
+ for(Resource child : graph.syncRequest(new UnescapedChildMapOfResource(configuration)).values()) {\r
+ try {\r
+ result.add(graph.adaptContextual(child, this, Variable.class, Variable.class));\r
+ } catch (AdaptionException e) {\r
+ }\r
+ }\r
+ \r
+ return result;\r
+ }\r
+ \r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2011 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.adapter;\r
+\r
+import java.util.ArrayList;\r
+import java.util.Collection;\r
+import java.util.Map;\r
+\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.common.uri.UnescapedChildMapOfResource;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.db.layer0.variable.StandardGraphChildVariable;\r
+import org.simantics.db.layer0.variable.Variable;\r
+import org.simantics.layer0.Layer0;\r
+\r
+public class RunVariable extends StandardGraphChildVariable {\r
+\r
+ public RunVariable(Resource resource) {\r
+ super(resource);\r
+ }\r
+\r
+ @Override\r
+ public Variable getPossibleChild(ReadGraph graph, String name) throws DatabaseException {\r
+ Resource config = getConfiguration(graph);\r
+ Map<String, Resource> children = graph.syncRequest(new UnescapedChildMapOfResource(config));\r
+ Resource child = children.get(name);\r
+ if(child == null) {\r
+ return getPossibleSpecialChild(graph, name);\r
+ }\r
+ else return new HistoryVariable(this, child);\r
+ }\r
+\r
+\r
+ @Override\r
+ public Collection<Variable> browseChildren(ReadGraph graph) throws DatabaseException {\r
+ ArrayList<Variable> result = new ArrayList<Variable>();\r
+ Resource config = getConfiguration(graph);\r
+ for(Resource child : graph.syncRequest(new UnescapedChildMapOfResource(config)).values())\r
+ result.add(new HistoryVariable(this, child));\r
+ collectSpecialChildren(graph, result);\r
+ return result;\r
+ }\r
+\r
+ Resource getConfiguration(ReadGraph graph) throws DatabaseException {\r
+ Layer0 L0 = Layer0.getInstance(graph);\r
+ Resource experiment = graph.getPossibleObject(resource, L0.PartOf);\r
+ Resource model = graph.getPossibleObject(experiment, L0.PartOf);\r
+ return graph.getPossibleObject(model, L0.HasBaseRealization);\r
+ }\r
+ \r
+}\r
--- /dev/null
+/* Generated By:JavaCC: Do not edit this line. ExpressionParser.java */\r
+package org.simantics.sysdyn.expressionParser;\r
+\r
+import java.util.Set;\r
+import java.util.HashSet;\r
+import java.util.List;\r
+import java.util.ArrayList;\r
+import java.util.HashMap;\r
+\r
+\r
+public class ExpressionParser implements ExpressionParserConstants {\r
+\r
+ public class ForRange {\r
+ public Token start;\r
+ public Token end;\r
+ }\r
+\r
+ boolean forIndex = false;\r
+ Token firstToken;\r
+\r
+ public Token getFirstToken() {\r
+ return firstToken;\r
+ }\r
+\r
+ List<ForRange> forRanges = new ArrayList<ForRange>();\r
+\r
+ public List<ForRange> getForRanges() {\r
+ return forRanges;\r
+ }\r
+\r
+ HashMap<String, List<Token>> references = new HashMap<String, List<Token>>();\r
+\r
+ public HashMap<String, List<Token>> getReferences() {\r
+ return references;\r
+ }\r
+\r
+ HashMap<String, List<List<Token>>> ranges = new HashMap<String, List<List<Token>>>();\r
+\r
+ public HashMap<String, List<List<Token>>> getRanges() {\r
+ return ranges;\r
+ }\r
+\r
+ List<Token> currentRange = null;\r
+\r
+ HashMap<Token, List<Token>> forIndices = new HashMap<Token, List<Token>>();\r
+\r
+ public HashMap<Token, List<Token>> getForIndices() {\r
+ return forIndices;\r
+ }\r
+\r
+ HashMap<String, List<Token>> enumerationReferences = new HashMap<String, List<Token>>();\r
+\r
+ public HashMap<String, List<Token>> getEnumerationReferences() {\r
+ return enumerationReferences;\r
+ }\r
+\r
+/*** Parser ********************************************************/\r
+\r
+// https://javacc.dev.java.net/doc/javaccgrm.html\r
+// add_op -> add_op()\r
+// [ add_op ] -> ( add_op() )?\r
+// { add_op term } -> ( add_op() term() )*\r
+ final public void expr() throws ParseException {\r
+ switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {\r
+ case 6:\r
+ case 12:\r
+ case 33:\r
+ case 35:\r
+ case 62:\r
+ case 64:\r
+ case 66:\r
+ case 78:\r
+ case 79:\r
+ case 80:\r
+ case 81:\r
+ case IDENT:\r
+ case STRING:\r
+ case UNSIGNED_INTEGER:\r
+ case UNSIGNED_NUMBER:\r
+ firstToken = token;\r
+ simple_expression();\r
+ jj_consume_token(0);\r
+ break;\r
+ case 31:\r
+ firstToken = token;\r
+ jj_consume_token(31);\r
+ expression();\r
+ jj_consume_token(28);\r
+ expression();\r
+ label_1:\r
+ while (true) {\r
+ switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {\r
+ case 20:\r
+ ;\r
+ break;\r
+ default:\r
+ jj_la1[0] = jj_gen;\r
+ break label_1;\r
+ }\r
+ jj_consume_token(20);\r
+ expression();\r
+ jj_consume_token(28);\r
+ expression();\r
+ }\r
+ jj_consume_token(15);\r
+ expression();\r
+ jj_consume_token(0);\r
+ break;\r
+ default:\r
+ jj_la1[1] = jj_gen;\r
+ jj_consume_token(-1);\r
+ throw new ParseException();\r
+ }\r
+ }\r
+\r
+ final public void expression() throws ParseException {\r
+ switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {\r
+ case 6:\r
+ case 12:\r
+ case 33:\r
+ case 35:\r
+ case 62:\r
+ case 64:\r
+ case 66:\r
+ case 78:\r
+ case 79:\r
+ case 80:\r
+ case 81:\r
+ case IDENT:\r
+ case STRING:\r
+ case UNSIGNED_INTEGER:\r
+ case UNSIGNED_NUMBER:\r
+ simple_expression();\r
+ break;\r
+ case 31:\r
+ jj_consume_token(31);\r
+ expression();\r
+ jj_consume_token(28);\r
+ expression();\r
+ label_2:\r
+ while (true) {\r
+ switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {\r
+ case 20:\r
+ ;\r
+ break;\r
+ default:\r
+ jj_la1[2] = jj_gen;\r
+ break label_2;\r
+ }\r
+ jj_consume_token(20);\r
+ expression();\r
+ jj_consume_token(28);\r
+ expression();\r
+ }\r
+ jj_consume_token(15);\r
+ expression();\r
+ break;\r
+ default:\r
+ jj_la1[3] = jj_gen;\r
+ jj_consume_token(-1);\r
+ throw new ParseException();\r
+ }\r
+ }\r
+\r
+ final public void simple_expression() throws ParseException {\r
+ logical_expression();\r
+ switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {\r
+ case 69:\r
+ jj_consume_token(69);\r
+ logical_expression();\r
+ switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {\r
+ case 69:\r
+ jj_consume_token(69);\r
+ logical_expression();\r
+ break;\r
+ default:\r
+ jj_la1[4] = jj_gen;\r
+ ;\r
+ }\r
+ break;\r
+ default:\r
+ jj_la1[5] = jj_gen;\r
+ ;\r
+ }\r
+ }\r
+\r
+ final public void logical_expression() throws ParseException {\r
+ logical_term();\r
+ label_3:\r
+ while (true) {\r
+ switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {\r
+ case 22:\r
+ ;\r
+ break;\r
+ default:\r
+ jj_la1[6] = jj_gen;\r
+ break label_3;\r
+ }\r
+ jj_consume_token(22);\r
+ logical_term();\r
+ }\r
+ }\r
+\r
+ final public void logical_term() throws ParseException {\r
+ logical_factor();\r
+ label_4:\r
+ while (true) {\r
+ switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {\r
+ case 9:\r
+ ;\r
+ break;\r
+ default:\r
+ jj_la1[7] = jj_gen;\r
+ break label_4;\r
+ }\r
+ jj_consume_token(9);\r
+ logical_factor();\r
+ }\r
+ }\r
+\r
+ final public void logical_factor() throws ParseException {\r
+ switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {\r
+ case 12:\r
+ jj_consume_token(12);\r
+ break;\r
+ default:\r
+ jj_la1[8] = jj_gen;\r
+ ;\r
+ }\r
+ relation();\r
+ }\r
+\r
+ final public void relation() throws ParseException {\r
+ arithmetic_expression();\r
+ switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {\r
+ case 72:\r
+ case 73:\r
+ case 74:\r
+ case 75:\r
+ case 76:\r
+ case 77:\r
+ rel_op();\r
+ arithmetic_expression();\r
+ break;\r
+ default:\r
+ jj_la1[9] = jj_gen;\r
+ ;\r
+ }\r
+ }\r
+\r
+ final public void rel_op() throws ParseException {\r
+ switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {\r
+ case 72:\r
+ jj_consume_token(72);\r
+ break;\r
+ case 73:\r
+ jj_consume_token(73);\r
+ break;\r
+ case 74:\r
+ jj_consume_token(74);\r
+ break;\r
+ case 75:\r
+ jj_consume_token(75);\r
+ break;\r
+ case 76:\r
+ jj_consume_token(76);\r
+ break;\r
+ case 77:\r
+ jj_consume_token(77);\r
+ break;\r
+ default:\r
+ jj_la1[10] = jj_gen;\r
+ jj_consume_token(-1);\r
+ throw new ParseException();\r
+ }\r
+ }\r
+\r
+ final public void arithmetic_expression() throws ParseException {\r
+ switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {\r
+ case 78:\r
+ case 79:\r
+ case 80:\r
+ case 81:\r
+ add_op();\r
+ break;\r
+ default:\r
+ jj_la1[11] = jj_gen;\r
+ ;\r
+ }\r
+ term();\r
+ label_5:\r
+ while (true) {\r
+ switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {\r
+ case 78:\r
+ case 79:\r
+ case 80:\r
+ case 81:\r
+ ;\r
+ break;\r
+ default:\r
+ jj_la1[12] = jj_gen;\r
+ break label_5;\r
+ }\r
+ add_op();\r
+ term();\r
+ }\r
+ }\r
+\r
+ final public void add_op() throws ParseException {\r
+ switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {\r
+ case 78:\r
+ jj_consume_token(78);\r
+ break;\r
+ case 79:\r
+ jj_consume_token(79);\r
+ break;\r
+ case 80:\r
+ jj_consume_token(80);\r
+ break;\r
+ case 81:\r
+ jj_consume_token(81);\r
+ break;\r
+ default:\r
+ jj_la1[13] = jj_gen;\r
+ jj_consume_token(-1);\r
+ throw new ParseException();\r
+ }\r
+ }\r
+\r
+ final public void term() throws ParseException {\r
+ factor();\r
+ label_6:\r
+ while (true) {\r
+ switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {\r
+ case 82:\r
+ case 83:\r
+ case 84:\r
+ case 85:\r
+ ;\r
+ break;\r
+ default:\r
+ jj_la1[14] = jj_gen;\r
+ break label_6;\r
+ }\r
+ mul_op();\r
+ factor();\r
+ }\r
+ }\r
+\r
+ final public void factor() throws ParseException {\r
+ primary();\r
+ switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {\r
+ case 86:\r
+ case 87:\r
+ switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {\r
+ case 86:\r
+ jj_consume_token(86);\r
+ break;\r
+ case 87:\r
+ jj_consume_token(87);\r
+ primary();\r
+ break;\r
+ default:\r
+ jj_la1[15] = jj_gen;\r
+ jj_consume_token(-1);\r
+ throw new ParseException();\r
+ }\r
+ break;\r
+ default:\r
+ jj_la1[16] = jj_gen;\r
+ ;\r
+ }\r
+ }\r
+\r
+ final public void mul_op() throws ParseException {\r
+ switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {\r
+ case 82:\r
+ jj_consume_token(82);\r
+ break;\r
+ case 83:\r
+ jj_consume_token(83);\r
+ break;\r
+ case 84:\r
+ jj_consume_token(84);\r
+ break;\r
+ case 85:\r
+ jj_consume_token(85);\r
+ break;\r
+ default:\r
+ jj_la1[17] = jj_gen;\r
+ jj_consume_token(-1);\r
+ throw new ParseException();\r
+ }\r
+ }\r
+\r
+ final public void primary() throws ParseException {\r
+ switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {\r
+ case UNSIGNED_NUMBER:\r
+ jj_consume_token(UNSIGNED_NUMBER);\r
+ break;\r
+ case UNSIGNED_INTEGER:\r
+ jj_consume_token(UNSIGNED_INTEGER);\r
+ break;\r
+ case STRING:\r
+ jj_consume_token(STRING);\r
+ break;\r
+ case 6:\r
+ jj_consume_token(6);\r
+ break;\r
+ case 33:\r
+ jj_consume_token(33);\r
+ break;\r
+ default:\r
+ jj_la1[19] = jj_gen;\r
+ if (jj_2_1(2147483647)) {\r
+ name();\r
+ function_call_args();\r
+ } else {\r
+ switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {\r
+ case IDENT:\r
+ component_reference(null);\r
+ break;\r
+ case 62:\r
+ jj_consume_token(62);\r
+ output_expression_list();\r
+ jj_consume_token(63);\r
+ break;\r
+ case 66:\r
+ jj_consume_token(66);\r
+ expression_list();\r
+ label_7:\r
+ while (true) {\r
+ switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {\r
+ case 70:\r
+ ;\r
+ break;\r
+ default:\r
+ jj_la1[18] = jj_gen;\r
+ break label_7;\r
+ }\r
+ jj_consume_token(70);\r
+ expression_list();\r
+ }\r
+ jj_consume_token(67);\r
+ break;\r
+ case 64:\r
+ jj_consume_token(64);\r
+ function_arguments();\r
+ jj_consume_token(65);\r
+ break;\r
+ case 35:\r
+ jj_consume_token(35);\r
+ break;\r
+ default:\r
+ jj_la1[20] = jj_gen;\r
+ jj_consume_token(-1);\r
+ throw new ParseException();\r
+ }\r
+ }\r
+ }\r
+ }\r
+\r
+ final public void name() throws ParseException {\r
+ jj_consume_token(IDENT);\r
+ switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {\r
+ case 68:\r
+ jj_consume_token(68);\r
+ name();\r
+ break;\r
+ default:\r
+ jj_la1[21] = jj_gen;\r
+ ;\r
+ }\r
+ }\r
+\r
+ final public void component_reference(Token prevToken) throws ParseException {\r
+ jj_consume_token(IDENT);\r
+ String name = token.image;\r
+\r
+ // prevToken != null => this is the second part of an enumeration\r
+ if(forIndex == true && prevToken != null) {\r
+ if(enumerationReferences.get(prevToken.image) == null) {\r
+ enumerationReferences.put(prevToken.image, new ArrayList<Token>());\r
+ }\r
+ List<Token> list = enumerationReferences.get(prevToken.image);\r
+ list.add(token);\r
+\r
+ // forIndex == true, prevToken == null => this is the enumeration\r
+ } else if(forIndex == true && prevToken == null) {\r
+ if(enumerationReferences.get(token.image) == null) {\r
+ enumerationReferences.put(token.image, new ArrayList<Token>());\r
+ }\r
+ List<Token> list = enumerationReferences.get(token.image);\r
+ list.add(token);\r
+ } else {\r
+ if(references.get(name) == null) {\r
+ references.put(name, new ArrayList<Token>());\r
+ }\r
+ List<Token> list = references.get(name);\r
+ list.add(token);\r
+ }\r
+\r
+ Token curToken = token;\r
+ switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {\r
+ case 66:\r
+ array_subscripts();\r
+ break;\r
+ default:\r
+ jj_la1[22] = jj_gen;\r
+ ;\r
+ }\r
+ switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {\r
+ case 68:\r
+ jj_consume_token(68);\r
+ component_reference(curToken);\r
+ break;\r
+ default:\r
+ jj_la1[23] = jj_gen;\r
+ ;\r
+ }\r
+ }\r
+\r
+ final public void function_call_args() throws ParseException {\r
+ jj_consume_token(62);\r
+ switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {\r
+ case 6:\r
+ case 12:\r
+ case 31:\r
+ case 33:\r
+ case 35:\r
+ case 62:\r
+ case 64:\r
+ case 66:\r
+ case 78:\r
+ case 79:\r
+ case 80:\r
+ case 81:\r
+ case IDENT:\r
+ case STRING:\r
+ case UNSIGNED_INTEGER:\r
+ case UNSIGNED_NUMBER:\r
+ function_arguments();\r
+ break;\r
+ default:\r
+ jj_la1[24] = jj_gen;\r
+ ;\r
+ }\r
+ jj_consume_token(63);\r
+ }\r
+\r
+ final public void function_arguments() throws ParseException {\r
+ if (jj_2_2(2)) {\r
+ expression();\r
+ switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {\r
+ case 21:\r
+ case 71:\r
+ switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {\r
+ case 71:\r
+ jj_consume_token(71);\r
+ function_arguments();\r
+ break;\r
+ case 21:\r
+ jj_consume_token(21);\r
+ for_indices();\r
+ break;\r
+ default:\r
+ jj_la1[25] = jj_gen;\r
+ jj_consume_token(-1);\r
+ throw new ParseException();\r
+ }\r
+ break;\r
+ default:\r
+ jj_la1[26] = jj_gen;\r
+ ;\r
+ }\r
+ } else {\r
+ switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {\r
+ case IDENT:\r
+ named_arguments();\r
+ break;\r
+ default:\r
+ jj_la1[27] = jj_gen;\r
+ jj_consume_token(-1);\r
+ throw new ParseException();\r
+ }\r
+ }\r
+ }\r
+\r
+ final public void for_indices() throws ParseException {\r
+ for_index();\r
+ label_8:\r
+ while (true) {\r
+ switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {\r
+ case 71:\r
+ ;\r
+ break;\r
+ default:\r
+ jj_la1[28] = jj_gen;\r
+ break label_8;\r
+ }\r
+ jj_consume_token(71);\r
+ for_index();\r
+ }\r
+ }\r
+\r
+ final public void for_index() throws ParseException {\r
+ jj_consume_token(IDENT);\r
+ forIndices.put(token, currentRange);\r
+ forIndex = true;\r
+ switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {\r
+ case 41:\r
+ jj_consume_token(41);\r
+ ForRange forRange = new ForRange();\r
+ forRange.start = token;\r
+ expression();\r
+ forRange.start = forRange.start.next;\r
+ forRange.end = token;\r
+ forRanges.add(forRange);\r
+ break;\r
+ default:\r
+ jj_la1[29] = jj_gen;\r
+ ;\r
+ }\r
+ forIndex = false;\r
+ }\r
+\r
+ final public void named_arguments() throws ParseException {\r
+ named_argument();\r
+ switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {\r
+ case 71:\r
+ jj_consume_token(71);\r
+ named_arguments();\r
+ break;\r
+ default:\r
+ jj_la1[30] = jj_gen;\r
+ ;\r
+ }\r
+ }\r
+\r
+ final public void named_argument() throws ParseException {\r
+ jj_consume_token(IDENT);\r
+ jj_consume_token(88);\r
+ expression();\r
+ }\r
+\r
+ final public void output_expression_list() throws ParseException {\r
+ switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {\r
+ case 6:\r
+ case 12:\r
+ case 31:\r
+ case 33:\r
+ case 35:\r
+ case 62:\r
+ case 64:\r
+ case 66:\r
+ case 78:\r
+ case 79:\r
+ case 80:\r
+ case 81:\r
+ case IDENT:\r
+ case STRING:\r
+ case UNSIGNED_INTEGER:\r
+ case UNSIGNED_NUMBER:\r
+ expression();\r
+ break;\r
+ default:\r
+ jj_la1[31] = jj_gen;\r
+ ;\r
+ }\r
+ label_9:\r
+ while (true) {\r
+ switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {\r
+ case 71:\r
+ ;\r
+ break;\r
+ default:\r
+ jj_la1[32] = jj_gen;\r
+ break label_9;\r
+ }\r
+ jj_consume_token(71);\r
+ switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {\r
+ case 6:\r
+ case 12:\r
+ case 31:\r
+ case 33:\r
+ case 35:\r
+ case 62:\r
+ case 64:\r
+ case 66:\r
+ case 78:\r
+ case 79:\r
+ case 80:\r
+ case 81:\r
+ case IDENT:\r
+ case STRING:\r
+ case UNSIGNED_INTEGER:\r
+ case UNSIGNED_NUMBER:\r
+ expression();\r
+ break;\r
+ default:\r
+ jj_la1[33] = jj_gen;\r
+ ;\r
+ }\r
+ }\r
+ }\r
+\r
+ final public void expression_list() throws ParseException {\r
+ expression();\r
+ label_10:\r
+ while (true) {\r
+ switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {\r
+ case 71:\r
+ ;\r
+ break;\r
+ default:\r
+ jj_la1[34] = jj_gen;\r
+ break label_10;\r
+ }\r
+ jj_consume_token(71);\r
+ expression();\r
+ }\r
+ }\r
+\r
+ final public void array_subscripts() throws ParseException {\r
+ if(ranges.get(token.image) == null) {\r
+ ranges.put(token.image, new ArrayList<List<Token>>());\r
+ }\r
+ List<List<Token>> rangesList = ranges.get(token.image);\r
+ currentRange = new ArrayList<Token>();\r
+ jj_consume_token(66);\r
+ subscript(currentRange);\r
+ label_11:\r
+ while (true) {\r
+ switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {\r
+ case 71:\r
+ ;\r
+ break;\r
+ default:\r
+ jj_la1[35] = jj_gen;\r
+ break label_11;\r
+ }\r
+ jj_consume_token(71);\r
+ subscript(currentRange);\r
+ }\r
+ jj_consume_token(67);\r
+ rangesList.add(currentRange);\r
+ }\r
+\r
+ final public void subscript(List<Token> currentRange) throws ParseException {\r
+ Token rangeToken = new Token(token.kind, "");\r
+ rangeToken.beginColumn = token.beginColumn + 1;\r
+ rangeToken.beginLine = token.beginLine;\r
+ switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {\r
+ case 69:\r
+ jj_consume_token(69);\r
+ currentRange.add(token);\r
+ break;\r
+ case IDENT:\r
+ case UNSIGNED_INTEGER:\r
+ rangeIndex(rangeToken, false);\r
+ switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {\r
+ case 69:\r
+ jj_consume_token(69);\r
+ rangeIndex(rangeToken, true);\r
+ break;\r
+ default:\r
+ jj_la1[36] = jj_gen;\r
+ ;\r
+ }\r
+ rangeToken.endColumn = token.endColumn;\r
+ rangeToken.endLine = token.endLine;\r
+ currentRange.add(rangeToken);\r
+ break;\r
+ default:\r
+ jj_la1[37] = jj_gen;\r
+ jj_consume_token(-1);\r
+ throw new ParseException();\r
+ }\r
+ }\r
+\r
+ final public void rangeIndex(Token rangeToken, boolean second) throws ParseException {\r
+ if(second)\r
+ rangeToken.image = rangeToken.image + ":";\r
+ switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {\r
+ case UNSIGNED_INTEGER:\r
+ jj_consume_token(UNSIGNED_INTEGER);\r
+ rangeToken.image = rangeToken.image + token.image;\r
+ break;\r
+ case IDENT:\r
+ jj_consume_token(IDENT);\r
+ rangeToken.image = rangeToken.image + token.image;\r
+ break;\r
+ default:\r
+ jj_la1[38] = jj_gen;\r
+ jj_consume_token(-1);\r
+ throw new ParseException();\r
+ }\r
+ }\r
+\r
+ private boolean jj_2_1(int xla) {\r
+ jj_la = xla; jj_lastpos = jj_scanpos = token;\r
+ try { return !jj_3_1(); }\r
+ catch(LookaheadSuccess ls) { return true; }\r
+ finally { jj_save(0, xla); }\r
+ }\r
+\r
+ private boolean jj_2_2(int xla) {\r
+ jj_la = xla; jj_lastpos = jj_scanpos = token;\r
+ try { return !jj_3_2(); }\r
+ catch(LookaheadSuccess ls) { return true; }\r
+ finally { jj_save(1, xla); }\r
+ }\r
+\r
+ private boolean jj_3R_35() {\r
+ if (jj_3R_37()) return true;\r
+ Token xsp;\r
+ xsp = jj_scanpos;\r
+ if (jj_3R_38()) jj_scanpos = xsp;\r
+ return false;\r
+ }\r
+\r
+ private boolean jj_3R_52() {\r
+ if (jj_scan_token(68)) return true;\r
+ return false;\r
+ }\r
+\r
+ private boolean jj_3R_31() {\r
+ if (jj_3R_35()) return true;\r
+ Token xsp;\r
+ while (true) {\r
+ xsp = jj_scanpos;\r
+ if (jj_3R_36()) { jj_scanpos = xsp; break; }\r
+ }\r
+ return false;\r
+ }\r
+\r
+ private boolean jj_3R_34() {\r
+ Token xsp;\r
+ xsp = jj_scanpos;\r
+ if (jj_scan_token(78)) {\r
+ jj_scanpos = xsp;\r
+ if (jj_scan_token(79)) {\r
+ jj_scanpos = xsp;\r
+ if (jj_scan_token(80)) {\r
+ jj_scanpos = xsp;\r
+ if (jj_scan_token(81)) return true;\r
+ }\r
+ }\r
+ }\r
+ return false;\r
+ }\r
+\r
+ private boolean jj_3R_26() {\r
+ if (jj_scan_token(9)) return true;\r
+ return false;\r
+ }\r
+\r
+ private boolean jj_3R_30() {\r
+ if (jj_3R_34()) return true;\r
+ return false;\r
+ }\r
+\r
+ private boolean jj_3R_55() {\r
+ if (jj_3R_57()) return true;\r
+ return false;\r
+ }\r
+\r
+ private boolean jj_3R_28() {\r
+ Token xsp;\r
+ xsp = jj_scanpos;\r
+ if (jj_3R_30()) jj_scanpos = xsp;\r
+ if (jj_3R_31()) return true;\r
+ while (true) {\r
+ xsp = jj_scanpos;\r
+ if (jj_3R_32()) { jj_scanpos = xsp; break; }\r
+ }\r
+ return false;\r
+ }\r
+\r
+ private boolean jj_3R_33() {\r
+ Token xsp;\r
+ xsp = jj_scanpos;\r
+ if (jj_scan_token(72)) {\r
+ jj_scanpos = xsp;\r
+ if (jj_scan_token(73)) {\r
+ jj_scanpos = xsp;\r
+ if (jj_scan_token(74)) {\r
+ jj_scanpos = xsp;\r
+ if (jj_scan_token(75)) {\r
+ jj_scanpos = xsp;\r
+ if (jj_scan_token(76)) {\r
+ jj_scanpos = xsp;\r
+ if (jj_scan_token(77)) return true;\r
+ }\r
+ }\r
+ }\r
+ }\r
+ }\r
+ return false;\r
+ }\r
+\r
+ private boolean jj_3R_50() {\r
+ Token xsp;\r
+ xsp = jj_scanpos;\r
+ if (jj_3_2()) {\r
+ jj_scanpos = xsp;\r
+ if (jj_3R_55()) return true;\r
+ }\r
+ return false;\r
+ }\r
+\r
+ private boolean jj_3_2() {\r
+ if (jj_3R_13()) return true;\r
+ Token xsp;\r
+ xsp = jj_scanpos;\r
+ if (jj_3R_14()) jj_scanpos = xsp;\r
+ return false;\r
+ }\r
+\r
+ private boolean jj_3R_22() {\r
+ if (jj_scan_token(69)) return true;\r
+ return false;\r
+ }\r
+\r
+ private boolean jj_3R_24() {\r
+ if (jj_scan_token(22)) return true;\r
+ return false;\r
+ }\r
+\r
+ private boolean jj_3R_27() {\r
+ if (jj_3R_28()) return true;\r
+ Token xsp;\r
+ xsp = jj_scanpos;\r
+ if (jj_3R_29()) jj_scanpos = xsp;\r
+ return false;\r
+ }\r
+\r
+ private boolean jj_3R_46() {\r
+ if (jj_scan_token(62)) return true;\r
+ return false;\r
+ }\r
+\r
+ private boolean jj_3R_25() {\r
+ Token xsp;\r
+ xsp = jj_scanpos;\r
+ if (jj_scan_token(12)) jj_scanpos = xsp;\r
+ if (jj_3R_27()) return true;\r
+ return false;\r
+ }\r
+\r
+ private boolean jj_3R_51() {\r
+ if (jj_3R_56()) return true;\r
+ return false;\r
+ }\r
+\r
+ private boolean jj_3R_23() {\r
+ if (jj_3R_25()) return true;\r
+ Token xsp;\r
+ while (true) {\r
+ xsp = jj_scanpos;\r
+ if (jj_3R_26()) { jj_scanpos = xsp; break; }\r
+ }\r
+ return false;\r
+ }\r
+\r
+ private boolean jj_3R_21() {\r
+ if (jj_3R_23()) return true;\r
+ Token xsp;\r
+ while (true) {\r
+ xsp = jj_scanpos;\r
+ if (jj_3R_24()) { jj_scanpos = xsp; break; }\r
+ }\r
+ return false;\r
+ }\r
+\r
+ private boolean jj_3R_20() {\r
+ if (jj_3R_21()) return true;\r
+ Token xsp;\r
+ xsp = jj_scanpos;\r
+ if (jj_3R_22()) jj_scanpos = xsp;\r
+ return false;\r
+ }\r
+\r
+ private boolean jj_3R_17() {\r
+ if (jj_scan_token(31)) return true;\r
+ if (jj_3R_13()) return true;\r
+ return false;\r
+ }\r
+\r
+ private boolean jj_3R_54() {\r
+ if (jj_scan_token(71)) return true;\r
+ return false;\r
+ }\r
+\r
+ private boolean jj_3R_13() {\r
+ Token xsp;\r
+ xsp = jj_scanpos;\r
+ if (jj_3R_16()) {\r
+ jj_scanpos = xsp;\r
+ if (jj_3R_17()) return true;\r
+ }\r
+ return false;\r
+ }\r
+\r
+ private boolean jj_3R_16() {\r
+ if (jj_3R_20()) return true;\r
+ return false;\r
+ }\r
+\r
+ private boolean jj_3R_56() {\r
+ if (jj_scan_token(66)) return true;\r
+ return false;\r
+ }\r
+\r
+ private boolean jj_3R_15() {\r
+ if (jj_scan_token(68)) return true;\r
+ if (jj_3R_12()) return true;\r
+ return false;\r
+ }\r
+\r
+ private boolean jj_3R_19() {\r
+ if (jj_scan_token(21)) return true;\r
+ return false;\r
+ }\r
+\r
+ private boolean jj_3R_47() {\r
+ if (jj_scan_token(IDENT)) return true;\r
+ Token xsp;\r
+ xsp = jj_scanpos;\r
+ if (jj_3R_51()) jj_scanpos = xsp;\r
+ xsp = jj_scanpos;\r
+ if (jj_3R_52()) jj_scanpos = xsp;\r
+ return false;\r
+ }\r
+\r
+ private boolean jj_3R_53() {\r
+ if (jj_3R_13()) return true;\r
+ return false;\r
+ }\r
+\r
+ private boolean jj_3R_49() {\r
+ if (jj_3R_13()) return true;\r
+ return false;\r
+ }\r
+\r
+ private boolean jj_3R_48() {\r
+ Token xsp;\r
+ xsp = jj_scanpos;\r
+ if (jj_3R_53()) jj_scanpos = xsp;\r
+ while (true) {\r
+ xsp = jj_scanpos;\r
+ if (jj_3R_54()) { jj_scanpos = xsp; break; }\r
+ }\r
+ return false;\r
+ }\r
+\r
+ private boolean jj_3R_12() {\r
+ if (jj_scan_token(IDENT)) return true;\r
+ Token xsp;\r
+ xsp = jj_scanpos;\r
+ if (jj_3R_15()) jj_scanpos = xsp;\r
+ return false;\r
+ }\r
+\r
+ private boolean jj_3_1() {\r
+ if (jj_3R_12()) return true;\r
+ if (jj_scan_token(62)) return true;\r
+ return false;\r
+ }\r
+\r
+ private boolean jj_3R_58() {\r
+ if (jj_scan_token(IDENT)) return true;\r
+ return false;\r
+ }\r
+\r
+ private boolean jj_3R_45() {\r
+ if (jj_scan_token(87)) return true;\r
+ return false;\r
+ }\r
+\r
+ private boolean jj_3R_57() {\r
+ if (jj_3R_58()) return true;\r
+ return false;\r
+ }\r
+\r
+ private boolean jj_3R_44() {\r
+ if (jj_scan_token(64)) return true;\r
+ if (jj_3R_50()) return true;\r
+ return false;\r
+ }\r
+\r
+ private boolean jj_3R_43() {\r
+ if (jj_scan_token(66)) return true;\r
+ if (jj_3R_49()) return true;\r
+ return false;\r
+ }\r
+\r
+ private boolean jj_3R_40() {\r
+ if (jj_3R_12()) return true;\r
+ if (jj_3R_46()) return true;\r
+ return false;\r
+ }\r
+\r
+ private boolean jj_3R_42() {\r
+ if (jj_scan_token(62)) return true;\r
+ if (jj_3R_48()) return true;\r
+ if (jj_scan_token(63)) return true;\r
+ return false;\r
+ }\r
+\r
+ private boolean jj_3R_38() {\r
+ Token xsp;\r
+ xsp = jj_scanpos;\r
+ if (jj_scan_token(86)) {\r
+ jj_scanpos = xsp;\r
+ if (jj_3R_45()) return true;\r
+ }\r
+ return false;\r
+ }\r
+\r
+ private boolean jj_3R_41() {\r
+ if (jj_3R_47()) return true;\r
+ return false;\r
+ }\r
+\r
+ private boolean jj_3R_37() {\r
+ Token xsp;\r
+ xsp = jj_scanpos;\r
+ if (jj_scan_token(93)) {\r
+ jj_scanpos = xsp;\r
+ if (jj_scan_token(92)) {\r
+ jj_scanpos = xsp;\r
+ if (jj_scan_token(91)) {\r
+ jj_scanpos = xsp;\r
+ if (jj_scan_token(6)) {\r
+ jj_scanpos = xsp;\r
+ if (jj_scan_token(33)) {\r
+ jj_scanpos = xsp;\r
+ if (jj_3R_40()) {\r
+ jj_scanpos = xsp;\r
+ if (jj_3R_41()) {\r
+ jj_scanpos = xsp;\r
+ if (jj_3R_42()) {\r
+ jj_scanpos = xsp;\r
+ if (jj_3R_43()) {\r
+ jj_scanpos = xsp;\r
+ if (jj_3R_44()) {\r
+ jj_scanpos = xsp;\r
+ if (jj_scan_token(35)) return true;\r
+ }\r
+ }\r
+ }\r
+ }\r
+ }\r
+ }\r
+ }\r
+ }\r
+ }\r
+ }\r
+ return false;\r
+ }\r
+\r
+ private boolean jj_3R_18() {\r
+ if (jj_scan_token(71)) return true;\r
+ return false;\r
+ }\r
+\r
+ private boolean jj_3R_14() {\r
+ Token xsp;\r
+ xsp = jj_scanpos;\r
+ if (jj_3R_18()) {\r
+ jj_scanpos = xsp;\r
+ if (jj_3R_19()) return true;\r
+ }\r
+ return false;\r
+ }\r
+\r
+ private boolean jj_3R_36() {\r
+ if (jj_3R_39()) return true;\r
+ return false;\r
+ }\r
+\r
+ private boolean jj_3R_29() {\r
+ if (jj_3R_33()) return true;\r
+ return false;\r
+ }\r
+\r
+ private boolean jj_3R_32() {\r
+ if (jj_3R_34()) return true;\r
+ return false;\r
+ }\r
+\r
+ private boolean jj_3R_39() {\r
+ Token xsp;\r
+ xsp = jj_scanpos;\r
+ if (jj_scan_token(82)) {\r
+ jj_scanpos = xsp;\r
+ if (jj_scan_token(83)) {\r
+ jj_scanpos = xsp;\r
+ if (jj_scan_token(84)) {\r
+ jj_scanpos = xsp;\r
+ if (jj_scan_token(85)) return true;\r
+ }\r
+ }\r
+ }\r
+ return false;\r
+ }\r
+\r
+ /** Generated Token Manager. */\r
+ public ExpressionParserTokenManager token_source;\r
+ SimpleCharStream jj_input_stream;\r
+ /** Current token. */\r
+ public Token token;\r
+ /** Next token. */\r
+ public Token jj_nt;\r
+ private int jj_ntk;\r
+ private Token jj_scanpos, jj_lastpos;\r
+ private int jj_la;\r
+ private int jj_gen;\r
+ final private int[] jj_la1 = new int[39];\r
+ static private int[] jj_la1_0;\r
+ static private int[] jj_la1_1;\r
+ static private int[] jj_la1_2;\r
+ static {\r
+ jj_la1_init_0();\r
+ jj_la1_init_1();\r
+ jj_la1_init_2();\r
+ }\r
+ private static void jj_la1_init_0() {\r
+ jj_la1_0 = new int[] {0x100000,0x80001040,0x100000,0x80001040,0x0,0x0,0x400000,0x200,0x1000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x40,0x0,0x0,0x0,0x0,0x80001040,0x200000,0x200000,0x0,0x0,0x0,0x0,0x80001040,0x0,0x80001040,0x0,0x0,0x0,0x0,0x0,};\r
+ }\r
+ private static void jj_la1_init_1() {\r
+ jj_la1_1 = new int[] {0x0,0x4000000a,0x0,0x4000000a,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x2,0x40000008,0x0,0x0,0x0,0x4000000a,0x0,0x0,0x0,0x0,0x200,0x0,0x4000000a,0x0,0x4000000a,0x0,0x0,0x0,0x0,0x0,};\r
+ }\r
+ private static void jj_la1_init_2() {\r
+ jj_la1_2 = new int[] {0x0,0x3c03c005,0x0,0x3c03c005,0x20,0x20,0x0,0x0,0x0,0x3f00,0x3f00,0x3c000,0x3c000,0x3c000,0x3c0000,0xc00000,0xc00000,0x3c0000,0x40,0x38000000,0x4000005,0x10,0x4,0x10,0x3c03c005,0x80,0x80,0x4000000,0x80,0x0,0x80,0x3c03c005,0x80,0x3c03c005,0x80,0x80,0x20,0x14000020,0x14000000,};\r
+ }\r
+ final private JJCalls[] jj_2_rtns = new JJCalls[2];\r
+ private boolean jj_rescan = false;\r
+ private int jj_gc = 0;\r
+\r
+ /** Constructor with InputStream. */\r
+ public ExpressionParser(java.io.InputStream stream) {\r
+ this(stream, null);\r
+ }\r
+ /** Constructor with InputStream and supplied encoding */\r
+ public ExpressionParser(java.io.InputStream stream, String encoding) {\r
+ try { jj_input_stream = new SimpleCharStream(stream, encoding, 1, 1); } catch(java.io.UnsupportedEncodingException e) { throw new RuntimeException(e); }\r
+ token_source = new ExpressionParserTokenManager(jj_input_stream);\r
+ token = new Token();\r
+ jj_ntk = -1;\r
+ jj_gen = 0;\r
+ for (int i = 0; i < 39; i++) jj_la1[i] = -1;\r
+ for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls();\r
+ }\r
+\r
+ /** Reinitialise. */\r
+ public void ReInit(java.io.InputStream stream) {\r
+ ReInit(stream, null);\r
+ }\r
+ /** Reinitialise. */\r
+ public void ReInit(java.io.InputStream stream, String encoding) {\r
+ try { jj_input_stream.ReInit(stream, encoding, 1, 1); } catch(java.io.UnsupportedEncodingException e) { throw new RuntimeException(e); }\r
+ token_source.ReInit(jj_input_stream);\r
+ token = new Token();\r
+ jj_ntk = -1;\r
+ jj_gen = 0;\r
+ for (int i = 0; i < 39; i++) jj_la1[i] = -1;\r
+ for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls();\r
+ }\r
+\r
+ /** Constructor. */\r
+ public ExpressionParser(java.io.Reader stream) {\r
+ jj_input_stream = new SimpleCharStream(stream, 1, 1);\r
+ token_source = new ExpressionParserTokenManager(jj_input_stream);\r
+ token = new Token();\r
+ jj_ntk = -1;\r
+ jj_gen = 0;\r
+ for (int i = 0; i < 39; i++) jj_la1[i] = -1;\r
+ for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls();\r
+ }\r
+\r
+ /** Reinitialise. */\r
+ public void ReInit(java.io.Reader stream) {\r
+ jj_input_stream.ReInit(stream, 1, 1);\r
+ token_source.ReInit(jj_input_stream);\r
+ token = new Token();\r
+ jj_ntk = -1;\r
+ jj_gen = 0;\r
+ for (int i = 0; i < 39; i++) jj_la1[i] = -1;\r
+ for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls();\r
+ }\r
+\r
+ /** Constructor with generated Token Manager. */\r
+ public ExpressionParser(ExpressionParserTokenManager tm) {\r
+ token_source = tm;\r
+ token = new Token();\r
+ jj_ntk = -1;\r
+ jj_gen = 0;\r
+ for (int i = 0; i < 39; i++) jj_la1[i] = -1;\r
+ for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls();\r
+ }\r
+\r
+ /** Reinitialise. */\r
+ public void ReInit(ExpressionParserTokenManager tm) {\r
+ token_source = tm;\r
+ token = new Token();\r
+ jj_ntk = -1;\r
+ jj_gen = 0;\r
+ for (int i = 0; i < 39; i++) jj_la1[i] = -1;\r
+ for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls();\r
+ }\r
+\r
+ private Token jj_consume_token(int kind) throws ParseException {\r
+ Token oldToken;\r
+ if ((oldToken = token).next != null) token = token.next;\r
+ else token = token.next = token_source.getNextToken();\r
+ jj_ntk = -1;\r
+ if (token.kind == kind) {\r
+ jj_gen++;\r
+ if (++jj_gc > 100) {\r
+ jj_gc = 0;\r
+ for (int i = 0; i < jj_2_rtns.length; i++) {\r
+ JJCalls c = jj_2_rtns[i];\r
+ while (c != null) {\r
+ if (c.gen < jj_gen) c.first = null;\r
+ c = c.next;\r
+ }\r
+ }\r
+ }\r
+ return token;\r
+ }\r
+ token = oldToken;\r
+ jj_kind = kind;\r
+ throw generateParseException();\r
+ }\r
+\r
+ static private final class LookaheadSuccess extends java.lang.Error { }\r
+ final private LookaheadSuccess jj_ls = new LookaheadSuccess();\r
+ private boolean jj_scan_token(int kind) {\r
+ if (jj_scanpos == jj_lastpos) {\r
+ jj_la--;\r
+ if (jj_scanpos.next == null) {\r
+ jj_lastpos = jj_scanpos = jj_scanpos.next = token_source.getNextToken();\r
+ } else {\r
+ jj_lastpos = jj_scanpos = jj_scanpos.next;\r
+ }\r
+ } else {\r
+ jj_scanpos = jj_scanpos.next;\r
+ }\r
+ if (jj_rescan) {\r
+ int i = 0; Token tok = token;\r
+ while (tok != null && tok != jj_scanpos) { i++; tok = tok.next; }\r
+ if (tok != null) jj_add_error_token(kind, i);\r
+ }\r
+ if (jj_scanpos.kind != kind) return true;\r
+ if (jj_la == 0 && jj_scanpos == jj_lastpos) throw jj_ls;\r
+ return false;\r
+ }\r
+\r
+\r
+/** Get the next Token. */\r
+ final public Token getNextToken() {\r
+ if (token.next != null) token = token.next;\r
+ else token = token.next = token_source.getNextToken();\r
+ jj_ntk = -1;\r
+ jj_gen++;\r
+ return token;\r
+ }\r
+\r
+/** Get the specific Token. */\r
+ final public Token getToken(int index) {\r
+ Token t = token;\r
+ for (int i = 0; i < index; i++) {\r
+ if (t.next != null) t = t.next;\r
+ else t = t.next = token_source.getNextToken();\r
+ }\r
+ return t;\r
+ }\r
+\r
+ private int jj_ntk() {\r
+ if ((jj_nt=token.next) == null)\r
+ return (jj_ntk = (token.next=token_source.getNextToken()).kind);\r
+ else\r
+ return (jj_ntk = jj_nt.kind);\r
+ }\r
+\r
+ private java.util.List<int[]> jj_expentries = new java.util.ArrayList<int[]>();\r
+ private int[] jj_expentry;\r
+ private int jj_kind = -1;\r
+ private int[] jj_lasttokens = new int[100];\r
+ private int jj_endpos;\r
+\r
+ private void jj_add_error_token(int kind, int pos) {\r
+ if (pos >= 100) return;\r
+ if (pos == jj_endpos + 1) {\r
+ jj_lasttokens[jj_endpos++] = kind;\r
+ } else if (jj_endpos != 0) {\r
+ jj_expentry = new int[jj_endpos];\r
+ for (int i = 0; i < jj_endpos; i++) {\r
+ jj_expentry[i] = jj_lasttokens[i];\r
+ }\r
+ jj_entries_loop: for (java.util.Iterator<?> it = jj_expentries.iterator(); it.hasNext();) {\r
+ int[] oldentry = (int[])(it.next());\r
+ if (oldentry.length == jj_expentry.length) {\r
+ for (int i = 0; i < jj_expentry.length; i++) {\r
+ if (oldentry[i] != jj_expentry[i]) {\r
+ continue jj_entries_loop;\r
+ }\r
+ }\r
+ jj_expentries.add(jj_expentry);\r
+ break jj_entries_loop;\r
+ }\r
+ }\r
+ if (pos != 0) jj_lasttokens[(jj_endpos = pos) - 1] = kind;\r
+ }\r
+ }\r
+\r
+ /** Generate ParseException. */\r
+ public ParseException generateParseException() {\r
+ jj_expentries.clear();\r
+ boolean[] la1tokens = new boolean[94];\r
+ if (jj_kind >= 0) {\r
+ la1tokens[jj_kind] = true;\r
+ jj_kind = -1;\r
+ }\r
+ for (int i = 0; i < 39; i++) {\r
+ if (jj_la1[i] == jj_gen) {\r
+ for (int j = 0; j < 32; j++) {\r
+ if ((jj_la1_0[i] & (1<<j)) != 0) {\r
+ la1tokens[j] = true;\r
+ }\r
+ if ((jj_la1_1[i] & (1<<j)) != 0) {\r
+ la1tokens[32+j] = true;\r
+ }\r
+ if ((jj_la1_2[i] & (1<<j)) != 0) {\r
+ la1tokens[64+j] = true;\r
+ }\r
+ }\r
+ }\r
+ }\r
+ for (int i = 0; i < 94; i++) {\r
+ if (la1tokens[i]) {\r
+ jj_expentry = new int[1];\r
+ jj_expentry[0] = i;\r
+ jj_expentries.add(jj_expentry);\r
+ }\r
+ }\r
+ jj_endpos = 0;\r
+ jj_rescan_token();\r
+ jj_add_error_token(0, 0);\r
+ int[][] exptokseq = new int[jj_expentries.size()][];\r
+ for (int i = 0; i < jj_expentries.size(); i++) {\r
+ exptokseq[i] = jj_expentries.get(i);\r
+ }\r
+ return new ParseException(token, exptokseq, tokenImage);\r
+ }\r
+\r
+ /** Enable tracing. */\r
+ final public void enable_tracing() {\r
+ }\r
+\r
+ /** Disable tracing. */\r
+ final public void disable_tracing() {\r
+ }\r
+\r
+ private void jj_rescan_token() {\r
+ jj_rescan = true;\r
+ for (int i = 0; i < 2; i++) {\r
+ try {\r
+ JJCalls p = jj_2_rtns[i];\r
+ do {\r
+ if (p.gen > jj_gen) {\r
+ jj_la = p.arg; jj_lastpos = jj_scanpos = p.first;\r
+ switch (i) {\r
+ case 0: jj_3_1(); break;\r
+ case 1: jj_3_2(); break;\r
+ }\r
+ }\r
+ p = p.next;\r
+ } while (p != null);\r
+ } catch(LookaheadSuccess ls) { }\r
+ }\r
+ jj_rescan = false;\r
+ }\r
+\r
+ private void jj_save(int index, int xla) {\r
+ JJCalls p = jj_2_rtns[index];\r
+ while (p.gen > jj_gen) {\r
+ if (p.next == null) { p = p.next = new JJCalls(); break; }\r
+ p = p.next;\r
+ }\r
+ p.gen = jj_gen + xla - jj_la; p.first = token; p.arg = xla;\r
+ }\r
+\r
+ static final class JJCalls {\r
+ int gen;\r
+ Token first;\r
+ int arg;\r
+ JJCalls next;\r
+ }\r
+\r
+}\r
--- /dev/null
+options {\r
+ JDK_VERSION = "1.6";\r
+ STATIC = false;\r
+}\r
+\r
+PARSER_BEGIN(ExpressionParser)\r
+package org.simantics.sysdyn.expressionParser;\r
+\r
+import java.util.Set;\r
+import java.util.HashSet;\r
+import java.util.List;\r
+import java.util.ArrayList;\r
+import java.util.HashMap;\r
+\r
+\r
+public class ExpressionParser {\r
+\r
+ public class ForRange {\r public Token start;\r
+ public Token end;\r
+ }\r
+\r
+ boolean forIndex = false;\r
+ Token firstToken;\r
+\r
+ public Token getFirstToken() {\r return firstToken;\r
+ }\r\r
+ List<ForRange> forRanges = new ArrayList<ForRange>();\r
+ \r
+ public List<ForRange> getForRanges() {\r
+ return forRanges;\r
+ }\r
+ \r
+ HashMap<String, List<Token>> references = new HashMap<String, List<Token>>();\r
+ \r
+ public HashMap<String, List<Token>> getReferences() {\r
+ return references;\r
+ }\r
+\r
+ HashMap<String, List<List<Token>>> ranges = new HashMap<String, List<List<Token>>>();\r
+ \r
+ public HashMap<String, List<List<Token>>> getRanges() {\r
+ return ranges;\r
+ }\r
+\r
+ List<Token> currentRange = null;\r
+\r
+ HashMap<Token, List<Token>> forIndices = new HashMap<Token, List<Token>>();\r
+\r
+ public HashMap<Token, List<Token>> getForIndices() {\r
+ return forIndices;\r
+ }\r
+\r
+ HashMap<String, List<Token>> enumerationReferences = new HashMap<String, List<Token>>();\r
+ \r
+ public HashMap<String, List<Token>> getEnumerationReferences() {\r
+ return enumerationReferences;\r
+ }\r
+ \r
+ \r
+}\r
+PARSER_END(ExpressionParser)\r
+\r
+/*** Lexer *********************************************************/\r
+\r
+SKIP:\r
+{ <WHITESPACE: " " | "\n" | "\r" | "\t" > \r
+| <COMMENT1: "/*" (~["*"] | "*" ~["/"])* "*/" > \r
+| <COMMENT2: "//" (~["\n"])* >\r
+}\r
+\r
+TOKEN:\r
+{\r
+"algorithm" | "discrete" | "false" | "model" | "redeclare"\r
+| "and" | "each" | "final" | "not" | "replaceable"\r
+| "annotation" | "else" | "flow" | "operator" | "return"\r
+|"assert" | "elseif" | "for" | "or" | "stream"\r
+| "block" | "elsewhen" | "function" | "outer" | "then"\r
+| "break" | "encapsulated" | "if" | "output" | "true"\r
+| "class" | "end" | "import" | "package" | "type"\r
+| "connect" | "enumeration" | "in" | "parameter" | "when"\r
+| "connector" | "equation" | "initial" | "partial" | "while"\r
+| "constant" | "expandable" | "inner" | "protected" | "within"\r
+| "constrainedby" | "extends" | "input" | "public"\r
+| "der" | "external" | "loop" | "record"\r
+| "(" | ")" | "{" | "}" | "[" | "]" | "." | ":" | ";" | ","\r
+| "<" | "<=" | ">" | ">=" | "==" | "<>"\r
+| "+" | "-" | ".+" | ".-"\r
+| "*" | "/" | ".*" | "./"\r
+| "^" | ".^"\r
+| "=" | ":=" \r
+| <IDENT: ["a"-"z","A"-"Z","_"] (["a"-"z","A"-"Z","_","0"-"9"])* >\r
+| <STRING: "\"" (~["\"", "\\", "\n"] | "\\" ~["\n"])* "\"">\r
+ { matchedToken.image = matchedToken.image.substring(1,matchedToken.image.length()-1); }\r
+| <UNSIGNED_INTEGER: (["0"-"9"])+ >\r
+| <UNSIGNED_NUMBER: \r
+ ( <UNSIGNED_INTEGER> "." (<UNSIGNED_INTEGER>)? (["e","E"] <UNSIGNED_INTEGER>)?\r
+ | "." <UNSIGNED_INTEGER> (["e","E"] <UNSIGNED_INTEGER>)?\r
+ | <UNSIGNED_INTEGER> ["e","E"] <UNSIGNED_INTEGER>\r
+ ) >\r
+}\r
+\r
+/*** Parser ********************************************************/\r
+\r
+// https://javacc.dev.java.net/doc/javaccgrm.html\r
+// add_op -> add_op()\r
+// [ add_op ] -> ( add_op() )?\r
+// { add_op term } -> ( add_op() term() )*\r
+\r
+void expr() : {\r
+} {\r
+ {\r
+ firstToken = token;\r
+ }\r
+ simple_expression() <EOF>\r
+ |\r
+ {\r
+ firstToken = token;\r
+ }\r
+ "if" expression() "then" expression() ( "elseif" expression() "then" expression() )*\r
+ "else" expression() <EOF>\r
+}\r
+\r
+void expression() : {\r
+} {\r
+ simple_expression()\r
+ | "if" expression() "then" expression() ( "elseif" expression() "then" expression() )*\r
+ "else" expression()\r
+}\r
+\r
+void simple_expression() : {\r
+} {\r
+ logical_expression() ( ":" logical_expression() ( ":" logical_expression() )? )?\r
+} \r
+\r
+void logical_expression() : {\r
+} {\r
+ logical_term() ( "or" logical_term() )*\r
+} \r
+\r
+void logical_term() : {\r
+} {\r
+ logical_factor() ( "and" logical_factor() )*\r
+}\r
+\r
+void logical_factor() : {\r
+} {\r
+ ( "not" )? relation()\r
+}\r
+\r
+void relation() : {\r
+} {\r
+ arithmetic_expression() ( rel_op() arithmetic_expression() )?\r
+}\r
+\r
+void rel_op() : {\r
+} {\r
+ "<" | "<=" | ">" | ">=" | "==" | "<>"\r
+}\r
+\r
+void arithmetic_expression() : {\r
+} {\r
+ (add_op())? term() (add_op() term())*\r
+}\r
+\r
+void add_op() : {\r
+} {\r
+ "+" | "-" | ".+" | ".-"\r
+}\r
+\r
+void term() : {\r
+} {\r
+ factor() ( mul_op() factor() )*\r
+}\r
+\r
+void factor() : {\r
+} {\r
+ primary() ( "^" | ".^" primary() )?\r
+}\r
+\r
+void mul_op() : {\r
+} {\r
+ "*" | "/" | ".*" | "./"\r
+}\r
+\r
+void primary() : {\r
+} {\r
+ <UNSIGNED_NUMBER>\r
+ | <UNSIGNED_INTEGER>\r
+ | <STRING>\r
+ | "false"\r
+ | "true"\r
+ | LOOKAHEAD( name() "(" ) name() function_call_args()\r
+ | component_reference(null)\r
+ | "(" output_expression_list() ")"\r
+ | "[" expression_list() ( ";" expression_list() )* "]"\r
+ | "{" function_arguments() "}"\r
+ | "end"\r
+}\r
+\r
+void name() : {\r
+} {\r
+ <IDENT> ( "." name() )?\r
+}\r
+\r
+void component_reference(Token prevToken) : {\r
+} {\r
+ //IDENT [ array_subscripts ] [ "." component_reference ]\r
+ <IDENT> {\r
+ String name = token.image;\r
+\r
+ // prevToken != null => this is the second part of an enumeration\r
+ if(forIndex == true && prevToken != null) {\r
+ if(enumerationReferences.get(prevToken.image) == null) {\r enumerationReferences.put(prevToken.image, new ArrayList<Token>());\r
+ }\r
+ List<Token> list = enumerationReferences.get(prevToken.image);\r
+ list.add(token); \r
+\r
+ // forIndex == true, prevToken == null => this is the enumeration\r
+ } else if(forIndex == true && prevToken == null) {\r
+ if(enumerationReferences.get(token.image) == null) {\r
+ enumerationReferences.put(token.image, new ArrayList<Token>());\r
+ }\r
+ List<Token> list = enumerationReferences.get(token.image);\r
+ list.add(token); \r
+ } else {\r if(references.get(name) == null) {\r
+ references.put(name, new ArrayList<Token>());\r
+ }\r
+ List<Token> list = references.get(name);\r
+ list.add(token);\r
+ }\r
+\r
+ Token curToken = token;\r
+ }\r
+ \r
+ ( array_subscripts() )? ( "." component_reference(curToken) )?\r
+}\r
+\r
+\r
+void function_call_args() : {\r
+} {\r
+ "(" ( function_arguments() )? ")"\r
+}\r
+\r
+void function_arguments() : {\r
+} {\r
+ //expression [ "," function_arguments | for for_indices ]\r
+ //| named_arguments\r
+ LOOKAHEAD(2) expression() ( "," function_arguments() | "for" for_indices() )?\r
+ | named_arguments()\r
+}\r
+\r
+void for_indices() : {\r
+} {\r
+ //for_index {"," for_index}\r
+ for_index() ("," for_index())*\r
+}\r
+\r
+void for_index() : {\r
+} {\r
+ //IDENT [ in expression ]\r
+ <IDENT>\r {\r
+ forIndices.put(token, currentRange);\r
+ forIndex = true;\r }\r
+ ( "in"\r {\r
+ ForRange forRange = new ForRange();\r
+ forRange.start = token;\r }\r
+ expression()\r {\r
+ forRange.start = forRange.start.next;\r
+ forRange.end = token;\r
+ forRanges.add(forRange);\r }\r
+ )?\r
+ {\r forIndex = false;\r
+ }\r
+}\r
+\r
+void named_arguments() : {\r
+} {\r
+ named_argument() ( "," named_arguments() )?\r
+}\r
+\r
+void named_argument() : {\r
+} { \r
+ <IDENT> "=" expression()\r
+}\r
+\r
+void output_expression_list() : {\r
+} {\r
+ ( expression() )? ( "," ( expression() )? )*\r
+}\r
+\r
+\r
+void expression_list() : {\r
+} {\r
+ expression() ( "," expression() )*\r
+}\r
+\r
+void array_subscripts() : {\r if(ranges.get(token.image) == null) {\r
+ ranges.put(token.image, new ArrayList<List<Token>>());\r
+ }\r
+ List<List<Token>> rangesList = ranges.get(token.image);\r
+ currentRange = new ArrayList<Token>(); \r
+} {\r
+ "[" subscript(currentRange) ( "," subscript(currentRange) )* "]"\r
+ {\r
+ rangesList.add(currentRange);\r
+ }\r
+}\r
+\r
+void subscript(List<Token> currentRange) : {\r
+ Token rangeToken = new Token(token.kind, "");\r
+ rangeToken.beginColumn = token.beginColumn + 1;\r
+ rangeToken.beginLine = token.beginLine;\r
+} {\r ":"\r {\r currentRange.add(token);\r
+ }\r
+ | rangeIndex(rangeToken, false) ( ":" rangeIndex(rangeToken, true))? {\r
+ rangeToken.endColumn = token.endColumn;\r
+ rangeToken.endLine = token.endLine;\r
+ currentRange.add(rangeToken);\r
+ }\r
+}\r
+\r
+void rangeIndex(Token rangeToken, boolean second) : {\r
+ if(second)\r
+ rangeToken.image = rangeToken.image + ":";\r
+} {\r <UNSIGNED_INTEGER>\r {\r
+ rangeToken.image = rangeToken.image + token.image; \r }\r
+ | <IDENT>\r {\r rangeToken.image = rangeToken.image + token.image;\r
+ }\r
+}\r \r
+\r
--- /dev/null
+/* Generated By:JavaCC: Do not edit this line. ExpressionParserConstants.java */\r
+package org.simantics.sysdyn.expressionParser;\r
+\r
+\r
+/**\r
+ * Token literal values and constants.\r
+ * Generated by org.javacc.parser.OtherFilesGen#start()\r
+ */\r
+public interface ExpressionParserConstants {\r
+\r
+ /** End of File. */\r
+ int EOF = 0;\r
+ /** RegularExpression Id. */\r
+ int WHITESPACE = 1;\r
+ /** RegularExpression Id. */\r
+ int COMMENT1 = 2;\r
+ /** RegularExpression Id. */\r
+ int COMMENT2 = 3;\r
+ /** RegularExpression Id. */\r
+ int IDENT = 90;\r
+ /** RegularExpression Id. */\r
+ int STRING = 91;\r
+ /** RegularExpression Id. */\r
+ int UNSIGNED_INTEGER = 92;\r
+ /** RegularExpression Id. */\r
+ int UNSIGNED_NUMBER = 93;\r
+\r
+ /** Lexical state. */\r
+ int DEFAULT = 0;\r
+\r
+ /** Literal token values. */\r
+ String[] tokenImage = {\r
+ "<EOF>",\r
+ "<WHITESPACE>",\r
+ "<COMMENT1>",\r
+ "<COMMENT2>",\r
+ "\"algorithm\"",\r
+ "\"discrete\"",\r
+ "\"false\"",\r
+ "\"model\"",\r
+ "\"redeclare\"",\r
+ "\"and\"",\r
+ "\"each\"",\r
+ "\"final\"",\r
+ "\"not\"",\r
+ "\"replaceable\"",\r
+ "\"annotation\"",\r
+ "\"else\"",\r
+ "\"flow\"",\r
+ "\"operator\"",\r
+ "\"return\"",\r
+ "\"assert\"",\r
+ "\"elseif\"",\r
+ "\"for\"",\r
+ "\"or\"",\r
+ "\"stream\"",\r
+ "\"block\"",\r
+ "\"elsewhen\"",\r
+ "\"function\"",\r
+ "\"outer\"",\r
+ "\"then\"",\r
+ "\"break\"",\r
+ "\"encapsulated\"",\r
+ "\"if\"",\r
+ "\"output\"",\r
+ "\"true\"",\r
+ "\"class\"",\r
+ "\"end\"",\r
+ "\"import\"",\r
+ "\"package\"",\r
+ "\"type\"",\r
+ "\"connect\"",\r
+ "\"enumeration\"",\r
+ "\"in\"",\r
+ "\"parameter\"",\r
+ "\"when\"",\r
+ "\"connector\"",\r
+ "\"equation\"",\r
+ "\"initial\"",\r
+ "\"partial\"",\r
+ "\"while\"",\r
+ "\"constant\"",\r
+ "\"expandable\"",\r
+ "\"inner\"",\r
+ "\"protected\"",\r
+ "\"within\"",\r
+ "\"constrainedby\"",\r
+ "\"extends\"",\r
+ "\"input\"",\r
+ "\"public\"",\r
+ "\"der\"",\r
+ "\"external\"",\r
+ "\"loop\"",\r
+ "\"record\"",\r
+ "\"(\"",\r
+ "\")\"",\r
+ "\"{\"",\r
+ "\"}\"",\r
+ "\"[\"",\r
+ "\"]\"",\r
+ "\".\"",\r
+ "\":\"",\r
+ "\";\"",\r
+ "\",\"",\r
+ "\"<\"",\r
+ "\"<=\"",\r
+ "\">\"",\r
+ "\">=\"",\r
+ "\"==\"",\r
+ "\"<>\"",\r
+ "\"+\"",\r
+ "\"-\"",\r
+ "\".+\"",\r
+ "\".-\"",\r
+ "\"*\"",\r
+ "\"/\"",\r
+ "\".*\"",\r
+ "\"./\"",\r
+ "\"^\"",\r
+ "\".^\"",\r
+ "\"=\"",\r
+ "\":=\"",\r
+ "<IDENT>",\r
+ "<STRING>",\r
+ "<UNSIGNED_INTEGER>",\r
+ "<UNSIGNED_NUMBER>",\r
+ };\r
+\r
+}\r
--- /dev/null
+/* Generated By:JavaCC: Do not edit this line. ExpressionParserTokenManager.java */\r
+package org.simantics.sysdyn.expressionParser;\r
+import java.util.Set;\r
+import java.util.HashSet;\r
+import java.util.List;\r
+import java.util.ArrayList;\r
+import java.util.HashMap;\r
+\r
+/** Token Manager. */\r
+public class ExpressionParserTokenManager implements ExpressionParserConstants\r
+{\r
+\r
+ /** Debug output. */\r
+ public java.io.PrintStream debugStream = System.out;\r
+ /** Set debug output. */\r
+ public void setDebugStream(java.io.PrintStream ds) { debugStream = ds; }\r
+private final int jjStopStringLiteralDfa_0(int pos, long active0, long active1)
+{\r
+ switch (pos)
+ {\r
+ case 0:\r
+ if ((active0 & 0x3ffffffffffffff0L) != 0L)\r
+ {\r
+ jjmatchedKind = 90;\r
+ return 2;\r
+ }\r
+ if ((active1 & 0x80000L) != 0L)\r
+ return 13;\r
+ if ((active1 & 0xb30010L) != 0L)\r
+ return 9;\r
+ return -1;\r
+ case 1:\r
+ if ((active0 & 0x108420080400000L) != 0L)\r
+ return 2;\r
+ if ((active0 & 0x3ef7bdff7fbffff0L) != 0L)\r
+ {\r
+ if (jjmatchedPos != 1)\r
+ {\r
+ jjmatchedKind = 90;\r
+ jjmatchedPos = 1;\r
+ }\r
+ return 2;\r
+ }\r
+ return -1;\r
+ case 2:\r
+ if ((active0 & 0x400000800201200L) != 0L)\r
+ return 2;\r
+ if ((active0 & 0x3bfffdf77f9fedf0L) != 0L)\r
+ {\r
+ jjmatchedKind = 90;\r
+ jjmatchedPos = 2;\r
+ return 2;\r
+ }\r
+ return -1;\r
+ case 3:\r
+ if ((active0 & 0x1000084212118400L) != 0L)\r
+ return 2;\r
+ if ((active0 & 0x2bfff5b56d8e69f0L) != 0L)\r
+ {\r
+ if (jjmatchedPos != 3)\r
+ {\r
+ jjmatchedKind = 90;\r
+ jjmatchedPos = 3;\r
+ }\r
+ return 2;\r
+ }\r
+ return -1;\r
+ case 4:\r
+ if ((active0 & 0x1090004290008c0L) != 0L)\r
+ return 2;\r
+ if ((active0 & 0x2af6f5b1469e6130L) != 0L)\r
+ {\r
+ jjmatchedKind = 90;\r
+ jjmatchedPos = 4;\r
+ return 2;\r
+ }\r
+ return -1;\r
+ case 5:\r
+ if ((active0 & 0x22200011009c0000L) != 0L)\r
+ return 2;\r
+ if ((active0 & 0x8d6f5a046026130L) != 0L)\r
+ {\r
+ jjmatchedKind = 90;\r
+ jjmatchedPos = 5;\r
+ return 2;\r
+ }\r
+ return -1;\r
+ case 6:\r
+ if ((active0 & 0x80d0a000000000L) != 0L)\r
+ return 2;\r
+ if ((active0 & 0x856250046026130L) != 0L)\r
+ {\r
+ if (jjmatchedPos != 6)\r
+ {\r
+ jjmatchedKind = 90;\r
+ jjmatchedPos = 6;\r
+ }\r
+ return 2;\r
+ }\r
+ return -1;\r
+ case 7:\r
+ if ((active0 & 0x54150040006110L) != 0L)\r
+ {\r
+ jjmatchedKind = 90;\r
+ jjmatchedPos = 7;\r
+ return 2;\r
+ }\r
+ if ((active0 & 0x802200006020020L) != 0L)\r
+ return 2;\r
+ return -1;\r
+ case 8:\r
+ if ((active0 & 0x10140000000110L) != 0L)\r
+ return 2;\r
+ if ((active0 & 0x44010040006000L) != 0L)\r
+ {\r
+ jjmatchedKind = 90;\r
+ jjmatchedPos = 8;\r
+ return 2;\r
+ }\r
+ return -1;\r
+ case 9:\r
+ if ((active0 & 0x40010040002000L) != 0L)\r
+ {\r
+ jjmatchedKind = 90;\r
+ jjmatchedPos = 9;\r
+ return 2;\r
+ }\r
+ if ((active0 & 0x4000000004000L) != 0L)\r
+ return 2;\r
+ return -1;\r
+ case 10:\r
+ if ((active0 & 0x10000002000L) != 0L)\r
+ return 2;\r
+ if ((active0 & 0x40000040000000L) != 0L)\r
+ {\r
+ jjmatchedKind = 90;\r
+ jjmatchedPos = 10;\r
+ return 2;\r
+ }\r
+ return -1;\r
+ case 11:\r
+ if ((active0 & 0x40000000L) != 0L)\r
+ return 2;\r
+ if ((active0 & 0x40000000000000L) != 0L)\r
+ {\r
+ jjmatchedKind = 90;\r
+ jjmatchedPos = 11;\r
+ return 2;\r
+ }\r
+ return -1;\r
+ default :\r
+ return -1;\r
+ }\r
+}\r
+private final int jjStartNfa_0(int pos, long active0, long active1)
+{\r
+ return jjMoveNfa_0(jjStopStringLiteralDfa_0(pos, active0, active1), pos + 1);\r
+}\r
+private int jjStopAtPos(int pos, int kind)\r
+{\r
+ jjmatchedKind = kind;\r
+ jjmatchedPos = pos;\r
+ return pos + 1;\r
+}\r
+private int jjMoveStringLiteralDfa0_0()\r
+{\r
+ switch(curChar)\r
+ {\r
+ case 40:\r
+ return jjStopAtPos(0, 62);\r
+ case 41:\r
+ return jjStopAtPos(0, 63);\r
+ case 42:\r
+ return jjStopAtPos(0, 82);\r
+ case 43:\r
+ return jjStopAtPos(0, 78);\r
+ case 44:\r
+ return jjStopAtPos(0, 71);\r
+ case 45:\r
+ return jjStopAtPos(0, 79);\r
+ case 46:\r
+ jjmatchedKind = 68;\r
+ return jjMoveStringLiteralDfa1_0(0x0L, 0xb30000L);\r
+ case 47:\r
+ return jjStartNfaWithStates_0(0, 83, 13);\r
+ case 58:\r
+ jjmatchedKind = 69;\r
+ return jjMoveStringLiteralDfa1_0(0x0L, 0x2000000L);\r
+ case 59:\r
+ return jjStopAtPos(0, 70);\r
+ case 60:\r
+ jjmatchedKind = 72;\r
+ return jjMoveStringLiteralDfa1_0(0x0L, 0x2200L);\r
+ case 61:\r
+ jjmatchedKind = 88;\r
+ return jjMoveStringLiteralDfa1_0(0x0L, 0x1000L);\r
+ case 62:\r
+ jjmatchedKind = 74;\r
+ return jjMoveStringLiteralDfa1_0(0x0L, 0x800L);\r
+ case 91:\r
+ return jjStopAtPos(0, 66);\r
+ case 93:\r
+ return jjStopAtPos(0, 67);\r
+ case 94:\r
+ return jjStopAtPos(0, 86);\r
+ case 97:\r
+ return jjMoveStringLiteralDfa1_0(0x84210L, 0x0L);\r
+ case 98:\r
+ return jjMoveStringLiteralDfa1_0(0x21000000L, 0x0L);\r
+ case 99:\r
+ return jjMoveStringLiteralDfa1_0(0x42108400000000L, 0x0L);\r
+ case 100:\r
+ return jjMoveStringLiteralDfa1_0(0x400000000000020L, 0x0L);\r
+ case 101:\r
+ return jjMoveStringLiteralDfa1_0(0x884210842108400L, 0x0L);\r
+ case 102:\r
+ return jjMoveStringLiteralDfa1_0(0x4210840L, 0x0L);\r
+ case 105:\r
+ return jjMoveStringLiteralDfa1_0(0x108421080000000L, 0x0L);\r
+ case 108:\r
+ return jjMoveStringLiteralDfa1_0(0x1000000000000000L, 0x0L);\r
+ case 109:\r
+ return jjMoveStringLiteralDfa1_0(0x80L, 0x0L);\r
+ case 110:\r
+ return jjMoveStringLiteralDfa1_0(0x1000L, 0x0L);\r
+ case 111:\r
+ return jjMoveStringLiteralDfa1_0(0x108420000L, 0x0L);\r
+ case 112:\r
+ return jjMoveStringLiteralDfa1_0(0x210842000000000L, 0x0L);\r
+ case 114:\r
+ return jjMoveStringLiteralDfa1_0(0x2000000000042100L, 0x0L);\r
+ case 115:\r
+ return jjMoveStringLiteralDfa1_0(0x800000L, 0x0L);\r
+ case 116:\r
+ return jjMoveStringLiteralDfa1_0(0x4210000000L, 0x0L);\r
+ case 119:\r
+ return jjMoveStringLiteralDfa1_0(0x21080000000000L, 0x0L);\r
+ case 123:\r
+ return jjStopAtPos(0, 64);\r
+ case 125:\r
+ return jjStopAtPos(0, 65);\r
+ default :\r
+ return jjMoveNfa_0(0, 0);\r
+ }\r
+}\r
+private int jjMoveStringLiteralDfa1_0(long active0, long active1)\r
+{\r
+ try { curChar = input_stream.readChar(); }\r
+ catch(java.io.IOException e) {\r
+ jjStopStringLiteralDfa_0(0, active0, active1);\r
+ return 1;\r
+ }\r
+ switch(curChar)\r
+ {\r
+ case 42:\r
+ if ((active1 & 0x100000L) != 0L)\r
+ return jjStopAtPos(1, 84);\r
+ break;\r
+ case 43:\r
+ if ((active1 & 0x10000L) != 0L)\r
+ return jjStopAtPos(1, 80);\r
+ break;\r
+ case 45:\r
+ if ((active1 & 0x20000L) != 0L)\r
+ return jjStopAtPos(1, 81);\r
+ break;\r
+ case 47:\r
+ if ((active1 & 0x200000L) != 0L)\r
+ return jjStopAtPos(1, 85);\r
+ break;\r
+ case 61:\r
+ if ((active1 & 0x200L) != 0L)\r
+ return jjStopAtPos(1, 73);\r
+ else if ((active1 & 0x800L) != 0L)\r
+ return jjStopAtPos(1, 75);\r
+ else if ((active1 & 0x1000L) != 0L)\r
+ return jjStopAtPos(1, 76);\r
+ else if ((active1 & 0x2000000L) != 0L)\r
+ return jjStopAtPos(1, 89);\r
+ break;\r
+ case 62:\r
+ if ((active1 & 0x2000L) != 0L)\r
+ return jjStopAtPos(1, 77);\r
+ break;\r
+ case 94:\r
+ if ((active1 & 0x800000L) != 0L)\r
+ return jjStopAtPos(1, 87);\r
+ break;\r
+ case 97:\r
+ return jjMoveStringLiteralDfa2_0(active0, 0x842000000440L, active1, 0L);\r
+ case 101:\r
+ return jjMoveStringLiteralDfa2_0(active0, 0x2400000000042100L, active1, 0L);\r
+ case 102:\r
+ if ((active0 & 0x80000000L) != 0L)\r
+ return jjStartNfaWithStates_0(1, 31, 2);\r
+ break;\r
+ case 104:\r
+ return jjMoveStringLiteralDfa2_0(active0, 0x1080010000000L, active1, 0L);\r
+ case 105:\r
+ return jjMoveStringLiteralDfa2_0(active0, 0x20000000000820L, active1, 0L);\r
+ case 108:\r
+ return jjMoveStringLiteralDfa2_0(active0, 0x403118010L, active1, 0L);\r
+ case 109:\r
+ return jjMoveStringLiteralDfa2_0(active0, 0x1000000000L, active1, 0L);\r
+ case 110:\r
+ if ((active0 & 0x20000000000L) != 0L)\r
+ {\r
+ jjmatchedKind = 41;\r
+ jjmatchedPos = 1;\r
+ }\r
+ return jjMoveStringLiteralDfa2_0(active0, 0x108410840004200L, active1, 0L);\r
+ case 111:\r
+ return jjMoveStringLiteralDfa2_0(active0, 0x1042108000201080L, active1, 0L);\r
+ case 112:\r
+ return jjMoveStringLiteralDfa2_0(active0, 0x20000L, active1, 0L);\r
+ case 113:\r
+ return jjMoveStringLiteralDfa2_0(active0, 0x200000000000L, active1, 0L);\r
+ case 114:\r
+ if ((active0 & 0x400000L) != 0L)\r
+ return jjStartNfaWithStates_0(1, 22, 2);\r
+ return jjMoveStringLiteralDfa2_0(active0, 0x10000220000000L, active1, 0L);\r
+ case 115:\r
+ return jjMoveStringLiteralDfa2_0(active0, 0x80000L, active1, 0L);\r
+ case 116:\r
+ return jjMoveStringLiteralDfa2_0(active0, 0x800000L, active1, 0L);\r
+ case 117:\r
+ return jjMoveStringLiteralDfa2_0(active0, 0x20000010c000000L, active1, 0L);\r
+ case 120:\r
+ return jjMoveStringLiteralDfa2_0(active0, 0x884000000000000L, active1, 0L);\r
+ case 121:\r
+ return jjMoveStringLiteralDfa2_0(active0, 0x4000000000L, active1, 0L);\r
+ default :\r
+ break;\r
+ }\r
+ return jjStartNfa_0(0, active0, active1);\r
+}\r
+private int jjMoveStringLiteralDfa2_0(long old0, long active0, long old1, long active1)\r
+{\r
+ if (((active0 &= old0) | (active1 &= old1)) == 0L)\r
+ return jjStartNfa_0(0, old0, old1);\r
+ try { curChar = input_stream.readChar(); }\r
+ catch(java.io.IOException e) {\r
+ jjStopStringLiteralDfa_0(1, active0, 0L);\r
+ return 2;\r
+ }\r
+ switch(curChar)\r
+ {\r
+ case 97:\r
+ return jjMoveStringLiteralDfa3_0(active0, 0x400000000L);\r
+ case 98:\r
+ return jjMoveStringLiteralDfa3_0(active0, 0x200000000000000L);\r
+ case 99:\r
+ return jjMoveStringLiteralDfa3_0(active0, 0x2000002040000400L);\r
+ case 100:\r
+ if ((active0 & 0x200L) != 0L)\r
+ return jjStartNfaWithStates_0(2, 9, 2);\r
+ else if ((active0 & 0x800000000L) != 0L)\r
+ return jjStartNfaWithStates_0(2, 35, 2);\r
+ return jjMoveStringLiteralDfa3_0(active0, 0x180L);\r
+ case 101:\r
+ return jjMoveStringLiteralDfa3_0(active0, 0x80030020000L);\r
+ case 103:\r
+ return jjMoveStringLiteralDfa3_0(active0, 0x10L);\r
+ case 105:\r
+ return jjMoveStringLiteralDfa3_0(active0, 0x1400000000000L);\r
+ case 108:\r
+ return jjMoveStringLiteralDfa3_0(active0, 0x40L);\r
+ case 110:\r
+ return jjMoveStringLiteralDfa3_0(active0, 0x4a108004004800L);\r
+ case 111:\r
+ return jjMoveStringLiteralDfa3_0(active0, 0x1010000001010000L);\r
+ case 112:\r
+ return jjMoveStringLiteralDfa3_0(active0, 0x104005000002000L);\r
+ case 114:\r
+ if ((active0 & 0x200000L) != 0L)\r
+ return jjStartNfaWithStates_0(2, 21, 2);\r
+ else if ((active0 & 0x400000000000000L) != 0L)\r
+ return jjStartNfaWithStates_0(2, 58, 2);\r
+ return jjMoveStringLiteralDfa3_0(active0, 0x840000800000L);\r
+ case 115:\r
+ return jjMoveStringLiteralDfa3_0(active0, 0x2188020L);\r
+ case 116:\r
+ if ((active0 & 0x1000L) != 0L)\r
+ return jjStartNfaWithStates_0(2, 12, 2);\r
+ return jjMoveStringLiteralDfa3_0(active0, 0x8a0000108040000L);\r
+ case 117:\r
+ return jjMoveStringLiteralDfa3_0(active0, 0x210200000000L);\r
+ default :\r
+ break;\r
+ }\r
+ return jjStartNfa_0(1, active0, 0L);\r
+}\r
+private int jjMoveStringLiteralDfa3_0(long old0, long active0)\r
+{\r
+ if (((active0 &= old0)) == 0L)\r
+ return jjStartNfa_0(1, old0, 0L);\r
+ try { curChar = input_stream.readChar(); }\r
+ catch(java.io.IOException e) {\r
+ jjStopStringLiteralDfa_0(2, active0, 0L);\r
+ return 3;\r
+ }\r
+ switch(curChar)\r
+ {\r
+ case 97:\r
+ return jjMoveStringLiteralDfa4_0(active0, 0x4240060000800L);\r
+ case 99:\r
+ return jjMoveStringLiteralDfa4_0(active0, 0x5000020L);\r
+ case 101:\r
+ if ((active0 & 0x8000L) != 0L)\r
+ {\r
+ jjmatchedKind = 15;\r
+ jjmatchedPos = 3;\r
+ }\r
+ else if ((active0 & 0x200000000L) != 0L)\r
+ return jjStartNfaWithStates_0(3, 33, 2);\r
+ else if ((active0 & 0x4000000000L) != 0L)\r
+ return jjStartNfaWithStates_0(3, 38, 2);\r
+ return jjMoveStringLiteralDfa4_0(active0, 0x88800000a980180L);\r
+ case 104:\r
+ if ((active0 & 0x400L) != 0L)\r
+ return jjStartNfaWithStates_0(3, 10, 2);\r
+ return jjMoveStringLiteralDfa4_0(active0, 0x20000000000000L);\r
+ case 107:\r
+ return jjMoveStringLiteralDfa4_0(active0, 0x2000000000L);\r
+ case 108:\r
+ return jjMoveStringLiteralDfa4_0(active0, 0x201000000002000L);\r
+ case 109:\r
+ return jjMoveStringLiteralDfa4_0(active0, 0x10000000000L);\r
+ case 110:\r
+ if ((active0 & 0x10000000L) != 0L)\r
+ return jjStartNfaWithStates_0(3, 28, 2);\r
+ else if ((active0 & 0x80000000000L) != 0L)\r
+ return jjStartNfaWithStates_0(3, 43, 2);\r
+ return jjMoveStringLiteralDfa4_0(active0, 0x108000000000L);\r
+ case 111:\r
+ return jjMoveStringLiteralDfa4_0(active0, 0x2000001000004010L);\r
+ case 112:\r
+ if ((active0 & 0x1000000000000000L) != 0L)\r
+ return jjStartNfaWithStates_0(3, 60, 2);\r
+ return jjMoveStringLiteralDfa4_0(active0, 0x100000000L);\r
+ case 114:\r
+ return jjMoveStringLiteralDfa4_0(active0, 0x20000L);\r
+ case 115:\r
+ return jjMoveStringLiteralDfa4_0(active0, 0x42000400000040L);\r
+ case 116:\r
+ return jjMoveStringLiteralDfa4_0(active0, 0x10c00000000000L);\r
+ case 117:\r
+ return jjMoveStringLiteralDfa4_0(active0, 0x100000000040000L);\r
+ case 119:\r
+ if ((active0 & 0x10000L) != 0L)\r
+ return jjStartNfaWithStates_0(3, 16, 2);\r
+ break;\r
+ default :\r
+ break;\r
+ }\r
+ return jjStartNfa_0(2, active0, 0L);\r
+}\r
+private int jjMoveStringLiteralDfa4_0(long old0, long active0)\r
+{\r
+ if (((active0 &= old0)) == 0L)\r
+ return jjStartNfa_0(2, old0, 0L);\r
+ try { curChar = input_stream.readChar(); }\r
+ catch(java.io.IOException e) {\r
+ jjStopStringLiteralDfa_0(3, active0, 0L);\r
+ return 4;\r
+ }\r
+ switch(curChar)\r
+ {\r
+ case 97:\r
+ return jjMoveStringLiteralDfa5_0(active0, 0x2000822000L);\r
+ case 99:\r
+ return jjMoveStringLiteralDfa5_0(active0, 0x100L);\r
+ case 101:\r
+ if ((active0 & 0x40L) != 0L)\r
+ return jjStartNfaWithStates_0(4, 6, 2);\r
+ else if ((active0 & 0x1000000000000L) != 0L)\r
+ return jjStartNfaWithStates_0(4, 48, 2);\r
+ return jjMoveStringLiteralDfa5_0(active0, 0x10118000000000L);\r
+ case 105:\r
+ return jjMoveStringLiteralDfa5_0(active0, 0x220c00000100000L);\r
+ case 107:\r
+ if ((active0 & 0x1000000L) != 0L)\r
+ return jjStartNfaWithStates_0(4, 24, 2);\r
+ else if ((active0 & 0x20000000L) != 0L)\r
+ return jjStartNfaWithStates_0(4, 29, 2);\r
+ break;\r
+ case 108:\r
+ if ((active0 & 0x80L) != 0L)\r
+ return jjStartNfaWithStates_0(4, 7, 2);\r
+ else if ((active0 & 0x800L) != 0L)\r
+ return jjStartNfaWithStates_0(4, 11, 2);\r
+ break;\r
+ case 109:\r
+ return jjMoveStringLiteralDfa5_0(active0, 0x40000000000L);\r
+ case 110:\r
+ return jjMoveStringLiteralDfa5_0(active0, 0x84000000000000L);\r
+ case 112:\r
+ return jjMoveStringLiteralDfa5_0(active0, 0x40000000L);\r
+ case 114:\r
+ if ((active0 & 0x8000000L) != 0L)\r
+ return jjStartNfaWithStates_0(4, 27, 2);\r
+ else if ((active0 & 0x8000000000000L) != 0L)\r
+ return jjStartNfaWithStates_0(4, 51, 2);\r
+ return jjMoveStringLiteralDfa5_0(active0, 0x28000010000c0030L);\r
+ case 115:\r
+ if ((active0 & 0x400000000L) != 0L)\r
+ return jjStartNfaWithStates_0(4, 34, 2);\r
+ break;\r
+ case 116:\r
+ if ((active0 & 0x100000000000000L) != 0L)\r
+ return jjStartNfaWithStates_0(4, 56, 2);\r
+ return jjMoveStringLiteralDfa5_0(active0, 0x42200004004000L);\r
+ case 117:\r
+ return jjMoveStringLiteralDfa5_0(active0, 0x100000000L);\r
+ case 119:\r
+ return jjMoveStringLiteralDfa5_0(active0, 0x2000000L);\r
+ default :\r
+ break;\r
+ }\r
+ return jjStartNfa_0(3, active0, 0L);\r
+}\r
+private int jjMoveStringLiteralDfa5_0(long old0, long active0)\r
+{\r
+ if (((active0 &= old0)) == 0L)\r
+ return jjStartNfa_0(3, old0, 0L);\r
+ try { curChar = input_stream.readChar(); }\r
+ catch(java.io.IOException e) {\r
+ jjStopStringLiteralDfa_0(4, active0, 0L);\r
+ return 5;\r
+ }\r
+ switch(curChar)\r
+ {\r
+ case 97:\r
+ return jjMoveStringLiteralDfa6_0(active0, 0x2c00000004000L);\r
+ case 99:\r
+ if ((active0 & 0x200000000000000L) != 0L)\r
+ return jjStartNfaWithStates_0(5, 57, 2);\r
+ return jjMoveStringLiteralDfa6_0(active0, 0x10108000002000L);\r
+ case 100:\r
+ if ((active0 & 0x2000000000000000L) != 0L)\r
+ return jjStartNfaWithStates_0(5, 61, 2);\r
+ return jjMoveStringLiteralDfa6_0(active0, 0x84000000000000L);\r
+ case 101:\r
+ return jjMoveStringLiteralDfa6_0(active0, 0x40000000020L);\r
+ case 102:\r
+ if ((active0 & 0x100000L) != 0L)\r
+ return jjStartNfaWithStates_0(5, 20, 2);\r
+ break;\r
+ case 103:\r
+ return jjMoveStringLiteralDfa6_0(active0, 0x2000000000L);\r
+ case 104:\r
+ return jjMoveStringLiteralDfa6_0(active0, 0x2000000L);\r
+ case 105:\r
+ return jjMoveStringLiteralDfa6_0(active0, 0x200004000010L);\r
+ case 108:\r
+ return jjMoveStringLiteralDfa6_0(active0, 0x100L);\r
+ case 109:\r
+ if ((active0 & 0x800000L) != 0L)\r
+ return jjStartNfaWithStates_0(5, 23, 2);\r
+ break;\r
+ case 110:\r
+ if ((active0 & 0x40000L) != 0L)\r
+ return jjStartNfaWithStates_0(5, 18, 2);\r
+ else if ((active0 & 0x20000000000000L) != 0L)\r
+ return jjStartNfaWithStates_0(5, 53, 2);\r
+ return jjMoveStringLiteralDfa6_0(active0, 0x800000000000000L);\r
+ case 114:\r
+ return jjMoveStringLiteralDfa6_0(active0, 0x40010000000000L);\r
+ case 115:\r
+ return jjMoveStringLiteralDfa6_0(active0, 0x40000000L);\r
+ case 116:\r
+ if ((active0 & 0x80000L) != 0L)\r
+ return jjStartNfaWithStates_0(5, 19, 2);\r
+ else if ((active0 & 0x100000000L) != 0L)\r
+ return jjStartNfaWithStates_0(5, 32, 2);\r
+ else if ((active0 & 0x1000000000L) != 0L)\r
+ return jjStartNfaWithStates_0(5, 36, 2);\r
+ return jjMoveStringLiteralDfa6_0(active0, 0x20000L);\r
+ default :\r
+ break;\r
+ }\r
+ return jjStartNfa_0(4, active0, 0L);\r
+}\r
+private int jjMoveStringLiteralDfa6_0(long old0, long active0)\r
+{\r
+ if (((active0 &= old0)) == 0L)\r
+ return jjStartNfa_0(4, old0, 0L);\r
+ try { curChar = input_stream.readChar(); }\r
+ catch(java.io.IOException e) {\r
+ jjStopStringLiteralDfa_0(5, active0, 0L);\r
+ return 6;\r
+ }\r
+ switch(curChar)\r
+ {\r
+ case 97:\r
+ return jjMoveStringLiteralDfa7_0(active0, 0x844010000000100L);\r
+ case 101:\r
+ if ((active0 & 0x2000000000L) != 0L)\r
+ return jjStartNfaWithStates_0(6, 37, 2);\r
+ return jjMoveStringLiteralDfa7_0(active0, 0x2002000L);\r
+ case 108:\r
+ if ((active0 & 0x400000000000L) != 0L)\r
+ return jjStartNfaWithStates_0(6, 46, 2);\r
+ else if ((active0 & 0x800000000000L) != 0L)\r
+ return jjStartNfaWithStates_0(6, 47, 2);\r
+ break;\r
+ case 110:\r
+ return jjMoveStringLiteralDfa7_0(active0, 0x2000000000000L);\r
+ case 111:\r
+ return jjMoveStringLiteralDfa7_0(active0, 0x200004020000L);\r
+ case 115:\r
+ if ((active0 & 0x80000000000000L) != 0L)\r
+ return jjStartNfaWithStates_0(6, 55, 2);\r
+ break;\r
+ case 116:\r
+ if ((active0 & 0x8000000000L) != 0L)\r
+ {\r
+ jjmatchedKind = 39;\r
+ jjmatchedPos = 6;\r
+ }\r
+ return jjMoveStringLiteralDfa7_0(active0, 0x10140000004030L);\r
+ case 117:\r
+ return jjMoveStringLiteralDfa7_0(active0, 0x40000000L);\r
+ default :\r
+ break;\r
+ }\r
+ return jjStartNfa_0(5, active0, 0L);\r
+}\r
+private int jjMoveStringLiteralDfa7_0(long old0, long active0)\r
+{\r
+ if (((active0 &= old0)) == 0L)\r
+ return jjStartNfa_0(5, old0, 0L);\r
+ try { curChar = input_stream.readChar(); }\r
+ catch(java.io.IOException e) {\r
+ jjStopStringLiteralDfa_0(6, active0, 0L);\r
+ return 7;\r
+ }\r
+ switch(curChar)\r
+ {\r
+ case 97:\r
+ return jjMoveStringLiteralDfa8_0(active0, 0x2000L);\r
+ case 98:\r
+ return jjMoveStringLiteralDfa8_0(active0, 0x4000000000000L);\r
+ case 101:\r
+ if ((active0 & 0x20L) != 0L)\r
+ return jjStartNfaWithStates_0(7, 5, 2);\r
+ return jjMoveStringLiteralDfa8_0(active0, 0x10040000000000L);\r
+ case 104:\r
+ return jjMoveStringLiteralDfa8_0(active0, 0x10L);\r
+ case 105:\r
+ return jjMoveStringLiteralDfa8_0(active0, 0x40000000004000L);\r
+ case 108:\r
+ if ((active0 & 0x800000000000000L) != 0L)\r
+ return jjStartNfaWithStates_0(7, 59, 2);\r
+ return jjMoveStringLiteralDfa8_0(active0, 0x40000000L);\r
+ case 110:\r
+ if ((active0 & 0x2000000L) != 0L)\r
+ return jjStartNfaWithStates_0(7, 25, 2);\r
+ else if ((active0 & 0x4000000L) != 0L)\r
+ return jjStartNfaWithStates_0(7, 26, 2);\r
+ else if ((active0 & 0x200000000000L) != 0L)\r
+ return jjStartNfaWithStates_0(7, 45, 2);\r
+ break;\r
+ case 111:\r
+ return jjMoveStringLiteralDfa8_0(active0, 0x100000000000L);\r
+ case 114:\r
+ if ((active0 & 0x20000L) != 0L)\r
+ return jjStartNfaWithStates_0(7, 17, 2);\r
+ return jjMoveStringLiteralDfa8_0(active0, 0x100L);\r
+ case 116:\r
+ if ((active0 & 0x2000000000000L) != 0L)\r
+ return jjStartNfaWithStates_0(7, 49, 2);\r
+ return jjMoveStringLiteralDfa8_0(active0, 0x10000000000L);\r
+ default :\r
+ break;\r
+ }\r
+ return jjStartNfa_0(6, active0, 0L);\r
+}\r
+private int jjMoveStringLiteralDfa8_0(long old0, long active0)\r
+{\r
+ if (((active0 &= old0)) == 0L)\r
+ return jjStartNfa_0(6, old0, 0L);\r
+ try { curChar = input_stream.readChar(); }\r
+ catch(java.io.IOException e) {\r
+ jjStopStringLiteralDfa_0(7, active0, 0L);\r
+ return 8;\r
+ }\r
+ switch(curChar)\r
+ {\r
+ case 97:\r
+ return jjMoveStringLiteralDfa9_0(active0, 0x40000000L);\r
+ case 98:\r
+ return jjMoveStringLiteralDfa9_0(active0, 0x2000L);\r
+ case 100:\r
+ if ((active0 & 0x10000000000000L) != 0L)\r
+ return jjStartNfaWithStates_0(8, 52, 2);\r
+ break;\r
+ case 101:\r
+ if ((active0 & 0x100L) != 0L)\r
+ return jjStartNfaWithStates_0(8, 8, 2);\r
+ break;\r
+ case 105:\r
+ return jjMoveStringLiteralDfa9_0(active0, 0x10000000000L);\r
+ case 108:\r
+ return jjMoveStringLiteralDfa9_0(active0, 0x4000000000000L);\r
+ case 109:\r
+ if ((active0 & 0x10L) != 0L)\r
+ return jjStartNfaWithStates_0(8, 4, 2);\r
+ break;\r
+ case 110:\r
+ return jjMoveStringLiteralDfa9_0(active0, 0x40000000000000L);\r
+ case 111:\r
+ return jjMoveStringLiteralDfa9_0(active0, 0x4000L);\r
+ case 114:\r
+ if ((active0 & 0x40000000000L) != 0L)\r
+ return jjStartNfaWithStates_0(8, 42, 2);\r
+ else if ((active0 & 0x100000000000L) != 0L)\r
+ return jjStartNfaWithStates_0(8, 44, 2);\r
+ break;\r
+ default :\r
+ break;\r
+ }\r
+ return jjStartNfa_0(7, active0, 0L);\r
+}\r
+private int jjMoveStringLiteralDfa9_0(long old0, long active0)\r
+{\r
+ if (((active0 &= old0)) == 0L)\r
+ return jjStartNfa_0(7, old0, 0L);\r
+ try { curChar = input_stream.readChar(); }\r
+ catch(java.io.IOException e) {\r
+ jjStopStringLiteralDfa_0(8, active0, 0L);\r
+ return 9;\r
+ }\r
+ switch(curChar)\r
+ {\r
+ case 101:\r
+ if ((active0 & 0x4000000000000L) != 0L)\r
+ return jjStartNfaWithStates_0(9, 50, 2);\r
+ return jjMoveStringLiteralDfa10_0(active0, 0x40000000000000L);\r
+ case 108:\r
+ return jjMoveStringLiteralDfa10_0(active0, 0x2000L);\r
+ case 110:\r
+ if ((active0 & 0x4000L) != 0L)\r
+ return jjStartNfaWithStates_0(9, 14, 2);\r
+ break;\r
+ case 111:\r
+ return jjMoveStringLiteralDfa10_0(active0, 0x10000000000L);\r
+ case 116:\r
+ return jjMoveStringLiteralDfa10_0(active0, 0x40000000L);\r
+ default :\r
+ break;\r
+ }\r
+ return jjStartNfa_0(8, active0, 0L);\r
+}\r
+private int jjMoveStringLiteralDfa10_0(long old0, long active0)\r
+{\r
+ if (((active0 &= old0)) == 0L)\r
+ return jjStartNfa_0(8, old0, 0L);\r
+ try { curChar = input_stream.readChar(); }\r
+ catch(java.io.IOException e) {\r
+ jjStopStringLiteralDfa_0(9, active0, 0L);\r
+ return 10;\r
+ }\r
+ switch(curChar)\r
+ {\r
+ case 100:\r
+ return jjMoveStringLiteralDfa11_0(active0, 0x40000000000000L);\r
+ case 101:\r
+ if ((active0 & 0x2000L) != 0L)\r
+ return jjStartNfaWithStates_0(10, 13, 2);\r
+ return jjMoveStringLiteralDfa11_0(active0, 0x40000000L);\r
+ case 110:\r
+ if ((active0 & 0x10000000000L) != 0L)\r
+ return jjStartNfaWithStates_0(10, 40, 2);\r
+ break;\r
+ default :\r
+ break;\r
+ }\r
+ return jjStartNfa_0(9, active0, 0L);\r
+}\r
+private int jjMoveStringLiteralDfa11_0(long old0, long active0)\r
+{\r
+ if (((active0 &= old0)) == 0L)\r
+ return jjStartNfa_0(9, old0, 0L);\r
+ try { curChar = input_stream.readChar(); }\r
+ catch(java.io.IOException e) {\r
+ jjStopStringLiteralDfa_0(10, active0, 0L);\r
+ return 11;\r
+ }\r
+ switch(curChar)\r
+ {\r
+ case 98:\r
+ return jjMoveStringLiteralDfa12_0(active0, 0x40000000000000L);\r
+ case 100:\r
+ if ((active0 & 0x40000000L) != 0L)\r
+ return jjStartNfaWithStates_0(11, 30, 2);\r
+ break;\r
+ default :\r
+ break;\r
+ }\r
+ return jjStartNfa_0(10, active0, 0L);\r
+}\r
+private int jjMoveStringLiteralDfa12_0(long old0, long active0)\r
+{\r
+ if (((active0 &= old0)) == 0L)\r
+ return jjStartNfa_0(10, old0, 0L);\r
+ try { curChar = input_stream.readChar(); }\r
+ catch(java.io.IOException e) {\r
+ jjStopStringLiteralDfa_0(11, active0, 0L);\r
+ return 12;\r
+ }\r
+ switch(curChar)\r
+ {\r
+ case 121:\r
+ if ((active0 & 0x40000000000000L) != 0L)\r
+ return jjStartNfaWithStates_0(12, 54, 2);\r
+ break;\r
+ default :\r
+ break;\r
+ }\r
+ return jjStartNfa_0(11, active0, 0L);\r
+}\r
+private int jjStartNfaWithStates_0(int pos, int kind, int state)\r
+{\r
+ jjmatchedKind = kind;\r
+ jjmatchedPos = pos;\r
+ try { curChar = input_stream.readChar(); }\r
+ catch(java.io.IOException e) { return pos + 1; }\r
+ return jjMoveNfa_0(state, pos + 1);\r
+}\r
+static final long[] jjbitVec0 = {
+ 0x0L, 0x0L, 0xffffffffffffffffL, 0xffffffffffffffffL
+};\r
+private int jjMoveNfa_0(int startState, int curPos)\r
+{\r
+ int startsAt = 0;\r
+ jjnewStateCnt = 31;\r
+ int i = 1;\r
+ jjstateSet[0] = startState;\r
+ int kind = 0x7fffffff;\r
+ for (;;)\r
+ {\r
+ if (++jjround == 0x7fffffff)\r
+ ReInitRounds();\r
+ if (curChar < 64)\r
+ {\r
+ long l = 1L << curChar;\r
+ do\r
+ {\r
+ switch(jjstateSet[--i])\r
+ {\r
+ case 13:\r
+ if (curChar == 47)\r
+ {\r
+ if (kind > 3)\r
+ kind = 3;\r
+ jjCheckNAdd(20);\r
+ }\r
+ else if (curChar == 42)\r
+ jjCheckNAddStates(0, 2);\r
+ break;\r
+ case 0:\r
+ if ((0x3ff000000000000L & l) != 0L)\r
+ {\r
+ if (kind > 92)\r
+ kind = 92;\r
+ jjCheckNAddStates(3, 7);\r
+ }\r
+ else if ((0x100002600L & l) != 0L)\r
+ {\r
+ if (kind > 1)\r
+ kind = 1;\r
+ }\r
+ else if (curChar == 47)\r
+ jjAddStates(8, 9);\r
+ else if (curChar == 46)\r
+ jjCheckNAdd(9);\r
+ else if (curChar == 34)\r
+ jjCheckNAddStates(10, 12);\r
+ break;\r
+ case 2:\r
+ if ((0x3ff000000000000L & l) == 0L)\r
+ break;\r
+ if (kind > 90)\r
+ kind = 90;\r
+ jjstateSet[jjnewStateCnt++] = 2;\r
+ break;\r
+ case 3:\r
+ if (curChar == 34)\r
+ jjCheckNAddStates(10, 12);\r
+ break;\r
+ case 4:\r
+ if ((0xfffffffbfffffbffL & l) != 0L)\r
+ jjCheckNAddStates(10, 12);\r
+ break;\r
+ case 6:\r
+ if ((0xfffffffffffffbffL & l) != 0L)\r
+ jjCheckNAddStates(10, 12);\r
+ break;\r
+ case 7:\r
+ if (curChar == 34 && kind > 91)\r
+ kind = 91;\r
+ break;\r
+ case 8:\r
+ if (curChar == 46)\r
+ jjCheckNAdd(9);\r
+ break;\r
+ case 9:\r
+ if ((0x3ff000000000000L & l) == 0L)\r
+ break;\r
+ if (kind > 93)\r
+ kind = 93;\r
+ jjCheckNAddTwoStates(9, 10);\r
+ break;\r
+ case 11:\r
+ if ((0x3ff000000000000L & l) == 0L)\r
+ break;\r
+ if (kind > 93)\r
+ kind = 93;\r
+ jjstateSet[jjnewStateCnt++] = 11;\r
+ break;\r
+ case 12:\r
+ if (curChar == 47)\r
+ jjAddStates(8, 9);\r
+ break;\r
+ case 14:\r
+ if ((0xfffffbffffffffffL & l) != 0L)\r
+ jjCheckNAddStates(0, 2);\r
+ break;\r
+ case 15:\r
+ if (curChar == 42)\r
+ jjstateSet[jjnewStateCnt++] = 16;\r
+ break;\r
+ case 16:\r
+ if ((0xffff7fffffffffffL & l) != 0L)\r
+ jjCheckNAddStates(0, 2);\r
+ break;\r
+ case 17:\r
+ if (curChar == 47 && kind > 2)\r
+ kind = 2;\r
+ break;\r
+ case 18:\r
+ if (curChar == 42)\r
+ jjstateSet[jjnewStateCnt++] = 17;\r
+ break;\r
+ case 19:\r
+ if (curChar != 47)\r
+ break;\r
+ if (kind > 3)\r
+ kind = 3;\r
+ jjCheckNAdd(20);\r
+ break;\r
+ case 20:\r
+ if ((0xfffffffffffffbffL & l) == 0L)\r
+ break;\r
+ if (kind > 3)\r
+ kind = 3;\r
+ jjCheckNAdd(20);\r
+ break;\r
+ case 21:\r
+ if ((0x3ff000000000000L & l) == 0L)\r
+ break;\r
+ if (kind > 92)\r
+ kind = 92;\r
+ jjCheckNAddStates(3, 7);\r
+ break;\r
+ case 22:\r
+ if ((0x3ff000000000000L & l) == 0L)\r
+ break;\r
+ if (kind > 92)\r
+ kind = 92;\r
+ jjCheckNAdd(22);\r
+ break;\r
+ case 23:\r
+ if ((0x3ff000000000000L & l) != 0L)\r
+ jjCheckNAddTwoStates(23, 24);\r
+ break;\r
+ case 24:\r
+ if (curChar != 46)\r
+ break;\r
+ if (kind > 93)\r
+ kind = 93;\r
+ jjCheckNAddTwoStates(25, 26);\r
+ break;\r
+ case 25:\r
+ if ((0x3ff000000000000L & l) == 0L)\r
+ break;\r
+ if (kind > 93)\r
+ kind = 93;\r
+ jjCheckNAddTwoStates(25, 26);\r
+ break;\r
+ case 27:\r
+ if ((0x3ff000000000000L & l) == 0L)\r
+ break;\r
+ if (kind > 93)\r
+ kind = 93;\r
+ jjstateSet[jjnewStateCnt++] = 27;\r
+ break;\r
+ case 28:\r
+ if ((0x3ff000000000000L & l) != 0L)\r
+ jjCheckNAddTwoStates(28, 29);\r
+ break;\r
+ case 30:\r
+ if ((0x3ff000000000000L & l) == 0L)\r
+ break;\r
+ if (kind > 93)\r
+ kind = 93;\r
+ jjstateSet[jjnewStateCnt++] = 30;\r
+ break;\r
+ default : break;\r
+ }\r
+ } while(i != startsAt);\r
+ }\r
+ else if (curChar < 128)\r
+ {\r
+ long l = 1L << (curChar & 077);\r
+ do\r
+ {\r
+ switch(jjstateSet[--i])\r
+ {\r
+ case 0:\r
+ case 2:\r
+ if ((0x7fffffe87fffffeL & l) == 0L)\r
+ break;\r
+ if (kind > 90)\r
+ kind = 90;\r
+ jjCheckNAdd(2);\r
+ break;\r
+ case 4:\r
+ if ((0xffffffffefffffffL & l) != 0L)\r
+ jjCheckNAddStates(10, 12);\r
+ break;\r
+ case 5:\r
+ if (curChar == 92)\r
+ jjstateSet[jjnewStateCnt++] = 6;\r
+ break;\r
+ case 6:\r
+ jjCheckNAddStates(10, 12);\r
+ break;\r
+ case 10:\r
+ if ((0x2000000020L & l) != 0L)\r
+ jjstateSet[jjnewStateCnt++] = 11;\r
+ break;\r
+ case 14:\r
+ case 16:\r
+ jjCheckNAddStates(0, 2);\r
+ break;\r
+ case 20:\r
+ if (kind > 3)\r
+ kind = 3;\r
+ jjstateSet[jjnewStateCnt++] = 20;\r
+ break;\r
+ case 26:\r
+ if ((0x2000000020L & l) != 0L)\r
+ jjstateSet[jjnewStateCnt++] = 27;\r
+ break;\r
+ case 29:\r
+ if ((0x2000000020L & l) != 0L)\r
+ jjstateSet[jjnewStateCnt++] = 30;\r
+ break;\r
+ default : break;\r
+ }\r
+ } while(i != startsAt);\r
+ }\r
+ else\r
+ {\r
+ int i2 = (curChar & 0xff) >> 6;\r
+ long l2 = 1L << (curChar & 077);\r
+ do\r
+ {\r
+ switch(jjstateSet[--i])\r
+ {\r
+ case 4:\r
+ case 6:\r
+ if ((jjbitVec0[i2] & l2) != 0L)\r
+ jjCheckNAddStates(10, 12);\r
+ break;\r
+ case 14:\r
+ case 16:\r
+ if ((jjbitVec0[i2] & l2) != 0L)\r
+ jjCheckNAddStates(0, 2);\r
+ break;\r
+ case 20:\r
+ if ((jjbitVec0[i2] & l2) == 0L)\r
+ break;\r
+ if (kind > 3)\r
+ kind = 3;\r
+ jjstateSet[jjnewStateCnt++] = 20;\r
+ break;\r
+ default : break;\r
+ }\r
+ } while(i != startsAt);\r
+ }\r
+ if (kind != 0x7fffffff)\r
+ {\r
+ jjmatchedKind = kind;\r
+ jjmatchedPos = curPos;\r
+ kind = 0x7fffffff;\r
+ }\r
+ ++curPos;\r
+ if ((i = jjnewStateCnt) == (startsAt = 31 - (jjnewStateCnt = startsAt)))\r
+ return curPos;\r
+ try { curChar = input_stream.readChar(); }\r
+ catch(java.io.IOException e) { return curPos; }\r
+ }\r
+}\r
+static final int[] jjnextStates = {
+ 14, 15, 18, 22, 23, 24, 28, 29, 13, 19, 4, 5, 7,
+};\r
+\r
+/** Token literal values. */\r
+public static final String[] jjstrLiteralImages = {\r
+"", null, null, null, "\141\154\147\157\162\151\164\150\155", \r
+"\144\151\163\143\162\145\164\145", "\146\141\154\163\145", "\155\157\144\145\154", \r
+"\162\145\144\145\143\154\141\162\145", "\141\156\144", "\145\141\143\150", "\146\151\156\141\154", "\156\157\164", \r
+"\162\145\160\154\141\143\145\141\142\154\145", "\141\156\156\157\164\141\164\151\157\156", "\145\154\163\145", \r
+"\146\154\157\167", "\157\160\145\162\141\164\157\162", "\162\145\164\165\162\156", \r
+"\141\163\163\145\162\164", "\145\154\163\145\151\146", "\146\157\162", "\157\162", \r
+"\163\164\162\145\141\155", "\142\154\157\143\153", "\145\154\163\145\167\150\145\156", \r
+"\146\165\156\143\164\151\157\156", "\157\165\164\145\162", "\164\150\145\156", "\142\162\145\141\153", \r
+"\145\156\143\141\160\163\165\154\141\164\145\144", "\151\146", "\157\165\164\160\165\164", "\164\162\165\145", \r
+"\143\154\141\163\163", "\145\156\144", "\151\155\160\157\162\164", "\160\141\143\153\141\147\145", \r
+"\164\171\160\145", "\143\157\156\156\145\143\164", \r
+"\145\156\165\155\145\162\141\164\151\157\156", "\151\156", "\160\141\162\141\155\145\164\145\162", "\167\150\145\156", \r
+"\143\157\156\156\145\143\164\157\162", "\145\161\165\141\164\151\157\156", "\151\156\151\164\151\141\154", \r
+"\160\141\162\164\151\141\154", "\167\150\151\154\145", "\143\157\156\163\164\141\156\164", \r
+"\145\170\160\141\156\144\141\142\154\145", "\151\156\156\145\162", "\160\162\157\164\145\143\164\145\144", \r
+"\167\151\164\150\151\156", "\143\157\156\163\164\162\141\151\156\145\144\142\171", \r
+"\145\170\164\145\156\144\163", "\151\156\160\165\164", "\160\165\142\154\151\143", "\144\145\162", \r
+"\145\170\164\145\162\156\141\154", "\154\157\157\160", "\162\145\143\157\162\144", "\50", "\51", "\173", "\175", \r
+"\133", "\135", "\56", "\72", "\73", "\54", "\74", "\74\75", "\76", "\76\75", \r
+"\75\75", "\74\76", "\53", "\55", "\56\53", "\56\55", "\52", "\57", "\56\52", "\56\57", \r
+"\136", "\56\136", "\75", "\72\75", null, null, null, null, };\r
+\r
+/** Lexer state names. */\r
+public static final String[] lexStateNames = {\r
+ "DEFAULT",\r
+};\r
+static final long[] jjtoToken = {
+ 0xfffffffffffffff1L, 0x3fffffffL,
+};\r
+static final long[] jjtoSkip = {
+ 0xeL, 0x0L,
+};\r
+protected SimpleCharStream input_stream;\r
+private final int[] jjrounds = new int[31];\r
+private final int[] jjstateSet = new int[62];\r
+private final StringBuilder jjimage = new StringBuilder();\r
+private StringBuilder image = jjimage;\r
+private int jjimageLen;\r
+private int lengthOfMatch;\r
+protected char curChar;\r
+/** Constructor. */\r
+public ExpressionParserTokenManager(SimpleCharStream stream){\r
+ if (SimpleCharStream.staticFlag)\r
+ throw new Error("ERROR: Cannot use a static CharStream class with a non-static lexical analyzer.");\r
+ input_stream = stream;\r
+}\r
+\r
+/** Constructor. */\r
+public ExpressionParserTokenManager(SimpleCharStream stream, int lexState){\r
+ this(stream);\r
+ SwitchTo(lexState);\r
+}\r
+\r
+/** Reinitialise parser. */\r
+public void ReInit(SimpleCharStream stream)\r
+{\r
+ jjmatchedPos = jjnewStateCnt = 0;\r
+ curLexState = defaultLexState;\r
+ input_stream = stream;\r
+ ReInitRounds();\r
+}\r
+private void ReInitRounds()\r
+{\r
+ int i;\r
+ jjround = 0x80000001;\r
+ for (i = 31; i-- > 0;)\r
+ jjrounds[i] = 0x80000000;\r
+}\r
+\r
+/** Reinitialise parser. */\r
+public void ReInit(SimpleCharStream stream, int lexState)\r
+{\r
+ ReInit(stream);\r
+ SwitchTo(lexState);\r
+}\r
+\r
+/** Switch to specified lex state. */\r
+public void SwitchTo(int lexState)\r
+{\r
+ if (lexState >= 1 || lexState < 0)\r
+ throw new TokenMgrError("Error: Ignoring invalid lexical state : " + lexState + ". State unchanged.", TokenMgrError.INVALID_LEXICAL_STATE);\r
+ else\r
+ curLexState = lexState;\r
+}\r
+\r
+protected Token jjFillToken()\r
+{\r
+ final Token t;\r
+ final String curTokenImage;\r
+ final int beginLine;\r
+ final int endLine;\r
+ final int beginColumn;\r
+ final int endColumn;\r
+ String im = jjstrLiteralImages[jjmatchedKind];\r
+ curTokenImage = (im == null) ? input_stream.GetImage() : im;\r
+ beginLine = input_stream.getBeginLine();\r
+ beginColumn = input_stream.getBeginColumn();\r
+ endLine = input_stream.getEndLine();\r
+ endColumn = input_stream.getEndColumn();\r
+ t = Token.newToken(jjmatchedKind);\r
+ t.kind = jjmatchedKind;\r
+ t.image = curTokenImage;\r
+\r
+ t.beginLine = beginLine;\r
+ t.endLine = endLine;\r
+ t.beginColumn = beginColumn;\r
+ t.endColumn = endColumn;\r
+\r
+ return t;\r
+}\r
+\r
+int curLexState = 0;\r
+int defaultLexState = 0;\r
+int jjnewStateCnt;\r
+int jjround;\r
+int jjmatchedPos;\r
+int jjmatchedKind;\r
+\r
+/** Get the next Token. */\r
+public Token getNextToken() \r
+{\r
+ Token matchedToken;\r
+ int curPos = 0;\r
+\r
+ EOFLoop :
+ for (;;)\r
+ {\r
+ try\r
+ {\r
+ curChar = input_stream.BeginToken();\r
+ }\r
+ catch(java.io.IOException e)\r
+ {\r
+ jjmatchedKind = 0;\r
+ matchedToken = jjFillToken();\r
+ return matchedToken;\r
+ }\r
+ image = jjimage;\r
+ image.setLength(0);\r
+ jjimageLen = 0;\r
+\r
+ jjmatchedKind = 0x7fffffff;\r
+ jjmatchedPos = 0;\r
+ curPos = jjMoveStringLiteralDfa0_0();\r
+ if (jjmatchedKind != 0x7fffffff)\r
+ {\r
+ if (jjmatchedPos + 1 < curPos)\r
+ input_stream.backup(curPos - jjmatchedPos - 1);\r
+ if ((jjtoToken[jjmatchedKind >> 6] & (1L << (jjmatchedKind & 077))) != 0L)\r
+ {\r
+ matchedToken = jjFillToken();\r
+ TokenLexicalActions(matchedToken);\r
+ return matchedToken;\r
+ }\r
+ else\r
+ {\r
+ continue EOFLoop;\r
+ }\r
+ }\r
+ int error_line = input_stream.getEndLine();\r
+ int error_column = input_stream.getEndColumn();\r
+ String error_after = null;\r
+ boolean EOFSeen = false;\r
+ try { input_stream.readChar(); input_stream.backup(1); }\r
+ catch (java.io.IOException e1) {\r
+ EOFSeen = true;\r
+ error_after = curPos <= 1 ? "" : input_stream.GetImage();\r
+ if (curChar == '\n' || curChar == '\r') {\r
+ error_line++;\r
+ error_column = 0;\r
+ }\r
+ else\r
+ error_column++;\r
+ }\r
+ if (!EOFSeen) {\r
+ input_stream.backup(1);\r
+ error_after = curPos <= 1 ? "" : input_stream.GetImage();\r
+ }\r
+ throw new TokenMgrError(EOFSeen, curLexState, error_line, error_column, error_after, curChar, TokenMgrError.LEXICAL_ERROR);\r
+ }\r
+}\r
+\r
+void TokenLexicalActions(Token matchedToken)\r
+{\r
+ switch(jjmatchedKind)\r
+ {\r
+ case 91 :\r
+ image.append(input_stream.GetSuffix(jjimageLen + (lengthOfMatch = jjmatchedPos + 1)));\r
+ matchedToken.image = matchedToken.image.substring(1,matchedToken.image.length()-1);\r
+ break;\r
+ default :\r
+ break;\r
+ }\r
+}\r
+private void jjCheckNAdd(int state)\r
+{\r
+ if (jjrounds[state] != jjround)\r
+ {\r
+ jjstateSet[jjnewStateCnt++] = state;\r
+ jjrounds[state] = jjround;\r
+ }\r
+}\r
+private void jjAddStates(int start, int end)\r
+{\r
+ do {\r
+ jjstateSet[jjnewStateCnt++] = jjnextStates[start];\r
+ } while (start++ != end);\r
+}\r
+private void jjCheckNAddTwoStates(int state1, int state2)\r
+{\r
+ jjCheckNAdd(state1);\r
+ jjCheckNAdd(state2);\r
+}\r
+\r
+private void jjCheckNAddStates(int start, int end)\r
+{\r
+ do {\r
+ jjCheckNAdd(jjnextStates[start]);\r
+ } while (start++ != end);\r
+}\r
+\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2010 Association for Decentralized Information Management\r
+ * in Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.expressionParser;\r
+\r
+/**\r
+ * This exception is thrown when parse errors are encountered.\r
+ * You can explicitly create objects of this exception type by\r
+ * calling the method generateParseException in the generated\r
+ * parser.\r
+ *\r
+ * You can modify this class to customize your error reporting\r
+ * mechanisms so long as you retain the public fields.\r
+ */\r
+public class ParseException extends Exception {\r
+\r
+ /**\r
+ * The version identifier for this Serializable class.\r
+ * Increment only if the <i>serialized</i> form of the\r
+ * class changes.\r
+ */\r
+ private static final long serialVersionUID = 1L;\r
+\r
+ /**\r
+ * This constructor is used by the method "generateParseException"\r
+ * in the generated parser. Calling this constructor generates\r
+ * a new object of this type with the fields "currentToken",\r
+ * "expectedTokenSequences", and "tokenImage" set.\r
+ */\r
+ public ParseException(Token currentTokenVal,\r
+ int[][] expectedTokenSequencesVal,\r
+ String[] tokenImageVal\r
+ )\r
+ {\r
+ super(initialise(currentTokenVal, expectedTokenSequencesVal, tokenImageVal));\r
+ currentToken = currentTokenVal;\r
+ expectedTokenSequences = expectedTokenSequencesVal;\r
+ tokenImage = tokenImageVal;\r
+ }\r
+\r
+ /**\r
+ * The following constructors are for use by you for whatever\r
+ * purpose you can think of. Constructing the exception in this\r
+ * manner makes the exception behave in the normal way - i.e., as\r
+ * documented in the class "Throwable". The fields "errorToken",\r
+ * "expectedTokenSequences", and "tokenImage" do not contain\r
+ * relevant information. The JavaCC generated code does not use\r
+ * these constructors.\r
+ */\r
+\r
+ public ParseException() {\r
+ super();\r
+ }\r
+\r
+ /** Constructor with message. */\r
+ public ParseException(String message) {\r
+ super(message);\r
+ }\r
+\r
+\r
+ /**\r
+ * This is the last token that has been consumed successfully. If\r
+ * this object has been created due to a parse error, the token\r
+ * followng this token will (therefore) be the first error token.\r
+ */\r
+ public Token currentToken;\r
+\r
+ /**\r
+ * Each entry in this array is an array of integers. Each array\r
+ * of integers represents a sequence of tokens (by their ordinal\r
+ * values) that is expected at this point of the parse.\r
+ */\r
+ public int[][] expectedTokenSequences;\r
+\r
+ /**\r
+ * This is a reference to the "tokenImage" array of the generated\r
+ * parser within which the parse error occurred. This array is\r
+ * defined in the generated ...Constants interface.\r
+ */\r
+ public String[] tokenImage;\r
+\r
+ /**\r
+ * It uses "currentToken" and "expectedTokenSequences" to generate a parse\r
+ * error message and returns it. If this object has been created\r
+ * due to a parse error, and you do not catch it (it gets thrown\r
+ * from the parser) the correct error message\r
+ * gets displayed.\r
+ */\r
+ private static String initialise(Token currentToken,\r
+ int[][] expectedTokenSequences,\r
+ String[] tokenImage) {\r
+ String eol = System.getProperty("line.separator", "\n");\r
+ StringBuffer expected = new StringBuffer();\r
+ int maxSize = 0;\r
+ for (int i = 0; i < expectedTokenSequences.length; i++) {\r
+ if (maxSize < expectedTokenSequences[i].length) {\r
+ maxSize = expectedTokenSequences[i].length;\r
+ }\r
+ for (int j = 0; j < expectedTokenSequences[i].length; j++) {\r
+ expected.append(tokenImage[expectedTokenSequences[i][j]]).append(' ');\r
+ }\r
+ if (expectedTokenSequences[i][expectedTokenSequences[i].length - 1] != 0) {\r
+ expected.append("...");\r
+ }\r
+ expected.append(eol).append(" ");\r
+ }\r
+ String retval = "Encountered \"";\r
+ Token tok = currentToken.next;\r
+ for (int i = 0; i < maxSize; i++) {\r
+ if (i != 0) retval += " ";\r
+ if (tok.kind == 0) {\r
+ retval += tokenImage[0];\r
+ break;\r
+ }\r
+ retval += " " + tokenImage[tok.kind];\r
+ retval += " \"";\r
+ retval += add_escapes(tok.image);\r
+ retval += " \"";\r
+ tok = tok.next;\r
+ }\r
+ retval += "\" at line " + currentToken.next.beginLine + ", column " + currentToken.next.beginColumn;\r
+ retval += "." + eol;\r
+ if (expectedTokenSequences.length == 1) {\r
+ retval += "Was expecting:" + eol + " ";\r
+ } else {\r
+ retval += "Was expecting one of:" + eol + " ";\r
+ }\r
+ retval += expected.toString();\r
+ return retval;\r
+ }\r
+\r
+ /**\r
+ * The end of line string for this machine.\r
+ */\r
+ protected String eol = System.getProperty("line.separator", "\n");\r
+\r
+ /**\r
+ * Used to convert raw characters to their escaped version\r
+ * when these raw version cannot be used as part of an ASCII\r
+ * string literal.\r
+ */\r
+ static String add_escapes(String str) {\r
+ StringBuffer retval = new StringBuffer();\r
+ char ch;\r
+ for (int i = 0; i < str.length(); i++) {\r
+ switch (str.charAt(i))\r
+ {\r
+ case 0 :\r
+ continue;\r
+ case '\b':\r
+ retval.append("\\b");\r
+ continue;\r
+ case '\t':\r
+ retval.append("\\t");\r
+ continue;\r
+ case '\n':\r
+ retval.append("\\n");\r
+ continue;\r
+ case '\f':\r
+ retval.append("\\f");\r
+ continue;\r
+ case '\r':\r
+ retval.append("\\r");\r
+ continue;\r
+ case '\"':\r
+ retval.append("\\\"");\r
+ continue;\r
+ case '\'':\r
+ retval.append("\\\'");\r
+ continue;\r
+ case '\\':\r
+ retval.append("\\\\");\r
+ continue;\r
+ default:\r
+ if ((ch = str.charAt(i)) < 0x20 || ch > 0x7e) {\r
+ String s = "0000" + Integer.toString(ch, 16);\r
+ retval.append("\\u" + s.substring(s.length() - 4, s.length()));\r
+ } else {\r
+ retval.append(ch);\r
+ }\r
+ continue;\r
+ }\r
+ }\r
+ return retval.toString();\r
+ }\r
+\r
+}\r
+/* JavaCC - OriginalChecksum=65dcbd31a9e7a053287ebf70e24f8b8f (do not edit this line) */\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2010 Association for Decentralized Information Management\r
+ * in Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.expressionParser;\r
+\r
+/**\r
+ * An implementation of interface CharStream, where the stream is assumed to\r
+ * contain only ASCII characters (without unicode processing).\r
+ */\r
+\r
+public class SimpleCharStream\r
+{\r
+/** Whether parser is static. */\r
+ public static final boolean staticFlag = false;\r
+ int bufsize;\r
+ int available;\r
+ int tokenBegin;\r
+/** Position in buffer. */\r
+ public int bufpos = -1;\r
+ protected int bufline[];\r
+ protected int bufcolumn[];\r
+\r
+ protected int column = 0;\r
+ protected int line = 1;\r
+\r
+ protected boolean prevCharIsCR = false;\r
+ protected boolean prevCharIsLF = false;\r
+\r
+ protected java.io.Reader inputStream;\r
+\r
+ protected char[] buffer;\r
+ protected int maxNextCharInd = 0;\r
+ protected int inBuf = 0;\r
+ protected int tabSize = 8;\r
+\r
+ protected void setTabSize(int i) { tabSize = i; }\r
+ protected int getTabSize(int i) { return tabSize; }\r
+\r
+\r
+ protected void ExpandBuff(boolean wrapAround)\r
+ {\r
+ char[] newbuffer = new char[bufsize + 2048];\r
+ int newbufline[] = new int[bufsize + 2048];\r
+ int newbufcolumn[] = new int[bufsize + 2048];\r
+\r
+ try\r
+ {\r
+ if (wrapAround)\r
+ {\r
+ System.arraycopy(buffer, tokenBegin, newbuffer, 0, bufsize - tokenBegin);\r
+ System.arraycopy(buffer, 0, newbuffer, bufsize - tokenBegin, bufpos);\r
+ buffer = newbuffer;\r
+\r
+ System.arraycopy(bufline, tokenBegin, newbufline, 0, bufsize - tokenBegin);\r
+ System.arraycopy(bufline, 0, newbufline, bufsize - tokenBegin, bufpos);\r
+ bufline = newbufline;\r
+\r
+ System.arraycopy(bufcolumn, tokenBegin, newbufcolumn, 0, bufsize - tokenBegin);\r
+ System.arraycopy(bufcolumn, 0, newbufcolumn, bufsize - tokenBegin, bufpos);\r
+ bufcolumn = newbufcolumn;\r
+\r
+ maxNextCharInd = (bufpos += (bufsize - tokenBegin));\r
+ }\r
+ else\r
+ {\r
+ System.arraycopy(buffer, tokenBegin, newbuffer, 0, bufsize - tokenBegin);\r
+ buffer = newbuffer;\r
+\r
+ System.arraycopy(bufline, tokenBegin, newbufline, 0, bufsize - tokenBegin);\r
+ bufline = newbufline;\r
+\r
+ System.arraycopy(bufcolumn, tokenBegin, newbufcolumn, 0, bufsize - tokenBegin);\r
+ bufcolumn = newbufcolumn;\r
+\r
+ maxNextCharInd = (bufpos -= tokenBegin);\r
+ }\r
+ }\r
+ catch (Throwable t)\r
+ {\r
+ throw new Error(t.getMessage());\r
+ }\r
+\r
+\r
+ bufsize += 2048;\r
+ available = bufsize;\r
+ tokenBegin = 0;\r
+ }\r
+\r
+ protected void FillBuff() throws java.io.IOException\r
+ {\r
+ if (maxNextCharInd == available)\r
+ {\r
+ if (available == bufsize)\r
+ {\r
+ if (tokenBegin > 2048)\r
+ {\r
+ bufpos = maxNextCharInd = 0;\r
+ available = tokenBegin;\r
+ }\r
+ else if (tokenBegin < 0)\r
+ bufpos = maxNextCharInd = 0;\r
+ else\r
+ ExpandBuff(false);\r
+ }\r
+ else if (available > tokenBegin)\r
+ available = bufsize;\r
+ else if ((tokenBegin - available) < 2048)\r
+ ExpandBuff(true);\r
+ else\r
+ available = tokenBegin;\r
+ }\r
+\r
+ int i;\r
+ try {\r
+ if ((i = inputStream.read(buffer, maxNextCharInd, available - maxNextCharInd)) == -1)\r
+ {\r
+ inputStream.close();\r
+ throw new java.io.IOException();\r
+ }\r
+ else\r
+ maxNextCharInd += i;\r
+ return;\r
+ }\r
+ catch(java.io.IOException e) {\r
+ --bufpos;\r
+ backup(0);\r
+ if (tokenBegin == -1)\r
+ tokenBegin = bufpos;\r
+ throw e;\r
+ }\r
+ }\r
+\r
+/** Start. */\r
+ public char BeginToken() throws java.io.IOException\r
+ {\r
+ tokenBegin = -1;\r
+ char c = readChar();\r
+ tokenBegin = bufpos;\r
+\r
+ return c;\r
+ }\r
+\r
+ protected void UpdateLineColumn(char c)\r
+ {\r
+ column++;\r
+\r
+ if (prevCharIsLF)\r
+ {\r
+ prevCharIsLF = false;\r
+ line += (column = 1);\r
+ }\r
+ else if (prevCharIsCR)\r
+ {\r
+ prevCharIsCR = false;\r
+ if (c == '\n')\r
+ {\r
+ prevCharIsLF = true;\r
+ }\r
+ else\r
+ line += (column = 1);\r
+ }\r
+\r
+ switch (c)\r
+ {\r
+ case '\r' :\r
+ prevCharIsCR = true;\r
+ break;\r
+ case '\n' :\r
+ prevCharIsLF = true;\r
+ break;\r
+ case '\t' :\r
+ column--;\r
+ column += (tabSize - (column % tabSize));\r
+ break;\r
+ default :\r
+ break;\r
+ }\r
+\r
+ bufline[bufpos] = line;\r
+ bufcolumn[bufpos] = column;\r
+ }\r
+\r
+/** Read a character. */\r
+ public char readChar() throws java.io.IOException\r
+ {\r
+ if (inBuf > 0)\r
+ {\r
+ --inBuf;\r
+\r
+ if (++bufpos == bufsize)\r
+ bufpos = 0;\r
+\r
+ return buffer[bufpos];\r
+ }\r
+\r
+ if (++bufpos >= maxNextCharInd)\r
+ FillBuff();\r
+\r
+ char c = buffer[bufpos];\r
+\r
+ UpdateLineColumn(c);\r
+ return c;\r
+ }\r
+\r
+ @Deprecated\r
+ /**\r
+ * @deprecated\r
+ * @see #getEndColumn\r
+ */\r
+\r
+ public int getColumn() {\r
+ return bufcolumn[bufpos];\r
+ }\r
+\r
+ @Deprecated\r
+ /**\r
+ * @deprecated\r
+ * @see #getEndLine\r
+ */\r
+\r
+ public int getLine() {\r
+ return bufline[bufpos];\r
+ }\r
+\r
+ /** Get token end column number. */\r
+ public int getEndColumn() {\r
+ return bufcolumn[bufpos];\r
+ }\r
+\r
+ /** Get token end line number. */\r
+ public int getEndLine() {\r
+ return bufline[bufpos];\r
+ }\r
+\r
+ /** Get token beginning column number. */\r
+ public int getBeginColumn() {\r
+ return bufcolumn[tokenBegin];\r
+ }\r
+\r
+ /** Get token beginning line number. */\r
+ public int getBeginLine() {\r
+ return bufline[tokenBegin];\r
+ }\r
+\r
+/** Backup a number of characters. */\r
+ public void backup(int amount) {\r
+\r
+ inBuf += amount;\r
+ if ((bufpos -= amount) < 0)\r
+ bufpos += bufsize;\r
+ }\r
+\r
+ /** Constructor. */\r
+ public SimpleCharStream(java.io.Reader dstream, int startline,\r
+ int startcolumn, int buffersize)\r
+ {\r
+ inputStream = dstream;\r
+ line = startline;\r
+ column = startcolumn - 1;\r
+\r
+ available = bufsize = buffersize;\r
+ buffer = new char[buffersize];\r
+ bufline = new int[buffersize];\r
+ bufcolumn = new int[buffersize];\r
+ }\r
+\r
+ /** Constructor. */\r
+ public SimpleCharStream(java.io.Reader dstream, int startline,\r
+ int startcolumn)\r
+ {\r
+ this(dstream, startline, startcolumn, 4096);\r
+ }\r
+\r
+ /** Constructor. */\r
+ public SimpleCharStream(java.io.Reader dstream)\r
+ {\r
+ this(dstream, 1, 1, 4096);\r
+ }\r
+\r
+ /** Reinitialise. */\r
+ public void ReInit(java.io.Reader dstream, int startline,\r
+ int startcolumn, int buffersize)\r
+ {\r
+ inputStream = dstream;\r
+ line = startline;\r
+ column = startcolumn - 1;\r
+\r
+ if (buffer == null || buffersize != buffer.length)\r
+ {\r
+ available = bufsize = buffersize;\r
+ buffer = new char[buffersize];\r
+ bufline = new int[buffersize];\r
+ bufcolumn = new int[buffersize];\r
+ }\r
+ prevCharIsLF = prevCharIsCR = false;\r
+ tokenBegin = inBuf = maxNextCharInd = 0;\r
+ bufpos = -1;\r
+ }\r
+\r
+ /** Reinitialise. */\r
+ public void ReInit(java.io.Reader dstream, int startline,\r
+ int startcolumn)\r
+ {\r
+ ReInit(dstream, startline, startcolumn, 4096);\r
+ }\r
+\r
+ /** Reinitialise. */\r
+ public void ReInit(java.io.Reader dstream)\r
+ {\r
+ ReInit(dstream, 1, 1, 4096);\r
+ }\r
+ /** Constructor. */\r
+ public SimpleCharStream(java.io.InputStream dstream, String encoding, int startline,\r
+ int startcolumn, int buffersize) throws java.io.UnsupportedEncodingException\r
+ {\r
+ this(encoding == null ? new java.io.InputStreamReader(dstream) : new java.io.InputStreamReader(dstream, encoding), startline, startcolumn, buffersize);\r
+ }\r
+\r
+ /** Constructor. */\r
+ public SimpleCharStream(java.io.InputStream dstream, int startline,\r
+ int startcolumn, int buffersize)\r
+ {\r
+ this(new java.io.InputStreamReader(dstream), startline, startcolumn, buffersize);\r
+ }\r
+\r
+ /** Constructor. */\r
+ public SimpleCharStream(java.io.InputStream dstream, String encoding, int startline,\r
+ int startcolumn) throws java.io.UnsupportedEncodingException\r
+ {\r
+ this(dstream, encoding, startline, startcolumn, 4096);\r
+ }\r
+\r
+ /** Constructor. */\r
+ public SimpleCharStream(java.io.InputStream dstream, int startline,\r
+ int startcolumn)\r
+ {\r
+ this(dstream, startline, startcolumn, 4096);\r
+ }\r
+\r
+ /** Constructor. */\r
+ public SimpleCharStream(java.io.InputStream dstream, String encoding) throws java.io.UnsupportedEncodingException\r
+ {\r
+ this(dstream, encoding, 1, 1, 4096);\r
+ }\r
+\r
+ /** Constructor. */\r
+ public SimpleCharStream(java.io.InputStream dstream)\r
+ {\r
+ this(dstream, 1, 1, 4096);\r
+ }\r
+\r
+ /** Reinitialise. */\r
+ public void ReInit(java.io.InputStream dstream, String encoding, int startline,\r
+ int startcolumn, int buffersize) throws java.io.UnsupportedEncodingException\r
+ {\r
+ ReInit(encoding == null ? new java.io.InputStreamReader(dstream) : new java.io.InputStreamReader(dstream, encoding), startline, startcolumn, buffersize);\r
+ }\r
+\r
+ /** Reinitialise. */\r
+ public void ReInit(java.io.InputStream dstream, int startline,\r
+ int startcolumn, int buffersize)\r
+ {\r
+ ReInit(new java.io.InputStreamReader(dstream), startline, startcolumn, buffersize);\r
+ }\r
+\r
+ /** Reinitialise. */\r
+ public void ReInit(java.io.InputStream dstream, String encoding) throws java.io.UnsupportedEncodingException\r
+ {\r
+ ReInit(dstream, encoding, 1, 1, 4096);\r
+ }\r
+\r
+ /** Reinitialise. */\r
+ public void ReInit(java.io.InputStream dstream)\r
+ {\r
+ ReInit(dstream, 1, 1, 4096);\r
+ }\r
+ /** Reinitialise. */\r
+ public void ReInit(java.io.InputStream dstream, String encoding, int startline,\r
+ int startcolumn) throws java.io.UnsupportedEncodingException\r
+ {\r
+ ReInit(dstream, encoding, startline, startcolumn, 4096);\r
+ }\r
+ /** Reinitialise. */\r
+ public void ReInit(java.io.InputStream dstream, int startline,\r
+ int startcolumn)\r
+ {\r
+ ReInit(dstream, startline, startcolumn, 4096);\r
+ }\r
+ /** Get token literal value. */\r
+ public String GetImage()\r
+ {\r
+ if (bufpos >= tokenBegin)\r
+ return new String(buffer, tokenBegin, bufpos - tokenBegin + 1);\r
+ else\r
+ return new String(buffer, tokenBegin, bufsize - tokenBegin) +\r
+ new String(buffer, 0, bufpos + 1);\r
+ }\r
+\r
+ /** Get the suffix. */\r
+ public char[] GetSuffix(int len)\r
+ {\r
+ char[] ret = new char[len];\r
+\r
+ if ((bufpos + 1) >= len)\r
+ System.arraycopy(buffer, bufpos - len + 1, ret, 0, len);\r
+ else\r
+ {\r
+ System.arraycopy(buffer, bufsize - (len - bufpos - 1), ret, 0,\r
+ len - bufpos - 1);\r
+ System.arraycopy(buffer, 0, ret, len - bufpos - 1, bufpos + 1);\r
+ }\r
+\r
+ return ret;\r
+ }\r
+\r
+ /** Reset buffer when finished. */\r
+ public void Done()\r
+ {\r
+ buffer = null;\r
+ bufline = null;\r
+ bufcolumn = null;\r
+ }\r
+\r
+ /**\r
+ * Method to adjust line and column numbers for the start of a token.\r
+ */\r
+ public void adjustBeginLineColumn(int newLine, int newCol)\r
+ {\r
+ int start = tokenBegin;\r
+ int len;\r
+\r
+ if (bufpos >= tokenBegin)\r
+ {\r
+ len = bufpos - tokenBegin + inBuf + 1;\r
+ }\r
+ else\r
+ {\r
+ len = bufsize - tokenBegin + bufpos + 1 + inBuf;\r
+ }\r
+\r
+ int i = 0, j = 0, k = 0;\r
+ int nextColDiff = 0, columnDiff = 0;\r
+\r
+ while (i < len && bufline[j = start % bufsize] == bufline[k = ++start % bufsize])\r
+ {\r
+ bufline[j] = newLine;\r
+ nextColDiff = columnDiff + bufcolumn[k] - bufcolumn[j];\r
+ bufcolumn[j] = newCol + columnDiff;\r
+ columnDiff = nextColDiff;\r
+ i++;\r
+ }\r
+\r
+ if (i < len)\r
+ {\r
+ bufline[j] = newLine++;\r
+ bufcolumn[j] = newCol + columnDiff;\r
+\r
+ while (i++ < len)\r
+ {\r
+ if (bufline[j = start % bufsize] != bufline[++start % bufsize])\r
+ bufline[j] = newLine++;\r
+ else\r
+ bufline[j] = newLine;\r
+ }\r
+ }\r
+\r
+ line = bufline[j];\r
+ column = bufcolumn[j];\r
+ }\r
+\r
+}\r
+/* JavaCC - OriginalChecksum=c766a5138ab7879b8b98d46681a242b8 (do not edit this line) */\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2010 Association for Decentralized Information Management\r
+ * in Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.expressionParser;\r
+\r
+import java.io.StringReader;\r
+import java.util.HashMap;\r
+import java.util.List;\r
+\r
+public class TestExpressionParser {\r
+ \r
+ static private ExpressionParser parser;\r
+ \r
+ public static void parse(String string) {\r
+ parser.ReInit(new StringReader(string));\r
+ try {\r
+ parser.expr();\r
+ HashMap<String, List<Token>> references = parser.getReferences();\r
+ for(String ref : references.keySet()) {\r
+ System.out.println(ref);\r
+ }\r
+ } catch (ParseException e) {\r
+ System.out.println("While parsing " + string + ":");\r
+ // TODO Auto-generated catch block\r
+ e.printStackTrace();\r
+ }\r
+ }\r
+ \r
+ public static void main(String[] args) {\r
+ parser = new ExpressionParser(\r
+ new StringReader("")\r
+ );\r
+ parse("1 + m2ma");\r
+ System.out.println("##");\r
+ parse("ter2e + moro");\r
+ System.out.println("##");\r
+ parse("moro * sqr(4.0) + min(m2ma, moi)");\r
+ }\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2010 Association for Decentralized Information Management\r
+ * in Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.expressionParser;\r
+\r
+/**\r
+ * Describes the input token stream.\r
+ */\r
+\r
+public class Token implements java.io.Serializable {\r
+\r
+ /**\r
+ * The version identifier for this Serializable class.\r
+ * Increment only if the <i>serialized</i> form of the\r
+ * class changes.\r
+ */\r
+ private static final long serialVersionUID = 1L;\r
+\r
+ /**\r
+ * An integer that describes the kind of this token. This numbering\r
+ * system is determined by JavaCCParser, and a table of these numbers is\r
+ * stored in the file ...Constants.java.\r
+ */\r
+ public int kind;\r
+\r
+ /** The line number of the first character of this Token. */\r
+ public int beginLine;\r
+ /** The column number of the first character of this Token. */\r
+ public int beginColumn;\r
+ /** The line number of the last character of this Token. */\r
+ public int endLine;\r
+ /** The column number of the last character of this Token. */\r
+ public int endColumn;\r
+\r
+ /**\r
+ * The string image of the token.\r
+ */\r
+ public String image;\r
+\r
+ /**\r
+ * A reference to the next regular (non-special) token from the input\r
+ * stream. If this is the last token from the input stream, or if the\r
+ * token manager has not read tokens beyond this one, this field is\r
+ * set to null. This is true only if this token is also a regular\r
+ * token. Otherwise, see below for a description of the contents of\r
+ * this field.\r
+ */\r
+ public Token next;\r
+\r
+ /**\r
+ * This field is used to access special tokens that occur prior to this\r
+ * token, but after the immediately preceding regular (non-special) token.\r
+ * If there are no such special tokens, this field is set to null.\r
+ * When there are more than one such special token, this field refers\r
+ * to the last of these special tokens, which in turn refers to the next\r
+ * previous special token through its specialToken field, and so on\r
+ * until the first special token (whose specialToken field is null).\r
+ * The next fields of special tokens refer to other special tokens that\r
+ * immediately follow it (without an intervening regular token). If there\r
+ * is no such token, this field is null.\r
+ */\r
+ public Token specialToken;\r
+\r
+ /**\r
+ * An optional attribute value of the Token.\r
+ * Tokens which are not used as syntactic sugar will often contain\r
+ * meaningful values that will be used later on by the compiler or\r
+ * interpreter. This attribute value is often different from the image.\r
+ * Any subclass of Token that actually wants to return a non-null value can\r
+ * override this method as appropriate.\r
+ */\r
+ public Object getValue() {\r
+ return null;\r
+ }\r
+\r
+ /**\r
+ * No-argument constructor\r
+ */\r
+ public Token() {}\r
+\r
+ /**\r
+ * Constructs a new token for the specified Image.\r
+ */\r
+ public Token(int kind)\r
+ {\r
+ this(kind, null);\r
+ }\r
+\r
+ /**\r
+ * Constructs a new token for the specified Image and Kind.\r
+ */\r
+ public Token(int kind, String image)\r
+ {\r
+ this.kind = kind;\r
+ this.image = image;\r
+ }\r
+\r
+ /**\r
+ * Returns the image.\r
+ */\r
+ public String toString()\r
+ {\r
+ return image;\r
+ }\r
+\r
+ /**\r
+ * Returns a new Token object, by default. However, if you want, you\r
+ * can create and return subclass objects based on the value of ofKind.\r
+ * Simply add the cases to the switch for all those special cases.\r
+ * For example, if you have a subclass of Token called IDToken that\r
+ * you want to create if ofKind is ID, simply add something like :\r
+ *\r
+ * case MyParserConstants.ID : return new IDToken(ofKind, image);\r
+ *\r
+ * to the following switch statement. Then you can cast matchedToken\r
+ * variable to the appropriate type and use sit in your lexical actions.\r
+ */\r
+ public static Token newToken(int ofKind, String image)\r
+ {\r
+ switch(ofKind)\r
+ {\r
+ default : return new Token(ofKind, image);\r
+ }\r
+ }\r
+\r
+ public static Token newToken(int ofKind)\r
+ {\r
+ return newToken(ofKind, null);\r
+ }\r
+\r
+}\r
+/* JavaCC - OriginalChecksum=ed7a6d865f7fbc2c64e008e34bd824b0 (do not edit this line) */\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2010 Association for Decentralized Information Management\r
+ * in Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.expressionParser;\r
+\r
+/** Token Manager Error. */\r
+public class TokenMgrError extends Error\r
+{\r
+\r
+ /**\r
+ * The version identifier for this Serializable class.\r
+ * Increment only if the <i>serialized</i> form of the\r
+ * class changes.\r
+ */\r
+ private static final long serialVersionUID = 1L;\r
+\r
+ /*\r
+ * Ordinals for various reasons why an Error of this type can be thrown.\r
+ */\r
+\r
+ /**\r
+ * Lexical error occurred.\r
+ */\r
+ static final int LEXICAL_ERROR = 0;\r
+\r
+ /**\r
+ * An attempt was made to create a second instance of a static token manager.\r
+ */\r
+ static final int STATIC_LEXER_ERROR = 1;\r
+\r
+ /**\r
+ * Tried to change to an invalid lexical state.\r
+ */\r
+ static final int INVALID_LEXICAL_STATE = 2;\r
+\r
+ /**\r
+ * Detected (and bailed out of) an infinite loop in the token manager.\r
+ */\r
+ static final int LOOP_DETECTED = 3;\r
+\r
+ /**\r
+ * Indicates the reason why the exception is thrown. It will have\r
+ * one of the above 4 values.\r
+ */\r
+ int errorCode;\r
+\r
+ /**\r
+ * Replaces unprintable characters by their escaped (or unicode escaped)\r
+ * equivalents in the given string\r
+ */\r
+ protected static final String addEscapes(String str) {\r
+ StringBuffer retval = new StringBuffer();\r
+ char ch;\r
+ for (int i = 0; i < str.length(); i++) {\r
+ switch (str.charAt(i))\r
+ {\r
+ case 0 :\r
+ continue;\r
+ case '\b':\r
+ retval.append("\\b");\r
+ continue;\r
+ case '\t':\r
+ retval.append("\\t");\r
+ continue;\r
+ case '\n':\r
+ retval.append("\\n");\r
+ continue;\r
+ case '\f':\r
+ retval.append("\\f");\r
+ continue;\r
+ case '\r':\r
+ retval.append("\\r");\r
+ continue;\r
+ case '\"':\r
+ retval.append("\\\"");\r
+ continue;\r
+ case '\'':\r
+ retval.append("\\\'");\r
+ continue;\r
+ case '\\':\r
+ retval.append("\\\\");\r
+ continue;\r
+ default:\r
+ if ((ch = str.charAt(i)) < 0x20 || ch > 0x7e) {\r
+ String s = "0000" + Integer.toString(ch, 16);\r
+ retval.append("\\u" + s.substring(s.length() - 4, s.length()));\r
+ } else {\r
+ retval.append(ch);\r
+ }\r
+ continue;\r
+ }\r
+ }\r
+ return retval.toString();\r
+ }\r
+\r
+ /**\r
+ * Returns a detailed message for the Error when it is thrown by the\r
+ * token manager to indicate a lexical error.\r
+ * Parameters :\r
+ * EOFSeen : indicates if EOF caused the lexical error\r
+ * curLexState : lexical state in which this error occurred\r
+ * errorLine : line number when the error occurred\r
+ * errorColumn : column number when the error occurred\r
+ * errorAfter : prefix that was seen before this error occurred\r
+ * curchar : the offending character\r
+ * Note: You can customize the lexical error message by modifying this method.\r
+ */\r
+ protected static String LexicalError(boolean EOFSeen, int lexState, int errorLine, int errorColumn, String errorAfter, char curChar) {\r
+ return("Lexical error at line " +\r
+ errorLine + ", column " +\r
+ errorColumn + ". Encountered: " +\r
+ (EOFSeen ? "<EOF> " : ("\"" + addEscapes(String.valueOf(curChar)) + "\"") + " (" + (int)curChar + "), ") +\r
+ "after : \"" + addEscapes(errorAfter) + "\"");\r
+ }\r
+\r
+ /**\r
+ * You can also modify the body of this method to customize your error messages.\r
+ * For example, cases like LOOP_DETECTED and INVALID_LEXICAL_STATE are not\r
+ * of end-users concern, so you can return something like :\r
+ *\r
+ * "Internal Error : Please file a bug report .... "\r
+ *\r
+ * from this method for such cases in the release version of your parser.\r
+ */\r
+ public String getMessage() {\r
+ return super.getMessage();\r
+ }\r
+\r
+ /*\r
+ * Constructors of various flavors follow.\r
+ */\r
+\r
+ /** No arg constructor. */\r
+ public TokenMgrError() {\r
+ }\r
+\r
+ /** Constructor with message and reason. */\r
+ public TokenMgrError(String message, int reason) {\r
+ super(message);\r
+ errorCode = reason;\r
+ }\r
+\r
+ /** Full Constructor. */\r
+ public TokenMgrError(boolean EOFSeen, int lexState, int errorLine, int errorColumn, String errorAfter, char curChar, int reason) {\r
+ this(LexicalError(EOFSeen, lexState, errorLine, errorColumn, errorAfter, curChar), reason);\r
+ }\r
+}\r
+/* JavaCC - OriginalChecksum=24b6b4792f62099f85bde9ed73a49451 (do not edit this line) */\r
--- /dev/null
+package org.simantics.sysdyn.manager;\r
+\r
+import java.io.File;\r
+import java.io.FileNotFoundException;\r
+import java.io.FileOutputStream;\r
+import java.io.IOException;\r
+import java.io.PrintStream;\r
+import java.util.ArrayList;\r
+import java.util.Collection;\r
+import java.util.HashSet;\r
+import java.util.List;\r
+import java.util.Set;\r
+\r
+import org.simantics.databoard.Bindings;\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.common.request.ObjectsWithType;\r
+import org.simantics.db.common.request.ReadRequest;\r
+import org.simantics.db.common.utils.NameUtils;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.db.layer0.util.Simantics;\r
+import org.simantics.layer0.Layer0;\r
+import org.simantics.simulation.ontology.SimulationResource;\r
+import org.simantics.sysdyn.Activator;\r
+import org.simantics.sysdyn.SysdynResource;\r
+\r
+public class FunctionUtils {\r
+ \r
+ public static List<String> getLibraryPathsForModelica(final SysdynModel model) {\r
+ final ArrayList<String> paths = new ArrayList<String>();\r
+ \r
+ try {\r
+ Simantics.getSession().syncRequest(new ReadRequest() {\r
+ \r
+ @Override\r
+ public void run(ReadGraph graph) throws DatabaseException {\r
+ SysdynResource sr = SysdynResource.getInstance(graph);\r
+ SimulationResource simu = SimulationResource.getInstance(graph);\r
+ \r
+ Set<Resource> parents = getParents(graph, model, true);\r
+ for(Resource parent : parents) {\r
+ if(graph.isInstanceOf(parent, sr.SysdynModel)) {\r
+ Resource configuration = graph.getPossibleObject(parent, simu.HasConfiguration);\r
+ if(configuration.equals(model.getConfigurationResource())) {\r
+ String parentName = NameUtils.getSafeName(graph, parent);\r
+ paths.add(parentName + "_functions.mo");\r
+ }\r
+ } else {\r
+ String libraryname = NameUtils.getSafeName(graph, parent);\r
+ paths.add("..\\\\..\\\\libraries\\\\functions\\\\" + libraryname + ".mo");\r
+ }\r
+ }\r
+ }\r
+ });\r
+ } catch (DatabaseException e) {\r
+ e.printStackTrace();\r
+ }\r
+ \r
+ return paths;\r
+ }\r
+ \r
+ private static Set<Resource> getParents(ReadGraph graph, SysdynModel model, boolean onlyWithContent) throws DatabaseException{\r
+ HashSet<Resource> parents = new HashSet<Resource>();\r
+\r
+ Layer0 l0 = Layer0.getInstance(graph);\r
+ SysdynResource sr = SysdynResource.getInstance(graph);\r
+ SimulationResource simu = SimulationResource.getInstance(graph);\r
+ Resource modelResource = graph.getPossibleObject(model.getConfigurationResource(), simu.IsConfigurationOf);\r
+ \r
+ parents.add(modelResource);\r
+ \r
+ for(Resource r : graph.getObjects(modelResource, l0.IsLinkedTo)) {\r
+ if(graph.isInstanceOf(r, sr.SharedFunctionOntology)) {\r
+ parents.add(r);\r
+ } else {\r
+ Collection<Resource> libraries = graph.syncRequest(new ObjectsWithType(\r
+ r, l0.ConsistsOf, sr.SysdynModelicaFunctionLibrary));\r
+ if(!libraries.isEmpty())\r
+ parents.add(r);\r
+ }\r
+ }\r
+ \r
+ if(onlyWithContent) {\r
+ HashSet<Resource> contentParents = new HashSet<Resource>();\r
+ for(Resource parent : parents) {\r
+ if(hasContent(graph, parent))\r
+ contentParents.add(parent);\r
+ }\r
+ parents = contentParents;\r
+ }\r
+ \r
+ return parents;\r
+ \r
+ }\r
+ \r
+ private static boolean hasContent(ReadGraph graph, Resource library) {\r
+ Layer0 l0 = Layer0.getInstance(graph);\r
+ SysdynResource sr = SysdynResource.getInstance(graph);\r
+ try {\r
+ if(!graph.syncRequest(new ObjectsWithType(library, l0.ConsistsOf, sr.SysdynModelicaFunction)).isEmpty())\r
+ return true;\r
+ else {\r
+ for(Resource l : graph.syncRequest(new ObjectsWithType(library, l0.ConsistsOf, sr.SysdynModelicaFunctionLibrary))) {\r
+ boolean hasContent = hasContent(graph, l);\r
+ if(hasContent)\r
+ return true;\r
+ }\r
+ }\r
+ } catch (DatabaseException e) {\r
+ e.printStackTrace();\r
+ }\r
+ return false;\r
+ }\r
+ \r
+ public static void updateFunctionFilesForModel(ReadGraph graph, SysdynModel model) throws DatabaseException {\r
+ SysdynResource sr = SysdynResource.getInstance(graph);\r
+ \r
+ Set<Resource> parents = getParents(graph, model, false);\r
+ \r
+ for(Resource parent : parents) {\r
+ if(graph.isInstanceOf(parent, sr.SysdynModel)) {\r
+ String parentName = NameUtils.getSafeName(graph, parent);\r
+ File scriptFile = new File(model.getSimulationDir(), parentName + "_functions.mo");\r
+ updateFunctionFile(graph, parent, scriptFile, false);\r
+ } else {\r
+ updateFunctionFileForLibrary(graph, parent);\r
+ }\r
+ }\r
+ return;\r
+ }\r
+ \r
+ private static File getDir(ReadGraph graph, Resource resource) throws DatabaseException {\r
+ SysdynResource sr = SysdynResource.getInstance(graph);\r
+ Layer0 l0 = Layer0.getInstance(graph);\r
+ \r
+ Resource library = resource;\r
+ while(!graph.isInstanceOf(library, sr.SysdynModel) && !graph.isInstanceOf(library, l0.Ontology)) {\r
+ library = graph.getSingleObject(resource, l0.PartOf);\r
+ }\r
+ \r
+ File dir = null;\r
+ \r
+ if(graph.isInstanceOf(library, sr.SysdynModel)) {\r
+ SimulationResource simu = SimulationResource.getInstance(graph);\r
+ Resource configuration = graph.getSingleObject(library, simu.HasConfiguration);\r
+ SysdynModelManager smm = SysdynModelManager.getInstance(graph.getSession());\r
+ SysdynModel model = smm.getModel(graph, configuration);\r
+ dir = model.getSimulationDir();\r
+ } else {\r
+ File librariesDir = Activator.getBundleContext().getDataFile("libraries");\r
+ if (!librariesDir.exists()) {\r
+ librariesDir.mkdir();\r
+ }\r
+ dir = new File(librariesDir, "functions");\r
+ if (!dir.exists()) {\r
+ dir.mkdir();\r
+ }\r
+ }\r
+ return dir;\r
+ }\r
+\r
+ public static void createExternalFunctionFile(ReadGraph graph, Resource externalFunction) throws DatabaseException {\r
+ SysdynResource sr = SysdynResource.getInstance(graph);\r
+ Layer0 l0 = Layer0.getInstance(graph);\r
+\r
+ Resource function = graph.getSingleObject(externalFunction, l0.PartOf);\r
+ File dir = getDir(graph, function);\r
+\r
+ try {\r
+ String name = NameUtils.getSafeName(graph, externalFunction);\r
+ if(name.endsWith(".o") || name.endsWith(".a")) {\r
+ FileOutputStream fos = new FileOutputStream(dir + "\\" + name);\r
+ byte[] fileBArray = graph.getPossibleRelatedValue(externalFunction, sr.HasExternalFile, Bindings.BYTE_ARRAY);\r
+ fos.write(fileBArray);\r
+ fos.close();\r
+ }\r
+ } catch (IOException e) {\r
+ e.printStackTrace();\r
+ }\r
+ }\r
+ \r
+ public static void removeExternalFunctionFile(ReadGraph graph, Resource externalFunction) throws DatabaseException {\r
+ Layer0 l0 = Layer0.getInstance(graph);\r
+\r
+ Resource function = graph.getSingleObject(externalFunction, l0.PartOf);\r
+ File dir = getDir(graph, function);\r
+ String name = NameUtils.getSafeName(graph, externalFunction);\r
+ File file = new File(dir, name);\r
+ file.delete();\r
+ }\r
+\r
+ \r
+ \r
+ public static void updateFunctionFileForLibrary(ReadGraph graph, Resource library) throws DatabaseException {\r
+ SysdynResource sr = SysdynResource.getInstance(graph);\r
+ Layer0 l0 = Layer0.getInstance(graph);\r
+ \r
+ while(!graph.isInstanceOf(library, sr.SysdynModel) && !graph.isInstanceOf(library, l0.Ontology)) {\r
+ library = graph.getSingleObject(library, l0.PartOf);\r
+ }\r
+ \r
+ if(graph.isInstanceOf(library, sr.SysdynModel)) {\r
+ SimulationResource simu = SimulationResource.getInstance(graph);\r
+ Resource configuration = graph.getSingleObject(library, simu.HasConfiguration);\r
+ SysdynModelManager smm = SysdynModelManager.getInstance(graph.getSession());\r
+ SysdynModel model = smm.getModel(graph, configuration);\r
+ updateFunctionFilesForModel(graph, model);\r
+ } else {\r
+ \r
+ File librariesDir = Activator.getBundleContext().getDataFile("libraries");\r
+ if (!librariesDir.exists()) {\r
+ librariesDir.mkdir();\r
+ }\r
+ File dir = new File(librariesDir, "functions");\r
+ if (!dir.exists()) {\r
+ dir.mkdir();\r
+ }\r
+ String parentName = NameUtils.getSafeName(graph, library);\r
+ File scriptFile = new File(dir, parentName + ".mo");\r
+ \r
+ Resource sysdyn = graph.getResource("http://www.simantics.org/Sysdyn-1.0");\r
+\r
+ if(library.equals(sysdyn)) {\r
+ updateFunctionFile(graph, library, scriptFile, true);\r
+ } else {\r
+ updateFunctionFile(graph, library, scriptFile, false);\r
+ }\r
+ }\r
+ \r
+\r
+ }\r
+ \r
+ private static void updateFunctionFile(ReadGraph graph, Resource library, File scriptFile, boolean builtIn) throws DatabaseException {\r
+ PrintStream s;\r
+ try {\r
+ s = new PrintStream(scriptFile);\r
+ } catch (FileNotFoundException e) {\r
+ e.printStackTrace();\r
+ return;\r
+ }\r
+ \r
+ SysdynResource sr = SysdynResource.getInstance(graph);\r
+ String name = NameUtils.getSafeName(graph, library);\r
+ if(!builtIn && !graph.isInstanceOf(library, sr.SysdynModel))\r
+ s.println("package " + name);\r
+ writeLibrary(graph, library, s, builtIn);\r
+ if(!builtIn && !graph.isInstanceOf(library, sr.SysdynModel))\r
+ s.println("end " + name + ";\n");\r
+ \r
+ s.close();\r
+ }\r
+ \r
+ private static void writeLibrary(ReadGraph graph, Resource library, PrintStream stream, boolean builtIn) throws DatabaseException {\r
+ Layer0 l0 = Layer0.getInstance(graph);\r
+ SysdynResource sr = SysdynResource.getInstance(graph);\r
+ writeLibraryFunctions(graph, library, stream);\r
+ for(Resource sublibrary : graph.syncRequest(new ObjectsWithType(library, l0.ConsistsOf, sr.SysdynModelicaFunctionLibrary))) {\r
+ String name = NameUtils.getSafeName(graph, sublibrary);\r
+ if(!builtIn)\r
+ stream.println("encapsulated package " + name);\r
+ writeLibrary(graph, sublibrary, stream, builtIn);\r
+ if(!builtIn)\r
+ stream.println("end " + name + ";\n");\r
+ }\r
+ }\r
+ \r
+ private static void writeLibraryFunctions(ReadGraph graph, Resource library, PrintStream stream) throws DatabaseException {\r
+ Layer0 l0 = Layer0.getInstance(graph);\r
+ SysdynResource sr = SysdynResource.getInstance(graph);\r
+ for(Resource function : graph.syncRequest(new ObjectsWithType(library, l0.ConsistsOf, sr.SysdynModelicaFunction))) {\r
+ String name = NameUtils.getSafeName(graph, function);\r
+ String functionCode = graph.getRelatedValue(function, sr.HasModelicaFunctionCode);\r
+ stream.println("function " + name);\r
+ stream.println(functionCode);\r
+ stream.println("end " + name + ";\n");\r
+ for(Resource externalFunction : graph.syncRequest(new ObjectsWithType(function, l0.ConsistsOf, sr.ExternalFunctionFile))) {\r
+ createExternalFunctionFile(graph, externalFunction);\r
+ }\r
+ }\r
+ }\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2010 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.manager;\r
+\r
+import java.util.List;\r
+\r
+import org.simantics.modelica.data.DataSet;\r
+\r
+public class SysdynDataSet extends DataSet {\r
+\r
+ public String result;\r
+\r
+ public SysdynDataSet(String name, String result, List<Double> times, List<Double> values) {\r
+ super(name, times, values);\r
+ this.result = result;\r
+ }\r
+\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2010 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.manager;\r
+\r
+import java.io.File;\r
+import java.util.UUID;\r
+import java.util.concurrent.locks.Lock;\r
+\r
+import org.eclipse.core.runtime.Platform;\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.Session;\r
+import org.simantics.db.VirtualGraph;\r
+import org.simantics.db.WriteGraph;\r
+import org.simantics.db.common.request.ReadRequest;\r
+import org.simantics.db.common.request.WriteRequest;\r
+import org.simantics.db.common.utils.NameUtils;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.db.service.VirtualGraphSupport;\r
+import org.simantics.layer0.Layer0;\r
+import org.simantics.layer0.utils.direct.GraphUtils;\r
+import org.simantics.simulation.data.Datasource;\r
+import org.simantics.simulation.experiment.Experiment;\r
+import org.simantics.simulation.experiment.ExperimentState;\r
+import org.simantics.simulation.experiment.IDynamicExperiment;\r
+import org.simantics.simulation.ontology.SimulationResource;\r
+import org.simantics.sysdyn.SysdynResource;\r
+import org.simantics.sysdyn.simulation.SimulationScheduler;\r
+\r
+public class SysdynExperiment extends Experiment implements IDynamicExperiment {\r
+\r
+ Session session;\r
+ Runnable modificationListener;\r
+ Resource experiment;\r
+ SysdynModel sysdynModel;\r
+ boolean toggled = false;\r
+\r
+ public SysdynExperiment(Resource experiment, Resource model) {\r
+ super(model);\r
+ this.experiment = experiment;\r
+ // TODO Auto-generated constructor stub\r
+ }\r
+\r
+ public Resource getResource() {\r
+ return this.experiment;\r
+ }\r
+\r
+ @Override\r
+ public void rewindTo(double time) {\r
+ // TODO Auto-generated method stub\r
+ System.out.println("rewindTo");\r
+ }\r
+\r
+ @Override\r
+ public void saveState() {\r
+ if(sysdynModel.getSysdynResult() == null) return;\r
+\r
+ try {\r
+ session.syncRequest(new WriteRequest() {\r
+\r
+ @Override\r
+ public void perform(WriteGraph graph) throws DatabaseException {\r
+ Layer0 l0 = Layer0.getInstance(graph);\r
+ Resource model = graph.getSingleObject(experiment, l0.PartOf);\r
+ Resource project = graph.getSingleObject(model, l0.PartOf);\r
+ String projectName = graph.getPossibleRelatedValue(project, l0.HasName);\r
+ File root = new File(Platform.getLocation().toOSString(), "www.simantics.org");\r
+ if(!root.isDirectory()) root.mkdir();\r
+ File projectRoot = new File(root, projectName);\r
+ if(!projectRoot.isDirectory()) projectRoot.mkdir();\r
+ File file = new File( projectRoot, UUID.randomUUID().toString() + ".dbb");\r
+\r
+ String name = NameUtils.findFreshName(graph, "Result", model, l0.ConsistsOf, "%s%d");\r
+\r
+ SysdynResource sr = SysdynResource.getInstance(graph);\r
+ Resource res = GraphUtils.create2(graph, sr.Result,\r
+ l0.HasLabel, name,\r
+ l0.HasName, name,\r
+ l0.PartOf, model,\r
+ sr.HasResultFile, file.getAbsolutePath());\r
+ graph.claim(experiment, sr.HasResult, res);\r
+ sysdynModel.getSysdynResult().saveToFile(file);\r
+ }\r
+ });\r
+ } catch (DatabaseException e) {\r
+ e.printStackTrace();\r
+ }\r
+ }\r
+\r
+\r
+ @Override\r
+ public void simulate(boolean enabled) {\r
+ if(enabled && sysdynModel != null) {\r
+ changeState(ExperimentState.RUNNING);\r
+ startSimulation();\r
+ } else if (!toggled){\r
+ changeState(ExperimentState.STOPPED);\r
+ }\r
+ }\r
+\r
+\r
+ private void startSimulation() {\r
+ session.asyncRequest(new ReadRequest() {\r
+\r
+ @Override\r
+ public void run(ReadGraph graph) throws DatabaseException {\r
+ SimulationScheduler.start(sysdynModel, SysdynExperiment.this);\r
+ }\r
+ });\r
+ }\r
+\r
+ public void toggleSimulation(boolean enabled) {\r
+ if(enabled) {\r
+ this.toggled = true;\r
+ changeState(ExperimentState.RUNNING);\r
+ if(modificationListener == null) { \r
+\r
+ modificationListener = new Runnable() {\r
+\r
+ @Override\r
+ public void run() {\r
+ session.asyncRequest(new ReadRequest() {\r
+\r
+ @Override\r
+ public void run(ReadGraph graph) throws DatabaseException {\r
+ if(getState() == ExperimentState.RUNNING) {\r
+ SimulationScheduler.start(sysdynModel, SysdynExperiment.this);\r
+ }\r
+\r
+ }\r
+ });\r
+\r
+ };\r
+ };\r
+ sysdynModel.addModificationListener(modificationListener);\r
+ } \r
+ }\r
+ else {\r
+ changeState(ExperimentState.STOPPED);\r
+ this.toggled = false;\r
+ }\r
+\r
+ }\r
+\r
+ @Override\r
+ public void simulateDuration(double duration) {\r
+ // TODO Auto-generated method stub\r
+ System.out.println("simulateDuartion");\r
+ }\r
+\r
+ @Override\r
+ public void refresh(Session session) {\r
+ session.asyncRequest(new ReadRequest() {\r
+\r
+ @Override\r
+ public void run(ReadGraph graph) throws DatabaseException {\r
+ init(graph);\r
+ }\r
+\r
+ });\r
+ }\r
+\r
+ public void init(ReadGraph g) {\r
+ this.session = g.getSession();\r
+ changeState(ExperimentState.STOPPED);\r
+\r
+ session.asyncRequest(new ReadRequest() {\r
+\r
+ @Override\r
+ public void run(ReadGraph graph) throws DatabaseException {\r
+ final Resource configuration = graph.getPossibleObject(model, SimulationResource.getInstance(graph).HasConfiguration);\r
+ sysdynModel = SysdynModelManager.getInstance(session).getModel(graph, configuration);\r
+ toggleActivation(graph, true);\r
+ }\r
+ });\r
+\r
+ }\r
+\r
+ protected void localStateChange() {\r
+ final ExperimentState state = getState();\r
+ session.asyncRequest(new WriteRequest() {\r
+ @Override\r
+ public void perform(WriteGraph graph) throws DatabaseException {\r
+ Layer0 L0 = Layer0.getInstance(graph);\r
+ SimulationResource SR = SimulationResource.getInstance(graph);\r
+ graph.deny(model, SR.HasExperimentState);\r
+ Resource st = graph.newResource();\r
+ switch(state) {\r
+ case INITIALIZING:\r
+ graph.claim(st, L0.InstanceOf, SR.ExperimentState_Initializing);\r
+ break;\r
+ case RUNNING:\r
+ graph.claim(st, L0.InstanceOf, SR.ExperimentState_Running);\r
+ break;\r
+ case STOPPED:\r
+ graph.claim(st, L0.InstanceOf, SR.ExperimentState_Stopped);\r
+ break;\r
+ case DISPOSED:\r
+ graph.claim(st, L0.InstanceOf, SR.ExperimentState_Disposed);\r
+ break;\r
+ }\r
+\r
+ graph.claim(model, SR.HasExperimentState, st);\r
+ }});\r
+\r
+ switch(state) {\r
+ case DISPOSED:\r
+ System.out.println("disposed");\r
+ session.asyncRequest(new ReadRequest() {\r
+\r
+ @Override\r
+ public void run(ReadGraph graph) throws DatabaseException {\r
+ sysdynModel.cancelSimulation();\r
+ sysdynModel.removeModificationListener(modificationListener);\r
+ modificationListener = null;\r
+ toggleActivation(graph, false);\r
+ }\r
+ });\r
+ break;\r
+ }\r
+\r
+ }\r
+\r
+\r
+ private void toggleActivation(ReadGraph graph, final boolean activate) {\r
+ VirtualGraphSupport support = graph.getService(VirtualGraphSupport.class);\r
+ final Session session = graph.getSession();\r
+ session.asyncRequest(new WriteRequest(support.getWorkspacePersistent("experiments")) {\r
+ @Override\r
+ public void perform(WriteGraph graph) throws DatabaseException {\r
+ VirtualGraph runtime = graph.getService(VirtualGraph.class);\r
+\r
+ session.asyncRequest(new WriteRequest(runtime) {\r
+\r
+ @Override\r
+ public void perform(WriteGraph graph) throws DatabaseException {\r
+ SimulationResource SIMU = SimulationResource.getInstance(graph);\r
+ if(activate)\r
+ graph.claim(experiment, SIMU.IsActive, experiment);\r
+ else\r
+ graph.denyStatement(experiment, SIMU.IsActive, experiment);\r
+ }\r
+\r
+ });\r
+ }\r
+ });\r
+ }\r
+\r
+ @Override\r
+ public Lock getDatasourceLock() {\r
+ // TODO Auto-generated method stub\r
+ return null;\r
+ }\r
+\r
+ @Override\r
+ public Datasource getDatasource() {\r
+ // TODO Auto-generated method stub\r
+ return null;\r
+ }\r
+\r
+}\r
+\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2010 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.manager;\r
+\r
+import java.io.File;\r
+import java.io.FileNotFoundException;\r
+import java.io.IOException;\r
+import java.util.ArrayList;\r
+import java.util.Arrays;\r
+import java.util.Collection;\r
+import java.util.HashMap;\r
+import java.util.HashSet;\r
+import java.util.List;\r
+import java.util.Map;\r
+import java.util.Set;\r
+import java.util.concurrent.CopyOnWriteArrayList;\r
+\r
+import org.eclipse.core.runtime.IProgressMonitor;\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.Session;\r
+import org.simantics.db.common.request.ReadRequest;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.db.exception.ManyObjectsForFunctionalRelationException;\r
+import org.simantics.db.exception.ServiceException;\r
+import org.simantics.layer0.Layer0;\r
+import org.simantics.modelica.IModelicaMonitor;\r
+import org.simantics.modelica.ModelicaException;\r
+import org.simantics.modelica.ModelicaManager;\r
+import org.simantics.modelica.SimulationLocation;\r
+import org.simantics.modelica.data.SimulationResult;\r
+import org.simantics.objmap.IMapping;\r
+import org.simantics.objmap.IMappingListener;\r
+import org.simantics.objmap.Mappings;\r
+import org.simantics.simulation.experiment.Experiment;\r
+import org.simantics.simulation.experiment.ExperimentState;\r
+import org.simantics.simulation.experiment.IExperiment;\r
+import org.simantics.simulation.model.IModel;\r
+import org.simantics.simulation.ontology.SimulationResource;\r
+import org.simantics.simulation.project.ExperimentRuns;\r
+import org.simantics.simulation.project.IExperimentActivationListener;\r
+import org.simantics.structural.stubs.StructuralResource2;\r
+import org.simantics.sysdyn.Activator;\r
+import org.simantics.sysdyn.SysdynResource;\r
+import org.simantics.sysdyn.modelica.ModelicaWriter;\r
+import org.simantics.sysdyn.representation.Configuration;\r
+import org.simantics.sysdyn.representation.IElement;\r
+import org.simantics.sysdyn.representation.IndependentVariable;\r
+import org.simantics.sysdyn.representation.Model;\r
+import org.simantics.sysdyn.representation.Module;\r
+import org.simantics.sysdyn.representation.SysdynSchema;\r
+import org.simantics.sysdyn.representation.expressions.IExpression;\r
+import org.simantics.sysdyn.representation.expressions.ParameterExpression;\r
+\r
+/**\r
+ * Maintains a Java representation of system dynamic model.\r
+ * @author Hannu Niemistö\r
+ */\r
+public class SysdynModel implements IMappingListener, IModel {\r
+\r
+ private Session session;\r
+\r
+ private IMapping mapping;\r
+\r
+ private Resource configurationResource;\r
+ private Resource modelResource;\r
+ \r
+ private Configuration configuration;\r
+\r
+ private Set<Configuration> modules = new HashSet<Configuration>();\r
+\r
+ private Process process;\r
+ private boolean canceled;\r
+ private SimulationResult result;\r
+ private SysdynResult sysdynResult;\r
+\r
+ private CopyOnWriteArrayList<Runnable> modificationListeners =\r
+ new CopyOnWriteArrayList<Runnable>();\r
+ private CopyOnWriteArrayList<Runnable> resultListeners =\r
+ new CopyOnWriteArrayList<Runnable>();\r
+\r
+ @SuppressWarnings("rawtypes")\r
+ private Map<Class, Object> services = new HashMap<Class, Object>();\r
+\r
+ private String previousModelStructure;\r
+ private HashMap<String, String> previousImportantInits = new HashMap<String, String>();\r
+\r
+ private File simulationDir;\r
+\r
+ void readModules(ReadGraph graph, Resource configResource, Set<Resource> result) throws DatabaseException {\r
+\r
+ if(!result.add(configResource)) return;\r
+\r
+ Layer0 l0 = Layer0.getInstance(graph);\r
+ SysdynResource sr = SysdynResource.getInstance(graph);\r
+ StructuralResource2 str = StructuralResource2.getInstance(graph);\r
+\r
+ for(Resource part : graph.getObjects(configResource, l0.ConsistsOf)) {\r
+ if(graph.isInstanceOf(part, sr.Module)) {\r
+ Resource type = graph.getPossibleType(part, sr.Module);\r
+ Resource config = graph.getPossibleObject(type, str.IsDefinedBy);\r
+ readModules(graph, config, result);\r
+ }\r
+ }\r
+\r
+ }\r
+\r
+ Set<Resource> readModules(ReadGraph graph, Resource configResource) throws DatabaseException {\r
+ HashSet<Resource> result = new HashSet<Resource>();\r
+ readModules(graph, configResource, result);\r
+ return result;\r
+ }\r
+\r
+ private void createMapping(ReadGraph g) throws DatabaseException {\r
+ SysdynSchema schema = new SysdynSchema(g);\r
+ mapping = Mappings.createWithListening(schema);\r
+ mapping.addMappingListener(SysdynModel.this);\r
+ configuration = (Configuration)mapping.map(g, configurationResource);\r
+ for(Resource config : readModules(g, configurationResource)) {\r
+ modules.add((Configuration)mapping.map(g, config));\r
+ }\r
+ System.out.println("Loaded model with " + modules.size() + " modules.");\r
+ }\r
+\r
+ public SysdynModel(ReadGraph g, Resource configurationResource) {\r
+ this.session = g.getSession();\r
+ this.configurationResource = configurationResource;\r
+\r
+ try {\r
+ createMapping(g);\r
+ } catch(DatabaseException e) {\r
+ e.printStackTrace();\r
+ }\r
+ sysdynResult = new SysdynResult();\r
+ sysdynResult.setResult(new SimulationResult());\r
+\r
+ previousModelStructure = "";\r
+ }\r
+\r
+\r
+ /*\r
+ * some dummy(?) stuff for experiments\r
+ */\r
+ public SysdynModel(Resource modelResource) {\r
+ this.modelResource = modelResource;\r
+ }\r
+\r
+ public synchronized void simulate(IModelicaMonitor monitor, final IProgressMonitor progressMonitor, final Experiment experiment) throws IOException {\r
+ canceled = false;\r
+ progressMonitor.subTask("Write modelica classes");\r
+ ModelicaWriter writer = new ModelicaWriter();\r
+ for(Configuration c : modules) {\r
+ writer.write(c);\r
+ }\r
+ progressMonitor.worked(1);\r
+\r
+ progressMonitor.subTask("Write initial files");\r
+ String modelText = writer.toString();\r
+ HashMap<String, String> inits = getInits(configuration, "");\r
+ Model model = configuration.getModel();\r
+ Double startTime = model.getStartTime();\r
+ Double stopTime = model.getStopTime();\r
+ Double numberOfIntervals = model.getOutputInterval();\r
+ inits.put("start value", startTime.toString());\r
+ inits.put("stop value", stopTime.toString());\r
+ if(numberOfIntervals != null) {\r
+ inits.put("step value", numberOfIntervals.toString());\r
+ } else {\r
+ inits.put("step value", "" + (stopTime - startTime) / 500);\r
+ }\r
+ String method = "\"" + model.getSolver() + "\"";\r
+ inits.put("method", method);\r
+ if(model.getTolerance() != null)\r
+ inits.put("tolerance", model.getTolerance().toString());\r
+\r
+ StringBuilder functionscript = new StringBuilder();\r
+ for(String path : FunctionUtils.getLibraryPathsForModelica(this)) {\r
+ System.out.println("loadFile(\"" + path + "\");\n");\r
+ functionscript.append("loadFile(\"" + path + "\");\n"); \r
+ }\r
+ \r
+ final SimulationLocation simulationLocation = ModelicaManager.createInputFiles(\r
+ getSimulationDir(),\r
+ configuration.getName(),\r
+ writer.toString(),\r
+ inits,\r
+ functionscript.toString());\r
+ \r
+\r
+ progressMonitor.worked(1);\r
+\r
+\r
+ if (!simulationLocation.exeFile.isFile() || hasStructureChanged(modelText, inits)) {\r
+ progressMonitor.subTask("Build model");\r
+ previousModelStructure = modelText;\r
+ System.out.println("== Modelica == ");\r
+ System.out.println(writer.toString());\r
+ System.out.println("== Modelica ends == ");\r
+\r
+ try {\r
+ simulationLocation.exeFile.delete();\r
+ ModelicaManager.buildModel(simulationLocation, monitor);\r
+ previousImportantInits.clear();\r
+ previousImportantInits.put("start value", startTime.toString());\r
+ previousImportantInits.put("stop value", stopTime.toString());\r
+ previousImportantInits.put("method", method);\r
+ } catch (ModelicaException e) {\r
+ if(e.getMessage() != null)\r
+ monitor.message(e.getMessage());\r
+ monitor.showConsole();\r
+ canceled = true;\r
+ previousModelStructure = "";\r
+ }\r
+ }\r
+\r
+ progressMonitor.worked(1);\r
+\r
+ if(simulationLocation != null && !canceled) {\r
+ progressMonitor.subTask("Simulate model");\r
+ process = ModelicaManager.runModelica(\r
+ simulationLocation,\r
+ monitor,\r
+ inits\r
+ );\r
+ ModelicaManager.printProcessOutput(process, monitor);\r
+\r
+ Thread resultThread = new Thread() {\r
+ @Override\r
+ public void run() {\r
+ try {\r
+ process.waitFor();\r
+\r
+ if(!canceled) {\r
+ progressMonitor.worked(1);\r
+ progressMonitor.subTask("Read results");\r
+ result = new SimulationResult();\r
+ result.read(simulationLocation.outputFile);\r
+ result.readInits(simulationLocation.initFile);\r
+ result.filter();\r
+ sysdynResult.setResult(result);\r
+ progressMonitor.worked(1);\r
+ \r
+ resultChanged();\r
+ \r
+ setExperimentStopped(experiment);\r
+ }\r
+ } catch (FileNotFoundException e) {\r
+ e.printStackTrace();\r
+ } catch (IOException e) {\r
+ e.printStackTrace();\r
+ } catch (InterruptedException e) {\r
+ e.printStackTrace();\r
+ }\r
+ }\r
+ };\r
+ resultThread.run();\r
+ }\r
+ if(canceled)\r
+ setExperimentStopped(experiment);\r
+ process = null;\r
+ }\r
+\r
+ private void setExperimentStopped(Experiment experiment) {\r
+ if(experiment instanceof SysdynExperiment) {\r
+ SysdynExperiment e = (SysdynExperiment)experiment;\r
+ if(e.getState() != ExperimentState.DISPOSED)\r
+ e.simulate(false);\r
+ }\r
+ }\r
+\r
+ private boolean hasStructureChanged(String modelText, Map<String, String> inits) {\r
+ if (!modelText.equals(previousModelStructure))\r
+ return true;\r
+ for(String key : previousImportantInits.keySet()) {\r
+ if(!inits.containsKey(key) || !previousImportantInits.get(key).equals(inits.get(key)))\r
+ return true;\r
+ }\r
+ return false;\r
+ }\r
+\r
+ public void cancelSimulation() {\r
+ canceled = true;\r
+ if(process != null) {\r
+ process.destroy();\r
+ }\r
+ }\r
+\r
+ public synchronized boolean update(ReadGraph graph) throws DatabaseException {\r
+ if(mapping.isDomainModified()) {\r
+ mapping.updateRange(graph);\r
+ for(Resource config : readModules(graph, configurationResource)) {\r
+ if(!modules.contains(config))\r
+ modules.add((Configuration)mapping.map(graph, config));\r
+ }\r
+ return true;\r
+ }\r
+ else\r
+ return false;\r
+ }\r
+ \r
+ public synchronized boolean update() throws DatabaseException {\r
+ if(mapping.isDomainModified()) {\r
+ session.syncRequest(new ReadRequest() {\r
+ @Override\r
+ public void run(ReadGraph graph) throws DatabaseException {\r
+ mapping.updateRange(graph);\r
+ for(Resource config : readModules(graph, configurationResource)) {\r
+ if(!modules.contains(config))\r
+ modules.add((Configuration)mapping.map(graph, config));\r
+ }\r
+ }\r
+ });\r
+ return true;\r
+ }\r
+ else\r
+ return false;\r
+ }\r
+\r
+ public SimulationResult getSimulationResult() {\r
+ return result;\r
+ }\r
+\r
+ public SysdynResult getSysdynResult() {\r
+ return sysdynResult;\r
+ }\r
+\r
+ public void addResultListener(Runnable listener) {\r
+ synchronized(resultListeners) {\r
+ resultListeners.add(listener);\r
+ }\r
+ }\r
+\r
+ public void removeResultListener(Runnable listener) {\r
+ synchronized(resultListeners) {\r
+ resultListeners.remove(listener);\r
+ }\r
+ }\r
+ \r
+ public void resultChanged() {\r
+ synchronized(resultListeners) {\r
+ for(Runnable listener : resultListeners) {\r
+ listener.run();\r
+ }\r
+ }\r
+ }\r
+\r
+ public void addModificationListener(Runnable listener) {\r
+ synchronized(modificationListeners) {\r
+ modificationListeners.add(listener);\r
+ }\r
+ }\r
+\r
+ public void removeModificationListener(Runnable listener) {\r
+ synchronized(modificationListeners) {\r
+ modificationListeners.remove(listener);\r
+ }\r
+ }\r
+\r
+ @Override\r
+ public void domainModified() {\r
+ synchronized(modificationListeners) {\r
+ for(Runnable listener : modificationListeners)\r
+ listener.run();\r
+ }\r
+ }\r
+\r
+ @Override\r
+ public void rangeModified() {\r
+ }\r
+\r
+ public Configuration getConfiguration() {\r
+ return configuration;\r
+ }\r
+ \r
+ public Resource getConfigurationResource() {\r
+ return configurationResource;\r
+ }\r
+\r
+ public IMapping getMapping() {\r
+ return mapping;\r
+ }\r
+\r
+ public synchronized IElement getElement(Resource resource) {\r
+ return (IElement)mapping.get(resource);\r
+ }\r
+\r
+ public <T> T getService(Class<T> clazz) {\r
+ synchronized(services) {\r
+ return clazz.cast(services.get(clazz));\r
+ }\r
+ }\r
+\r
+ public <T> void addService(Class<T> clazz, T service) {\r
+ synchronized(services) {\r
+ services.put(clazz, service);\r
+ }\r
+ }\r
+\r
+ @Override\r
+ public IExperiment loadExperiment(ReadGraph g, Resource experiment, IExperimentActivationListener listener) {\r
+ \r
+ // Not good. IModel pushes only modelResource and it is assumed that\r
+ // SysdynModel is based on configuration\r
+ if(configurationResource == null && modelResource != null) {\r
+ SimulationResource simu = SimulationResource.getInstance(g);\r
+ try {\r
+ configurationResource = g.getPossibleObject(modelResource, simu.HasConfiguration);\r
+ } catch (ManyObjectsForFunctionalRelationException e) {\r
+ e.printStackTrace();\r
+ } catch (ServiceException e) {\r
+ e.printStackTrace();\r
+ } \r
+ }\r
+\r
+ SysdynExperiment exp = new SysdynExperiment(experiment, modelResource);\r
+ try {\r
+ exp.init(g);\r
+ ExperimentRuns.createRun(g.getSession(), experiment, exp, listener, null);\r
+ if(listener != null)\r
+ listener.onExperimentActivated(exp);\r
+ return exp;\r
+ } catch(Exception e) {\r
+ if(listener != null)\r
+ listener.onFailure(e);\r
+ return null;\r
+ }\r
+ }\r
+\r
+ public Collection<SysdynResult> getActiveResults(ReadGraph graph) {\r
+ ArrayList<SysdynResult> results = new ArrayList<SysdynResult>();\r
+\r
+ try {\r
+ Layer0 l0 = Layer0.getInstance(graph);\r
+ SysdynResource sr = SysdynResource.getInstance(graph);\r
+ SimulationResource SIMU = SimulationResource.getInstance(graph);\r
+ Resource model = graph.getSingleObject(configurationResource, SIMU.IsConfigurationOf);\r
+ Collection<Resource> experiments = graph.getObjects(model, l0.ConsistsOf);\r
+ for(Resource experiment : experiments) {\r
+ Collection<Resource> experimentResults = graph.getObjects(experiment, sr.HasResult);\r
+ for(Resource result : experimentResults) {\r
+ if(graph.hasStatement(result, SIMU.IsActive)) {\r
+ SysdynResult sysdynResult = new SysdynResult(\r
+ (String) graph.getPossibleRelatedValue(result, l0.HasLabel),\r
+ (String) graph.getPossibleRelatedValue(result, sr.HasResultFile));\r
+ results.add(sysdynResult);\r
+ }\r
+ }\r
+ }\r
+ } catch (Exception e) {\r
+ e.printStackTrace();\r
+ }\r
+\r
+ if(getSysdynResult() != null)\r
+ results.add(0, getSysdynResult() );\r
+\r
+\r
+\r
+ return results;\r
+ }\r
+\r
+ private HashMap<String, String> getInits(Configuration configuration, String prefix) {\r
+ HashMap<String, String> inits = new HashMap<String, String>();\r
+ for (IElement element : configuration.getElements()) {\r
+ if (element instanceof Module) {\r
+ Module module = (Module) element;\r
+ Configuration conf = module.getType().getConfiguration();\r
+ inits.putAll(getInits(conf, prefix + module.getName() + "."));\r
+ } else if (element instanceof IndependentVariable) {\r
+ IndependentVariable variable = (IndependentVariable) element;\r
+ //FIXME: more general solution?\r
+ IExpression expression = variable.getExpressions().getExpressions().get(0);\r
+ if (expression instanceof ParameterExpression) {\r
+ Double value = ((ParameterExpression)expression).getValue();\r
+ if(value != null)\r
+ inits.put(prefix + variable.getName(), "" + value);\r
+ }\r
+ }\r
+ }\r
+ return inits;\r
+ }\r
+ \r
+ public File getSimulationDir() {\r
+ if(simulationDir == null) {\r
+ File modelsDir = Activator.getBundleContext().getDataFile("models");\r
+ String configName = configuration.getName();\r
+ List<String> files = Arrays.asList(modelsDir.list());\r
+ if (files.contains(configName)) {\r
+ int i = 2;\r
+ while (files.contains(configName + "_" + i)){\r
+ i++;\r
+ }\r
+ configName += "_" + i;\r
+ }\r
+\r
+ simulationDir = Activator.getBundleContext().getDataFile("models/" + configName);\r
+ if (!simulationDir.exists()) {\r
+ simulationDir.mkdir();\r
+ }\r
+ }\r
+ return simulationDir;\r
+ }\r
+\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2010 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.manager;\r
+\r
+import java.util.WeakHashMap;\r
+\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.Session;\r
+import org.simantics.db.common.request.ReadRequest;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.simulation.ontology.SimulationResource;\r
+\r
+/**\r
+ * Manages system dynamic models.\r
+ * @author Hannu Niemistö\r
+ */\r
+public class SysdynModelManager {\r
+ WeakHashMap<Resource, SysdynModel> models =\r
+ new WeakHashMap<Resource, SysdynModel>(); // FIXME: Resources are weak, there is no guarantee that model exists in this map as long as needed.\r
+ // HashTable with a disposal procedure could be better solution..\r
+ Session session;\r
+\r
+ public SysdynModelManager(Session session) {\r
+ this.session = session;\r
+ }\r
+\r
+ /**\r
+ * Use only if not inside a transaction\r
+ */\r
+ public SysdynModel getModel(final Resource resource) {\r
+ synchronized(models) {\r
+ SysdynModel model = models.get(resource);\r
+ if(model == null) {\r
+ try {\r
+ session.syncRequest(new ReadRequest() {\r
+ \r
+ @Override\r
+ public void run(ReadGraph graph) throws DatabaseException {\r
+ SysdynModel model = new SysdynModel(graph, resource);\r
+ models.put(resource, model);\r
+ FunctionUtils.updateFunctionFilesForModel(graph, model);\r
+ }\r
+ });\r
+ } catch (DatabaseException e) {\r
+ e.printStackTrace();\r
+ }\r
+ \r
+ \r
+ model = models.get(resource);\r
+ }\r
+ return model;\r
+ }\r
+ }\r
+ \r
+ /**\r
+ * Should be used if called inside a transaction\r
+ */\r
+ public SysdynModel getModel(ReadGraph g, Resource resource) {\r
+ synchronized(models) {\r
+ SysdynModel model = models.get(resource);\r
+ if(model == null) {\r
+ model = new SysdynModel(g, resource);\r
+ models.put(resource, model);\r
+ try {\r
+ SimulationResource simu = SimulationResource.getInstance(g);\r
+ Resource modelResource = g.getPossibleObject(model.getConfigurationResource(), simu.IsConfigurationOf);\r
+ if(modelResource != null)\r
+ FunctionUtils.updateFunctionFilesForModel(g, model);\r
+ } catch (DatabaseException e) {\r
+ e.printStackTrace();\r
+ }\r
+ }\r
+ return model;\r
+ }\r
+ }\r
+\r
+ public synchronized static SysdynModelManager getInstance(Session session) {\r
+ SysdynModelManager manager =\r
+ session.peekService(SysdynModelManager.class);\r
+ if(manager == null) {\r
+ manager = new SysdynModelManager(session);\r
+ session.registerService(SysdynModelManager.class, manager);\r
+ }\r
+ return manager;\r
+ }\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2010 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.manager;\r
+\r
+\r
+import java.io.File;\r
+import java.io.IOException;\r
+import java.util.ArrayList;\r
+import java.util.List;\r
+import java.util.TreeMap;\r
+\r
+import org.simantics.databoard.Accessors;\r
+import org.simantics.databoard.Bindings;\r
+import org.simantics.databoard.Files;\r
+import org.simantics.databoard.Historian;\r
+import org.simantics.databoard.accessor.Accessor;\r
+import org.simantics.databoard.accessor.MapAccessor;\r
+import org.simantics.databoard.accessor.RecordAccessor;\r
+import org.simantics.databoard.accessor.binary.BinaryRecord;\r
+import org.simantics.databoard.accessor.binary.BinaryVariant;\r
+import org.simantics.databoard.accessor.error.AccessorConstructionException;\r
+import org.simantics.databoard.accessor.error.AccessorException;\r
+import org.simantics.databoard.accessor.java.JavaRecord;\r
+import org.simantics.databoard.accessor.reference.ChildReference;\r
+import org.simantics.databoard.accessor.reference.ComponentReference;\r
+import org.simantics.databoard.accessor.reference.IndexReference;\r
+import org.simantics.databoard.accessor.reference.KeyReference;\r
+import org.simantics.databoard.accessor.reference.NameReference;\r
+import org.simantics.databoard.annotations.Arguments;\r
+import org.simantics.databoard.binding.Binding;\r
+import org.simantics.databoard.binding.RecordBinding;\r
+import org.simantics.databoard.binding.error.BindingException;\r
+import org.simantics.databoard.binding.mutable.Variant;\r
+import org.simantics.databoard.type.Datatype;\r
+import org.simantics.modelica.data.DataSet;\r
+import org.simantics.modelica.data.SimulationResult;\r
+\r
+public class SysdynResult {\r
+\r
+ RecordAccessor accessor;\r
+ String resultName;\r
+\r
+ public SysdynResult() {\r
+\r
+ }\r
+\r
+ public SysdynResult(SimulationResult result) {\r
+ if(result != null)\r
+ setResult(result);\r
+ }\r
+\r
+ /**\r
+ * Open result from a file\r
+ * \r
+ * @param result Name of the result (seen in visualization)\r
+ * @param path file path\r
+ */\r
+ public SysdynResult(String result, String path) {\r
+ this.resultName = result;\r
+ File file = new File(path);\r
+ try {\r
+ BinaryVariant bv = (BinaryVariant)Accessors.openAccessor(file);\r
+ BinaryRecord br = bv.getContentAccessor();\r
+ accessor = br;\r
+ } catch (AccessorConstructionException e) {\r
+ e.printStackTrace();\r
+ } \r
+ }\r
+\r
+ public Accessor getAccessor() {\r
+ return accessor;\r
+ }\r
+\r
+ public void setResult(SimulationResult result) {\r
+ try {\r
+ // Create Memory Historian\r
+ Datatype recordingSessionType = Historian.getRecordingSessionType();\r
+ RecordBinding sessionBinding = (RecordBinding) Bindings.getBinding( recordingSessionType );\r
+ RecordBinding recordingBinding = (RecordBinding) Bindings.getBinding( Recording.class );\r
+ Object session = sessionBinding.createDefault(); \r
+ accessor = (JavaRecord) Accessors.getAccessor( sessionBinding, session );\r
+ MapAccessor recordings = accessor.getFieldAccessor("recordings");\r
+\r
+ // There is a recording for each variable\r
+ List<DataSet> datasets = result.getVariableDataSets();\r
+\r
+ // Add variables\r
+ for(DataSet ds : datasets){\r
+ // Add recording to session\r
+ Recording recording = createRecording(ds);\r
+ recordings.put(Bindings.VARIANT, recording.nodeId, Bindings.VARIANT, new Variant(recordingBinding, recording));\r
+ }\r
+\r
+ // Add initial values\r
+ for(DataSet ds : result.getInitialValueDataSets()){\r
+ Variant nodeId = Variant.ofInstance( ds.name );\r
+ if (recordings.containsKey(Bindings.VARIANT, nodeId)) continue;\r
+ // Add recording to session\r
+ Recording recording = createRecording(ds);\r
+ recordings.put(Bindings.VARIANT, recording.nodeId, Bindings.VARIANT, new Variant(recordingBinding, recording));\r
+ }\r
+\r
+ } catch (Exception e) {\r
+ e.printStackTrace();\r
+ } \r
+ }\r
+\r
+ @SuppressWarnings("unchecked")\r
+ Recording createRecording(DataSet ds) throws BindingException {\r
+ RecordBinding recordingBinding = (RecordBinding) Bindings.getBindingUnchecked( Recording.class );\r
+ Recording recording = (Recording) recordingBinding.createDefault(); \r
+ recording.nodeId = Variant.ofInstance( ds.name );\r
+ recording.labels.put("en", ds.name);\r
+\r
+ // Create one segment\r
+ TreeMap<Double, Double> segment = new TreeMap<Double, Double>();\r
+ recording.segments = new TreeMap[] { segment };\r
+\r
+ int length = ds.values.size();\r
+ for (int i=0; i<length; i++) {\r
+ double time = ds.times.get(i);\r
+ double value = ds.values.get(i);\r
+ segment.put(time, value); \r
+ }\r
+ return recording;\r
+ }\r
+\r
+ public void saveToFile(File file) {\r
+ if(accessor == null) return;\r
+ try {\r
+ Binding binding;\r
+ Object value;\r
+ if (accessor instanceof JavaRecord) {\r
+ // Get binding and value from memory\r
+ JavaRecord jr = (JavaRecord) accessor;\r
+ binding = jr.getBinding();\r
+ value = jr.getObject();\r
+ } else {\r
+ // Read value from another file\r
+ binding = Bindings.getBinding( accessor.type() );\r
+ value = accessor.getValue(binding);\r
+ }\r
+\r
+ // Write to file\r
+ Files.createFile(file, binding, value);\r
+ } catch (IOException e) {\r
+ e.printStackTrace();\r
+ } catch (AccessorException e) {\r
+ e.printStackTrace();\r
+ }\r
+\r
+ }\r
+\r
+ public static class Recording {\r
+ public Variant nodeId;\r
+ public @Arguments({String.class, String.class}) TreeMap<String, String> labels;\r
+ public @Arguments({TreeMap.class, Double.class, Double.class}) TreeMap<Double, Double>[] segments;\r
+ }\r
+\r
+ public SysdynDataSet getDataSet(String variable) {\r
+ if(accessor != null) {\r
+ try {\r
+ ChildReference ref = ChildReference.compile(\r
+ new NameReference("recordings"),\r
+ new KeyReference( Bindings.VARIANT, Variant.ofInstance(variable) ),\r
+ new ComponentReference(),\r
+ new NameReference("segments"),\r
+ new IndexReference(0)\r
+ );\r
+\r
+ MapAccessor ma = accessor.getComponent( ref );\r
+ int size = ma.size();\r
+ Double[] times = new Double[size];\r
+ Double[] values = new Double[size];\r
+\r
+ ma.getAll(Bindings.DOUBLE, Bindings.DOUBLE, times, values);\r
+\r
+ List<Double> times_ = new ArrayList<Double>(size);\r
+ List<Double> values_ = new ArrayList<Double>(size);\r
+ for (int i=0; i<size; i++) {\r
+ times_.add(i, times[i]);\r
+ values_.add(i, values[i]);\r
+ }\r
+\r
+ return new SysdynDataSet(variable, resultName, times_, values_);\r
+\r
+ } catch (AccessorConstructionException e) {\r
+ // Variable was not found\r
+ System.err.println("Variable "+variable+" is not available in the history.");\r
+ } catch (AccessorException e) {\r
+ // Unable to read data from file\r
+ e.printStackTrace();\r
+ }\r
+ }\r
+ return null;\r
+ }\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2011 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.mdlImport;\r
+\r
+import java.io.BufferedReader;\r
+import java.io.IOException;\r
+import java.io.StringReader;\r
+import java.util.regex.Matcher;\r
+import java.util.regex.Pattern;\r
+\r
+public class ImportUtils {\r
+ \r
+ public static String escapeExpression(String string) {\r
+ string = string.replace("Ä", "A");\r
+ string = string.replace("ä", "a");\r
+ string = string.replace("ö", "o");\r
+ string = string.replace("Ö", "O");\r
+ string = string.replace("\\", "\n");\r
+ \r
+ StringBuilder sb = new StringBuilder();\r
+ \r
+ if(string.contains("\"")) {\r
+ boolean startedQuote = false;\r
+ StringBuilder var = new StringBuilder();\r
+ for(char c : string.toCharArray()) {\r
+ if(c == '"') {\r
+ if(!startedQuote) {\r
+ startedQuote = true;\r
+ var = new StringBuilder();\r
+ continue;\r
+ } else {\r
+ startedQuote = false;\r
+ sb.append(var.toString().replaceAll("[^a-zA-Z 0-9]+", ""));\r
+ continue;\r
+ }\r
+ }\r
+ if(startedQuote) {\r
+ var.append(c);\r
+ } else {\r
+ sb.append(c);\r
+ }\r
+ }\r
+ \r
+ string = sb.toString();\r
+ }\r
+ \r
+ string = toCamelCase(string);\r
+ \r
+ return string;\r
+\r
+ }\r
+ \r
+ public static String escapeName(String string) {\r
+ string = string.replace("Ä", "A");\r
+ string = string.replace("ä", "a");\r
+ string = string.replace("ö", "o");\r
+ string = string.replace("Ö", "O");\r
+ string = string.replaceAll("[^a-zA-Z 0-9]+", "");\r
+ return toCamelCase(string);\r
+ }\r
+ \r
+ \r
+ public static String toCamelCase(String string) {\r
+ if(string.length() < 1) {\r
+ return string;\r
+ }\r
+ \r
+ try {\r
+ String result = new String(string);\r
+ BufferedReader br = new BufferedReader(new StringReader(string));\r
+ Pattern p = Pattern.compile("[a-zA-Z0-9]+");\r
+ Matcher m;\r
+ m = p.matcher(br.readLine());\r
+ String word;\r
+ boolean first = true;\r
+ while (m.find()) {\r
+ word = m.group();\r
+ String replacement;\r
+ if(first) {\r
+ replacement = word;\r
+ first = false;\r
+ } else {\r
+ replacement = word.substring(0, 1).toUpperCase() + word.substring(1);\r
+ }\r
+ result = result.replace(word, replacement);\r
+ }\r
+ return result.replace(" ", "");\r
+ } catch (IOException e) {\r
+ e.printStackTrace();\r
+ return string;\r
+ }\r
+ \r
+ }\r
+\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2011 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.mdlImport;\r
+\r
+import java.util.ArrayList;\r
+\r
+public class MdlFile {\r
+ \r
+ private ArrayList<String> variables = new ArrayList<String>();\r
+ private ArrayList<String> controls = new ArrayList<String>();\r
+ private ArrayList<String> sketchData = new ArrayList<String>();\r
+ private ArrayList<String> otherData = new ArrayList<String>();\r
+\r
+\r
+\r
+ public void addVariable(String variable) {\r
+ variables.add(variable);\r
+ }\r
+ \r
+ public ArrayList<String> getVariables() {\r
+ return variables;\r
+ }\r
+ \r
+ public void addControl(String control) {\r
+ controls.add(control);\r
+ }\r
+ \r
+ public ArrayList<String> getControls() {\r
+ return controls;\r
+ }\r
+ \r
+ public void addSketchData(String sketchRow) {\r
+ sketchData.add(sketchRow);\r
+ }\r
+\r
+ public ArrayList<String> getSketchData() {\r
+ return sketchData;\r
+ }\r
+\r
+ public void addOtherData(String dataRow) {\r
+ otherData.add(dataRow);\r
+ }\r
+\r
+ public ArrayList<String> getOtherData() {\r
+ return otherData;\r
+ }\r
+\r
+\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2011 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.mdlImport;\r
+\r
+import java.awt.geom.Point2D;\r
+import java.io.BufferedReader;\r
+import java.io.File;\r
+import java.io.FileInputStream;\r
+import java.io.FileReader;\r
+import java.io.IOException;\r
+import java.io.InputStreamReader;\r
+import java.io.Reader;\r
+import java.util.ArrayList;\r
+import java.util.HashMap;\r
+\r
+import org.simantics.sysdyn.mdlImport.mdlElements.Auxiliary;\r
+import org.simantics.sysdyn.mdlImport.mdlElements.Cloud;\r
+import org.simantics.sysdyn.mdlImport.mdlElements.Connection;\r
+import org.simantics.sysdyn.mdlImport.mdlElements.Dependency;\r
+import org.simantics.sysdyn.mdlImport.mdlElements.Element;\r
+import org.simantics.sysdyn.mdlImport.mdlElements.EquivalenceSubscript;\r
+import org.simantics.sysdyn.mdlImport.mdlElements.Expression;\r
+import org.simantics.sysdyn.mdlImport.mdlElements.Flow;\r
+import org.simantics.sysdyn.mdlImport.mdlElements.Function;\r
+import org.simantics.sysdyn.mdlImport.mdlElements.Model;\r
+import org.simantics.sysdyn.mdlImport.mdlElements.Stock;\r
+import org.simantics.sysdyn.mdlImport.mdlElements.Subscript;\r
+import org.simantics.sysdyn.mdlImport.mdlElements.Valve;\r
+import org.simantics.sysdyn.mdlImport.mdlElements.Variable;\r
+import org.simantics.sysdyn.mdlImport.mdlElements.View;\r
+\r
+public class MdlParser {\r
+ \r
+ public static Model parse(File file) {\r
+ \r
+ Model model = new Model();\r
+ \r
+ String[] name = file.getName().split("\\.mdl");\r
+ model.setName(name[0]);\r
+ \r
+ MdlFile mdlFile = getMdlContents(file);\r
+ \r
+ getVariableData(model, mdlFile.getVariables());\r
+ \r
+ getSketchData(model, mdlFile.getSketchData());\r
+ \r
+ getControlData(model, mdlFile.getControls());\r
+ \r
+// getOthertData(model, mdlFile.getOtherData());\r
+ \r
+ setAllSubscripts(model);\r
+ \r
+ return model;\r
+ }\r
+ \r
+\r
+ private static MdlFile getMdlContents(File aFile) {\r
+ MdlFile mdlFile = new MdlFile();\r
+ \r
+ try {\r
+ BufferedReader input = new BufferedReader(new FileReader(aFile));\r
+ \r
+ try {\r
+ String line = null; //not declared within while loop\r
+ \r
+ // See if the document is encoded with UTF-8. It will be marked with {UTF-8} on the first line\r
+ input.mark(30);\r
+ if (( line = input.readLine()) != null &&\r
+ line.contains("{UTF-8}")){\r
+ Reader in = new InputStreamReader(new FileInputStream(aFile), "UTF-8");\r
+ input = new BufferedReader(in);\r
+ line = input.readLine();\r
+ } else {\r
+ input.reset();\r
+ }\r
+ \r
+ \r
+ boolean isControl = false;\r
+ \r
+ while (( line = input.readLine()) != null){\r
+ // Build an element (combine the lines to one string)\r
+ StringBuilder elementBuilder = new StringBuilder();\r
+ while(line != null && !line.contains("\\\\\\---///")) {\r
+ // Add a new line for the element\r
+ elementBuilder.append(line);\r
+ if(line.endsWith("|") && !line.endsWith("~~|")) {\r
+ //Element definition has ended\r
+ break;\r
+ }\r
+ line = input.readLine();\r
+ }\r
+ \r
+ if(line.contains("\\\\\\---///"))\r
+ break;\r
+ \r
+ String variable = elementBuilder.toString();\r
+\r
+ if(variable.trim().matches("[\\*]{46}.+[\\*]{46}.+")) {\r
+ if(variable.contains(".Control")) {\r
+ isControl = true;\r
+ } else {\r
+ isControl = false;\r
+ }\r
+ continue;\r
+ }\r
+\r
+ // Add element string to model\r
+ if(isControl) {\r
+ mdlFile.addControl(variable);\r
+ } else {\r
+ mdlFile.addVariable(variable);\r
+ }\r
+ }\r
+ \r
+ while (( line = input.readLine()) != null && !line.contains("///---\\\\\\")){\r
+ mdlFile.addSketchData(line);\r
+ }\r
+ \r
+ while (( line = input.readLine()) != null){\r
+ mdlFile.addOtherData(line);\r
+ }\r
+ }\r
+ finally {\r
+ input.close();\r
+ }\r
+ }\r
+ catch (IOException ex){\r
+ ex.printStackTrace();\r
+ }\r
+ \r
+ return mdlFile;\r
+ }\r
+ \r
+ private static void getVariableData(Model model, ArrayList<String> elements) {\r
+ ArrayList<EquivalenceSubscript> equivalenceSubscripts = new ArrayList<EquivalenceSubscript>();\r
+ for(String elementString : elements) {\r
+ Variable v = createVariable(model, elementString);\r
+ if(v instanceof EquivalenceSubscript){\r
+ equivalenceSubscripts.add((EquivalenceSubscript) v);\r
+ }\r
+ }\r
+ \r
+ // All variables are ready, determine subscript equivalences\r
+ for(EquivalenceSubscript es : equivalenceSubscripts) {\r
+ Element e = model.getElement(es.getEquivalentToName());\r
+ if(e != null && e instanceof Subscript) {\r
+ es.setEquivalentTo((Subscript)e);\r
+ }\r
+ }\r
+ }\r
+ \r
+ \r
+ private static void getControlData(Model model, ArrayList<String> controls) {\r
+ for(String controlString : controls) {\r
+ String[] nameAndData = controlString.split("="); \r
+ String[] expressionUnitsAndComments = nameAndData[1].split("[\\~|\\|]");\r
+ \r
+ if(nameAndData[0].trim().equals("FINAL TIME")) {\r
+ model.setEndTime(Double.parseDouble(expressionUnitsAndComments[0]));\r
+ } else if(nameAndData[0].trim().equals("INITIAL TIME")) {\r
+ model.setStartTime(Double.parseDouble(expressionUnitsAndComments[0]));\r
+ } else if(nameAndData[0].trim().equals("TIME STEP")) {\r
+ model.setTimeStep(Double.parseDouble(expressionUnitsAndComments[0]));\r
+ } else if(nameAndData[0].trim().equals("SAVEPER")) {\r
+ model.setSaveper(expressionUnitsAndComments[0]);\r
+ model.setTimeUnit(expressionUnitsAndComments[1]);\r
+ }\r
+ }\r
+ \r
+ }\r
+ \r
+ private static Variable getVariable(Model model, String name) {\r
+ Element e = model.getElement(name);\r
+ Variable variable = null;\r
+ if(e != null && e instanceof Variable)\r
+ variable = (Variable)e;\r
+ return variable;\r
+ }\r
+ \r
+ private static String[] getNormalVariableNameDataAndRange(String element) {\r
+ String[] nameAndData = element.split("=", 2);\r
+ String[] nameAndRange = nameAndData[0].trim().split("[\\[|\\]]");\r
+ if(nameAndData.length == 2)\r
+ return new String[] {nameAndRange[0], nameAndData[1], nameAndRange.length == 2 ? nameAndRange[1] : null};\r
+ return null;\r
+ }\r
+ \r
+ private static String[] getSubscriptNameAndData(String element) {\r
+ String[] nameAndData = element.split(":");\r
+ if(nameAndData.length == 2)\r
+ return nameAndData;\r
+ return null;\r
+ } \r
+ \r
+ private static String[] getEquivalenceSubscriptNameAndData(String element) {\r
+ String[] nameAndData = element.split("\\<\\-\\>");\r
+ if(nameAndData.length == 2)\r
+ return nameAndData;\r
+ return null;\r
+ }\r
+ \r
+ private static String[] getTableNameDataAndRange(String element) {\r
+ String[] parts = element.split("\\~"); \r
+ if(!parts[0].contains("(") || !parts[0].contains(")"))\r
+ return null;\r
+ String name = element.substring(0, element.indexOf("("));\r
+ String theRest = element.substring(element.indexOf("("));\r
+ String[] nameAndData = {name, theRest};\r
+ String[] nameAndRange = nameAndData[0].trim().split("[\\[|\\]]");\r
+ if(nameAndData.length == 2)\r
+ return new String[] {nameAndRange[0], nameAndData[1], nameAndRange.length == 2 ? nameAndRange[1] : null};\r
+ return nameAndData;\r
+ }\r
+ \r
+ private static String[] getDataVariableNameAndData(String element) {\r
+ String[] nameAndData = {\r
+ element.substring(0, element.indexOf("~")),\r
+ " " + element.substring(element.indexOf("~"))};\r
+ return nameAndData;\r
+ }\r
+ \r
+ private static Variable createVariable(Model model, String elementString) {\r
+\r
+ String[] elementExpressions = elementString.split("\\~\\~\\|");\r
+ \r
+ Variable variable = null;\r
+ \r
+ for(String s : elementExpressions) {\r
+ // Skip these definitions at least for now\r
+ if(elementExpressions.length > 1 && s.contains("A FUNCTION OF"))\r
+ continue;\r
+ \r
+ Expression expression = new Expression();\r
+\r
+ String[] nameAndData = null;\r
+ String name;\r
+ \r
+ // Create the expression based on the expression string\r
+ if((nameAndData = getNormalVariableNameDataAndRange(s)) != null) {\r
+ \r
+ name = nameAndData[0].replace("\"", "");\r
+ variable = getVariable(model, name);\r
+ if(variable == null) {\r
+ variable = new Auxiliary();\r
+ variable.setName(name);\r
+ model.addElement(variable);\r
+ }\r
+ \r
+ if(!nameAndData[1].trim().endsWith("|")) {\r
+ // Multiple expressions\r
+ expression.setExpression(nameAndData[1].trim());\r
+ } else {\r
+ String[] expressionUnitsAndComments = nameAndData[1].split("[\\~|\\|]");\r
+ expression.setExpression(expressionUnitsAndComments[0].trim());\r
+ }\r
+ \r
+ } else if((nameAndData = getSubscriptNameAndData(s)) != null) {\r
+ \r
+ name = nameAndData[0].replace("\"", "");\r
+ variable = getVariable(model, name);\r
+ if(variable == null) {\r
+ variable = new Subscript();\r
+ variable.setName(name);\r
+ model.addElement(variable);\r
+ }\r
+ \r
+ // No support for multidimensional variables. Don't know what that would mean\r
+ String[] expressionUnitsAndComments = nameAndData[1].split("[\\~|\\|]");\r
+ expression.setExpression(expressionUnitsAndComments[0].trim());\r
+ variable.setUnits(expressionUnitsAndComments[1].trim());\r
+ variable.setComments(expressionUnitsAndComments[2].trim());\r
+ \r
+ } else if((nameAndData = getEquivalenceSubscriptNameAndData(s)) != null) {\r
+ \r
+ name = nameAndData[0].replace("\"", "");\r
+ variable = getVariable(model, name);\r
+ if(variable == null) {\r
+ variable = new EquivalenceSubscript();\r
+ variable.setName(name);\r
+ model.addElement(variable);\r
+ }\r
+ \r
+ // No support for multidimensional variables. Don't know what that would mean\r
+ String[] expressionUnitsAndComments = nameAndData[1].split("[\\~|\\|]");\r
+ expression.setExpression(expressionUnitsAndComments[0].trim());\r
+ variable.setUnits(expressionUnitsAndComments[1].trim());\r
+ variable.setComments(expressionUnitsAndComments[2].trim());\r
+ \r
+ } else if((nameAndData = getTableNameDataAndRange(s)) != null) {\r
+ \r
+ name =(nameAndData[0].replace("\"", ""));\r
+ variable = getVariable(model, name);\r
+ if(variable == null) {\r
+ variable = new Function();\r
+ variable.setName(name);\r
+ model.addElement(variable);\r
+ }\r
+ \r
+ String[] expressionUnitsAndComments = nameAndData[1].split("[\\~|\\|]");\r
+ // ([(0,0)-(2,5)],(0,5),(0.5,3),(1,0.5),(2,0.5) => ( ; (0,0)-(2,5) ; ,(0,5),(0.5,3),(1,0.5),(2,0.5)\r
+ String table = expressionUnitsAndComments[0].trim().split("[\\[|\\]]")[2];\r
+ // ,(0,5),(0.5,3),(1,0.5),(2,0.5) => (0,5),(0.5,3),(1,0.5),(2,0.5)\r
+ table = table.substring(table.indexOf(",") + 1, table.lastIndexOf(")"));\r
+ table = "{" + table + "}";\r
+ table = table.replace("(", "{");\r
+ table = table.replace(")", "}");\r
+ expression.setExpression(table); \r
+ \r
+ \r
+ } else if((nameAndData = getDataVariableNameAndData(s)) != null) {\r
+ \r
+ name = nameAndData[0].replace("\"", "");\r
+ variable = getVariable(model, name);\r
+ if(variable == null) {\r
+ variable = new Auxiliary();\r
+ variable.setName(name);\r
+ model.addElement(variable);\r
+ }\r
+ \r
+ expression.setExpression("");\r
+ } \r
+ \r
+ if(nameAndData == null || variable == null)\r
+ continue;\r
+ \r
+ // Set possible range for the expression\r
+ if(nameAndData.length == 3)\r
+ expression.setRange(nameAndData[2]);\r
+ \r
+ // Set units and comments for the variable \r
+ if(nameAndData[1].trim().endsWith("|")) {\r
+ String[] expressionUnitsAndComments = nameAndData[1].split("[\\~|\\|]");\r
+ String units = expressionUnitsAndComments[1].trim();\r
+ if(units.contains("[") &&\r
+ units.contains("]") &&\r
+ units.lastIndexOf("]") == units.length() - 1) {\r
+ // Range definitions are at the end\r
+ String range = units.substring(\r
+ units.lastIndexOf("[") + 1, \r
+ units.length() - 1);\r
+ String[] rangeParts = range.split(",");\r
+ \r
+ try {\r
+ variable.setRangeStart(Double.parseDouble(rangeParts[0]));\r
+ if(rangeParts.length >= 2)\r
+ variable.setRangeEnd(Double.parseDouble(rangeParts[1]));\r
+ if(rangeParts.length >= 3)\r
+ variable.setRangeStep(Double.parseDouble(rangeParts[2]));\r
+ } catch (NumberFormatException e) {\r
+ // Not a double\r
+ }\r
+ expressionUnitsAndComments[1] = units.substring(0, units.lastIndexOf("["));\r
+ }\r
+ variable.setUnits(expressionUnitsAndComments[1].trim());\r
+ variable.setComments(expressionUnitsAndComments[2].trim());\r
+ }\r
+ \r
+ // Finally add the expression to element\r
+ variable.getExpressions().add(expression);\r
+ }\r
+ return variable;\r
+ }\r
+ \r
+ private static int SCALE = 4;\r
+ private static void getSketchData(Model model, ArrayList<String> sketchData) {\r
+\r
+ String line = null;\r
+ View view = null;\r
+ int i = 0;\r
+ while(i < sketchData.size()) {\r
+ line = sketchData.get(i);\r
+ if(line.startsWith("*")) {\r
+ view = new View();\r
+ model.addView(view);\r
+ \r
+ view.setName(line.substring(1));\r
+\r
+ // STARTED A NEW VIEW\r
+\r
+ HashMap<String, Element> elementNumbers = new HashMap<String, Element>();\r
+ ArrayList<String> ghostNumbers = new ArrayList<String>();\r
+ ArrayList<String[]> connections = new ArrayList<String[]>();\r
+ HashMap<String, String[]> emptyValves = new HashMap<String, String[]>(); // map for valves that don't have an element \r
+ \r
+ \r
+ i++;\r
+ line = sketchData.get(i);\r
+ while(i < sketchData.size() && !sketchData.get(i).startsWith("*")) {\r
+ line = sketchData.get(i);\r
+ \r
+ if(line.startsWith("$")) {\r
+ view.setFontParameters(line);\r
+ i++;\r
+ continue;\r
+ }\r
+ \r
+ String[] data = line.split(",");\r
+ if(data[0].equals("1")) {\r
+ // Connections are handled after all elements\r
+ String[] connectionData = line.split(",");\r
+ connections.add(connectionData);\r
+ \r
+ } else if(data[0].equals("11")){\r
+ // Valve\r
+ i = i + 1;\r
+ String elementLine = sketchData.get(i);\r
+ String[] elementData = elementLine.split(",");\r
+ // FIXME: Assumes that element is always attached to the valve\r
+ Element element = model.getElement(elementData[2].replace("\"", ""));\r
+ Valve valve = new Valve();\r
+ if(element != null && element instanceof Variable) {\r
+ Variable v = (Variable) element;\r
+ valve.setName(v.getName());\r
+ valve.setExpressions(v.getExpressions());\r
+ valve.setUnits(v.getUnits());\r
+ valve.setComments(v.getComments());\r
+ valve.setX(Integer.parseInt(data[3]) / SCALE);\r
+ valve.setY(Integer.parseInt(data[4]) / SCALE);\r
+ \r
+ model.removeElement(element);\r
+ model.addElement(view, valve);\r
+ \r
+ // Add valve to the element list with both valve and variable symbol numbers\r
+ elementNumbers.put(elementData[1], valve);\r
+ elementNumbers.put(data[1], valve);\r
+ } else {\r
+ i = i - 1;\r
+ emptyValves.put(data[1], data);\r
+ }\r
+ } else if(data[0].equals("12")){\r
+ // Cloud\r
+ Cloud cloud = new Cloud();\r
+ cloud.setX(Integer.parseInt(data[3]) / SCALE); \r
+ cloud.setY(Integer.parseInt(data[4]) / SCALE); \r
+ elementNumbers.put(data[1], cloud);\r
+ model.addElement(view, cloud);\r
+ } else if(data[0].equals("10") && data.length <= 15){\r
+ // Some variable\r
+ Element e = model.getElement(data[2].replace("\"", "").trim());\r
+ if(e != null && e instanceof Variable) {\r
+ Variable v = (Variable) e;\r
+ if(v.getExpressions().get(0).getExpression().startsWith("INTEG (") && !(e instanceof Stock)) {\r
+ // Stock\r
+ Stock s = new Stock();\r
+ s.setName(v.getName());\r
+ s.setUnits(v.getUnits());\r
+ s.setComments(v.getComments());\r
+ s.setExpressions(v.getExpressions());\r
+ model.removeElement(e);\r
+ e = s;\r
+ model.addElement(view, e);\r
+ }\r
+ }\r
+\r
+ e.setX(Integer.parseInt(data[3]) / SCALE); \r
+ e.setY(Integer.parseInt(data[4]) / SCALE); \r
+ elementNumbers.put(data[1], e);\r
+ model.relocateElement(view, e);\r
+ } else if(data[0].equals("10") && data.length > 15){\r
+ // TODO: Ghost\r
+ // for now, direct back to the original element\r
+ Element originalElement = model.getElement(data[2].replace("\"", ""));\r
+ if(originalElement != null) {\r
+ elementNumbers.put(data[1], originalElement);\r
+ ghostNumbers.add(data[1]);\r
+ }\r
+ }\r
+ \r
+ i++;\r
+ }\r
+ i--;\r
+ \r
+ // Find the first variable that is connected to an empty valve\r
+ for(String[] connectionData : connections) {\r
+ if(!connectionData[9].equals("64"))\r
+ continue; // not dependency\r
+ String[] end = emptyValves.get(connectionData[3]);\r
+ if(end != null && elementNumbers.get(connectionData[3]) == null) {\r
+ // Use the connected element to create a valve and give it a name \r
+ Element start = elementNumbers.get(connectionData[2]);\r
+ if(start == null)\r
+ continue;\r
+ \r
+ Valve valve = new Valve();\r
+ valve.setName(start.getName() + " Rate");\r
+ valve.setX(Integer.parseInt(end[3]) / SCALE); \r
+ valve.setY(Integer.parseInt(end[4]) / SCALE);\r
+ \r
+ model.addElement(view, valve);\r
+ elementNumbers.put(connectionData[3], valve);\r
+ valve.setUnits("");\r
+ valve.setComments("");\r
+ }\r
+ }\r
+ \r
+ \r
+ \r
+ for(String[] connectionData : connections) {\r
+ \r
+ Element start = elementNumbers.get(connectionData[2]);\r
+ Element end = elementNumbers.get(connectionData[3]);\r
+ // Discard connection if one of the ends is null\r
+ if(start == null || end == null)\r
+ continue;\r
+ \r
+ \r
+ Connection connection; \r
+ if(connectionData[9].equals("64")) {\r
+ // Dependency\r
+ Point2D startPoint = new Point2D.Double(start.getX(), start.getY());\r
+ Point2D endPoint = new Point2D.Double(end.getX(), end.getY());\r
+ String controlX = connectionData[13].substring(connectionData[13].indexOf("(") + 1);\r
+ String controlY = connectionData[14].substring(0, connectionData[14].indexOf(")"));\r
+ Point2D controlPoint = new Point2D.Double(Double.parseDouble(controlX) / SCALE, Double.parseDouble(controlY) / SCALE);\r
+ \r
+ if(ghostNumbers.contains(connectionData[2]) ||\r
+ ghostNumbers.contains(connectionData[3])) {\r
+ connection = new Dependency();\r
+ } else {\r
+ double angle = Dependency.angleOfArc(\r
+ startPoint.getX(), startPoint.getY(),\r
+ controlPoint.getX(), controlPoint.getY(),\r
+ endPoint.getX(), endPoint.getY());\r
+\r
+ connection = new Dependency(angle);\r
+ }\r
+ \r
+ } else {\r
+ // Flow\r
+ connection = new Flow();\r
+ if(connectionData[4].equals("100")) {\r
+ // Flip the flow\r
+ Element temp = start;\r
+ start = end;\r
+ end = temp;\r
+ }\r
+ }\r
+ connection.setStart(start);\r
+ connection.setEnd(end);\r
+ model.addConnection(connection);\r
+ }\r
+ \r
+ \r
+ // Generate expressions for empty valves \r
+ for(String key : emptyValves.keySet()) {\r
+ Element e = elementNumbers.get(key);\r
+ if(e instanceof Valve && ((Valve)e).getExpressions().isEmpty()) {\r
+ Valve valve = (Valve)e;\r
+ // Find the stock\r
+ Stock stock = null;\r
+ for(Connection connection : valve.getConnections()) {\r
+ if(!(connection instanceof Flow))\r
+ continue;\r
+ if(connection.getStart().equals(valve) &&\r
+ connection.getEnd() instanceof Stock) {\r
+ stock = (Stock)connection.getEnd();\r
+ break;\r
+ }\r
+ }\r
+ \r
+ // Create the expression. Use the expression of the stock, and undo the effect of other valves\r
+ if(stock != null && stock instanceof Stock) {\r
+ Expression expression = new Expression();\r
+ \r
+ StringBuilder sb = new StringBuilder();\r
+ sb.append(((Stock)stock).getIntegralParts(stock.getExpressions().get(0))[0]);\r
+ \r
+ for(Connection c : stock.getConnections()) {\r
+ if(c instanceof Flow) {\r
+ if(c.getStart().equals(stock) && !c.getEnd().equals(valve)) {\r
+ sb.append("+");\r
+ sb.append(c.getEnd().getName());\r
+ } else if(!c.getStart().equals(valve)){\r
+ sb.append("-");\r
+ sb.append(c.getStart().getName());\r
+ }\r
+ }\r
+ }\r
+ expression.setExpression(sb.toString());\r
+ ArrayList<Expression> expressions = new ArrayList<Expression>();\r
+ expressions.add(expression);\r
+ valve.setExpressions(expressions);\r
+ }\r
+ }\r
+ }\r
+ }\r
+ i++;\r
+ }\r
+\r
+ }\r
+ \r
+ private static void getOthertData(Model model, String otherData) {\r
+ \r
+ }\r
+ \r
+ private static void setAllSubscripts(Model model) {\r
+ \r
+ // Set subscripts for all elements\r
+ ArrayList<Element> elements = new ArrayList<Element>();\r
+ elements.addAll(model.getUnlocatedElements());\r
+ for(View view : model.getViews()) {\r
+ elements.addAll(view.getElements());\r
+ }\r
+ \r
+ for(Element e : elements) { \r
+ if(!(e instanceof Variable))\r
+ continue;\r
+ Variable v = (Variable)e;\r
+ v.initializeSubscripts(model);\r
+ }\r
+ }\r
+ \r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2011 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.mdlImport.mdlElements;\r
+\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.WriteGraph;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.layer0.utils.direct.GraphUtils;\r
+import org.simantics.sysdyn.SysdynResource;\r
+import org.simantics.sysdyn.mdlImport.ImportUtils;\r
+\r
+public class Auxiliary extends Variable {\r
+\r
+ @Override\r
+ public Resource getExpression(WriteGraph graph, Expression expression) throws DatabaseException {\r
+ \r
+ SysdynResource sr = SysdynResource.getInstance(graph);\r
+ Resource e = GraphUtils.create2(graph, \r
+ sr.NormalExpression,\r
+ sr.HasEquation, ImportUtils.escapeExpression(expression.getExpression()).trim());\r
+ return e;\r
+ }\r
+\r
+ @Override\r
+ public void write(WriteGraph graph, Resource parent, double xOffset,\r
+ double yOffset) {\r
+ if(parent == null || graph == null)\r
+ return;\r
+ \r
+ try {\r
+ SysdynResource sr = SysdynResource.getInstance(graph);\r
+ if(!graph.isInstanceOf(parent, sr.Configuration))\r
+ return;\r
+ createVariable(graph, parent, sr.Auxiliary, sr.AuxiliarySymbol, xOffset, yOffset);\r
+ } catch (DatabaseException e) {\r
+ e.printStackTrace();\r
+ }\r
+ }\r
+\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2011 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.mdlImport.mdlElements;\r
+\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.WriteGraph;\r
+import org.simantics.db.common.utils.OrderedSetUtils;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.diagram.stubs.DiagramResource;\r
+import org.simantics.diagram.stubs.G2DResource;\r
+import org.simantics.layer0.Layer0;\r
+import org.simantics.layer0.utils.direct.GraphUtils;\r
+import org.simantics.modeling.ModelingResources;\r
+import org.simantics.sysdyn.SysdynResource;\r
+\r
+public class Cloud extends Element {\r
+\r
+ @Override\r
+ public void write(WriteGraph graph, Resource parent, double xOffset,\r
+ double yOffset) {\r
+ if(parent == null || graph == null)\r
+ return;\r
+ \r
+ try {\r
+ SysdynResource sr = SysdynResource.getInstance(graph);\r
+ Layer0 l0 = Layer0.getInstance(graph); \r
+ ModelingResources mr = ModelingResources.getInstance(graph);\r
+ DiagramResource dr = DiagramResource.getInstance(graph);\r
+ G2DResource g2d = G2DResource.getInstance(graph);\r
+ \r
+ if(!graph.isInstanceOf(parent, sr.Configuration))\r
+ return;\r
+ \r
+ Resource diagram = graph.getSingleObject(parent, mr.CompositeToDiagram);\r
+\r
+ if(diagram == null)\r
+ return;\r
+ \r
+ Resource cloud = GraphUtils.create2(graph, \r
+ sr.Cloud);\r
+\r
+ graph.claim(parent, l0.ConsistsOf, cloud);\r
+\r
+ \r
+\r
+ Resource symbol = GraphUtils.create2(graph, \r
+ sr.CloudSymbol,\r
+ mr.ElementToComponent, cloud);\r
+\r
+ double[] transform = {1.0, 0.0, 0.0, 1.0, getX() + xOffset, getY() + yOffset};\r
+ graph.claimLiteral(symbol, dr.HasTransform, g2d.Transform, transform);\r
+\r
+ OrderedSetUtils.add(graph, diagram, symbol);\r
+\r
+ setResource(cloud);\r
+\r
+ } catch (DatabaseException e) {\r
+ e.printStackTrace();\r
+ }\r
+ }\r
+\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2011 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.mdlImport.mdlElements;\r
+\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.WriteGraph;\r
+import org.simantics.db.common.utils.OrderedSetUtils;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.diagram.stubs.DiagramResource;\r
+import org.simantics.layer0.Layer0;\r
+import org.simantics.layer0.utils.direct.GraphUtils;\r
+import org.simantics.modeling.ModelingResources;\r
+import org.simantics.structural.stubs.StructuralResource2;\r
+import org.simantics.sysdyn.SysdynResource;\r
+\r
+public abstract class Connection implements IWriteableMDLObject {\r
+ protected Element start, end;\r
+ \r
+ public Resource writeConnection(WriteGraph graph, Resource configuration, Resource connectionType, Resource connectionSymbol) throws DatabaseException {\r
+ if(configuration == null || graph == null \r
+ || start.getResource() == null || end.getResource() == null) {\r
+ return null;\r
+ }\r
+ SysdynResource sr = SysdynResource.getInstance(graph);\r
+ Layer0 l0 = Layer0.getInstance(graph); \r
+ ModelingResources mr = ModelingResources.getInstance(graph);\r
+ DiagramResource dr = DiagramResource.getInstance(graph);\r
+ StructuralResource2 sr2 = StructuralResource2.getInstance(graph);\r
+ \r
+ Resource diagram = graph.getPossibleObject(configuration, mr.CompositeToDiagram);\r
+ Resource startElement = graph.getPossibleObject(start.getResource(), mr.ComponentToElement);\r
+ Resource endElement = graph.getPossibleObject(end.getResource(), mr.ComponentToElement);\r
+ if(diagram == null || startElement == null || endElement == null)\r
+ return null;\r
+ \r
+ \r
+ if(connectionType == null)\r
+ connectionType = sr.Dependency;\r
+ \r
+ if(connectionSymbol == null)\r
+ connectionSymbol = sr.DependencyConnection;\r
+ \r
+ // Build the connection to configuration\r
+ Resource connection = GraphUtils.create2(graph, \r
+ connectionType,\r
+ sr.HasHead, end.getResource(),\r
+ sr.HasTail, start.getResource(),\r
+ l0.PartOf, configuration);\r
+ graph.claim(connection, mr.Mapped, connection);\r
+ \r
+ \r
+ // Build diagram connectors and connection\r
+ Resource tailConnector = GraphUtils.create2(graph, \r
+ dr.Connector,\r
+ sr.HasTailTerminal, startElement);\r
+ \r
+ Resource headConnector = GraphUtils.create2(graph,\r
+ dr.Connector,\r
+ sr.HasHeadTerminal, endElement,\r
+ dr.AreConnected, tailConnector);\r
+ \r
+ Resource diagramConnection = GraphUtils.create2(graph, \r
+ connectionSymbol,\r
+ sr2.HasConnectionType, sr.SysdynConnectionType,\r
+ mr.DiagramConnectionToConnection, connection,\r
+ dr.HasArrowConnector, headConnector,\r
+ dr.HasPlainConnector, tailConnector);\r
+ \r
+ OrderedSetUtils.add(graph, diagram, diagramConnection);\r
+ \r
+ return connection;\r
+ }\r
+\r
+ public Element getStart() {\r
+ return start;\r
+ }\r
+\r
+ public void setStart(Element start) {\r
+ this.start = start;\r
+ }\r
+\r
+ public Element getEnd() {\r
+ return end;\r
+ }\r
+\r
+ public void setEnd(Element end) {\r
+ this.end = end;\r
+ }\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2011 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.mdlImport.mdlElements;\r
+\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.WriteGraph;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.modeling.ModelingResources;\r
+import org.simantics.sysdyn.SysdynResource;\r
+\r
+public class Dependency extends Connection {\r
+ \r
+ private double angle;\r
+ \r
+ public Dependency() {\r
+ this(-0.1);\r
+ }\r
+ \r
+ public Dependency(double angle) {\r
+ this.angle = angle; \r
+ }\r
+\r
+ @Override\r
+ public void write(WriteGraph graph, Resource parent) {\r
+ if(parent == null || graph == null || start == null || end == null)\r
+ return;\r
+ try {\r
+ SysdynResource sr = SysdynResource.getInstance(graph);\r
+ Resource connection = writeConnection(graph, parent, sr.Dependency, sr.DependencyConnection);\r
+\r
+ if(connection != null) {\r
+ ModelingResources mr = ModelingResources.getInstance(graph);\r
+ Resource diagramConnection = graph.getSingleObject(connection, mr.ConnectionToDiagramConnection);\r
+ graph.claimLiteral(diagramConnection, sr.angle, angle);\r
+ }\r
+\r
+ } catch (DatabaseException e) {\r
+ e.printStackTrace();\r
+ }\r
+\r
+ }\r
+\r
+ public double getAngle() {\r
+ return angle;\r
+ }\r
+\r
+ public void setAngle(double angle) {\r
+ this.angle = angle;\r
+ }\r
+ \r
+ \r
+ \r
+ /**\r
+ * Returns an angle in radians between straight line from (x0,y0) to (x2,y2)\r
+ * and an arc from (x0,y0) to (x2,y2) thru (x1,y1). The angle\r
+ * is measured at (x0,y0) and is between -PI and PI.\r
+ */\r
+ public static double angleOfArc(\r
+ double x0, double y0, \r
+ double x1, double y1,\r
+ double x2, double y2) {\r
+ double dx0 = x1-x0;\r
+ double dy0 = y1-y0;\r
+ double dx1 = x1-x2;\r
+ double dy1 = y1-y2;\r
+ double dx = x2-x0;\r
+ double dy = y2-y0;\r
+ // Length of cross product (p1-p0)x(p2-p0)\r
+ double dd = dx0*dy - dy0*dx; \r
+ \r
+ if(Math.abs(dd) < 1e-6) // Points are (almost) collinear\r
+ return 0.0;\r
+ else { \r
+ // (p1-p0)*(p1-p2) / dd\r
+ double offset = (dx0*dx1 + dy0*dy1) / dd;\r
+ double angle = Math.PI*0.5 - Math.atan(offset);\r
+ if(dd > 0.0)\r
+ angle = angle-Math.PI;\r
+ return angle;\r
+ \r
+ }\r
+ }\r
+\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2011 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.mdlImport.mdlElements;\r
+\r
+import java.util.ArrayList;\r
+\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.WriteGraph;\r
+import org.simantics.db.exception.DatabaseException;\r
+\r
+public abstract class Element implements IWriteableMDLElement {\r
+ \r
+ protected int x, y;\r
+ protected Resource resource;\r
+ protected String name;\r
+ protected ArrayList<Connection> connections;\r
+ \r
+ protected Resource getExpression(WriteGraph graph, Expression expression)\r
+ throws DatabaseException {\r
+ return null;\r
+ } \r
+ \r
+ public int getX() {\r
+ return x;\r
+ }\r
+\r
+ public void setX(int x) {\r
+ this.x = x;\r
+ }\r
+\r
+ public int getY() {\r
+ return y;\r
+ }\r
+\r
+ public void setY(int y) {\r
+ this.y = y;\r
+ }\r
+\r
+ public String getName() {\r
+ if(name == null)\r
+ return "Name";\r
+ return name;\r
+ }\r
+\r
+ public void setName(String name) {\r
+ this.name = name;\r
+ }\r
+\r
+ public Resource getResource() {\r
+ return resource;\r
+ }\r
+\r
+ public void setResource(Resource resource) {\r
+ this.resource = resource;\r
+ }\r
+ \r
+ public ArrayList<Connection> getConnections() {\r
+ if(connections == null)\r
+ connections = new ArrayList<Connection>();\r
+ return connections;\r
+ }\r
+\r
+ public void setConnections(ArrayList<Connection> connections) {\r
+ this.connections = connections;\r
+ }\r
+ \r
+ public void addConnection(Connection connection) {\r
+ getConnections().add(connection);\r
+ }\r
+}\r
+\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2011 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.mdlImport.mdlElements;\r
+\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.WriteGraph;\r
+\r
+public class EquivalenceSubscript extends Subscript {\r
+ \r
+ public String getEquivalentToName() {\r
+ String name = "";\r
+ if(expressions != null && expressions.get(0) != null) {\r
+ name = expressions.get(0).getExpression().trim();\r
+ }\r
+ return name;\r
+ }\r
+\r
+ public void setEquivalentTo(Subscript equivalentTo) {\r
+ setExpressions(equivalentTo.getExpressions());\r
+ }\r
+\r
+ @Override\r
+ public void write(WriteGraph graph, Resource parent, double xOffset,\r
+ double yOffset) {\r
+ super.write(graph, parent, xOffset, yOffset);\r
+ }\r
+\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2011 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.mdlImport.mdlElements;\r
+\r
+\r
+public class Expression {\r
+ private String range, expression;\r
+ \r
+ @Override\r
+ public String toString() {\r
+ return (range != null ? "[" + range + "]: " : "") + expression; \r
+ }\r
+\r
+ public String getRange() {\r
+ return range;\r
+ }\r
+\r
+ public void setRange(String range) {\r
+ this.range = range;\r
+ }\r
+\r
+ public String getExpression() {\r
+ if(expression == null)\r
+ return "";\r
+ return expression;\r
+ }\r
+\r
+ public void setExpression(String expression) {\r
+ this.expression = expression;\r
+ }\r
+ \r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2011 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.mdlImport.mdlElements;\r
+\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.WriteGraph;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.sysdyn.SysdynResource;\r
+\r
+public class Flow extends Connection {\r
+\r
+ @Override\r
+ public void write(WriteGraph graph, Resource parent) {\r
+ if(parent == null || graph == null)\r
+ return;\r
+ try {\r
+ SysdynResource sr = SysdynResource.getInstance(graph);\r
+ writeConnection(graph, parent, sr.Flow, sr.FlowConnection);\r
+ } catch (DatabaseException e) {\r
+ e.printStackTrace();\r
+ }\r
+ }\r
+\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2011 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.mdlImport.mdlElements;\r
+\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.WriteGraph;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.layer0.Layer0;\r
+import org.simantics.layer0.utils.direct.GraphUtils;\r
+import org.simantics.sysdyn.SysdynResource;\r
+import org.simantics.sysdyn.mdlImport.ImportUtils;\r
+\r
+public class Function extends Variable {\r
+\r
+ @Override\r
+ public void write(WriteGraph graph, Resource parent, double xOffset,\r
+ double yOffset) {\r
+ if(parent == null || graph == null)\r
+ return;\r
+ \r
+ try {\r
+ SysdynResource sr = SysdynResource.getInstance(graph);\r
+ if(!graph.isInstanceOf(parent, sr.SysdynModel))\r
+ return;\r
+ Layer0 l0 = Layer0.getInstance(graph); \r
+ \r
+ Resource function = GraphUtils.create2(graph, \r
+ sr.SysdynModelicaFunction,\r
+ l0.HasName, ImportUtils.escapeName(this.getName()));\r
+ \r
+ if(comments != null && comments.length() > 0)\r
+ graph.claimLiteral(function, l0.HasDescription, comments);\r
+ \r
+ if(expressions != null && expressions.get(0) != null) {\r
+ StringBuilder sb = new StringBuilder();\r
+ sb.append(" input Real a;\n");\r
+ sb.append(" output Real result;\n");\r
+ sb.append("algorithm\n");\r
+ sb.append(" result := interpolate(a, " + expressions.get(0).getExpression() + ");");\r
+ graph.claimLiteral(function, sr.HasModelicaFunctionCode, sb.toString());\r
+ }\r
+\r
+ graph.claim(parent, l0.ConsistsOf, function);\r
+ resource = function;\r
+ } catch (DatabaseException e) {\r
+ e.printStackTrace();\r
+ }\r
+ \r
+ }\r
+\r
+\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2011 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.mdlImport.mdlElements;\r
+\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.WriteGraph;\r
+\r
+public interface IWriteableMDLElement {\r
+\r
+ /**\r
+ * Writes an element with coordinates (variable, cloud) to the given resource.\r
+ * \r
+ * Offsets determine where the parent view is located in the combined diagram\r
+ * \r
+ * @param graph WriteGraph\r
+ * @param parent The resource where the object is located\r
+ * @param xOffset xOffset of the view in the diagram\r
+ * @param yOffset yOffset of the view in the diagram\r
+ */\r
+ public void write(WriteGraph graph, Resource parent, double xOffset, double yOffset);\r
+}
\ No newline at end of file
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2011 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.mdlImport.mdlElements;\r
+\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.WriteGraph;\r
+\r
+public interface IWriteableMDLObject {\r
+ \r
+ /**\r
+ * Writes an object with no coordinates (connection, model, view) to the given resource\r
+ * \r
+ * @param graph WriteGraph\r
+ * @param parent The resource where the object is located\r
+ */\r
+ public void write(WriteGraph graph, Resource parent);\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2011 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.mdlImport.mdlElements;\r
+\r
+import java.util.ArrayList;\r
+import java.util.HashMap;\r
+\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.WriteGraph;\r
+import org.simantics.db.common.utils.NameUtils;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.db.layer0.adapter.Template;\r
+import org.simantics.layer0.Layer0;\r
+import org.simantics.layer0.utils.direct.GraphUtils;\r
+import org.simantics.modeling.ModelingResources;\r
+import org.simantics.simulation.ontology.SimulationResource;\r
+import org.simantics.sysdyn.SysdynResource;\r
+import org.simantics.utils.datastructures.ArrayMap;\r
+\r
+public class Model implements IWriteableMDLObject {\r
+\r
+ private String name, timeUnit, saveper;\r
+ private double startTime = 0, endTime = 10, timeStep = 1;\r
+ \r
+ private HashMap<String, Element> elementMap = new HashMap<String, Element>();\r
+ private ArrayList<Subscript> subscripts = new ArrayList<Subscript>();\r
+ private ArrayList<Function> functions = new ArrayList<Function>();\r
+ private ArrayList<Connection> connections = new ArrayList<Connection>();\r
+ private ArrayList<View> views = new ArrayList<View>();\r
+ private ArrayList<Element> unlocatedElements = new ArrayList<Element>();\r
+ \r
+ public void addElement(Element element) {\r
+ if(element instanceof Subscript)\r
+ addSubscript((Subscript)element);\r
+ else if(element instanceof Function)\r
+ addFunction((Function)element);\r
+ else\r
+ unlocatedElements.add(element);\r
+ if(element.getName() != null)\r
+ elementMap.put(element.getName(), element);\r
+ }\r
+ \r
+ public void addSubscript(Subscript subscript) {\r
+ subscripts.add(subscript);\r
+ }\r
+ \r
+ public void addFunction(Function function) {\r
+ functions.add(function);\r
+ }\r
+ \r
+ public void addElement(View view, Element element) {\r
+ if(element instanceof Subscript)\r
+ addSubscript((Subscript)element);\r
+ else {\r
+ if(unlocatedElements.contains(element))\r
+ unlocatedElements.remove(element);\r
+ view.addElement(element);\r
+ }\r
+ if(element.getName() != null)\r
+ elementMap.put(element.getName(), element);\r
+ }\r
+ \r
+ public void relocateElement(View view, Element element) {\r
+ if(unlocatedElements.contains(element))\r
+ unlocatedElements.remove(element);\r
+ for(View v : views) {\r
+ if(v.getElements().contains(element))\r
+ v.getElements().remove(element);\r
+ }\r
+ view.addElement(element);\r
+ }\r
+ \r
+ public void removeElement(Element element) {\r
+ if(unlocatedElements.contains(element))\r
+ unlocatedElements.remove(element);\r
+ \r
+ for(View view : views) {\r
+ if(view.getElements().contains(element)) {\r
+ view.getElements().remove(element);\r
+ }\r
+ }\r
+ \r
+ // just to be sure: loop the whole elementMap and don't trust the element's name\r
+ String toBeRemoved = null;\r
+ for(String key : elementMap.keySet()) {\r
+ if(element.equals(elementMap.get(key))) {\r
+ toBeRemoved = key;\r
+ break;\r
+ }\r
+ }\r
+ if(toBeRemoved != null)\r
+ elementMap.remove(toBeRemoved);\r
+ }\r
+ \r
+ public ArrayList<Element> getUnlocatedElements() {\r
+ return unlocatedElements;\r
+ }\r
+ \r
+ public Element getElement(String name) {\r
+ return elementMap.get(name);\r
+ }\r
+ \r
+ public void addConnection(Connection connection) {\r
+ connections.add(connection);\r
+ if(connection.getStart() != null &&\r
+ !connection.getStart().getConnections().contains(connection)) {\r
+ connection.getStart().addConnection(connection);\r
+ }\r
+ if(connection.getEnd() != null &&\r
+ !connection.getEnd().getConnections().contains(connection)) {\r
+ connection.getEnd().addConnection(connection);\r
+ }\r
+ }\r
+ \r
+ public ArrayList<Connection> getConnections() {\r
+ return connections;\r
+ }\r
+ \r
+ public ArrayList<Subscript> getSubscripts() {\r
+ return subscripts;\r
+ }\r
+\r
+ public String getName() {\r
+ if(name == null)\r
+ return "ModelName";\r
+ return name;\r
+ }\r
+\r
+ public void setName(String name) {\r
+ this.name = name;\r
+ }\r
+\r
+ public String getTimeUnit() {\r
+ return timeUnit;\r
+ }\r
+\r
+ public void setTimeUnit(String timeUnit) {\r
+ this.timeUnit = timeUnit;\r
+ }\r
+\r
+ public String getSaveper() {\r
+ return saveper;\r
+ }\r
+\r
+ public void setSaveper(String saveper) {\r
+ this.saveper = saveper;\r
+ }\r
+\r
+ public double getStartTime() {\r
+ return startTime;\r
+ }\r
+\r
+ public void setStartTime(double startTime) {\r
+ this.startTime = startTime;\r
+ }\r
+\r
+ public double getEndTime() {\r
+ return endTime;\r
+ }\r
+\r
+ public void setEndTime(double endTime) {\r
+ this.endTime = endTime;\r
+ }\r
+\r
+ public double getTimeStep() {\r
+ return timeStep;\r
+ }\r
+\r
+ public void setTimeStep(double timeStep) {\r
+ this.timeStep = timeStep;\r
+ }\r
+\r
+ public HashMap<String, Element> getElementMap() {\r
+ return elementMap;\r
+ }\r
+\r
+ public void setElementMap(HashMap<String, Element> elementMap) {\r
+ this.elementMap = elementMap;\r
+ }\r
+\r
+ public void setSubscripts(ArrayList<Subscript> subscripts) {\r
+ this.subscripts = subscripts;\r
+ }\r
+\r
+ public void setConnections(ArrayList<Connection> connections) {\r
+ this.connections = connections;\r
+ }\r
+ \r
+ public void addView(View view) {\r
+ views.add(view);\r
+ }\r
+ \r
+ public ArrayList<View> getViews() {\r
+ return views;\r
+ }\r
+\r
+ /**\r
+ * Write the model to a project\r
+ * @param graph WriteGraph\r
+ * @param parent Project resource\r
+ */\r
+ @Override\r
+ public void write(WriteGraph graph, Resource parent) {\r
+ if(parent == null || graph == null)\r
+ return;\r
+ \r
+ try {\r
+ SysdynResource sr = SysdynResource.getInstance(graph);\r
+ Layer0 l0 = Layer0.getInstance(graph);\r
+ SimulationResource simu = SimulationResource.getInstance(graph);\r
+\r
+ // Diagram creation copied from SysdynProject. \r
+ // Could the same code be reused? \r
+ \r
+ Resource sysdyn = graph.getResource("http://www.simantics.org/Sysdyn-1.0");\r
+ Resource layer0 = graph.getResource("http://www.simantics.org/Layer0-1.0");\r
+\r
+ Resource model = GraphUtils.create2(\r
+ graph,\r
+ sr.SysdynModel,\r
+ l0.PartOf, parent,\r
+ l0.HasName, NameUtils.findFreshName(graph, getName(), parent, l0.ConsistsOf, "%s%d"),\r
+ l0.HasLabel, getName(),\r
+ sr.HasStartTime, startTime,\r
+ sr.HasStopTime, endTime,\r
+ l0.IsLinkedTo, sysdyn,\r
+ l0.IsLinkedTo, layer0\r
+ );\r
+\r
+\r
+ Resource conf = GraphUtils.create2(graph,\r
+ sr.Configuration,\r
+ l0.PartOf, model,\r
+ l0.HasName, getName()\r
+ );\r
+ \r
+ Resource diagram = graph.newResource();\r
+ graph.adapt(sr.ConfigurationDiagramTemplate, Template.class).apply(graph,\r
+ ArrayMap\r
+ .keys("", "diagram", "name")\r
+ .values(conf, diagram, "Diagrammi")\r
+ );\r
+ \r
+ \r
+ ModelingResources mr = ModelingResources.getInstance(graph);\r
+ // Remove default mapping and add sysdyn mapping\r
+ for(Resource trigger : graph.getObjects(diagram, l0.HasTrigger)) {\r
+ if(graph.isInstanceOf(trigger, mr.DiagramToCompositeMapping)) {\r
+ graph.deny(diagram, l0.HasTrigger, trigger);\r
+ }\r
+ }\r
+ Resource mapping = graph.newResource();\r
+ graph.claim(mapping, l0.InstanceOf, null, sr.DiagramToCompositeMapping);\r
+ graph.claim(diagram, l0.HasTrigger, mapping);\r
+\r
+ graph.claim(model, simu.HasConfiguration, conf);\r
+ graph.claim(model, l0.HasBaseRealization, conf);\r
+\r
+ Resource report = GraphUtils.create2(graph, l0.Report, l0.HasDocumentation, "===Report===");\r
+\r
+ GraphUtils.create2(graph, simu.Experiment,\r
+ l0.HasName, "Experiment",\r
+ l0.HasLabel, "Experiment",\r
+ l0.HasReportFactory, report,\r
+ l0.PartOf, model);\r
+\r
+ for(Subscript s : subscripts) {\r
+ s.write(graph, conf, 0, 0);\r
+ }\r
+\r
+ // Create the grid n*n of views:\r
+ \r
+ double n = Math.sqrt(views.size());\r
+ n = Math.ceil(n);\r
+ \r
+ int width = 0, height = 0;\r
+ for(View v : views) {\r
+ if(v.getWidth() > width)\r
+ width = v.getWidth();\r
+ if(v.getHeight() > height)\r
+ height = v.getHeight();\r
+ }\r
+\r
+ for(int i = 0; i < n; i++) {\r
+ for(int j = 0; j < n; j++) {\r
+ int index = i * (int)n + j;\r
+ if(index < views.size()) {\r
+ View v = views.get(index);\r
+ v.setxOffset(width * j);\r
+ v.setyOffset(height * i);\r
+ v.write(graph, conf);\r
+ }\r
+ }\r
+ }\r
+ \r
+ for(Element e : unlocatedElements) {\r
+ e.write(graph, conf, 0, 0);\r
+ }\r
+\r
+ for(Connection c : connections) {\r
+ c.write(graph, conf);\r
+ }\r
+ \r
+ for(Function f : functions) {\r
+ f.write(graph, model, 0, 0);\r
+ }\r
+\r
+\r
+ } catch (DatabaseException e) {\r
+ e.printStackTrace();\r
+ }\r
+ }\r
+ \r
+ \r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2011 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.mdlImport.mdlElements;\r
+\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.WriteGraph;\r
+import org.simantics.db.exception.DatabaseException;\r
+\r
+public class ModelControl extends Variable {\r
+\r
+\r
+\r
+ @Override\r
+ public Resource getExpression(WriteGraph graph, Expression expression)\r
+ throws DatabaseException {\r
+ return null;\r
+ }\r
+\r
+ @Override\r
+ public void write(WriteGraph graph, Resource parent, double xOffset,\r
+ double yOffset) {\r
+ // TODO Auto-generated method stub\r
+ \r
+ }\r
+\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2011 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.mdlImport.mdlElements;\r
+\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.WriteGraph;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.layer0.utils.direct.GraphUtils;\r
+import org.simantics.sysdyn.SysdynResource;\r
+import org.simantics.sysdyn.mdlImport.ImportUtils;\r
+\r
+public class Stock extends Variable {\r
+\r
+ @Override\r
+ public Resource getExpression(WriteGraph graph, Expression expression) throws DatabaseException { \r
+\r
+ String integralEquation = ImportUtils.escapeExpression(getIntegralParts(expression)[1]);\r
+ SysdynResource sr = SysdynResource.getInstance(graph);\r
+ Resource e = GraphUtils.create2(graph, \r
+ sr.StockExpression,\r
+ sr.HasInitialEquation, integralEquation);\r
+ \r
+ return e;\r
+ }\r
+ \r
+ public String[] getIntegralParts(Expression expression) {\r
+ // Does not work, if the integral has some other logic than +inflows -outflows!\r
+ \r
+ // Parsing the possible functions. Searching ',' that divides the INTEG -function\r
+ int parenthesiscount = 0;\r
+ int location = 0;\r
+ char[] charArray = expression.getExpression().toCharArray();\r
+ for(int i = 0; i < charArray.length; i++) {\r
+ char c = charArray[i];\r
+ if(c == '(')\r
+ parenthesiscount++;\r
+ else if(c == ')')\r
+ parenthesiscount--;\r
+ else if(c == ',' && parenthesiscount == 1) {\r
+ location = i + 1;\r
+ break;\r
+ }\r
+ }\r
+ \r
+ String exp = expression.getExpression();\r
+ String initialEquation = exp.substring(location, exp.lastIndexOf(')')).trim();\r
+ String integral = exp.substring(exp.indexOf("(") + 1, location - 1).trim();\r
+ \r
+ \r
+ return new String[] {integral, initialEquation};\r
+ }\r
+\r
+ @Override\r
+ public void write(WriteGraph graph, Resource parent, double xOffset,\r
+ double yOffset) {\r
+ if(parent == null || graph == null)\r
+ return;\r
+ \r
+ try {\r
+ SysdynResource sr = SysdynResource.getInstance(graph);\r
+ if(!graph.isInstanceOf(parent, sr.Configuration))\r
+ return;\r
+ createVariable(graph, parent, sr.Stock, sr.StockSymbol, xOffset, yOffset);\r
+ } catch (DatabaseException e) {\r
+ e.printStackTrace();\r
+ }\r
+ \r
+ }\r
+\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2011 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.mdlImport.mdlElements;\r
+\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.WriteGraph;\r
+import org.simantics.db.common.utils.OrderedSetUtils;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.layer0.Layer0;\r
+import org.simantics.layer0.utils.direct.GraphUtils;\r
+import org.simantics.sysdyn.SysdynResource;\r
+\r
+public class Subscript extends Variable {\r
+\r
+ @Override\r
+ public Resource getExpression(WriteGraph graph, Expression expression)\r
+ throws DatabaseException {\r
+ return null;\r
+ }\r
+\r
+ @Override\r
+ public void write(WriteGraph graph, Resource parent, double xOffset,\r
+ double yOffset) {\r
+ if(parent == null || graph == null)\r
+ return;\r
+ \r
+ try {\r
+ SysdynResource sr = SysdynResource.getInstance(graph);\r
+ if(!graph.isInstanceOf(parent, sr.Configuration))\r
+ return;\r
+ Layer0 l0 = Layer0.getInstance(graph); \r
+ Resource enumerationIndexes = OrderedSetUtils.create(graph, sr.EnumerationIndexes);\r
+\r
+ if(expressions != null && expressions.get(0) != null) {\r
+ String[] indexes = expressions.get(0).getExpression().split(",");\r
+ for(String s : indexes) {\r
+ Resource ei = GraphUtils.create2(graph, \r
+ sr.EnumerationIndex,\r
+ l0.HasName, s.trim());\r
+ OrderedSetUtils.add(graph, enumerationIndexes, ei);\r
+ }\r
+ }\r
+\r
+ Resource enumeration = GraphUtils.create2(graph, \r
+ sr.Enumeration,\r
+ l0.HasName, this.getName(),\r
+ sr.HasEnumerationIndexes, enumerationIndexes);\r
+\r
+ graph.claim(parent, l0.ConsistsOf, enumeration);\r
+\r
+ resource = enumeration;\r
+ } catch (DatabaseException e) {\r
+ e.printStackTrace();\r
+ }\r
+ }\r
+\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2011 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.mdlImport.mdlElements;\r
+\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.WriteGraph;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.layer0.utils.direct.GraphUtils;\r
+import org.simantics.sysdyn.SysdynResource;\r
+import org.simantics.sysdyn.mdlImport.ImportUtils;\r
+\r
+public class Valve extends Variable {\r
+\r
+ @Override\r
+ public Resource getExpression(WriteGraph graph, Expression expression) throws DatabaseException {\r
+ SysdynResource sr = SysdynResource.getInstance(graph);\r
+ String expressionString = ImportUtils.escapeExpression(expression.getExpression());\r
+ Resource e = GraphUtils.create2(graph, \r
+ sr.NormalExpression,\r
+ sr.HasEquation, expressionString.trim());\r
+ return e;\r
+ }\r
+\r
+ @Override\r
+ public void write(WriteGraph graph, Resource parent, double xOffset,\r
+ double yOffset) {\r
+ try {\r
+ SysdynResource sr = SysdynResource.getInstance(graph);\r
+ if(!graph.isInstanceOf(parent, sr.Configuration))\r
+ return;\r
+ createVariable(graph, parent, sr.Valve, sr.ValveSymbol, xOffset, yOffset);\r
+ } catch (DatabaseException e) {\r
+ e.printStackTrace();\r
+ }\r
+ }\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2011 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.mdlImport.mdlElements;\r
+\r
+import java.util.ArrayList;\r
+\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.WriteGraph;\r
+import org.simantics.db.common.utils.OrderedSetUtils;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.diagram.stubs.DiagramResource;\r
+import org.simantics.diagram.stubs.G2DResource;\r
+import org.simantics.layer0.Layer0;\r
+import org.simantics.layer0.utils.direct.GraphUtils;\r
+import org.simantics.modeling.ModelingResources;\r
+import org.simantics.sysdyn.SysdynResource;\r
+import org.simantics.sysdyn.mdlImport.ImportUtils;\r
+\r
+public abstract class Variable extends Element {\r
+ protected String units;\r
+ protected String comments;\r
+ protected ArrayList<Expression> expressions;\r
+ protected ArrayList<Subscript> subscripts;\r
+\r
+ private Double rangeStart, rangeEnd, rangeStep;\r
+ \r
+ protected void createVariable(WriteGraph graph, Resource configuration, Resource variableType, Resource symbolType, double xOffset, double yOffset) throws DatabaseException {\r
+ SysdynResource sr = SysdynResource.getInstance(graph);\r
+ Layer0 l0 = Layer0.getInstance(graph); \r
+ ModelingResources mr = ModelingResources.getInstance(graph);\r
+ DiagramResource dr = DiagramResource.getInstance(graph);\r
+ G2DResource g2d = G2DResource.getInstance(graph);\r
+ \r
+ Resource diagram = graph.getSingleObject(configuration, mr.CompositeToDiagram);\r
+ if(diagram == null)\r
+ return;\r
+ \r
+ Resource expressionList = OrderedSetUtils.create(graph, sr.Expressions);\r
+ \r
+ // Make sure at least one expression exist\r
+ if(getExpressions().isEmpty()) {\r
+ Expression e = new Expression();\r
+ e.setExpression("");\r
+ getExpressions().add(e);\r
+ }\r
+ \r
+ for(Expression e : getExpressions()) {\r
+ \r
+ // Get expression from the variable. They have different types\r
+ Resource expression = getExpression(graph, e);\r
+ \r
+ if(e.getRange() != null) {\r
+ graph.claimLiteral(expression, sr.HasArrayRange, "[" + e.getRange().trim() + "]");\r
+ }\r
+ OrderedSetUtils.add(graph, expressionList, expression);\r
+ }\r
+ \r
+ Resource arrayIndexList = OrderedSetUtils.create(graph, sr.ArrayIndexes);\r
+ \r
+\r
+ Resource variable = GraphUtils.create2(graph, \r
+ variableType,\r
+ l0.HasName, ImportUtils.escapeName(name),\r
+ sr.HasExpressions, expressionList);\r
+ graph.claim(variable, mr.Mapped, variable);\r
+ \r
+ \r
+ if(subscripts != null) {\r
+ for(Subscript sub : subscripts) {\r
+ if(sub.getResource() != null)\r
+ OrderedSetUtils.add(graph, arrayIndexList, sub.getResource());\r
+ }\r
+ graph.claim(variable, sr.HasArrayIndexes, arrayIndexList);\r
+ }\r
+ \r
+ if(units != null && units.length() > 0)\r
+ graph.claimLiteral(variable, sr.HasUnit, units);\r
+ if(comments != null && comments.length() > 0)\r
+ graph.claimLiteral(variable, l0.HasDescription, comments);\r
+ if(rangeStart != null)\r
+ graph.claimLiteral(variable, sr.HasRangeStart, rangeStart);\r
+ if(rangeEnd != null)\r
+ graph.claimLiteral(variable, sr.HasRangeEnd, rangeEnd);\r
+ if(rangeStep != null)\r
+ graph.claimLiteral(variable, sr.HasRangeStep, rangeStep);\r
+ \r
+ graph.claim(configuration, l0.ConsistsOf, variable);\r
+ \r
+ \r
+ Resource symbol = GraphUtils.create2(graph, \r
+ symbolType,\r
+ mr.ElementToComponent, variable);\r
+ \r
+ double[] transform = {1.0, 0.0, 0.0, 1.0, x + xOffset, y + yOffset};\r
+ graph.claimLiteral(symbol, dr.HasTransform, g2d.Transform, transform);\r
+ \r
+ OrderedSetUtils.add(graph, diagram, symbol);\r
+ \r
+ resource = variable;\r
+ }\r
+ \r
+ \r
+ public String getUnits() {\r
+ return units;\r
+ }\r
+\r
+ public void setUnits(String units) {\r
+ this.units = units;\r
+ }\r
+\r
+ public String getComments() {\r
+ return comments;\r
+ }\r
+\r
+ public void setComments(String comments) {\r
+ this.comments = comments;\r
+ }\r
+\r
+ public ArrayList<Expression> getExpressions() {\r
+ if(expressions == null) {\r
+ expressions = new ArrayList<Expression>();\r
+ }\r
+ return expressions;\r
+ }\r
+\r
+ public void setExpressions(ArrayList<Expression> expressions) {\r
+ this.expressions = expressions;\r
+ }\r
+\r
+ public ArrayList<Subscript> getSubscripts() {\r
+ if(subscripts == null)\r
+ subscripts = new ArrayList<Subscript>();\r
+ return subscripts;\r
+ }\r
+\r
+ public void setSubscripts(ArrayList<Subscript> subscripts) {\r
+ this.subscripts = subscripts;\r
+ }\r
+ \r
+\r
+ public Double getRangeStart() {\r
+ return rangeStart;\r
+ }\r
+\r
+ public void setRangeStart(Double rangeStart) {\r
+ this.rangeStart = rangeStart;\r
+ }\r
+\r
+ public Double getRangeEnd() {\r
+ return rangeEnd;\r
+ }\r
+\r
+ public void setRangeEnd(Double rangeEnd) {\r
+ this.rangeEnd = rangeEnd;\r
+ }\r
+\r
+ public Double getRangeStep() {\r
+ return rangeStep;\r
+ }\r
+\r
+ public void setRangeStep(Double rangeStep) {\r
+ this.rangeStep = rangeStep;\r
+ }\r
+ \r
+ /**\r
+ * Use this to set subscripts after all elements have been read\r
+ * \r
+ * @param model The model where the variable is located\r
+ */\r
+ public void initializeSubscripts(Model model) {\r
+ for(Expression ex : getExpressions()) {\r
+ if(ex.getRange() != null) {\r
+ \r
+ // Subscripts exist, check that subscripts -array is initialized\r
+ getSubscripts();\r
+ \r
+ String[] elements = ex.getRange().split(",");\r
+ // Search the corresponding subscript for each element, if it has not been searched already\r
+ for(int i = 0; i < elements.length; i++) {\r
+ // The subscript has been defined, move to next\r
+ if(subscripts.size() > i)\r
+ continue;\r
+ \r
+ String element = elements[i].trim();\r
+ for(Subscript sub : model.getSubscripts()) {\r
+ if(sub.getName().equals(element)) {\r
+ subscripts.add(sub);\r
+ break;\r
+ }\r
+ for(String index : sub.getExpressions().get(0).getExpression().split(",")) {\r
+ if(index.trim().equals(element)) {\r
+ subscripts.add(sub);\r
+ break;\r
+ }\r
+ }\r
+ // Subscript was defined for this index in previous for-loop\r
+ if(subscripts.size() == i + 1)\r
+ break;\r
+ }\r
+ }\r
+ }\r
+ }\r
+ }\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2011 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.mdlImport.mdlElements;\r
+\r
+import java.util.ArrayList;\r
+\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.WriteGraph;\r
+\r
+public class View implements IWriteableMDLObject {\r
+ \r
+ private int minX = 0, maxX = 0, minY = 0, maxY = 0;\r
+ private double xOffset = 0, yOffset = 0;\r
+ private String name, fontParameters;\r
+ \r
+ private ArrayList<Element> elements = new ArrayList<Element>();\r
+ \r
+\r
+ @Override\r
+ public void write(WriteGraph graph, Resource parent) {\r
+ xOffset = xOffset - minX;\r
+ yOffset = yOffset - minY;\r
+ for(Element e : elements) {\r
+ e.write(graph, parent, xOffset, yOffset);\r
+ }\r
+ }\r
+ \r
+ public void addElement(Element e) {\r
+ if(e instanceof Subscript ||\r
+ e instanceof Function)\r
+ return;\r
+ \r
+ if(e.getX()<minX)\r
+ minX = e.getX();\r
+ if(e.getX()>maxX)\r
+ maxX = e.getX();\r
+ if(e.getY()<minY)\r
+ minY = e.getY();\r
+ if(e.getY()>maxY)\r
+ maxY = e.getY();\r
+ this.elements.add(e);\r
+ }\r
+ \r
+ public ArrayList<Element> getElements() {\r
+ return elements;\r
+ }\r
+\r
+ public void setElements(ArrayList<Element> elements) {\r
+ this.elements = elements;\r
+ }\r
+ \r
+ public String getName() {\r
+ return name;\r
+ }\r
+\r
+ public void setName(String name) {\r
+ this.name = name;\r
+ }\r
+\r
+\r
+ public String getFontParameters() {\r
+ return fontParameters;\r
+ }\r
+\r
+\r
+ public void setFontParameters(String fontParameters) {\r
+ this.fontParameters = fontParameters;\r
+ }\r
+\r
+\r
+ public int getMinX() {\r
+ return minX;\r
+ }\r
+\r
+ public void setMinX(int minX) {\r
+ this.minX = minX;\r
+ }\r
+\r
+ public int getMaxX() {\r
+ return maxX;\r
+ }\r
+\r
+ public void setMaxX(int maxX) {\r
+ this.maxX = maxX;\r
+ }\r
+\r
+ public int getMinY() {\r
+ return minY;\r
+ }\r
+\r
+ public void setMinY(int minY) {\r
+ this.minY = minY;\r
+ }\r
+\r
+ public int getMaxY() {\r
+ return maxY;\r
+ }\r
+\r
+ public void setMaxY(int maxY) {\r
+ this.maxY = maxY;\r
+ }\r
+\r
+ public double getxOffset() {\r
+ return xOffset;\r
+ }\r
+\r
+ public void setxOffset(double xOffset) {\r
+ this.xOffset = xOffset;\r
+ }\r
+\r
+ public double getyOffset() {\r
+ return yOffset;\r
+ }\r
+\r
+ public void setyOffset(double yOffset) {\r
+ this.yOffset = yOffset;\r
+ }\r
+ \r
+ public int getWidth() {\r
+ return maxX - minX;\r
+ }\r
+ \r
+ public int getHeight() {\r
+ return maxY - minY;\r
+ }\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2010 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.modelica;\r
+\r
+import java.util.ArrayList;\r
+import java.util.HashMap;\r
+\r
+import org.simantics.sysdyn.representation.Configuration;\r
+import org.simantics.sysdyn.representation.Dependency;\r
+import org.simantics.sysdyn.representation.Enumeration;\r
+import org.simantics.sysdyn.representation.IElement;\r
+import org.simantics.sysdyn.representation.IndependentVariable;\r
+import org.simantics.sysdyn.representation.Input;\r
+import org.simantics.sysdyn.representation.Module;\r
+import org.simantics.sysdyn.representation.ModuleType;\r
+import org.simantics.sysdyn.representation.Stock;\r
+import org.simantics.sysdyn.representation.Variable;\r
+\r
+public class ModelicaWriter {\r
+\r
+ StringBuilder b = new StringBuilder();\r
+ String app;\r
+ boolean enumerationsWritten = false;\r
+\r
+ public void write(Configuration conf) {\r
+\r
+ if(!enumerationsWritten) {\r
+ b.append("partial class Enumeration_class\n");\r
+ b.append(" parameter Integer size;\n");\r
+ b.append(" parameter Integer elements[:];\n");\r
+ b.append("end Enumeration_class;\n\n");\r
+ enumerationsWritten = true;\r
+ }\r
+ \r
+ writeConfiguration(conf);\r
+ }\r
+\r
+ private void writeConfiguration(Configuration configuration) {\r
+\r
+ ArrayList<IndependentVariable> variables = new ArrayList<IndependentVariable>();\r
+ ArrayList<Input> inputs = new ArrayList<Input>();\r
+ ArrayList<Module> modules = new ArrayList<Module>();\r
+ ArrayList<Stock> stocks = new ArrayList<Stock>();\r
+ ArrayList<Enumeration> enumerations = new ArrayList<Enumeration>();\r
+ ArrayList<Dependency> inputDependencies = new ArrayList<Dependency>();\r
+ ArrayList<Dependency> outputDependencies = new ArrayList<Dependency>();\r
+ HashMap<String, ArrayList<Input>> moduleInputs = new HashMap<String, ArrayList<Input>>();\r
+\r
+ // Initialize lists\r
+ for(IElement element : configuration.getElements()) {\r
+ if(element instanceof IndependentVariable) {\r
+ variables.add((IndependentVariable)element);\r
+ if(element instanceof Stock)\r
+ stocks.add((Stock)element);\r
+ } else if (element instanceof Module) {\r
+ Module m = (Module)element; \r
+ modules.add(m);\r
+ moduleInputs.put(m.getName(), new ArrayList<Input>());\r
+ for(IElement e : m.getType().getConfiguration().getElements())\r
+ if(e instanceof Input && !((Input)e).isHeadOfDependency()) {\r
+ moduleInputs.get(m.getName()).add((Input)e);\r
+ }\r
+ } else if (element instanceof Input) {\r
+ inputs.add((Input)element);\r
+ } else if (element instanceof Enumeration) {\r
+ enumerations.add((Enumeration)element);\r
+ } else if (element instanceof Dependency && ((Dependency)element).refersTo() != null) {\r
+ Dependency dependency = (Dependency)element;\r
+ if(dependency.getHead() instanceof Module) {\r
+ outputDependencies.add(dependency);\r
+ } else if(dependency.getTail() instanceof Module){\r
+ inputDependencies.add(dependency);\r
+ }\r
+ }\r
+ }\r
+\r
+ ModuleType mt = configuration.getModuleType();\r
+ String className = mt != null ? (mt.getName().replace(" ", "")) : (configuration.getName().replace(" ", ""));\r
+ b.append("class ").append(className).append('\n');\r
+\r
+ b.append("// Variable definitions\n");\r
+ for(IndependentVariable variable : variables) {\r
+ app = variable.getDeclaration();\r
+ if (app != null) b.append(app);\r
+ }\r
+\r
+ if(!modules.isEmpty()) {\r
+ b.append("// Module definitions\n");\r
+ for(Module m : modules) {\r
+ b.append(m.getDeclaration());\r
+ }\r
+ }\r
+\r
+ if(!inputs.isEmpty()) {\r
+ b.append("// Input definitions\n");\r
+ for(Input i : inputs) {\r
+ b.append(i.getDeclaration());\r
+ }\r
+ }\r
+ \r
+ if(!enumerations.isEmpty()) {\r
+ b.append("// Enumeration definitions\n");\r
+ for(Enumeration e : enumerations) {\r
+ b.append(e.getDeclaration());\r
+ }\r
+ }\r
+\r
+ boolean initialEquations = false;\r
+ for(Stock stock : stocks) {\r
+ app = stock.getInitialEquation();\r
+ if (app != null) {\r
+ if(initialEquations == false) {\r
+ initialEquations = true;\r
+ b.append("// Initial Equations\n");\r
+ b.append("initial equation\n");\r
+ }\r
+ b.append(app);\r
+ }\r
+ }\r
+\r
+ b.append("equation\n");\r
+\r
+ b.append("// Equations\n");\r
+ for(IndependentVariable variable : variables) {\r
+ app = variable.getEquation();\r
+ if (app != null) b.append(app);\r
+ }\r
+\r
+\r
+ b.append("// Inputs\n");\r
+ for(Dependency dependency : inputDependencies) {\r
+ Input variable = (Input)dependency.getHead();\r
+ Module module = (Module)dependency.getTail();\r
+ Variable reference = (Variable)dependency.refersTo();\r
+ b.append(" " + variable.getName() + " = " + module.getName() + "." + reference.getName() + ";\n");\r
+ }\r
+\r
+ b.append("// Outputs\n");\r
+ for(Dependency dependency : outputDependencies) {\r
+ Variable variable = (Variable)dependency.getTail();\r
+ Module module = (Module)dependency.getHead();\r
+ Input reference = (Input)dependency.refersTo();\r
+ b.append(" " + module.getName() + "." + reference.getName() + " = " + variable.getName() + ";\n");\r
+ moduleInputs.get(module.getName()).remove(reference);\r
+ }\r
+\r
+ b.append("// Default values for inputs in modules\n");\r
+ for(String moduleLabel : moduleInputs.keySet()) {\r
+ for(Input input : moduleInputs.get(moduleLabel)) {\r
+ b.append(" " + moduleLabel + "." + input.getName() + " = " + input.getDefaultInputValue() + ";\n");\r
+ }\r
+ }\r
+\r
+ b.append("end ").append(className).append(";\n\n");\r
+\r
+\r
+// for(Module m : modules) {\r
+// writeConfiguration(m.getConfiguration());\r
+// }\r
+\r
+ }\r
+\r
+ public String escape(String name) {\r
+ return name.replace(' ', '_');\r
+ }\r
+\r
+ @Override\r
+ public String toString() {\r
+ return b.toString();\r
+ }\r
+\r
+}\r
--- /dev/null
+package org.simantics.sysdyn.representation;\r
+\r
+import java.util.ArrayList;\r
+\r
+import org.simantics.objmap.annotations.GraphType;\r
+import org.simantics.objmap.annotations.RelatedOrderedSetElements;\r
+\r
+@GraphType("http://www.simantics.org/Sysdyn-1.0/ArrayIndexes")\r
+public class ArrayIndexes {\r
+ \r
+ @RelatedOrderedSetElements\r
+ private ArrayList<Enumeration> enumerations = new ArrayList<Enumeration>();\r
+\r
+ public ArrayList<Enumeration> getEnumerations() {\r
+ return enumerations;\r
+ }\r
+\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2010 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.representation;\r
+\r
+import org.simantics.objmap.annotations.GraphType;\r
+import org.simantics.sysdyn.representation.visitors.IElementVisitorVoid;\r
+\r
+@GraphType("http://www.simantics.org/Sysdyn-1.0/Auxiliary")\r
+public class Auxiliary extends IndependentVariable {\r
+ @Override\r
+ public void accept(IElementVisitorVoid v) {\r
+ v.visit(this);\r
+ }\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2010 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.representation;\r
+\r
+import org.simantics.objmap.annotations.GraphType;\r
+import org.simantics.sysdyn.representation.visitors.IElementVisitorVoid;\r
+\r
+@GraphType("http://www.simantics.org/Sysdyn-1.0/Cloud")\r
+public class Cloud implements IElement {\r
+ @Override\r
+ public void accept(IElementVisitorVoid v) {\r
+ v.visit(this);\r
+ }\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2010 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.representation;\r
+\r
+import java.util.ArrayList;\r
+\r
+import org.simantics.objmap.annotations.GraphType;\r
+import org.simantics.objmap.annotations.RelatedElement;\r
+import org.simantics.objmap.annotations.RelatedElements;\r
+import org.simantics.objmap.annotations.RelatedValue;\r
+\r
+\r
+@GraphType("http://www.simantics.org/Sysdyn-1.0/Configuration")\r
+public class Configuration {\r
+ \r
+ @RelatedValue("http://www.simantics.org/Layer0-1.0/HasName")\r
+ private String name;\r
+\r
+ @RelatedValue("http://www.simantics.org/Layer0-1.0/HasLabel")\r
+ private String label;\r
+ \r
+ @RelatedElement("http://www.simantics.org/Structural-1.0/Defines")\r
+ private ModuleType moduleType;\r
+ \r
+ @RelatedElement("http://www.simantics.org/Simulation-1.0/IsConfigurationOf")\r
+ private Model model;\r
+\r
+ @RelatedElements(\r
+ value = "http://www.simantics.org/Layer0-1.0/ConsistsOf",\r
+ composition = true)\r
+ private ArrayList<IElement> elements = new ArrayList<IElement>();\r
+\r
+\r
+ public ArrayList<IElement> getElements() {\r
+ return elements;\r
+ }\r
+\r
+ public String getName() {\r
+ return name;\r
+ }\r
+\r
+ public String getLabel() {\r
+ return label;\r
+ }\r
+ \r
+ public ModuleType getModuleType() {\r
+ return moduleType;\r
+ }\r
+ \r
+ public Model getModel() {\r
+ return model;\r
+ }\r
+ \r
+ \r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2010 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.representation;\r
+\r
+import org.simantics.objmap.annotations.GraphType;\r
+import org.simantics.objmap.annotations.RelatedElement;\r
+import org.simantics.sysdyn.representation.visitors.IElementVisitorVoid;\r
+\r
+@GraphType("http://www.simantics.org/Sysdyn-1.0/Dependency")\r
+public class Dependency implements IElement {\r
+ @RelatedElement("http://www.simantics.org/Sysdyn-1.0/HasTail")\r
+ private IElement tail;\r
+ @RelatedElement("http://www.simantics.org/Sysdyn-1.0/HasHead")\r
+ private IElement head;\r
+ @RelatedElement("http://www.simantics.org/Sysdyn-1.0/RefersTo")\r
+ private IElement refersTo;\r
+ \r
+ @Override\r
+ public void accept(IElementVisitorVoid v) {\r
+ v.visit(this); \r
+ }\r
+ \r
+ public IElement getTail() {\r
+ return this.tail;\r
+ }\r
+ \r
+ public IElement getHead() {\r
+ return this.head;\r
+ }\r
+ \r
+ public IElement refersTo() {\r
+ return this.refersTo;\r
+ }\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2011 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.representation;\r
+\r
+import java.util.ArrayList;\r
+\r
+import org.simantics.objmap.annotations.GraphType;\r
+import org.simantics.objmap.annotations.RelatedElement;\r
+import org.simantics.objmap.annotations.RelatedElements;\r
+import org.simantics.objmap.annotations.RelatedValue;\r
+import org.simantics.sysdyn.representation.visitors.IElementVisitorVoid;\r
+\r
+@GraphType("http://www.simantics.org/Sysdyn-1.0/Enumeration")\r
+public class Enumeration extends Variable {\r
+ \r
+ @RelatedElement("http://www.simantics.org/Sysdyn-1.0/HasEnumerationIndexes")\r
+ private EnumerationIndexes enumerationIndexes;\r
+ \r
+ @RelatedValue("http://www.simantics.org/Sysdyn-1.0/IsReplaceable")\r
+ private Boolean isReplaceable;\r
+ \r
+ @RelatedElements(\r
+ value = "http://www.simantics.org/Sysdyn-1.0/ReplacedEnumeration/Inverse",\r
+ composition = true)\r
+ private ArrayList<Redeclaration> redeclarations = new ArrayList<Redeclaration>();\r
+\r
+ @Override\r
+ public void accept(IElementVisitorVoid v) {\r
+ v.visit(this); \r
+ }\r
+ \r
+ public String getDeclaration() {\r
+ StringBuilder sb = new StringBuilder();\r
+ sb.append(getEnumerationClassDefinition());\r
+ sb.append(" ");\r
+ sb.append(this.name + "_class");\r
+ sb.append(" " + this.name);\r
+ sb.append(";\n");\r
+ return sb.toString();\r
+ }\r
+ \r
+ public ArrayList<EnumerationIndex> getEnumerationIndexes() {\r
+ return enumerationIndexes.getEnumerationIndexes();\r
+ }\r
+ \r
+ public boolean isReplaceable() {\r
+ return Boolean.TRUE.equals(isReplaceable);\r
+ }\r
+ \r
+ public String getEnumerationClassDefinition() {\r
+ \r
+ // Build indexes (one = 1, two = 2, etc..) and elements {1,2,3,..,size}\r
+ ArrayList<EnumerationIndex> indexes = getEnumerationIndexes();\r
+ StringBuilder elementsBuilder = new StringBuilder();\r
+ elementsBuilder.append("{");\r
+ StringBuilder indexesBuilder = new StringBuilder();\r
+ for(int i = 1; i <= indexes.size(); i++) {\r
+ indexesBuilder.append(" constant Integer ");\r
+ indexesBuilder.append(indexes.get(i - 1).getName());\r
+ indexesBuilder.append(" = " + i + ";\n");\r
+ \r
+ elementsBuilder.append(i);\r
+ if(i < indexes.size())\r
+ elementsBuilder.append(",");\r
+ }\r
+ elementsBuilder.append("}");\r
+ \r
+ /*\r
+ * class E_class\r
+ * extends Enumeration_class(size = n, elements = {1,2,3,..n});\r
+ * constant Integer index1 = 1;\r
+ * constant Integer index2 = 2;\r
+ * ....\r
+ * constant Integer indexn = n;\r
+ * end E_class;\r
+ */\r
+ \r
+ StringBuilder sb = new StringBuilder();\r
+ sb.append(" class ");\r
+ sb.append(this.name);\r
+ sb.append("_class\n");\r
+ sb.append(" extends Enumeration_class(size=");\r
+ sb.append(indexes.size());\r
+ sb.append(", elements=");\r
+ sb.append(elementsBuilder);\r
+ sb.append(");\n");\r
+ sb.append(indexesBuilder);\r
+ sb.append(" end ");\r
+ sb.append(this.name);\r
+ sb.append("_class;\n");\r
+ \r
+ return sb.toString();\r
+ }\r
+ \r
+ public ArrayList<Redeclaration> getRedeclarations() {\r
+ return redeclarations;\r
+ }\r
+\r
+}\r
--- /dev/null
+package org.simantics.sysdyn.representation;\r
+\r
+import org.simantics.objmap.annotations.GraphType;\r
+import org.simantics.objmap.annotations.RelatedValue;\r
+\r
+@GraphType("http://www.simantics.org/Sysdyn-1.0/EnumerationIndex")\r
+public class EnumerationIndex {\r
+\r
+ @RelatedValue("http://www.simantics.org/Layer0-1.0/HasName")\r
+ protected String name;\r
+ \r
+ public String getName() {\r
+ return this.name;\r
+ }\r
+\r
+}\r
--- /dev/null
+package org.simantics.sysdyn.representation;\r
+\r
+import java.util.ArrayList;\r
+\r
+import org.simantics.objmap.annotations.GraphType;\r
+import org.simantics.objmap.annotations.RelatedOrderedSetElements;\r
+\r
+@GraphType("http://www.simantics.org/Sysdyn-1.0/EnumerationIndexes")\r
+public class EnumerationIndexes {\r
+ \r
+ @RelatedOrderedSetElements\r
+ private ArrayList<EnumerationIndex> enumerationIndexes = new ArrayList<EnumerationIndex>();\r
+\r
+ public ArrayList<EnumerationIndex> getEnumerationIndexes() {\r
+ return enumerationIndexes;\r
+ }\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2010 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.representation;\r
+\r
+import org.simantics.objmap.annotations.GraphType;\r
+import org.simantics.objmap.annotations.RelatedElement;\r
+import org.simantics.sysdyn.representation.visitors.IElementVisitorVoid;\r
+\r
+@GraphType("http://www.simantics.org/Sysdyn-1.0/Flow")\r
+public class Flow implements IElement {\r
+ @RelatedElement("http://www.simantics.org/Sysdyn-1.0/HasTail")\r
+ private IElement tail;\r
+ @RelatedElement("http://www.simantics.org/Sysdyn-1.0/HasHead")\r
+ private IElement head;\r
+ \r
+ @Override\r
+ public void accept(IElementVisitorVoid v) {\r
+ v.visit(this); \r
+ }\r
+ \r
+ public IElement getTail() {\r
+ return this.tail;\r
+ }\r
+ \r
+ public IElement getHead() {\r
+ return this.head;\r
+ }\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2010 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.representation;\r
+\r
+import org.simantics.sysdyn.representation.visitors.IElementVisitorVoid;\r
+\r
+public interface IElement {\r
+ void accept(IElementVisitorVoid v);\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2010 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.representation;\r
+\r
+import java.util.ArrayList;\r
+\r
+import org.simantics.sysdyn.representation.expressions.IExpression;\r
+import org.simantics.sysdyn.representation.expressions.ParameterExpression;\r
+\r
+public abstract class IndependentVariable extends Variable {\r
+ \r
+ public String getDeclaration() {\r
+ ArrayList<IExpression> expressions = this.expressions.getExpressions();\r
+ return expressions.get(0).getDeclaration(this);\r
+ \r
+ /*\r
+ ArrayList<IExpression> expressions = this.expressions.getExpressions();\r
+ ArrayIndexes ai = this.getArrayIndexes();\r
+ ArrayList<Enumeration> enumerations = null;\r
+ if(ai != null) \r
+ enumerations = ai.getEnumerations();\r
+ if(enumerations == null || enumerations.size() < 1) {\r
+ // NOT an array variable, get declaration from the only expression.\r
+ if(expressions.get(0) == null)\r
+ return null;\r
+ else\r
+ return expressions.get(0).getDeclaration(this);\r
+ } else {\r
+ // ARRAY variable. Create declaration according to the type, name and indexes\r
+ //TODO: check if all of them are parameters -> form a parameter\r
+ StringBuilder sb = new StringBuilder();\r
+ sb.append(" ");\r
+ sb.append(this.getType());\r
+ sb.append(" ");\r
+ sb.append(this.getName());\r
+ sb.append("[");\r
+ Iterator<Enumeration> iterator = enumerations.iterator();\r
+ while(iterator.hasNext()) {\r
+ sb.append(iterator.next().getName());\r
+ if(iterator.hasNext()) {\r
+ sb.append(", ");\r
+ }\r
+ }\r
+ sb.append("];\n");\r
+ return sb.toString();\r
+ }\r
+ */\r
+ }\r
+ \r
+ public String getInitialEquation() {\r
+ StringBuilder sb = new StringBuilder(); \r
+\r
+ for(IExpression expression : expressions.getExpressions()) {\r
+ String initialEquation = expression.getInitialEquation(this);\r
+ if(initialEquation != null)\r
+ sb.append(initialEquation);\r
+ }\r
+ String result = sb.toString();\r
+ return result.length() > 0 ? result : null;\r
+ }\r
+ \r
+ public String getEquation() {\r
+ ArrayList<IExpression> expressions = this.expressions.getExpressions();\r
+ ArrayIndexes ai = this.getArrayIndexes();\r
+ ArrayList<Enumeration> enumerations = null;\r
+ if(ai != null) \r
+ enumerations = ai.getEnumerations();\r
+ IExpression firstExpression = expressions.get(0);\r
+ if(enumerations == null || enumerations.size() < 1) {\r
+ // NOT an array variable, get equation from the only expression.\r
+ if(firstExpression == null || firstExpression instanceof ParameterExpression)\r
+ return null;\r
+ else\r
+ return firstExpression.getEquation(this);\r
+ } else {\r
+ // ARRAY variable. Create all equations for the variable\r
+ //TODO: check that it has not been a parameter\r
+ StringBuilder sb = new StringBuilder(); \r
+ for(IExpression expression : expressions) {\r
+ sb.append(expression.getEquation(this));\r
+ }\r
+ return sb.toString();\r
+ }\r
+ \r
+ }\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2010 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.representation;\r
+\r
+import java.util.ArrayList;\r
+import java.util.Iterator;\r
+import java.util.List;\r
+\r
+import org.simantics.objmap.annotations.GraphType;\r
+import org.simantics.objmap.annotations.RelatedElements;\r
+import org.simantics.objmap.annotations.RelatedValue;\r
+import org.simantics.sysdyn.representation.visitors.IElementVisitorVoid;\r
+\r
+@GraphType("http://www.simantics.org/Sysdyn-1.0/Input")\r
+public class Input extends Variable {\r
+\r
+ @RelatedValue("http://www.simantics.org/Sysdyn-1.0/HasDefaultInputValue")\r
+ private Double defaultInputValue;\r
+ @RelatedElements("http://www.simantics.org/Sysdyn-1.0/IsHeadOf")\r
+ private List<IElement> isHeadOf;\r
+ \r
+ \r
+ \r
+ @Override\r
+ public void accept(IElementVisitorVoid v) {\r
+ v.visit(this);\r
+ }\r
+\r
+ public String getDefaultInputValue() {\r
+ if( getArrayIndexes() == null || getArrayIndexes().getEnumerations().isEmpty()) {\r
+ return defaultInputValue.toString();\r
+ } else {\r
+ StringBuilder sb = new StringBuilder();\r
+ sb.append("fill(");\r
+ sb.append(defaultInputValue);\r
+ sb.append(", ");\r
+ Iterator<Enumeration> i = getArrayIndexes().getEnumerations().iterator();\r
+ while(i.hasNext()) {\r
+ Enumeration e = i.next();\r
+ sb.append(e.getEnumerationIndexes().size());\r
+ if(i.hasNext())\r
+ sb.append(", ");\r
+ }\r
+ sb.append(")");\r
+ return sb.toString();\r
+ }\r
+ }\r
+\r
+ public boolean isHeadOfDependency() {\r
+ return !isHeadOf.isEmpty();\r
+ }\r
+ \r
+ public String getDeclaration() {\r
+ ArrayIndexes ai = getArrayIndexes();\r
+ ArrayList<Enumeration> enumerations = null;\r
+ if(ai != null) \r
+ enumerations = ai.getEnumerations();\r
+ \r
+ String range = "";\r
+ if(enumerations != null && enumerations.size() > 0) {\r
+ StringBuilder sb = new StringBuilder();\r
+ sb.append("[");\r
+ Iterator<Enumeration> iterator = enumerations.iterator();\r
+ while(iterator.hasNext()) {\r
+ sb.append(iterator.next().getName() + ".size");\r
+ if(iterator.hasNext()) {\r
+ sb.append(", ");\r
+ }\r
+ }\r
+ sb.append("]");\r
+ range = sb.toString();\r
+ }\r
+ \r
+ return " " + getType() + " " + getName() + range + ";\n";\r
+ }\r
+}\r
--- /dev/null
+package org.simantics.sysdyn.representation;\r
+\r
+import org.simantics.objmap.annotations.GraphType;\r
+import org.simantics.sysdyn.representation.visitors.IElementVisitorVoid;\r
+\r
+\r
+@GraphType("http://www.simantics.org/Layer0-1.0/Library")\r
+public class LibraryDummy implements IElement {\r
+ \r
+ @Override\r
+ public void accept(IElementVisitorVoid v) {\r
+ v.visit(this); \r
+ }\r
+\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2010 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.representation;\r
+\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.Session;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.db.request.Read;\r
+import org.simantics.objmap.IMapping;\r
+import org.simantics.objmap.Mappings;\r
+\r
+public class LoadRepresentation {\r
+\r
+ public static Configuration loadConfiguration(Session session, final Resource configuration) throws DatabaseException {\r
+ return session.syncRequest(new Read<Configuration>() {\r
+\r
+ @Override\r
+ public Configuration perform(ReadGraph graph)\r
+ throws DatabaseException {\r
+ SysdynSchema schema = new SysdynSchema(graph);\r
+ IMapping mapping = Mappings.createWithoutListening(schema);\r
+ return (Configuration)mapping.map(graph, configuration); \r
+ }\r
+ \r
+ });\r
+ }\r
+ \r
+ public static IElement loadElement(Session session, final Resource element) throws DatabaseException {\r
+ return session.syncRequest(new Read<IElement>() {\r
+\r
+ @Override\r
+ public IElement perform(ReadGraph graph)\r
+ throws DatabaseException {\r
+ SysdynSchema schema = new SysdynSchema(graph);\r
+ IMapping mapping = Mappings.createWithoutListening(schema);\r
+ return (IElement)mapping.map(graph, element); \r
+ }\r
+ \r
+ });\r
+ }\r
+ \r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2010 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.representation;\r
+\r
+import org.simantics.objmap.annotations.GraphType;\r
+import org.simantics.objmap.annotations.RelatedValue;\r
+\r
+@GraphType("http://www.simantics.org/Sysdyn-1.0/SysdynModel")\r
+public class Model {\r
+\r
+ @RelatedValue("http://www.simantics.org/Sysdyn-1.0/HasStartTime")\r
+ private Double startTime = 0.0;\r
+ \r
+ @RelatedValue("http://www.simantics.org/Sysdyn-1.0/HasStopTime")\r
+ private Double stopTime = 10.0;\r
+ \r
+ @RelatedValue("http://www.simantics.org/Sysdyn-1.0/HasOutputInterval")\r
+ private Double outputInterval;\r
+ \r
+ @RelatedValue("http://www.simantics.org/Sysdyn-1.0/HasTolerance")\r
+ private Double tolerance;\r
+ \r
+ @RelatedValue("http://www.simantics.org/Sysdyn-1.0/HasSolver")\r
+ private String solver;\r
+\r
+ public Double getStartTime() {\r
+ return startTime;\r
+ }\r
+\r
+ public Double getStopTime() {\r
+ return stopTime;\r
+ }\r
+ \r
+ public Double getOutputInterval() {\r
+ return outputInterval;\r
+ }\r
+\r
+ public Double getTolerance() {\r
+ return tolerance;\r
+ }\r
+\r
+ public String getSolver() {\r
+ return solver;\r
+ }\r
+ \r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2010 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.representation;\r
+\r
+import java.util.ArrayList;\r
+import java.util.Iterator;\r
+import java.util.List;\r
+\r
+import org.simantics.objmap.annotations.GraphType;\r
+import org.simantics.objmap.annotations.RelatedElement;\r
+import org.simantics.objmap.annotations.RelatedElements;\r
+import org.simantics.objmap.annotations.RelatedValue;\r
+import org.simantics.sysdyn.representation.visitors.IElementVisitorVoid;\r
+\r
+@GraphType("http://www.simantics.org/Sysdyn-1.0/Module")\r
+public class Module implements IElement {\r
+\r
+ @RelatedValue("http://www.simantics.org/Layer0-1.0/HasName")\r
+ private String name;\r
+\r
+ @RelatedElement("http://www.simantics.org/Layer0-1.0/PartOf")\r
+ private Configuration parentConfiguration;\r
+\r
+ @RelatedElement("http://www.simantics.org/Layer0-1.0/InstanceOf")\r
+ private ModuleType type;\r
+ \r
+ @RelatedElements("http://www.simantics.org/Sysdyn-1.0/HasRedeclaration")\r
+ private List<Redeclaration> redeclarations;\r
+ \r
+ @Override\r
+ public void accept(IElementVisitorVoid v) {\r
+ v.visit(this);\r
+ }\r
+\r
+ public String getName() {\r
+ return name;\r
+ }\r
+ \r
+ public ModuleType getType() {\r
+ return type;\r
+ }\r
+ \r
+ /**\r
+ * Returns the declaration of a module with possible redeclared enumerations\r
+ * \r
+ * Module m(redeclare type E1 = enumeration(i1, i2, i3), redeclare type E2 = enumeration(i4, i5, i6));\r
+ * \r
+ * @return Declaration of a module instance\r
+ */\r
+ public String getDeclaration() {\r
+ StringBuilder sb = new StringBuilder();\r
+ sb.append(" ");\r
+ sb.append(getType().getName());\r
+ sb.append(" ");\r
+ sb.append(getName());\r
+ if(!getRedeclarations().isEmpty()) {\r
+ sb.append("(");\r
+ Iterator<Redeclaration> i = getRedeclarations().iterator();\r
+ while(i.hasNext()) {\r
+ Redeclaration rd = i.next();\r
+ sb.append(rd.getRedeclaration());\r
+ if(i.hasNext())\r
+ sb.append(",");\r
+ }\r
+ sb.append(")");\r
+ }\r
+ sb.append(";\n");\r
+ return sb.toString();\r
+ }\r
+\r
+ public Configuration getParentConfiguration() {\r
+ return this.parentConfiguration;\r
+ }\r
+ \r
+ /**\r
+ * Return the list of the defined redeclarations for this module instance.\r
+ * \r
+ * @return List of the defined redeclarations or an empty list if redeclarations have not been set \r
+ */\r
+ public List<Redeclaration> getRedeclarations() {\r
+ if(redeclarations == null) {\r
+ redeclarations = new ArrayList<Redeclaration>();\r
+ }\r
+ return redeclarations;\r
+ }\r
+\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2010 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.representation;\r
+\r
+import org.simantics.objmap.annotations.GraphType;\r
+import org.simantics.objmap.annotations.RelatedElement;\r
+import org.simantics.objmap.annotations.RelatedValue;\r
+import org.simantics.sysdyn.representation.visitors.IElementVisitorVoid;\r
+\r
+@GraphType("http://www.simantics.org/Structural-1.0/ComponentType")\r
+public class ModuleType implements IElement {\r
+\r
+ @RelatedValue("http://www.simantics.org/Layer0-1.0/HasName")\r
+ private String name;\r
+ \r
+ @RelatedElement("http://www.simantics.org/Structural-1.0/IsDefinedBy")\r
+ private Configuration configuration;\r
+\r
+ public String getName() {\r
+ return name;\r
+ }\r
+\r
+ public Configuration getConfiguration() {\r
+ return this.configuration;\r
+ }\r
+ \r
+ @Override\r
+ public void accept(IElementVisitorVoid v) {\r
+ }\r
+\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2011 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.representation;\r
+\r
+import org.simantics.objmap.annotations.GraphType;\r
+import org.simantics.objmap.annotations.RelatedElement;\r
+\r
+@GraphType("http://www.simantics.org/Sysdyn-1.0/Redeclaration")\r
+public class Redeclaration {\r
+ \r
+ @RelatedElement("http://www.simantics.org/Sysdyn-1.0/ReplacedEnumeration")\r
+ private Enumeration replacedEnumeration;\r
+ \r
+ @RelatedElement("http://www.simantics.org/Sysdyn-1.0/ReplacingEnumeration")\r
+ private Enumeration replacingEnumeration;\r
+ \r
+ public String getRedeclaration() {\r
+ if(replacedEnumeration == null || replacingEnumeration == null) {\r
+ return "";\r
+ }\r
+ StringBuilder sb = new StringBuilder();\r
+ sb.append(replacedEnumeration.getName());\r
+ sb.append(".size = ");\r
+ sb.append(replacingEnumeration.getName());\r
+ sb.append(".size, ");\r
+ sb.append(replacedEnumeration.getName());\r
+ sb.append(".elements = ");\r
+ sb.append(replacingEnumeration.getName());\r
+ sb.append(".elements");\r
+ \r
+ return sb.toString();\r
+ }\r
+\r
+ public Enumeration getReplacedEnumeration() {\r
+ return replacedEnumeration;\r
+ }\r
+\r
+ public Enumeration getReplacingEnumeration() {\r
+ return replacingEnumeration;\r
+ }\r
+ \r
+ \r
+\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2010 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.representation;\r
+\r
+import java.util.ArrayList;\r
+\r
+import org.simantics.objmap.annotations.GraphType;\r
+import org.simantics.objmap.annotations.RelatedElements;\r
+import org.simantics.sysdyn.representation.visitors.IElementVisitorVoid;\r
+\r
+@GraphType("http://www.simantics.org/Sysdyn-1.0/Stock")\r
+public class Stock extends IndependentVariable {\r
+\r
+ @RelatedElements(\r
+ value = "http://www.simantics.org/Sysdyn-1.0/IsHeadOf",\r
+ composition = true)\r
+ private ArrayList<IElement> incomingConnections = new ArrayList<IElement>();\r
+ \r
+\r
+ @RelatedElements(\r
+ value = "http://www.simantics.org/Sysdyn-1.0/IsTailOf",\r
+ composition = true)\r
+ private ArrayList<IElement> outgoingConnections = new ArrayList<IElement>();\r
+ \r
+ @Override\r
+ public void accept(IElementVisitorVoid v) {\r
+ v.visit(this); \r
+ }\r
+\r
+ public ArrayList<Valve> getIncomingValves() {\r
+ ArrayList<Valve> valves = new ArrayList<Valve>();\r
+ for(IElement element : incomingConnections) {\r
+ if(element instanceof Flow) {\r
+ Flow flow = (Flow)element;\r
+ valves.add((Valve)flow.getTail());\r
+ }\r
+ }\r
+ return valves;\r
+ }\r
+\r
+ public ArrayList<Valve> getOutgoingValves() {\r
+ ArrayList<Valve> valves = new ArrayList<Valve>();\r
+ for(IElement element : outgoingConnections) {\r
+ if(element instanceof Flow) {\r
+ Flow flow = (Flow)element;\r
+ valves.add((Valve)flow.getHead());\r
+ }\r
+ }\r
+ return valves;\r
+ }\r
+ \r
+ \r
+}\r
+\r
+\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2010 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.representation;\r
+\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.objmap.schema.MappingSchemas;\r
+import org.simantics.objmap.schema.SimpleSchema;\r
+import org.simantics.sysdyn.representation.expressions.ConstantExpression;\r
+import org.simantics.sysdyn.representation.expressions.Expressions;\r
+import org.simantics.sysdyn.representation.expressions.LookupExpression;\r
+import org.simantics.sysdyn.representation.expressions.NormalExpression;\r
+import org.simantics.sysdyn.representation.expressions.ParameterExpression;\r
+import org.simantics.sysdyn.representation.expressions.StockExpression;\r
+import org.simantics.sysdyn.representation.expressions.WithLookupExpression;\r
+\r
+public class SysdynSchema extends SimpleSchema {\r
+ \r
+ public SysdynSchema(ReadGraph g) { \r
+ try {\r
+ addLinkType(MappingSchemas.fromAnnotations(g, Auxiliary.class));\r
+ addLinkType(MappingSchemas.fromAnnotations(g, Cloud.class));\r
+ addLinkType(MappingSchemas.fromAnnotations(g, Configuration.class));\r
+ addLinkType(MappingSchemas.fromAnnotations(g, Dependency.class));\r
+ addLinkType(MappingSchemas.fromAnnotations(g, Flow.class));\r
+ addLinkType(MappingSchemas.fromAnnotations(g, Stock.class));\r
+ addLinkType(MappingSchemas.fromAnnotations(g, Valve.class));\r
+ addLinkType(MappingSchemas.fromAnnotations(g, Module.class));\r
+ addLinkType(MappingSchemas.fromAnnotations(g, Input.class));\r
+ addLinkType(MappingSchemas.fromAnnotations(g, ModuleType.class));\r
+ addLinkType(MappingSchemas.fromAnnotations(g, Model.class));\r
+ addLinkType(MappingSchemas.fromAnnotations(g, Expressions.class));\r
+ addLinkType(MappingSchemas.fromAnnotations(g, Enumeration.class));\r
+ addLinkType(MappingSchemas.fromAnnotations(g, EnumerationIndex.class));\r
+ addLinkType(MappingSchemas.fromAnnotations(g, EnumerationIndexes.class));\r
+ addLinkType(MappingSchemas.fromAnnotations(g, ArrayIndexes.class));\r
+ addLinkType(MappingSchemas.fromAnnotations(g, NormalExpression.class));\r
+ addLinkType(MappingSchemas.fromAnnotations(g, ParameterExpression.class));\r
+ addLinkType(MappingSchemas.fromAnnotations(g, StockExpression.class));\r
+ addLinkType(MappingSchemas.fromAnnotations(g, ConstantExpression.class));\r
+ addLinkType(MappingSchemas.fromAnnotations(g, WithLookupExpression.class));\r
+ addLinkType(MappingSchemas.fromAnnotations(g, LookupExpression.class));\r
+ addLinkType(MappingSchemas.fromAnnotations(g, Redeclaration.class));\r
+ addLinkType(MappingSchemas.fromAnnotations(g, LibraryDummy.class));\r
+ } catch (DatabaseException e) {\r
+ e.printStackTrace();\r
+ } catch (InstantiationException e) {\r
+ e.printStackTrace();\r
+ } catch (IllegalAccessException e) {\r
+ e.printStackTrace();\r
+ } \r
+ }\r
+\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2010 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.representation;\r
+\r
+import org.simantics.objmap.annotations.GraphType;\r
+import org.simantics.sysdyn.representation.visitors.IElementVisitorVoid;\r
+\r
+@GraphType("http://www.simantics.org/Sysdyn-1.0/Valve")\r
+public class Valve extends IndependentVariable {\r
+ @Override\r
+ public void accept(IElementVisitorVoid v) {\r
+ v.visit(this);\r
+ }\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2010 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.representation;\r
+\r
+import org.simantics.objmap.annotations.RelatedElement;\r
+import org.simantics.objmap.annotations.RelatedValue;\r
+import org.simantics.sysdyn.representation.expressions.Expressions;\r
+\r
+public abstract class Variable implements IElement {\r
+ \r
+ @RelatedValue("http://www.simantics.org/Layer0-1.0/HasType")\r
+ protected String type;\r
+ \r
+ @RelatedValue("http://www.simantics.org/Layer0-1.0/HasName")\r
+ protected String name;\r
+ \r
+ @RelatedElement("http://www.simantics.org/Layer0-1.0/PartOf")\r
+ protected Configuration configuration;\r
+ \r
+ @RelatedElement("http://www.simantics.org/Sysdyn-1.0/HasArrayIndexes")\r
+ protected ArrayIndexes arrayIndexes;\r
+ \r
+ @RelatedElement("http://www.simantics.org/Sysdyn-1.0/HasExpressions")\r
+ protected Expressions expressions;\r
+ \r
+\r
+ public String getName() {\r
+ return this.name;\r
+ }\r
+ \r
+ public Configuration getParentConfiguration() {\r
+ return this.configuration;\r
+ }\r
+\r
+ public String getType() {\r
+ return this.type;\r
+ }\r
+ \r
+ public ArrayIndexes getArrayIndexes() {\r
+ return this.arrayIndexes;\r
+ }\r
+ \r
+ public Expressions getExpressions() {\r
+ return this.expressions;\r
+ }\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2010 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.representation.expressions;\r
+\r
+import org.simantics.objmap.annotations.GraphType;\r
+import org.simantics.objmap.annotations.RelatedValue;\r
+import org.simantics.sysdyn.representation.IndependentVariable;\r
+\r
+@GraphType("http://www.simantics.org/Sysdyn-1.0/ConstantExpression")\r
+public class ConstantExpression extends Expression {\r
+\r
+ @RelatedValue("http://www.simantics.org/Sysdyn-1.0/HasEquation")\r
+ private String equation;\r
+\r
+ @Override\r
+ public String getDeclaration(IndependentVariable variable) {\r
+ StringBuilder b = new StringBuilder();\r
+ b.append(" constant " + variable.getType() + " " + variable.getName());\r
+ b.append(" = " + equation + ";\n");\r
+ return b.toString(); }\r
+\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2010 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.representation.expressions;\r
+\r
+import org.simantics.objmap.annotations.GraphType;\r
+\r
+@GraphType("http://www.simantics.org/Sysdyn-1.0/DelayExpression")\r
+public class DelayExpression extends Expression {\r
+\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2010 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.representation.expressions;\r
+\r
+import org.simantics.objmap.annotations.RelatedValue;\r
+import org.simantics.sysdyn.representation.IndependentVariable;\r
+\r
+public abstract class Expression implements IExpression {\r
+ \r
+ @RelatedValue("http://www.simantics.org/Sysdyn-1.0/HasArrayRange")\r
+ private String range;\r
+ \r
+ @Override\r
+ public String getDeclaration(IndependentVariable variable) {\r
+ return null;\r
+ }\r
+\r
+ @Override\r
+ public String getEquation(IndependentVariable variable) {\r
+ return null;\r
+ }\r
+\r
+ @Override\r
+ public String getInitialEquation(IndependentVariable variable) {\r
+ return null;\r
+ }\r
+ \r
+ @Override\r
+ public String getArrayRange() {\r
+ if(range == null)\r
+ return "";\r
+ else\r
+ return range;\r
+ }\r
+\r
+}\r
--- /dev/null
+package org.simantics.sysdyn.representation.expressions;\r
+\r
+import java.util.ArrayList;\r
+\r
+import org.simantics.objmap.annotations.GraphType;\r
+import org.simantics.objmap.annotations.RelatedOrderedSetElements;\r
+\r
+@GraphType("http://www.simantics.org/Sysdyn-1.0/Expressions")\r
+public class Expressions {\r
+\r
+ @RelatedOrderedSetElements\r
+ private ArrayList<IExpression> expressions = new ArrayList<IExpression>();\r
+\r
+ public ArrayList<IExpression> getExpressions() {\r
+ return expressions;\r
+ }\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2010 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.representation.expressions;\r
+\r
+import org.simantics.sysdyn.representation.IndependentVariable;\r
+\r
+public interface IExpression {\r
+\r
+ String getDeclaration(IndependentVariable variable);\r
+ String getInitialEquation(IndependentVariable variable);\r
+ String getEquation(IndependentVariable variable);\r
+ String getArrayRange();\r
+\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2010 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.representation.expressions;\r
+\r
+import org.simantics.objmap.annotations.GraphType;\r
+\r
+@GraphType("http://www.simantics.org/Sysdyn-1.0/LookupExpression")\r
+public class LookupExpression extends Expression {\r
+\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2010 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.representation.expressions;\r
+\r
+import java.util.ArrayList;\r
+import java.util.Iterator;\r
+\r
+import org.simantics.objmap.annotations.GraphType;\r
+import org.simantics.objmap.annotations.RelatedValue;\r
+import org.simantics.sysdyn.representation.ArrayIndexes;\r
+import org.simantics.sysdyn.representation.Enumeration;\r
+import org.simantics.sysdyn.representation.IndependentVariable;\r
+import org.simantics.sysdyn.representation.utils.IndexUtils;\r
+\r
+@GraphType("http://www.simantics.org/Sysdyn-1.0/NormalExpression")\r
+public class NormalExpression extends Expression {\r
+\r
+ @RelatedValue("http://www.simantics.org/Sysdyn-1.0/HasEquation")\r
+ private String equation;\r
+\r
+ @Override\r
+ public String getDeclaration(IndependentVariable variable) {\r
+ \r
+ ArrayIndexes ai = variable.getArrayIndexes();\r
+ ArrayList<Enumeration> enumerations = null;\r
+ if(ai != null) \r
+ enumerations = ai.getEnumerations();\r
+ \r
+ String range = "";\r
+ if(enumerations != null && enumerations.size() > 0) {\r
+ StringBuilder sb = new StringBuilder();\r
+ sb.append("[");\r
+ Iterator<Enumeration> iterator = enumerations.iterator();\r
+ while(iterator.hasNext()) {\r
+ sb.append(iterator.next().getName() + ".size");\r
+ if(iterator.hasNext()) {\r
+ sb.append(", ");\r
+ }\r
+ }\r
+ sb.append("]");\r
+ range = sb.toString();\r
+ }\r
+ \r
+ return " " + variable.getType() + " " + variable.getName() + range + ";\n";\r
+ }\r
+\r
+ @Override\r
+ public String getEquation(IndependentVariable variable) {\r
+ String equation = IndexUtils.equationRangesToIndexes(variable, this.equation);\r
+ String range = IndexUtils.rangeToIndexes(variable, this.getArrayRange());\r
+ return " " + variable.getName() + (range.equals("[:]") ? "" : range) + " = " + equation + ";\n";\r
+ }\r
+\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2010 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.representation.expressions;\r
+\r
+import java.util.ArrayList;\r
+import java.util.Iterator;\r
+\r
+import org.simantics.objmap.annotations.GraphType;\r
+import org.simantics.objmap.annotations.RelatedValue;\r
+import org.simantics.sysdyn.representation.ArrayIndexes;\r
+import org.simantics.sysdyn.representation.Enumeration;\r
+import org.simantics.sysdyn.representation.IndependentVariable;\r
+import org.simantics.sysdyn.representation.utils.IndexUtils;\r
+\r
+@GraphType("http://www.simantics.org/Sysdyn-1.0/ParameterExpression")\r
+public class ParameterExpression extends Expression {\r
+ \r
+ @RelatedValue("http://www.simantics.org/Sysdyn-1.0/HasEquation")\r
+ private String equation;\r
+ \r
+ @Override\r
+ public String getDeclaration(IndependentVariable variable) {\r
+ // FIXME: Still needs to manually confirm that really is parameter\r
+ ArrayIndexes ai = variable.getArrayIndexes();\r
+ ArrayList<Enumeration> enumerations = null;\r
+ if(ai != null) \r
+ enumerations = ai.getEnumerations();\r
+ \r
+ boolean parameter = true;\r
+ String range = "";\r
+ if(enumerations != null && enumerations.size() > 0) {\r
+ parameter = false;\r
+ StringBuilder sb = new StringBuilder();\r
+ sb.append("[");\r
+ Iterator<Enumeration> iterator = enumerations.iterator();\r
+ while(iterator.hasNext()) {\r
+ sb.append(iterator.next().getName() + ".size");\r
+ if(iterator.hasNext()) {\r
+ sb.append(", ");\r
+ }\r
+ }\r
+ sb.append("]");\r
+ range = sb.toString();\r
+ }\r
+ \r
+ StringBuilder sb = new StringBuilder();\r
+ sb.append(" " + (parameter ? "parameter " : "") + variable.getType() + " " + variable.getName() + range);\r
+ if(parameter)\r
+ sb.append(" = " + 0.0 + " /* Value read from init file */");\r
+ sb.append(";\n");\r
+ return sb.toString();\r
+ }\r
+ \r
+ \r
+ /**\r
+ * Used when the expression is a part of an array variable. Then it is like a normal auxiliary.\r
+ */\r
+ @Override\r
+ public String getEquation(IndependentVariable variable) {\r
+ String range = IndexUtils.rangeToIndexes(variable, this.getArrayRange());\r
+ return " " + variable.getName() + (range.equals("[:]") ? "" : range) + " = " + equation + ";\n";\r
+ };\r
+ \r
+ public Double getValue() {\r
+ try {\r
+ return Double.parseDouble(equation);\r
+ } catch(NumberFormatException e) {\r
+ return null;\r
+ }\r
+ }\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2010 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.representation.expressions;\r
+\r
+import java.util.ArrayList;\r
+import java.util.Iterator;\r
+\r
+import org.simantics.objmap.annotations.GraphType;\r
+import org.simantics.objmap.annotations.RelatedValue;\r
+import org.simantics.sysdyn.representation.ArrayIndexes;\r
+import org.simantics.sysdyn.representation.Enumeration;\r
+import org.simantics.sysdyn.representation.IndependentVariable;\r
+import org.simantics.sysdyn.representation.Stock;\r
+import org.simantics.sysdyn.representation.Valve;\r
+import org.simantics.sysdyn.representation.utils.IndexUtils;\r
+\r
+@GraphType("http://www.simantics.org/Sysdyn-1.0/StockExpression")\r
+public class StockExpression extends Expression {\r
+\r
+ @RelatedValue("http://www.simantics.org/Sysdyn-1.0/HasInitialEquation")\r
+ private String initialEquation;\r
+\r
+ @Override\r
+ public String getDeclaration(IndependentVariable variable) {\r
+ Double value = getStartValue(variable);\r
+ \r
+ ArrayIndexes ai = variable.getArrayIndexes();\r
+ ArrayList<Enumeration> enumerations = null;\r
+ if(ai != null) \r
+ enumerations = ai.getEnumerations();\r
+ \r
+ String range = "";\r
+ if(enumerations != null && enumerations.size() > 0) {\r
+ StringBuilder sb = new StringBuilder();\r
+ sb.append("[");\r
+ Iterator<Enumeration> iterator = enumerations.iterator();\r
+ while(iterator.hasNext()) {\r
+ sb.append(iterator.next().getName() + ".size");\r
+ if(iterator.hasNext()) {\r
+ sb.append(", ");\r
+ }\r
+ }\r
+ sb.append("]");\r
+ range = sb.toString();\r
+ }\r
+ \r
+ String each = "";\r
+ if(ai != null && !ai.getEnumerations().isEmpty())\r
+ each = "each";\r
+ if (value == null) {\r
+ return " " + variable.getType() + " " + variable.getName() + range + "(" + each + " fixed=false);\n";\r
+ } else {\r
+ return " " + variable.getType() + " " + variable.getName() + range + "(" + each+ " start=" + value + "," + each + " fixed=true);\n";\r
+ }\r
+ }\r
+\r
+ @Override\r
+ public String getEquation(IndependentVariable variable) {\r
+ String range = IndexUtils.rangeToIndexes(variable, this.getArrayRange());\r
+ StringBuilder b = new StringBuilder();\r
+ b.append(" der(")\r
+ .append(variable.getName() + range)\r
+ .append(") =");\r
+ for(Valve valve : ((Stock)variable).getIncomingValves())\r
+ b.append("\n + ").append(valve.getName() + range);\r
+ for(Valve valve : ((Stock)variable).getOutgoingValves())\r
+ b.append("\n - ").append(valve.getName() + range);\r
+ b.append(";\n");\r
+ return b.toString();\r
+ }\r
+\r
+ @Override\r
+ public String getInitialEquation(IndependentVariable variable) {\r
+ try {\r
+ Double.parseDouble(initialEquation);\r
+ return null;\r
+ } catch (Exception e){\r
+ // Has an initial equation\r
+ } \r
+ String range = IndexUtils.rangeToIndexes(variable, this.getArrayRange());\r
+ if(range == null)\r
+ range = "";\r
+ return " " + variable.getName() + range + " = " + initialEquation + ";\n";\r
+\r
+ }\r
+ \r
+ \r
+ private Double getStartValue(IndependentVariable variable) {\r
+ Double value = null;\r
+ ArrayList<IExpression> expressions = variable.getExpressions().getExpressions();\r
+ if(expressions.size() == 1) {\r
+ IExpression e = expressions.get(0);\r
+ if(e.getInitialEquation(variable) == null) {\r
+ // Has start value\r
+ value = Double.parseDouble(initialEquation);\r
+ }\r
+ }\r
+ return value;\r
+ }\r
+\r
+\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2010 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.representation.expressions;\r
+\r
+import java.util.ArrayList;\r
+import java.util.Iterator;\r
+\r
+import org.simantics.objmap.annotations.GraphType;\r
+import org.simantics.objmap.annotations.RelatedValue;\r
+import org.simantics.sysdyn.representation.ArrayIndexes;\r
+import org.simantics.sysdyn.representation.Enumeration;\r
+import org.simantics.sysdyn.representation.IndependentVariable;\r
+import org.simantics.sysdyn.representation.utils.IndexUtils;\r
+\r
+\r
+@GraphType("http://www.simantics.org/Sysdyn-1.0/WithLookupExpression")\r
+public class WithLookupExpression extends Expression {\r
+\r
+ @RelatedValue("http://www.simantics.org/Sysdyn-1.0/HasLookup")\r
+ private String lookupTable;\r
+ @RelatedValue("http://www.simantics.org/Sysdyn-1.0/HasEquation")\r
+ private String equation;\r
+\r
+ @Override\r
+ public String getDeclaration(IndependentVariable variable) {\r
+ ArrayIndexes ai = variable.getArrayIndexes();\r
+ ArrayList<Enumeration> enumerations = null;\r
+ if(ai != null) \r
+ enumerations = ai.getEnumerations();\r
+ \r
+ String range = "";\r
+ if(enumerations != null && enumerations.size() > 0) {\r
+ StringBuilder sb = new StringBuilder();\r
+ sb.append("[");\r
+ Iterator<Enumeration> iterator = enumerations.iterator();\r
+ while(iterator.hasNext()) {\r
+ sb.append(iterator.next().getName() + ".size");\r
+ if(iterator.hasNext()) {\r
+ sb.append(", ");\r
+ }\r
+ }\r
+ sb.append("]");\r
+ range = sb.toString();\r
+ }\r
+ \r
+ return " " + variable.getType() + " " + variable.getName() + range + ";\n";\r
+\r
+ }\r
+\r
+ @Override\r
+ public String getEquation(IndependentVariable variable) {\r
+ String equation = IndexUtils.equationRangesToIndexes(variable, this.equation);\r
+ String range = IndexUtils.rangeToIndexes(variable, this.getArrayRange());\r
+\r
+ return \r
+ " " + variable.getName() + (range.equals("[:]") ? "" : range) + " = interpolate(" + equation + ", " + lookupTable + ");\n";\r
+ }\r
+\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2011 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.representation.utils;\r
+\r
+import java.io.StringReader;\r
+import java.util.ArrayList;\r
+import java.util.StringTokenizer;\r
+\r
+import org.simantics.sysdyn.expressionParser.ExpressionParser;\r
+import org.simantics.sysdyn.expressionParser.ExpressionParser.ForRange;\r
+import org.simantics.sysdyn.expressionParser.ParseException;\r
+import org.simantics.sysdyn.representation.ArrayIndexes;\r
+import org.simantics.sysdyn.representation.Configuration;\r
+import org.simantics.sysdyn.representation.Enumeration;\r
+import org.simantics.sysdyn.representation.EnumerationIndex;\r
+import org.simantics.sysdyn.representation.IElement;\r
+import org.simantics.sysdyn.representation.Variable;\r
+\r
+public class IndexUtils {\r
+\r
+ public static int indexOf(Enumeration enumeration, String index) {\r
+ int result = -1;\r
+ ArrayList<EnumerationIndex> indexes = enumeration.getEnumerationIndexes();\r
+ for(int i = 0; i < indexes.size(); i++) {\r
+ if(indexes.get(i).getName().equals(index)) {\r
+ result = i +1;\r
+ break;\r
+ }\r
+ }\r
+ return result;\r
+ }\r
+ \r
+ \r
+ public static String rangeToIndexes(Variable variable, String range) {\r
+ StringBuilder sb = new StringBuilder();\r
+ ArrayIndexes arrayIndexes = variable.getArrayIndexes();\r
+ if(arrayIndexes == null || range == null)\r
+ return "";\r
+ ArrayList<Enumeration> enumerations = arrayIndexes.getEnumerations();\r
+ StringTokenizer st = new StringTokenizer(range, "[]:,", true);\r
+ int index = 0;\r
+ while(st.hasMoreTokens()) {\r
+ String rangeToken = st.nextToken().trim();\r
+ if(rangeToken.matches("[\\[\\]:]")) {\r
+ sb.append(rangeToken);\r
+ } else if (rangeToken.equals(",")) {\r
+ sb.append(rangeToken);\r
+ index++;\r
+ } else if(rangeToken.equals(enumerations.get(index).getName())) {\r
+ sb.append(":");\r
+ } else {\r
+ int i = indexOf(enumerations.get(index), rangeToken);\r
+ if(i >= 0)\r
+ sb.append(i);\r
+ else\r
+ sb.append(rangeToken);\r
+ }\r
+ \r
+ }\r
+ return sb.toString();\r
+ }\r
+ \r
+ private static String fixForRangeEnumerations(Variable variable, String equation) {\r
+ ExpressionParser parser = new ExpressionParser(new StringReader(equation));\r
+ try {\r
+ parser.expr();\r
+ for(ForRange forRange : parser.getForRanges()) {\r
+ if(forRange.start.equals(forRange.end)) {\r
+ Variable v = getVariable(variable.getParentConfiguration(), forRange.start.image);\r
+ if(v instanceof Enumeration) {\r
+ equation = equation.replaceAll("in[\\s]*" + forRange.start.image + "($|[^\\.])", "in " + forRange.start.image + ".elements$1");\r
+ }\r
+ }\r
+ }\r
+ } catch (ParseException e) {\r
+ e.printStackTrace();\r
+ }\r
+ return equation;\r
+ }\r
+ \r
+ public static String equationRangesToIndexes(Variable variable, String equation) {\r
+ if(equation == null || !equation.contains("[")) return equation;\r
+ \r
+ StringBuilder result = new StringBuilder();\r
+ String delimiters = "+-*/(){}[],. ";\r
+ StringTokenizer st = new StringTokenizer(equation, delimiters, true);\r
+ String prevToken = st.nextToken();\r
+ result.append(prevToken);\r
+ while (st.hasMoreTokens()) {\r
+ String nextToken = st.nextToken();\r
+ if (nextToken.equals("[")) {\r
+ StringBuilder range = new StringBuilder();\r
+ range.append("[");\r
+ String rangeToken = st.nextToken();\r
+ while(!rangeToken.equals("]")) {\r
+ range.append(rangeToken);\r
+ rangeToken = st.nextToken();\r
+ }\r
+ range.append("]");\r
+ \r
+ Variable prevVar = getVariable(variable.getParentConfiguration(), prevToken);\r
+ result.append(rangeToIndexes(prevVar, range.toString()));\r
+ } else {\r
+ result.append(nextToken);\r
+ }\r
+ prevToken = nextToken;\r
+ }\r
+ \r
+ equation = fixForRangeEnumerations(variable, result.toString());\r
+ return equation;\r
+ }\r
+ \r
+ private static Variable getVariable(Configuration configuration, String name) {\r
+ for(IElement element : configuration.getElements()) {\r
+ if(element instanceof Variable) {\r
+ Variable variable = (Variable) element;\r
+ if(variable.getName().equals(name)) {\r
+ return variable;\r
+ }\r
+ }\r
+ }\r
+ return null;\r
+ }\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2010 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.representation.visitors;\r
+\r
+import org.simantics.sysdyn.representation.Auxiliary;\r
+import org.simantics.sysdyn.representation.Cloud;\r
+import org.simantics.sysdyn.representation.Configuration;\r
+import org.simantics.sysdyn.representation.Dependency;\r
+import org.simantics.sysdyn.representation.Enumeration;\r
+import org.simantics.sysdyn.representation.Flow;\r
+import org.simantics.sysdyn.representation.Input;\r
+import org.simantics.sysdyn.representation.LibraryDummy;\r
+import org.simantics.sysdyn.representation.Module;\r
+import org.simantics.sysdyn.representation.Stock;\r
+import org.simantics.sysdyn.representation.Valve;\r
+\r
+public class ElementVisitorVoidAdapter implements IElementVisitorVoid {\r
+\r
+ @Override\r
+ public void visit(Auxiliary auxiliary) {\r
+ }\r
+\r
+ @Override\r
+ public void visit(Stock stock) {\r
+ }\r
+\r
+ @Override\r
+ public void visit(Valve valve) {\r
+ }\r
+\r
+ @Override\r
+ public void visit(Cloud cloud) {\r
+ }\r
+\r
+ @Override\r
+ public void visit(Input input) {\r
+ }\r
+\r
+ @Override\r
+ public void visit(Dependency dependency) {\r
+ }\r
+\r
+ @Override\r
+ public void visit(Flow flow) {\r
+ }\r
+ \r
+ @Override\r
+ public void visit(Module module) {\r
+ }\r
+\r
+ @Override\r
+ public void visit(Configuration configuration) {\r
+ }\r
+ \r
+ @Override\r
+ public void visit(Enumeration enumeration) {\r
+ }\r
+ \r
+ @Override\r
+ public void visit(LibraryDummy libraryDummy) {\r
+ }\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2010 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.representation.visitors;\r
+\r
+import org.simantics.sysdyn.representation.Auxiliary;\r
+import org.simantics.sysdyn.representation.Cloud;\r
+import org.simantics.sysdyn.representation.Configuration;\r
+import org.simantics.sysdyn.representation.Dependency;\r
+import org.simantics.sysdyn.representation.Enumeration;\r
+import org.simantics.sysdyn.representation.Flow;\r
+import org.simantics.sysdyn.representation.Input;\r
+import org.simantics.sysdyn.representation.LibraryDummy;\r
+import org.simantics.sysdyn.representation.Module;\r
+import org.simantics.sysdyn.representation.Stock;\r
+import org.simantics.sysdyn.representation.Valve;\r
+\r
+public interface IElementVisitorVoid {\r
+\r
+ void visit(Auxiliary auxiliary);\r
+ void visit(Stock stock);\r
+ void visit(Valve valve);\r
+ void visit(Cloud cloud);\r
+ void visit(Input input);\r
+ void visit(Dependency dependency);\r
+ void visit(Flow flow); \r
+ void visit(Module module);\r
+ void visit(Configuration configuration);\r
+ void visit(Enumeration enumeration);\r
+ void visit(LibraryDummy libraryDummy);\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2010 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.simulation;\r
+\r
+import java.text.SimpleDateFormat;\r
+import java.util.Calendar;\r
+\r
+import org.eclipse.core.runtime.IProgressMonitor;\r
+import org.eclipse.core.runtime.IStatus;\r
+import org.eclipse.core.runtime.Status;\r
+import org.eclipse.core.runtime.jobs.Job;\r
+import org.eclipse.ui.console.IConsole;\r
+import org.eclipse.ui.console.ConsolePlugin;\r
+import org.eclipse.ui.console.IConsoleManager;\r
+import org.eclipse.ui.console.MessageConsole;\r
+import org.eclipse.ui.console.MessageConsoleStream;\r
+import org.eclipse.ui.PlatformUI;\r
+import org.simantics.modelica.IModelicaMonitor;\r
+import org.simantics.simulation.experiment.Experiment;\r
+import org.simantics.sysdyn.manager.SysdynModel;\r
+\r
+public class SimulationJob extends Job {\r
+\r
+ SysdynModel model;\r
+ Experiment experiment;\r
+ IModelicaMonitor monitor;\r
+\r
+ public SimulationJob(SysdynModel model, Experiment experiment) {\r
+ super("Simulate " + model.getConfiguration().getName());\r
+ this.model = model;\r
+ this.experiment = experiment;\r
+ if(PlatformUI.isWorkbenchRunning()) {\r
+ this.monitor = new ModelicaMonitor();\r
+ } else {\r
+ // Fallback to headless\r
+ this.monitor = new HeadlessModelicaMonitor();\r
+ }\r
+ }\r
+\r
+ @Override\r
+ protected IStatus run(IProgressMonitor monitor) {\r
+ monitor.beginTask("Simulate " + model.getConfiguration().getName(), 5); \r
+ this.monitor.message("Simulate " + model.getConfiguration().getName());\r
+ try {\r
+ model.update();\r
+ model.simulate(this.monitor, monitor, experiment);\r
+ } catch (Exception e) {\r
+ e.printStackTrace();\r
+ this.monitor.showConsole();\r
+ return new Status(\r
+ Status.ERROR, \r
+ "org.simantics.sysdyn.ui", \r
+ "Simulation failed: \n" + e.getMessage());\r
+ } \r
+ this.monitor.message("\n");\r
+ monitor.done(); \r
+ return Status.OK_STATUS;\r
+ }\r
+ \r
+ @Override\r
+ public boolean belongsTo(Object family) {\r
+ return "SimulationJob".equals(family);\r
+ }\r
+\r
+ private class HeadlessModelicaMonitor implements IModelicaMonitor {\r
+ public HeadlessModelicaMonitor() {\r
+ }\r
+\r
+ @Override\r
+ public void message(String message) {\r
+ message(message, "hh:mm:ss");\r
+ }\r
+ \r
+ /**\r
+ * Print message to a console with a specified time stamp format\r
+ * \r
+ * @param message the message to be printed\r
+ * @param timeStampFormat simpledateformat timestamp format. null if no timestamp wanted\r
+ */\r
+ public void message(String message, String timeStampFormat) {\r
+ Calendar cal = Calendar.getInstance();\r
+ SimpleDateFormat sdf = new SimpleDateFormat(timeStampFormat);\r
+ String time = sdf.format(cal.getTime());\r
+ \r
+ System.out.println("[" + time +"] " + message);\r
+ }\r
+\r
+ public void clearConsole() {\r
+ }\r
+ \r
+ public void showConsole() {\r
+ }\r
+\r
+ }\r
+\r
+ private class ModelicaMonitor implements IModelicaMonitor {\r
+\r
+ MessageConsole console;\r
+ \r
+ public ModelicaMonitor() {\r
+ ConsolePlugin plugin = ConsolePlugin.getDefault();\r
+ IConsoleManager conMan = plugin.getConsoleManager();\r
+ IConsole[] existing = conMan.getConsoles();\r
+ for (int i = 0; i < existing.length; i++)\r
+ if (existing[i].getName().equals("Simulation"))\r
+ console = (MessageConsole) existing[i];\r
+ if(console == null) {\r
+ MessageConsole myConsole = new MessageConsole("Simulation", null);\r
+ conMan.addConsoles(new IConsole[]{myConsole});\r
+ console = myConsole;\r
+ }\r
+ }\r
+\r
+ @Override\r
+ public void message(String message) {\r
+ message(message, "hh:mm:ss");\r
+ }\r
+ \r
+ /**\r
+ * Print message to a console with a specified time stamp format\r
+ * \r
+ * @param message the message to be printed\r
+ * @param timeStampFormat simpledateformat timestamp format. null if no timestamp wanted\r
+ */\r
+ public void message(String message, String timeStampFormat) {\r
+ Calendar cal = Calendar.getInstance();\r
+ SimpleDateFormat sdf = new SimpleDateFormat(timeStampFormat);\r
+ String time = sdf.format(cal.getTime());\r
+ \r
+ MessageConsoleStream out = this.console.newMessageStream();\r
+ if(message.length() > 1)\r
+ out.println("[" + time +"] " + message);\r
+ if(message.contains("Error"))\r
+ showConsole();\r
+ }\r
+\r
+ public void clearConsole() {\r
+ this.console.clearConsole();\r
+ }\r
+ \r
+ public void showConsole() {\r
+ ConsolePlugin plugin = ConsolePlugin.getDefault();\r
+ IConsoleManager conMan = plugin.getConsoleManager();\r
+ conMan.showConsoleView(console);\r
+ }\r
+\r
+ }\r
+ \r
+ @Override\r
+ protected void canceling() {\r
+ model.cancelSimulation();\r
+ }\r
+\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2010 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.simulation;\r
+\r
+import org.simantics.simulation.experiment.Experiment;\r
+import org.simantics.sysdyn.manager.SysdynModel;\r
+\r
+public class SimulationScheduler {\r
+ SysdynModel model;\r
+ Experiment experiment;\r
+ SimulationJob job;\r
+ \r
+ private SimulationScheduler(SysdynModel model, Experiment experiment) { \r
+ this.model = model;\r
+ this.experiment = experiment;\r
+ this.job = new SimulationJob(model, experiment);\r
+ }\r
+ \r
+ private void start() {\r
+ job.schedule();\r
+ }\r
+\r
+ public static synchronized SimulationScheduler start(SysdynModel model, Experiment experiment) {\r
+ SimulationScheduler scheduler = model.getService(SimulationScheduler.class);\r
+ if(scheduler == null || !scheduler.experiment.equals(experiment)) {\r
+ scheduler = new SimulationScheduler(model, experiment);\r
+ model.addService(SimulationScheduler.class, scheduler);\r
+ scheduler.start();\r
+ } else {\r
+ scheduler.start();\r
+ }\r
+ return scheduler;\r
+ }\r
+ \r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2010 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+/* Generated By:JavaCC: Do not edit this line. ParseException.java Version 5.0 */\r
+/* JavaCCOptions:KEEP_LINE_COL=null */\r
+package org.simantics.sysdyn.tableParser;\r
+\r
+/**\r
+ * This exception is thrown when parse errors are encountered.\r
+ * You can explicitly create objects of this exception type by\r
+ * calling the method generateParseException in the generated\r
+ * parser.\r
+ *\r
+ * You can modify this class to customize your error reporting\r
+ * mechanisms so long as you retain the public fields.\r
+ */\r
+public class ParseException extends Exception {\r
+\r
+ /**\r
+ * The version identifier for this Serializable class.\r
+ * Increment only if the <i>serialized</i> form of the\r
+ * class changes.\r
+ */\r
+ private static final long serialVersionUID = 1L;\r
+\r
+ /**\r
+ * This constructor is used by the method "generateParseException"\r
+ * in the generated parser. Calling this constructor generates\r
+ * a new object of this type with the fields "currentToken",\r
+ * "expectedTokenSequences", and "tokenImage" set.\r
+ */\r
+ public ParseException(Token currentTokenVal,\r
+ int[][] expectedTokenSequencesVal,\r
+ String[] tokenImageVal\r
+ )\r
+ {\r
+ super(initialise(currentTokenVal, expectedTokenSequencesVal, tokenImageVal));\r
+ currentToken = currentTokenVal;\r
+ expectedTokenSequences = expectedTokenSequencesVal;\r
+ tokenImage = tokenImageVal;\r
+ }\r
+\r
+ /**\r
+ * The following constructors are for use by you for whatever\r
+ * purpose you can think of. Constructing the exception in this\r
+ * manner makes the exception behave in the normal way - i.e., as\r
+ * documented in the class "Throwable". The fields "errorToken",\r
+ * "expectedTokenSequences", and "tokenImage" do not contain\r
+ * relevant information. The JavaCC generated code does not use\r
+ * these constructors.\r
+ */\r
+\r
+ public ParseException() {\r
+ super();\r
+ }\r
+\r
+ /** Constructor with message. */\r
+ public ParseException(String message) {\r
+ super(message);\r
+ }\r
+\r
+\r
+ /**\r
+ * This is the last token that has been consumed successfully. If\r
+ * this object has been created due to a parse error, the token\r
+ * followng this token will (therefore) be the first error token.\r
+ */\r
+ public Token currentToken;\r
+\r
+ /**\r
+ * Each entry in this array is an array of integers. Each array\r
+ * of integers represents a sequence of tokens (by their ordinal\r
+ * values) that is expected at this point of the parse.\r
+ */\r
+ public int[][] expectedTokenSequences;\r
+\r
+ /**\r
+ * This is a reference to the "tokenImage" array of the generated\r
+ * parser within which the parse error occurred. This array is\r
+ * defined in the generated ...Constants interface.\r
+ */\r
+ public String[] tokenImage;\r
+\r
+ /**\r
+ * It uses "currentToken" and "expectedTokenSequences" to generate a parse\r
+ * error message and returns it. If this object has been created\r
+ * due to a parse error, and you do not catch it (it gets thrown\r
+ * from the parser) the correct error message\r
+ * gets displayed.\r
+ */\r
+ private static String initialise(Token currentToken,\r
+ int[][] expectedTokenSequences,\r
+ String[] tokenImage) {\r
+ String eol = System.getProperty("line.separator", "\n");\r
+ StringBuffer expected = new StringBuffer();\r
+ int maxSize = 0;\r
+ for (int i = 0; i < expectedTokenSequences.length; i++) {\r
+ if (maxSize < expectedTokenSequences[i].length) {\r
+ maxSize = expectedTokenSequences[i].length;\r
+ }\r
+ for (int j = 0; j < expectedTokenSequences[i].length; j++) {\r
+ expected.append(tokenImage[expectedTokenSequences[i][j]]).append(' ');\r
+ }\r
+ if (expectedTokenSequences[i][expectedTokenSequences[i].length - 1] != 0) {\r
+ expected.append("...");\r
+ }\r
+ expected.append(eol).append(" ");\r
+ }\r
+ String retval = "Encountered \"";\r
+ Token tok = currentToken.next;\r
+ for (int i = 0; i < maxSize; i++) {\r
+ if (i != 0) retval += " ";\r
+ if (tok.kind == 0) {\r
+ retval += tokenImage[0];\r
+ break;\r
+ }\r
+ retval += " " + tokenImage[tok.kind];\r
+ retval += " \"";\r
+ retval += add_escapes(tok.image);\r
+ retval += " \"";\r
+ tok = tok.next;\r
+ }\r
+ retval += "\" at line " + currentToken.next.beginLine + ", column " + currentToken.next.beginColumn;\r
+ retval += "." + eol;\r
+ if (expectedTokenSequences.length == 1) {\r
+ retval += "Was expecting:" + eol + " ";\r
+ } else {\r
+ retval += "Was expecting one of:" + eol + " ";\r
+ }\r
+ retval += expected.toString();\r
+ return retval;\r
+ }\r
+\r
+ /**\r
+ * The end of line string for this machine.\r
+ */\r
+ protected String eol = System.getProperty("line.separator", "\n");\r
+\r
+ /**\r
+ * Used to convert raw characters to their escaped version\r
+ * when these raw version cannot be used as part of an ASCII\r
+ * string literal.\r
+ */\r
+ static String add_escapes(String str) {\r
+ StringBuffer retval = new StringBuffer();\r
+ char ch;\r
+ for (int i = 0; i < str.length(); i++) {\r
+ switch (str.charAt(i))\r
+ {\r
+ case 0 :\r
+ continue;\r
+ case '\b':\r
+ retval.append("\\b");\r
+ continue;\r
+ case '\t':\r
+ retval.append("\\t");\r
+ continue;\r
+ case '\n':\r
+ retval.append("\\n");\r
+ continue;\r
+ case '\f':\r
+ retval.append("\\f");\r
+ continue;\r
+ case '\r':\r
+ retval.append("\\r");\r
+ continue;\r
+ case '\"':\r
+ retval.append("\\\"");\r
+ continue;\r
+ case '\'':\r
+ retval.append("\\\'");\r
+ continue;\r
+ case '\\':\r
+ retval.append("\\\\");\r
+ continue;\r
+ default:\r
+ if ((ch = str.charAt(i)) < 0x20 || ch > 0x7e) {\r
+ String s = "0000" + Integer.toString(ch, 16);\r
+ retval.append("\\u" + s.substring(s.length() - 4, s.length()));\r
+ } else {\r
+ retval.append(ch);\r
+ }\r
+ continue;\r
+ }\r
+ }\r
+ return retval.toString();\r
+ }\r
+\r
+}\r
+/* JavaCC - OriginalChecksum=812397ddfc370286eccefa2f873e20e3 (do not edit this line) */\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2010 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+/* Generated By:JavaCC: Do not edit this line. SimpleCharStream.java Version 5.0 */\r
+/* JavaCCOptions:STATIC=false,SUPPORT_CLASS_VISIBILITY_PUBLIC=true */\r
+package org.simantics.sysdyn.tableParser;\r
+\r
+/**\r
+ * An implementation of interface CharStream, where the stream is assumed to\r
+ * contain only ASCII characters (without unicode processing).\r
+ */\r
+\r
+public class SimpleCharStream\r
+{\r
+/** Whether parser is static. */\r
+ public static final boolean staticFlag = false;\r
+ int bufsize;\r
+ int available;\r
+ int tokenBegin;\r
+/** Position in buffer. */\r
+ public int bufpos = -1;\r
+ protected int bufline[];\r
+ protected int bufcolumn[];\r
+\r
+ protected int column = 0;\r
+ protected int line = 1;\r
+\r
+ protected boolean prevCharIsCR = false;\r
+ protected boolean prevCharIsLF = false;\r
+\r
+ protected java.io.Reader inputStream;\r
+\r
+ protected char[] buffer;\r
+ protected int maxNextCharInd = 0;\r
+ protected int inBuf = 0;\r
+ protected int tabSize = 8;\r
+\r
+ protected void setTabSize(int i) { tabSize = i; }\r
+ protected int getTabSize(int i) { return tabSize; }\r
+\r
+\r
+ protected void ExpandBuff(boolean wrapAround)\r
+ {\r
+ char[] newbuffer = new char[bufsize + 2048];\r
+ int newbufline[] = new int[bufsize + 2048];\r
+ int newbufcolumn[] = new int[bufsize + 2048];\r
+\r
+ try\r
+ {\r
+ if (wrapAround)\r
+ {\r
+ System.arraycopy(buffer, tokenBegin, newbuffer, 0, bufsize - tokenBegin);\r
+ System.arraycopy(buffer, 0, newbuffer, bufsize - tokenBegin, bufpos);\r
+ buffer = newbuffer;\r
+\r
+ System.arraycopy(bufline, tokenBegin, newbufline, 0, bufsize - tokenBegin);\r
+ System.arraycopy(bufline, 0, newbufline, bufsize - tokenBegin, bufpos);\r
+ bufline = newbufline;\r
+\r
+ System.arraycopy(bufcolumn, tokenBegin, newbufcolumn, 0, bufsize - tokenBegin);\r
+ System.arraycopy(bufcolumn, 0, newbufcolumn, bufsize - tokenBegin, bufpos);\r
+ bufcolumn = newbufcolumn;\r
+\r
+ maxNextCharInd = (bufpos += (bufsize - tokenBegin));\r
+ }\r
+ else\r
+ {\r
+ System.arraycopy(buffer, tokenBegin, newbuffer, 0, bufsize - tokenBegin);\r
+ buffer = newbuffer;\r
+\r
+ System.arraycopy(bufline, tokenBegin, newbufline, 0, bufsize - tokenBegin);\r
+ bufline = newbufline;\r
+\r
+ System.arraycopy(bufcolumn, tokenBegin, newbufcolumn, 0, bufsize - tokenBegin);\r
+ bufcolumn = newbufcolumn;\r
+\r
+ maxNextCharInd = (bufpos -= tokenBegin);\r
+ }\r
+ }\r
+ catch (Throwable t)\r
+ {\r
+ throw new Error(t.getMessage());\r
+ }\r
+\r
+\r
+ bufsize += 2048;\r
+ available = bufsize;\r
+ tokenBegin = 0;\r
+ }\r
+\r
+ protected void FillBuff() throws java.io.IOException\r
+ {\r
+ if (maxNextCharInd == available)\r
+ {\r
+ if (available == bufsize)\r
+ {\r
+ if (tokenBegin > 2048)\r
+ {\r
+ bufpos = maxNextCharInd = 0;\r
+ available = tokenBegin;\r
+ }\r
+ else if (tokenBegin < 0)\r
+ bufpos = maxNextCharInd = 0;\r
+ else\r
+ ExpandBuff(false);\r
+ }\r
+ else if (available > tokenBegin)\r
+ available = bufsize;\r
+ else if ((tokenBegin - available) < 2048)\r
+ ExpandBuff(true);\r
+ else\r
+ available = tokenBegin;\r
+ }\r
+\r
+ int i;\r
+ try {\r
+ if ((i = inputStream.read(buffer, maxNextCharInd, available - maxNextCharInd)) == -1)\r
+ {\r
+ inputStream.close();\r
+ throw new java.io.IOException();\r
+ }\r
+ else\r
+ maxNextCharInd += i;\r
+ return;\r
+ }\r
+ catch(java.io.IOException e) {\r
+ --bufpos;\r
+ backup(0);\r
+ if (tokenBegin == -1)\r
+ tokenBegin = bufpos;\r
+ throw e;\r
+ }\r
+ }\r
+\r
+/** Start. */\r
+ public char BeginToken() throws java.io.IOException\r
+ {\r
+ tokenBegin = -1;\r
+ char c = readChar();\r
+ tokenBegin = bufpos;\r
+\r
+ return c;\r
+ }\r
+\r
+ protected void UpdateLineColumn(char c)\r
+ {\r
+ column++;\r
+\r
+ if (prevCharIsLF)\r
+ {\r
+ prevCharIsLF = false;\r
+ line += (column = 1);\r
+ }\r
+ else if (prevCharIsCR)\r
+ {\r
+ prevCharIsCR = false;\r
+ if (c == '\n')\r
+ {\r
+ prevCharIsLF = true;\r
+ }\r
+ else\r
+ line += (column = 1);\r
+ }\r
+\r
+ switch (c)\r
+ {\r
+ case '\r' :\r
+ prevCharIsCR = true;\r
+ break;\r
+ case '\n' :\r
+ prevCharIsLF = true;\r
+ break;\r
+ case '\t' :\r
+ column--;\r
+ column += (tabSize - (column % tabSize));\r
+ break;\r
+ default :\r
+ break;\r
+ }\r
+\r
+ bufline[bufpos] = line;\r
+ bufcolumn[bufpos] = column;\r
+ }\r
+\r
+/** Read a character. */\r
+ public char readChar() throws java.io.IOException\r
+ {\r
+ if (inBuf > 0)\r
+ {\r
+ --inBuf;\r
+\r
+ if (++bufpos == bufsize)\r
+ bufpos = 0;\r
+\r
+ return buffer[bufpos];\r
+ }\r
+\r
+ if (++bufpos >= maxNextCharInd)\r
+ FillBuff();\r
+\r
+ char c = buffer[bufpos];\r
+\r
+ UpdateLineColumn(c);\r
+ return c;\r
+ }\r
+\r
+ @Deprecated\r
+ /**\r
+ * @deprecated\r
+ * @see #getEndColumn\r
+ */\r
+\r
+ public int getColumn() {\r
+ return bufcolumn[bufpos];\r
+ }\r
+\r
+ @Deprecated\r
+ /**\r
+ * @deprecated\r
+ * @see #getEndLine\r
+ */\r
+\r
+ public int getLine() {\r
+ return bufline[bufpos];\r
+ }\r
+\r
+ /** Get token end column number. */\r
+ public int getEndColumn() {\r
+ return bufcolumn[bufpos];\r
+ }\r
+\r
+ /** Get token end line number. */\r
+ public int getEndLine() {\r
+ return bufline[bufpos];\r
+ }\r
+\r
+ /** Get token beginning column number. */\r
+ public int getBeginColumn() {\r
+ return bufcolumn[tokenBegin];\r
+ }\r
+\r
+ /** Get token beginning line number. */\r
+ public int getBeginLine() {\r
+ return bufline[tokenBegin];\r
+ }\r
+\r
+/** Backup a number of characters. */\r
+ public void backup(int amount) {\r
+\r
+ inBuf += amount;\r
+ if ((bufpos -= amount) < 0)\r
+ bufpos += bufsize;\r
+ }\r
+\r
+ /** Constructor. */\r
+ public SimpleCharStream(java.io.Reader dstream, int startline,\r
+ int startcolumn, int buffersize)\r
+ {\r
+ inputStream = dstream;\r
+ line = startline;\r
+ column = startcolumn - 1;\r
+\r
+ available = bufsize = buffersize;\r
+ buffer = new char[buffersize];\r
+ bufline = new int[buffersize];\r
+ bufcolumn = new int[buffersize];\r
+ }\r
+\r
+ /** Constructor. */\r
+ public SimpleCharStream(java.io.Reader dstream, int startline,\r
+ int startcolumn)\r
+ {\r
+ this(dstream, startline, startcolumn, 4096);\r
+ }\r
+\r
+ /** Constructor. */\r
+ public SimpleCharStream(java.io.Reader dstream)\r
+ {\r
+ this(dstream, 1, 1, 4096);\r
+ }\r
+\r
+ /** Reinitialise. */\r
+ public void ReInit(java.io.Reader dstream, int startline,\r
+ int startcolumn, int buffersize)\r
+ {\r
+ inputStream = dstream;\r
+ line = startline;\r
+ column = startcolumn - 1;\r
+\r
+ if (buffer == null || buffersize != buffer.length)\r
+ {\r
+ available = bufsize = buffersize;\r
+ buffer = new char[buffersize];\r
+ bufline = new int[buffersize];\r
+ bufcolumn = new int[buffersize];\r
+ }\r
+ prevCharIsLF = prevCharIsCR = false;\r
+ tokenBegin = inBuf = maxNextCharInd = 0;\r
+ bufpos = -1;\r
+ }\r
+\r
+ /** Reinitialise. */\r
+ public void ReInit(java.io.Reader dstream, int startline,\r
+ int startcolumn)\r
+ {\r
+ ReInit(dstream, startline, startcolumn, 4096);\r
+ }\r
+\r
+ /** Reinitialise. */\r
+ public void ReInit(java.io.Reader dstream)\r
+ {\r
+ ReInit(dstream, 1, 1, 4096);\r
+ }\r
+ /** Constructor. */\r
+ public SimpleCharStream(java.io.InputStream dstream, String encoding, int startline,\r
+ int startcolumn, int buffersize) throws java.io.UnsupportedEncodingException\r
+ {\r
+ this(encoding == null ? new java.io.InputStreamReader(dstream) : new java.io.InputStreamReader(dstream, encoding), startline, startcolumn, buffersize);\r
+ }\r
+\r
+ /** Constructor. */\r
+ public SimpleCharStream(java.io.InputStream dstream, int startline,\r
+ int startcolumn, int buffersize)\r
+ {\r
+ this(new java.io.InputStreamReader(dstream), startline, startcolumn, buffersize);\r
+ }\r
+\r
+ /** Constructor. */\r
+ public SimpleCharStream(java.io.InputStream dstream, String encoding, int startline,\r
+ int startcolumn) throws java.io.UnsupportedEncodingException\r
+ {\r
+ this(dstream, encoding, startline, startcolumn, 4096);\r
+ }\r
+\r
+ /** Constructor. */\r
+ public SimpleCharStream(java.io.InputStream dstream, int startline,\r
+ int startcolumn)\r
+ {\r
+ this(dstream, startline, startcolumn, 4096);\r
+ }\r
+\r
+ /** Constructor. */\r
+ public SimpleCharStream(java.io.InputStream dstream, String encoding) throws java.io.UnsupportedEncodingException\r
+ {\r
+ this(dstream, encoding, 1, 1, 4096);\r
+ }\r
+\r
+ /** Constructor. */\r
+ public SimpleCharStream(java.io.InputStream dstream)\r
+ {\r
+ this(dstream, 1, 1, 4096);\r
+ }\r
+\r
+ /** Reinitialise. */\r
+ public void ReInit(java.io.InputStream dstream, String encoding, int startline,\r
+ int startcolumn, int buffersize) throws java.io.UnsupportedEncodingException\r
+ {\r
+ ReInit(encoding == null ? new java.io.InputStreamReader(dstream) : new java.io.InputStreamReader(dstream, encoding), startline, startcolumn, buffersize);\r
+ }\r
+\r
+ /** Reinitialise. */\r
+ public void ReInit(java.io.InputStream dstream, int startline,\r
+ int startcolumn, int buffersize)\r
+ {\r
+ ReInit(new java.io.InputStreamReader(dstream), startline, startcolumn, buffersize);\r
+ }\r
+\r
+ /** Reinitialise. */\r
+ public void ReInit(java.io.InputStream dstream, String encoding) throws java.io.UnsupportedEncodingException\r
+ {\r
+ ReInit(dstream, encoding, 1, 1, 4096);\r
+ }\r
+\r
+ /** Reinitialise. */\r
+ public void ReInit(java.io.InputStream dstream)\r
+ {\r
+ ReInit(dstream, 1, 1, 4096);\r
+ }\r
+ /** Reinitialise. */\r
+ public void ReInit(java.io.InputStream dstream, String encoding, int startline,\r
+ int startcolumn) throws java.io.UnsupportedEncodingException\r
+ {\r
+ ReInit(dstream, encoding, startline, startcolumn, 4096);\r
+ }\r
+ /** Reinitialise. */\r
+ public void ReInit(java.io.InputStream dstream, int startline,\r
+ int startcolumn)\r
+ {\r
+ ReInit(dstream, startline, startcolumn, 4096);\r
+ }\r
+ /** Get token literal value. */\r
+ public String GetImage()\r
+ {\r
+ if (bufpos >= tokenBegin)\r
+ return new String(buffer, tokenBegin, bufpos - tokenBegin + 1);\r
+ else\r
+ return new String(buffer, tokenBegin, bufsize - tokenBegin) +\r
+ new String(buffer, 0, bufpos + 1);\r
+ }\r
+\r
+ /** Get the suffix. */\r
+ public char[] GetSuffix(int len)\r
+ {\r
+ char[] ret = new char[len];\r
+\r
+ if ((bufpos + 1) >= len)\r
+ System.arraycopy(buffer, bufpos - len + 1, ret, 0, len);\r
+ else\r
+ {\r
+ System.arraycopy(buffer, bufsize - (len - bufpos - 1), ret, 0,\r
+ len - bufpos - 1);\r
+ System.arraycopy(buffer, 0, ret, len - bufpos - 1, bufpos + 1);\r
+ }\r
+\r
+ return ret;\r
+ }\r
+\r
+ /** Reset buffer when finished. */\r
+ public void Done()\r
+ {\r
+ buffer = null;\r
+ bufline = null;\r
+ bufcolumn = null;\r
+ }\r
+\r
+ /**\r
+ * Method to adjust line and column numbers for the start of a token.\r
+ */\r
+ public void adjustBeginLineColumn(int newLine, int newCol)\r
+ {\r
+ int start = tokenBegin;\r
+ int len;\r
+\r
+ if (bufpos >= tokenBegin)\r
+ {\r
+ len = bufpos - tokenBegin + inBuf + 1;\r
+ }\r
+ else\r
+ {\r
+ len = bufsize - tokenBegin + bufpos + 1 + inBuf;\r
+ }\r
+\r
+ int i = 0, j = 0, k = 0;\r
+ int nextColDiff = 0, columnDiff = 0;\r
+\r
+ while (i < len && bufline[j = start % bufsize] == bufline[k = ++start % bufsize])\r
+ {\r
+ bufline[j] = newLine;\r
+ nextColDiff = columnDiff + bufcolumn[k] - bufcolumn[j];\r
+ bufcolumn[j] = newCol + columnDiff;\r
+ columnDiff = nextColDiff;\r
+ i++;\r
+ }\r
+\r
+ if (i < len)\r
+ {\r
+ bufline[j] = newLine++;\r
+ bufcolumn[j] = newCol + columnDiff;\r
+\r
+ while (i++ < len)\r
+ {\r
+ if (bufline[j = start % bufsize] != bufline[++start % bufsize])\r
+ bufline[j] = newLine++;\r
+ else\r
+ bufline[j] = newLine;\r
+ }\r
+ }\r
+\r
+ line = bufline[j];\r
+ column = bufcolumn[j];\r
+ }\r
+\r
+}\r
+/* JavaCC - OriginalChecksum=6ae427b43f697d2e9732f56763450bf7 (do not edit this line) */\r
--- /dev/null
+/* Generated By:JavaCC: Do not edit this line. TableParser.java */\r
+package org.simantics.sysdyn.tableParser;\r
+\r
+import java.util.ArrayList;\r
+\r
+public class TableParser implements TableParserConstants {\r
+ ArrayList<Token> xTokens = new ArrayList<Token>();\r
+ ArrayList<Token> yTokens = new ArrayList<Token>();\r
+\r
+ public ArrayList<Token> getXTokens() {\r
+ return xTokens;\r
+ }\r
+\r
+ public ArrayList<Token> getYTokens() {\r
+ return yTokens;\r
+ }\r
+\r
+/*** Parser ********************************************************/\r
+ final public void table() throws ParseException {\r
+ switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {\r
+ case 64:\r
+ case 66:\r
+ switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {\r
+ case 64:\r
+ curlyTable();\r
+ break;\r
+ case 66:\r
+ bracketTable();\r
+ break;\r
+ default:\r
+ jj_la1[0] = jj_gen;\r
+ jj_consume_token(-1);\r
+ throw new ParseException();\r
+ }\r
+ break;\r
+ default:\r
+ jj_la1[1] = jj_gen;\r
+ ;\r
+ }\r
+ jj_consume_token(0);\r
+ }\r
+\r
+ final public void curlyTable() throws ParseException {\r
+ jj_consume_token(64);\r
+ jj_consume_token(64);\r
+ table_element();\r
+ jj_consume_token(65);\r
+ label_1:\r
+ while (true) {\r
+ switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {\r
+ case 71:\r
+ ;\r
+ break;\r
+ default:\r
+ jj_la1[2] = jj_gen;\r
+ break label_1;\r
+ }\r
+ jj_consume_token(71);\r
+ jj_consume_token(64);\r
+ table_element();\r
+ jj_consume_token(65);\r
+ }\r
+ jj_consume_token(65);\r
+ }\r
+\r
+ final public void bracketTable() throws ParseException {\r
+ jj_consume_token(66);\r
+ table_element();\r
+ label_2:\r
+ while (true) {\r
+ switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {\r
+ case 70:\r
+ ;\r
+ break;\r
+ default:\r
+ jj_la1[3] = jj_gen;\r
+ break label_2;\r
+ }\r
+ jj_consume_token(70);\r
+ table_element();\r
+ }\r
+ jj_consume_token(67);\r
+ }\r
+\r
+ final public void table_element() throws ParseException {\r
+ x_value();\r
+ jj_consume_token(71);\r
+ y_value();\r
+ }\r
+\r
+ final public void x_value() throws ParseException {\r
+ signed_number();\r
+ xTokens.add(token);\r
+ }\r
+\r
+ final public void y_value() throws ParseException {\r
+ signed_number();\r
+ yTokens.add(token);\r
+ }\r
+\r
+ final public void signed_number() throws ParseException {\r
+ switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {\r
+ case UNSIGNED_INTEGER:\r
+ jj_consume_token(UNSIGNED_INTEGER);\r
+ break;\r
+ case UNSIGNED_NUMBER:\r
+ jj_consume_token(UNSIGNED_NUMBER);\r
+ break;\r
+ case SIGNED_NUMBER:\r
+ jj_consume_token(SIGNED_NUMBER);\r
+ break;\r
+ default:\r
+ jj_la1[4] = jj_gen;\r
+ jj_consume_token(-1);\r
+ throw new ParseException();\r
+ }\r
+ }\r
+\r
+ /** Generated Token Manager. */\r
+ public TableParserTokenManager token_source;\r
+ SimpleCharStream jj_input_stream;\r
+ /** Current token. */\r
+ public Token token;\r
+ /** Next token. */\r
+ public Token jj_nt;\r
+ private int jj_ntk;\r
+ private int jj_gen;\r
+ final private int[] jj_la1 = new int[5];\r
+ static private int[] jj_la1_0;\r
+ static private int[] jj_la1_1;\r
+ static private int[] jj_la1_2;\r
+ static {\r
+ jj_la1_init_0();\r
+ jj_la1_init_1();\r
+ jj_la1_init_2();\r
+ }\r
+ private static void jj_la1_init_0() {\r
+ jj_la1_0 = new int[] {0x0,0x0,0x0,0x0,0x0,};\r
+ }\r
+ private static void jj_la1_init_1() {\r
+ jj_la1_1 = new int[] {0x0,0x0,0x0,0x0,0x0,};\r
+ }\r
+ private static void jj_la1_init_2() {\r
+ jj_la1_2 = new int[] {0x5,0x5,0x80,0x40,0x70000000,};\r
+ }\r
+\r
+ /** Constructor with InputStream. */\r
+ public TableParser(java.io.InputStream stream) {\r
+ this(stream, null);\r
+ }\r
+ /** Constructor with InputStream and supplied encoding */\r
+ public TableParser(java.io.InputStream stream, String encoding) {\r
+ try { jj_input_stream = new SimpleCharStream(stream, encoding, 1, 1); } catch(java.io.UnsupportedEncodingException e) { throw new RuntimeException(e); }\r
+ token_source = new TableParserTokenManager(jj_input_stream);\r
+ token = new Token();\r
+ jj_ntk = -1;\r
+ jj_gen = 0;\r
+ for (int i = 0; i < 5; i++) jj_la1[i] = -1;\r
+ }\r
+\r
+ /** Reinitialise. */\r
+ public void ReInit(java.io.InputStream stream) {\r
+ ReInit(stream, null);\r
+ }\r
+ /** Reinitialise. */\r
+ public void ReInit(java.io.InputStream stream, String encoding) {\r
+ try { jj_input_stream.ReInit(stream, encoding, 1, 1); } catch(java.io.UnsupportedEncodingException e) { throw new RuntimeException(e); }\r
+ token_source.ReInit(jj_input_stream);\r
+ token = new Token();\r
+ jj_ntk = -1;\r
+ jj_gen = 0;\r
+ for (int i = 0; i < 5; i++) jj_la1[i] = -1;\r
+ }\r
+\r
+ /** Constructor. */\r
+ public TableParser(java.io.Reader stream) {\r
+ jj_input_stream = new SimpleCharStream(stream, 1, 1);\r
+ token_source = new TableParserTokenManager(jj_input_stream);\r
+ token = new Token();\r
+ jj_ntk = -1;\r
+ jj_gen = 0;\r
+ for (int i = 0; i < 5; i++) jj_la1[i] = -1;\r
+ }\r
+\r
+ /** Reinitialise. */\r
+ public void ReInit(java.io.Reader stream) {\r
+ jj_input_stream.ReInit(stream, 1, 1);\r
+ token_source.ReInit(jj_input_stream);\r
+ token = new Token();\r
+ jj_ntk = -1;\r
+ jj_gen = 0;\r
+ for (int i = 0; i < 5; i++) jj_la1[i] = -1;\r
+ }\r
+\r
+ /** Constructor with generated Token Manager. */\r
+ public TableParser(TableParserTokenManager tm) {\r
+ token_source = tm;\r
+ token = new Token();\r
+ jj_ntk = -1;\r
+ jj_gen = 0;\r
+ for (int i = 0; i < 5; i++) jj_la1[i] = -1;\r
+ }\r
+\r
+ /** Reinitialise. */\r
+ public void ReInit(TableParserTokenManager tm) {\r
+ token_source = tm;\r
+ token = new Token();\r
+ jj_ntk = -1;\r
+ jj_gen = 0;\r
+ for (int i = 0; i < 5; i++) jj_la1[i] = -1;\r
+ }\r
+\r
+ private Token jj_consume_token(int kind) throws ParseException {\r
+ Token oldToken;\r
+ if ((oldToken = token).next != null) token = token.next;\r
+ else token = token.next = token_source.getNextToken();\r
+ jj_ntk = -1;\r
+ if (token.kind == kind) {\r
+ jj_gen++;\r
+ return token;\r
+ }\r
+ token = oldToken;\r
+ jj_kind = kind;\r
+ throw generateParseException();\r
+ }\r
+\r
+\r
+/** Get the next Token. */\r
+ final public Token getNextToken() {\r
+ if (token.next != null) token = token.next;\r
+ else token = token.next = token_source.getNextToken();\r
+ jj_ntk = -1;\r
+ jj_gen++;\r
+ return token;\r
+ }\r
+\r
+/** Get the specific Token. */\r
+ final public Token getToken(int index) {\r
+ Token t = token;\r
+ for (int i = 0; i < index; i++) {\r
+ if (t.next != null) t = t.next;\r
+ else t = t.next = token_source.getNextToken();\r
+ }\r
+ return t;\r
+ }\r
+\r
+ private int jj_ntk() {\r
+ if ((jj_nt=token.next) == null)\r
+ return (jj_ntk = (token.next=token_source.getNextToken()).kind);\r
+ else\r
+ return (jj_ntk = jj_nt.kind);\r
+ }\r
+\r
+ private java.util.List<int[]> jj_expentries = new java.util.ArrayList<int[]>();\r
+ private int[] jj_expentry;\r
+ private int jj_kind = -1;\r
+\r
+ /** Generate ParseException. */\r
+ public ParseException generateParseException() {\r
+ jj_expentries.clear();\r
+ boolean[] la1tokens = new boolean[95];\r
+ if (jj_kind >= 0) {\r
+ la1tokens[jj_kind] = true;\r
+ jj_kind = -1;\r
+ }\r
+ for (int i = 0; i < 5; i++) {\r
+ if (jj_la1[i] == jj_gen) {\r
+ for (int j = 0; j < 32; j++) {\r
+ if ((jj_la1_0[i] & (1<<j)) != 0) {\r
+ la1tokens[j] = true;\r
+ }\r
+ if ((jj_la1_1[i] & (1<<j)) != 0) {\r
+ la1tokens[32+j] = true;\r
+ }\r
+ if ((jj_la1_2[i] & (1<<j)) != 0) {\r
+ la1tokens[64+j] = true;\r
+ }\r
+ }\r
+ }\r
+ }\r
+ for (int i = 0; i < 95; i++) {\r
+ if (la1tokens[i]) {\r
+ jj_expentry = new int[1];\r
+ jj_expentry[0] = i;\r
+ jj_expentries.add(jj_expentry);\r
+ }\r
+ }\r
+ int[][] exptokseq = new int[jj_expentries.size()][];\r
+ for (int i = 0; i < jj_expentries.size(); i++) {\r
+ exptokseq[i] = jj_expentries.get(i);\r
+ }\r
+ return new ParseException(token, exptokseq, tokenImage);\r
+ }\r
+\r
+ /** Enable tracing. */\r
+ final public void enable_tracing() {\r
+ }\r
+\r
+ /** Disable tracing. */\r
+ final public void disable_tracing() {\r
+ }\r
+\r
+}\r
--- /dev/null
+options {\r
+ JDK_VERSION = "1.6";\r
+ STATIC = false;\r
+}\r
+\r
+PARSER_BEGIN(TableParser)\r
+package org.simantics.sysdyn.tableParser;\r
+\r
+import java.util.ArrayList;\r
+\r
+public class TableParser {\r
+ ArrayList<Token> xTokens = new ArrayList<Token>();\r
+ ArrayList<Token> yTokens = new ArrayList<Token>();\r
+ \r
+ public ArrayList<Token> getXTokens() {\r
+ return xTokens;\r
+ }\r
+ \r
+ public ArrayList<Token> getYTokens() {\r
+ return yTokens;\r
+ }\r
+ \r
+ \r
+}\r
+PARSER_END(TableParser)\r
+\r
+/*** Lexer *********************************************************/\r
+\r
+SKIP:\r
+{ <WHITESPACE: " " | "\n" | "\r" | "\t" > \r
+| <COMMENT1: "/*" (~["*"] | "*" ~["/"])* "*/" > \r
+| <COMMENT2: "//" (~["\n"])* >\r
+}\r
+\r
+TOKEN:\r
+{\r
+"algorithm" | "discrete" | "false" | "model" | "redeclare"\r
+| "and" | "each" | "final" | "not" | "replaceable"\r
+| "annotation" | "else" | "flow" | "operator" | "return"\r
+|"assert" | "elseif" | "for" | "or" | "stream"\r
+| "block" | "elsewhen" | "function" | "outer" | "then"\r
+| "break" | "encapsulated" | "if" | "output" | "true"\r
+| "class" | "end" | "import" | "package" | "type"\r
+| "connect" | "enumeration" | "in" | "parameter" | "when"\r
+| "connector" | "equation" | "initial" | "partial" | "while"\r
+| "constant" | "expandable" | "inner" | "protected" | "within"\r
+| "constrainedby" | "extends" | "input" | "public"\r
+| "der" | "external" | "loop" | "record"\r
+| "(" | ")" | "{" | "}" | "[" | "]" | "." | ":" | ";" | ","\r
+| "<" | "<=" | ">" | ">=" | "==" | "<>"\r
+| "+" | "-" | ".+" | ".-"\r
+| "*" | "/" | ".*" | "./"\r
+| "^" | ".^"\r
+| "=" | ":=" \r
+| <IDENT: ["a"-"z","A"-"Z","_"] (["a"-"z","A"-"Z","_","0"-"9"])* >\r
+| <STRING: "\"" (~["\"", "\\", "\n"] | "\\" ~["\n"])* "\"">\r
+ { matchedToken.image = matchedToken.image.substring(1,matchedToken.image.length()-1); }\r
+| <UNSIGNED_INTEGER: (["0"-"9"])+ >\r
+| <UNSIGNED_NUMBER: \r
+ ( <UNSIGNED_INTEGER> "." (<UNSIGNED_INTEGER>)? (["e","E"] <UNSIGNED_INTEGER>)?\r
+ | "." <UNSIGNED_INTEGER> (["e","E"] <UNSIGNED_INTEGER>)?\r
+ | <UNSIGNED_INTEGER> ["e","E"] <UNSIGNED_INTEGER>\r
+ ) >\r
+| <SIGNED_NUMBER : (("-")? ( <UNSIGNED_NUMBER> | <UNSIGNED_INTEGER> ))>\r
+}\r
+\r
+/*** Parser ********************************************************/\r
+\r
+void table() : {\r
+} {\r
+ ( curlyTable() | bracketTable())? <EOF>\r
+}\r
+\r
+void curlyTable() : {\r} {\r
+ ( "{" "{" table_element() "}" ( "," "{" table_element() "}" )* "}" )\r
+} \r\r
+void bracketTable() : {\r} {\r
+ ( "[" table_element() ( ";" table_element() )* "]" )\r
+}\r \r
+\r
+void table_element() : {\r
+} {\r
+ (x_value() "," y_value())\r
+} \r
+\r
+void x_value() : {\r
+} { \r
+ \r
+ signed_number() {\r
+ xTokens.add(token);\r
+ }\r
+}\r
+\r
+void y_value() : {\r
+} { \r
+ signed_number() {\r
+ yTokens.add(token);\r
+ }\r
+}\r
+\r
+void signed_number() : {\r
+} {\r
+ ( <UNSIGNED_INTEGER> | <UNSIGNED_NUMBER> | <SIGNED_NUMBER> )\r
+}
\ No newline at end of file
--- /dev/null
+/* Generated By:JavaCC: Do not edit this line. TableParserConstants.java */\r
+package org.simantics.sysdyn.tableParser;\r
+\r
+\r
+/**\r
+ * Token literal values and constants.\r
+ * Generated by org.javacc.parser.OtherFilesGen#start()\r
+ */\r
+public interface TableParserConstants {\r
+\r
+ /** End of File. */\r
+ int EOF = 0;\r
+ /** RegularExpression Id. */\r
+ int WHITESPACE = 1;\r
+ /** RegularExpression Id. */\r
+ int COMMENT1 = 2;\r
+ /** RegularExpression Id. */\r
+ int COMMENT2 = 3;\r
+ /** RegularExpression Id. */\r
+ int IDENT = 90;\r
+ /** RegularExpression Id. */\r
+ int STRING = 91;\r
+ /** RegularExpression Id. */\r
+ int UNSIGNED_INTEGER = 92;\r
+ /** RegularExpression Id. */\r
+ int UNSIGNED_NUMBER = 93;\r
+ /** RegularExpression Id. */\r
+ int SIGNED_NUMBER = 94;\r
+\r
+ /** Lexical state. */\r
+ int DEFAULT = 0;\r
+\r
+ /** Literal token values. */\r
+ String[] tokenImage = {\r
+ "<EOF>",\r
+ "<WHITESPACE>",\r
+ "<COMMENT1>",\r
+ "<COMMENT2>",\r
+ "\"algorithm\"",\r
+ "\"discrete\"",\r
+ "\"false\"",\r
+ "\"model\"",\r
+ "\"redeclare\"",\r
+ "\"and\"",\r
+ "\"each\"",\r
+ "\"final\"",\r
+ "\"not\"",\r
+ "\"replaceable\"",\r
+ "\"annotation\"",\r
+ "\"else\"",\r
+ "\"flow\"",\r
+ "\"operator\"",\r
+ "\"return\"",\r
+ "\"assert\"",\r
+ "\"elseif\"",\r
+ "\"for\"",\r
+ "\"or\"",\r
+ "\"stream\"",\r
+ "\"block\"",\r
+ "\"elsewhen\"",\r
+ "\"function\"",\r
+ "\"outer\"",\r
+ "\"then\"",\r
+ "\"break\"",\r
+ "\"encapsulated\"",\r
+ "\"if\"",\r
+ "\"output\"",\r
+ "\"true\"",\r
+ "\"class\"",\r
+ "\"end\"",\r
+ "\"import\"",\r
+ "\"package\"",\r
+ "\"type\"",\r
+ "\"connect\"",\r
+ "\"enumeration\"",\r
+ "\"in\"",\r
+ "\"parameter\"",\r
+ "\"when\"",\r
+ "\"connector\"",\r
+ "\"equation\"",\r
+ "\"initial\"",\r
+ "\"partial\"",\r
+ "\"while\"",\r
+ "\"constant\"",\r
+ "\"expandable\"",\r
+ "\"inner\"",\r
+ "\"protected\"",\r
+ "\"within\"",\r
+ "\"constrainedby\"",\r
+ "\"extends\"",\r
+ "\"input\"",\r
+ "\"public\"",\r
+ "\"der\"",\r
+ "\"external\"",\r
+ "\"loop\"",\r
+ "\"record\"",\r
+ "\"(\"",\r
+ "\")\"",\r
+ "\"{\"",\r
+ "\"}\"",\r
+ "\"[\"",\r
+ "\"]\"",\r
+ "\".\"",\r
+ "\":\"",\r
+ "\";\"",\r
+ "\",\"",\r
+ "\"<\"",\r
+ "\"<=\"",\r
+ "\">\"",\r
+ "\">=\"",\r
+ "\"==\"",\r
+ "\"<>\"",\r
+ "\"+\"",\r
+ "\"-\"",\r
+ "\".+\"",\r
+ "\".-\"",\r
+ "\"*\"",\r
+ "\"/\"",\r
+ "\".*\"",\r
+ "\"./\"",\r
+ "\"^\"",\r
+ "\".^\"",\r
+ "\"=\"",\r
+ "\":=\"",\r
+ "<IDENT>",\r
+ "<STRING>",\r
+ "<UNSIGNED_INTEGER>",\r
+ "<UNSIGNED_NUMBER>",\r
+ "<SIGNED_NUMBER>",\r
+ };\r
+\r
+}\r
--- /dev/null
+/* Generated By:JavaCC: Do not edit this line. TableParserTokenManager.java */\r
+package org.simantics.sysdyn.tableParser;\r
+import java.util.ArrayList;\r
+\r
+/** Token Manager. */\r
+public class TableParserTokenManager implements TableParserConstants\r
+{\r
+\r
+ /** Debug output. */\r
+ public java.io.PrintStream debugStream = System.out;\r
+ /** Set debug output. */\r
+ public void setDebugStream(java.io.PrintStream ds) { debugStream = ds; }\r
+private final int jjStopStringLiteralDfa_0(int pos, long active0, long active1)
+{\r
+ switch (pos)
+ {\r
+ case 0:\r
+ if ((active1 & 0x80000L) != 0L)\r
+ return 24;\r
+ if ((active0 & 0x3ffffffffffffff0L) != 0L)\r
+ {\r
+ jjmatchedKind = 90;\r
+ return 2;\r
+ }\r
+ if ((active1 & 0xb30010L) != 0L)\r
+ return 46;\r
+ if ((active1 & 0x8000L) != 0L)\r
+ return 9;\r
+ return -1;\r
+ case 1:\r
+ if ((active0 & 0x108420080400000L) != 0L)\r
+ return 2;\r
+ if ((active0 & 0x3ef7bdff7fbffff0L) != 0L)\r
+ {\r
+ if (jjmatchedPos != 1)\r
+ {\r
+ jjmatchedKind = 90;\r
+ jjmatchedPos = 1;\r
+ }\r
+ return 2;\r
+ }\r
+ return -1;\r
+ case 2:\r
+ if ((active0 & 0x400000800201200L) != 0L)\r
+ return 2;\r
+ if ((active0 & 0x3bfffdf77f9fedf0L) != 0L)\r
+ {\r
+ jjmatchedKind = 90;\r
+ jjmatchedPos = 2;\r
+ return 2;\r
+ }\r
+ return -1;\r
+ case 3:\r
+ if ((active0 & 0x1000084212118400L) != 0L)\r
+ return 2;\r
+ if ((active0 & 0x2bfff5b56d8e69f0L) != 0L)\r
+ {\r
+ if (jjmatchedPos != 3)\r
+ {\r
+ jjmatchedKind = 90;\r
+ jjmatchedPos = 3;\r
+ }\r
+ return 2;\r
+ }\r
+ return -1;\r
+ case 4:\r
+ if ((active0 & 0x1090004290008c0L) != 0L)\r
+ return 2;\r
+ if ((active0 & 0x2af6f5b1469e6130L) != 0L)\r
+ {\r
+ jjmatchedKind = 90;\r
+ jjmatchedPos = 4;\r
+ return 2;\r
+ }\r
+ return -1;\r
+ case 5:\r
+ if ((active0 & 0x22200011009c0000L) != 0L)\r
+ return 2;\r
+ if ((active0 & 0x8d6f5a046026130L) != 0L)\r
+ {\r
+ jjmatchedKind = 90;\r
+ jjmatchedPos = 5;\r
+ return 2;\r
+ }\r
+ return -1;\r
+ case 6:\r
+ if ((active0 & 0x80d0a000000000L) != 0L)\r
+ return 2;\r
+ if ((active0 & 0x856250046026130L) != 0L)\r
+ {\r
+ if (jjmatchedPos != 6)\r
+ {\r
+ jjmatchedKind = 90;\r
+ jjmatchedPos = 6;\r
+ }\r
+ return 2;\r
+ }\r
+ return -1;\r
+ case 7:\r
+ if ((active0 & 0x54150040006110L) != 0L)\r
+ {\r
+ jjmatchedKind = 90;\r
+ jjmatchedPos = 7;\r
+ return 2;\r
+ }\r
+ if ((active0 & 0x802200006020020L) != 0L)\r
+ return 2;\r
+ return -1;\r
+ case 8:\r
+ if ((active0 & 0x10140000000110L) != 0L)\r
+ return 2;\r
+ if ((active0 & 0x44010040006000L) != 0L)\r
+ {\r
+ jjmatchedKind = 90;\r
+ jjmatchedPos = 8;\r
+ return 2;\r
+ }\r
+ return -1;\r
+ case 9:\r
+ if ((active0 & 0x40010040002000L) != 0L)\r
+ {\r
+ jjmatchedKind = 90;\r
+ jjmatchedPos = 9;\r
+ return 2;\r
+ }\r
+ if ((active0 & 0x4000000004000L) != 0L)\r
+ return 2;\r
+ return -1;\r
+ case 10:\r
+ if ((active0 & 0x10000002000L) != 0L)\r
+ return 2;\r
+ if ((active0 & 0x40000040000000L) != 0L)\r
+ {\r
+ jjmatchedKind = 90;\r
+ jjmatchedPos = 10;\r
+ return 2;\r
+ }\r
+ return -1;\r
+ case 11:\r
+ if ((active0 & 0x40000000L) != 0L)\r
+ return 2;\r
+ if ((active0 & 0x40000000000000L) != 0L)\r
+ {\r
+ jjmatchedKind = 90;\r
+ jjmatchedPos = 11;\r
+ return 2;\r
+ }\r
+ return -1;\r
+ default :\r
+ return -1;\r
+ }\r
+}\r
+private final int jjStartNfa_0(int pos, long active0, long active1)
+{\r
+ return jjMoveNfa_0(jjStopStringLiteralDfa_0(pos, active0, active1), pos + 1);\r
+}\r
+private int jjStopAtPos(int pos, int kind)\r
+{\r
+ jjmatchedKind = kind;\r
+ jjmatchedPos = pos;\r
+ return pos + 1;\r
+}\r
+private int jjMoveStringLiteralDfa0_0()\r
+{\r
+ switch(curChar)\r
+ {\r
+ case 40:\r
+ return jjStopAtPos(0, 62);\r
+ case 41:\r
+ return jjStopAtPos(0, 63);\r
+ case 42:\r
+ return jjStopAtPos(0, 82);\r
+ case 43:\r
+ return jjStopAtPos(0, 78);\r
+ case 44:\r
+ return jjStopAtPos(0, 71);\r
+ case 45:\r
+ return jjStartNfaWithStates_0(0, 79, 9);\r
+ case 46:\r
+ jjmatchedKind = 68;\r
+ return jjMoveStringLiteralDfa1_0(0x0L, 0xb30000L);\r
+ case 47:\r
+ return jjStartNfaWithStates_0(0, 83, 24);\r
+ case 58:\r
+ jjmatchedKind = 69;\r
+ return jjMoveStringLiteralDfa1_0(0x0L, 0x2000000L);\r
+ case 59:\r
+ return jjStopAtPos(0, 70);\r
+ case 60:\r
+ jjmatchedKind = 72;\r
+ return jjMoveStringLiteralDfa1_0(0x0L, 0x2200L);\r
+ case 61:\r
+ jjmatchedKind = 88;\r
+ return jjMoveStringLiteralDfa1_0(0x0L, 0x1000L);\r
+ case 62:\r
+ jjmatchedKind = 74;\r
+ return jjMoveStringLiteralDfa1_0(0x0L, 0x800L);\r
+ case 91:\r
+ return jjStopAtPos(0, 66);\r
+ case 93:\r
+ return jjStopAtPos(0, 67);\r
+ case 94:\r
+ return jjStopAtPos(0, 86);\r
+ case 97:\r
+ return jjMoveStringLiteralDfa1_0(0x84210L, 0x0L);\r
+ case 98:\r
+ return jjMoveStringLiteralDfa1_0(0x21000000L, 0x0L);\r
+ case 99:\r
+ return jjMoveStringLiteralDfa1_0(0x42108400000000L, 0x0L);\r
+ case 100:\r
+ return jjMoveStringLiteralDfa1_0(0x400000000000020L, 0x0L);\r
+ case 101:\r
+ return jjMoveStringLiteralDfa1_0(0x884210842108400L, 0x0L);\r
+ case 102:\r
+ return jjMoveStringLiteralDfa1_0(0x4210840L, 0x0L);\r
+ case 105:\r
+ return jjMoveStringLiteralDfa1_0(0x108421080000000L, 0x0L);\r
+ case 108:\r
+ return jjMoveStringLiteralDfa1_0(0x1000000000000000L, 0x0L);\r
+ case 109:\r
+ return jjMoveStringLiteralDfa1_0(0x80L, 0x0L);\r
+ case 110:\r
+ return jjMoveStringLiteralDfa1_0(0x1000L, 0x0L);\r
+ case 111:\r
+ return jjMoveStringLiteralDfa1_0(0x108420000L, 0x0L);\r
+ case 112:\r
+ return jjMoveStringLiteralDfa1_0(0x210842000000000L, 0x0L);\r
+ case 114:\r
+ return jjMoveStringLiteralDfa1_0(0x2000000000042100L, 0x0L);\r
+ case 115:\r
+ return jjMoveStringLiteralDfa1_0(0x800000L, 0x0L);\r
+ case 116:\r
+ return jjMoveStringLiteralDfa1_0(0x4210000000L, 0x0L);\r
+ case 119:\r
+ return jjMoveStringLiteralDfa1_0(0x21080000000000L, 0x0L);\r
+ case 123:\r
+ return jjStopAtPos(0, 64);\r
+ case 125:\r
+ return jjStopAtPos(0, 65);\r
+ default :\r
+ return jjMoveNfa_0(0, 0);\r
+ }\r
+}\r
+private int jjMoveStringLiteralDfa1_0(long active0, long active1)\r
+{\r
+ try { curChar = input_stream.readChar(); }\r
+ catch(java.io.IOException e) {\r
+ jjStopStringLiteralDfa_0(0, active0, active1);\r
+ return 1;\r
+ }\r
+ switch(curChar)\r
+ {\r
+ case 42:\r
+ if ((active1 & 0x100000L) != 0L)\r
+ return jjStopAtPos(1, 84);\r
+ break;\r
+ case 43:\r
+ if ((active1 & 0x10000L) != 0L)\r
+ return jjStopAtPos(1, 80);\r
+ break;\r
+ case 45:\r
+ if ((active1 & 0x20000L) != 0L)\r
+ return jjStopAtPos(1, 81);\r
+ break;\r
+ case 47:\r
+ if ((active1 & 0x200000L) != 0L)\r
+ return jjStopAtPos(1, 85);\r
+ break;\r
+ case 61:\r
+ if ((active1 & 0x200L) != 0L)\r
+ return jjStopAtPos(1, 73);\r
+ else if ((active1 & 0x800L) != 0L)\r
+ return jjStopAtPos(1, 75);\r
+ else if ((active1 & 0x1000L) != 0L)\r
+ return jjStopAtPos(1, 76);\r
+ else if ((active1 & 0x2000000L) != 0L)\r
+ return jjStopAtPos(1, 89);\r
+ break;\r
+ case 62:\r
+ if ((active1 & 0x2000L) != 0L)\r
+ return jjStopAtPos(1, 77);\r
+ break;\r
+ case 94:\r
+ if ((active1 & 0x800000L) != 0L)\r
+ return jjStopAtPos(1, 87);\r
+ break;\r
+ case 97:\r
+ return jjMoveStringLiteralDfa2_0(active0, 0x842000000440L, active1, 0L);\r
+ case 101:\r
+ return jjMoveStringLiteralDfa2_0(active0, 0x2400000000042100L, active1, 0L);\r
+ case 102:\r
+ if ((active0 & 0x80000000L) != 0L)\r
+ return jjStartNfaWithStates_0(1, 31, 2);\r
+ break;\r
+ case 104:\r
+ return jjMoveStringLiteralDfa2_0(active0, 0x1080010000000L, active1, 0L);\r
+ case 105:\r
+ return jjMoveStringLiteralDfa2_0(active0, 0x20000000000820L, active1, 0L);\r
+ case 108:\r
+ return jjMoveStringLiteralDfa2_0(active0, 0x403118010L, active1, 0L);\r
+ case 109:\r
+ return jjMoveStringLiteralDfa2_0(active0, 0x1000000000L, active1, 0L);\r
+ case 110:\r
+ if ((active0 & 0x20000000000L) != 0L)\r
+ {\r
+ jjmatchedKind = 41;\r
+ jjmatchedPos = 1;\r
+ }\r
+ return jjMoveStringLiteralDfa2_0(active0, 0x108410840004200L, active1, 0L);\r
+ case 111:\r
+ return jjMoveStringLiteralDfa2_0(active0, 0x1042108000201080L, active1, 0L);\r
+ case 112:\r
+ return jjMoveStringLiteralDfa2_0(active0, 0x20000L, active1, 0L);\r
+ case 113:\r
+ return jjMoveStringLiteralDfa2_0(active0, 0x200000000000L, active1, 0L);\r
+ case 114:\r
+ if ((active0 & 0x400000L) != 0L)\r
+ return jjStartNfaWithStates_0(1, 22, 2);\r
+ return jjMoveStringLiteralDfa2_0(active0, 0x10000220000000L, active1, 0L);\r
+ case 115:\r
+ return jjMoveStringLiteralDfa2_0(active0, 0x80000L, active1, 0L);\r
+ case 116:\r
+ return jjMoveStringLiteralDfa2_0(active0, 0x800000L, active1, 0L);\r
+ case 117:\r
+ return jjMoveStringLiteralDfa2_0(active0, 0x20000010c000000L, active1, 0L);\r
+ case 120:\r
+ return jjMoveStringLiteralDfa2_0(active0, 0x884000000000000L, active1, 0L);\r
+ case 121:\r
+ return jjMoveStringLiteralDfa2_0(active0, 0x4000000000L, active1, 0L);\r
+ default :\r
+ break;\r
+ }\r
+ return jjStartNfa_0(0, active0, active1);\r
+}\r
+private int jjMoveStringLiteralDfa2_0(long old0, long active0, long old1, long active1)\r
+{\r
+ if (((active0 &= old0) | (active1 &= old1)) == 0L)\r
+ return jjStartNfa_0(0, old0, old1);\r
+ try { curChar = input_stream.readChar(); }\r
+ catch(java.io.IOException e) {\r
+ jjStopStringLiteralDfa_0(1, active0, 0L);\r
+ return 2;\r
+ }\r
+ switch(curChar)\r
+ {\r
+ case 97:\r
+ return jjMoveStringLiteralDfa3_0(active0, 0x400000000L);\r
+ case 98:\r
+ return jjMoveStringLiteralDfa3_0(active0, 0x200000000000000L);\r
+ case 99:\r
+ return jjMoveStringLiteralDfa3_0(active0, 0x2000002040000400L);\r
+ case 100:\r
+ if ((active0 & 0x200L) != 0L)\r
+ return jjStartNfaWithStates_0(2, 9, 2);\r
+ else if ((active0 & 0x800000000L) != 0L)\r
+ return jjStartNfaWithStates_0(2, 35, 2);\r
+ return jjMoveStringLiteralDfa3_0(active0, 0x180L);\r
+ case 101:\r
+ return jjMoveStringLiteralDfa3_0(active0, 0x80030020000L);\r
+ case 103:\r
+ return jjMoveStringLiteralDfa3_0(active0, 0x10L);\r
+ case 105:\r
+ return jjMoveStringLiteralDfa3_0(active0, 0x1400000000000L);\r
+ case 108:\r
+ return jjMoveStringLiteralDfa3_0(active0, 0x40L);\r
+ case 110:\r
+ return jjMoveStringLiteralDfa3_0(active0, 0x4a108004004800L);\r
+ case 111:\r
+ return jjMoveStringLiteralDfa3_0(active0, 0x1010000001010000L);\r
+ case 112:\r
+ return jjMoveStringLiteralDfa3_0(active0, 0x104005000002000L);\r
+ case 114:\r
+ if ((active0 & 0x200000L) != 0L)\r
+ return jjStartNfaWithStates_0(2, 21, 2);\r
+ else if ((active0 & 0x400000000000000L) != 0L)\r
+ return jjStartNfaWithStates_0(2, 58, 2);\r
+ return jjMoveStringLiteralDfa3_0(active0, 0x840000800000L);\r
+ case 115:\r
+ return jjMoveStringLiteralDfa3_0(active0, 0x2188020L);\r
+ case 116:\r
+ if ((active0 & 0x1000L) != 0L)\r
+ return jjStartNfaWithStates_0(2, 12, 2);\r
+ return jjMoveStringLiteralDfa3_0(active0, 0x8a0000108040000L);\r
+ case 117:\r
+ return jjMoveStringLiteralDfa3_0(active0, 0x210200000000L);\r
+ default :\r
+ break;\r
+ }\r
+ return jjStartNfa_0(1, active0, 0L);\r
+}\r
+private int jjMoveStringLiteralDfa3_0(long old0, long active0)\r
+{\r
+ if (((active0 &= old0)) == 0L)\r
+ return jjStartNfa_0(1, old0, 0L);\r
+ try { curChar = input_stream.readChar(); }\r
+ catch(java.io.IOException e) {\r
+ jjStopStringLiteralDfa_0(2, active0, 0L);\r
+ return 3;\r
+ }\r
+ switch(curChar)\r
+ {\r
+ case 97:\r
+ return jjMoveStringLiteralDfa4_0(active0, 0x4240060000800L);\r
+ case 99:\r
+ return jjMoveStringLiteralDfa4_0(active0, 0x5000020L);\r
+ case 101:\r
+ if ((active0 & 0x8000L) != 0L)\r
+ {\r
+ jjmatchedKind = 15;\r
+ jjmatchedPos = 3;\r
+ }\r
+ else if ((active0 & 0x200000000L) != 0L)\r
+ return jjStartNfaWithStates_0(3, 33, 2);\r
+ else if ((active0 & 0x4000000000L) != 0L)\r
+ return jjStartNfaWithStates_0(3, 38, 2);\r
+ return jjMoveStringLiteralDfa4_0(active0, 0x88800000a980180L);\r
+ case 104:\r
+ if ((active0 & 0x400L) != 0L)\r
+ return jjStartNfaWithStates_0(3, 10, 2);\r
+ return jjMoveStringLiteralDfa4_0(active0, 0x20000000000000L);\r
+ case 107:\r
+ return jjMoveStringLiteralDfa4_0(active0, 0x2000000000L);\r
+ case 108:\r
+ return jjMoveStringLiteralDfa4_0(active0, 0x201000000002000L);\r
+ case 109:\r
+ return jjMoveStringLiteralDfa4_0(active0, 0x10000000000L);\r
+ case 110:\r
+ if ((active0 & 0x10000000L) != 0L)\r
+ return jjStartNfaWithStates_0(3, 28, 2);\r
+ else if ((active0 & 0x80000000000L) != 0L)\r
+ return jjStartNfaWithStates_0(3, 43, 2);\r
+ return jjMoveStringLiteralDfa4_0(active0, 0x108000000000L);\r
+ case 111:\r
+ return jjMoveStringLiteralDfa4_0(active0, 0x2000001000004010L);\r
+ case 112:\r
+ if ((active0 & 0x1000000000000000L) != 0L)\r
+ return jjStartNfaWithStates_0(3, 60, 2);\r
+ return jjMoveStringLiteralDfa4_0(active0, 0x100000000L);\r
+ case 114:\r
+ return jjMoveStringLiteralDfa4_0(active0, 0x20000L);\r
+ case 115:\r
+ return jjMoveStringLiteralDfa4_0(active0, 0x42000400000040L);\r
+ case 116:\r
+ return jjMoveStringLiteralDfa4_0(active0, 0x10c00000000000L);\r
+ case 117:\r
+ return jjMoveStringLiteralDfa4_0(active0, 0x100000000040000L);\r
+ case 119:\r
+ if ((active0 & 0x10000L) != 0L)\r
+ return jjStartNfaWithStates_0(3, 16, 2);\r
+ break;\r
+ default :\r
+ break;\r
+ }\r
+ return jjStartNfa_0(2, active0, 0L);\r
+}\r
+private int jjMoveStringLiteralDfa4_0(long old0, long active0)\r
+{\r
+ if (((active0 &= old0)) == 0L)\r
+ return jjStartNfa_0(2, old0, 0L);\r
+ try { curChar = input_stream.readChar(); }\r
+ catch(java.io.IOException e) {\r
+ jjStopStringLiteralDfa_0(3, active0, 0L);\r
+ return 4;\r
+ }\r
+ switch(curChar)\r
+ {\r
+ case 97:\r
+ return jjMoveStringLiteralDfa5_0(active0, 0x2000822000L);\r
+ case 99:\r
+ return jjMoveStringLiteralDfa5_0(active0, 0x100L);\r
+ case 101:\r
+ if ((active0 & 0x40L) != 0L)\r
+ return jjStartNfaWithStates_0(4, 6, 2);\r
+ else if ((active0 & 0x1000000000000L) != 0L)\r
+ return jjStartNfaWithStates_0(4, 48, 2);\r
+ return jjMoveStringLiteralDfa5_0(active0, 0x10118000000000L);\r
+ case 105:\r
+ return jjMoveStringLiteralDfa5_0(active0, 0x220c00000100000L);\r
+ case 107:\r
+ if ((active0 & 0x1000000L) != 0L)\r
+ return jjStartNfaWithStates_0(4, 24, 2);\r
+ else if ((active0 & 0x20000000L) != 0L)\r
+ return jjStartNfaWithStates_0(4, 29, 2);\r
+ break;\r
+ case 108:\r
+ if ((active0 & 0x80L) != 0L)\r
+ return jjStartNfaWithStates_0(4, 7, 2);\r
+ else if ((active0 & 0x800L) != 0L)\r
+ return jjStartNfaWithStates_0(4, 11, 2);\r
+ break;\r
+ case 109:\r
+ return jjMoveStringLiteralDfa5_0(active0, 0x40000000000L);\r
+ case 110:\r
+ return jjMoveStringLiteralDfa5_0(active0, 0x84000000000000L);\r
+ case 112:\r
+ return jjMoveStringLiteralDfa5_0(active0, 0x40000000L);\r
+ case 114:\r
+ if ((active0 & 0x8000000L) != 0L)\r
+ return jjStartNfaWithStates_0(4, 27, 2);\r
+ else if ((active0 & 0x8000000000000L) != 0L)\r
+ return jjStartNfaWithStates_0(4, 51, 2);\r
+ return jjMoveStringLiteralDfa5_0(active0, 0x28000010000c0030L);\r
+ case 115:\r
+ if ((active0 & 0x400000000L) != 0L)\r
+ return jjStartNfaWithStates_0(4, 34, 2);\r
+ break;\r
+ case 116:\r
+ if ((active0 & 0x100000000000000L) != 0L)\r
+ return jjStartNfaWithStates_0(4, 56, 2);\r
+ return jjMoveStringLiteralDfa5_0(active0, 0x42200004004000L);\r
+ case 117:\r
+ return jjMoveStringLiteralDfa5_0(active0, 0x100000000L);\r
+ case 119:\r
+ return jjMoveStringLiteralDfa5_0(active0, 0x2000000L);\r
+ default :\r
+ break;\r
+ }\r
+ return jjStartNfa_0(3, active0, 0L);\r
+}\r
+private int jjMoveStringLiteralDfa5_0(long old0, long active0)\r
+{\r
+ if (((active0 &= old0)) == 0L)\r
+ return jjStartNfa_0(3, old0, 0L);\r
+ try { curChar = input_stream.readChar(); }\r
+ catch(java.io.IOException e) {\r
+ jjStopStringLiteralDfa_0(4, active0, 0L);\r
+ return 5;\r
+ }\r
+ switch(curChar)\r
+ {\r
+ case 97:\r
+ return jjMoveStringLiteralDfa6_0(active0, 0x2c00000004000L);\r
+ case 99:\r
+ if ((active0 & 0x200000000000000L) != 0L)\r
+ return jjStartNfaWithStates_0(5, 57, 2);\r
+ return jjMoveStringLiteralDfa6_0(active0, 0x10108000002000L);\r
+ case 100:\r
+ if ((active0 & 0x2000000000000000L) != 0L)\r
+ return jjStartNfaWithStates_0(5, 61, 2);\r
+ return jjMoveStringLiteralDfa6_0(active0, 0x84000000000000L);\r
+ case 101:\r
+ return jjMoveStringLiteralDfa6_0(active0, 0x40000000020L);\r
+ case 102:\r
+ if ((active0 & 0x100000L) != 0L)\r
+ return jjStartNfaWithStates_0(5, 20, 2);\r
+ break;\r
+ case 103:\r
+ return jjMoveStringLiteralDfa6_0(active0, 0x2000000000L);\r
+ case 104:\r
+ return jjMoveStringLiteralDfa6_0(active0, 0x2000000L);\r
+ case 105:\r
+ return jjMoveStringLiteralDfa6_0(active0, 0x200004000010L);\r
+ case 108:\r
+ return jjMoveStringLiteralDfa6_0(active0, 0x100L);\r
+ case 109:\r
+ if ((active0 & 0x800000L) != 0L)\r
+ return jjStartNfaWithStates_0(5, 23, 2);\r
+ break;\r
+ case 110:\r
+ if ((active0 & 0x40000L) != 0L)\r
+ return jjStartNfaWithStates_0(5, 18, 2);\r
+ else if ((active0 & 0x20000000000000L) != 0L)\r
+ return jjStartNfaWithStates_0(5, 53, 2);\r
+ return jjMoveStringLiteralDfa6_0(active0, 0x800000000000000L);\r
+ case 114:\r
+ return jjMoveStringLiteralDfa6_0(active0, 0x40010000000000L);\r
+ case 115:\r
+ return jjMoveStringLiteralDfa6_0(active0, 0x40000000L);\r
+ case 116:\r
+ if ((active0 & 0x80000L) != 0L)\r
+ return jjStartNfaWithStates_0(5, 19, 2);\r
+ else if ((active0 & 0x100000000L) != 0L)\r
+ return jjStartNfaWithStates_0(5, 32, 2);\r
+ else if ((active0 & 0x1000000000L) != 0L)\r
+ return jjStartNfaWithStates_0(5, 36, 2);\r
+ return jjMoveStringLiteralDfa6_0(active0, 0x20000L);\r
+ default :\r
+ break;\r
+ }\r
+ return jjStartNfa_0(4, active0, 0L);\r
+}\r
+private int jjMoveStringLiteralDfa6_0(long old0, long active0)\r
+{\r
+ if (((active0 &= old0)) == 0L)\r
+ return jjStartNfa_0(4, old0, 0L);\r
+ try { curChar = input_stream.readChar(); }\r
+ catch(java.io.IOException e) {\r
+ jjStopStringLiteralDfa_0(5, active0, 0L);\r
+ return 6;\r
+ }\r
+ switch(curChar)\r
+ {\r
+ case 97:\r
+ return jjMoveStringLiteralDfa7_0(active0, 0x844010000000100L);\r
+ case 101:\r
+ if ((active0 & 0x2000000000L) != 0L)\r
+ return jjStartNfaWithStates_0(6, 37, 2);\r
+ return jjMoveStringLiteralDfa7_0(active0, 0x2002000L);\r
+ case 108:\r
+ if ((active0 & 0x400000000000L) != 0L)\r
+ return jjStartNfaWithStates_0(6, 46, 2);\r
+ else if ((active0 & 0x800000000000L) != 0L)\r
+ return jjStartNfaWithStates_0(6, 47, 2);\r
+ break;\r
+ case 110:\r
+ return jjMoveStringLiteralDfa7_0(active0, 0x2000000000000L);\r
+ case 111:\r
+ return jjMoveStringLiteralDfa7_0(active0, 0x200004020000L);\r
+ case 115:\r
+ if ((active0 & 0x80000000000000L) != 0L)\r
+ return jjStartNfaWithStates_0(6, 55, 2);\r
+ break;\r
+ case 116:\r
+ if ((active0 & 0x8000000000L) != 0L)\r
+ {\r
+ jjmatchedKind = 39;\r
+ jjmatchedPos = 6;\r
+ }\r
+ return jjMoveStringLiteralDfa7_0(active0, 0x10140000004030L);\r
+ case 117:\r
+ return jjMoveStringLiteralDfa7_0(active0, 0x40000000L);\r
+ default :\r
+ break;\r
+ }\r
+ return jjStartNfa_0(5, active0, 0L);\r
+}\r
+private int jjMoveStringLiteralDfa7_0(long old0, long active0)\r
+{\r
+ if (((active0 &= old0)) == 0L)\r
+ return jjStartNfa_0(5, old0, 0L);\r
+ try { curChar = input_stream.readChar(); }\r
+ catch(java.io.IOException e) {\r
+ jjStopStringLiteralDfa_0(6, active0, 0L);\r
+ return 7;\r
+ }\r
+ switch(curChar)\r
+ {\r
+ case 97:\r
+ return jjMoveStringLiteralDfa8_0(active0, 0x2000L);\r
+ case 98:\r
+ return jjMoveStringLiteralDfa8_0(active0, 0x4000000000000L);\r
+ case 101:\r
+ if ((active0 & 0x20L) != 0L)\r
+ return jjStartNfaWithStates_0(7, 5, 2);\r
+ return jjMoveStringLiteralDfa8_0(active0, 0x10040000000000L);\r
+ case 104:\r
+ return jjMoveStringLiteralDfa8_0(active0, 0x10L);\r
+ case 105:\r
+ return jjMoveStringLiteralDfa8_0(active0, 0x40000000004000L);\r
+ case 108:\r
+ if ((active0 & 0x800000000000000L) != 0L)\r
+ return jjStartNfaWithStates_0(7, 59, 2);\r
+ return jjMoveStringLiteralDfa8_0(active0, 0x40000000L);\r
+ case 110:\r
+ if ((active0 & 0x2000000L) != 0L)\r
+ return jjStartNfaWithStates_0(7, 25, 2);\r
+ else if ((active0 & 0x4000000L) != 0L)\r
+ return jjStartNfaWithStates_0(7, 26, 2);\r
+ else if ((active0 & 0x200000000000L) != 0L)\r
+ return jjStartNfaWithStates_0(7, 45, 2);\r
+ break;\r
+ case 111:\r
+ return jjMoveStringLiteralDfa8_0(active0, 0x100000000000L);\r
+ case 114:\r
+ if ((active0 & 0x20000L) != 0L)\r
+ return jjStartNfaWithStates_0(7, 17, 2);\r
+ return jjMoveStringLiteralDfa8_0(active0, 0x100L);\r
+ case 116:\r
+ if ((active0 & 0x2000000000000L) != 0L)\r
+ return jjStartNfaWithStates_0(7, 49, 2);\r
+ return jjMoveStringLiteralDfa8_0(active0, 0x10000000000L);\r
+ default :\r
+ break;\r
+ }\r
+ return jjStartNfa_0(6, active0, 0L);\r
+}\r
+private int jjMoveStringLiteralDfa8_0(long old0, long active0)\r
+{\r
+ if (((active0 &= old0)) == 0L)\r
+ return jjStartNfa_0(6, old0, 0L);\r
+ try { curChar = input_stream.readChar(); }\r
+ catch(java.io.IOException e) {\r
+ jjStopStringLiteralDfa_0(7, active0, 0L);\r
+ return 8;\r
+ }\r
+ switch(curChar)\r
+ {\r
+ case 97:\r
+ return jjMoveStringLiteralDfa9_0(active0, 0x40000000L);\r
+ case 98:\r
+ return jjMoveStringLiteralDfa9_0(active0, 0x2000L);\r
+ case 100:\r
+ if ((active0 & 0x10000000000000L) != 0L)\r
+ return jjStartNfaWithStates_0(8, 52, 2);\r
+ break;\r
+ case 101:\r
+ if ((active0 & 0x100L) != 0L)\r
+ return jjStartNfaWithStates_0(8, 8, 2);\r
+ break;\r
+ case 105:\r
+ return jjMoveStringLiteralDfa9_0(active0, 0x10000000000L);\r
+ case 108:\r
+ return jjMoveStringLiteralDfa9_0(active0, 0x4000000000000L);\r
+ case 109:\r
+ if ((active0 & 0x10L) != 0L)\r
+ return jjStartNfaWithStates_0(8, 4, 2);\r
+ break;\r
+ case 110:\r
+ return jjMoveStringLiteralDfa9_0(active0, 0x40000000000000L);\r
+ case 111:\r
+ return jjMoveStringLiteralDfa9_0(active0, 0x4000L);\r
+ case 114:\r
+ if ((active0 & 0x40000000000L) != 0L)\r
+ return jjStartNfaWithStates_0(8, 42, 2);\r
+ else if ((active0 & 0x100000000000L) != 0L)\r
+ return jjStartNfaWithStates_0(8, 44, 2);\r
+ break;\r
+ default :\r
+ break;\r
+ }\r
+ return jjStartNfa_0(7, active0, 0L);\r
+}\r
+private int jjMoveStringLiteralDfa9_0(long old0, long active0)\r
+{\r
+ if (((active0 &= old0)) == 0L)\r
+ return jjStartNfa_0(7, old0, 0L);\r
+ try { curChar = input_stream.readChar(); }\r
+ catch(java.io.IOException e) {\r
+ jjStopStringLiteralDfa_0(8, active0, 0L);\r
+ return 9;\r
+ }\r
+ switch(curChar)\r
+ {\r
+ case 101:\r
+ if ((active0 & 0x4000000000000L) != 0L)\r
+ return jjStartNfaWithStates_0(9, 50, 2);\r
+ return jjMoveStringLiteralDfa10_0(active0, 0x40000000000000L);\r
+ case 108:\r
+ return jjMoveStringLiteralDfa10_0(active0, 0x2000L);\r
+ case 110:\r
+ if ((active0 & 0x4000L) != 0L)\r
+ return jjStartNfaWithStates_0(9, 14, 2);\r
+ break;\r
+ case 111:\r
+ return jjMoveStringLiteralDfa10_0(active0, 0x10000000000L);\r
+ case 116:\r
+ return jjMoveStringLiteralDfa10_0(active0, 0x40000000L);\r
+ default :\r
+ break;\r
+ }\r
+ return jjStartNfa_0(8, active0, 0L);\r
+}\r
+private int jjMoveStringLiteralDfa10_0(long old0, long active0)\r
+{\r
+ if (((active0 &= old0)) == 0L)\r
+ return jjStartNfa_0(8, old0, 0L);\r
+ try { curChar = input_stream.readChar(); }\r
+ catch(java.io.IOException e) {\r
+ jjStopStringLiteralDfa_0(9, active0, 0L);\r
+ return 10;\r
+ }\r
+ switch(curChar)\r
+ {\r
+ case 100:\r
+ return jjMoveStringLiteralDfa11_0(active0, 0x40000000000000L);\r
+ case 101:\r
+ if ((active0 & 0x2000L) != 0L)\r
+ return jjStartNfaWithStates_0(10, 13, 2);\r
+ return jjMoveStringLiteralDfa11_0(active0, 0x40000000L);\r
+ case 110:\r
+ if ((active0 & 0x10000000000L) != 0L)\r
+ return jjStartNfaWithStates_0(10, 40, 2);\r
+ break;\r
+ default :\r
+ break;\r
+ }\r
+ return jjStartNfa_0(9, active0, 0L);\r
+}\r
+private int jjMoveStringLiteralDfa11_0(long old0, long active0)\r
+{\r
+ if (((active0 &= old0)) == 0L)\r
+ return jjStartNfa_0(9, old0, 0L);\r
+ try { curChar = input_stream.readChar(); }\r
+ catch(java.io.IOException e) {\r
+ jjStopStringLiteralDfa_0(10, active0, 0L);\r
+ return 11;\r
+ }\r
+ switch(curChar)\r
+ {\r
+ case 98:\r
+ return jjMoveStringLiteralDfa12_0(active0, 0x40000000000000L);\r
+ case 100:\r
+ if ((active0 & 0x40000000L) != 0L)\r
+ return jjStartNfaWithStates_0(11, 30, 2);\r
+ break;\r
+ default :\r
+ break;\r
+ }\r
+ return jjStartNfa_0(10, active0, 0L);\r
+}\r
+private int jjMoveStringLiteralDfa12_0(long old0, long active0)\r
+{\r
+ if (((active0 &= old0)) == 0L)\r
+ return jjStartNfa_0(10, old0, 0L);\r
+ try { curChar = input_stream.readChar(); }\r
+ catch(java.io.IOException e) {\r
+ jjStopStringLiteralDfa_0(11, active0, 0L);\r
+ return 12;\r
+ }\r
+ switch(curChar)\r
+ {\r
+ case 121:\r
+ if ((active0 & 0x40000000000000L) != 0L)\r
+ return jjStartNfaWithStates_0(12, 54, 2);\r
+ break;\r
+ default :\r
+ break;\r
+ }\r
+ return jjStartNfa_0(11, active0, 0L);\r
+}\r
+private int jjStartNfaWithStates_0(int pos, int kind, int state)\r
+{\r
+ jjmatchedKind = kind;\r
+ jjmatchedPos = pos;\r
+ try { curChar = input_stream.readChar(); }\r
+ catch(java.io.IOException e) { return pos + 1; }\r
+ return jjMoveNfa_0(state, pos + 1);\r
+}\r
+static final long[] jjbitVec0 = {
+ 0x0L, 0x0L, 0xffffffffffffffffL, 0xffffffffffffffffL
+};\r
+private int jjMoveNfa_0(int startState, int curPos)\r
+{\r
+ int startsAt = 0;\r
+ jjnewStateCnt = 46;\r
+ int i = 1;\r
+ jjstateSet[0] = startState;\r
+ int kind = 0x7fffffff;\r
+ for (;;)\r
+ {\r
+ if (++jjround == 0x7fffffff)\r
+ ReInitRounds();\r
+ if (curChar < 64)\r
+ {\r
+ long l = 1L << curChar;\r
+ do\r
+ {\r
+ switch(jjstateSet[--i])\r
+ {\r
+ case 24:\r
+ if (curChar == 47)\r
+ {\r
+ if (kind > 3)\r
+ kind = 3;\r
+ jjCheckNAdd(31);\r
+ }\r
+ else if (curChar == 42)\r
+ jjCheckNAddStates(0, 2);\r
+ break;\r
+ case 46:\r
+ if ((0x3ff000000000000L & l) != 0L)\r
+ {\r
+ if (kind > 94)\r
+ kind = 94;\r
+ jjCheckNAddTwoStates(10, 11);\r
+ }\r
+ if ((0x3ff000000000000L & l) != 0L)\r
+ {\r
+ if (kind > 93)\r
+ kind = 93;\r
+ jjCheckNAddTwoStates(43, 44);\r
+ }\r
+ break;\r
+ case 9:\r
+ if ((0x3ff000000000000L & l) != 0L)\r
+ {\r
+ if (kind > 94)\r
+ kind = 94;\r
+ jjCheckNAddStates(3, 7);\r
+ }\r
+ else if (curChar == 46)\r
+ jjCheckNAdd(10);\r
+ break;\r
+ case 0:\r
+ if ((0x3ff000000000000L & l) != 0L)\r
+ {\r
+ if (kind > 92)\r
+ kind = 92;\r
+ jjCheckNAddStates(8, 17);\r
+ }\r
+ else if ((0x100002600L & l) != 0L)\r
+ {\r
+ if (kind > 1)\r
+ kind = 1;\r
+ }\r
+ else if (curChar == 46)\r
+ jjCheckNAddTwoStates(43, 10);\r
+ else if (curChar == 47)\r
+ jjAddStates(18, 19);\r
+ else if (curChar == 45)\r
+ jjAddStates(20, 21);\r
+ else if (curChar == 34)\r
+ jjCheckNAddStates(22, 24);\r
+ break;\r
+ case 2:\r
+ if ((0x3ff000000000000L & l) == 0L)\r
+ break;\r
+ if (kind > 90)\r
+ kind = 90;\r
+ jjstateSet[jjnewStateCnt++] = 2;\r
+ break;\r
+ case 3:\r
+ if (curChar == 34)\r
+ jjCheckNAddStates(22, 24);\r
+ break;\r
+ case 4:\r
+ if ((0xfffffffbfffffbffL & l) != 0L)\r
+ jjCheckNAddStates(22, 24);\r
+ break;\r
+ case 6:\r
+ if ((0xfffffffffffffbffL & l) != 0L)\r
+ jjCheckNAddStates(22, 24);\r
+ break;\r
+ case 7:\r
+ if (curChar == 34 && kind > 91)\r
+ kind = 91;\r
+ break;\r
+ case 8:\r
+ if (curChar == 45)\r
+ jjAddStates(20, 21);\r
+ break;\r
+ case 10:\r
+ if ((0x3ff000000000000L & l) == 0L)\r
+ break;\r
+ if (kind > 94)\r
+ kind = 94;\r
+ jjCheckNAddTwoStates(10, 11);\r
+ break;\r
+ case 12:\r
+ if ((0x3ff000000000000L & l) == 0L)\r
+ break;\r
+ if (kind > 94)\r
+ kind = 94;\r
+ jjstateSet[jjnewStateCnt++] = 12;\r
+ break;\r
+ case 13:\r
+ if ((0x3ff000000000000L & l) == 0L)\r
+ break;\r
+ if (kind > 94)\r
+ kind = 94;\r
+ jjCheckNAddStates(3, 7);\r
+ break;\r
+ case 14:\r
+ if ((0x3ff000000000000L & l) == 0L)\r
+ break;\r
+ if (kind > 94)\r
+ kind = 94;\r
+ jjCheckNAdd(14);\r
+ break;\r
+ case 15:\r
+ if ((0x3ff000000000000L & l) != 0L)\r
+ jjCheckNAddTwoStates(15, 16);\r
+ break;\r
+ case 17:\r
+ if ((0x3ff000000000000L & l) == 0L)\r
+ break;\r
+ if (kind > 94)\r
+ kind = 94;\r
+ jjstateSet[jjnewStateCnt++] = 17;\r
+ break;\r
+ case 18:\r
+ if ((0x3ff000000000000L & l) != 0L)\r
+ jjCheckNAddTwoStates(18, 19);\r
+ break;\r
+ case 19:\r
+ if (curChar != 46)\r
+ break;\r
+ if (kind > 94)\r
+ kind = 94;\r
+ jjCheckNAddTwoStates(20, 21);\r
+ break;\r
+ case 20:\r
+ if ((0x3ff000000000000L & l) == 0L)\r
+ break;\r
+ if (kind > 94)\r
+ kind = 94;\r
+ jjCheckNAddTwoStates(20, 21);\r
+ break;\r
+ case 22:\r
+ if ((0x3ff000000000000L & l) == 0L)\r
+ break;\r
+ if (kind > 94)\r
+ kind = 94;\r
+ jjstateSet[jjnewStateCnt++] = 22;\r
+ break;\r
+ case 23:\r
+ if (curChar == 47)\r
+ jjAddStates(18, 19);\r
+ break;\r
+ case 25:\r
+ if ((0xfffffbffffffffffL & l) != 0L)\r
+ jjCheckNAddStates(0, 2);\r
+ break;\r
+ case 26:\r
+ if (curChar == 42)\r
+ jjstateSet[jjnewStateCnt++] = 27;\r
+ break;\r
+ case 27:\r
+ if ((0xffff7fffffffffffL & l) != 0L)\r
+ jjCheckNAddStates(0, 2);\r
+ break;\r
+ case 28:\r
+ if (curChar == 47 && kind > 2)\r
+ kind = 2;\r
+ break;\r
+ case 29:\r
+ if (curChar == 42)\r
+ jjstateSet[jjnewStateCnt++] = 28;\r
+ break;\r
+ case 30:\r
+ if (curChar != 47)\r
+ break;\r
+ if (kind > 3)\r
+ kind = 3;\r
+ jjCheckNAdd(31);\r
+ break;\r
+ case 31:\r
+ if ((0xfffffffffffffbffL & l) == 0L)\r
+ break;\r
+ if (kind > 3)\r
+ kind = 3;\r
+ jjCheckNAdd(31);\r
+ break;\r
+ case 32:\r
+ if ((0x3ff000000000000L & l) == 0L)\r
+ break;\r
+ if (kind > 92)\r
+ kind = 92;\r
+ jjCheckNAddStates(8, 17);\r
+ break;\r
+ case 33:\r
+ if ((0x3ff000000000000L & l) == 0L)\r
+ break;\r
+ if (kind > 92)\r
+ kind = 92;\r
+ jjCheckNAdd(33);\r
+ break;\r
+ case 34:\r
+ if ((0x3ff000000000000L & l) != 0L)\r
+ jjCheckNAddTwoStates(34, 35);\r
+ break;\r
+ case 35:\r
+ if (curChar != 46)\r
+ break;\r
+ if (kind > 93)\r
+ kind = 93;\r
+ jjCheckNAddTwoStates(36, 37);\r
+ break;\r
+ case 36:\r
+ if ((0x3ff000000000000L & l) == 0L)\r
+ break;\r
+ if (kind > 93)\r
+ kind = 93;\r
+ jjCheckNAddTwoStates(36, 37);\r
+ break;\r
+ case 38:\r
+ if ((0x3ff000000000000L & l) == 0L)\r
+ break;\r
+ if (kind > 93)\r
+ kind = 93;\r
+ jjstateSet[jjnewStateCnt++] = 38;\r
+ break;\r
+ case 39:\r
+ if ((0x3ff000000000000L & l) != 0L)\r
+ jjCheckNAddTwoStates(39, 40);\r
+ break;\r
+ case 41:\r
+ if ((0x3ff000000000000L & l) == 0L)\r
+ break;\r
+ if (kind > 93)\r
+ kind = 93;\r
+ jjstateSet[jjnewStateCnt++] = 41;\r
+ break;\r
+ case 42:\r
+ if (curChar == 46)\r
+ jjCheckNAddTwoStates(43, 10);\r
+ break;\r
+ case 43:\r
+ if ((0x3ff000000000000L & l) == 0L)\r
+ break;\r
+ if (kind > 93)\r
+ kind = 93;\r
+ jjCheckNAddTwoStates(43, 44);\r
+ break;\r
+ case 45:\r
+ if ((0x3ff000000000000L & l) == 0L)\r
+ break;\r
+ if (kind > 93)\r
+ kind = 93;\r
+ jjstateSet[jjnewStateCnt++] = 45;\r
+ break;\r
+ default : break;\r
+ }\r
+ } while(i != startsAt);\r
+ }\r
+ else if (curChar < 128)\r
+ {\r
+ long l = 1L << (curChar & 077);\r
+ do\r
+ {\r
+ switch(jjstateSet[--i])\r
+ {\r
+ case 0:\r
+ case 2:\r
+ if ((0x7fffffe87fffffeL & l) == 0L)\r
+ break;\r
+ if (kind > 90)\r
+ kind = 90;\r
+ jjCheckNAdd(2);\r
+ break;\r
+ case 4:\r
+ if ((0xffffffffefffffffL & l) != 0L)\r
+ jjCheckNAddStates(22, 24);\r
+ break;\r
+ case 5:\r
+ if (curChar == 92)\r
+ jjstateSet[jjnewStateCnt++] = 6;\r
+ break;\r
+ case 6:\r
+ jjCheckNAddStates(22, 24);\r
+ break;\r
+ case 11:\r
+ if ((0x2000000020L & l) != 0L)\r
+ jjstateSet[jjnewStateCnt++] = 12;\r
+ break;\r
+ case 16:\r
+ if ((0x2000000020L & l) != 0L)\r
+ jjstateSet[jjnewStateCnt++] = 17;\r
+ break;\r
+ case 21:\r
+ if ((0x2000000020L & l) != 0L)\r
+ jjstateSet[jjnewStateCnt++] = 22;\r
+ break;\r
+ case 25:\r
+ case 27:\r
+ jjCheckNAddStates(0, 2);\r
+ break;\r
+ case 31:\r
+ if (kind > 3)\r
+ kind = 3;\r
+ jjstateSet[jjnewStateCnt++] = 31;\r
+ break;\r
+ case 37:\r
+ if ((0x2000000020L & l) != 0L)\r
+ jjstateSet[jjnewStateCnt++] = 38;\r
+ break;\r
+ case 40:\r
+ if ((0x2000000020L & l) != 0L)\r
+ jjstateSet[jjnewStateCnt++] = 41;\r
+ break;\r
+ case 44:\r
+ if ((0x2000000020L & l) != 0L)\r
+ jjstateSet[jjnewStateCnt++] = 45;\r
+ break;\r
+ default : break;\r
+ }\r
+ } while(i != startsAt);\r
+ }\r
+ else\r
+ {\r
+ int i2 = (curChar & 0xff) >> 6;\r
+ long l2 = 1L << (curChar & 077);\r
+ do\r
+ {\r
+ switch(jjstateSet[--i])\r
+ {\r
+ case 4:\r
+ case 6:\r
+ if ((jjbitVec0[i2] & l2) != 0L)\r
+ jjCheckNAddStates(22, 24);\r
+ break;\r
+ case 25:\r
+ case 27:\r
+ if ((jjbitVec0[i2] & l2) != 0L)\r
+ jjCheckNAddStates(0, 2);\r
+ break;\r
+ case 31:\r
+ if ((jjbitVec0[i2] & l2) == 0L)\r
+ break;\r
+ if (kind > 3)\r
+ kind = 3;\r
+ jjstateSet[jjnewStateCnt++] = 31;\r
+ break;\r
+ default : break;\r
+ }\r
+ } while(i != startsAt);\r
+ }\r
+ if (kind != 0x7fffffff)\r
+ {\r
+ jjmatchedKind = kind;\r
+ jjmatchedPos = curPos;\r
+ kind = 0x7fffffff;\r
+ }\r
+ ++curPos;\r
+ if ((i = jjnewStateCnt) == (startsAt = 46 - (jjnewStateCnt = startsAt)))\r
+ return curPos;\r
+ try { curChar = input_stream.readChar(); }\r
+ catch(java.io.IOException e) { return curPos; }\r
+ }\r
+}\r
+static final int[] jjnextStates = {
+ 25, 26, 29, 14, 15, 16, 18, 19, 33, 34, 35, 39, 40, 14, 15, 16,
+ 18, 19, 24, 30, 9, 13, 4, 5, 7,
+};\r
+\r
+/** Token literal values. */\r
+public static final String[] jjstrLiteralImages = {\r
+"", null, null, null, "\141\154\147\157\162\151\164\150\155", \r
+"\144\151\163\143\162\145\164\145", "\146\141\154\163\145", "\155\157\144\145\154", \r
+"\162\145\144\145\143\154\141\162\145", "\141\156\144", "\145\141\143\150", "\146\151\156\141\154", "\156\157\164", \r
+"\162\145\160\154\141\143\145\141\142\154\145", "\141\156\156\157\164\141\164\151\157\156", "\145\154\163\145", \r
+"\146\154\157\167", "\157\160\145\162\141\164\157\162", "\162\145\164\165\162\156", \r
+"\141\163\163\145\162\164", "\145\154\163\145\151\146", "\146\157\162", "\157\162", \r
+"\163\164\162\145\141\155", "\142\154\157\143\153", "\145\154\163\145\167\150\145\156", \r
+"\146\165\156\143\164\151\157\156", "\157\165\164\145\162", "\164\150\145\156", "\142\162\145\141\153", \r
+"\145\156\143\141\160\163\165\154\141\164\145\144", "\151\146", "\157\165\164\160\165\164", "\164\162\165\145", \r
+"\143\154\141\163\163", "\145\156\144", "\151\155\160\157\162\164", "\160\141\143\153\141\147\145", \r
+"\164\171\160\145", "\143\157\156\156\145\143\164", \r
+"\145\156\165\155\145\162\141\164\151\157\156", "\151\156", "\160\141\162\141\155\145\164\145\162", "\167\150\145\156", \r
+"\143\157\156\156\145\143\164\157\162", "\145\161\165\141\164\151\157\156", "\151\156\151\164\151\141\154", \r
+"\160\141\162\164\151\141\154", "\167\150\151\154\145", "\143\157\156\163\164\141\156\164", \r
+"\145\170\160\141\156\144\141\142\154\145", "\151\156\156\145\162", "\160\162\157\164\145\143\164\145\144", \r
+"\167\151\164\150\151\156", "\143\157\156\163\164\162\141\151\156\145\144\142\171", \r
+"\145\170\164\145\156\144\163", "\151\156\160\165\164", "\160\165\142\154\151\143", "\144\145\162", \r
+"\145\170\164\145\162\156\141\154", "\154\157\157\160", "\162\145\143\157\162\144", "\50", "\51", "\173", "\175", \r
+"\133", "\135", "\56", "\72", "\73", "\54", "\74", "\74\75", "\76", "\76\75", \r
+"\75\75", "\74\76", "\53", "\55", "\56\53", "\56\55", "\52", "\57", "\56\52", "\56\57", \r
+"\136", "\56\136", "\75", "\72\75", null, null, null, null, null, };\r
+\r
+/** Lexer state names. */\r
+public static final String[] lexStateNames = {\r
+ "DEFAULT",\r
+};\r
+static final long[] jjtoToken = {
+ 0xfffffffffffffff1L, 0x7fffffffL,
+};\r
+static final long[] jjtoSkip = {
+ 0xeL, 0x0L,
+};\r
+protected SimpleCharStream input_stream;\r
+private final int[] jjrounds = new int[46];\r
+private final int[] jjstateSet = new int[92];\r
+private final StringBuilder jjimage = new StringBuilder();\r
+private StringBuilder image = jjimage;\r
+private int jjimageLen;\r
+private int lengthOfMatch;\r
+protected char curChar;\r
+/** Constructor. */\r
+public TableParserTokenManager(SimpleCharStream stream){\r
+ if (SimpleCharStream.staticFlag)\r
+ throw new Error("ERROR: Cannot use a static CharStream class with a non-static lexical analyzer.");\r
+ input_stream = stream;\r
+}\r
+\r
+/** Constructor. */\r
+public TableParserTokenManager(SimpleCharStream stream, int lexState){\r
+ this(stream);\r
+ SwitchTo(lexState);\r
+}\r
+\r
+/** Reinitialise parser. */\r
+public void ReInit(SimpleCharStream stream)\r
+{\r
+ jjmatchedPos = jjnewStateCnt = 0;\r
+ curLexState = defaultLexState;\r
+ input_stream = stream;\r
+ ReInitRounds();\r
+}\r
+private void ReInitRounds()\r
+{\r
+ int i;\r
+ jjround = 0x80000001;\r
+ for (i = 46; i-- > 0;)\r
+ jjrounds[i] = 0x80000000;\r
+}\r
+\r
+/** Reinitialise parser. */\r
+public void ReInit(SimpleCharStream stream, int lexState)\r
+{\r
+ ReInit(stream);\r
+ SwitchTo(lexState);\r
+}\r
+\r
+/** Switch to specified lex state. */\r
+public void SwitchTo(int lexState)\r
+{\r
+ if (lexState >= 1 || lexState < 0)\r
+ throw new TokenMgrError("Error: Ignoring invalid lexical state : " + lexState + ". State unchanged.", TokenMgrError.INVALID_LEXICAL_STATE);\r
+ else\r
+ curLexState = lexState;\r
+}\r
+\r
+protected Token jjFillToken()\r
+{\r
+ final Token t;\r
+ final String curTokenImage;\r
+ final int beginLine;\r
+ final int endLine;\r
+ final int beginColumn;\r
+ final int endColumn;\r
+ String im = jjstrLiteralImages[jjmatchedKind];\r
+ curTokenImage = (im == null) ? input_stream.GetImage() : im;\r
+ beginLine = input_stream.getBeginLine();\r
+ beginColumn = input_stream.getBeginColumn();\r
+ endLine = input_stream.getEndLine();\r
+ endColumn = input_stream.getEndColumn();\r
+ t = Token.newToken(jjmatchedKind, curTokenImage);\r
+\r
+ t.beginLine = beginLine;\r
+ t.endLine = endLine;\r
+ t.beginColumn = beginColumn;\r
+ t.endColumn = endColumn;\r
+\r
+ return t;\r
+}\r
+\r
+int curLexState = 0;\r
+int defaultLexState = 0;\r
+int jjnewStateCnt;\r
+int jjround;\r
+int jjmatchedPos;\r
+int jjmatchedKind;\r
+\r
+/** Get the next Token. */\r
+public Token getNextToken() \r
+{\r
+ Token matchedToken;\r
+ int curPos = 0;\r
+\r
+ EOFLoop :
+ for (;;)\r
+ {\r
+ try\r
+ {\r
+ curChar = input_stream.BeginToken();\r
+ }\r
+ catch(java.io.IOException e)\r
+ {\r
+ jjmatchedKind = 0;\r
+ matchedToken = jjFillToken();\r
+ return matchedToken;\r
+ }\r
+ image = jjimage;\r
+ image.setLength(0);\r
+ jjimageLen = 0;\r
+\r
+ jjmatchedKind = 0x7fffffff;\r
+ jjmatchedPos = 0;\r
+ curPos = jjMoveStringLiteralDfa0_0();\r
+ if (jjmatchedKind != 0x7fffffff)\r
+ {\r
+ if (jjmatchedPos + 1 < curPos)\r
+ input_stream.backup(curPos - jjmatchedPos - 1);\r
+ if ((jjtoToken[jjmatchedKind >> 6] & (1L << (jjmatchedKind & 077))) != 0L)\r
+ {\r
+ matchedToken = jjFillToken();\r
+ TokenLexicalActions(matchedToken);\r
+ return matchedToken;\r
+ }\r
+ else\r
+ {\r
+ continue EOFLoop;\r
+ }\r
+ }\r
+ int error_line = input_stream.getEndLine();\r
+ int error_column = input_stream.getEndColumn();\r
+ String error_after = null;\r
+ boolean EOFSeen = false;\r
+ try { input_stream.readChar(); input_stream.backup(1); }\r
+ catch (java.io.IOException e1) {\r
+ EOFSeen = true;\r
+ error_after = curPos <= 1 ? "" : input_stream.GetImage();\r
+ if (curChar == '\n' || curChar == '\r') {\r
+ error_line++;\r
+ error_column = 0;\r
+ }\r
+ else\r
+ error_column++;\r
+ }\r
+ if (!EOFSeen) {\r
+ input_stream.backup(1);\r
+ error_after = curPos <= 1 ? "" : input_stream.GetImage();\r
+ }\r
+ throw new TokenMgrError(EOFSeen, curLexState, error_line, error_column, error_after, curChar, TokenMgrError.LEXICAL_ERROR);\r
+ }\r
+}\r
+\r
+void TokenLexicalActions(Token matchedToken)\r
+{\r
+ switch(jjmatchedKind)\r
+ {\r
+ case 91 :\r
+ image.append(input_stream.GetSuffix(jjimageLen + (lengthOfMatch = jjmatchedPos + 1)));\r
+ matchedToken.image = matchedToken.image.substring(1,matchedToken.image.length()-1);\r
+ break;\r
+ default :\r
+ break;\r
+ }\r
+}\r
+private void jjCheckNAdd(int state)\r
+{\r
+ if (jjrounds[state] != jjround)\r
+ {\r
+ jjstateSet[jjnewStateCnt++] = state;\r
+ jjrounds[state] = jjround;\r
+ }\r
+}\r
+private void jjAddStates(int start, int end)\r
+{\r
+ do {\r
+ jjstateSet[jjnewStateCnt++] = jjnextStates[start];\r
+ } while (start++ != end);\r
+}\r
+private void jjCheckNAddTwoStates(int state1, int state2)\r
+{\r
+ jjCheckNAdd(state1);\r
+ jjCheckNAdd(state2);\r
+}\r
+\r
+private void jjCheckNAddStates(int start, int end)\r
+{\r
+ do {\r
+ jjCheckNAdd(jjnextStates[start]);\r
+ } while (start++ != end);\r
+}\r
+\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2010 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+/* Generated By:JavaCC: Do not edit this line. Token.java Version 5.0 */\r
+/* JavaCCOptions:TOKEN_EXTENDS=,KEEP_LINE_COL=null,SUPPORT_CLASS_VISIBILITY_PUBLIC=true */\r
+package org.simantics.sysdyn.tableParser;\r
+\r
+/**\r
+ * Describes the input token stream.\r
+ */\r
+\r
+public class Token implements java.io.Serializable {\r
+\r
+ /**\r
+ * The version identifier for this Serializable class.\r
+ * Increment only if the <i>serialized</i> form of the\r
+ * class changes.\r
+ */\r
+ private static final long serialVersionUID = 1L;\r
+\r
+ /**\r
+ * An integer that describes the kind of this token. This numbering\r
+ * system is determined by JavaCCParser, and a table of these numbers is\r
+ * stored in the file ...Constants.java.\r
+ */\r
+ public int kind;\r
+\r
+ /** The line number of the first character of this Token. */\r
+ public int beginLine;\r
+ /** The column number of the first character of this Token. */\r
+ public int beginColumn;\r
+ /** The line number of the last character of this Token. */\r
+ public int endLine;\r
+ /** The column number of the last character of this Token. */\r
+ public int endColumn;\r
+\r
+ /**\r
+ * The string image of the token.\r
+ */\r
+ public String image;\r
+\r
+ /**\r
+ * A reference to the next regular (non-special) token from the input\r
+ * stream. If this is the last token from the input stream, or if the\r
+ * token manager has not read tokens beyond this one, this field is\r
+ * set to null. This is true only if this token is also a regular\r
+ * token. Otherwise, see below for a description of the contents of\r
+ * this field.\r
+ */\r
+ public Token next;\r
+\r
+ /**\r
+ * This field is used to access special tokens that occur prior to this\r
+ * token, but after the immediately preceding regular (non-special) token.\r
+ * If there are no such special tokens, this field is set to null.\r
+ * When there are more than one such special token, this field refers\r
+ * to the last of these special tokens, which in turn refers to the next\r
+ * previous special token through its specialToken field, and so on\r
+ * until the first special token (whose specialToken field is null).\r
+ * The next fields of special tokens refer to other special tokens that\r
+ * immediately follow it (without an intervening regular token). If there\r
+ * is no such token, this field is null.\r
+ */\r
+ public Token specialToken;\r
+\r
+ /**\r
+ * An optional attribute value of the Token.\r
+ * Tokens which are not used as syntactic sugar will often contain\r
+ * meaningful values that will be used later on by the compiler or\r
+ * interpreter. This attribute value is often different from the image.\r
+ * Any subclass of Token that actually wants to return a non-null value can\r
+ * override this method as appropriate.\r
+ */\r
+ public Object getValue() {\r
+ return null;\r
+ }\r
+\r
+ /**\r
+ * No-argument constructor\r
+ */\r
+ public Token() {}\r
+\r
+ /**\r
+ * Constructs a new token for the specified Image.\r
+ */\r
+ public Token(int kind)\r
+ {\r
+ this(kind, null);\r
+ }\r
+\r
+ /**\r
+ * Constructs a new token for the specified Image and Kind.\r
+ */\r
+ public Token(int kind, String image)\r
+ {\r
+ this.kind = kind;\r
+ this.image = image;\r
+ }\r
+\r
+ /**\r
+ * Returns the image.\r
+ */\r
+ public String toString()\r
+ {\r
+ return image;\r
+ }\r
+\r
+ /**\r
+ * Returns a new Token object, by default. However, if you want, you\r
+ * can create and return subclass objects based on the value of ofKind.\r
+ * Simply add the cases to the switch for all those special cases.\r
+ * For example, if you have a subclass of Token called IDToken that\r
+ * you want to create if ofKind is ID, simply add something like :\r
+ *\r
+ * case MyParserConstants.ID : return new IDToken(ofKind, image);\r
+ *\r
+ * to the following switch statement. Then you can cast matchedToken\r
+ * variable to the appropriate type and use sit in your lexical actions.\r
+ */\r
+ public static Token newToken(int ofKind, String image)\r
+ {\r
+ switch(ofKind)\r
+ {\r
+ default : return new Token(ofKind, image);\r
+ }\r
+ }\r
+\r
+ public static Token newToken(int ofKind)\r
+ {\r
+ return newToken(ofKind, null);\r
+ }\r
+\r
+}\r
+/* JavaCC - OriginalChecksum=d63d0e2011f8ce7fbf4f8ee6fd4e3986 (do not edit this line) */\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2010 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+/* Generated By:JavaCC: Do not edit this line. TokenMgrError.java Version 5.0 */\r
+/* JavaCCOptions: */\r
+package org.simantics.sysdyn.tableParser;\r
+\r
+/** Token Manager Error. */\r
+public class TokenMgrError extends Error\r
+{\r
+\r
+ /**\r
+ * The version identifier for this Serializable class.\r
+ * Increment only if the <i>serialized</i> form of the\r
+ * class changes.\r
+ */\r
+ private static final long serialVersionUID = 1L;\r
+\r
+ /*\r
+ * Ordinals for various reasons why an Error of this type can be thrown.\r
+ */\r
+\r
+ /**\r
+ * Lexical error occurred.\r
+ */\r
+ static final int LEXICAL_ERROR = 0;\r
+\r
+ /**\r
+ * An attempt was made to create a second instance of a static token manager.\r
+ */\r
+ static final int STATIC_LEXER_ERROR = 1;\r
+\r
+ /**\r
+ * Tried to change to an invalid lexical state.\r
+ */\r
+ static final int INVALID_LEXICAL_STATE = 2;\r
+\r
+ /**\r
+ * Detected (and bailed out of) an infinite loop in the token manager.\r
+ */\r
+ static final int LOOP_DETECTED = 3;\r
+\r
+ /**\r
+ * Indicates the reason why the exception is thrown. It will have\r
+ * one of the above 4 values.\r
+ */\r
+ int errorCode;\r
+\r
+ /**\r
+ * Replaces unprintable characters by their escaped (or unicode escaped)\r
+ * equivalents in the given string\r
+ */\r
+ protected static final String addEscapes(String str) {\r
+ StringBuffer retval = new StringBuffer();\r
+ char ch;\r
+ for (int i = 0; i < str.length(); i++) {\r
+ switch (str.charAt(i))\r
+ {\r
+ case 0 :\r
+ continue;\r
+ case '\b':\r
+ retval.append("\\b");\r
+ continue;\r
+ case '\t':\r
+ retval.append("\\t");\r
+ continue;\r
+ case '\n':\r
+ retval.append("\\n");\r
+ continue;\r
+ case '\f':\r
+ retval.append("\\f");\r
+ continue;\r
+ case '\r':\r
+ retval.append("\\r");\r
+ continue;\r
+ case '\"':\r
+ retval.append("\\\"");\r
+ continue;\r
+ case '\'':\r
+ retval.append("\\\'");\r
+ continue;\r
+ case '\\':\r
+ retval.append("\\\\");\r
+ continue;\r
+ default:\r
+ if ((ch = str.charAt(i)) < 0x20 || ch > 0x7e) {\r
+ String s = "0000" + Integer.toString(ch, 16);\r
+ retval.append("\\u" + s.substring(s.length() - 4, s.length()));\r
+ } else {\r
+ retval.append(ch);\r
+ }\r
+ continue;\r
+ }\r
+ }\r
+ return retval.toString();\r
+ }\r
+\r
+ /**\r
+ * Returns a detailed message for the Error when it is thrown by the\r
+ * token manager to indicate a lexical error.\r
+ * Parameters :\r
+ * EOFSeen : indicates if EOF caused the lexical error\r
+ * curLexState : lexical state in which this error occurred\r
+ * errorLine : line number when the error occurred\r
+ * errorColumn : column number when the error occurred\r
+ * errorAfter : prefix that was seen before this error occurred\r
+ * curchar : the offending character\r
+ * Note: You can customize the lexical error message by modifying this method.\r
+ */\r
+ protected static String LexicalError(boolean EOFSeen, int lexState, int errorLine, int errorColumn, String errorAfter, char curChar) {\r
+ return("Lexical error at line " +\r
+ errorLine + ", column " +\r
+ errorColumn + ". Encountered: " +\r
+ (EOFSeen ? "<EOF> " : ("\"" + addEscapes(String.valueOf(curChar)) + "\"") + " (" + (int)curChar + "), ") +\r
+ "after : \"" + addEscapes(errorAfter) + "\"");\r
+ }\r
+\r
+ /**\r
+ * You can also modify the body of this method to customize your error messages.\r
+ * For example, cases like LOOP_DETECTED and INVALID_LEXICAL_STATE are not\r
+ * of end-users concern, so you can return something like :\r
+ *\r
+ * "Internal Error : Please file a bug report .... "\r
+ *\r
+ * from this method for such cases in the release version of your parser.\r
+ */\r
+ public String getMessage() {\r
+ return super.getMessage();\r
+ }\r
+\r
+ /*\r
+ * Constructors of various flavors follow.\r
+ */\r
+\r
+ /** No arg constructor. */\r
+ public TokenMgrError() {\r
+ }\r
+\r
+ /** Constructor with message and reason. */\r
+ public TokenMgrError(String message, int reason) {\r
+ super(message);\r
+ errorCode = reason;\r
+ }\r
+\r
+ /** Full Constructor. */\r
+ public TokenMgrError(boolean EOFSeen, int lexState, int errorLine, int errorColumn, String errorAfter, char curChar, int reason) {\r
+ this(LexicalError(EOFSeen, lexState, errorLine, errorColumn, errorAfter, curChar), reason);\r
+ }\r
+}\r
+/* JavaCC - OriginalChecksum=abb0cd060e347479552118d1e61a7e46 (do not edit this line) */\r
--- /dev/null
+syntax: regexp\r
+^org/\r
+^c_sharp/\r
+^layer0c.bin\r
+^layer0c.txt\r
+^directories.log\r
+\r
+syntax: glob\r
+*.svn/*
\ No newline at end of file
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>\r
+<projectDescription>\r
+ <name>sysdyn_ontologies</name>\r
+ <comment></comment>\r
+ <projects>\r
+ </projects>\r
+ <buildSpec>\r
+ </buildSpec>\r
+ <natures>\r
+ </natures>\r
+</projectDescription>\r
--- /dev/null
+../foundation_ontologies\r
+../2d_ontologies\r
+../modeling_ontologies\r
--- /dev/null
+@rem ***************************************************************************\r
+@rem Copyright (c) 2007, 2010 Association for Decentralized Information Management\r
+@rem in Industry THTH ry.\r
+@rem All rights reserved. This program and the accompanying materials\r
+@rem are made available under the terms of the Eclipse Public License v1.0\r
+@rem which accompanies this distribution, and is available at\r
+@rem http://www.eclipse.org/legal/epl-v10.html\r
+@rem\r
+@rem Contributors:\r
+@rem VTT Technical Research Centre of Finland - initial API and implementation\r
+@rem ***************************************************************************\r
+@echo off\r
+call "%~dp0..\org.simantics.db.build\build" "%~dp0" ..\foundation_ontologies\foundation.graph ..\sysdyn_ontologies\sysdyn.graph ..\modeling_ontologies\modeling.graph ..\modeling_ontologies\devs.graph ..\webmon_ontologies\webmon.graph ..\modeling_ontologies\spreadsheet.graph
\ No newline at end of file
--- /dev/null
+copy=org/simantics/sysdyn=../org.simantics.sysdyn/src\r
--- /dev/null
+%import "layer0.graph" L0\r
+%import "diagram2.graph" DIA\r
+%import "g2d.graph" G2D\r
+%import "structural2.graph" ST\r
+%import "modeling.graph" MOD\r
+%import "project.graph" PROJ\r
+%import "simulation.graph" SIMU\r
+%import "workbench.graph" WORKBENCH\r
+\r
+%deflib L0.Type Sysdyn\r
+%deflib L0.Relation Sysdyn\r
+%deflib DIA.ElementClass Symbols\r
+\r
+%define assert($pred,$obj)\r
+ $subject\r
+ L0.Asserts _ : L0.Assertion\r
+ L0.HasPredicate $pred\r
+ L0.HasObject $obj\r
+ \r
+%define tag($pred)\r
+ $subject\r
+ $pred $subject\r
+\r
+%define symmetric()\r
+ $subject\r
+ $layer0.InverseOf $subject\r
+\r
+%define defSymbol($label, $componentType)\r
+ $subject <T DIA.Element\r
+ L0.PartOf Sysdyn\r
+ MOD.SymbolToComponentType $componentType \r
+ L0.HasLabel $label : L0.String\r
+\r
+%define terminal($parent, $relation)\r
+ $subject\r
+ DIA.HasConnectionVariable _ : ST.ConnectionVariable\r
+ ST.Binds $relation \r
+ ST.IsParameterOf $parent\r
+\r
+######################################################################\r
+# Defines ontology and attaches it to SimanticsDomain\r
+######################################################################\r
+\r
+Sysdyn @ "Sysdyn-1.0" : L0.Ontology\r
+ L0.PartOf L0.SimanticsDomain\r
+ L0.HasVersion "1.0" : L0.Version\r
+ L0.HasResourceClass "org.simantics.sysdyn.SysdynResource" : L0.String\r
+ L0.HasPackageName "sysdyn" : L0.String \r
+ L0.ConsistsOf\r
+ Symbols : L0.Library\r
+\r
+SysdynProject : PROJ.Feature\r
+ tag(PROJ.LifecycleFeature)\r
+ L0.HasLabel "System Dynamics Project" : L0.String\r
+ L0.HasDescription """System dynamics modelling project. Create system dynamics models and simulate them with OpenModelica.""" : L0.String\r
+ L0.PartOf Sysdyn\r
+ L0.PartOf PROJ.PublishedProjectFeatures\r
+ PROJ.RequiresFeature\r
+ ImportedOntologies : PROJ.OntologyRequirementValidationFeature\r
+ L0.HasDescription "Specifies the ontologies required by a Sysdyn project." : L0.String\r
+ PROJ.RequiresNamespace\r
+ "http://www.simantics.org/Sysdyn-1.0" : L0.URI\r
+ WORKBENCH.SymbolManager\r
+ PROJ.ExperimentControl\r
+ SysdynModelManager : PROJ.Feature\r
+ L0.PartOf Sysdyn\r
+ L0.HasLabel "Sysdyn Model Manager" : L0.String\r
+ L0.HasDescription "Sysdyn Model Manager." : L0.String\r
+ PROJ.RequiresFeature PROJ.ExperimentControl\r
+\r
+\r
+SysdynModuleTestProject : PROJ.Project\r
+ PROJ.HasFeature SysdynProject\r
+ L0.PartOf L0.Projects\r
+\r
+######################################################################\r
+# Model\r
+###################################################################### \r
+\r
+SysdynModel <T SIMU.Model\r
+ L0.PartOf Sysdyn\r
+ [SIMU.HasConfiguration all Configuration]\r
+ [HasStartTime card "1"]\r
+ [HasStopTime card "1"]\r
+ [HasTolerance card "0..1"]\r
+\r
+######################################################################\r
+# Configuration\r
+######################################################################\r
+\r
+Sysdyn \r
+ L0.ConsistsOf\r
+ Symbols : L0.Library\r
+ SysdynConnectionType : ST.ConnectionType\r
+\r
+DiagramToCompositeMapping <T L0.Trigger\r
+ L0.PartOf Sysdyn\r
+ \r
+ConfigurationDiagram <T DIA.Diagram\r
+ L0.PartOf Sysdyn\r
+ assert(ST.HasModelingRules, SysdynDiagramModelingRules) \r
+ DIA.HasSymbolContribution _ : DIA.BasicSymbolContribution\r
+ DIA.BasicSymbolContributionHasSymbolLibrary\r
+ BasicSymbolLibrary\r
+\r
+SysdynDiagramModelingRules : MOD.MappedModelingRules\r
+ MOD.HasBaseRules ST.StandardModelingRules\r
+ \r
+SymbolReferences : DIA.SymbolReferenceLibrary\r
+ L0.PartOf Sysdyn\r
+ L0.ConsistsOf\r
+ BasicSymbolLibrary @ "Basic Symbols" : DIA.SymbolReferenceLibrary\r
+\r
+Configuration <T ST.Composite\r
+ [L0.ConsistsOf all (Variable or Dependency or Module)]\r
+ \r
+HasStartTime <R L0.HasProperty\r
+ L0.HasRange L0.Double \r
+\r
+HasStopTime <R L0.HasProperty\r
+ L0.HasRange L0.Double\r
+ \r
+HasTolerance <R L0.HasProperty\r
+ L0.HasRange L0.Double \r
+\r
+HistoryRealization <T L0.Realization\r
+DefaultRealization <T L0.Realization\r
+\r
+######################################################################\r
+# Variables\r
+######################################################################\r
+\r
+Variable <T ST.Component \r
+ [L0.HasType card "1"]\r
+ [HasX card "1"]\r
+ [HasY card "1"]\r
+ \r
+HasX <R L0.HasProperty : L0.FunctionalRelation\r
+ L0.HasRange L0.Double\r
+HasY <R L0.HasProperty : L0.FunctionalRelation\r
+ L0.HasRange L0.Double\r
+HasExpression <R L0.IsRelatedTo : L0.FunctionalRelation\r
+ L0.HasRange Expression\r
+\r
+\r
+HasUnit <R L0.HasProperty\r
+ L0.HasRange L0.String\r
+ \r
+HasRangeStart <R L0.HasProperty\r
+ L0.HasRange L0.Double \r
+ \r
+HasRangeEnd <R L0.HasProperty\r
+ L0.HasRange L0.Double \r
+ \r
+HasRangeStep <R L0.HasProperty\r
+ L0.HasRange L0.Double \r
+\r
+IndependentVariable <T Variable\r
+ [HasUnit card "0..1"]\r
+ [HasExpression card "0..1"] \r
+ [HasRangeStart card "0..1"]\r
+ [HasRangeEnd card "0..1"]\r
+ [HasRangeStep card "0..1"]\r
+ [L0.HasDescription card "0..1"]\r
+\r
+Auxiliary <T IndependentVariable\r
+ L0.Asserts _ : L0.Assertion\r
+ L0.HasPredicate L0.HasType\r
+ L0.HasObject "Real" : L0.String\r
+\r
+Valve <T IndependentVariable\r
+ L0.Asserts _ : L0.Assertion\r
+ L0.HasPredicate L0.HasType\r
+ L0.HasObject "Real" : L0.String\r
+ \r
+Stock <T IndependentVariable\r
+ L0.Asserts _ : L0.Assertion\r
+ L0.HasPredicate L0.HasType\r
+ L0.HasObject "Real" : L0.String\r
+\r
+Cloud <T Variable\r
+\r
+Input <T Variable\r
+ [HasDefaultInputValue card "0..1"]\r
+ [L0.HasDescription card "0..1"]\r
+ [HasUnit card "0..1"] \r
+ L0.Asserts _ : L0.Assertion\r
+ L0.HasPredicate HasDefaultInputValue\r
+ L0.HasObject "0" : L0.Double\r
+ L0.Asserts _ : L0.Assertion\r
+ L0.HasPredicate L0.HasType\r
+ L0.HasObject "Real" : L0.String\r
+\r
+######################################################################\r
+# Modules\r
+######################################################################\r
+\r
+Module <T ST.Component\r
+ [ST.IsDefinedBy all Configuration]\r
+ [L0.HasLabel card "1"]\r
+ \r
+ModuleSymbol <T DIA.FontProvider <T DIA.ColorProvider\r
+ defSymbol("ModuleSymbol", Module)\r
+ ST.IsDefinedBy %list : DIA.Composite <R L0.HasNext\r
+ _ : SysdynTerminal\r
+ terminal(ModuleSymbol, IsHeadOfTerminal)\r
+ _ : SysdynTerminal\r
+ terminal(ModuleSymbol, IsTailOfTerminal)\r
+\r
+IsOutput <R L0.IsRelatedTo : L0.Tag\r
+ symmetric()\r
+\r
+######################################################################\r
+# Connections and Relations\r
+######################################################################\r
+\r
+IsTailOf <R ST.IsConnectedTo\r
+ L0.HasDomain Variable\r
+ L0.HasRange Dependency\r
+ L0.InverseOf HasTail \r
+ ST.AllowsConnectionType SysdynConnectionType\r
+ ST.HasAttachmentRelation DIA.HasPlainConnector\r
+IsHeadOf <R ST.IsConnectedTo\r
+ L0.HasDomain Variable\r
+ L0.HasRange Dependency\r
+ L0.InverseOf HasHead\r
+ ST.AllowsConnectionType SysdynConnectionType\r
+ ST.HasAttachmentRelation DIA.HasArrowConnector\r
+\r
+Dependency <T ST.Connection\r
+ [angle card "1"]\r
+ [HasHead card "1"]\r
+ [HasTail card "1"]\r
+ [RefersTo card "0..1"]\r
+ \r
+Flow <T ST.Connection\r
+ [HasHead card "1"]\r
+ [HasTail card "1"]\r
+\r
+RefersTo <R L0.IsRelatedTo : L0.FunctionalRelation\r
+ L0.HasDomain [Variable]\r
+ L0.HasRange [Variable]\r
+\r
+\r
+######################################################################\r
+# Expression\r
+######################################################################\r
+\r
+HasEquation <R L0.HasProperty\r
+ L0.HasRange L0.String \r
+\r
+HasInitialEquation <R L0.HasProperty\r
+ L0.HasRange L0.String\r
+\r
+HasLookup <R L0.HasProperty\r
+ L0.HasRange L0.String \r
+\r
+HasMinX <R L0.HasProperty\r
+ L0.HasRange L0.Double\r
+\r
+HasMaxX <R L0.HasProperty\r
+ L0.HasRange L0.Double\r
+\r
+HasMinY <R L0.HasProperty\r
+ L0.HasRange L0.Double\r
+\r
+HasMaxY <R L0.HasProperty\r
+ L0.HasRange L0.Double\r
+\r
+Expression <T L0.Entity\r
+\r
+NormalExpression <T Expression\r
+ [HasEquation card "1"] \r
+\r
+ParameterExpression <T Expression\r
+ [HasEquation card "1"] \r
+ \r
+ConstantExpression <T Expression\r
+ [HasEquation card "1"] \r
+\r
+DelayExpression <T Expression\r
+ [HasEquation card "1"] \r
+\r
+StockExpression <T Expression\r
+ [HasInitialEquation card "1"]\r
+\r
+LookupExpression <T Expression\r
+ [HasLookup card "1"] \r
+\r
+WithLookupExpression <T Expression\r
+ [HasLookup card "1"] \r
+ [HasEquation card "1"] \r
+ [HasMinX card "1"]\r
+ [HasMaxX card "1"]\r
+ [HasMinY card "1"]\r
+ [HasMaxY card "1"]\r
+\r
+HasDefaultInputValue <R L0.HasProperty : L0.FunctionalRelation\r
+ L0.HasRange L0.Double\r
+\r
+######################################################################\r
+# Experiments\r
+######################################################################\r
+\r
+Experiment <T SIMU.Experiment\r
+ [HasResult]\r
+\r
+\r
+BasicExperiment <T Experiment\r
+\r
+GameExperiment <T Experiment\r
+\r
+SimulateOnChangeExperiment <T Experiment\r
+\r
+HasResult <R L0.IsRelatedTo\r
+ L0.HasRange [Result]\r
+\r
+######################################################################\r
+# Results\r
+######################################################################\r
+\r
+Result <T L0.Entity\r
+ SIMU.IsActive\r
+ [L0.HasName card "1"]\r
+ [HasParameterFile card "0..1"]\r
+ [HasResultFile card "0..1"]\r
+\r
+HasParameterFile <R L0.HasProperty\r
+ L0.HasRange L0.String \r
+\r
+HasResultFile <R L0.HasProperty\r
+ L0.HasRange L0.String\r
+\r
+######################################################################\r
+# Macros for component types\r
+######################################################################\r
+\r
+%define def()\r
+ $subject <T ST.Component\r
+ L0.PartOf Sysdyn\r
+\r
+%define connection($relation)\r
+ $subject\r
+ ST.HasParameter _ : ST.ConnectionVariable\r
+ ST.Binds $relation\r
+\r
+%define defConnectionPoint($connectionType, $attachmentRelation)\r
+ $subject <R ST.IsConnectedTo \r
+ ST.AllowsConnectionType $connectionType\r
+ ST.HasAttachmentRelation $attachmentRelation\r
+\r
+%define terminalRelation($target)\r
+ $subject <R ST.IsConnectedTo\r
+ MOD.DiagramConnectionRelationToConnectionRelation $target\r
+\r
+######################################################################\r
+# Component types\r
+######################################################################\r
+\r
+IsHeadOfTerminal\r
+ L0.InverseOf HasHeadTerminal\r
+ terminalRelation(IsHeadOf)\r
+IsTailOfTerminal\r
+ L0.InverseOf HasTailTerminal\r
+ terminalRelation(IsTailOf)\r
+\r
+SysdynTerminal <T DIA.Terminal\r
+\r
+######################################################################\r
+Stock\r
+ def()\r
+ connection(IsTailOf)\r
+ connection(IsHeadOf)\r
+\r
+StockSymbol <T DIA.FontProvider <T DIA.ColorProvider\r
+ defSymbol("Stock", Stock)\r
+ L0.IsDependencyOf BasicSymbolLibrary\r
+ ST.IsDefinedBy %list : DIA.Composite <R L0.HasNext\r
+ _ : SysdynTerminal\r
+ terminal(StockSymbol, IsHeadOfTerminal)\r
+ _ : SysdynTerminal\r
+ terminal(StockSymbol, IsTailOfTerminal)\r
+\r
+######################################################################\r
+Valve\r
+ def()\r
+ connection(IsTailOf)\r
+ connection(IsHeadOf)\r
+\r
+ValveSymbol <T DIA.FontProvider <T DIA.ColorProvider\r
+ defSymbol("Valve", Valve)\r
+ L0.IsDependencyOf BasicSymbolLibrary\r
+ ST.IsDefinedBy %list : DIA.Composite <R L0.HasNext\r
+ _ : SysdynTerminal\r
+ terminal(ValveSymbol, IsHeadOfTerminal)\r
+ _ : SysdynTerminal\r
+ terminal(ValveSymbol, IsTailOfTerminal)\r
+\r
+######################################################################\r
+Auxiliary\r
+ def()\r
+ connection(IsTailOf)\r
+ connection(IsHeadOf)\r
+\r
+AuxiliarySymbol <T DIA.FontProvider <T DIA.ColorProvider\r
+ defSymbol("Auxiliary", Auxiliary)\r
+ L0.IsDependencyOf BasicSymbolLibrary\r
+ ST.IsDefinedBy %list : DIA.Composite <R L0.HasNext\r
+ _ : SysdynTerminal\r
+ terminal(AuxiliarySymbol, IsHeadOfTerminal)\r
+ _ : SysdynTerminal\r
+ terminal(AuxiliarySymbol, IsTailOfTerminal)\r
+\r
+######################################################################\r
+Cloud\r
+ def()\r
+ connection(IsTailOf)\r
+ connection(IsHeadOf)\r
+\r
+CloudSymbol <T DIA.FontProvider <T DIA.ColorProvider\r
+ defSymbol("Cloud", Cloud)\r
+ L0.IsDependencyOf BasicSymbolLibrary\r
+ ST.IsDefinedBy %list : DIA.Composite <R L0.HasNext\r
+ _ : SysdynTerminal\r
+ terminal(CloudSymbol, IsHeadOfTerminal)\r
+ _ : SysdynTerminal\r
+ terminal(CloudSymbol, IsTailOfTerminal)\r
+ \r
+######################################################################\r
+Input\r
+ def()\r
+ connection(IsTailOf)\r
+ connection(IsHeadOf)\r
+\r
+InputSymbol <T DIA.FontProvider <T DIA.ColorProvider\r
+ defSymbol("Input", Input)\r
+ L0.IsDependencyOf BasicSymbolLibrary\r
+ ST.IsDefinedBy %list : DIA.Composite <R L0.HasNext\r
+ _ : SysdynTerminal\r
+ terminal(InputSymbol, IsHeadOfTerminal)\r
+ _ : SysdynTerminal\r
+ terminal(InputSymbol, IsTailOfTerminal) \r
+\r
+######################################################################\r
+# Diagram connection types\r
+######################################################################\r
+\r
+angle <R L0.HasProperty : L0.FunctionalRelation\r
+ L0.HasRange L0.Double\r
+\r
+FlowConnection <T DIA.Connection\r
+ MOD.DiagramConnectionTypeToConnectionType\r
+ Flow \r
+ \r
+DependencyConnection <T DIA.Connection\r
+ [angle card "1"]\r
+ assert(angle, "0.1" : L0.Double) \r
+ MOD.DiagramConnectionTypeToConnectionType\r
+ Dependency\r
+\r
+######################################################################\r
+# Work model with two modules\r
+######################################################################\r
+\r
+%define dep($e1, $e2, $angle)\r
+ $subject\r
+ tag(AdminIsVisible)\r
+ tag(AdminIsFocusable)\r
+ ST.HasConnectionType SysdynConnectionType\r
+ angle $angle : L0.Double\r
+ DIA.HasArrowConnector _ : DIA.Connector\r
+ HasHeadTerminal $e1\r
+ DIA.AreConnected _ : DIA.Connector \r
+ HasTailTerminal $e2\r
+ DIA.IsPlainConnectorOf $subject\r
+\r
+%define flow($e1, $e2)\r
+ $subject\r
+ tag(AdminIsVisible)\r
+ tag(AdminIsFocusable)\r
+ ST.HasConnectionType SysdynConnectionType\r
+ DIA.HasPlainConnector _ : DIA.Connector\r
+ HasTailTerminal $e2\r
+ DIA.AreConnected _ : DIA.Connector \r
+ HasHeadTerminal $e1\r
+ DIA.IsArrowConnectorOf $subject\r
+ \r
+%define conf_dep($v1, $v2)\r
+ $subject\r
+ tag(MOD.Mapped)\r
+ HasHead $v1\r
+ HasTail $v2\r
+\r
+%define conf_dep_ref($v1, $v2, $ref)\r
+ $subject\r
+ tag(MOD.Mapped)\r
+ HasHead $v1\r
+ HasTail $v2\r
+ RefersTo $ref \r
+ \r
+WorkSymbol <T ModuleSymbol\r
+ MOD.SymbolToComponentType WorkModule\r
+ ST.IsDefinedBy %list : DIA.Composite <R L0.HasNext\r
+ _ : SysdynTerminal\r
+ terminal(ModuleSymbol, IsHeadOfTerminal)\r
+ _ : SysdynTerminal\r
+ terminal(ModuleSymbol, IsTailOfTerminal)\r
+\r
+WorkforceSymbol <T ModuleSymbol\r
+ MOD.SymbolToComponentType WorkforceModule\r
+ ST.IsDefinedBy %list : DIA.Composite <R L0.HasNext\r
+ _ : SysdynTerminal\r
+ terminal(ModuleSymbol, IsHeadOfTerminal)\r
+ _ : SysdynTerminal\r
+ terminal(ModuleSymbol, IsTailOfTerminal)\r
+\r
+_ @ "WorkModel" : SysdynModel\r
+ L0.HasLabel "Work Model" : L0.String\r
+ L0.PartOf SysdynModuleTestProject\r
+ SIMU.HasConfiguration WorkModelConfiguration\r
+ L0.ConsistsOf \r
+ _ @ "Experiment" : Experiment\r
+ L0.HasLabel "Experiment" : L0.String\r
+ WorkModule\r
+ WorkforceModule \r
+ WorkModuleConfiguration\r
+ WorkforceModuleConfiguration\r
+ WorkModelConfiguration \r
+\r
+\r
+WorkModelConfiguration @ "WorkModelConfiguration" : Configuration\r
+ L0.HasLabel "WorkModelConfiguration" : L0.String\r
+ HasStartTime "0.0" : L0.Double\r
+ HasStopTime "24.0" : L0.Double\r
+ \r
+ L0.ConsistsOf\r
+ ### Modules\r
+ Workforce @ "Workforce" : WorkforceModule\r
+ tag(MOD.Mapped)\r
+ L0.HasLabel "Workforce" : L0.String\r
+ Work1 @ "Work1" : WorkModule\r
+ tag(MOD.Mapped)\r
+ L0.HasLabel "Work1" : L0.String \r
+ Work2 @ "Work2" : WorkModule\r
+ tag(MOD.Mapped)\r
+ L0.HasLabel "Work2" : L0.String \r
+ \r
+ ## Parameters\r
+ Work1CompletionTime @ "Work1CompletionTime" : Auxiliary\r
+ tag(MOD.Mapped)\r
+ HasExpression _ : ParameterExpression\r
+ HasEquation "15" : L0.String \r
+ Work2CompletionTime @ "Work2CompletionTime" : Auxiliary\r
+ tag(MOD.Mapped) \r
+ HasExpression _ : ParameterExpression\r
+ HasEquation "11" : L0.String \r
+ Work2Amount @ "Work2Amount" : Auxiliary\r
+ tag(MOD.Mapped) \r
+ HasExpression _ : ParameterExpression\r
+ HasEquation "700" : L0.String \r
+ \r
+ ## Inputs\r
+ TotalPossibleWorkingSpeedInput @ "TotalPossibleWorkingSpeedInput" : Input\r
+ tag(MOD.Mapped)\r
+ RequiredWorkingSpeed1 @ "RequiredWorkingSpeed1" : Input\r
+ tag(MOD.Mapped)\r
+ RequiredWorkingSpeed2 @ "RequiredWorkingSpeed2" : Input\r
+ tag(MOD.Mapped) \r
+ Work1WorkDone @ "Work1WorkDone" : Input\r
+ tag(MOD.Mapped) \r
+ Work2WorkDone @ "Work2WorkDone" : Input\r
+ tag(MOD.Mapped) \r
+ \r
+ ## Auxiliaries \r
+ RequiredWorkingSpeedTotal @ "RequiredWorkingSpeedTotal" : Auxiliary\r
+ tag(MOD.Mapped)\r
+ HasExpression _ : NormalExpression\r
+ HasEquation "RequiredWorkingSpeed1+RequiredWorkingSpeed2" : L0.String \r
+ \r
+ d1 : Dependency\r
+ conf_dep_ref(TotalPossibleWorkingSpeedInput, Workforce, PossibleWorkingSpeed) \r
+ d2 : Dependency\r
+ conf_dep_ref(Work1, TotalPossibleWorkingSpeedInput, PossibleWorkingSpeedInput) \r
+ d3 : Dependency\r
+ conf_dep_ref(Work1, Work1CompletionTime, WorkCompletionTimeInput) \r
+ d4 : Dependency\r
+ conf_dep_ref(Work1, RequiredWorkingSpeedTotal, RequiredWorkingSpeedTotalInput) \r
+ d5 : Dependency\r
+ conf_dep_ref(RequiredWorkingSpeed1, Work1, RequiredWorkingSpeed) \r
+ d6 : Dependency\r
+ conf_dep_ref(Work2, TotalPossibleWorkingSpeedInput, PossibleWorkingSpeedInput) \r
+ d7 : Dependency\r
+ conf_dep_ref(Work2, Work2CompletionTime, WorkCompletionTimeInput) \r
+ d8 : Dependency\r
+ conf_dep_ref(Work2, RequiredWorkingSpeedTotal, RequiredWorkingSpeedTotalInput) \r
+ d9 : Dependency\r
+ conf_dep_ref(RequiredWorkingSpeed2, Work2, RequiredWorkingSpeed) \r
+ d10 : Dependency\r
+ conf_dep_ref(Workforce, RequiredWorkingSpeedTotal, RequiredWorkingSpeedInput) \r
+ d11 : Dependency\r
+ conf_dep(RequiredWorkingSpeedTotal, RequiredWorkingSpeed1) \r
+ d12 : Dependency\r
+ conf_dep(RequiredWorkingSpeedTotal, RequiredWorkingSpeed2)\r
+ d13 : Dependency\r
+ conf_dep_ref(Work1WorkDone, Work1, WorkDone)\r
+ d14 : Dependency\r
+ conf_dep_ref(Work2WorkDone, Work2, WorkDone) \r
+ d15 : Dependency\r
+ conf_dep_ref(Work2, Work2Amount, ProjectWorkAmount) \r
+ \r
+ \r
+WorkModelConfigurationDiagram : ConfigurationDiagram <R L0.HasNext\r
+ MOD.DiagramToComposite WorkModelConfiguration\r
+ DIA.HasLayer _ @ "Admin" : DIA.Layer\r
+ DIA.IsActive "true" : L0.Boolean\r
+ DIA.HasFocusableTag AdminIsFocusable @ "Admin1" <R DIA.IsFocusable\r
+ symmetric()\r
+ DIA.HasVisibleTag AdminIsVisible @ "Admin2" <R DIA.IsVisible\r
+ symmetric()\r
+ L0.HasTrigger _ : DiagramToCompositeMapping\r
+ #DIA.NavigationEnabled "false" : L0.Boolean\r
+ %list_elements\r
+ WorkforceElement : WorkforceSymbol\r
+ MOD.ElementToComponent Workforce\r
+ DIA.HasTransform "1.0, 0.0, 0.0, 1.0, 101.0, 50.0" : G2D.Transform\r
+ Work1Element : WorkSymbol\r
+ MOD.ElementToComponent Work1\r
+ DIA.HasTransform "1.0, 0.0, 0.0, 1.0, 114.0, 87.0" : G2D.Transform\r
+ Work2Element : WorkSymbol\r
+ MOD.ElementToComponent Work2\r
+ DIA.HasTransform "1.0, 0.0, 0.0, 1.0, 108.0, 161.0" : G2D.Transform \r
+ Work1CompletionTimeElement : AuxiliarySymbol\r
+ MOD.ElementToComponent Work1CompletionTime\r
+ DIA.HasTransform "1.0, 0.0, 0.0, 1.0, 165.0, 99.0" : G2D.Transform \r
+ Work2CompletionTimeElement : AuxiliarySymbol\r
+ MOD.ElementToComponent Work2CompletionTime\r
+ DIA.HasTransform "1.0, 0.0, 0.0, 1.0, 165.0, 153.0" : G2D.Transform \r
+ Work2AmountElement : AuxiliarySymbol\r
+ MOD.ElementToComponent Work2Amount\r
+ DIA.HasTransform "1.0, 0.0, 0.0, 1.0, 75.0, 160.0" : G2D.Transform \r
+ RequiredWorkingSpeedTotalElement : AuxiliarySymbol\r
+ MOD.ElementToComponent RequiredWorkingSpeedTotal\r
+ DIA.HasTransform "1.0, 0.0, 0.0, 1.0, 32.0, 76.0" : G2D.Transform \r
+ TotalPossibleWorkingSpeedInputElement : InputSymbol\r
+ MOD.ElementToComponent TotalPossibleWorkingSpeedInput\r
+ DIA.HasTransform "1.0, 0.0, 0.0, 1.0, 141.0, 60.0" : G2D.Transform\r
+ RequiredWorkingSpeed1Element : InputSymbol\r
+ MOD.ElementToComponent RequiredWorkingSpeed1\r
+ DIA.HasTransform "1.0, 0.0, 0.0, 1.0, 65.0, 125.0" : G2D.Transform\r
+ RequiredWorkingSpeed2Element : InputSymbol\r
+ MOD.ElementToComponent RequiredWorkingSpeed2\r
+ DIA.HasTransform "1.0, 0.0, 0.0, 1.0, 100.0, 122.0" : G2D.Transform\r
+ Work1WorkDoneElement : InputSymbol\r
+ MOD.ElementToComponent Work1WorkDone\r
+ DIA.HasTransform "1.0, 0.0, 0.0, 1.0, 155.0, 110.0" : G2D.Transform\r
+ Work2WorkDoneElement : InputSymbol\r
+ MOD.ElementToComponent Work2WorkDone\r
+ DIA.HasTransform "1.0, 0.0, 0.0, 1.0, 155.0, 130.0" : G2D.Transform \r
+ _ : DependencyConnection\r
+ MOD.DiagramConnectionToConnection d1 \r
+ dep(TotalPossibleWorkingSpeedInputElement, WorkforceElement, "-0.1") \r
+ _ : DependencyConnection\r
+ MOD.DiagramConnectionToConnection d2\r
+ dep(Work1Element, TotalPossibleWorkingSpeedInputElement, "-0.1") \r
+ _ : DependencyConnection\r
+ MOD.DiagramConnectionToConnection d3 \r
+ dep(Work1Element , Work1CompletionTimeElement, "-0.1") \r
+ _ : DependencyConnection\r
+ MOD.DiagramConnectionToConnection d4 \r
+ dep(Work1Element , RequiredWorkingSpeedTotalElement, "-0.1") \r
+ _ : DependencyConnection\r
+ MOD.DiagramConnectionToConnection d5 \r
+ dep(RequiredWorkingSpeed1Element , Work1Element, "-0.1") \r
+ _ : DependencyConnection\r
+ MOD.DiagramConnectionToConnection d6\r
+ dep(Work2Element , TotalPossibleWorkingSpeedInputElement, "-0.1") \r
+ _ : DependencyConnection\r
+ MOD.DiagramConnectionToConnection d7 \r
+ dep(Work2Element , Work2CompletionTimeElement, "-0.1") \r
+ _ : DependencyConnection\r
+ MOD.DiagramConnectionToConnection d8 \r
+ dep(Work2Element , RequiredWorkingSpeedTotalElement, "-0.1") \r
+ _ : DependencyConnection\r
+ MOD.DiagramConnectionToConnection d9\r
+ dep(RequiredWorkingSpeed2Element , Work2Element, "-0.1") \r
+ _ : DependencyConnection\r
+ MOD.DiagramConnectionToConnection d10\r
+ dep(WorkforceElement, RequiredWorkingSpeedTotalElement, "-0.1") \r
+ _ : DependencyConnection\r
+ MOD.DiagramConnectionToConnection d11\r
+ dep(RequiredWorkingSpeedTotalElement, RequiredWorkingSpeed1Element, "-0.1") \r
+ _ : DependencyConnection\r
+ MOD.DiagramConnectionToConnection d12\r
+ dep(RequiredWorkingSpeedTotalElement, RequiredWorkingSpeed2Element, "-0.1") \r
+ _ : DependencyConnection\r
+ MOD.DiagramConnectionToConnection d13\r
+ dep(Work1WorkDoneElement, Work1Element , "-0.1") \r
+ _ : DependencyConnection\r
+ MOD.DiagramConnectionToConnection d14\r
+ dep(Work2WorkDoneElement, Work2Element , "-0.1") \r
+ _ : DependencyConnection\r
+ MOD.DiagramConnectionToConnection d15\r
+ dep(Work2Element, Work2AmountElement , "-0.1") \r
+ \r
+WorkModule @ "WorkModule" <T Module\r
+ ST.IsDefinedBy WorkModuleConfiguration\r
+\r
+WorkModuleConfiguration @ "WorkModuleConfiguration" : Configuration\r
+ L0.ConsistsOf \r
+ \r
+ ## Parameters\r
+ MaximumWorkingSpeed @ "MaximumWorkingSpeed" : Auxiliary\r
+ tag(MOD.Mapped)\r
+ HasExpression _ : ParameterExpression\r
+ HasEquation "500" : L0.String \r
+ WorkQuality @ "WorkQuality" : Auxiliary\r
+ tag(MOD.Mapped)\r
+ HasExpression _ : ParameterExpression\r
+ HasEquation "0.9" : L0.String \r
+ \r
+ ## Valves\r
+ WorkingSpeed @ "WorkingSpeed" : Valve\r
+ tag(MOD.Mapped)\r
+ HasExpression _ : NormalExpression\r
+ HasEquation "if ProjectIsReady < 1 then WorkAllocation else 0" : L0.String\r
+ ErrorsGenerated @ "ErrorsGenerated" : Valve\r
+ tag(MOD.Mapped)\r
+ HasExpression _ : NormalExpression\r
+ HasEquation "(1-WorkQuality)*WorkingSpeed" : L0.String \r
+ ErrorsFoundRate @ "ErrorsFoundRate" : Valve\r
+ tag(MOD.Mapped)\r
+ HasExpression _ : NormalExpression\r
+ HasEquation "Errors/ErrorsFoundTime" : L0.String \r
+ ProjectReadyness @ "ProjectReadyness" : Valve\r
+ tag(MOD.Mapped)\r
+ HasExpression _ : NormalExpression\r
+ HasEquation "(xidz(first=WorkDone, second=ProjectWorkAmount, x=0.0) - ProjectIsReady) / 0.08" : L0.String \r
+ \r
+\r
+ \r
+ ## Stocks\r
+ WorkToDo @ "WorkToDo" : Stock\r
+ tag(MOD.Mapped)\r
+ HasExpression _ : StockExpression\r
+ HasInitialEquation "ProjectWorkAmount" : L0.String \r
+ WorkDone @ "WorkDone" : Stock\r
+ tag(MOD.Mapped)\r
+ HasExpression _ : StockExpression\r
+ HasInitialEquation "0" : L0.String \r
+ tag(IsOutput)\r
+ Errors @ "Errors" : Stock\r
+ tag(MOD.Mapped)\r
+ HasExpression _ : StockExpression\r
+ HasInitialEquation "0" : L0.String \r
+ ProjectIsReady @ "ProjectIsReady" : Stock\r
+ tag(MOD.Mapped)\r
+ HasExpression _ : StockExpression\r
+ HasInitialEquation "0" : L0.String \r
+ \r
+ ## Auxiliaries \r
+ TimeToDeadline @ "TimeToDeadline" : Auxiliary\r
+ tag(MOD.Mapped)\r
+ HasExpression _ : NormalExpression\r
+ HasEquation "max(0, WorkCompletionTimeInput-time)" : L0.String \r
+ RequiredWorkingSpeed @ "RequiredWorkingSpeed" : Auxiliary\r
+ tag(MOD.Mapped)\r
+ tag(IsOutput)\r
+ HasExpression _ : NormalExpression\r
+ HasEquation "if ProjectIsReady < 1 then xidz(first=WorkToDo, second=TimeToDeadline, x=MaximumWorkingSpeed) else 0" : L0.String \r
+ WorkAllocation @ "WorkAllocation" : Auxiliary\r
+ tag(MOD.Mapped)\r
+ HasExpression _ : NormalExpression\r
+ HasEquation "xidz(first = RequiredWorkingSpeed, second = RequiredWorkingSpeedTotalInput, x = 0.0) * PossibleWorkingSpeedInput" : L0.String \r
+ ErrorsFoundTime @ "ErrorsFoundTime" : Auxiliary\r
+ tag(MOD.Mapped)\r
+ HasExpression _ : WithLookupExpression\r
+ HasEquation "xidz(first=WorkDone, second=ProjectWorkAmount, x=0.0)" : L0.String \r
+ HasLookup "{{0,5},{0.5,3},{1,0.5},{2,0.5}}" : L0.String \r
+\r
+ ## Inputs\r
+ WorkCompletionTimeInput @ "WorkCompletionTimeInput" : Input\r
+ tag(MOD.Mapped)\r
+ PossibleWorkingSpeedInput @ "PossibleWorkingSpeedInput" : Input\r
+ tag(MOD.Mapped) \r
+ RequiredWorkingSpeedTotalInput @ "RequiredWorkingSpeedTotalInput" : Input\r
+ tag(MOD.Mapped) \r
+ ProjectWorkAmount @ "ProjectWorkAmount" : Input\r
+ tag(MOD.Mapped)\r
+ HasDefaultInputValue "1000.0" : L0.Double \r
+ \r
+ c31 : Cloud\r
+ c33 : Cloud\r
+ \r
+ d31 : Dependency\r
+ conf_dep(TimeToDeadline, WorkCompletionTimeInput) \r
+ d32 : Dependency\r
+ conf_dep(RequiredWorkingSpeed, MaximumWorkingSpeed) \r
+ d33 : Dependency\r
+ conf_dep(RequiredWorkingSpeed, TimeToDeadline) \r
+ d34 : Dependency\r
+ conf_dep(RequiredWorkingSpeed, ProjectIsReady) \r
+ d35 : Dependency\r
+ conf_dep(RequiredWorkingSpeed, WorkToDo) \r
+ d36 : Dependency\r
+ conf_dep(WorkAllocation, RequiredWorkingSpeedTotalInput) \r
+ d37 : Dependency\r
+ conf_dep(WorkAllocation, PossibleWorkingSpeedInput) \r
+ d38 : Dependency\r
+ conf_dep(WorkAllocation, RequiredWorkingSpeed) \r
+ d40 : Dependency\r
+ conf_dep(ProjectReadyness, WorkDone) \r
+ d41 : Dependency\r
+ conf_dep(ProjectReadyness, ProjectWorkAmount) \r
+ d42 : Dependency\r
+ conf_dep(WorkingSpeed, WorkAllocation) \r
+ d43 : Dependency\r
+ conf_dep(WorkingSpeed, ProjectIsReady) \r
+ d44 : Dependency\r
+ conf_dep(ErrorsGenerated, WorkingSpeed) \r
+ d45 : Dependency\r
+ conf_dep(ErrorsGenerated, WorkQuality) \r
+ d46 : Dependency\r
+ conf_dep(ErrorsFoundRate, Errors) \r
+ d47 : Dependency\r
+ conf_dep(ErrorsFoundRate, ErrorsFoundTime) \r
+ d48 : Dependency\r
+ conf_dep(ErrorsFoundTime, ProjectWorkAmount) \r
+ d49 : Dependency\r
+ conf_dep(ErrorsFoundTime, WorkDone) \r
+ \r
+ \r
+ f31 : Flow\r
+ conf_dep(WorkingSpeed, WorkToDo) \r
+ f32 : Flow\r
+ conf_dep(WorkDone, WorkingSpeed) \r
+ f33 : Flow\r
+ conf_dep(ErrorsGenerated, c31) \r
+ f34 : Flow\r
+ conf_dep(Errors, ErrorsGenerated) \r
+ f35 : Flow\r
+ conf_dep(ErrorsFoundRate, Errors) \r
+ f36 : Flow\r
+ conf_dep(ErrorsFoundRate, WorkDone) \r
+ f37 : Flow\r
+ conf_dep(WorkToDo, ErrorsFoundRate) \r
+ f40 : Flow\r
+ conf_dep(ProjectIsReady, ProjectReadyness) \r
+ f41 : Flow\r
+ conf_dep(ProjectReadyness, c33) \r
+ \r
+WorkModuleConfigurationDiagram : ConfigurationDiagram <R L0.HasNext\r
+ MOD.DiagramToComposite WorkModuleConfiguration\r
+ DIA.HasLayer _ @ "Admin" : DIA.Layer\r
+ DIA.IsActive "true" : L0.Boolean\r
+ DIA.HasFocusableTag AdminIsFocusable\r
+ DIA.HasVisibleTag AdminIsVisible\r
+ L0.HasTrigger _ : DiagramToCompositeMapping\r
+ %list_elements \r
+ \r
+ WorkCompletionTimeInputElement : InputSymbol\r
+ MOD.ElementToComponent WorkCompletionTimeInput\r
+ DIA.HasTransform "1.0, 0.0, 0.0, 1.0, 60.0, 55.0" : G2D.Transform \r
+ PossibleWorkingSpeedInputElement : InputSymbol\r
+ MOD.ElementToComponent PossibleWorkingSpeedInput\r
+ DIA.HasTransform "1.0, 0.0, 0.0, 1.0, 190.0, 60.0" : G2D.Transform \r
+ RequiredWorkingSpeedTotalInputElement : InputSymbol\r
+ MOD.ElementToComponent RequiredWorkingSpeedTotalInput\r
+ DIA.HasTransform "1.0, 0.0, 0.0, 1.0, 165.0, 45.0" : G2D.Transform \r
+ ProjectWorkAmountElement : InputSymbol\r
+ MOD.ElementToComponent ProjectWorkAmount\r
+ DIA.HasTransform "1.0, 0.0, 0.0, 1.0, 210.0, 120.0" : G2D.Transform \r
+ \r
+ WorkingSpeedElement : ValveSymbol\r
+ MOD.ElementToComponent WorkingSpeed\r
+ DIA.HasTransform "1.0, 0.0, 0.0, 1.0, 125.0, 100.0" : G2D.Transform \r
+ ErrorsGeneratedElement : ValveSymbol\r
+ MOD.ElementToComponent ErrorsGenerated\r
+ DIA.HasTransform "1.0, 0.0, 0.0, 1.0, 135.0, 110.0" : G2D.Transform \r
+ ErrorsFoundRateElement : ValveSymbol\r
+ MOD.ElementToComponent ErrorsFoundRate\r
+ DIA.HasTransform "1.0, 0.0, 0.0, 1.0, 140.0, 140.0" : G2D.Transform \r
+ ProjectReadynessElement : ValveSymbol\r
+ MOD.ElementToComponent ProjectReadyness\r
+ DIA.HasTransform "1.0, 0.0, 0.0, 1.0, 215.0, 85.0" : G2D.Transform \r
+ \r
+ WorkToDoElement : StockSymbol\r
+ MOD.ElementToComponent WorkToDo\r
+ DIA.HasTransform "1.0, 0.0, 0.0, 1.0, 85.0, 100.0" : G2D.Transform \r
+ WorkDoneElement : StockSymbol\r
+ MOD.ElementToComponent WorkDone\r
+ DIA.HasTransform "1.0, 0.0, 0.0, 1.0, 160.0, 100.0" : G2D.Transform \r
+ ErrorsElement : StockSymbol\r
+ MOD.ElementToComponent Errors\r
+ DIA.HasTransform "1.0, 0.0, 0.0, 1.0, 153.0, 110.0" : G2D.Transform \r
+ ProjectIsReadyElement : StockSymbol\r
+ MOD.ElementToComponent ProjectIsReady\r
+ DIA.HasTransform "1.0, 0.0, 0.0, 1.0, 180.0, 85.0" : G2D.Transform \r
+ \r
+ MaximumWorkingSpeedElement : AuxiliarySymbol\r
+ MOD.ElementToComponent MaximumWorkingSpeed\r
+ DIA.HasTransform "1.0, 0.0, 0.0, 1.0, 45.0, 70.0" : G2D.Transform \r
+ WorkQualityElement : AuxiliarySymbol\r
+ MOD.ElementToComponent WorkQuality\r
+ DIA.HasTransform "1.0, 0.0, 0.0, 1.0, 120.0, 130.0" : G2D.Transform \r
+ TimeToDeadlineElement : AuxiliarySymbol\r
+ MOD.ElementToComponent TimeToDeadline\r
+ DIA.HasTransform "1.0, 0.0, 0.0, 1.0, 80.0, 75.0" : G2D.Transform \r
+ RequiredWorkingSpeedElement : AuxiliarySymbol\r
+ MOD.ElementToComponent RequiredWorkingSpeed\r
+ DIA.HasTransform "1.0, 0.0, 0.0, 1.0, 90.0, 90.0" : G2D.Transform \r
+ WorkAllocationElement : AuxiliarySymbol\r
+ MOD.ElementToComponent WorkAllocation\r
+ DIA.HasTransform "1.0, 0.0, 0.0, 1.0, 140.0, 75.0" : G2D.Transform \r
+ ErrorsFoundTimeElement : AuxiliarySymbol\r
+ MOD.ElementToComponent ErrorsFoundTime\r
+ DIA.HasTransform "1.0, 0.0, 0.0, 1.0, 180.0, 140.0" : G2D.Transform \r
+\r
+ c31Element : CloudSymbol\r
+ MOD.ElementToComponent c31\r
+ DIA.HasTransform "1.0, 0.0, 0.0, 1.0, 110.0, 110.0" : G2D.Transform \r
+ c33Element : CloudSymbol\r
+ MOD.ElementToComponent c33\r
+ DIA.HasTransform "1.0, 0.0, 0.0, 1.0, 230.0, 85.0" : G2D.Transform \r
+ \r
+ _ : DependencyConnection\r
+ MOD.DiagramConnectionToConnection d31\r
+ dep(TimeToDeadlineElement, WorkCompletionTimeInputElement , "-0.1") \r
+ _ : DependencyConnection\r
+ MOD.DiagramConnectionToConnection d32\r
+ dep(RequiredWorkingSpeedElement, MaximumWorkingSpeedElement , "-0.1") \r
+ _ : DependencyConnection\r
+ MOD.DiagramConnectionToConnection d33\r
+ dep(RequiredWorkingSpeedElement, TimeToDeadlineElement , "-0.1") \r
+ _ : DependencyConnection\r
+ MOD.DiagramConnectionToConnection d34\r
+ dep(RequiredWorkingSpeedElement, ProjectIsReadyElement , "-0.1") \r
+ _ : DependencyConnection\r
+ MOD.DiagramConnectionToConnection d35\r
+ dep(RequiredWorkingSpeedElement, WorkToDoElement , "-0.1") \r
+ _ : DependencyConnection\r
+ MOD.DiagramConnectionToConnection d36\r
+ dep(WorkAllocationElement, RequiredWorkingSpeedTotalInputElement , "-0.1") \r
+ _ : DependencyConnection\r
+ MOD.DiagramConnectionToConnection d37\r
+ dep(WorkAllocationElement, PossibleWorkingSpeedInputElement , "-0.1") \r
+ _ : DependencyConnection\r
+ MOD.DiagramConnectionToConnection d38\r
+ dep(WorkAllocationElement, RequiredWorkingSpeedElement , "-0.1") \r
+ _ : DependencyConnection\r
+ MOD.DiagramConnectionToConnection d40\r
+ dep(ProjectReadynessElement, WorkDoneElement , "-0.1") \r
+ _ : DependencyConnection\r
+ MOD.DiagramConnectionToConnection d41\r
+ dep(ProjectReadynessElement, ProjectWorkAmountElement , "-0.1") \r
+ _ : DependencyConnection \r
+ MOD.DiagramConnectionToConnection d42\r
+ dep(WorkingSpeedElement, WorkAllocationElement , "-0.1") \r
+ _ : DependencyConnection\r
+ MOD.DiagramConnectionToConnection d43\r
+ dep(WorkingSpeedElement, ProjectIsReadyElement , "-0.1") \r
+ _ : DependencyConnection\r
+ MOD.DiagramConnectionToConnection d44\r
+ dep(ErrorsGeneratedElement, WorkingSpeedElement , "-0.1") \r
+ _ : DependencyConnection\r
+ MOD.DiagramConnectionToConnection d45\r
+ dep(ErrorsGeneratedElement, WorkQualityElement , "-0.1") \r
+ _ : DependencyConnection\r
+ MOD.DiagramConnectionToConnection d46\r
+ dep(ErrorsFoundRateElement, ErrorsElement , "-0.1") \r
+ _ : DependencyConnection\r
+ MOD.DiagramConnectionToConnection d47\r
+ dep(ErrorsFoundRateElement, ErrorsFoundTimeElement , "-0.1") \r
+ _ : DependencyConnection\r
+ MOD.DiagramConnectionToConnection d48\r
+ dep(ErrorsFoundTimeElement, ProjectWorkAmountElement , "-0.1") \r
+ _ : DependencyConnection\r
+ MOD.DiagramConnectionToConnection d49\r
+ dep(ErrorsFoundTimeElement, WorkDoneElement , "-0.1") \r
+ \r
+ _ : FlowConnection\r
+ MOD.DiagramConnectionToConnection f31\r
+ flow(WorkingSpeedElement, WorkToDoElement ) \r
+ _ : FlowConnection\r
+ MOD.DiagramConnectionToConnection f32\r
+ flow(WorkDoneElement, WorkingSpeedElement ) \r
+ _ : FlowConnection\r
+ MOD.DiagramConnectionToConnection f33\r
+ flow(ErrorsGeneratedElement, c31Element ) \r
+ _ : FlowConnection\r
+ MOD.DiagramConnectionToConnection f34\r
+ flow(ErrorsElement, ErrorsGeneratedElement ) \r
+ _ : FlowConnection\r
+ MOD.DiagramConnectionToConnection f35\r
+ flow(ErrorsFoundRateElement, ErrorsElement ) \r
+ _ : FlowConnection\r
+ MOD.DiagramConnectionToConnection f36\r
+ flow(ErrorsFoundRateElement, WorkDoneElement ) \r
+ _ : FlowConnection\r
+ MOD.DiagramConnectionToConnection f37\r
+ flow(WorkToDoElement, ErrorsFoundRateElement ) \r
+ _ : FlowConnection\r
+ MOD.DiagramConnectionToConnection f40\r
+ flow(ProjectIsReadyElement, ProjectReadynessElement ) \r
+ _ : FlowConnection\r
+ MOD.DiagramConnectionToConnection f41\r
+ flow(ProjectReadynessElement, c33Element ) \r
+ \r
+ \r
+WorkforceModule @ "WorkforceModule" <T Module\r
+ ST.IsDefinedBy WorkforceModuleConfiguration\r
+\r
+WorkforceModuleConfiguration @ "WorkforceModuleConfiguration" : Configuration\r
+ L0.ConsistsOf \r
+ \r
+ ## Parameters\r
+ TimeToAllocateResources @ "TimeToAllocateResources" : Auxiliary\r
+ tag(MOD.Mapped)\r
+ HasExpression _ : ParameterExpression\r
+ HasEquation "2" : L0.String \r
+ Productivity @ "Productivity" : Auxiliary\r
+ tag(MOD.Mapped) \r
+ HasExpression _ : ParameterExpression\r
+ HasEquation "1" : L0.String \r
+ \r
+ ## Valve\r
+ NetResources @ "NetResources" : Valve\r
+ tag(MOD.Mapped)\r
+ HasExpression _ : NormalExpression\r
+ HasEquation "(WorkForceRequired-WorkforceStock)/TimeToAllocateResources" : L0.String \r
+\r
+ ## Stock\r
+ WorkforceStock @ "WorkforceStock" : Stock\r
+ tag(MOD.Mapped)\r
+ HasExpression _ : StockExpression\r
+ HasInitialEquation "0" : L0.String \r
+ \r
+ ## Auxiliaries \r
+ WorkForceRequired @ "WorkForceRequired" : Auxiliary\r
+ tag(MOD.Mapped)\r
+ HasExpression _ : NormalExpression\r
+ HasEquation "RequiredWorkingSpeedInput/Productivity" : L0.String \r
+ PossibleWorkingSpeed @ "PossibleWorkingSpeed" : Auxiliary\r
+ tag(MOD.Mapped)\r
+ tag(IsOutput)\r
+ HasExpression _ : NormalExpression\r
+ HasEquation "WorkforceStock*Productivity" : L0.String \r
+ \r
+ ## Inputs\r
+ RequiredWorkingSpeedInput @ "RequiredWorkingSpeedInput" : Input\r
+ tag(MOD.Mapped) \r
+ \r
+ c21 : Cloud\r
+ \r
+ d21 : Dependency\r
+ conf_dep(NetResources, TimeToAllocateResources) \r
+ d22 : Dependency\r
+ conf_dep(NetResources, WorkforceStock) \r
+ d23 : Dependency\r
+ conf_dep(NetResources, WorkForceRequired) \r
+ d24 : Dependency\r
+ conf_dep(WorkForceRequired, Productivity) \r
+ d25 : Dependency\r
+ conf_dep(WorkForceRequired, RequiredWorkingSpeedInput) \r
+ d26 : Dependency\r
+ conf_dep(PossibleWorkingSpeed, WorkforceStock) \r
+ d27 : Dependency\r
+ conf_dep(PossibleWorkingSpeed, Productivity) \r
+ f21 : Flow\r
+ conf_dep(WorkforceStock, NetResources) \r
+ f22 : Flow\r
+ conf_dep(NetResources, c21) \r
+ \r
+WorkforceModuleConfigurationDiagram : ConfigurationDiagram <R L0.HasNext\r
+ MOD.DiagramToComposite WorkforceModuleConfiguration\r
+ DIA.HasLayer _ @ "Admin" : DIA.Layer\r
+ DIA.IsActive "true" : L0.Boolean\r
+ DIA.HasFocusableTag AdminIsFocusable\r
+ DIA.HasVisibleTag AdminIsVisible\r
+ L0.HasTrigger _ : DiagramToCompositeMapping\r
+ %list_elements \r
+ TimeToAllocateResourcesElement : AuxiliarySymbol\r
+ MOD.ElementToComponent TimeToAllocateResources\r
+ DIA.HasTransform "1.0, 0.0, 0.0, 1.0, 45.0, 75.0" : G2D.Transform \r
+ ProductivityElement : AuxiliarySymbol\r
+ MOD.ElementToComponent Productivity\r
+ DIA.HasTransform "1.0, 0.0, 0.0, 1.0, 120.0, 115.0" : G2D.Transform\r
+ NetResourcesElement : ValveSymbol\r
+ MOD.ElementToComponent NetResources\r
+ DIA.HasTransform "1.0, 0.0, 0.0, 1.0, 60.0, 84.0" : G2D.Transform \r
+ WorkforceStockElement : StockSymbol\r
+ MOD.ElementToComponent WorkforceStock\r
+ DIA.HasTransform "1.0, 0.0, 0.0, 1.0, 93.0, 84.0" : G2D.Transform \r
+ WorkForceRequiredElement : AuxiliarySymbol\r
+ MOD.ElementToComponent WorkForceRequired\r
+ DIA.HasTransform "1.0, 0.0, 0.0, 1.0, 82.0, 117.0" : G2D.Transform\r
+ PossibleWorkingSpeedElement : AuxiliarySymbol\r
+ MOD.ElementToComponent PossibleWorkingSpeed\r
+ DIA.HasTransform "1.0, 0.0, 0.0, 1.0, 115.0, 102.0" : G2D.Transform \r
+ RequiredWorkingSpeedInputElement : InputSymbol\r
+ MOD.ElementToComponent RequiredWorkingSpeedInput\r
+ DIA.HasTransform "1.0, 0.0, 0.0, 1.0, 45.0, 127.0" : G2D.Transform \r
+ c21Element : CloudSymbol\r
+ MOD.ElementToComponent c21\r
+ DIA.HasTransform "1.0, 0.0, 0.0, 1.0, 45.0, 85.0" : G2D.Transform \r
+ _ : DependencyConnection\r
+ MOD.DiagramConnectionToConnection d21\r
+ dep(NetResourcesElement, TimeToAllocateResourcesElement , "-0.1")\r
+ _ : DependencyConnection\r
+ MOD.DiagramConnectionToConnection d22\r
+ dep(NetResourcesElement, WorkforceStockElement , "-0.1")\r
+ _ : DependencyConnection\r
+ MOD.DiagramConnectionToConnection d23\r
+ dep(NetResourcesElement, WorkForceRequiredElement , "-0.1")\r
+ _ : DependencyConnection\r
+ MOD.DiagramConnectionToConnection d24\r
+ dep(WorkForceRequiredElement, ProductivityElement , "-0.1")\r
+ _ : DependencyConnection\r
+ MOD.DiagramConnectionToConnection d25\r
+ dep(WorkForceRequiredElement, RequiredWorkingSpeedInputElement , "-0.1")\r
+ _ : DependencyConnection\r
+ MOD.DiagramConnectionToConnection d26\r
+ dep(PossibleWorkingSpeedElement, WorkforceStockElement , "-0.1")\r
+ _ : DependencyConnection\r
+ MOD.DiagramConnectionToConnection d27\r
+ dep(PossibleWorkingSpeedElement, ProductivityElement , "-0.1") \r
+ _ : FlowConnection\r
+ MOD.DiagramConnectionToConnection f21\r
+ flow(WorkforceStockElement, NetResourcesElement ) \r
+ _ : FlowConnection\r
+ MOD.DiagramConnectionToConnection f22\r
+ flow(c21Element, NetResourcesElement ) \r
+ \r
+ \r
+######################################################################\r
+# Customer model\r
+######################################################################\r
+\r
+CustomersSymbol <T ModuleSymbol\r
+ MOD.SymbolToComponentType CustomerModule\r
+ ST.IsDefinedBy %list : DIA.Composite <R L0.HasNext\r
+ _ : SysdynTerminal\r
+ terminal(ModuleSymbol, IsHeadOfTerminal)\r
+ _ : SysdynTerminal\r
+ terminal(ModuleSymbol, IsTailOfTerminal)\r
+\r
+CapacitySymbol <T ModuleSymbol\r
+ MOD.SymbolToComponentType CapacityModule\r
+ ST.IsDefinedBy %list : DIA.Composite <R L0.HasNext\r
+ _ : SysdynTerminal\r
+ terminal(ModuleSymbol, IsHeadOfTerminal)\r
+ _ : SysdynTerminal\r
+ terminal(ModuleSymbol, IsTailOfTerminal)\r
+\r
+_ @ "CustomerModel" : SysdynModel\r
+ L0.HasLabel "Asiakasmalli" : L0.String\r
+ L0.PartOf SysdynModuleTestProject\r
+ SIMU.HasConfiguration RootConfiguration\r
+ L0.ConsistsOf \r
+ _ @ "Experiment" : Experiment\r
+ L0.HasLabel "Experiment" : L0.String\r
+ CustomerModule\r
+ CustomerModuleConfiguration\r
+ CapacityModule \r
+ CapacityModuleConfiguration\r
+ RootConfiguration \r
+\r
+RootConfigurationDiagram : ConfigurationDiagram <R L0.HasNext\r
+ MOD.DiagramToComposite RootConfiguration\r
+ DIA.HasLayer _ @ "Admin" : DIA.Layer\r
+ DIA.IsActive "true" : L0.Boolean\r
+ DIA.HasFocusableTag AdminIsFocusableCM @ "Admin1CM" <R DIA.IsFocusable\r
+ symmetric()\r
+ DIA.HasVisibleTag AdminIsVisibleCM @ "Admin2CM" <R DIA.IsVisible\r
+ symmetric()\r
+ L0.HasTrigger _ : DiagramToCompositeMapping\r
+ #DIA.NavigationEnabled "false" : L0.Boolean\r
+ %list_elements\r
+ CustomersElement : CustomersSymbol\r
+ MOD.ElementToComponent Customers\r
+ DIA.HasTransform "1.0, 0.0, 0.0, 1.0, 89.0, 133.0" : G2D.Transform\r
+ CapacityElement : CapacitySymbol\r
+ MOD.ElementToComponent Capacity\r
+ DIA.HasTransform "1.0, 0.0, 0.0, 1.0, 87.0, 65.0" : G2D.Transform\r
+ SalesRevenueElement : ValveSymbol\r
+ MOD.ElementToComponent SalesRevenue\r
+ DIA.HasTransform "1.0, 0.0, 0.0, 1.0, 100.0, 90.0" : G2D.Transform\r
+ CumulativeRevenueElement : StockSymbol\r
+ MOD.ElementToComponent CumulativeRevenue\r
+ DIA.HasTransform "1.0, 0.0, 0.0, 1.0, 115.0, 90.0" : G2D.Transform\r
+ DummyCloudElement : CloudSymbol\r
+ MOD.ElementToComponent DummyCloud\r
+ DIA.HasTransform "1.0, 0.0, 0.0, 1.0, 85.0, 90.0" : G2D.Transform\r
+ PriceElement : AuxiliarySymbol\r
+ MOD.ElementToComponent Price\r
+ DIA.HasTransform "1.0, 0.0, 0.0, 1.0, 99.0, 80.0" : G2D.Transform\r
+ SalesElement : AuxiliarySymbol\r
+ MOD.ElementToComponent Sales\r
+ DIA.HasTransform "1.0, 0.0, 0.0, 1.0, 92.0, 102.0" : G2D.Transform\r
+ WidgetsPerPersonInputElement : InputSymbol\r
+ MOD.ElementToComponent WidgetsPerPersonInput\r
+ DIA.HasTransform "1.0, 0.0, 0.0, 1.0, 61.0, 90.0" : G2D.Transform\r
+ NewCustomersInputElement : InputSymbol\r
+ MOD.ElementToComponent NewCustomersInput\r
+ DIA.HasTransform "1.0, 0.0, 0.0, 1.0, 91.0, 113.0" : G2D.Transform\r
+ WordOfMouthDemandInputElement : InputSymbol\r
+ MOD.ElementToComponent WordOfMouthDemandInput\r
+ DIA.HasTransform "1.0, 0.0, 0.0, 1.0, 49.0, 98.0" : G2D.Transform\r
+ CapacityInputElement : InputSymbol\r
+ MOD.ElementToComponent CapacityInput\r
+ DIA.HasTransform "1.0, 0.0, 0.0, 1.0, 136.0, 90.0" : G2D.Transform\r
+ _ : FlowConnection\r
+ MOD.DiagramConnectionToConnection Flow1 \r
+ flow(SalesRevenueElement, DummyCloudElement)\r
+ _ : FlowConnection\r
+ MOD.DiagramConnectionToConnection Flow2\r
+ flow(CumulativeRevenueElement ,SalesRevenueElement)\r
+ _ : DependencyConnection\r
+ MOD.DiagramConnectionToConnection Dependency1 \r
+ dep(SalesRevenueElement, PriceElement, "-0.1")\r
+ _ : DependencyConnection\r
+ MOD.DiagramConnectionToConnection Dependency2 \r
+ dep(SalesRevenueElement, SalesElement, "-0.1")\r
+ _ : DependencyConnection\r
+ MOD.DiagramConnectionToConnection Dependency3 \r
+ dep(SalesElement, NewCustomersInputElement, "-0.1")\r
+ _ : DependencyConnection\r
+ MOD.DiagramConnectionToConnection Dependency4 \r
+ dep(SalesElement, WidgetsPerPersonInputElement, "0.12")\r
+ _ : DependencyConnection\r
+ MOD.DiagramConnectionToConnection Dependency5 \r
+ dep(CustomersElement, CapacityInputElement, "-0.28")\r
+ _ : DependencyConnection\r
+ MOD.DiagramConnectionToConnection Dependency6\r
+ dep(CustomersElement, WidgetsPerPersonInputElement, "0.27")\r
+ _ : DependencyConnection\r
+ MOD.DiagramConnectionToConnection Dependency7\r
+ dep(WordOfMouthDemandInputElement, CustomersElement, "-0.2")\r
+ _ : DependencyConnection\r
+ MOD.DiagramConnectionToConnection Dependency8\r
+ dep(CapacityElement, WordOfMouthDemandInputElement, "-0.98")\r
+ _ : DependencyConnection\r
+ MOD.DiagramConnectionToConnection Dependency9\r
+ dep(NewCustomersInputElement, CustomersElement, "-0.1")\r
+ _ : DependencyConnection\r
+ MOD.DiagramConnectionToConnection Dependency10\r
+ dep(WidgetsPerPersonInputElement, CapacityElement, "0.88")\r
+ _ : DependencyConnection\r
+ MOD.DiagramConnectionToConnection Dependency11\r
+ dep(CapacityInputElement, CapacityElement, "-0.31")\r
+ \r
+RootConfiguration @ "RootConfiguration" : Configuration\r
+ L0.HasLabel "Konfiguraatio" : L0.String\r
+ HasStartTime "0.0" : L0.Double\r
+ HasStopTime "100.0" : L0.Double\r
+ L0.ConsistsOf\r
+ ### Modules\r
+ Customers @ "Asiakkaat" : CustomerModule\r
+ tag(MOD.Mapped)\r
+ L0.HasLabel "Asiakkaat" : L0.String\r
+ Capacity @ "Kapasiteetti" : CapacityModule\r
+ tag(MOD.Mapped)\r
+ L0.HasLabel "Kapasiteetti" : L0.String \r
+ ### Variables\r
+ Price @ "Hinta" : Auxiliary\r
+ tag(MOD.Mapped)\r
+ HasExpression _ : ParameterExpression\r
+ HasEquation "50" : L0.String\r
+ Sales @ "Myynti" : Auxiliary\r
+ tag(MOD.Mapped)\r
+ HasExpression _ : NormalExpression\r
+ HasEquation "UusiaAsiakkaita * WidgettejaHenkilolle" : L0.String \r
+ CumulativeRevenue @ "KumulatiivisetTulot" : Stock\r
+ tag(MOD.Mapped)\r
+ HasExpression _ : StockExpression\r
+ HasInitialEquation "0" : L0.String \r
+ SalesRevenue @ "Myyntitulot" : Valve\r
+ tag(MOD.Mapped)\r
+ HasExpression _ : NormalExpression\r
+ HasEquation "Myynti * Hinta" : L0.String \r
+ DummyCloud : Cloud\r
+ tag(MOD.Mapped)\r
+ ### Input variables\r
+ WidgetsPerPersonInput @ "WidgettejaHenkilolle" : Input\r
+ tag(MOD.Mapped)\r
+ NewCustomersInput @ "UusiaAsiakkaita" : Input\r
+ tag(MOD.Mapped)\r
+ WordOfMouthDemandInput @ "PuskaradioKysynta" : Input\r
+ tag(MOD.Mapped)\r
+ CapacityInput @ "KapasiteettiInput" : Input\r
+ tag(MOD.Mapped) \r
+ Flow1 : Flow\r
+ tag(MOD.Mapped)\r
+ HasHead SalesRevenue\r
+ HasTail DummyCloud\r
+ Flow2 : Flow\r
+ tag(MOD.Mapped)\r
+ HasHead CumulativeRevenue\r
+ HasTail SalesRevenue \r
+ Dependency1 : Dependency\r
+ conf_dep(SalesRevenue, Price)\r
+ Dependency2 : Dependency\r
+ conf_dep(SalesRevenue, Sales)\r
+ Dependency3 : Dependency\r
+ conf_dep(Sales, NewCustomersInput)\r
+ Dependency4 : Dependency\r
+ conf_dep(Sales, WidgetsPerPersonInput)\r
+ Dependency5 : Dependency\r
+ conf_dep_ref(Customers, CapacityInput, CapacityInput2)\r
+ Dependency6 : Dependency\r
+ conf_dep_ref(Customers, WidgetsPerPersonInput, WidgetsPerPersonInput2)\r
+ Dependency7 : Dependency\r
+ conf_dep_ref(WordOfMouthDemandInput, Customers, WordOfMouthDemandOutput)\r
+ Dependency8 : Dependency\r
+ conf_dep_ref(Capacity, WordOfMouthDemandInput, WordOfMouthDemandInput2)\r
+ Dependency9 : Dependency\r
+ conf_dep_ref(NewCustomersInput, Customers, NewCustomers)\r
+ Dependency10 : Dependency\r
+ conf_dep_ref(WidgetsPerPersonInput, Capacity, WidgetsPerPersonOutput)\r
+ Dependency11 : Dependency\r
+ conf_dep_ref(CapacityInput, Capacity, CapacityStock)\r
+ \r
+CapacityModule @ "Kapasiteettimoduuli" <T Module\r
+ ST.IsDefinedBy CapacityModuleConfiguration\r
+\r
+CapacityModuleConfiguration @ "Kapasiteettimoduulikonfiguraatio" : Configuration\r
+ L0.ConsistsOf \r
+ CapacityAdjustment @ "Kapasiteettisaato" : Auxiliary\r
+ HasExpression _ : NormalExpression\r
+ HasEquation "(Tavoitekapasiteetti - Kapasiteetti)/Kapasiteetinsaatoaika" : L0.String\r
+ TargetCapacity @ "Tavoitekapasiteetti" : Auxiliary\r
+ HasExpression _ : NormalExpression\r
+ HasEquation "PuskaradioKysynta * WidgettejaHenkilolle" : L0.String\r
+ DesiredProduction @ "Tavoitetuotanto" : Auxiliary\r
+ HasExpression _ : NormalExpression\r
+ HasEquation "Tavoitekapasiteetti" : L0.String\r
+ PotentialProduction @ "PotentiaalinenTuotanto" : Auxiliary\r
+ HasExpression _ : NormalExpression\r
+ HasEquation "Kapasiteetti" : L0.String\r
+ Production @ "Tuotanto" : Auxiliary\r
+ HasExpression _ : NormalExpression\r
+ HasEquation "min(Tavoitetuotanto, PotentiaalinenTuotanto)" : L0.String\r
+ CapacityLife @ "Kapasiteettielama" : Auxiliary\r
+ HasExpression _ : ParameterExpression\r
+ HasEquation "20" : L0.String \r
+ TimeToAdjustCapacity @ "Kapasiteetinsaatoaika" : Auxiliary\r
+ HasExpression _ : ParameterExpression\r
+ HasEquation "12" : L0.String \r
+ WidgetsPerPersonOutput @ "WidgettejaHenkilolle" : Auxiliary\r
+ HasExpression _ : ParameterExpression\r
+ HasEquation "1" : L0.String \r
+ tag(IsOutput)\r
+ \r
+ DummyCloud2 : Cloud\r
+ DummyCloud3 : Cloud \r
+ CapacityStock @ "Kapasiteetti" : Stock\r
+ HasExpression _ : StockExpression\r
+ HasInitialEquation "Tavoitekapasiteetti" : L0.String\r
+ tag(IsOutput) \r
+ Investment @ "Sijoitus" : Valve\r
+ HasExpression _ : NormalExpression\r
+ HasEquation "Kapasiteettisaato" : L0.String \r
+ Reductions @ "Vahennys" : Valve\r
+ HasExpression _ : NormalExpression\r
+ HasEquation "Kapasiteetti/Kapasiteettielama" : L0.String \r
+ \r
+ ### Input variables\r
+ WordOfMouthDemandInput2 @ "PuskaradioKysynta" : Input\r
+\r
+ ### Dependencies \r
+ Flow3 : Flow\r
+ HasHead Investment\r
+ HasTail DummyCloud2 \r
+ tag(MOD.Mapped)\r
+ Flow4 : Flow\r
+ HasHead CapacityStock\r
+ HasTail Investment \r
+ tag(MOD.Mapped)\r
+ Flow5 : Flow\r
+ HasHead Reductions\r
+ HasTail CapacityStock\r
+ tag(MOD.Mapped)\r
+ Flow6 : Flow\r
+ HasHead DummyCloud3\r
+ HasTail Reductions \r
+ tag(MOD.Mapped) \r
+ Dependency12 : Dependency\r
+ HasHead Reductions\r
+ HasTail CapacityStock\r
+ tag(MOD.Mapped)\r
+ Dependency13 : Dependency\r
+ HasHead PotentialProduction\r
+ HasTail CapacityStock\r
+ tag(MOD.Mapped)\r
+ Dependency14 : Dependency\r
+ HasHead CapacityAdjustment\r
+ HasTail CapacityStock\r
+ tag(MOD.Mapped)\r
+ Dependency15 : Dependency\r
+ HasHead Reductions\r
+ HasTail CapacityLife\r
+ tag(MOD.Mapped)\r
+ Dependency16 : Dependency\r
+ HasHead Production\r
+ HasTail PotentialProduction\r
+ tag(MOD.Mapped)\r
+ Dependency17 : Dependency\r
+ HasHead Production\r
+ HasTail DesiredProduction \r
+ tag(MOD.Mapped)\r
+ Dependency18 : Dependency\r
+ HasHead DesiredProduction\r
+ HasTail TargetCapacity\r
+ tag(MOD.Mapped)\r
+ Dependency19 : Dependency\r
+ HasHead CapacityAdjustment\r
+ HasTail TargetCapacity\r
+ tag(MOD.Mapped)\r
+ Dependency20 : Dependency\r
+ HasHead TargetCapacity\r
+ HasTail WidgetsPerPersonOutput\r
+ tag(MOD.Mapped)\r
+ Dependency21 : Dependency\r
+ HasHead TargetCapacity\r
+ HasTail WordOfMouthDemandInput2\r
+ tag(MOD.Mapped)\r
+ Dependency22 : Dependency\r
+ HasHead CapacityAdjustment\r
+ HasTail TimeToAdjustCapacity\r
+ tag(MOD.Mapped)\r
+ Dependency23 : Dependency\r
+ HasHead Investment\r
+ HasTail CapacityAdjustment \r
+ tag(MOD.Mapped) \r
+ \r
+CapacityModuleConfigurationDiagram : ConfigurationDiagram <R L0.HasNext\r
+ MOD.DiagramToComposite CapacityModuleConfiguration\r
+ DIA.HasLayer _ @ "Admin" : DIA.Layer\r
+ DIA.IsActive "true" : L0.Boolean\r
+ DIA.HasFocusableTag AdminIsFocusableCM\r
+ DIA.HasVisibleTag AdminIsVisibleCM\r
+ L0.HasTrigger _ : DiagramToCompositeMapping\r
+ %list_elements\r
+ DummyCloud2Element : CloudSymbol\r
+ MOD.ElementToComponent DummyCloud2\r
+ DIA.HasTransform "1.0, 0.0, 0.0, 1.0, 85.0, 90.0" : G2D.Transform\r
+ InvestmentElement : ValveSymbol\r
+ MOD.ElementToComponent Investment\r
+ DIA.HasTransform "1.0, 0.0, 0.0, 1.0, 100.0, 90.0" : G2D.Transform\r
+ CapacityStockElement : StockSymbol\r
+ MOD.ElementToComponent CapacityStock\r
+ DIA.HasTransform "1.0, 0.0, 0.0, 1.0, 115.0, 90.0" : G2D.Transform\r
+ ReductionsElement : ValveSymbol\r
+ MOD.ElementToComponent Reductions\r
+ DIA.HasTransform "1.0, 0.0, 0.0, 1.0, 150.0, 90.0" : G2D.Transform\r
+ DummyCloud3Element : CloudSymbol\r
+ MOD.ElementToComponent DummyCloud3\r
+ DIA.HasTransform "1.0, 0.0, 0.0, 1.0, 175.0, 90.0" : G2D.Transform\r
+ _ : FlowConnection\r
+ MOD.DiagramConnectionToConnection Flow3\r
+ flow(InvestmentElement, DummyCloud2Element)\r
+ _ : FlowConnection\r
+ MOD.DiagramConnectionToConnection Flow4\r
+ flow(CapacityStockElement, InvestmentElement)\r
+ _ : FlowConnection\r
+ MOD.DiagramConnectionToConnection Flow5\r
+ flow(ReductionsElement, CapacityStockElement)\r
+ _ : FlowConnection\r
+ MOD.DiagramConnectionToConnection Flow6\r
+ flow(DummyCloud3Element, ReductionsElement)\r
+ \r
+ CapacityAdjustmentElement : AuxiliarySymbol\r
+ MOD.ElementToComponent CapacityAdjustment\r
+ DIA.HasTransform "1.0, 0.0, 0.0, 1.0, 80.0, 105.0" : G2D.Transform\r
+ TargetCapacityElement : AuxiliarySymbol\r
+ MOD.ElementToComponent TargetCapacity\r
+ DIA.HasTransform "1.0, 0.0, 0.0, 1.0, 110.0, 120.0" : G2D.Transform\r
+ DesiredProductionElement : AuxiliarySymbol\r
+ MOD.ElementToComponent DesiredProduction\r
+ DIA.HasTransform "1.0, 0.0, 0.0, 1.0, 140.0, 120.0" : G2D.Transform\r
+ PotentialProductionElement : AuxiliarySymbol\r
+ MOD.ElementToComponent PotentialProduction\r
+ DIA.HasTransform "1.0, 0.0, 0.0, 1.0, 120.0, 105.0" : G2D.Transform\r
+ ProductionElement : AuxiliarySymbol\r
+ MOD.ElementToComponent Production\r
+ DIA.HasTransform "1.0, 0.0, 0.0, 1.0, 145.0, 110.0" : G2D.Transform\r
+ CapacityLifeElement : AuxiliarySymbol\r
+ MOD.ElementToComponent CapacityLife\r
+ DIA.HasTransform "1.0, 0.0, 0.0, 1.0, 150, 100.0" : G2D.Transform\r
+ TimeToAdjustCapacityElement : AuxiliarySymbol\r
+ MOD.ElementToComponent TimeToAdjustCapacity\r
+ DIA.HasTransform "1.0, 0.0, 0.0, 1.0, 70.0, 120.0" : G2D.Transform\r
+ WidgetsPerPersonOutputElement : AuxiliarySymbol\r
+ MOD.ElementToComponent WidgetsPerPersonOutput\r
+ DIA.HasTransform "1.0, 0.0, 0.0, 1.0, 130.0, 150.0" : G2D.Transform \r
+ WordOfMouthDemandInput2Element : InputSymbol\r
+ MOD.ElementToComponent WordOfMouthDemandInput2\r
+ DIA.HasTransform "1.0, 0.0, 0.0, 1.0, 100.0, 150.0" : G2D.Transform\r
+ _ : DependencyConnection\r
+ MOD.DiagramConnectionToConnection Dependency12\r
+ dep(ReductionsElement, CapacityStockElement, "-1.0")\r
+ _ : DependencyConnection\r
+ MOD.DiagramConnectionToConnection Dependency13\r
+ dep(PotentialProductionElement, CapacityStockElement, "-0.1") \r
+ _ : DependencyConnection\r
+ MOD.DiagramConnectionToConnection Dependency14\r
+ dep(CapacityAdjustmentElement, CapacityStockElement, "-0.1")\r
+ _ : DependencyConnection\r
+ MOD.DiagramConnectionToConnection Dependency15\r
+ dep(ReductionsElement, CapacityLifeElement, "-0.1")\r
+ _ : DependencyConnection\r
+ MOD.DiagramConnectionToConnection Dependency16\r
+ dep(ProductionElement, PotentialProductionElement, "1.04")\r
+ _ : DependencyConnection\r
+ MOD.DiagramConnectionToConnection Dependency17\r
+ dep(ProductionElement, DesiredProductionElement, "-0.1")\r
+ _ : DependencyConnection\r
+ MOD.DiagramConnectionToConnection Dependency18\r
+ dep(DesiredProductionElement, TargetCapacityElement, "-0.1")\r
+ _ : DependencyConnection\r
+ MOD.DiagramConnectionToConnection Dependency19\r
+ dep(CapacityAdjustmentElement, TargetCapacityElement, "-0.1")\r
+ _ : DependencyConnection\r
+ MOD.DiagramConnectionToConnection Dependency20\r
+ dep(TargetCapacityElement, WidgetsPerPersonOutputElement, "-0.1")\r
+ _ : DependencyConnection\r
+ MOD.DiagramConnectionToConnection Dependency21\r
+ dep(TargetCapacityElement, WordOfMouthDemandInput2Element, "-0.1")\r
+ _ : DependencyConnection\r
+ MOD.DiagramConnectionToConnection Dependency22\r
+ dep(CapacityAdjustmentElement, TimeToAdjustCapacityElement, "-0.1")\r
+ _ : DependencyConnection\r
+ MOD.DiagramConnectionToConnection Dependency23\r
+ dep(InvestmentElement, CapacityAdjustmentElement, "-0.1") \r
+\r
+\r
+CustomerModule @ "Asiakasmoduuli" <T Module\r
+ ST.IsDefinedBy CustomerModuleConfiguration\r
+\r
+\r
+CustomerModuleConfiguration @ "Asiakasmoduulikonfiguraatio" : Configuration\r
+ L0.ConsistsOf \r
+ ContactsOfNoncustomersWithCustomers @ "EiAsiakkaidenJaAsiakkaidenKohtaamiset" : Auxiliary\r
+ HasExpression _ : NormalExpression\r
+ HasEquation "AsiakkaidenKohtaamiset * PotentiaalisetAsiakaskeskittymat" : L0.String\r
+ ContactsWithCustomers @ "AsiakkaidenKohtaamiset" : Auxiliary\r
+ HasExpression _ : NormalExpression\r
+ HasEquation "Asiakkaat * Sosiaalisuus" : L0.String\r
+ PotentialCustomerConcentration @ "PotentiaalisetAsiakaskeskittymat" : Auxiliary\r
+ HasExpression _ : NormalExpression\r
+ HasEquation "MahdollisetAsiakkaat / MarkkinoidenKoko" : L0.String\r
+# WordOfMouthDemandOutput @ "Puskaradiokysynta_Per_MarkkinoidenKoko" : Auxiliary\r
+ WordOfMouthDemandOutput @ "Puskaradiokysynta" : Auxiliary\r
+ HasExpression _ : NormalExpression\r
+ HasEquation "EiAsiakkaidenJaAsiakkaidenKohtaamiset * Hedelmallisyys" : L0.String\r
+ tag(IsOutput)\r
+ TotalMarket @ "MarkkinoidenKoko" : Auxiliary\r
+ HasExpression _ : NormalExpression\r
+ HasEquation "Asiakkaat + MahdollisetAsiakkaat" : L0.String \r
+ Fruitfulness @ "Hedelmallisyys" : Auxiliary\r
+ HasExpression _ : ParameterExpression\r
+ HasEquation "0.01" : L0.String \r
+ Sociability @ "Sosiaalisuus" : Auxiliary\r
+ HasExpression _ : ParameterExpression\r
+ HasEquation "20" : L0.String \r
+ PotentialCustomersStock @ "MahdollisetAsiakkaat" : Stock\r
+ HasExpression _ : StockExpression\r
+ HasInitialEquation "1e+006" : L0.String \r
+ CustomersStock @ "Asiakkaat" : Stock\r
+ HasExpression _ : StockExpression\r
+ HasInitialEquation "1000" : L0.String \r
+ NewCustomers @ "UudetAsiakkaat" : Valve\r
+ HasExpression _ : NormalExpression\r
+ HasEquation " min(Puskaradiokysynta, Kapasiteetti/WidgettejaHenkilolle)" : L0.String \r
+ tag(IsOutput)\r
+ ### Input variables\r
+ CapacityInput2 @ "Kapasiteetti" : Input\r
+ WidgetsPerPersonInput2 @ "WidgettejaHenkilolle" : Input\r
+ \r
+ ### Dependencies \r
+ Flow7 : Flow\r
+ HasHead NewCustomers\r
+ HasTail PotentialCustomersStock \r
+ tag(MOD.Mapped) \r
+ Flow8 : Flow\r
+ HasHead CustomersStock\r
+ HasTail NewCustomers \r
+ tag(MOD.Mapped) \r
+ Dependency24 : Dependency\r
+ HasHead PotentialCustomerConcentration\r
+ HasTail TotalMarket\r
+ tag(MOD.Mapped) \r
+ Dependency25 : Dependency\r
+ HasHead ContactsOfNoncustomersWithCustomers\r
+ HasTail PotentialCustomerConcentration\r
+ tag(MOD.Mapped) \r
+ Dependency26 : Dependency\r
+ HasHead WordOfMouthDemandOutput\r
+ HasTail ContactsOfNoncustomersWithCustomers\r
+ tag(MOD.Mapped) \r
+ Dependency27 : Dependency\r
+ HasHead NewCustomers\r
+ HasTail WordOfMouthDemandOutput\r
+ tag(MOD.Mapped) \r
+ Dependency28 : Dependency\r
+ HasHead ContactsOfNoncustomersWithCustomers\r
+ HasTail ContactsWithCustomers\r
+ tag(MOD.Mapped) \r
+ Dependency29 : Dependency\r
+ HasHead ContactsWithCustomers\r
+ HasTail Sociability\r
+ tag(MOD.Mapped) \r
+ Dependency30 : Dependency\r
+ HasHead ContactsWithCustomers\r
+ HasTail CustomersStock\r
+ tag(MOD.Mapped) \r
+ Dependency31 : Dependency\r
+ HasHead TotalMarket\r
+ HasTail CustomersStock\r
+ tag(MOD.Mapped) \r
+ Dependency32 : Dependency\r
+ HasHead TotalMarket\r
+ HasTail PotentialCustomersStock\r
+ tag(MOD.Mapped) \r
+ Dependency33 : Dependency\r
+ HasHead NewCustomers\r
+ HasTail CapacityInput2\r
+ tag(MOD.Mapped) \r
+ Dependency34 : Dependency\r
+ HasHead NewCustomers\r
+ HasTail WidgetsPerPersonInput2\r
+ tag(MOD.Mapped) \r
+ Dependency35 : Dependency\r
+ HasHead WordOfMouthDemandOutput\r
+ HasTail Fruitfulness\r
+ tag(MOD.Mapped) \r
+ Dependency36 : Dependency\r
+ HasHead PotentialCustomerConcentration\r
+ HasTail PotentialCustomersStock\r
+ tag(MOD.Mapped) \r
+ \r
+CustomerModuleConfigurationDiagram : ConfigurationDiagram <R L0.HasNext\r
+ MOD.DiagramToComposite CustomerModuleConfiguration\r
+ DIA.HasLayer _ @ "Admin" : DIA.Layer\r
+ DIA.IsActive "true" : L0.Boolean\r
+ DIA.HasFocusableTag AdminIsFocusableCM\r
+ DIA.HasVisibleTag AdminIsVisibleCM\r
+ L0.HasTrigger _ : DiagramToCompositeMapping\r
+ %list_elements \r
+ ContactsOfNoncustomersWithCustomersElement : AuxiliarySymbol\r
+ MOD.ElementToComponent ContactsOfNoncustomersWithCustomers\r
+ DIA.HasTransform "1.0, 0.0, 0.0, 1.0, 64.0, 45.0" : G2D.Transform\r
+ ContactsWithCustomersElement : AuxiliarySymbol\r
+ MOD.ElementToComponent ContactsWithCustomers\r
+ DIA.HasTransform "1.0, 0.0, 0.0, 1.0, 130.0, 60.0" : G2D.Transform\r
+ PotentialCustomerConcentrationElement : AuxiliarySymbol\r
+ MOD.ElementToComponent PotentialCustomerConcentration\r
+ DIA.HasTransform "1.0, 0.0, 0.0, 1.0, 58.0, 60.0" : G2D.Transform\r
+ WordOfMouthDemandOutputElement : AuxiliarySymbol\r
+ MOD.ElementToComponent WordOfMouthDemandOutput\r
+ DIA.HasTransform "1.0, 0.0, 0.0, 1.0, 100.0, 75.0" : G2D.Transform\r
+ TotalMarketElement : AuxiliarySymbol\r
+ MOD.ElementToComponent TotalMarket\r
+ DIA.HasTransform "1.0, 0.0, 0.0, 1.0, 80.0, 120.0" : G2D.Transform \r
+ FruitfulnessElement : AuxiliarySymbol\r
+ MOD.ElementToComponent Fruitfulness\r
+ DIA.HasTransform "1.0, 0.0, 0.0, 1.0, 105.0, 60.0" : G2D.Transform\r
+ SociabilityElement : AuxiliarySymbol\r
+ MOD.ElementToComponent Sociability\r
+ DIA.HasTransform "1.0, 0.0, 0.0, 1.0, 125.0, 45.0" : G2D.Transform\r
+ PotentialCustomersStockElement : StockSymbol\r
+ MOD.ElementToComponent PotentialCustomersStock\r
+ DIA.HasTransform "1.0, 0.0, 0.0, 1.0, 60.0, 90.0" : G2D.Transform \r
+ CustomersStockElement : StockSymbol\r
+ MOD.ElementToComponent CustomersStock\r
+ DIA.HasTransform "1.0, 0.0, 0.0, 1.0, 120.0, 90.0" : G2D.Transform \r
+ NewCustomersElement : ValveSymbol\r
+ MOD.ElementToComponent NewCustomers\r
+ DIA.HasTransform "1.0, 0.0, 0.0, 1.0, 100.0, 90.0" : G2D.Transform\r
+ CapacityInput2Element : InputSymbol\r
+ MOD.ElementToComponent CapacityInput2\r
+ DIA.HasTransform "1.0, 0.0, 0.0, 1.0, 90.0, 105.0" : G2D.Transform\r
+ WidgetsPerPersonInput2Element : InputSymbol\r
+ MOD.ElementToComponent WidgetsPerPersonInput2\r
+ DIA.HasTransform "1.0, 0.0, 0.0, 1.0, 130.0, 110.0" : G2D.Transform\r
+ \r
+ \r
+ ### Dependencies \r
+ _ : FlowConnection\r
+ MOD.DiagramConnectionToConnection Flow7\r
+ flow(NewCustomersElement, PotentialCustomersStockElement) \r
+ _ : FlowConnection\r
+ MOD.DiagramConnectionToConnection Flow8\r
+ flow(CustomersStockElement, NewCustomersElement)\r
+ _ : DependencyConnection\r
+ MOD.DiagramConnectionToConnection Dependency24\r
+ dep(PotentialCustomerConcentrationElement, TotalMarketElement, "-1.7")\r
+ _ : DependencyConnection\r
+ MOD.DiagramConnectionToConnection Dependency25\r
+ dep(ContactsOfNoncustomersWithCustomersElement, PotentialCustomerConcentrationElement, "-0.1")\r
+ _ : DependencyConnection\r
+ MOD.DiagramConnectionToConnection Dependency26\r
+ dep(WordOfMouthDemandOutputElement, ContactsOfNoncustomersWithCustomersElement, "-0.1")\r
+ _ : DependencyConnection\r
+ MOD.DiagramConnectionToConnection Dependency27\r
+ dep(NewCustomersElement, WordOfMouthDemandOutputElement, "-0.1")\r
+ _ : DependencyConnection\r
+ MOD.DiagramConnectionToConnection Dependency28\r
+ dep(ContactsOfNoncustomersWithCustomersElement, ContactsWithCustomersElement, "-0.1")\r
+ _ : DependencyConnection\r
+ MOD.DiagramConnectionToConnection Dependency29\r
+ dep(ContactsWithCustomersElement, SociabilityElement, "-0.1")\r
+ _ : DependencyConnection\r
+ MOD.DiagramConnectionToConnection Dependency30\r
+ dep(ContactsWithCustomersElement, CustomersStockElement, "-0.1")\r
+ _ : DependencyConnection\r
+ MOD.DiagramConnectionToConnection Dependency31\r
+ dep(TotalMarketElement, CustomersStockElement, "-0.1")\r
+ _ : DependencyConnection\r
+ MOD.DiagramConnectionToConnection Dependency32\r
+ dep(TotalMarketElement, PotentialCustomersStockElement, "-0.1")\r
+ _ : DependencyConnection\r
+ MOD.DiagramConnectionToConnection Dependency33\r
+ dep(NewCustomersElement, CapacityInput2Element, "-0.1")\r
+ _ : DependencyConnection\r
+ MOD.DiagramConnectionToConnection Dependency34\r
+ dep(NewCustomersElement, WidgetsPerPersonInput2Element, "-0.6")\r
+ _ : DependencyConnection\r
+ MOD.DiagramConnectionToConnection Dependency35\r
+ dep(WordOfMouthDemandOutputElement, FruitfulnessElement, "-0.1")\r
+ _ : DependencyConnection\r
+ MOD.DiagramConnectionToConnection Dependency36\r
+ dep(PotentialCustomerConcentrationElement, PotentialCustomersStockElement, "-0.1") \r
+
\ No newline at end of file