List Info

Thread: creating non-modal dialog




creating non-modal dialog
user name
2006-04-20 07:05:49
Hi,

My goal is to create a non-modal dialog to replace default
Styles and 
Formatting - dialog.
MyDialog contains a listbox for styles just like the Style
and 
Formatting - dialog.

I would appreciate your opinion about the way I have done
this dialog. 
There is also a problem: this dialog won't close when
clicking that 
cross at top right corner of the dialog.
What I've done wrong?
Is the dialog even the right way to do this?


    private void createDialog() throws java.lang.Exception {

        String listBoxName = "StyleListBox";

        // create the dialog model and set its properties
        Object dialogModel = 
xRemoteServiceManager.createInstanceWithContext(
               
"com.sun.star.awt.UnoControlDialogModel",
xRemoteContext);

        XPropertySet xPSetDialog = (XPropertySet)
UnoRuntime.queryInterface(
                XPropertySet.class, dialogModel);
        xPSetDialog.setPropertyValue("Sizeable",
new Boolean(false));
       
xPSetDialog.setPropertyValue("PositionX", new
Integer(100));
       
xPSetDialog.setPropertyValue("PositionY", new
Integer(100));
        xPSetDialog.setPropertyValue("Width",
new Integer(120));
        xPSetDialog.setPropertyValue("Height",
new Integer(280));
        xPSetDialog.setPropertyValue("Title",
                                     new
String("Styles and Formatting"));
       
xPSetDialog.setPropertyValue("Closeable", new
Boolean(false));

        // get the service manager from the dialog model
        XMultiServiceFactory xMultiServiceFactory =
(XMultiServiceFactory)
                UnoRuntime.queryInterface(
                        XMultiServiceFactory.class,
dialogModel);

        // create the listbox model and set its properties
        Object listBoxModel =
xMultiServiceFactory.createInstance(
               
"com.sun.star.awt.UnoControlListBoxModel");

        String[] a = {"My Heading1", "My
Heading2"};

        XPropertySet xPSetListBox = (XPropertySet) 
UnoRuntime.queryInterface(
                XPropertySet.class, listBoxModel);
       
xPSetListBox.setPropertyValue("MultiSelection",
new Boolean(false));
       
xPSetListBox.setPropertyValue("StringItemList",
a);
        xPSetListBox.setPropertyValue("Name",
listBoxName);
       
xPSetListBox.setPropertyValue("PositionX", new
Integer(0));
       
xPSetListBox.setPropertyValue("PositionY", new
Integer(0));
        xPSetListBox.setPropertyValue("Width",
new Integer(120));
        xPSetListBox.setPropertyValue("Height",
new Integer(280));

        // insert listbox model into the dialog model
        XNameContainer xNameCont = (XNameContainer) 
UnoRuntime.queryInterface(
                XNameContainer.class, dialogModel);

        xNameCont.insertByName(listBoxName, listBoxModel);

        // create the dialog control and set the model
        Object dialog =
xRemoteServiceManager.createInstanceWithContext(
               
"com.sun.star.awt.UnoControlDialog",
xRemoteContext);

        XControl xControl = (XControl)
UnoRuntime.queryInterface(
                XControl.class, dialog);

        XControlModel xControlModel = (XControlModel) 
UnoRuntime.queryInterface(
                XControlModel.class, dialogModel);

        xControl.setModel(xControlModel);


        // not quite sure what this does but it works
        XWindow xWindow = (XWindow)
UnoRuntime.queryInterface(
                XWindow.class, xControl);

        xWindow.setVisible(true);

    }

Tuomas

------------------------------------------------------------
---------
To unsubscribe, e-mail: dev-unsubscribeapi.openoffice.org
For additional commands, e-mail: dev-helpapi.openoffice.org

creating non-modal dialog
user name
2006-04-20 13:41:49
Hi Tuomas,
 

Alle 09:05, giovedì 20 aprile 2006, Tuomas Räsänen ha
scritto:
> Hi,
>
> My goal is to create a non-modal dialog to replace
default Styles and
> Formatting - dialog.
> MyDialog contains a listbox for styles just like the
Style and
> Formatting - dialog.
>
> I would appreciate your opinion about the way I have
done this dialog.
> There is also a problem: this dialog won't close when
clicking that
> cross at top right corner of the dialog.
> What I've done wrong?
> Is the dialog even the right way to do this?


It sounds quite strange to me that a UNOControlDialog
behaves as non-modal.

I'm not aware of AWT internals, so I may be wrong, anyway I
think that in your 
case this is only an unwanted side effect of the missing
peer initialization.
The same applies for the closing problem.

AFAIK it shouldn't be possible to create a non-modal dialog
starting from a 
css.awt.UNOControlDialogModel

IMHO you should start from a normal window+frame+controller
to do that


regards
Paolo Mantovani



------------------------------------------------------------
---------
To unsubscribe, e-mail: dev-unsubscribeapi.openoffice.org
For additional commands, e-mail: dev-helpapi.openoffice.org

creating non-modal dialog
user name
2006-04-21 18:12:54
Tuomas Räsänen wrote:

> My goal is to create a non-modal dialog to replace
default Styles and
> Formatting - dialog.
> MyDialog contains a listbox for styles just like the
Style and
> Formatting - dialog.
> 
> I would appreciate your opinion about the way I have
done this dialog.
> There is also a problem: this dialog won't close when
clicking that
> cross at top right corner of the dialog.
> What I've done wrong?

I'm not a dialog API expert, but the following line of code
looks
strange to me:

>        
xPSetDialog.setPropertyValue("Closeable", new
Boolean(false));

I understand this as a command that this dialog shouldn't
be closeable
and so it isn't surprising that nothing happens when you
click on the
closer. OTOH I wonder why there is a closer at all in this
case but this
might be a bug or imperfection.

Best regards,
Mathias

-- 
Mathias Bauer - OpenOffice.org Application Framework Project
Lead
Please reply to the list only, nospamforMBAgmx.de is
a spam sink.

------------------------------------------------------------
---------
To unsubscribe, e-mail: dev-unsubscribeapi.openoffice.org
For additional commands, e-mail: dev-helpapi.openoffice.org

[1-3]

about | contact  Other archives ( Real Estate discussion Medical topics )