Hello,
Thank you for reporting these functionality gaps. I've added some issues to enhance the ${ask} variable. Meanwhile, as an workaround, you can
contribute custom variables through an workspace access plugin. We have a sample Workspace Access plugin which constitutes a good starting point on GitHub:
https://github.com/oxygenxml/sample-plu ... ace-access
If you are more comfortable with Javascript than with Java, then you can opt for the Javascript version of the Workspace Access plugin. Some good examples for that can be found on GitHub:
https://github.com/oxygenxml/wsaccess-j ... le-plugins . Actually there is one such sample plugin that actually contributes a custom editor variable:
https://github.com/oxygenxml/wsaccess-j ... rVariables
Here is a version of that custom editor variables provider that also contributes a variable ${mFiles} that is expanded to a comma separated enumeration of relative paths. What's not that great is that when the user presses Cancel in the dialog, it throws a runtime exception that stops the execution. This will present a rather unpleasant dialog to the user... By the way, in which contexts are you using ${ask} and you need this additional support? Author actions, transformation scenarios?
Code: Select all
function applicationStarted(pluginWorkspaceAccess) {
resolver = {
resolveEditorVariables: function (contentWithEditorVariables, currentEditedFileURL) {
var clipboardVarName = "clipboard";
var mFilesVarName = "mFiles";
if (contentWithEditorVariables.indexOf("${" + clipboardVarName + "}") != -1) {
clipboard = Packages.java.awt.Toolkit.getDefaultToolkit().getSystemClipboard();
try {
return contentWithEditorVariables.replace("${" + clipboardVarName + "}", clipboard.getData(Packages.java.awt.datatransfer.DataFlavor.stringFlavor));
Packages.java.lang.System.err.println("\nIN HERE2 " + clipboard.getData(DataFlavor.stringFlavor));
}
catch (e) {
// error: don't replace variable
return contentWithEditorVariables;
}
}
if (contentWithEditorVariables.indexOf("${" + mFilesVarName + "}") != -1) {
new Packages.java.lang.Exception().printStackTrace();
var canceled = false;
try {
var pluginWorkspace = pluginWorkspaceAccess;
// Present a file explorer with multiple selection.
var currentFileContext = null;
if (currentEditedFileURL != null) {
var base = new Packages.java.net.URL(currentEditedFileURL);
currentFileContext = pluginWorkspace.getUtilAccess().locateFile(base);
}
var files = pluginWorkspace.chooseFiles(currentFileContext, "Title", null, null);
if (files != null) {
var b = new Packages.java.lang.StringBuilder();
var base = null;
if (currentEditedFileURL != null) {
base = new Packages.java.net.URL(currentEditedFileURL);
}
for (var i = 0; i < files.length; i++) {
var makeRelative = pluginWorkspace.getUtilAccess().makeRelative(
base,
pluginWorkspace.getUtilAccess().convertFileToURL(files[i]));
if (b.length() > 0) {
b.append(",");
}
b.append(makeRelative);
}
contentWithEditorVariables = contentWithEditorVariables.replace("${" + mFilesVarName + "}", b.toString());
} else {
canceled = true;
}
}
catch (e) {
e.printStackTrace();
}
if (canceled) {
throw new Packages.java.lang.RuntimeException("operation canceled");
}
}
return contentWithEditorVariables;
}
}
pluginWorkspaceAccess.getUtilAccess().addCustomEditorVariablesResolver(new Packages.ro.sync.exml.workspace.api.util.EditorVariablesResolver(resolver));
}
function applicationClosing(pluginWorkspaceAccess) {
}