Skip to content

Commit

Permalink
content update and expression refactoring
Browse files Browse the repository at this point in the history
* german quotes, new countries
* generator for title/quality overview
* support more than 4 news choices
* prepare helpers for translation analysis
* variable expression refactoring including validation
* single quote strings for availability script attribute
* unify title/nickname for roles and persons, id->guid
* custom lexer for quote handling
* configurable duplicate language string validation
  • Loading branch information
nittka committed Nov 17, 2024
1 parent dff50b6 commit 2c4ace7
Show file tree
Hide file tree
Showing 32 changed files with 1,080 additions and 298 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.security.MessageDigest;
import java.util.TreeMap;

import javax.xml.parsers.DocumentBuilder;
Expand Down Expand Up @@ -51,8 +52,36 @@ public void iterateFolder() throws IOException {
write(ads, "ads/"+normName);
write(news, "news/"+normName);
write(scripts, "scripts/"+normName);
printDiffs();
}


private void printDiffs() {
try {
MessageDigest hash= MessageDigest.getInstance("SHA-256");
File parent=new File("target/dbcompare/");
if(parent.exists() && parent.isDirectory()) {
for (File subDir : parent.listFiles()) {
if(subDir.exists() && subDir.isDirectory()) {
File[] files = subDir.listFiles();
if(files!=null && files.length==2){
File f1 = files[0];
File f2 = files[1];
String b1 = new String(hash.digest(Files.toByteArray(f1)));
String b2 = new String(hash.digest(Files.toByteArray(f2)));
if(!b1.equals(b2)) {
System.err.println("diff in "+subDir.getName());
}
}
}
}
}else {
System.out.println("no compare directory found");
}
} catch (Exception e) {
e.printStackTrace();
}
}

@Test
public void normalizePersons() throws IOException {
parsePersonFile("persons/db_orig.xml");
Expand Down
9 changes: 9 additions & 0 deletions org.tvtower.db.ui/src/org/tvtower/db/ui/DatabaseUiModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,14 @@
package org.tvtower.db.ui;

import org.eclipse.ui.plugin.AbstractUIPlugin;
import org.eclipse.xtext.ide.LexerIdeBindings;
import org.eclipse.xtext.ide.editor.contentassist.antlr.internal.Lexer;
import org.eclipse.xtext.ui.editor.hover.IEObjectHover;
import org.eclipse.xtext.ui.editor.hover.IEObjectHoverProvider;
import org.eclipse.xtext.ui.editor.outline.actions.OutlineWithEditorLinker;
import org.eclipse.xtext.ui.editor.toggleComments.DefaultSingleLineCommentHelper;
import org.eclipse.xtext.ui.validation.AbstractValidatorConfigurationBlock;
import org.tvtower.db.ui.contentassist.CustomDatabaseLexer;
import org.tvtower.db.ui.hover.DatabaseEObjectHover;
import org.tvtower.db.ui.hover.DatabaseHoverProvider;
import org.tvtower.db.ui.outline.DatabaseOutlineWithEditorLinker;
Expand Down Expand Up @@ -49,4 +52,10 @@ public void configure(Binder binder) {
binder.bind(String.class).annotatedWith(Names.named(DefaultSingleLineCommentHelper.SL_COMMENT))
.toInstance("thereIsNoSLComment");
}

@Override
public void configureContentAssistLexer(Binder binder) {
binder.bind(Lexer.class).annotatedWith(Names.named(LexerIdeBindings.CONTENT_ASSIST))
.to(CustomDatabaseLexer.class);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ public class DatabaseValidatorConfigurationBlock extends AbstractValidatorConfig
@Override
protected void fillSettingsPage(Composite composite, int nColumns, int defaultIndent) {
addComboBox(DatabaseConfigurableIssueCodesProvider.UNSUPPORTED_ATTRIBUTE, "unsupported attribute", composite, defaultIndent);
addCheckBox(composite, "check availability effects (slow and buggy - activate on demand)", DatabaseConfigurableIssueCodesProvider.VALIDATTE_EFFECT_ACTIVATION, new String[] { IPreferenceStore.TRUE, IPreferenceStore.FALSE }, defaultIndent);
addComboBox(DatabaseConfigurableIssueCodesProvider.VALIDATE_LOCALIZATION_DUPLICATES, "localization duplicates", composite, defaultIndent);
addCheckBox(composite, "check availability effects (slow and buggy - activate on demand)", DatabaseConfigurableIssueCodesProvider.VALIDATE_EFFECT_ACTIVATION, new String[] { IPreferenceStore.TRUE, IPreferenceStore.FALSE }, defaultIndent);

Composite section = createSection("News", composite, nColumns);
addComboBox(DatabaseConfigurableIssueCodesProvider.TRIGGERED_NEWS_THREAD, "triggered news: different thread id", section, defaultIndent);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package org.tvtower.db.ui.contentassist;

import org.antlr.runtime.CharStream;
import org.antlr.runtime.RecognitionException;
import org.antlr.runtime.RecognizerSharedState;
import org.tvtower.db.LexerOverrider;
import org.tvtower.db.ide.contentassist.antlr.internal.InternalDatabaseLexer;

//lexer overriding adapted from the code I wrote for Xturtle (https://github.com/AKSW/Xturtle/blob/develop/de.itemis.tooling.xturtle/src/de/itemis/tooling/xturtle/CustomXturtleLexer.java)
public class CustomDatabaseLexer extends InternalDatabaseLexer {

LexerOverrider overrider = new LexerOverrider();

public CustomDatabaseLexer() {
super();
}

public CustomDatabaseLexer(CharStream input) {
this(input, new RecognizerSharedState());
}

public CustomDatabaseLexer(CharStream input, RecognizerSharedState state) {
super(input, state);

}

@Override
public void mTokens() throws RecognitionException {
if (overrider.override(input, state)) {
// done
} else {
super.mTokens();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -178,18 +178,6 @@ public void completeAdConditions_ProhibitedProgrammeFlag(EObject model, Assignme
flagProposal(Constants.programmeFlag, acceptor, context);
}

@Override
public void completeAdConditions_AllowedProgrammeType(EObject model, Assignment assignment,
ContentAssistContext context, ICompletionProposalAcceptor acceptor) {
mapProposal(Constants.programmeType, acceptor, context);
}

@Override
public void completeAdConditions_ProhibitedProgrammeType(EObject model, Assignment assignment,
ContentAssistContext context, ICompletionProposalAcceptor acceptor) {
mapProposal(Constants.programmeType, acceptor, context);
}

@Override
public void completeAdConditions_ProPressureGroup(EObject model, Assignment assignment,
ContentAssistContext context, ICompletionProposalAcceptor acceptor) {
Expand Down Expand Up @@ -610,6 +598,12 @@ public void completeJob_Required(EObject model, Assignment assignment, ContentAs
mapProposal(Constants._boolean, acceptor, context);
}

@Override
public void completeJob_RandomRole(EObject model, Assignment assignment, ContentAssistContext context,
ICompletionProposalAcceptor acceptor) {
mapProposal(Constants._boolean, acceptor, context);
}

@Override
public void completeScriptGenres_MainGenre(EObject model, Assignment assignment, ContentAssistContext context,
ICompletionProposalAcceptor acceptor) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import org.tvtower.db.database.Effect;
import org.tvtower.db.database.News;
import org.tvtower.db.database.NewsItem;
import org.tvtower.db.database.NewsProbabilities;
import org.tvtower.db.database.Person;
import org.tvtower.db.database.Programme;
import org.tvtower.db.database.ScriptTemplate;
Expand Down Expand Up @@ -79,11 +80,12 @@ protected void _createChildren(IOutlineNode parent, NewsItem n) {
}

protected void createNode(IOutlineNode parent, Effect e) {
maybeCreateTriggeredNewsNode(parent, e, e.getNews(), DatabasePackage.eINSTANCE.getEffect_News());
maybeCreateTriggeredNewsNode(parent, e, e.getNews1(), DatabasePackage.eINSTANCE.getEffect_News1());
maybeCreateTriggeredNewsNode(parent, e, e.getNews2(), DatabasePackage.eINSTANCE.getEffect_News2());
maybeCreateTriggeredNewsNode(parent, e, e.getNews3(), DatabasePackage.eINSTANCE.getEffect_News3());
maybeCreateTriggeredNewsNode(parent, e, e.getNews4(), DatabasePackage.eINSTANCE.getEffect_News4());
NewsProbabilities news = e.getNews();
if(news!=null) {
news.getNews().forEach(n->{
maybeCreateTriggeredNewsNode(parent, e, n.getNews(), DatabasePackage.eINSTANCE.getNewsProbability_News());
});
}
}

protected void maybeCreateTriggeredNewsNode(IOutlineNode outlineParent, Effect parentEffect, NewsItem triggeredNews,
Expand Down
Loading

0 comments on commit 2c4ace7

Please sign in to comment.