}
}
+
+ public static void createTg(Path input) throws Exception {
+ Path output = input.getParent().resolve("graph.tg");
+ createTg(input, output);
+ }
+
+ private static void createTg(Path input, Path output) throws Exception {
+ convertExportedSharedOntologyIntoBundleOntology(input, output);
+ }
+
+ public static void createPGraph(Path input) throws Exception {
+ Path output1 = input.getParent().resolve("graph.tg");
+ TransferableGraph1 tg = convertExportedSharedOntologyIntoBundleOntology(input, output1);
+ String listing = PrettyPrintTG.print(tg, false);
+ String newName = input.getFileName().toString();
+ if (newName.contains("\\."))
+ newName = newName.split("\\.")[0];
+ Path output2 = input.getParent().resolve(newName + ".pgraph");
+ Files.write(output2, listing.getBytes(),StandardOpenOption.CREATE);
+ }
public static void main(String[] args) throws Exception {
if (args.length == 0) {
System.out.println("Required arguments: <input .sharedLibrary file> [<output .tg file>]");
} else if (args.length == 1) {
Path input = Paths.get(args[0]);
- Path output1 = input.getParent().resolve("graph.tg");
- TransferableGraph1 tg = convertExportedSharedOntologyIntoBundleOntology(input, output1);
- String listing = PrettyPrintTG.print(tg, false);
- Path output2 = Paths.get(args[0].substring(0, args[0].length() - ".sharedLibrary".length()) + ".pgraph");
- Files.write(output2, listing.getBytes(),StandardOpenOption.CREATE);
+ createPGraph(input);
} else {
convertExportedSharedOntologyIntoBundleOntology(Paths.get(args[0]), Paths.get(args[1]));
}
* <code>true</code> if the model should be overwritten without a warning.
*/
boolean overwrite;
+ boolean tgAndPgraph;
ExportPlan(ISessionContext sessionContext, Deque<String> recentLocations) {
this.sessionContext = sessionContext;
import java.util.Collections;
import java.util.List;
+import org.eclipse.core.runtime.Platform;
import org.eclipse.jface.layout.GridDataFactory;
import org.eclipse.jface.layout.GridLayoutFactory;
import org.eclipse.jface.wizard.WizardPage;
validatePage();
}
});
+ String prop = System.getProperty("org.simantics.modeling.exportTgAndPgraph");
+ if (prop != null || Platform.inDevelopmentMode()) {
+ Button tgAndPgraph = new Button(container, SWT.CHECK);
+ tgAndPgraph.setText("&Generate TG and Pgraph with export");
+ tgAndPgraph.setSelection(exportModel.tgAndPgraph);
+ GridDataFactory.fillDefaults().grab(true, false).span(3, 1).applyTo(tgAndPgraph);
+ tgAndPgraph.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ exportModel.tgAndPgraph = tgAndPgraph.getSelection();
+ }
+ });
+ }
+
try {
initializeData();
} catch (DatabaseException e) {
import java.io.File;
import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
+import java.nio.file.Path;
+import java.nio.file.Paths;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.SubMonitor;
import org.simantics.databoard.serialization.SerializationException;
import org.simantics.db.common.utils.Logger;
import org.simantics.db.exception.DatabaseException;
+import org.simantics.graph.refactoring.FixExportedOntology;
import org.simantics.modeling.ModelingUtils;
import org.simantics.modeling.ModelingUtils.LibraryInfo;
import org.simantics.utils.ui.dialogs.ShowMessage;
+import org.slf4j.LoggerFactory;
/**
* @author Antti Villberg
*/
public class SharedOntologyExporter implements IRunnableWithProgress {
+ private static final org.slf4j.Logger LOGGER = LoggerFactory.getLogger(SharedOntologyExporter.class);
ExportPlan exportModel;
public SharedOntologyExporter(ExportPlan exportModel) {
void exportModel(SubMonitor mon) throws IOException, DatabaseException, SerializationException, BindingException{
try {
- doExport(mon, exportModel.exportLocation, exportModel.model);
+ doExport(mon, exportModel.exportLocation, exportModel.model, exportModel.tgAndPgraph);
} catch (DatabaseException e) {
e.printStackTrace();
}
public static void doExport(IProgressMonitor monitor, File location, final LibraryInfo info) throws DatabaseException, IOException {
+ doExport(monitor, location, info, false);
+ }
+
+ public static void doExport(IProgressMonitor monitor, File location, final LibraryInfo info, boolean pgraphAndTg) throws DatabaseException, IOException {
ModelingUtils.exportSharedOntology(monitor, Simantics.getSession(), location,Constants.SHARED_LIBRARY_FORMAT, Constants.SHARED_LIBRARY_CURRENT_VERSION, info);
+ if (pgraphAndTg) {
+ try {
+ Path input = Paths.get(location.toURI());
+ FixExportedOntology.createTg(input);
+ FixExportedOntology.createPGraph(input);
+ } catch (Exception e) {
+ LOGGER.error("Could not generate TG and Pgraph", e);
+ }
+ }
}
}