Skip to content

Commit

Permalink
uri -> getUri()
Browse files Browse the repository at this point in the history
  • Loading branch information
pvlasov committed Jun 29, 2024
1 parent 717afd1 commit 3947f97
Show file tree
Hide file tree
Showing 4 changed files with 87 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -635,7 +635,7 @@ public final void setEStructuralFeatureEndpoint(EReferenceConnection connection,

protected Object parameterTypes(WidgetFactory widgetFactory, URI base, ProgressMonitor progressMonitor) {
if (base == null) {
base = uri;
base = getUri();
}
EOperationNodeProcessor eOperationNodeProcessor = (EOperationNodeProcessor) widgetFactory;
Map<EReferenceConnection, WidgetFactory> eParameterWidgetFactories = eOperationNodeProcessor.getEParameterWidgetFactories();
Expand Down Expand Up @@ -703,7 +703,7 @@ protected Action createLoadSpecificationAction(Action parent, ProgressMonitor pr
key = "<b>" + key + "</b>";
}
if (featureWidgetFactory.hasLoadSpecificationAction()) {
URI loadSpecURI = featureWidgetFactory.getLoadSpecRef(uri);
URI loadSpecURI = featureWidgetFactory.getLoadSpecRef(getUri());
key = "<a href=\"" + loadSpecURI + "\">" + key + "</a>";
}
return key;
Expand Down Expand Up @@ -1077,7 +1077,7 @@ record EClassifierKey(String nsURI, String name) {}
Function<EClassifier, CompletableFuture<DiagramElement>> diagramElementProvider = k -> diagramElementsMap.computeIfAbsent(new EClassifierKey(k.getEPackage().getNsURI(), k.getName()), kk -> new CompletableFuture<>());
Function<EClassifier, CompletionStage<DiagramElement>> diagramElementCompletionStageProvider = k -> diagramElementProvider.apply(k);

org.nasdanika.diagram.plantuml.clazz.Type thisType = generateDiagramElement(uri, diagramElementCompletionStageProvider, progressMonitor);
org.nasdanika.diagram.plantuml.clazz.Type thisType = generateDiagramElement(getUri(), diagramElementCompletionStageProvider, progressMonitor);
thisType.setStyle("#DDDDDD");
classDiagram.getDiagramElements().add(thisType);
diagramElementProvider.apply(getTarget()).complete(thisType);
Expand All @@ -1094,7 +1094,7 @@ record EClassifierKey(String nsURI, String name) {}
EClassifier st = sgt.getEClassifier();
CompletableFuture<DiagramElement> stcf = diagramElementProvider.apply(st);
if (!stcf.isDone()) {
DiagramElement stde = swf.select(genericTypeClassifierDiagramElementSelector, uri, progressMonitor);
DiagramElement stde = swf.select(genericTypeClassifierDiagramElementSelector, getUri(), progressMonitor);
classDiagram.getDiagramElements().add(stde);
stcf.complete(stde);
}
Expand All @@ -1110,7 +1110,7 @@ record EClassifierKey(String nsURI, String name) {}
EClassifier st = subTypeRecord.subType();
CompletableFuture<DiagramElement> stcf = diagramElementProvider.apply(st);
if (!stcf.isDone()) {
DiagramElement stde = subTypeRecord.subTypeWidgetFactory().select(subTypeDiagramElementSelector, uri, progressMonitor);
DiagramElement stde = subTypeRecord.subTypeWidgetFactory().select(subTypeDiagramElementSelector, getUri(), progressMonitor);
classDiagram.getDiagramElements().add(stde);
stcf.complete(stde);
}
Expand All @@ -1125,11 +1125,11 @@ record EClassifierKey(String nsURI, String name) {}

// Outgoing
for (WidgetFactory rwf: eReferenceWidgetFactories.values()) {
EReference eRef = (EReference) rwf.select(EObjectNodeProcessor.TARGET_SELECTOR, uri, progressMonitor);
EReference eRef = (EReference) rwf.select(EObjectNodeProcessor.TARGET_SELECTOR, getUri(), progressMonitor);
EClass refClass = eRef.getEReferenceType();
CompletableFuture<DiagramElement> rccf = diagramElementProvider.apply(refClass);
if (!rccf.isDone()) {
DiagramElement rtde = rwf.select(referenceTypeDiagramElementSelector, uri, progressMonitor);
DiagramElement rtde = rwf.select(referenceTypeDiagramElementSelector, getUri(), progressMonitor);
classDiagram.getDiagramElements().add(rtde);
rccf.complete(rtde);
}
Expand All @@ -1151,7 +1151,7 @@ record EClassifierKey(String nsURI, String name) {}
if (declaringClass != null) {
CompletableFuture<DiagramElement> dccf = diagramElementProvider.apply(declaringClass);
if (!dccf.isDone()) {
DiagramElement dcde = rte.getValue().select(declaringClassDiagramElementSelector, uri, progressMonitor);
DiagramElement dcde = rte.getValue().select(declaringClassDiagramElementSelector, getUri(), progressMonitor);
classDiagram.getDiagramElements().add(dcde);
dccf.complete(dcde);
}
Expand All @@ -1168,7 +1168,7 @@ record EClassifierKey(String nsURI, String name) {}
if (declaringClass != null) {
CompletableFuture<DiagramElement> dccf = diagramElementProvider.apply(declaringClass);
if (!dccf.isDone()) {
DiagramElement dcde = typedElementWidgetFactoryEntry.getValue().select(declaringClassDiagramElementSelector, uri, progressMonitor);
DiagramElement dcde = typedElementWidgetFactoryEntry.getValue().select(declaringClassDiagramElementSelector, getUri(), progressMonitor);
classDiagram.getDiagramElements().add(dcde);
dccf.complete(dcde);
}
Expand Down Expand Up @@ -1383,7 +1383,7 @@ protected org.nasdanika.models.echarts.graph.Graph generateGraph(ProgressMonitor
EClassifier eClassifier = (EClassifier) cwf.select(EObjectNodeProcessor.TARGET_SELECTOR, progressMonitor);
CompletableFuture<org.nasdanika.models.echarts.graph.Node> eccf = nodeProvider.apply(eClassifier);
if (!eccf.isDone()) {
org.nasdanika.models.echarts.graph.Node ecn = cwf.select(eClassifierNodeSelector, uri, progressMonitor);
org.nasdanika.models.echarts.graph.Node ecn = cwf.select(eClassifierNodeSelector, getUri(), progressMonitor);
graph.getNodes().add(ecn);
eccf.complete(ecn);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ record EClassifierKey(String nsURI, String name) {}
EClassifier eClassifier = (EClassifier) cwf.select(EObjectNodeProcessor.TARGET_SELECTOR, progressMonitor);
CompletableFuture<DiagramElement> eccf = diagramElementProvider.apply(eClassifier);
if (!eccf.isDone()) {
DiagramElement ecde = cwf.select(eClassifierDiagramElementSelector, uri, progressMonitor);
DiagramElement ecde = cwf.select(eClassifierDiagramElementSelector, getUri(), progressMonitor);
classDiagram.getDiagramElements().add(ecde);
eccf.complete(ecde);
}
Expand Down Expand Up @@ -409,7 +409,7 @@ protected org.nasdanika.models.echarts.graph.Graph generateGraph(boolean withDep
EClassifier eClassifier = (EClassifier) cwf.select(EObjectNodeProcessor.TARGET_SELECTOR, progressMonitor);
CompletableFuture<org.nasdanika.models.echarts.graph.Node> eccf = nodeProvider.apply(eClassifier);
if (!eccf.isDone()) {
org.nasdanika.models.echarts.graph.Node ecn = cwf.select(eClassifierNodeSelector, uri, progressMonitor);
org.nasdanika.models.echarts.graph.Node ecn = cwf.select(eClassifierNodeSelector, getUri(), progressMonitor);
graph.getNodes().add(ecn);
eccf.complete(ecn);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ public String getLoadDescription() {

@Override
public URI getLoadSpecRef(URI base) {
URI uri = getUri();
if (uri == null) {
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,18 @@
import java.util.Collections;
import java.util.Map;
import java.util.UUID;
import java.util.function.Consumer;
import java.util.function.Function;
import java.util.function.Predicate;

import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EPackage;
import org.nasdanika.capability.CapabilityLoader;
import org.nasdanika.common.Context;
import org.nasdanika.common.Diagnostic;
import org.nasdanika.common.ProgressMonitor;
import org.nasdanika.html.model.app.Action;
import org.nasdanika.html.model.app.graph.emf.ActionGenerator;
import org.nasdanika.models.ecore.graph.EcoreGraphFactory;

Expand All @@ -21,6 +28,14 @@ public EcoreActionGenerator(
EcoreNodeProcessorFactory nodeProcessorFactory) {
super(sources, references, uriResolver, nodeProcessorFactory);
}

private EcoreActionGenerator(
Collection<? extends EObject> sources,
Collection<? extends EObject> references,
Function<? super EObject, URI> uriResolver,
Object[] nodeProcessorFactories) {
super(sources, references, uriResolver, nodeProcessorFactories);
}

public EcoreActionGenerator(
EObject source,
Expand Down Expand Up @@ -54,4 +69,63 @@ protected Object createGraphFactory() {
return new EcoreGraphFactory();
}

/**
* Loads mapping of {@link EPackage}s to doc URI's and node processor factories from {@link CapabilityLoader}.
* @param sources
* @param references
* @param capabilityLoader
* @param progressMonitor
* @return
*/
public static EcoreActionGenerator loadEcoreActionGenerator(
EObject source,
Context context,
java.util.function.BiFunction<URI, ProgressMonitor, Action> prototypeProvider,
Predicate<Object> factoryPredicate,
Predicate<EPackage> ePackagePredicate,
Consumer<Diagnostic> diagnosticConsumer,
ProgressMonitor progressMonitor) {

return loadEcoreActionGenerator(
source,
context,
prototypeProvider,
factoryPredicate,
ePackagePredicate,
new CapabilityLoader(),
diagnosticConsumer,
progressMonitor);
}

/**
* Loads mapping of {@link EPackage}s to doc URI's and node processor factories from {@link CapabilityLoader}.
* @param sources
* @param references
* @param capabilityLoader
* @param progressMonitor
* @return
*/
public static EcoreActionGenerator loadEcoreActionGenerator(
EObject source,
Context context,
java.util.function.BiFunction<URI, ProgressMonitor, Action> prototypeProvider,
Predicate<Object> factoryPredicate,
Predicate<EPackage> ePackagePredicate,
CapabilityLoader capabilityLoader,
Consumer<Diagnostic> diagnosticConsumer,
ProgressMonitor progressMonitor) {

return load(
source,
context,
prototypeProvider,
factoryPredicate,
ePackagePredicate,
capabilityLoader,
diagnosticConsumer,
EcoreActionGenerator::new,
progressMonitor);

}

}

0 comments on commit 3947f97

Please sign in to comment.