Community Tip - Learn all about PTC Community Badges. Engage with PTC and see how many you can earn! X
Adepters,
please help me with the following issue. I tried to develope adynamic combobox that allowes comfortable selection of "target-IDs" relating to cross references and jump marks. Unfortunately I stuck at 80% of the entire script.
So here is what happened until now:
ACL-Code that creates the $DialogWindow by calling doc_open($XMLDialogPath,1).
This script works fine as fare as I can see:
function my_dlgitem_callback(win, dlgitem, event, data, appdata){
# possible event/s: ITEM_CHANGED, ITEM_FOCUSED, and ITEM_UNFOCUSED
if(dlgitem == 'OKbutton' && event=='ITEM_CHANGED'){
$CombSelValue = dlgitem_get(win, 'tarbox', 'TEXT');
modify_tag Idref=$CombSelValue;
event_stop_process(1)
}
}
function CreateDialogAbsprungmarke(oid){
$XMLDialogPath = 'C:\Programme\Epic\custom\dialogs\absprungmarke.xml';
$DialogDoc = doc_open($XMLDialogPath,1);
$DialogWindow = window_create('xui',0x10,$DialogDoc);
# DialogWindow.dlgitem_set_value($DialogWindow, "tarbox", "test.123");
$currentOid = $oid;
# callbacks
dlgitem_add_callback($DialogWindow, 'OKbutton', 'my_dlgitem_callback');
# show dialog window
window_show($DialogWindow,1);
# Stop execution of ACL until OK-button was pressed
event_process();
response("And so on...");
}
The XUI-XML-File includes the JavaScript that offers the IDs: from the current document:
<window focus="tarbox" id="tarid" modal="false" orient="vertical" title="TargetID wählen:">
<combobox id="tarbox" type="dropdown" value="id...">
combobox>
<button label="OK" type="accept" id="OKbutton">
<script type="application/x-javascript" ev:event="domactivate">
<script type="application/x-javascript" ev:event="domactivate">
var doc = Application.activeDocument;
var tags = doc.getElementsByAttribute("ID-Ueberschrift",",0);
// var CurrentDialogDoc = Application.event.target.ownerDocument; ???
var CurrentDialogDoc = "C:\\Programme\\Epic\\custom\\dialogs\\absprungmarke.xml";
var xmlDoc = Application.openDocument(CurrentDialogDoc,(0,0001));
for (i=0; i<tags.length; i++)=" {<=" p=">
var CurrentNode = tags.item(i).firstChild;
if(CurrentNode.nodeType == CurrentNode.TEXT_NODE){
ComboNode = xmlDoc.getElementById("tarbox");
listNode = xmlDoc.createElement("listitem");
ComboNode.appendChild(listNode);
listNode.setAttribute("label", tags.item(i).getAttribute('ID-Ueberschrift'));
} else {
// print(CurrentNode.firstChild.NodeType);
}
}
script>
button>window>
Is it possible to modify the XUI-dialog without opening the same xui-file a second time?
How canI point the current XUI-Document with JavaScript???
I think something is wrong because the script results in the following Error:
Java VM Version 1.5.0_07-b03 -- Sun Microsystems Inc.
org.mozilla.javascript.WrappedException: Wrapped org.w3c.dom.DOMException: [A30111] DOM-Ausnahme: Es wurde versucht, ein schreibgeschütztes Objekt zu ändern (<js_eval>#15)
at org.mozilla.javascript.Context.throwAsScriptRuntimeEx(Context.java:1693)
at org.mozilla.javascript.MemberBox.invoke(MemberBox.java:157)
at org.mozilla.javascript.NativeJavaMethod.call(NativeJavaMethod.java:201)
at org.mozilla.javascript.optimizer.OptRuntime.call1(OptRuntime.java:64)
at org.mozilla.javascript.gen.c4._c0(<js_eval>:15)
at org.mozilla.javascript.gen.c4.call(<js_eval>)
at org.mozilla.javascript.ContextFactory.doTopCall(ContextFactory.java:337)
at org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:2755)
at org.mozilla.javascript.gen.c4.call(<js_eval>)
at org.mozilla.javascript.gen.c4.exec(<js_eval>)
at org.mozilla.javascript.Context.evaluateString(Context.java:1132)
at com.arbortext.epic.internal.js.JavaScript.eval(JavaScript.java:110)
at com.arbortext.epic.internal.js.JavaScript.eval(JavaScript.java:141)
Caused by: org.w3c.dom.DOMException: [A30111] DOM-Ausnahme: Es wurde versucht, ein schreibgeschütztes Objekt zu ändern
at com.arbortext.epic.internal.aom.NodeImpl.appendChild(Native Method)
at com.arbortext.epic.internal.aom.NodeImpl.appendChild(NodeImpl.java:306)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.mozilla.javascript.MemberBox.invoke(MemberBox.java:142)
... 11 more
Adeptors,
it works! I changed my XUI-Doc like this:
var doc = Application.activeDocument;var tags = doc.getElementsByAttribute("ID-Ueberschrift",",0);
var CurrentDialogDoc = Application.event.target.ownerDocument;
for (i=0; i<tags.length; i++)=" {<=" em=">
var CurrentNode = tags.item(i).firstChild;
if(CurrentNode.nodeType == CurrentNode.TEXT_NODE){
ComboNode = CurrentDialogDoc.getElementById("tarbox");
listNode = CurrentDialogDoc.createElement("listitem");
ComboNode.appendChild(listNode);
listNode.setAttribute("label", tags.item(i).getAttribute('ID-Ueberschrift'));
} else {
// print(CurrentNode.firstChild.NodeType);
}
}
And everything seems to work 🙂
BUT...
In practice I had to realize that the performance is very bad. It takes definitely to long to automatically insert the ID-Value for the current OID. We work with very large XML-Documents (relative...) so the following script:
var tags = doc.getElementsByAttribute("ID-Ueberschrift",",0);
takes about 70 ID values from the active document.
takes about values from the active document.After I press the OK button the script works a view seconds and inserts the selected ID:
sample
<absprungmarke idref="<strong">Immer.bi.kundendiens.uAnker1"/>
Does anybody have an Idee how to optimize the script?
1.)It should work much faster
2.)The dynamic ID values first appear after I press ok button. How can I make them available in themoment the dialog appears?
3.) How can I close the dialog after I press ok button? I suppose:CurrentDialogDoc.close()
Many thanks!
Hi Clay,
your script works well. It displays all IDs in a second. The only thing I had to adjust was the nesting at the end of the script. "ComboNode..." was inside the for-statement.
How can I generate the combolist in the moment the dialog appears? Until now I always have to click the OK button until the script starts to work. I couldn't find an appropriate event... 😞
I hope you can give me an advice for this final step.
Thanks
Johannes