Kaydet (Commit) 95692662 authored tarafından Mikhail Voitenko's avatar Mikhail Voitenko

store checkbox state in configuration

üst 19e7dac1
...@@ -4,9 +4,9 @@ ...@@ -4,9 +4,9 @@
* *
* $RCSfile: Helper.java,v $ * $RCSfile: Helper.java,v $
* *
* $Revision: 1.8 $ * $Revision: 1.9 $
* *
* last change: $Author: mav $ $Date: 2008-01-29 11:01:28 $ * last change: $Author: mav $ $Date: 2008-01-30 09:24:49 $
* *
* The Contents of this file are made available subject to * The Contents of this file are made available subject to
* the terms of GNU Lesser General Public License Version 2.1. * the terms of GNU Lesser General Public License Version 2.1.
...@@ -67,6 +67,7 @@ import com.sun.star.task.XPasswordContainer; ...@@ -67,6 +67,7 @@ import com.sun.star.task.XPasswordContainer;
import com.sun.star.uno.AnyConverter; import com.sun.star.uno.AnyConverter;
import com.sun.star.uno.UnoRuntime; import com.sun.star.uno.UnoRuntime;
import com.sun.star.uno.XComponentContext; import com.sun.star.uno.XComponentContext;
import com.sun.star.util.XChangesBatch;
import java.net.*; import java.net.*;
import java.io.*; import java.io.*;
import java.util.Hashtable; import java.util.Hashtable;
...@@ -242,22 +243,20 @@ public class Helper ...@@ -242,22 +243,20 @@ public class Helper
} }
} }
return ( m_bShowInBrowser != Boolean.FALSE ); return m_bShowInBrowser.booleanValue();
} }
synchronized protected static void SetShowInBrowserByDefault( XComponentContext xContext, boolean bValue ) synchronized protected static void SetShowInBrowserByDefault( XComponentContext xContext, boolean bValue )
{ {
try try
{ {
Boolean bShowInBrowser = new Boolean( bValue ); m_bShowInBrowser = new Boolean( bValue );
XNameContainer xContainer = Helper.GetConfigNameContainer( xContext, "org.openoffice.Office.Custom.WikiExtension/Settings" ); XPropertySet xProps = Helper.GetConfigProps( xContext, "org.openoffice.Office.Custom.WikiExtension/Settings" );
if ( xContainer.hasByName( "PreselectShowBrowser" ) ) xProps.setPropertyValue( "PreselectShowBrowser", new Boolean( bValue ) );
xContainer.replaceByName( "PreselectShowBrowser", bShowInBrowser ); XChangesBatch xBatch = ( XChangesBatch ) UnoRuntime.queryInterface( XChangesBatch.class, xProps );
else if ( xBatch != null )
xContainer.insertByName( "PreselectShowBrowser", bShowInBrowser ); xBatch.commitChanges();
m_bShowInBrowser = bShowInBrowser;
} }
catch( Exception e ) catch( Exception e )
{ {
...@@ -590,7 +589,7 @@ public class Helper ...@@ -590,7 +589,7 @@ public class Helper
return xConfigurationProvider; return xConfigurationProvider;
} }
protected static XNameContainer GetConfigNameContainer( XComponentContext xContext, String sNodepath ) protected static Object GetConfig( XComponentContext xContext, String sNodepath, boolean bWriteAccess )
throws com.sun.star.uno.Exception throws com.sun.star.uno.Exception
{ {
if ( xContext == null || sNodepath == null ) if ( xContext == null || sNodepath == null )
...@@ -602,32 +601,37 @@ public class Helper ...@@ -602,32 +601,37 @@ public class Helper
Object[] aArgs = new Object[1]; Object[] aArgs = new Object[1];
aArgs[0] = aVal; aArgs[0] = aVal;
Object oSettings = GetConfigurationProvider( xContext ).createInstanceWithArguments( return GetConfigurationProvider( xContext ).createInstanceWithArguments(
"com.sun.star.configuration.ConfigurationUpdateAccess", ( bWriteAccess ? "com.sun.star.configuration.ConfigurationUpdateAccess"
: "com.sun.star.configuration.ConfigurationAccess" ),
aArgs ); aArgs );
XNameContainer xContainer = ( XNameContainer ) UnoRuntime.queryInterface( XNameContainer.class, oSettings ); }
if ( xContainer == null )
protected static XPropertySet GetConfigProps( XComponentContext xContext, String sNodepath )
throws com.sun.star.uno.Exception
{
XPropertySet xProps = ( XPropertySet ) UnoRuntime.queryInterface( XPropertySet.class, GetConfig( xContext, sNodepath, true ) );
if ( xProps == null )
throw new com.sun.star.uno.RuntimeException(); throw new com.sun.star.uno.RuntimeException();
return xContainer; return xProps;
} }
protected static XNameAccess GetConfigNameAccess( XComponentContext xContext, String sNodepath )
protected static XNameContainer GetConfigNameContainer( XComponentContext xContext, String sNodepath )
throws com.sun.star.uno.Exception throws com.sun.star.uno.Exception
{ {
if ( xContext == null || sNodepath == null ) XNameContainer xContainer = ( XNameContainer ) UnoRuntime.queryInterface( XNameContainer.class, GetConfig( xContext, sNodepath, true ) );
if ( xContainer == null )
throw new com.sun.star.uno.RuntimeException(); throw new com.sun.star.uno.RuntimeException();
PropertyValue aVal = new PropertyValue(); return xContainer;
aVal.Name = "nodepath"; }
aVal.Value = sNodepath;
Object[] aArgs = new Object[1];
aArgs[0] = aVal;
Object oSettings = GetConfigurationProvider( xContext ).createInstanceWithArguments( protected static XNameAccess GetConfigNameAccess( XComponentContext xContext, String sNodepath )
"com.sun.star.configuration.ConfigurationAccess", throws com.sun.star.uno.Exception
aArgs ); {
XNameAccess xNameAccess = ( XNameAccess ) UnoRuntime.queryInterface( XNameAccess.class, oSettings ); XNameAccess xNameAccess = ( XNameAccess ) UnoRuntime.queryInterface( XNameAccess.class, GetConfig( xContext, sNodepath, false ) );
if ( xNameAccess == null ) if ( xNameAccess == null )
throw new com.sun.star.uno.RuntimeException(); throw new com.sun.star.uno.RuntimeException();
...@@ -895,7 +899,7 @@ public class Helper ...@@ -895,7 +899,7 @@ public class Helper
{ {
sError = GetLocalizedString( xContext, nErrorID ); sError = GetLocalizedString( xContext, nErrorID );
if ( sError != null && sArg != null ) if ( sError != null && sArg != null )
sError.replaceAll( "\\$ARG1", sArg ); sError.replaceAll( "$ARG1", sArg );
sTitle = GetLocalizedString( xContext, nTitleID ); sTitle = GetLocalizedString( xContext, nTitleID );
} }
......
...@@ -4,9 +4,9 @@ ...@@ -4,9 +4,9 @@
* *
* $RCSfile: WikiEditSettingDialog.java,v $ * $RCSfile: WikiEditSettingDialog.java,v $
* *
* $Revision: 1.9 $ * $Revision: 1.10 $
* *
* last change: $Author: mav $ $Date: 2008-01-29 11:01:28 $ * last change: $Author: mav $ $Date: 2008-01-30 09:24:49 $
* *
* The Contents of this file are made available subject to * The Contents of this file are made available subject to
* the terms of GNU Lesser General Public License Version 2.1. * the terms of GNU Lesser General Public License Version 2.1.
...@@ -82,7 +82,10 @@ public class WikiEditSettingDialog extends WikiDialog ...@@ -82,7 +82,10 @@ public class WikiEditSettingDialog extends WikiDialog
setting = ht; setting = ht;
try try
{ {
GetPropSet( "UrlField" ).setPropertyValue( "Text", ht.get( "Url" )); XPropertySet xUrlField = GetPropSet( "UrlField" );
xUrlField.setPropertyValue( "Text", ht.get( "Url" ) );
xUrlField.setPropertyValue( "Enabled", Boolean.FALSE );
GetPropSet( "UsernameField" ).setPropertyValue( "Text", ht.get( "Username" )); GetPropSet( "UsernameField" ).setPropertyValue( "Text", ht.get( "Username" ));
GetPropSet( "PasswordField" ).setPropertyValue( "Text", ht.get( "Password" )); GetPropSet( "PasswordField" ).setPropertyValue( "Text", ht.get( "Password" ));
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment