\r
import org.eclipse.core.commands.ExecutionEvent;\r
import org.eclipse.core.commands.ExecutionException;\r
+import org.eclipse.ui.handlers.HandlerUtil;\r
import org.simantics.db.Resource;\r
+import org.simantics.utils.ui.workbench.WorkbenchUtils;\r
\r
/**\r
* Exports a selected model asking the location.\r
@Override\r
public Object execute(ExecutionEvent event) throws ExecutionException {\r
\r
+ status = WorkbenchUtils.getStatusLine( HandlerUtil.getActiveSite(event) );\r
+ \r
final Resource model = determineModel(event);\r
if (model == null)\r
return null;\r
\r
String selected = getAbsolutePath(model, event, true);\r
\r
- if (selected != null)\r
+ if (selected != null) {\r
createFile(model, selected);\r
- \r
+ setExportStatus(model, selected);\r
+ }\r
+ \r
return null;\r
}\r
\r
import org.simantics.ui.SimanticsUI;\r
import org.simantics.ui.utils.ResourceAdaptionUtils;\r
import org.simantics.utils.ui.AdaptionUtils;\r
+import org.simantics.utils.ui.workbench.WorkbenchUtils;\r
\r
/**\r
* Exports a selected model without asking the location.\r
@Override\r
public Object execute(ExecutionEvent event) throws ExecutionException {\r
\r
+ status = WorkbenchUtils.getStatusLine( HandlerUtil.getActiveSite(event) );\r
+ \r
final Resource model = determineModel(event);\r
if (model == null)\r
return null;\r
\r
String selected = getAbsolutePath(model, event, false);\r
\r
- if (selected != null)\r
+ if (selected != null) {\r
createFile(model, selected);\r
- \r
- return null;\r
+ setExportStatus(model, selected);\r
+ }\r
+ \r
+ return null;\r
}\r
\r
@Override\r
import org.eclipse.core.commands.ExecutionEvent;\r
import org.eclipse.core.commands.ExecutionException;\r
import org.eclipse.core.runtime.Platform;\r
+import org.eclipse.jface.action.IStatusLineManager;\r
import org.eclipse.jface.viewers.ISelection;\r
import org.eclipse.swt.SWT;\r
import org.eclipse.swt.widgets.FileDialog;\r
import org.simantics.sysdyn.ui.utils.imports.ImportUtilsUI;\r
import org.simantics.ui.SimanticsUI;\r
import org.simantics.ui.utils.ResourceAdaptionUtils;\r
+import org.simantics.utils.ui.workbench.WorkbenchUtils;\r
\r
/**\r
* Exports a selected model\r
*/\r
public class ExportModelHandler extends AbstractHandler {\r
\r
+ protected static IStatusLineManager status;\r
+\r
@Override\r
public Object execute(ExecutionEvent event) throws ExecutionException {\r
\r
+ status = WorkbenchUtils.getStatusLine( HandlerUtil.getActiveSite(event) );\r
+ \r
final Resource model = determineModel(event);\r
if (model == null)\r
return null;\r
\r
String selected = getAbsolutePath(model, event, true);\r
\r
- if (selected != null)\r
+ if (selected != null) {\r
createFile(model, selected);\r
+ setExportStatus(model, selected);\r
+ }\r
\r
- return null;\r
+ return null;\r
}\r
-\r
+ \r
+ /**\r
+ * Create the export file.\r
+ * @param model Model which is exported.\r
+ * @param fileName Full name of the file.\r
+ */\r
+ protected void setExportStatus(final Resource model, final String fileName) {\r
+ try {\r
+ String modelName = SimanticsUI.getSession().syncRequest(new Read<String>() {\r
+ \r
+ @Override\r
+ public String perform(ReadGraph graph) throws DatabaseException {\r
+ if (!graph.hasStatement(model, Layer0.getInstance(graph).PartOf))\r
+ return null;\r
+ Layer0 l0 = Layer0.getInstance(graph);\r
+ return graph.syncRequest(new PossibleRelatedValue<String>(model, l0.HasName, Bindings.STRING ));\r
+ }\r
+ \r
+ });\r
+ \r
+ if (modelName != null)\r
+ setStatus("Saved model \"" + modelName + "\" to " + fileName);\r
+ \r
+ } catch (DatabaseException e) {\r
+ // TODO Auto-generated catch block\r
+ e.printStackTrace();\r
+ }\r
+ }\r
+ \r
/**\r
* Create the export file.\r
* @param model Model which is exported.\r
return selected;\r
\r
}\r
+ \r
+ protected static void setStatus(final String message) {\r
+ if (status != null)\r
+ status.setMessage(message);\r
+ }\r
+\r
}\r