diff options
Diffstat (limited to 'odk/examples/DevelopersGuide/GUI/SystemDialog.java')
-rw-r--r-- | odk/examples/DevelopersGuide/GUI/SystemDialog.java | 34 |
1 files changed, 17 insertions, 17 deletions
diff --git a/odk/examples/DevelopersGuide/GUI/SystemDialog.java b/odk/examples/DevelopersGuide/GUI/SystemDialog.java index 00aa44162442..c20718dfc300 100644 --- a/odk/examples/DevelopersGuide/GUI/SystemDialog.java +++ b/odk/examples/DevelopersGuide/GUI/SystemDialog.java @@ -46,16 +46,16 @@ import com.sun.star.uno.XComponentContext; public class SystemDialog { - + protected XComponentContext m_xContext = null; protected com.sun.star.lang.XMultiComponentFactory m_xMCF; - + /** Creates a new instance of MessageBox */ public SystemDialog(XComponentContext _xContext, XMultiComponentFactory _xMCF){ m_xContext = _xContext; m_xMCF = _xMCF; } - + public static void main(String args[]){ try { XComponentContext xContext = com.sun.star.comp.helper.Bootstrap.bootstrap(); @@ -72,8 +72,8 @@ public class SystemDialog { System.exit( 0 ); } - - + + public String raiseSaveAsDialog() { String sStorePath = ""; XComponent xComponent = null; @@ -81,37 +81,37 @@ public class SystemDialog { // the filepicker is instantiated with the global Multicomponentfactory... Object oFilePicker = m_xMCF.createInstanceWithContext("com.sun.star.ui.dialogs.FilePicker", m_xContext); XFilePicker xFilePicker = (XFilePicker) UnoRuntime.queryInterface(XFilePicker.class, oFilePicker); - + // the defaultname is the initially proposed filename.. xFilePicker.setDefaultName("MyExampleDocument"); - + // set the initial displaydirectory. In this example the user template directory is used Object oPathSettings = m_xMCF.createInstanceWithContext("com.sun.star.util.PathSettings",m_xContext); XPropertySet xPropertySet = (XPropertySet) com.sun.star.uno.UnoRuntime.queryInterface(XPropertySet.class, oPathSettings); String sTemplateUrl = (String) xPropertySet.getPropertyValue("Template_writable"); xFilePicker.setDisplayDirectory(sTemplateUrl); - + // set the filters of the dialog. The filternames may be retrieved from // http://wiki.services.openoffice.org/wiki/Framework/Article/Filter XFilterManager xFilterManager = (XFilterManager) UnoRuntime.queryInterface(XFilterManager.class, xFilePicker); xFilterManager.appendFilter("OpenDocument Text Template", "writer8_template"); xFilterManager.appendFilter("OpenDocument Text", "writer8"); - + // choose the template that defines the capabilities of the filepicker dialog XInitialization xInitialize = (XInitialization) UnoRuntime.queryInterface(XInitialization.class, xFilePicker); Short[] listAny = new Short[] { new Short(com.sun.star.ui.dialogs.TemplateDescription.FILESAVE_AUTOEXTENSION)}; xInitialize.initialize(listAny); - + // add a control to the dialog to add the extension automatically to the filename... XFilePickerControlAccess xFilePickerControlAccess = (XFilePickerControlAccess) UnoRuntime.queryInterface(XFilePickerControlAccess.class, xFilePicker); xFilePickerControlAccess.setValue(com.sun.star.ui.dialogs.ExtendedFilePickerElementIds.CHECKBOX_AUTOEXTENSION, (short) 0, new Boolean(true)); - + xComponent = (XComponent) UnoRuntime.queryInterface(XComponent.class, xFilePicker); - + // execute the dialog... XExecutableDialog xExecutable = (XExecutableDialog) UnoRuntime.queryInterface(XExecutableDialog.class, xFilePicker); short nResult = xExecutable.execute(); - + // query the resulting path of the dialog... if (nResult == com.sun.star.ui.dialogs.ExecutableDialogResults.OK){ String[] sPathList = xFilePicker.getFiles(); @@ -129,7 +129,7 @@ public class SystemDialog { } return sStorePath; } - + public String getWorkPath(){ String sWorkUrl = ""; try{ @@ -142,7 +142,7 @@ public class SystemDialog { } return sWorkUrl; } - + /** raises a folderpicker in which the user can browse and select a path * @param _sDisplayDirectory the path to the directory that is initially displayed * @param _sTitle the title of the folderpicker @@ -165,12 +165,12 @@ public class SystemDialog { xFolderPicker.setTitle(_sTitle); // show the dialog... short nResult = xExecutable.execute(); - + // User has clicked "Select" button... if (nResult == com.sun.star.ui.dialogs.ExecutableDialogResults.OK){ sReturnFolder = xFolderPicker.getDirectory(); } - + }catch( Exception exception ) { exception.printStackTrace(System.out); } finally{ |