diff options
Diffstat (limited to 'odk/examples/DevelopersGuide/BasicAndDialogs/CreatingDialogs/SampleDialog.java')
-rw-r--r-- | odk/examples/DevelopersGuide/BasicAndDialogs/CreatingDialogs/SampleDialog.java | 68 |
1 files changed, 34 insertions, 34 deletions
diff --git a/odk/examples/DevelopersGuide/BasicAndDialogs/CreatingDialogs/SampleDialog.java b/odk/examples/DevelopersGuide/BasicAndDialogs/CreatingDialogs/SampleDialog.java index 27a97ec40345..6145a3c49949 100644 --- a/odk/examples/DevelopersGuide/BasicAndDialogs/CreatingDialogs/SampleDialog.java +++ b/odk/examples/DevelopersGuide/BasicAndDialogs/CreatingDialogs/SampleDialog.java @@ -2,7 +2,7 @@ * * The Contents of this file are made available subject to the terms of * the BSD license. - * + * * Copyright 2000, 2010 Oracle and/or its affiliates. * All rights reserved. * @@ -29,7 +29,7 @@ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * *************************************************************************/ package com.sun.star.comp.sdk.examples; @@ -73,20 +73,20 @@ import com.sun.star.uno.XComponentContext; */ public class SampleDialog extends WeakBase implements XServiceInfo, XJobExecutor { - + static final String __serviceName = "com.sun.star.examples.SampleDialog"; private static final String _buttonName = "Button1"; private static final String _cancelButtonName = "CancelButton"; private static final String _labelName = "Label1"; private static final String _labelPrefix = "Number of button clicks: "; - + private XComponentContext _xComponentContext; - + public SampleDialog( XComponentContext xComponentContext ) { _xComponentContext = xComponentContext; } - + // static component operations public static XSingleServiceFactory __getServiceFactory( String implName, XMultiServiceFactory multiFactory, @@ -95,7 +95,7 @@ public class SampleDialog extends WeakBase implements XServiceInfo, XJobExecutor if ( implName.equals( SampleDialog.class.getName() ) ) { xSingleServiceFactory = FactoryHelper.getServiceFactory( SampleDialog.class, SampleDialog.__serviceName, multiFactory, regKey ); - } + } return xSingleServiceFactory; } @@ -103,7 +103,7 @@ public class SampleDialog extends WeakBase implements XServiceInfo, XJobExecutor return FactoryHelper.writeRegistryServiceInfo( SampleDialog.class.getName(), SampleDialog.__serviceName, regKey ); } - + // XServiceInfo public String getImplementationName( ) { return getClass().getName(); @@ -111,11 +111,11 @@ public class SampleDialog extends WeakBase implements XServiceInfo, XJobExecutor // XServiceInfo public boolean supportsService( /*IN*/String serviceName ) { - if ( serviceName.equals( __serviceName)) + if ( serviceName.equals( __serviceName)) return true; return false; } - + // XServiceInfo public String[] getSupportedServiceNames( ) { String[] retValue= new String[0]; @@ -132,7 +132,7 @@ public class SampleDialog extends WeakBase implements XServiceInfo, XJobExecutor catch ( Exception e ) { throw new com.sun.star.lang.WrappedTargetRuntimeException( e.getMessage(), this, e ); } - } + } } /** method for creating a dialog at runtime @@ -141,12 +141,12 @@ public class SampleDialog extends WeakBase implements XServiceInfo, XJobExecutor // get the service manager from the component context XMultiComponentFactory xMultiComponentFactory = _xComponentContext.getServiceManager(); - + // create the dialog model and set the properties Object dialogModel = xMultiComponentFactory.createInstanceWithContext( "com.sun.star.awt.UnoControlDialogModel", _xComponentContext ); XPropertySet xPSetDialog = ( XPropertySet )UnoRuntime.queryInterface( - XPropertySet.class, dialogModel ); + XPropertySet.class, dialogModel ); xPSetDialog.setPropertyValue( "PositionX", new Integer( 100 ) ); xPSetDialog.setPropertyValue( "PositionY", new Integer( 100 ) ); xPSetDialog.setPropertyValue( "Width", new Integer( 150 ) ); @@ -156,7 +156,7 @@ public class SampleDialog extends WeakBase implements XServiceInfo, XJobExecutor // get the service manager from the dialog model XMultiServiceFactory xMultiServiceFactory = ( XMultiServiceFactory )UnoRuntime.queryInterface( XMultiServiceFactory.class, dialogModel ); - + // create the button model and set the properties Object buttonModel = xMultiServiceFactory.createInstance( "com.sun.star.awt.UnoControlButtonModel" ); @@ -167,9 +167,9 @@ public class SampleDialog extends WeakBase implements XServiceInfo, XJobExecutor xPSetButton.setPropertyValue( "Width", new Integer( 50 ) ); xPSetButton.setPropertyValue( "Height", new Integer( 14 ) ); xPSetButton.setPropertyValue( "Name", _buttonName ); - xPSetButton.setPropertyValue( "TabIndex", new Short( (short)0 ) ); + xPSetButton.setPropertyValue( "TabIndex", new Short( (short)0 ) ); xPSetButton.setPropertyValue( "Label", new String( "Click Me" ) ); - + // create the label model and set the properties Object labelModel = xMultiServiceFactory.createInstance( "com.sun.star.awt.UnoControlFixedTextModel" ); @@ -180,7 +180,7 @@ public class SampleDialog extends WeakBase implements XServiceInfo, XJobExecutor xPSetLabel.setPropertyValue( "Width", new Integer( 100 ) ); xPSetLabel.setPropertyValue( "Height", new Integer( 14 ) ); xPSetLabel.setPropertyValue( "Name", _labelName ); - xPSetLabel.setPropertyValue( "TabIndex", new Short( (short)1 ) ); + xPSetLabel.setPropertyValue( "TabIndex", new Short( (short)1 ) ); xPSetLabel.setPropertyValue( "Label", _labelPrefix ); // create a Cancel button model and set the properties @@ -193,49 +193,49 @@ public class SampleDialog extends WeakBase implements XServiceInfo, XJobExecutor xPSetCancelButton.setPropertyValue( "Width", new Integer( 50 ) ); xPSetCancelButton.setPropertyValue( "Height", new Integer( 14 ) ); xPSetCancelButton.setPropertyValue( "Name", _cancelButtonName ); - xPSetCancelButton.setPropertyValue( "TabIndex", new Short( (short)2 ) ); + xPSetCancelButton.setPropertyValue( "TabIndex", new Short( (short)2 ) ); xPSetCancelButton.setPropertyValue( "PushButtonType", new Short( (short)2 ) ); xPSetCancelButton.setPropertyValue( "Label", new String( "Cancel" ) ); - + // insert the control models into the dialog model XNameContainer xNameCont = ( XNameContainer )UnoRuntime.queryInterface( XNameContainer.class, dialogModel ); xNameCont.insertByName( _buttonName, buttonModel ); xNameCont.insertByName( _labelName, labelModel ); xNameCont.insertByName( _cancelButtonName, cancelButtonModel ); - + // create the dialog control and set the model Object dialog = xMultiComponentFactory.createInstanceWithContext( "com.sun.star.awt.UnoControlDialog", _xComponentContext ); XControl xControl = ( XControl )UnoRuntime.queryInterface( XControl.class, dialog ); XControlModel xControlModel = ( XControlModel )UnoRuntime.queryInterface( - XControlModel.class, dialogModel ); + XControlModel.class, dialogModel ); xControl.setModel( xControlModel ); - + // add an action listener to the button control XControlContainer xControlCont = ( XControlContainer )UnoRuntime.queryInterface( - XControlContainer.class, dialog ); + XControlContainer.class, dialog ); Object objectButton = xControlCont.getControl( "Button1" ); XButton xButton = ( XButton )UnoRuntime.queryInterface( XButton.class, objectButton ); xButton.addActionListener( new ActionListenerImpl( xControlCont ) ); - + // create a peer Object toolkit = xMultiComponentFactory.createInstanceWithContext( - "com.sun.star.awt.ExtToolkit", _xComponentContext ); + "com.sun.star.awt.ExtToolkit", _xComponentContext ); XToolkit xToolkit = ( XToolkit )UnoRuntime.queryInterface( XToolkit.class, toolkit ); XWindow xWindow = ( XWindow )UnoRuntime.queryInterface( XWindow.class, xControl ); - xWindow.setVisible( false ); + xWindow.setVisible( false ); xControl.createPeer( xToolkit, null ); - + // execute the dialog XDialog xDialog = ( XDialog )UnoRuntime.queryInterface( XDialog.class, dialog ); xDialog.execute(); - + // dispose the dialog XComponent xComponent = ( XComponent )UnoRuntime.queryInterface( XComponent.class, dialog ); @@ -253,23 +253,23 @@ public class SampleDialog extends WeakBase implements XServiceInfo, XJobExecutor public ActionListenerImpl( XControlContainer xControlCont ) { _xControlCont = xControlCont; } - + // XEventListener public void disposing( EventObject eventObject ) { _xControlCont = null; } - + // XActionListener public void actionPerformed( ActionEvent actionEvent ) { // increase click counter _nCounts++; - + // set label text Object label = _xControlCont.getControl( "Label1" ); XFixedText xLabel = ( XFixedText )UnoRuntime.queryInterface( - XFixedText.class, label ); + XFixedText.class, label ); xLabel.setText( _labelPrefix + _nCounts ); - } - } + } + } } |