Skip to content

Commit

Permalink
Merge pull request #18 from mdal-lang/improve-modularity
Browse files Browse the repository at this point in the history
Improve modularity
  • Loading branch information
joneug authored Dec 16, 2020
2 parents d73921b + af74d9b commit d2ecedb
Show file tree
Hide file tree
Showing 19 changed files with 1,085 additions and 236 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ allprojects {
}

subprojects {
ext.xtextVersion = '2.21.0'
ext.xtextVersion = '2.23.0'
repositories {
mavenCentral()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,28 @@ class MdalLanguageServerTest extends AbstractLanguageServerTest {
val capabilities = initialize().capabilities
assertTrue(capabilities.definitionProvider && capabilities.documentFormattingProvider)
}

@Test
def void testMinimalModel() {
initialize()

val file = 'seminar.mdal'.writeFile("")
file.open('''
solution "Seminar Management" {
Prefix = "SEM";
master "Seminar" {
ShortName = "Sem.";
fields {
template("Description"; Description)
}
}
}
''')
val diagnostics = diagnostics.get(file)
assertTrue('''Unexpected errors: «diagnostics»''', diagnostics.empty)
}

@Test
def void testCorrectModel() {
Expand Down
2 changes: 1 addition & 1 deletion de.joneug.mdal.standalone/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ dependencies {
implementation "org.eclipse.xtext:org.eclipse.xtext:${xtextVersion}"
implementation "org.eclipse.xtext:org.eclipse.xtext.xbase:${xtextVersion}"
implementation "com.google.code.gson:gson:2.8.6"
implementation 'info.picocli:picocli:4.3.2'
implementation 'info.picocli:picocli:4.5.2'
}

apply plugin: 'application'
Expand Down
6 changes: 3 additions & 3 deletions de.joneug.mdal/src/main/java/de/joneug/mdal/Mdal.xtext
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ Solution:
'solution' name=STRING '{'
(
('Prefix' '=' prefix=STRING ';')? &
(master=Master) &
(master=Master)? &
(supplementals+=Supplemental)* &
(document=Document) &
(ledgerEntry=LedgerEntry)
(document=Document)? &
(ledgerEntry=LedgerEntry)?
)
'}'
;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,10 +145,12 @@ class DocumentExtensions {
document.line.doGenerate

// Codeunits
document.saveCodeunit(document.codeunitNamePost, document.doGenerateCodeunitPost)
document.saveCodeunit(document.codeunitNamePostYesNo, document.doGenerateCodeunitPostYesNo)
document.saveCodeunit(document.codeunitNameJnlCheckLine, document.doGenerateCodeunitJnlCheckLine)
document.saveCodeunit(document.codeunitNameJnlPostLine, document.doGenerateCodeunitJnlPostLine)
if (document.solution.ledgerEntry !== null) {
document.saveCodeunit(document.codeunitNamePost, document.doGenerateCodeunitPost)
document.saveCodeunit(document.codeunitNamePostYesNo, document.doGenerateCodeunitPostYesNo)
document.saveCodeunit(document.codeunitNameJnlCheckLine, document.doGenerateCodeunitJnlCheckLine)
document.saveCodeunit(document.codeunitNameJnlPostLine, document.doGenerateCodeunitJnlPostLine)
}
}

static def doGenerateStatusEnum(Document document) '''
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1295,31 +1295,33 @@ class DocumentHeaderExtensions {
ToolTip = 'View or add comments for the record.';
}
}
group("P&osting")
{
Caption = 'P&osting';
Image = Post;
action(Post)
{
ApplicationArea = All;
Caption = 'P&ost';
Ellipsis = true;
Image = PostOrder;
Promoted = true;
PromotedCategory = Category7;
PromotedIsBig = true;
ShortCutKey = 'F9';
ToolTip = 'Finalize the document or journal by posting the amounts and quantities to the related accounts in your company books.';

trigger OnAction()
var
«document.codeunitVariableNamePostYesNo»: Codeunit «document.codeunitNamePostYesNo.saveQuote»;
begin
«document.codeunitVariableNamePostYesNo».Run(Rec);
CurrPage.Update(false);
end;
}
}
«IF document.solution.ledgerEntry !== null»
group("P&osting")
{
Caption = 'P&osting';
Image = Post;
action(Post)
{
ApplicationArea = All;
Caption = 'P&ost';
Ellipsis = true;
Image = PostOrder;
Promoted = true;
PromotedCategory = Category7;
PromotedIsBig = true;
ShortCutKey = 'F9';
ToolTip = 'Finalize the document or journal by posting the amounts and quantities to the related accounts in your company books.';

trigger OnAction()
var
«document.codeunitVariableNamePostYesNo»: Codeunit «document.codeunitNamePostYesNo.saveQuote»;
begin
«document.codeunitVariableNamePostYesNo».Run(Rec);
CurrPage.Update(false);
end;
}
}
«ENDIF»
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,12 +139,14 @@ class MasterExtensions {
CommentLine.SetRange("No.", "No.");
CommentLine.DeleteAll();

«document.header.tableVariableName».SetCurrentKey("«master.cleanedName» No.");
«document.header.tableVariableName».SetRange("«master.cleanedName» No.", "No.");
IF NOT «document.header.tableVariableName».IsEmpty THEN
Error(
ExistingDocumentsErr,
TableCaption, "No.", «document.header.tableVariableName».TableCaption);
«IF document !== null»
«document.header.tableVariableName».SetCurrentKey("«master.cleanedName» No.");
«document.header.tableVariableName».SetRange("«master.cleanedName» No.", "No.");
IF NOT «document.header.tableVariableName».IsEmpty THEN
Error(
ExistingDocumentsErr,
TableCaption, "No.", «document.header.tableVariableName».TableCaption);
«ENDIF»
end;

trigger OnRename()
Expand All @@ -158,8 +160,10 @@ class MasterExtensions {
NoSeriesMgt: Codeunit NoSeriesManagement;
CommentLine: Record "Comment Line";
«master.tableVariableName»: Record "«master.tableName»";
«document.header.tableVariableName»: Record "«document.header.tableName»";
ExistingDocumentsErr: Label 'You cannot delete %1 %2 because there is at least one outstanding %3 for this «master.name».';
«IF document !== null»
«document.header.tableVariableName»: Record "«document.header.tableName»";
ExistingDocumentsErr: Label 'You cannot delete %1 %2 because there is at least one outstanding %3 for this «master.name».';
«ENDIF»
«IF master.hasTemplateOfType(TemplateDimensions
DimMgt: Codeunit DimensionManagement;
«ENDIF»
Expand Down Expand Up @@ -379,22 +383,24 @@ class MasterExtensions {
}
}
}
area(creation)
{
action(New«document.cleanedName»)
{
AccessByPermission = tabledata «document.header.tableName.saveQuote» = RIM;
ApplicationArea = All;
Caption = '«document.name»';
Image = NewDocument;
Promoted = true;
PromotedCategory = Category4;
RunObject = Page «document.documentPageName.saveQuote»;
RunPageLink = "«master.name» No." = field("No.");
RunPageMode = Create;
Visible = NOT IsOfficeAddin;
}
}
«IF document !== null»
area(creation)
{
action(New«document.cleanedName»)
{
AccessByPermission = tabledata «document.header.tableName.saveQuote» = RIM;
ApplicationArea = All;
Caption = '«document.name»';
Image = NewDocument;
Promoted = true;
PromotedCategory = Category4;
RunObject = Page «document.documentPageName.saveQuote»;
RunPageLink = "«master.name» No." = field("No.");
RunPageMode = Create;
Visible = NOT IsOfficeAddin;
}
}
«ENDIF»
}

var
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,37 +35,45 @@ class SolutionExtensions {
static def doGenerate(Solution solution) {
solution.logInfo("Generating solution '" + solution.name + "'")

// Setup
solution.logInfo("Generating setup files")
solution.doGenerateSetup
if (solution.master !== null || solution.document !== null) {
// Setup
solution.logInfo("Generating setup files")
solution.doGenerateSetup
}

// Comments
solution.logInfo("Generating comment files")
solution.doGenerateCommentObjects

// Source Code Setup
solution.logInfo("Generating source code setup files")
solution.doGenerateSourceCodeSetupObjects

// Master
solution.logInfo("Generating master files")
solution.master.doGenerate
if (solution.master !== null) {
// Master
solution.logInfo("Generating master files")
solution.master.doGenerate
}

// Supplementals
solution.logInfo("Generating supplemental files")
solution.supplementals.forEach[it.doGenerate]

// Document
solution.logInfo("Generating document files")
solution.document.doGenerate

// Ledger Entry
solution.logInfo("Generating ledger entry files")
solution.ledgerEntry.doGenerate

// Navigate Extensions
solution.logInfo("Generating navigate files")
solution.doGenerateNavigateExtensionObjects
if (solution.document !== null) {
// Document
solution.logInfo("Generating document files")
solution.document.doGenerate

// Ledger Entry
if (solution.ledgerEntry !== null) {
solution.logInfo("Generating ledger entry files")
solution.ledgerEntry.doGenerate
}

// Source Code Setup
solution.logInfo("Generating source code setup files")
solution.doGenerateSourceCodeSetupObjects

// Navigate Extensions
solution.logInfo("Generating navigate files")
solution.doGenerateNavigateExtensionObjects
}
}

/*
Expand Down Expand Up @@ -111,22 +119,24 @@ class SolutionExtensions {
Caption = '«solution.master.cleanedName» Nos.';
TableRelation = "No. Series";
}
field(3; "«solution.document.shortName» Nos."; Code[20])
{
Caption = '«solution.document.shortName» Nos.';
TableRelation = "No. Series";
}
field(4; "«solution.document.shortNamePosted» Nos."; Code[20])
{
Caption = '«solution.document.shortNamePosted» Nos.';
TableRelation = "No. Series";
}
field(10; "Copy Comments"; Boolean)
{
AccessByPermission = TableData «solution.document.header.tableNamePosted.saveQuote» = R;
Caption = 'Copy Comments To Posted Reg.';
InitValue = true;
}
«IF solution.document !== null»
field(3; "«solution.document.shortName» Nos."; Code[20])
{
Caption = '«solution.document.shortName» Nos.';
TableRelation = "No. Series";
}
field(4; "«solution.document.shortNamePosted» Nos."; Code[20])
{
Caption = '«solution.document.shortNamePosted» Nos.';
TableRelation = "No. Series";
}
field(10; "Copy Comments"; Boolean)
{
AccessByPermission = TableData «solution.document.header.tableNamePosted.saveQuote» = R;
Caption = 'Copy Comments To Posted Reg.';
InitValue = true;
}
«ENDIF»
}

keys
Expand Down Expand Up @@ -165,15 +175,17 @@ class SolutionExtensions {
{
area(content)
{
group(General)
{
Caption = 'General';

field("Copy Comments"; "Copy Comments")
{
ApplicationArea = All;
}
}
«IF solution.document !== null»
group(General)
{
Caption = 'General';

field("Copy Comments"; "Copy Comments")
{
ApplicationArea = All;
}
}
«ENDIF»
group("Number Series")
{
Caption = 'Number Series';
Expand All @@ -182,14 +194,16 @@ class SolutionExtensions {
{
ApplicationArea = All;
}
field("«solution.document.shortName» Nos."; "«solution.document.shortName» Nos.")
{
ApplicationArea = All;
}
field("«solution.document.shortNamePosted» Nos."; "«solution.document.shortNamePosted» Nos.")
{
ApplicationArea = All;
}
«IF solution.document !== null»
field("«solution.document.shortName» Nos."; "«solution.document.shortName» Nos.")
{
ApplicationArea = All;
}
field("«solution.document.shortNamePosted» Nos."; "«solution.document.shortNamePosted» Nos.")
{
ApplicationArea = All;
}
«ENDIF»
}
}
}
Expand All @@ -214,12 +228,16 @@ class SolutionExtensions {
*/
static def void doGenerateCommentObjects(Solution solution) {
solution.saveEnumExt(solution.commentLineTableNameEnumExtName, solution.doGenerateCommentLineTableNameEnumExt)
solution.saveEnum(solution.commentDocumentTypeEnumName, solution.doGenerateCommentDocumentTypeEnum)
solution.saveTableExt(solution.commentLineTableExtName, solution.doGenerateCommentLineTableExtName)
solution.saveTable(solution.commentLineTableName, solution.doGenerateCommentLineTable)
solution.savePage(solution.commentListPageName, solution.doGenerateCommentListPage)
solution.savePage(solution.commentSheetPageName, solution.doGenerateCommentSheetPage)
if (solution.master !== null) {
solution.saveEnumExt(solution.commentLineTableNameEnumExtName, solution.doGenerateCommentLineTableNameEnumExt)
solution.saveTableExt(solution.commentLineTableExtName, solution.doGenerateCommentLineTableExtName)
}
if (solution.document !== null) {
solution.saveEnum(solution.commentDocumentTypeEnumName, solution.doGenerateCommentDocumentTypeEnum)
solution.saveTable(solution.commentLineTableName, solution.doGenerateCommentLineTable)
solution.savePage(solution.commentListPageName, solution.doGenerateCommentListPage)
solution.savePage(solution.commentSheetPageName, solution.doGenerateCommentSheetPage)
}
}
static def getCommentLineTableNameEnumExtName(Solution solution) {
Expand Down
Loading

0 comments on commit d2ecedb

Please sign in to comment.