From 7323c6ea67b087bd57baa4555ee1422ab65a25b9 Mon Sep 17 00:00:00 2001 From: urs Date: Mon, 15 Apr 2024 17:00:41 +0200 Subject: [PATCH] add simple markdown report --- de.urszeidler.shr5.acceleo/plugin.xml | 14 + .../common/ShadowrunMarkdownSheetTools.mtl | 34 ++ .../sheets/MarkdownCharacterSheet.java | 415 ++++++++++++++++++ .../acceleo/sheets/markdownCharacterSheet.mtl | 363 +++++++++++++++ .../shr5/acceleo/util/ShadowrunTextTools.java | 8 + .../shr5/acceleo/util/shadowrunTextTools.mtl | 3 + 6 files changed, 837 insertions(+) create mode 100644 de.urszeidler.shr5.acceleo/src/de/urszeidler/shr5/acceleo/common/ShadowrunMarkdownSheetTools.mtl create mode 100644 de.urszeidler.shr5.acceleo/src/de/urszeidler/shr5/acceleo/sheets/MarkdownCharacterSheet.java create mode 100644 de.urszeidler.shr5.acceleo/src/de/urszeidler/shr5/acceleo/sheets/markdownCharacterSheet.mtl diff --git a/de.urszeidler.shr5.acceleo/plugin.xml b/de.urszeidler.shr5.acceleo/plugin.xml index bc77929ec..f8febfa7b 100644 --- a/de.urszeidler.shr5.acceleo/plugin.xml +++ b/de.urszeidler.shr5.acceleo/plugin.xml @@ -17,6 +17,20 @@ class="de.urszeidler.eclipse.shr5Management.CharacterGroup"> + + + + + + + collect(e| (e.toString()).cellText())+'').tagText('tr') /] + +[query public table(txt : String) : String = self.tagText('table') /] +[query public tableHeading(txt : String) : String = self.tagText('th') /] + + +[** + * Prints a row in the table +*/] +[template public printRow(row : Sequence(String))] +[startTag('tr')/][for (it : String | row)] +[startTag('td')/][it/][endTag('td')/][/for][endTag('tr')/] +[/template] + + diff --git a/de.urszeidler.shr5.acceleo/src/de/urszeidler/shr5/acceleo/sheets/MarkdownCharacterSheet.java b/de.urszeidler.shr5.acceleo/src/de/urszeidler/shr5/acceleo/sheets/MarkdownCharacterSheet.java new file mode 100644 index 000000000..c3a06ba96 --- /dev/null +++ b/de.urszeidler.shr5.acceleo/src/de/urszeidler/shr5/acceleo/sheets/MarkdownCharacterSheet.java @@ -0,0 +1,415 @@ +/******************************************************************************* + * Copyright (c) 2008, 2012 Obeo. + * 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: + * Obeo - initial API and implementation + *******************************************************************************/ +package de.urszeidler.shr5.acceleo.sheets; + +import java.io.File; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; + +import org.eclipse.acceleo.engine.event.IAcceleoTextGenerationListener; +import org.eclipse.acceleo.engine.generation.strategy.IAcceleoGenerationStrategy; +import org.eclipse.acceleo.engine.service.AbstractAcceleoGenerator; +import org.eclipse.emf.common.util.BasicMonitor; +import org.eclipse.emf.common.util.Monitor; +import org.eclipse.emf.common.util.URI; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.resource.ResourceSet; + +/** + * Entry point of the 'MarkdownCharacterSheet' generation module. + * + * @generated + */ +public class MarkdownCharacterSheet extends AbstractAcceleoGenerator { + /** + * The name of the module. + * + * @generated + */ + public static final String MODULE_FILE_NAME = "/de/urszeidler/shr5/acceleo/sheets/markdownCharacterSheet"; + + /** + * The name of the templates that are to be generated. + * + * @generated + */ + public static final String[] TEMPLATE_NAMES = { "markdownCharacterSheet" }; + + /** + * The list of properties files from the launch parameters (Launch configuration). + * + * @generated + */ + private List propertiesFiles = new ArrayList(); + + /** + * Allows the public constructor to be used. Note that a generator created + * this way cannot be used to launch generations before one of + * {@link #initialize(EObject, File, List)} or + * {@link #initialize(URI, File, List)} is called. + *

+ * The main reason for this constructor is to allow clients of this + * generation to call it from another Java file, as it allows for the + * retrieval of {@link #getProperties()} and + * {@link #getGenerationListeners()}. + *

+ * + * @generated + */ + public MarkdownCharacterSheet() { + // Empty implementation + } + + /** + * This allows clients to instantiates a generator with all required information. + * + * @param modelURI + * URI where the model on which this generator will be used is located. + * @param targetFolder + * This will be used as the output folder for this generation : it will be the base path + * against which all file block URLs will be resolved. + * @param arguments + * If the template which will be called requires more than one argument taken from the model, + * pass them here. + * @throws IOException + * This can be thrown in three scenarios : the module cannot be found, it cannot be loaded, or + * the model cannot be loaded. + * @generated + */ + public MarkdownCharacterSheet(URI modelURI, File targetFolder, + List arguments) throws IOException { + initialize(modelURI, targetFolder, arguments); + } + + /** + * This allows clients to instantiates a generator with all required information. + * + * @param model + * We'll iterate over the content of this element to find Objects matching the first parameter + * of the template we need to call. + * @param targetFolder + * This will be used as the output folder for this generation : it will be the base path + * against which all file block URLs will be resolved. + * @param arguments + * If the template which will be called requires more than one argument taken from the model, + * pass them here. + * @throws IOException + * This can be thrown in two scenarios : the module cannot be found, or it cannot be loaded. + * @generated + */ + public MarkdownCharacterSheet(EObject model, File targetFolder, + List arguments) throws IOException { + initialize(model, targetFolder, arguments); + } + + /** + * This can be used to launch the generation from a standalone application. + * + * @param args + * Arguments of the generation. + * @generated + */ + public static void main(String[] args) { + try { + if (args.length < 2) { + System.out.println("Arguments not valid : {model, folder}."); + } else { + URI modelURI = URI.createFileURI(args[0]); + File folder = new File(args[1]); + + List arguments = new ArrayList(); + + /* + * If you want to change the content of this method, do NOT forget to change the "@generated" + * tag in the Javadoc of this method to "@generated NOT". Without this new tag, any compilation + * of the Acceleo module with the main template that has caused the creation of this class will + * revert your modifications. + */ + + /* + * Add in this list all the arguments used by the starting point of the generation + * If your main template is called on an element of your model and a String, you can + * add in "arguments" this "String" attribute. + */ + + MarkdownCharacterSheet generator = new MarkdownCharacterSheet(modelURI, folder, arguments); + + /* + * Add the properties from the launch arguments. + * If you want to programmatically add new properties, add them in "propertiesFiles" + * You can add the absolute path of a properties files, or even a project relative path. + * If you want to add another "protocol" for your properties files, please override + * "getPropertiesLoaderService(AcceleoService)" in order to return a new property loader. + * The behavior of the properties loader service is explained in the Acceleo documentation + * (Help -> Help Contents). + */ + + for (int i = 2; i < args.length; i++) { + generator.addPropertiesFile(args[i]); + } + + generator.doGenerate(new BasicMonitor()); + } + } catch (IOException e) { + e.printStackTrace(); + } + } + + /** + * Launches the generation described by this instance. + * + * @param monitor + * This will be used to display progress information to the user. + * @throws IOException + * This will be thrown if any of the output files cannot be saved to disk. + * @generated + */ + @Override + public void doGenerate(Monitor monitor) throws IOException { + /* + * TODO if you wish to change the generation as a whole, override this. The default behavior should + * be sufficient in most cases. If you want to change the content of this method, do NOT forget to + * change the "@generated" tag in the Javadoc of this method to "@generated NOT". Without this new tag, + * any compilation of the Acceleo module with the main template that has caused the creation of this + * class will revert your modifications. If you encounter a problem with an unresolved proxy during the + * generation, you can remove the comments in the following instructions to check for problems. Please + * note that those instructions may have a significant impact on the performances. + */ + + //org.eclipse.emf.ecore.util.EcoreUtil.resolveAll(model); + + /* + * If you want to check for potential errors in your models before the launch of the generation, you + * use the code below. + */ + + //if (model != null && model.eResource() != null) { + // List errors = model.eResource().getErrors(); + // for (org.eclipse.emf.ecore.resource.Resource.Diagnostic diagnostic : errors) { + // System.err.println(diagnostic.toString()); + // } + //} + + super.doGenerate(monitor); + } + + /** + * If this generator needs to listen to text generation events, listeners can be returned from here. + * + * @return List of listeners that are to be notified when text is generated through this launch. + * @generated + */ + @Override + public List getGenerationListeners() { + List listeners = super.getGenerationListeners(); + /* + * TODO if you need to listen to generation event, add listeners to the list here. If you want to change + * the content of this method, do NOT forget to change the "@generated" tag in the Javadoc of this method + * to "@generated NOT". Without this new tag, any compilation of the Acceleo module with the main template + * that has caused the creation of this class will revert your modifications. + */ + return listeners; + } + + /** + * If you need to change the way files are generated, this is your entry point. + *

+ * The default is {@link org.eclipse.acceleo.engine.generation.strategy.DefaultStrategy}; it generates + * files on the fly. If you only need to preview the results, return a new + * {@link org.eclipse.acceleo.engine.generation.strategy.PreviewStrategy}. Both of these aren't aware of + * the running Eclipse and can be used standalone. + *

+ *

+ * If you need the file generation to be aware of the workspace (A typical example is when you wanna + * override files that are under clear case or any other VCS that could forbid the overriding), then + * return a new {@link org.eclipse.acceleo.engine.generation.strategy.WorkspaceAwareStrategy}. + * Note, however, that this cannot be used standalone. + *

+ *

+ * All three of these default strategies support merging through JMerge. + *

+ * + * @return The generation strategy that is to be used for generations launched through this launcher. + * @generated + */ + @Override + public IAcceleoGenerationStrategy getGenerationStrategy() { + return super.getGenerationStrategy(); + } + + /** + * This will be called in order to find and load the module that will be launched through this launcher. + * We expect this name not to contain file extension, and the module to be located beside the launcher. + * + * @return The name of the module that is to be launched. + * @generated + */ + @Override + public String getModuleName() { + return MODULE_FILE_NAME; + } + + /** + * If the module(s) called by this launcher require properties files, return their qualified path from + * here.Take note that the first added properties files will take precedence over subsequent ones if they + * contain conflicting keys. + * + * @return The list of properties file we need to add to the generation context. + * @see java.util.ResourceBundle#getBundle(String) + * @generated + */ + @Override + public List getProperties() { + /* + * If you want to change the content of this method, do NOT forget to change the "@generated" + * tag in the Javadoc of this method to "@generated NOT". Without this new tag, any compilation + * of the Acceleo module with the main template that has caused the creation of this class will + * revert your modifications. + */ + + /* + * TODO if your generation module requires access to properties files, add their qualified path to the list here. + * + * Properties files can be located in an Eclipse plug-in or in the file system (all Acceleo projects are Eclipse + * plug-in). In order to use properties files located in an Eclipse plugin, you need to add the path of the properties + * files to the "propertiesFiles" list: + * + * final String prefix = "platform:/plugin/"; + * final String pluginName = "org.eclipse.acceleo.module.sample"; + * final String packagePath = "/org/eclipse/acceleo/module/sample/properties/"; + * final String fileName = "default.properties"; + * propertiesFiles.add(prefix + pluginName + packagePath + fileName); + * + * With this mechanism, you can load properties files from your plugin or from another plugin. + * + * You may want to load properties files from the file system, for that you need to add the absolute path of the file: + * + * propertiesFiles.add("C:\Users\MyName\MyFile.properties"); + * + * If you want to let your users add properties files located in the same folder as the model: + * + * if (EMFPlugin.IS_ECLIPSE_RUNNING && model != null && model.eResource() != null) { + * propertiesFiles.addAll(AcceleoEngineUtils.getPropertiesFilesNearModel(model.eResource())); + * } + * + * To learn more about Properties Files, have a look at the Acceleo documentation (Help -> Help Contents). + */ + return propertiesFiles; + } + + /** + * Adds a properties file in the list of properties files. + * + * @param propertiesFile + * The properties file to add. + * @generated + * @since 3.1 + */ + @Override + public void addPropertiesFile(String propertiesFile) { + this.propertiesFiles.add(propertiesFile); + } + + /** + * This will be used to get the list of templates that are to be launched by this launcher. + * + * @return The list of templates to call on the module {@link #getModuleName()}. + * @generated + */ + @Override + public String[] getTemplateNames() { + return TEMPLATE_NAMES; + } + + /** + * This can be used to update the resource set's package registry with all needed EPackages. + * + * @param resourceSet + * The resource set which registry has to be updated. + * @generated + */ + @Override + public void registerPackages(ResourceSet resourceSet) { + super.registerPackages(resourceSet); + if (!isInWorkspace(org.eclipse.emf.ecore.EcorePackage.class)) { + resourceSet.getPackageRegistry().put(org.eclipse.emf.ecore.EcorePackage.eINSTANCE.getNsURI(), org.eclipse.emf.ecore.EcorePackage.eINSTANCE); + } + + /* + * If you want to change the content of this method, do NOT forget to change the "@generated" + * tag in the Javadoc of this method to "@generated NOT". Without this new tag, any compilation + * of the Acceleo module with the main template that has caused the creation of this class will + * revert your modifications. + */ + + /* + * If you need additional package registrations, you can register them here. The following line + * (in comment) is an example of the package registration for UML. + * + * You can use the method "isInWorkspace(Class c)" to check if the package that you are about to + * register is in the workspace. + * + * To register a package properly, please follow the following conventions: + * + * If the package is located in another plug-in, already installed in Eclipse. The following content should + * have been generated at the beginning of this method. Do not register the package using this mechanism if + * the metamodel is located in the workspace. + * + * if (!isInWorkspace(UMLPackage.class)) { + * // The normal package registration if your metamodel is in a plugin. + * resourceSet.getPackageRegistry().put(UMLPackage.eNS_URI, UMLPackage.eINSTANCE); + * } + * + * If the package is located in another project in your workspace, the plugin containing the package has not + * been register by EMF and Acceleo should register it automatically. If you want to use the generator in + * stand alone, the regular registration (seen a couple lines before) is needed. + * + * To learn more about Package Registration, have a look at the Acceleo documentation (Help -> Help Contents). + */ + } + + /** + * This can be used to update the resource set's resource factory registry with all needed factories. + * + * @param resourceSet + * The resource set which registry has to be updated. + * @generated + */ + @Override + public void registerResourceFactories(ResourceSet resourceSet) { + super.registerResourceFactories(resourceSet); + /* + * If you want to change the content of this method, do NOT forget to change the "@generated" + * tag in the Javadoc of this method to "@generated NOT". Without this new tag, any compilation + * of the Acceleo module with the main template that has caused the creation of this class will + * revert your modifications. + */ + + /* + * TODO If you need additional resource factories registrations, you can register them here. the following line + * (in comment) is an example of the resource factory registration. + * + * If you want to use the generator in stand alone, the resource factory registration will be required. + * + * To learn more about the registration of Resource Factories, have a look at the Acceleo documentation (Help -> Help Contents). + */ + + // resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put(XyzResource.FILE_EXTENSION, XyzResource.Factory.INSTANCE); + + /* + * Some metamodels require a very complex setup for standalone usage. For example, if you want to use a generator + * targetting UML models in standalone, you NEED to use the following: + */ + // UMLResourcesUtil.init(resourceSet) + } + +} diff --git a/de.urszeidler.shr5.acceleo/src/de/urszeidler/shr5/acceleo/sheets/markdownCharacterSheet.mtl b/de.urszeidler.shr5.acceleo/src/de/urszeidler/shr5/acceleo/sheets/markdownCharacterSheet.mtl new file mode 100644 index 000000000..bf7956034 --- /dev/null +++ b/de.urszeidler.shr5.acceleo/src/de/urszeidler/shr5/acceleo/sheets/markdownCharacterSheet.mtl @@ -0,0 +1,363 @@ +[comment encoding = UTF-8 /] +[module markdownCharacterSheet('http://urszeidler.de/shr5/1.0', 'http://urszeidler.de/shr5mngt/1.0', 'http://www.eclipse.org/emf/2002/Ecore')/] + +[import de::urszeidler::shr5::acceleo::common::ShadowrunTools /] +[import de::urszeidler::shr5::acceleo::common::ShadowrunManagmentTools /] +[import de::urszeidler::shr5::acceleo::common::ShadowrunSheetTools /] +[import de::urszeidler::shr5::acceleo::common::ShadowrunMarkdownSheetTools /] +[import de::urszeidler::shr5::acceleo::common::shr5EEnumhelper /] +[import de::urszeidler::shr5::acceleo::common::shr5ManagementEEnumhelper /] +[import de::urszeidler::shr5::acceleo::util::shadowrunTextTools /] + +[template public markdownCharacterSheet(aManagedCharacter : ManagedCharacter)] + + [comment @main /] +[file (aManagedCharacter.persona.name+'.md', false, 'UTF-8')] +[printBoardCharacterReport(aManagedCharacter)/] +[/file] +[/template] + +[** + * Print the chracter as a BB board txt. + * +*/] +[template public printBoardCharacterReport(aManagedCharacter : ManagedCharacter) +{ empty :String = '..............................' ; + empty1 :String = '....................' ; +}] +[printBasicCharacterData(aManagedCharacter)/] +[printPersonaBasic(aManagedCharacter,empty)/] + +[printSkillGroup(aManagedCharacter.persona.fertigkeitsGruppen,empty)/] + +[printActiveSkills(aManagedCharacter.persona.fertigkeiten,empty)/] + +[printKnowledgeSkills(aManagedCharacter.persona.fertigkeiten,empty)/] + +[if (aManagedCharacter.persona.oclIsKindOf(Zauberer))] +[let z : Zauberer = aManagedCharacter.persona.oclAsType(Zauberer)] +[printSpells(z,'',empty1)/] +[/let] +[/if] +[if (aManagedCharacter.persona.oclIsKindOf(KiAdept))] +[printKiPowers( aManagedCharacter.persona.oclAsType(KiAdept).kikraft)/] +[/if] +[if (aManagedCharacter.persona.oclIsKindOf(Technomancer))] +[printComplexForms( aManagedCharacter.persona.oclAsType(Technomancer).complexForms )/] +[/if] + +[if (aManagedCharacter.persona.oclIsKindOf(KoerperPersona))] +[let kp : KoerperPersona = aManagedCharacter.persona.oclAsType(KoerperPersona)] +[printQualities(kp.eigenschaften, empty)/] +[printAugmentations(kp.koerperMods, empty)/] +[/let] +[/if] + +[printGear(aManagedCharacter.inventar->asSequence(),empty)/] + +[printContracts(aManagedCharacter.contracts->asSequence(),empty)/] + +[printConnections(aManagedCharacter.connections,empty)/] + +[printVehicles(aManagedCharacter.vehicels,empty)/] + +[if (aManagedCharacter.oclIsTypeOf(PlayerCharacter))] +[printDiary(aManagedCharacter.oclAsType(PlayerCharacter).diary)/] +[/if] + +[printAdvacements(aManagedCharacter.changes)/] + +[printAllCredSticks(aManagedCharacter.inventar->selectByType(Credstick), empty) /] + + +['Notes'.localizedString().boldText()/] +[for (it : OclAny | aManagedCharacter.eContents())] +[if (it.oclIsKindOf(Beschreibbar) and not it.oclIsKindOf(AbstraktPersona))] +[if (not it.oclAsType(Beschreibbar).beschreibung.oclIsUndefined())] +[it.oclAsType(Beschreibbar).name.getText()/] +[it.oclAsType(Beschreibbar).beschreibung.tagText('`')/] +[/if] +[/if] +[/for] + +[/template] + +[template public printComplexForms (pcf : OrderedSet(PersonaKomplexForm)) ? (not pcf->isEmpty()) ] +['_UI_Technomancer_complexForms_feature'.localizedString().titelText()/] +[for (it : PersonaKomplexForm | pcf)] +[it.form.getText()/] +[/for] +[/template] + +[template public printPersonaBasic(aManagedCharacter : ManagedCharacter,empty :String) +{persona : AbstraktPersona = aManagedCharacter.persona ; }] +['Attributes'.titelText()/] +[printAttributes(persona,empty)/] +[printTextPlusSpace('_UI_SpezielleAttribute_essenz_feature'.localizedString(), empty)/] [ (persona.essenz)/100 /] +[printTextPlusSpace('_UI_SpezielleAttribute_initative_feature'.localizedString(), empty)/] [persona.toLocalizedInitative()/] +[if(persona.oclIsKindOf(AstraleProjektion))] +[let ap : AstraleProjektion = persona.oclAsType(AstraleProjektion)] +[printTextPlusSpace('_UI_AstraleProjektion_astraleInitative_feature'.localizedString(), empty)/] [ap.toLocalizedAstralInitative()/] +[/let][/if] +[if (aManagedCharacter.hasMatrixInitative())] +[printTextPlusSpace('Matrix Ini cold', empty)/] [aManagedCharacter.getMatrixInitative()/]+3d6 +[printTextPlusSpace('Matrix Ini hot', empty)/] [aManagedCharacter.getMatrixInitative()/]+4d6 +[/if] +[printTextPlusSpace('Condition', empty)/] [persona.oclAsType(KoerperPersona).zustandKoerperlichMax/]/[persona.oclAsType(KoerperPersona).zustandGeistigMax/] +[printTextPlusSpace('_UI_Panzerung_panzer_feature'.localizedString(), empty)/] [persona.oclAsType(KoerperPersona).panzer/] +[printTextPlusSpace('_UI_BerechneteAttribute_selbstbeherrschung_feature'.localizedString(), empty)/] [persona.oclAsType(KoerperPersona).selbstbeherrschung.toString()/] +[printTextPlusSpace('_UI_BerechneteAttribute_menschenkenntnis_feature'.localizedString(), empty)/] [persona.oclAsType(KoerperPersona).menschenkenntnis/] +[printTextPlusSpace('_UI_BerechneteAttribute_errinerungsvermoegen_feature'.localizedString(), empty)/] [(persona.oclAsType(KoerperPersona).errinerungsvermoegen).toString() /] +[printTextPlusSpace('Lifting/Carrying', empty)/] [persona.liftCarry()/] +[printTextPlusSpace('Movement', empty)/] [persona.movement()/] + +Limits +['_UI_ChrakterLimits_koerperlich_feature'.localizedString()/] [persona.oclAsType(KoerperPersona).koerperlich/] / ['_UI_ChrakterLimits_geistig_feature'.localizedString()/] [persona.oclAsType(KoerperPersona).geistig/] / ['_UI_ChrakterLimits_sozial_feature'.localizedString()/] [persona.oclAsType(KoerperPersona).sozial/] +[/template] + +[** + * Print the qualities +*/] +[template public printAdvacements(changes : OrderedSet(Changes)) ? (not changes->isEmpty()) { empty :String = ' ' ;}] +['_UI_ManagedCharacter_changes_feature'.localizedString().titelText()/] +[for (ag : Changes | changes-> select(changeApplied)-> sortedBy(date) )] +[ printTextPlusSpace(ag.date.formatDateLong()+' '+ getText(ag),empty) /][if (not ag.oclIsTypeOf(KarmaGaint))] [ag.karmaCost/][/if] +[/for] +[/template] + +[** + * Print the qualities +*/] +[template public printQualities(gears : OrderedSet(PersonaEigenschaft),empty :String) ? (not gears->isEmpty())] +['_UI_KoerperPersona_eigenschaften_feature'.localizedString().titelText()/] +[for (ag : PersonaEigenschaft | gears)] +[printTextPlusSpace(ag.getText(),empty)/][ag.karmaKosten/] +[/for] + +[printTextPlusSpace('sum :', empty)/][sumQuallitiyKarma(gears)/] +[/template] + +[** + * Print the kipowers +*/] +[template public printKiPowers(gears : OrderedSet(KiKraft)) ? (not gears->isEmpty())] +['_UI_KiAdept_kikraft_feature'.localizedString().titelText()/] +[for (ag : KiKraft | gears)] +[ag.getText() /] +[/for] +[/template] + + +[** + * Print the wares +*/] +[template public printAugmentations(gears : OrderedSet(Koerpermods),empty :String) ? (not gears->isEmpty()) +] +['_UI_KoerperPersona_koerperMods_feature'.localizedString().titelText()/] +[for (ag : Koerpermods | gears)] +[printTextPlusSpace(ag.getText(),empty)/][ag.oclAsType(GeldWert).wert/] +[/for] + +[printTextPlusSpace('sum :', empty)/][calcListenWertToString(gears->asSequence())/] +[/template] + +[template public printBasicCharacterData(aManagedCharacter : ManagedCharacter)] +['Basic Data'.titelText('##')/] +[let persona : AbstraktPersona = aManagedCharacter.persona] +['_UI_Beschreibbar_name_feature'.localizedString()/]: [persona.name.italicText() /] ['_UI_ManagedCharacter_sex_feature'.localizedString()/] : [aManagedCharacter.sex.sexToName().italicText() /] +['_UI_AbstractPersona_spezies_feature'.localizedString()/]: [persona.spezies.name.italicText()/] Type: [getText( persona.eClass()).italicText() /] + +[if (not (persona.beschreibung.size()=0 ) )] +[persona.beschreibung.quoteText()/] +[/if] +[/let] + +['_UI_ManagedCharacter_nativeLanguage_feature'.localizedString()/]: [aManagedCharacter.nativeLanguage.getText()/] +['_UI_ManagedCharacter_dateofbirth_feature'.localizedString()/]: [aManagedCharacter.dateofbirth.formatDate() /][if (aManagedCharacter.oclIsTypeOf(PlayerCharacter))] ['_UI_ManagedCharacter_age_feature'.localizedString()/]: [aManagedCharacter.oclAsType(PlayerCharacter).age/][/if] +['_UI_ManagedCharacter_karmaGaint_feature'.localizedString()/]: [aManagedCharacter.karmaGaint/] ['_UI_ManagedCharacter_currentKarma_feature'.localizedString()/]: [aManagedCharacter.currentKarma/] +['_UI_ManagedCharacter_streetCred_feature'.localizedString()/]: [aManagedCharacter.streetCred/] ['_UI_ManagedCharacter_notoriety_feature'.localizedString()/]: [aManagedCharacter.notoriety/] +['_UI_ManagedCharacter_height_feature'.localizedString()/]: [aManagedCharacter.height/] cm ['_UI_ManagedCharacter_weight_feature'.localizedString()/]: [aManagedCharacter.weight/] kg + +[/template] + + +[** + * print the attributes the persona, uses the localized text. +*/] +[template public printAttributes(persona : AbstraktPersona,empty :String)] +[for (ea : EAttribute | getOrderedAttibutesForPersona(persona))] +[let attributeName : String = getText(base2Calced(ea))] +[printTextPlusSpace(attributeName, empty)/] [persona.eGet(ea)/][if(not (persona.eGet(ea)=persona.eGet(base2Calced(ea))))]([persona.eGet(base2Calced(ea))/])[/if] +[/let] +[/for] +[/template] + + +[template public printSkillGroup(sg : OrderedSet(PersonaFertigkeitsGruppe),empty :String)] +['_UI_AbstractPersona_fertigkeitsGruppen_feature'.localizedString().titelText()/] +[for (pfg : PersonaFertigkeitsGruppe | sg)] +[printTextPlusSpace(pfg.gruppe.getText(), empty)/] [pfg.stufe/] +[/for] +[/template] + + +[template public printActiveSkills(sg : OrderedSet(PersonaFertigkeit),empty :String)] +['_UI_AbstractPersona_fertigkeiten_feature'.localizedString().titelText()/] +[for (pfg : PersonaFertigkeit | sg)] +[if (not(pfg.fertigkeit.oclIsKindOf(Wissensfertigkeit) ))] +[printTextPlusSpace(pfg.fertigkeit.getText(),empty)/] [pfg.stufe/] +[/if] +[/for] +[/template] + +[template public printKnowledgeSkills(sg : OrderedSet(PersonaFertigkeit),empty :String)] +['Knowledge Skills'.titelText()/] +[for (pfg : PersonaFertigkeit | sg)] +[if ((pfg.fertigkeit.oclIsKindOf(Wissensfertigkeit) ))] +[printTextPlusSpace(pfg.fertigkeit.getText(),empty )/] [pfg.stufe/] +[/if] +[/for] +[/template] + + +[template public printConnections(c : OrderedSet(Connection),empty :String)? (not c->isEmpty())] +['_UI_ManagedCharacter_connections_feature'.localizedString().titelText()/] +[for (connection : Connection | c)] +[printTextPlusSpace(connection.getText(),empty)/] [connection.influence/]/[connection.loyality/] +[/for] +[/template] + +[template public printSpells(z : Zauberer,loc : String,empty :String) ? (not z.zauber->isEmpty())] +['_UI_Zauberer_zauber_feature'.localizedString().titelText()/] +[for (pz : PersonaZauber | z.zauber)] +[printTextPlusSpace(pz.formel.getText(), empty)/] +[/for] +[/template] + +[template public printContracts(gears : Sequence(Vertrag),empty :String)? (not gears->isEmpty())] +['_UI_ManagedCharacter_contracts_feature'.localizedString().titelText()/] +[for (ag : Vertrag | gears)] +[printContract(ag, empty)/] +[/for] + +[printTextPlusSpace('sum :', empty)/] [calcListenWertToString(gears) /] +[/template] + +[template public printContract(c : Vertrag,empty :String)] +[printTextPlusSpace(c.getText(),empty)/] [c.wert.formatMoney()/] +[/template] + +[template public printContract(c : Lifestyle,empty :String)] +[printTextPlusSpace(c.getText(),empty)/] [c.wertValue.formatMoney()/]/[c.wert.formatMoney()/] +[for (l : LifestyleOption | c.options)] +- [printTextPlusSpace(l.getText(),empty)/] [l.wert.formatMoney()/] +[/for] +[/template] + +[template public printContract(c : Sin,empty :String)] +[printTextPlusSpace(c.getText(),empty)/] [c.wertValue.formatMoney()/]/[c.wert.formatMoney()/] +[for (l : Lizenz | c.licences)] +- [printTextPlusSpace(l.getText(),empty)/] [l.wert.formatMoney()/] +[/for] +[/template] + +[template public printVehicles(sg : OrderedSet(Fahrzeug),empty :String)? (not sg->isEmpty())] +['_UI_ManagedCharacter_vehicels_feature'.localizedString().titelText()/] +[for (pfg : Fahrzeug | sg)] +[printVehicle(pfg, empty)/] +[/for] + +[printTextPlusSpace('sum :', empty)/] [calcListenWertToString(sg->asSequence()) /] +[/template] + +[template private printVehicle(vehicle : Fahrzeug,empty :String)] +[printTextPlusSpace(vehicle.getText() ,empty)/] [vehicle.wertValue /] +[if (not vehicle.modifizierungen->isEmpty())][printGeldwertCollection(vehicle.modifizierungen, vehicle.wert,empty, '- ')/][/if] [/template] + +[template private printVehicle(vehicle : Drohne,empty :String)] +[printTextPlusSpace(vehicle.getText() ,empty)/] [vehicle.wertValue /] +[if (not vehicle.modifizierungen->isEmpty())] +[printGeldwertCollection(vehicle.modifizierungen, vehicle.wert,empty, '- ')/][/if] +[if (not vehicle.storedPrograms->isEmpty())] +[printGeldwertCollection(vehicle.storedPrograms, vehicle.wert,empty, '- ')/][/if][/template] + +[template public printGear(gears : Sequence(AbstraktGegenstand), empty :String)? (not gears->isEmpty())] +['_UI_ManagedCharacter_inventar_feature'.localizedString().titelText()/] +[for (ag : AbstraktGegenstand | gears)] +[printGegenstand(ag, empty)/] +[/for] + +[printTextPlusSpace('sum :', empty)/] [calcListenWertToString(gears) /] +[/template] + + +[template public printDiary(diary : CharacterDiary)] +['Diary'.localizedString().titelText()/] +Current Date: [diary.characterDate/] +[for (de : DiaryEntry | diary.entries -> sortedBy(characterDate))] +[printDiaryEntry(de)/] +[/for] +[/template] + +[template public printDiaryEntry (aDiaryEntry : DiaryEntry) ] +[aDiaryEntry.date.formatDateLong().boldText()/]: [aDiaryEntry.message/] +[/template] + +[template public printDiaryEntry (aDiaryEntry : TrainingsTime) ] +[aDiaryEntry.date.formatDateLong().boldText()/]: ['training for'.localizedString()/] [aDiaryEntry.change.getText()/] +[for (tr : TrainingRange | aDiaryEntry.training)] + * [tr.start.formatDate()/] - [tr.end.formatDate()/] : [tr.daysTrained/] ['Days_Trained'.localizedString()/] +[/for][/template] + +[template public printAllCredSticks(cs : OrderedSet(Credstick), empty :String)] +['Credsticks'.localizedString().titelText()/] +[for (credstick : Credstick | cs)] +[printCredStick(credstick, empty) /] +[/for] +[/template] + + +[template public printCredStick(credstick : Credstick, empty :String)] +[printTextPlusSpace('Credstick: '.concat(credstick.getText()), empty)/] +[for (t : CredstickTransaction | credstick.transactionlog)] +[if (t.oclIsTypeOf(ShoppingTransaction))] +Shopping list: +[printSoppingTransaction(t.oclAsType(ShoppingTransaction))/] +[else] +[t.date.formatDate() /] [t.description.italicText()/] [t.amount.formatMoney()/] +[/if] +[/for] +[printTextPlusSpace('Saldo :', empty)/] [credstick.currentValue.formatMoney() /] + +[/template] + + +[template public printSoppingTransaction(ta : ShoppingTransaction)] +[for (gw : GeldWert | ta.items)] +[gw.getText()/] [gw.oclAsType(Quelle).srcBook.getText()/] [gw.wertValue.formatMoney()/] +[/for] +calculated costs: [ta.caculatedCosts.formatMoney()/] (incuding [ta.fee/] fee) +[/template] + +[template private printGegenstand(gegenstand : AbstraktGegenstand,empty :String)] +[printTextPlusSpace(gegenstand.getText(),empty)/] [gegenstand.wert.formatMoney()/] +[/template] + +[template private printGegenstand(comlink : Commlink,empty :String)] +[printTextPlusSpace(comlink.getText() ,empty)/] [comlink.wertValue.formatMoney() /] +[printGeldwertCollection(comlink.storedPrograms, comlink.wert,empty, '- ')/] [/template] + +[template private printGegenstand(comlink : RiggerCommandConsole,empty :String)] +[printTextPlusSpace(comlink.getText() ,empty)/] [comlink.wertValue.formatMoney() /] +[printGeldwertCollection(comlink.storedPrograms,comlink.wert, empty, '- ')/] [/template] + +[template private printGegenstand(comlink : Cyberdeck,empty :String)] +[printTextPlusSpace(comlink.getText() ,empty)/] [comlink.wertValue.formatMoney() /] +[if (not comlink.storedPrograms->isEmpty())][printGeldwertCollection(comlink.storedPrograms, comlink.wert,empty, '- ')/][/if] [/template] + +[template public printGeldwertCollection(col : OrderedSet(GeldWert),wert: EBigDecimal ,empty :String,prefix : String)? (not col->isEmpty()) +post(trim()) +][for (gw : GeldWert | col)] +[printTextPlusSpace(prefix+gw.getText() ,empty)/] [gw.wert.formatMoney()/] +[/for] +[printTextPlusSpace('sum :', empty)/] [wert.formatMoney()/] [/template] diff --git a/de.urszeidler.shr5.acceleo/src/de/urszeidler/shr5/acceleo/util/ShadowrunTextTools.java b/de.urszeidler.shr5.acceleo/src/de/urszeidler/shr5/acceleo/util/ShadowrunTextTools.java index 5f00d5084..adc290989 100644 --- a/de.urszeidler.shr5.acceleo/src/de/urszeidler/shr5/acceleo/util/ShadowrunTextTools.java +++ b/de.urszeidler.shr5.acceleo/src/de/urszeidler/shr5/acceleo/util/ShadowrunTextTools.java @@ -52,6 +52,7 @@ public class ShadowrunTextTools { private static KomplexeForm komplexForm = Shr5Factory.eINSTANCE.createKomplexeForm(); private static NonPlayerCharacter character = Shr5managementFactory.eINSTANCE.createNonPlayerCharacter(); private static Feuerwaffe fiereweapon = Shr5Factory.eINSTANCE.createFeuerwaffe(); + private static DateFormat dateFormatLong = DateFormat.getDateInstance(DateFormat.FULL); private static DateFormat dateFormat = DateFormat.getDateInstance(DateFormat.SHORT); private static DateFormat dateTimeFormat = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT); private static DateFormat dateTimeFormatSec = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.LONG); @@ -197,6 +198,13 @@ public static String formatMoney(BigDecimal decimal) { + public static String formatDateLong(Date date) { + if(date==null) + return "unset"; + + return dateFormatLong.format(date); + } + public static String formatDate(Date date) { if(date==null) return "unset"; diff --git a/de.urszeidler.shr5.acceleo/src/de/urszeidler/shr5/acceleo/util/shadowrunTextTools.mtl b/de.urszeidler.shr5.acceleo/src/de/urszeidler/shr5/acceleo/util/shadowrunTextTools.mtl index 2c139ecaa..960d5ac8d 100644 --- a/de.urszeidler.shr5.acceleo/src/de/urszeidler/shr5/acceleo/util/shadowrunTextTools.mtl +++ b/de.urszeidler.shr5.acceleo/src/de/urszeidler/shr5/acceleo/util/shadowrunTextTools.mtl @@ -49,6 +49,9 @@ [query public formatDate(object : OclAny) : String = invoke('de.urszeidler.shr5.acceleo.util.ShadowrunTextTools', 'formatDate(java.util.Date)', Sequence{object}) /] +[query public formatDateLong(object : OclAny) : String + = invoke('de.urszeidler.shr5.acceleo.util.ShadowrunTextTools', 'formatDateLong(java.util.Date)', Sequence{object}) +/] [query public formatDateTime(object : OclAny) : String = invoke('de.urszeidler.shr5.acceleo.util.ShadowrunTextTools', 'formatDateTime(java.util.Date)', Sequence{object}) /]