summaryrefslogtreecommitdiff
path: root/odk
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2014-09-16 13:17:53 +0200
committerStephan Bergmann <sbergman@redhat.com>2014-09-16 13:17:53 +0200
commita3ed215584a9347f63739966c19a7dcb39c07b01 (patch)
treeb075f0e5254baf9e7bb42fbe98920ebe84624154 /odk
parentd3886f87789c880a662eecc5986ac03e76ca13b6 (diff)
Add back XTestDialogHandler methods
...erroneously removed by 34bcf9b498bccb5c924f4cec850ff15d88df6f07 "java: remove dead methods," plus fix-up of d5a31b221510a506a9c43d2c9f44c55405ce13fd "java: remove unused parameters" regression. Change-Id: I2913af8f35b89ebc580ab5f4f0025b595ad8cd0f
Diffstat (limited to 'odk')
-rw-r--r--odk/examples/DevelopersGuide/Components/dialogcomponent/DialogComponent.java73
1 files changed, 73 insertions, 0 deletions
diff --git a/odk/examples/DevelopersGuide/Components/dialogcomponent/DialogComponent.java b/odk/examples/DevelopersGuide/Components/dialogcomponent/DialogComponent.java
index 4004a50a9c3e..f814deb16193 100644
--- a/odk/examples/DevelopersGuide/Components/dialogcomponent/DialogComponent.java
+++ b/odk/examples/DevelopersGuide/Components/dialogcomponent/DialogComponent.java
@@ -32,16 +32,23 @@
*
*************************************************************************/
+import com.sun.star.beans.XPropertySet;
import com.sun.star.uno.Type;
import com.sun.star.uno.UnoRuntime;
import com.sun.star.uno.XComponentContext;
+import com.sun.star.lang.XMultiComponentFactory;
import com.sun.star.lang.XTypeProvider;
import com.sun.star.lang.XServiceInfo;
import com.sun.star.lang.XSingleComponentFactory;
import com.sun.star.lib.uno.helper.Factory;
+import com.sun.star.awt.XControl;
+import com.sun.star.awt.XControlContainer;
+import com.sun.star.awt.XControlModel;
import com.sun.star.awt.XDialog;
import com.sun.star.awt.XDialogEventHandler;
+import com.sun.star.awt.XDialogProvider2;
import com.sun.star.frame.XFrame;
+import com.sun.star.frame.XModel;
import com.sun.star.awt.XToolkit;
import com.sun.star.awt.XWindowPeer;
@@ -84,13 +91,79 @@ public class DialogComponent {
}
}
+ // XTestDialogHandler
+ public String createDialog( String DialogURL, XModel xModel, XFrame xFrame ) {
+ m_xFrame = xFrame;
+ try {
+ XMultiComponentFactory xMCF = m_xCmpCtx.getServiceManager();
+ Object obj;
+
+ // If valid we must pass the XModel when creating a DialogProvider object
+ if( xModel != null ) {
+ Object[] args = new Object[1];
+ args[0] = xModel;
+
+ obj = xMCF.createInstanceWithArgumentsAndContext(
+ "com.sun.star.awt.DialogProvider2", args, m_xCmpCtx );
+ }
+ else {
+ obj = xMCF.createInstanceWithContext(
+ "com.sun.star.awt.DialogProvider2", m_xCmpCtx );
+ }
+
+ XDialogProvider2 xDialogProvider = UnoRuntime.queryInterface( XDialogProvider2.class, obj );
+ XDialog xDialog = xDialogProvider.createDialogWithHandler( DialogURL, this );
+ if( xDialog != null )
+ xDialog.execute();
+ }
+ catch (Exception e) {
+ e.printStackTrace();
+ }
+ return "Created dialog \"" + DialogURL + "\"";
+ }
+ public void copyText( XDialog xDialog, Object aEventObject ) {
+ XControlContainer xControlContainer = UnoRuntime.queryInterface(
+ XControlContainer.class, xDialog );
+ String aTextPropertyStr = "Text";
+ String aText = "";
+ XControl xTextField1Control = xControlContainer.getControl( "TextField1" );
+ XControlModel xControlModel1 = xTextField1Control.getModel();
+ XPropertySet xPropertySet1 = UnoRuntime.queryInterface(
+ XPropertySet.class, xControlModel1 );
+ try
+ {
+ aText = (String)xPropertySet1.getPropertyValue( aTextPropertyStr );
+ }
+ catch (Exception e) {
+ e.printStackTrace();
+ }
+ XControl xTextField2Control = xControlContainer.getControl( "TextField2" );
+ XControlModel xControlModel2 = xTextField2Control.getModel();
+ XPropertySet xPropertySet2 = UnoRuntime.queryInterface(
+ XPropertySet.class, xControlModel2 );
+ try
+ {
+ xPropertySet2.setPropertyValue( aTextPropertyStr, aText );
+ }
+ catch (Exception e) {
+ e.printStackTrace();
+ }
+ showMessageBox( "DialogComponent", "copyText() called" );
+ }
+ public void handleEvent() {
+ showMessageBox( "DialogComponent", "handleEvent() called" );
+ }
+ public void handleEventWithArguments( XDialog xDialog, Object aEventObject ) {
+ showMessageBox( "DialogComponent", "handleEventWithArguments() called\n\n" +
+ "Event Object = " + aEventObject );
+ }
private final String aHandlerMethod1 = "doit1";
private final String aHandlerMethod2 = "doit2";