Skip to content

Commit

Permalink
#6: added selection dialog for FindMode.
Browse files Browse the repository at this point in the history
  • Loading branch information
tobwirtz committed Aug 11, 2024
1 parent 6589a69 commit fe7aa03
Showing 1 changed file with 24 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.processmining.implicitplaceidentification.algorithms.plugins;

import org.deckfour.uitopia.api.event.TaskListener;
import org.processmining.implicitplaceidentification.algorithms.FindMode;
import org.processmining.implicitplaceidentification.algorithms.StructureBasedImplicitPlaceFinder;
import org.processmining.implicitplaceidentification.algorithms.util.PetriNetCopier;
Expand All @@ -8,6 +9,8 @@
import org.processmining.contexts.uitopia.annotations.UITopiaVariant;
import org.processmining.framework.plugin.annotations.Plugin;
import org.processmining.framework.plugin.annotations.PluginVariant;
import org.processmining.implicitplaceidentification.dialogs.VariantSelectionDialog;
import org.processmining.implicitplaceidentification.parameters.IPFinderParams;
import org.processmining.models.graphbased.directed.petrinet.Petrinet;
import org.processmining.models.semantics.petrinet.Marking;
import org.processmining.plugins.petrinet.finalmarkingprovider.MarkingEditorPanel;
Expand All @@ -25,21 +28,19 @@ public class ILPBasedImplicitPlaceColorerPlugin {
@PluginVariant(variantLabel = "IP-Finder: ILP-based, apn", requiredParameterLabels = {2})
@UITopiaVariant(affiliation = "PADS Student", author = "Tobias Wirtz", email = "[email protected]")
public Petrinet colorAcceptingPetrinet(UIPluginContext context, AcceptingPetriNet acceptingPN) {
Petrinet net = acceptingPN.getNet();
Marking initialMarking = acceptingPN.getInitialMarking();

StructureBasedImplicitPlaceFinder ipFinder = new StructureBasedImplicitPlaceFinder(acceptingPN.getNet(),
acceptingPN.getInitialMarking(), FindMode.FIND_ALL_POTENTIAL_IPS);

PetriNetCopier copier = new PetriNetCopier(acceptingPN.getNet(), acceptingPN.getNet().getLabel() + " with " +
"colored IPs");
return copier.colorPlaces(ipFinder.find()).getDeepCopy();
return color(context, net, initialMarking);
}

@PluginVariant(variantLabel = "IP-Finder: ILP-based", requiredParameterLabels = {0, 1})
@UITopiaVariant(affiliation = "PADS Student", author = "Tobias Wirtz", email = "[email protected]")
public Petrinet color(UIPluginContext context, Petrinet net, Marking initialMarking) {
FindMode findmode = chooseFindmode(context);

StructureBasedImplicitPlaceFinder ipFinder = new StructureBasedImplicitPlaceFinder(net, initialMarking,
FindMode.FIND_ALL_POTENTIAL_IPS);
findmode);

PetriNetCopier copier = new PetriNetCopier(net, net.getLabel() + " with colored IPs");
return copier.colorPlaces(ipFinder.find()).getDeepCopy();
Expand All @@ -66,4 +67,20 @@ private static Marking chooseInitialMarking(UIPluginContext context, Petrinet ne
return initialMarking;
}


private static FindMode chooseFindmode(UIPluginContext context) {
// Get the default parameters.
IPFinderParams parameters = new IPFinderParams(false, FindMode.FIND_ALL_POTENTIAL_IPS);
// Get a dialog for this parameters.
VariantSelectionDialog dialog = new VariantSelectionDialog(context, parameters);
// Show the dialog. User can now change the parameters.
TaskListener.InteractionResult result = context.showWizard("Variant Selection", true, true, dialog);
// User has close the dialog.
if (result == TaskListener.InteractionResult.FINISHED) {
// Apply the algorithm depending on whether a connection already exists.
return parameters.getFindMode();
}
// Dialog got canceled.
return null;
}
}

0 comments on commit fe7aa03

Please sign in to comment.