Re: [api-dev] Using an Xframe as a parent for a Java dialog

2008-11-21 Thread Jan Füssel
Hi Peter,

the shown solution of mine is the result of longtime with Spring, AWT
 SWT. I don't think its possible out of the box. An early solution
is based on JNI, but it was to complex to realize my problems.

i'm going to fish for some source files when i arrive at home after work.

Jan

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: [api-dev] Using an Xframe as a parent for a Java dialog

2008-11-18 Thread Hedges, George
Hi Jan,

Thank you for your help, getting the window handle will help me solve my 
problem. I was able to get the window handle using Java rather than Basic:

XSystemDependentWindowPeer peer = (XSystemDependentWindowPeer) 
UnoRuntime.queryInterface(
XSystemDependentWindowPeer.class, myFrame.getContainerWindow());

Object handle = peer.getWindowHandle(new byte[4], 
SystemDependent.SYSTEM_WIN32));

Thank you also to the rest of you who answered for your suggestions. 

George

-Original Message-
From: Jan Füssel [mailto:[EMAIL PROTECTED] 
Sent: Friday, October 31, 2008 11:57 AM
To: dev@api.openoffice.org
Subject: Re: [api-dev] Using an Xframe as a parent for a Java dialog

Hi,

i've currently a solution to open a modless java-dialog, which need SWT and 
only works on a windows machine.

To get Windows Handle I used the following Basic-Code:

Dim oWindow : oWindow = ThisComponent.CurrentController.Frame.ContainerWindow
Dim HWND : HWND = oWindow.getWindowHandle(Array(),
com.sun.star.lang.SystemDependent.SYSTEM_WIN32)

With that handle I call java Java-Method which start an SWT-Dialog:

private void createDialog(int handle) {
final MyDialog myDialog = MyDialog.create(handle, componentContext);
myDialog.show();
}

Here a little piece of the MyDialog Class:

public class MyDialog {

private final Shell myShell;

private MyDialog(Shell shell) {
myShell = shell;
myShell.addFocusListener(new FocusAdapter() {
public void focusLost(FocusEvent e) {
myShell.setVisible(true);
}
});
}

public static MyDialog create(int handle, XComponentContext
componentContext) {
final int style = SWT.DIALOG_TRIM | SWT.APPLICATION_MODAL | SWT.RESIZE;
final Display display = new Display();
final Shell shell;
if (handle  0) {
final Shell parent = Shell.win32_new(display, handle);
shell = new Shell(parent, style);
} else {
shell = new Shell(style);
}
return new MyDialog(shell);
}

public void show() {
createMyShell();
myShell.open();
final Composite parent = myShell.getParent();
final Display display;
if (parent != null) {
display = parent.getDisplay();
} else {
display = Display.getDefault();
}
while (!myShell.isDisposed()) {
if (!display.readAndDispatch()) {
display.sleep();
}
}
}
}

I hope this little pieces of code could show you a way to resolve your problem.

Jan

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: [api-dev] Using an Xframe as a parent for a Java dialog

2008-11-01 Thread Robert Vojta
On Thu, Oct 30, 2008 at 9:36 PM, Hedges, George
[EMAIL PROTECTED] wrote:

Hi George,

 I'd like to have a modeless javax.swing.JDialog sitting on top of the
 document's XFrame.  Is there a technique for using an XFrame as a parent
 for a JDialog?

as Juergen and Jan said, it's not possible. But you can intercept
window close command and other stuff to avoid parent window to be
closed when your Java window is still opened.

I wrote a prototype few months ago to test this approach. You can
download it here:

  http://senduit.com/45d282  (will be there for one week)

The only thing you need to do is to call
JavaParentWindow.attachJavaWindow( window, officeDocument ). When you
finish, call detachJavaWindow( window ).

There's OfficeDocument class used. Don't worry, it carries only XFrame
in this case. So you can exchange OfficeDocument for XFrame and adapt
remaining classes.

Feel free to do whatever you want to do with this code. But remember,
it's prototype for approach test, it needs to be finished.

-- 
Robert Vojta

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: [api-dev] Using an Xframe as a parent for a Java dialog

2008-10-31 Thread Jan Füssel
Hi,

i've currently a solution to open a modless java-dialog, which need
SWT and only works on a windows machine.

To get Windows Handle I used the following Basic-Code:

Dim oWindow : oWindow = ThisComponent.CurrentController.Frame.ContainerWindow
Dim HWND : HWND = oWindow.getWindowHandle(Array(),
com.sun.star.lang.SystemDependent.SYSTEM_WIN32)

With that handle I call java Java-Method which start an SWT-Dialog:

private void createDialog(int handle) {
final MyDialog myDialog = MyDialog.create(handle, componentContext);
myDialog.show();
}

Here a little piece of the MyDialog Class:

public class MyDialog {

private final Shell myShell;

private MyDialog(Shell shell) {
myShell = shell;
myShell.addFocusListener(new FocusAdapter() {
public void focusLost(FocusEvent e) {
myShell.setVisible(true);
}
});
}

public static MyDialog create(int handle, XComponentContext
componentContext) {
final int style = SWT.DIALOG_TRIM | SWT.APPLICATION_MODAL | SWT.RESIZE;
final Display display = new Display();
final Shell shell;
if (handle  0) {
final Shell parent = Shell.win32_new(display, handle);
shell = new Shell(parent, style);
} else {
shell = new Shell(style);
}
return new MyDialog(shell);
}

public void show() {
createMyShell();
myShell.open();
final Composite parent = myShell.getParent();
final Display display;
if (parent != null) {
display = parent.getDisplay();
} else {
display = Display.getDefault();
}
while (!myShell.isDisposed()) {
if (!display.readAndDispatch()) {
display.sleep();
}
}
}
}

I hope this little pieces of code could show you a way to resolve your problem.

Jan

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



[api-dev] Using an Xframe as a parent for a Java dialog

2008-10-30 Thread Hedges, George
I'd like to have a modeless javax.swing.JDialog sitting on top of the
document's XFrame.  Is there a technique for using an XFrame as a parent
for a JDialog?