~workcraft/workcraft/trunk

« back to all changes in this revision

Viewing changes to CpogsPlugin/src/org/workcraft/plugins/cpog/tools/PGMinerSelectedGraphsExtractionTool.java

  • Committer: Danil Sokolov
  • Date: 2016-01-28 11:05:21 UTC
  • mfrom: (725.1.2 trunk-bug-1537854)
  • Revision ID: danilovesky@gmail.com-20160128110521-khwkegr8stdarkb0
Merge proposal for bug #1537854 approved.

Show diffs side-by-side

added added

removed removed

Lines of Context:
41
41
                        String allGraphs = CpogParsingTool.getExpressionFromGraph(visualCpog);
42
42
                        ArrayList<String> tempGraphs = new ArrayList<>();
43
43
                        ArrayList<String> graphs = new ArrayList<>();
44
 
                        String prefix = "input", suffix = ".tr";
45
44
                        inputFile = File.createTempFile("input", ".tr");
46
45
                        
47
 
                        PrintStream expressions = new PrintStream(inputFile);
 
46
                        
48
47
                        
49
48
                        int i = allGraphs.indexOf(" + ");
50
49
                        while (i > -1) {
51
50
                                allGraphs = allGraphs.substring(0, i) + "\n" + allGraphs.substring(i + 2);
52
51
                                i = allGraphs.indexOf(" + ");
53
52
                        }
 
53
                        allGraphs = allGraphs + "\n";
54
54
                        allGraphs = allGraphs.replaceAll(" -> ", " ");
55
55
                        
56
 
                        while (allGraphs.contains("\n")) {
57
 
                                int index = allGraphs.indexOf("\n");
58
 
                                String graph = (allGraphs.substring(0, index));
59
 
                                allGraphs = allGraphs.substring(index + 1);
60
 
                                tempGraphs.add(graph);
61
 
                        }
 
56
                        String[] graphList = allGraphs.split("\n");
62
57
                        
63
 
                        //tempGraphs.add(allGraphs);
 
58
                        for (String g : graphList) tempGraphs.add(g);
64
59
                        
65
60
                        for (String graph : tempGraphs) {
66
61
                                int index = graph.indexOf("= ");
67
62
                                if (index >= 0) {
68
63
                                        graph = graph.substring(index + 2);
69
 
                                }
70
 
                                while (graph.startsWith(" ")) {
71
 
                                        graph = graph.substring(1);
72
 
                                }
73
 
                                while (graph.endsWith(" ")) {
74
 
                                        graph = graph.substring(0, graph.length() - 1);
75
 
                                }
 
64
                                } else {
 
65
                                        JOptionPane.showMessageDialog(null,
 
66
                                                        "Error: A graph which is not a scenario has been selected.\n"
 
67
                                                        + "Please remove this from the selection, or group this as a page to continue",
 
68
                                                        "Error",
 
69
                                                        JOptionPane.ERROR_MESSAGE);
 
70
                                                        return null;
 
71
                                }
 
72
                                graph = graph.trim();
76
73
                                graphs.add(graph);
77
74
                        }
78
75
                        
 
76
                        PrintStream expressions = new PrintStream(inputFile);
 
77
                        
79
78
                        for (String graph : graphs) {
80
79
                                expressions.println(graph);
81
80
                        }
82
81
                        
83
82
                        expressions.close();
84
83
                        
85
 
                        
86
84
                        } catch (IOException exception) {
87
85
                                exception.printStackTrace();
88
86
                        } catch (ArrayIndexOutOfBoundsException e2) {
89
87
                                JOptionPane.showMessageDialog(null,
90
 
                                                "Error: No graphs have been selected",
 
88
                                                "Error: No scenarios have been selected",
91
89
                                                "Error",
92
90
                                                JOptionPane.ERROR_MESSAGE);
93
91
                                                throw e2;
102
100
                try {
103
101
                
104
102
                        File inputFile = getInputFile(we);
 
103
                        if (inputFile == null) return;
105
104
                        PGMinerTask task = new PGMinerTask(inputFile, false);
106
105
        
107
106
                        final Framework framework = Framework.getInstance();