Ulrich_Laegeler at arburg.com wrote:
> 
> how do i get the corresponding swing component
> in a document hook to execute an Alert or a ItemSelectorDialog.
> 

DocumentHook are not intended to be interactive[*] and we are not sure 
that they'll survive (in their current form) in XXE v4.

--> May be a custom Command would better do the same job.

--> May be you should consider using an OpenedDocumentHook instead.

See 
http://www.xmlmind.com/xmleditor/_distrib/doc/gui/openedDocumentHook.html

See
http://www.xmlmind.com/xmleditor/_distrib/doc/api/com/xmlmind/xmleditapp/kit/OpenedDocumentHook.html

An OpenedDocumentHook has methods such as:

checkingDocument(OpenedDocument openedDoc)

Where openedDoc.getApp().getDialogParent() returns a Component which can 
be used as the owner of any dialog box.

See
http://www.xmlmind.com/xmleditor/_distrib/doc/api/com/xmlmind/xmleditapp/kit/OpenedDocument.html#getApp()

See also 
http://www.xmlmind.com/xmleditor/_distrib/doc/api/com/xmlmind/xmleditapp/kit/App.html#getDialogParent()




---
[*] Here's a very twisted way to get a dialog box owner from a 
DocumentHook. This code has never been used/tested before.

DocumentHook has methods such as:

documentSaved(Document document, int status)

See 
http://www.xmlmind.com/xmleditor/_distrib/doc/api/com/xmlmind/xmleditapp/dochook/DocumentHook.html

Component dialogOwner = null;

DocumentListener[] listeners =
   document.getDocumentListeners(/*hasData*/ true);
if (listeners != null &&
     listeners.length > 0 &&
     (listeners[0] instanceof DocumentView)) {
     dialogOwner =
       ((DocumentView) listeners[0]).getPanel();
}

See
http://www.xmlmind.com/xmleditor/_distrib/doc/api/com/xmlmind/xmledit/doc/Document.html#getDocumentListeners(boolean)

See 
http://www.xmlmind.com/xmleditor/_distrib/doc/api/com/xmlmind/xmledit/view/DocumentView.html

See 
http://www.xmlmind.com/xmleditor/_distrib/doc/api/com/xmlmind/xmledit/gadget/RootGadget.html#getPanel()




Reply via email to