Skip to content

Commit

Permalink
Polishing/fixing
Browse files Browse the repository at this point in the history
  • Loading branch information
pvlasov committed Aug 27, 2024
1 parent 6a2377d commit f5aceb6
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,12 @@
import org.nasdanika.cli.ResourceSetMixIn;
import org.nasdanika.common.ProgressMonitor;
import org.nasdanika.common.Util;
import org.nasdanika.drawio.Document;
import org.nasdanika.html.model.app.Action;
import org.nasdanika.html.model.app.Label;
import org.nasdanika.html.model.app.util.LabelSupplier;

import picocli.CommandLine.Mixin;
import picocli.CommandLine.Option;
import picocli.CommandLine.ParentCommand;

/**
* Base class for action supplier commands.
Expand All @@ -27,10 +25,7 @@
*
*/
public abstract class AbstractHtmlAppGeneratorCommand extends CommandGroup implements LabelSupplier {

@ParentCommand
private Document.Supplier documentSupplier;


protected abstract Collection<Label> getLabels(ProgressMonitor progressMonitor);

@Mixin
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ public class DrawioHtmlAppGeneratorCommand extends AbstractHtmlAppGeneratorComma
@ParentCommand
private Document.Supplier documentSupplier;

protected Consumer<Diagnostic> createDiagnosticConsumer() {
return d -> d.dump(System.out, 0);
protected Consumer<Diagnostic> createDiagnosticConsumer(ProgressMonitor progressMonitor) {
return d -> progressMonitor.worked(d.getStatus(), 1, "Diagnostic: " + d.getMessage(), d);
}

protected DrawioActionGenerator createDrawioActionGenerator() {
Expand Down Expand Up @@ -63,7 +63,7 @@ protected Collection<Label> getLabels(ProgressMonitor progressMonitor) {
Document document = documentSupplier.getDocument(progressMonitor);
DrawioActionGenerator actionGenerator = createDrawioActionGenerator();
Supplier<Collection<Label>> labelSupplier = actionGenerator.createLabelsSupplier(document, progressMonitor);
Consumer<Diagnostic> diagnosticConsumer = createDiagnosticConsumer();
Consumer<Diagnostic> diagnosticConsumer = createDiagnosticConsumer(progressMonitor);
return labelSupplier.call(progressMonitor, diagnosticConsumer);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ protected Collection<Label> getLabels(ProgressMonitor progressMonitor) {
try {
Context context = contextMixin.createContext(progressMonitor);
EObject source = eObjectSupplier.getEObject(progressMonitor);
Consumer<Diagnostic> diagnosticConsumer = createDiagnosticConsumer();
Consumer<Diagnostic> diagnosticConsumer = createDiagnosticConsumer(progressMonitor);
HtmlAppGenerator generator = createHtmlAppGenerator(progressMonitor, context, source, diagnosticConsumer);
Map<EObject, Collection<Label>> labelMap = generator.generateHtmlAppModel(diagnosticConsumer, progressMonitor);
return flatMap(labelMap);
Expand Down Expand Up @@ -73,8 +73,8 @@ protected Collection<Label> flatMap(Map<EObject, Collection<Label>> labelMap) {

}

protected Consumer<Diagnostic> createDiagnosticConsumer() {
return d -> d.dump(System.out, 0);
protected Consumer<Diagnostic> createDiagnosticConsumer(ProgressMonitor progressMonitor) {
return d -> progressMonitor.worked(d.getStatus(), 1, "Diagnostic: " + d.getMessage(), d);
}

protected java.util.function.BiFunction<URI, ProgressMonitor, Label> createPrototypeProvider(ProgressMonitor progressMonitor) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,10 @@ protected ProgressMonitor createProgressMonitor() {
errorCount += ee.getValue().size();
}
progressMonitor.worked(Status.ERROR, 1, "There are " + errorCount + " page errors");
return Math.abs(errors.size() - errorCount);
if (pageErrors == -1) {
return 0;
}
return Math.abs(pageErrors - errorCount);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -171,12 +171,14 @@ public static <T extends HtmlAppGenerator> T load(
contributorPredicate);

Map<EPackage, URI> references = new IdentityHashMap<EPackage, URI>();
for (CapabilityProvider<Object> ePackageProvider: capabilityLoader.load(contributorRequirement, progressMonitor)) {
ePackageProvider.getPublisher().subscribe(contributor -> {
EPackageResourceSetContributor ePackageResourceSetContributor = (EPackageResourceSetContributor) contributor;
URI docURI = ePackageResourceSetContributor.getDocumentationURI();
if (docURI != null) {
references.put(ePackageResourceSetContributor.getEPackage(), docURI);
for (CapabilityProvider<Object> resourceSetContributorProvider: capabilityLoader.load(contributorRequirement, progressMonitor)) {
resourceSetContributorProvider.getPublisher().subscribe(contributor -> {
if (contributor instanceof EPackageResourceSetContributor) {
EPackageResourceSetContributor ePackageResourceSetContributor = (EPackageResourceSetContributor) contributor;
URI docURI = ePackageResourceSetContributor.getDocumentationURI();
if (docURI != null) {
references.put(ePackageResourceSetContributor.getEPackage(), docURI);
}
}
});
}
Expand Down

0 comments on commit f5aceb6

Please sign in to comment.