diff --git a/libPlg/src/plg/generator/log/LogGenerator.java b/libPlg/src/plg/generator/log/LogGenerator.java index 49a8a3b..94472b8 100644 --- a/libPlg/src/plg/generator/log/LogGenerator.java +++ b/libPlg/src/plg/generator/log/LogGenerator.java @@ -111,7 +111,7 @@ private XLog unfinishedLogGeneration() throws Exception { progress.start(); // define the number of CPU cores to use - int coresToUse = (parameters.useMultithreading())? CPUUtils.CPUAvailable() : 1; + int coresToUse = 1; //(parameters.useMultithreading())? CPUUtils.CPUAvailable() : 1; Logger.instance().info("Starting simulation with " + coresToUse + " cores"); // prepare the engine diff --git a/libPlg/src/plg/generator/scriptexecuter/IntegerScriptExecutor.java b/libPlg/src/plg/generator/scriptexecuter/IntegerScriptExecutor.java index d3cc5dd..ced4606 100644 --- a/libPlg/src/plg/generator/scriptexecuter/IntegerScriptExecutor.java +++ b/libPlg/src/plg/generator/scriptexecuter/IntegerScriptExecutor.java @@ -1,28 +1,30 @@ -package plg.generator.scriptexecuter; - -import plg.exceptions.InvalidScript; - -/** - * This class describes a script executor that will generate an integer value - * - * @author Andrea Burattin - */ -public class IntegerScriptExecutor extends ScriptExecutor { - - /** - * Script constructor - * - * @param script a Python script - */ - public IntegerScriptExecutor(String script) { - super(script); - } - - @Override - public Integer getValue() throws InvalidScript { - if (result == null) { - return null; - } - return (Integer) result.__tojava__(Integer.class); - } -} +package plg.generator.scriptexecuter; + +import org.python.core.Py; + +import plg.exceptions.InvalidScript; + +/** + * This class describes a script executor that will generate an integer value + * + * @author Andrea Burattin + */ +public class IntegerScriptExecutor extends ScriptExecutor { + + /** + * Script constructor + * + * @param script a Python script + */ + public IntegerScriptExecutor(String script) { + super(script); + } + + @Override + public Integer getValue() throws InvalidScript { + if (result == null) { + return null; + } + return Py.py2int(result); + } +} diff --git a/libPlg/src/plg/generator/scriptexecuter/StringScriptExecutor.java b/libPlg/src/plg/generator/scriptexecuter/StringScriptExecutor.java index 42d3ff3..1d07001 100644 --- a/libPlg/src/plg/generator/scriptexecuter/StringScriptExecutor.java +++ b/libPlg/src/plg/generator/scriptexecuter/StringScriptExecutor.java @@ -1,28 +1,30 @@ -package plg.generator.scriptexecuter; - -import plg.exceptions.InvalidScript; - -/** - * This class describes a script executor that will generate a string value - * - * @author Andrea Burattin - */ -public class StringScriptExecutor extends ScriptExecutor { - - /** - * Script constructor - * - * @param script a Python script - */ - public StringScriptExecutor(String script) { - super(script); - } - - @Override - public String getValue() throws InvalidScript { - if (result == null) { - return null; - } - return (String) result.__tojava__(String.class); - } -} +package plg.generator.scriptexecuter; + +import org.python.antlr.adapter.AstAdapters; + +import plg.exceptions.InvalidScript; + +/** + * This class describes a script executor that will generate a string value + * + * @author Andrea Burattin + */ +public class StringScriptExecutor extends ScriptExecutor { + + /** + * Script constructor + * + * @param script a Python script + */ + public StringScriptExecutor(String script) { + super(script); + } + + @Override + public String getValue() throws InvalidScript { + if (result == null) { + return null; + } + return result.__tojava__(Object.class).toString(); + } +} diff --git a/libPlg/src/plg/test/LogGeneratorMain.java b/libPlg/src/plg/test/LogGeneratorMain.java index 537398e..c0988b1 100644 --- a/libPlg/src/plg/test/LogGeneratorMain.java +++ b/libPlg/src/plg/test/LogGeneratorMain.java @@ -10,20 +10,22 @@ import plg.generator.ProgressAdapter; import plg.generator.log.LogGenerator; import plg.generator.log.SimulationConfiguration; +import plg.generator.log.noise.NoiseConfiguration; import plg.io.importer.BPMNImporter; +import plg.io.importer.PLGImporter; import plg.model.Process; public class LogGeneratorMain { public static void main(String[] args) throws Exception { - if (args.length != 3) { - System.err.println("Please use: java -jar LogGenerator.jar MODEL_FILE LOG_DESTINATION NO_TRACES"); - System.exit(-1); - } +// if (args.length != 3) { +// System.err.println("Please use: java -jar LogGenerator.jar MODEL_FILE LOG_DESTINATION NO_TRACES"); +// System.exit(-1); +// } - String modelFile = args[0]; - String logDestination = args[1]; - Integer noTraces = Integer.parseInt(args[2]); + String modelFile = "C:\\Users\\andbur\\Desktop\\authorization-request-extension.plg"; //args[0]; + String logDestination = "C:\\Users\\andbur\\Desktop\\extension-log.xes"; //args[1]; + Integer noTraces = 1000; System.out.println("Welcome!"); @@ -32,7 +34,8 @@ public static void main(String[] args) throws Exception { System.out.println("No. of traces: " + noTraces); System.out.print("1. Importing model... "); - BPMNImporter importer = new BPMNImporter(); +// BPMNImporter importer = new BPMNImporter(); + PLGImporter importer = new PLGImporter(); Process p = importer.importModel(modelFile, new ProgressAdapter()); System.out.println("done!"); @@ -42,6 +45,7 @@ public static void main(String[] args) throws Exception { System.out.print("3. Generating log... "); SimulationConfiguration sc = new SimulationConfiguration(noTraces); + sc.setNoiseConfiguration(NoiseConfiguration.NO_NOISE); LogGenerator generator = new LogGenerator(p, sc, new ProgressAdapter()); XLog log = generator.generateLog(); System.out.println("done!"); diff --git a/libPlgVisualizer/.classpath b/libPlgVisualizer/.classpath index 35b741a..4ddd3a5 100644 --- a/libPlgVisualizer/.classpath +++ b/libPlgVisualizer/.classpath @@ -1,9 +1,13 @@ - - - - - - - - - + + + + + + + + + + + + + diff --git a/libPlgVisualizer/lib/GraphViz-latest.jar b/libPlgVisualizer/lib/GraphViz-latest.jar new file mode 100644 index 0000000..e1ecbcf Binary files /dev/null and b/libPlgVisualizer/lib/GraphViz-latest.jar differ diff --git a/libPlgVisualizer/lib/KitFox.jar b/libPlgVisualizer/lib/KitFox.jar new file mode 100644 index 0000000..eb5b195 Binary files /dev/null and b/libPlgVisualizer/lib/KitFox.jar differ diff --git a/libPlgVisualizer/lib/commons-io-2.6.jar b/libPlgVisualizer/lib/commons-io-2.6.jar new file mode 100644 index 0000000..00556b1 Binary files /dev/null and b/libPlgVisualizer/lib/commons-io-2.6.jar differ diff --git a/libPlgVisualizer/lib/commons-lang3-3.8.1.jar b/libPlgVisualizer/lib/commons-lang3-3.8.1.jar new file mode 100644 index 0000000..2c65ce6 Binary files /dev/null and b/libPlgVisualizer/lib/commons-lang3-3.8.1.jar differ diff --git a/libPlgVisualizer/src/plg/visualizer/BPMNVisualizer2.java b/libPlgVisualizer/src/plg/visualizer/BPMNVisualizer2.java new file mode 100644 index 0000000..1efee0e --- /dev/null +++ b/libPlgVisualizer/src/plg/visualizer/BPMNVisualizer2.java @@ -0,0 +1,30 @@ +package plg.visualizer; + +import java.awt.Color; + +import org.processmining.plugins.graphviz.visualisation.DotPanel; + +import plg.model.Process; +import plg.visualizer.model.DotModel; + +/** + * This widget is used to visualize a BPMN model. + * + * @author Andrea Burattin + */ +public class BPMNVisualizer2 extends DotPanel { + + private static final long serialVersionUID = -8441909033110442685L; + + /** + * Class constructor + * + * @param process the process graph to show + */ + public BPMNVisualizer2(Process process) { + super(new DotModel(process)); + + setOpaque(true); + setBackground(Color.WHITE); + } +} diff --git a/libPlgVisualizer/src/plg/visualizer/model/DotModel.java b/libPlgVisualizer/src/plg/visualizer/model/DotModel.java new file mode 100644 index 0000000..bac41d0 --- /dev/null +++ b/libPlgVisualizer/src/plg/visualizer/model/DotModel.java @@ -0,0 +1,72 @@ +package plg.visualizer.model; + +import java.util.HashMap; +import java.util.Map; + +import org.processmining.plugins.graphviz.dot.Dot; +import org.processmining.plugins.graphviz.dot.DotNode; + +import plg.model.Component; +import plg.model.FlowObject; +import plg.model.Process; +import plg.model.data.DataObject; +import plg.model.data.IDataObjectOwner.DATA_OBJECT_DIRECTION; +import plg.model.sequence.Sequence; +import plg.visualizer.model.edges.DotDataObjectConnection; +import plg.visualizer.model.edges.DotSequence; +import plg.visualizer.model.nodes.DotNodesFactory; + +/** + * + * @author Andrea Burattin + */ +public class DotModel extends Dot { + + private Process model; + + public DotModel(Process model) { + this.model = model; + +// setOption("splines", "ortho"); +// setOption("nodesep", "0.5"); + setOption("rankdir", "LR"); + + realize(); + } + + private void realize() { + Map idToNodes = new HashMap(); + + // adding all nodes + for (Component node : model.getComponents()) { + if (node instanceof FlowObject || node instanceof DataObject) { + DotNode dotNode = DotNodesFactory.construct(node); + idToNodes.put(node.getId(), dotNode); + addNode(dotNode); + } + } + + // adding all edges + for (Sequence sequence : model.getSequences()) { + DotNode source = idToNodes.get(sequence.getSource().getId()); + DotNode sink = idToNodes.get(sequence.getSink().getId()); + addEdge(new DotSequence(source, sink)); + } + + // connecting all data objects + for (DataObject dobj : model.getDataObjects()) { + if (dobj.getObjectOwner() != null) { + DotNode source = null; + DotNode sink = null; + if (dobj.getDirectionOwner() == DATA_OBJECT_DIRECTION.GENERATED) { + source = idToNodes.get(dobj.getObjectOwner().getId()); + sink = idToNodes.get(dobj.getId()); + } else { + source = idToNodes.get(dobj.getId()); + sink = idToNodes.get(dobj.getObjectOwner().getId()); + } + addEdge(new DotDataObjectConnection(source, sink)); + } + } + } +} diff --git a/libPlgVisualizer/src/plg/visualizer/model/edges/DotDataObjectConnection.java b/libPlgVisualizer/src/plg/visualizer/model/edges/DotDataObjectConnection.java new file mode 100644 index 0000000..93f310d --- /dev/null +++ b/libPlgVisualizer/src/plg/visualizer/model/edges/DotDataObjectConnection.java @@ -0,0 +1,19 @@ +package plg.visualizer.model.edges; + +import org.processmining.plugins.graphviz.dot.DotEdge; +import org.processmining.plugins.graphviz.dot.DotNode; + +/** + * + * @author Andrea Burattin + */ +public class DotDataObjectConnection extends DotEdge { + + public DotDataObjectConnection(DotNode source, DotNode target) { + super(source, target); + + setOption("color", "#666666"); + setOption("style", "dashed"); + setOption("arrowhead", "open"); + } +} diff --git a/libPlgVisualizer/src/plg/visualizer/model/edges/DotSequence.java b/libPlgVisualizer/src/plg/visualizer/model/edges/DotSequence.java new file mode 100644 index 0000000..0209e99 --- /dev/null +++ b/libPlgVisualizer/src/plg/visualizer/model/edges/DotSequence.java @@ -0,0 +1,17 @@ +package plg.visualizer.model.edges; + +import org.processmining.plugins.graphviz.dot.DotEdge; +import org.processmining.plugins.graphviz.dot.DotNode; + +/** + * + * @author Andrea Burattin + */ +public class DotSequence extends DotEdge { + + public DotSequence(DotNode source, DotNode target) { + super(source, target); + + setOption("color", "#5a677b"); + } +} diff --git a/libPlgVisualizer/src/plg/visualizer/model/nodes/DotDataObject.java b/libPlgVisualizer/src/plg/visualizer/model/nodes/DotDataObject.java new file mode 100644 index 0000000..ab9253b --- /dev/null +++ b/libPlgVisualizer/src/plg/visualizer/model/nodes/DotDataObject.java @@ -0,0 +1,29 @@ +package plg.visualizer.model.nodes; + +import org.processmining.plugins.graphviz.dot.DotNode; + +import plg.model.data.DataObject; + +/** + * + * @author Andrea Burattin + */ +public class DotDataObject extends DotNode { + + public DotDataObject(DataObject node) { + super(node.getName(), null); + + setSelectable(true); + + setOption("shape", "note"); + setOption("fontsize", "10"); + setOption("width", "0.5"); + setOption("height", "0.5"); + setOption("style", "filled"); + setOption("fillcolor", "#ffffff"); + setOption("color", "#666666"); + setOption("fontcolor", "#666666"); + setOption("fontname", "sans-serif"); + } + +} diff --git a/libPlgVisualizer/src/plg/visualizer/model/nodes/DotEndEvent.java b/libPlgVisualizer/src/plg/visualizer/model/nodes/DotEndEvent.java new file mode 100644 index 0000000..988e3e0 --- /dev/null +++ b/libPlgVisualizer/src/plg/visualizer/model/nodes/DotEndEvent.java @@ -0,0 +1,28 @@ +package plg.visualizer.model.nodes; + +import org.processmining.plugins.graphviz.dot.DotNode; + +/** + * + * @author Andrea Burattin + */ +public class DotEndEvent extends DotNode { + + public DotEndEvent() { + super("", null); + + setSelectable(true); + + setOption("shape", "circle"); + setOption("style", "filled"); + setOption("fillcolor", "#e46e60:#ffc5c1"); + setOption("gradientangle", "270"); + setOption("color", "#630000"); + setOption("width", ".3"); + setOption("fontcolor", "#630000"); + setOption("fontname", "sans-serif"); + setOption("fontsize", "12.0"); + setOption("penwidth", "2"); + } + +} diff --git a/libPlgVisualizer/src/plg/visualizer/model/nodes/DotGateway.java b/libPlgVisualizer/src/plg/visualizer/model/nodes/DotGateway.java new file mode 100644 index 0000000..f51447f --- /dev/null +++ b/libPlgVisualizer/src/plg/visualizer/model/nodes/DotGateway.java @@ -0,0 +1,39 @@ +package plg.visualizer.model.nodes; + +import org.processmining.plugins.graphviz.dot.DotNode; + +/** + * + * @author Andrea Burattin + */ +public class DotGateway extends DotNode { + + public enum TYPE { + PARALLEL, EXCLUSIVE + } + + public DotGateway(TYPE type) { + super("", null); + + setSelectable(true); + + setOption("shape", "diamond"); + setOption("style", "filled"); + setOption("width", "0.4"); + setOption("height", "0.4"); + setOption("fontsize", "20"); + setOption("fillcolor", "#ffff84:#ffffbd"); + setOption("gradientangle", "270"); + setOption("color", "#a6a855"); + setOption("fontcolor", "#708041"); + setOption("fontname", "sans-serif"); + setOption("fixedsize", "true"); + + if (TYPE.PARALLEL.equals(type)) { + setLabel("+"); + } else { + setLabel("×"); + } + } + +} diff --git a/libPlgVisualizer/src/plg/visualizer/model/nodes/DotNodesFactory.java b/libPlgVisualizer/src/plg/visualizer/model/nodes/DotNodesFactory.java new file mode 100644 index 0000000..4e4be18 --- /dev/null +++ b/libPlgVisualizer/src/plg/visualizer/model/nodes/DotNodesFactory.java @@ -0,0 +1,36 @@ +package plg.visualizer.model.nodes; + +import org.processmining.plugins.graphviz.dot.DotNode; + +import plg.model.Component; +import plg.model.data.DataObject; +import plg.visualizer.model.nodes.DotGateway.TYPE; + +/** + * + * @author Andrea Burattin + */ +public class DotNodesFactory { + + public static DotNode construct(Component node) { + if (node instanceof plg.model.activity.Task) { + return new DotTask(((plg.model.activity.Task) node).getName()); + } + if (node instanceof plg.model.event.StartEvent) { + return new DotStartEvent(); + } + if (node instanceof plg.model.event.EndEvent) { + return new DotEndEvent(); + } + if (node instanceof plg.model.gateway.ParallelGateway) { + return new DotGateway(TYPE.PARALLEL); + } + if (node instanceof plg.model.gateway.ExclusiveGateway) { + return new DotGateway(TYPE.EXCLUSIVE); + } + if (node instanceof plg.model.data.DataObject) { + return new DotDataObject((DataObject) node); + } + return null; + } +} diff --git a/libPlgVisualizer/src/plg/visualizer/model/nodes/DotStartEvent.java b/libPlgVisualizer/src/plg/visualizer/model/nodes/DotStartEvent.java new file mode 100644 index 0000000..4d48934 --- /dev/null +++ b/libPlgVisualizer/src/plg/visualizer/model/nodes/DotStartEvent.java @@ -0,0 +1,28 @@ +package plg.visualizer.model.nodes; + +import org.processmining.plugins.graphviz.dot.DotNode; + +/** + * + * @author Andrea Burattin + */ +public class DotStartEvent extends DotNode { + + public DotStartEvent() { + super("", null); + + setSelectable(true); + + setOption("shape", "circle"); + setOption("style", "filled"); + setOption("fillcolor", "#5dbd5a:#bafcc2"); + setOption("gradientangle", "270"); + setOption("color", "#20962f"); + setOption("width", ".3"); + setOption("fontcolor", "#20962f"); + setOption("fontname", "sans-serif"); + setOption("fontsize", "12.0"); + setOption("penwidth", "2"); + } + +} diff --git a/libPlgVisualizer/src/plg/visualizer/model/nodes/DotTask.java b/libPlgVisualizer/src/plg/visualizer/model/nodes/DotTask.java new file mode 100644 index 0000000..b0be4e4 --- /dev/null +++ b/libPlgVisualizer/src/plg/visualizer/model/nodes/DotTask.java @@ -0,0 +1,27 @@ +package plg.visualizer.model.nodes; + +import org.processmining.plugins.graphviz.dot.DotNode; + +/** + * + * @author Andrea Burattin + */ +public class DotTask extends DotNode { + + public DotTask(String label) { + super(label, null); + + setSelectable(true); + + setOption("shape", "box"); + setOption("style", "rounded,filled"); + setOption("fillcolor", "#cedeef:#ffffff"); + setOption("gradientangle", "270"); + setOption("color", "#5a677b"); + setOption("width", "0.5"); + setOption("fontcolor", "#5a677b"); + setOption("fontname", "sans-serif"); + setOption("fontsize", "14.0"); + setOption("penwidth", "1"); + } +} diff --git a/libPlgVisualizer/src/plg/visualizer/prototype/PlgVisualizerPrototype.java b/libPlgVisualizer/src/plg/visualizer/prototype/PlgVisualizerPrototype.java index 01ac87d..f8169db 100644 --- a/libPlgVisualizer/src/plg/visualizer/prototype/PlgVisualizerPrototype.java +++ b/libPlgVisualizer/src/plg/visualizer/prototype/PlgVisualizerPrototype.java @@ -6,6 +6,8 @@ import plg.exceptions.IllegalSequenceException; import plg.exceptions.InvalidProcessException; +import plg.generator.process.ProcessGenerator; +import plg.generator.process.RandomizationConfiguration; import plg.model.Process; import plg.model.activity.Task; import plg.model.data.DataObject; @@ -14,14 +16,15 @@ import plg.model.event.StartEvent; import plg.model.gateway.Gateway; import plg.visualizer.BPMNVisualizer; +import plg.visualizer.BPMNVisualizer2; public class PlgVisualizerPrototype { public static void main(String[] args) throws IllegalSequenceException, InvalidProcessException { Process p = new Process("test"); - p = generateProcess(); -// ProcessGenerator.randomizeProcess(p, RandomizationConfiguration.BASIC_VALUES); - BPMNVisualizer v = new BPMNVisualizer(p); +// p = generateProcess(); + ProcessGenerator.randomizeProcess(p, RandomizationConfiguration.BASIC_VALUES); + BPMNVisualizer2 v = new BPMNVisualizer2(p); JFrame f = new JFrame("Test Frame"); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); @@ -29,7 +32,6 @@ public static void main(String[] args) throws IllegalSequenceException, InvalidP f.setLayout(new BorderLayout()); f.add(v, BorderLayout.CENTER); f.setVisible(true); - v.fit(); } private static Process generateProcess() throws IllegalSequenceException, InvalidProcessException { @@ -37,8 +39,8 @@ private static Process generateProcess() throws IllegalSequenceException, Invali StartEvent start = p.newStartEvent(); EndEvent end = p.newEndEvent(); Gateway split = p.newParallelGateway(); - Gateway join = p.newParallelGateway(); - Task a = p.newTask("a"); + Gateway join = p.newExclusiveGateway(); + Task a = p.newTask("Test activity"); Task b = p.newTask("b"); Task c = p.newTask("c"); Task d = p.newTask("d"); diff --git a/plg-cli/src/plg/cli/log/LogGenerator.java b/plg-cli/src/plg/cli/log/LogGenerator.java index 1493cdb..faef402 100644 --- a/plg-cli/src/plg/cli/log/LogGenerator.java +++ b/plg-cli/src/plg/cli/log/LogGenerator.java @@ -14,6 +14,7 @@ import plg.generator.ProgressAdapter; import plg.generator.log.SimulationConfiguration; import plg.io.importer.BPMNImporter; +import plg.io.importer.PLGImporter; import plg.model.Process; import plg.utils.PlgConstants; @@ -104,7 +105,8 @@ public static void main(String[] args) throws Exception { // model import System.out.print("1. Importing model... "); - BPMNImporter importer = new BPMNImporter(); + //BPMNImporter importer = new BPMNImporter(); + PLGImporter importer = new PLGImporter(); Process p = importer.importModel(parameters.modelFile.getAbsolutePath()); System.out.println("done!"); diff --git a/plg/.classpath b/plg/.classpath index 2ac743c..919871f 100644 --- a/plg/.classpath +++ b/plg/.classpath @@ -1,29 +1,29 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/plg/.settings/org.eclipse.jdt.core.prefs b/plg/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000..11f6e46 --- /dev/null +++ b/plg/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,7 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7 +org.eclipse.jdt.core.compiler.compliance=1.7 +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.7 diff --git a/plg/src/plg/gui/dialog/ErrorDialog.java b/plg/src/plg/gui/dialog/ErrorDialog.java index 4e348c5..d65b03d 100644 --- a/plg/src/plg/gui/dialog/ErrorDialog.java +++ b/plg/src/plg/gui/dialog/ErrorDialog.java @@ -1,121 +1,121 @@ -package plg.gui.dialog; - -import java.awt.GridBagConstraints; -import java.awt.GridBagLayout; -import java.awt.Insets; - -import javax.swing.JFrame; -import javax.swing.JLabel; -import javax.swing.JScrollPane; -import javax.swing.JTextArea; - -import plg.exceptions.IllegalSequenceException; -import plg.exceptions.InvalidDataObject; -import plg.exceptions.InvalidProcessException; -import plg.exceptions.InvalidScript; -import plg.exceptions.UnsupportedPLGFileFormat; -import plg.gui.controller.ApplicationController; -import plg.gui.util.collections.ImagesCollection; - -public class ErrorDialog extends GeneralDialog { - - private static final long serialVersionUID = 7240134489904377493L; - - private Exception exception; - private JLabel head; - private JTextArea details; - - public ErrorDialog(JFrame owner, Exception e) { - super(owner, "Exception thrown", e.getMessage(), ApplicationController.instance().getConfiguration(EvolutionDialog.class.getCanonicalName()), false, true); - this.exception = e; - - bodyPanel.setLayout(new GridBagLayout()); - - GridBagConstraints c = new GridBagConstraints(); - c.gridx = 0; - c.gridy = 0; - c.weighty = 0; - c.insets = new Insets(0, 0, 10, 10); - bodyPanel.add(new JLabel(ImagesCollection.ERROR_ICON), c); - - c = new GridBagConstraints(); - c.gridx = 1; - c.gridy = 0; - c.weighty = 0; - c.fill = GridBagConstraints.HORIZONTAL; - c.anchor = GridBagConstraints.WEST; - c.insets = new Insets(0, 0, 10, 0); - head = prepareFieldLabel(""); - head.setHorizontalAlignment(JLabel.LEFT); - bodyPanel.add(head, c); - - c = new GridBagConstraints(); - c.gridx = 0; - c.gridy = 1; - c.gridwidth = 2; - c.weightx = 1; - c.weighty = 1; - c.fill = GridBagConstraints.BOTH; - - details = new JTextArea(""); - details.setEditable(false); - JScrollPane sp = new JScrollPane(details); - bodyPanel.add(sp, c); - - pupulateDescriptions(); - } - - private void pupulateDescriptions() { - if (exception instanceof IllegalSequenceException) { - head.setText("" - + "Message: " + exception.getMessage() + "
" - + "Description: An illegal sequence has been reported. " - + "Illegal sequences are reported in Table 7.3 of the " - + "BPMN 2.0 " - + "standard definition."); - details.setText(getStackTrace()); - } else if (exception instanceof InvalidScript) { - head.setText("" - + "Message: " + exception.getMessage() + "
" - + "Description: there is an error in the Python script."); - details.setText(((InvalidScript) exception).getScript()); - }else if (exception instanceof UnsupportedPLGFileFormat) { - head.setText("" - + "Message: " + exception.getMessage() + "
" - + "Description: the provided PLG file format is not" - + "supported by the current implementation."); - details.setText(getStackTrace()); - } else if (exception instanceof InvalidDataObject) { - head.setText("" - + "Message: " + exception.getMessage() + "
" - + "Description: A provided data object is somehow illegal."); - details.setText(getStackTrace()); - } else if (exception instanceof InvalidProcessException) { - head.setText("" - + "Message: " + exception.getMessage() + "
" - + "Description: The process is somehow illegal."); - details.setText(getStackTrace()); - } else { - head.setText("Message: " + exception.getMessage() + ""); - details.setText(getStackTrace()); - } - } - - private String getStackTrace() { - String stackTrace = ""; - for (StackTraceElement ste : exception.getStackTrace()) { - stackTrace += ste.toString() + "\n"; - } - return stackTrace; - } - - public static void main(String args[]) { - JFrame f = new JFrame("test"); - f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); - f.setSize(800, 600); - f.setVisible(true); - - ErrorDialog e = new ErrorDialog(f, new InvalidScript("Illegal sequence", "ASDFSDF")); - e.setVisible(true); - } -} +package plg.gui.dialog; + +import java.awt.GridBagConstraints; +import java.awt.GridBagLayout; +import java.awt.Insets; + +import javax.swing.JFrame; +import javax.swing.JLabel; +import javax.swing.JScrollPane; +import javax.swing.JTextArea; + +import plg.exceptions.IllegalSequenceException; +import plg.exceptions.InvalidDataObject; +import plg.exceptions.InvalidProcessException; +import plg.exceptions.InvalidScript; +import plg.exceptions.UnsupportedPLGFileFormat; +import plg.gui.controller.ApplicationController; +import plg.gui.util.collections.ImagesCollection; + +public class ErrorDialog extends GeneralDialog { + + private static final long serialVersionUID = 7240134489904377493L; + + private Exception exception; + private JLabel head; + private JTextArea details; + + public ErrorDialog(JFrame owner, Exception e) { + super(owner, "Exception thrown", e.getMessage(), ApplicationController.instance().getConfiguration(EvolutionDialog.class.getCanonicalName()), false, true); + this.exception = e; + + bodyPanel.setLayout(new GridBagLayout()); + + GridBagConstraints c = new GridBagConstraints(); + c.gridx = 0; + c.gridy = 0; + c.weighty = 0; + c.insets = new Insets(0, 0, 10, 10); + bodyPanel.add(new JLabel(ImagesCollection.ERROR_ICON), c); + + c = new GridBagConstraints(); + c.gridx = 1; + c.gridy = 0; + c.weighty = 0; + c.fill = GridBagConstraints.HORIZONTAL; + c.anchor = GridBagConstraints.WEST; + c.insets = new Insets(0, 0, 10, 0); + head = prepareFieldLabel(""); + head.setHorizontalAlignment(JLabel.LEFT); + bodyPanel.add(head, c); + + c = new GridBagConstraints(); + c.gridx = 0; + c.gridy = 1; + c.gridwidth = 2; + c.weightx = 1; + c.weighty = 1; + c.fill = GridBagConstraints.BOTH; + + details = new JTextArea(""); + details.setEditable(false); + JScrollPane sp = new JScrollPane(details); + bodyPanel.add(sp, c); + + pupulateDescriptions(); + } + + private void pupulateDescriptions() { + if (exception instanceof IllegalSequenceException) { + head.setText("" + + "Message: " + exception.getMessage() + "
" + + "Description: An illegal sequence has been reported. " + + "Illegal sequences are reported in Table 7.3 of the " + + "BPMN 2.0 " + + "standard definition."); + details.setText(getStackTrace()); + } else if (exception instanceof InvalidScript) { + head.setText("" + + "Message: " + exception.getMessage() + "
" + + "Description: there is an error in the Python script."); + details.setText(((InvalidScript) exception).getScript()); + }else if (exception instanceof UnsupportedPLGFileFormat) { + head.setText("" + + "Message: " + exception.getMessage() + "
" + + "Description: the provided PLG file format is not" + + "supported by the current implementation."); + details.setText(getStackTrace()); + } else if (exception instanceof InvalidDataObject) { + head.setText("" + + "Message: " + exception.getMessage() + "
" + + "Description: A provided data object is somehow illegal."); + details.setText(getStackTrace()); + } else if (exception instanceof InvalidProcessException) { + head.setText("" + + "Message: " + exception.getMessage() + "
" + + "Description: The process is somehow illegal."); + details.setText(getStackTrace()); + } else { + head.setText("Message: " + exception.getMessage() + ""); + details.setText(getStackTrace()); + } + } + + private String getStackTrace() { + String stackTrace = ""; + for (StackTraceElement ste : exception.getStackTrace()) { + stackTrace += ste.toString() + "\n"; + } + return stackTrace; + } + + public static void main(String args[]) { + JFrame f = new JFrame("test"); + f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + f.setSize(800, 600); + f.setVisible(true); + + ErrorDialog e = new ErrorDialog(f, new InvalidScript("Illegal sequence", "ASDFSDF")); + e.setVisible(true); + } +}