~tapaal-contributor/tapaal/weight-values-fix-1770637

« back to all changes in this revision

Viewing changes to src/pipe/gui/Export.java

merged in branch lp:~tapaal-contributor/tapaal/Batch-export-PNML-XML-queries-1754675
adding batch export of files to PNML and XML

Show diffs side-by-side

added added

removed removed

Lines of Context:
19
19
import java.io.FileOutputStream;
20
20
import java.io.IOException;
21
21
import java.io.PrintStream;
 
22
import java.util.Collection;
22
23
import java.util.Iterator;
23
24
 
24
25
import javax.imageio.ImageIO;
42
43
import dk.aau.cs.gui.TabContent;
43
44
import dk.aau.cs.io.PNMLWriter;
44
45
import dk.aau.cs.model.tapn.NetworkMarking;
 
46
import dk.aau.cs.model.tapn.TimedArcPetriNetNetwork;
45
47
import dk.aau.cs.verification.ITAPNComposer;
46
48
import dk.aau.cs.verification.NameMapping;
47
49
import dk.aau.cs.verification.TAPNComposer;
88
90
                }
89
91
        }
90
92
        
91
 
        private static void toQueryXML(DrawingSurfaceImpl g, String filename){
 
93
        private static void toQueryXML(String filename){
 
94
                toQueryXML(CreateGui.getCurrentTab().network(), filename, CreateGui.getCurrentTab().queries());
 
95
                
 
96
        }
 
97
        
 
98
        public static void toQueryXML(TimedArcPetriNetNetwork network, String filename, Iterable<TAPNQuery> queries){
92
99
                try{
93
 
                        TabContent currentTab = CreateGui.getCurrentTab();
94
 
                        ITAPNComposer composer = new TAPNComposer(new MessengerImpl(), true);
95
 
                        NameMapping mapping = composer.transformModel(currentTab.network()).value2();
96
 
                        Iterator<TAPNQuery> queryIterator = currentTab.queries().iterator();
97
 
                        PrintStream queryStream = new PrintStream(filename);
98
 
                        CTLQueryVisitor XMLVisitor = new CTLQueryVisitor();
99
 
                        
100
 
                        while(queryIterator.hasNext()){
101
 
                            TAPNQuery clonedQuery = queryIterator.next().copy();
 
100
                    ITAPNComposer composer = new TAPNComposer(new MessengerImpl(), true);
 
101
                    NameMapping mapping = composer.transformModel(network).value2();
 
102
                    Iterator<TAPNQuery> queryIterator = queries.iterator();
 
103
                    PrintStream queryStream = new PrintStream(filename);
 
104
                    CTLQueryVisitor XMLVisitor = new CTLQueryVisitor();
 
105
                    
 
106
                    while(queryIterator.hasNext()){
 
107
                        TAPNQuery clonedQuery = queryIterator.next().copy();
102
108
 
103
109
                            // Attempt to parse and possibly transform the string query using the manual edit parser
104
110
                            TCTLAbstractProperty newProperty;
110
116
                            newProperty.accept(new RenameAllPlacesVisitor(mapping), null);
111
117
                            newProperty.accept(new RenameAllTransitionsVisitor(mapping), null);
112
118
                            XMLVisitor.buildXMLQuery(newProperty, clonedQuery.getName());
113
 
                        }
114
 
                        queryStream.print(XMLVisitor.getFormatted());
115
 
                        
116
 
                        queryStream.close();
 
119
                    }
 
120
                    queryStream.print(XMLVisitor.getFormatted());
 
121
                                
 
122
                                queryStream.close();
117
123
                } catch(FileNotFoundException e) {
118
124
                        System.err.append("An error occurred while exporting the queries to XML.");
119
125
                }
259
265
                        case QUERY:
260
266
                                filename = new FileBrowser("Query XML file", "xml", filename).saveFile(CreateGui.appGui.getCurrentTabName().replaceAll(".xml", "-queries"));
261
267
                                if (filename != null) {
262
 
                                        toQueryXML(g, filename);
 
268
                                        toQueryXML(filename);
263
269
                                }
264
270
                                break;
265
271
                        }