summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMikhail Voitenko <mav@openoffice.org>2008-01-30 18:02:16 +0000
committerMikhail Voitenko <mav@openoffice.org>2008-01-30 18:02:16 +0000
commite9a361bc9c1a6387151d7b1f33ae0cc957355002 (patch)
treee38698a011c0c434352b95f9df087d3903828a1f
parentce3035900899cce324433457e77929fa4991ffae (diff)
react on actions
-rw-r--r--swext/mediawiki/dialogs/Settings.xdl5
-rw-r--r--swext/mediawiki/src/com/sun/star/wiki/Helper.java26
-rw-r--r--swext/mediawiki/src/com/sun/star/wiki/WikiArticle.java6
-rw-r--r--swext/mediawiki/src/com/sun/star/wiki/WikiEditSettingDialog.java319
-rw-r--r--swext/mediawiki/src/com/sun/star/wiki/WikiOptionsEventHandlerImpl.java9
-rw-r--r--swext/mediawiki/src/com/sun/star/wiki/WikiPropDialog.java21
6 files changed, 237 insertions, 149 deletions
diff --git a/swext/mediawiki/dialogs/Settings.xdl b/swext/mediawiki/dialogs/Settings.xdl
index 013aa90ca9ab..b986abc017c5 100644
--- a/swext/mediawiki/dialogs/Settings.xdl
+++ b/swext/mediawiki/dialogs/Settings.xdl
@@ -5,9 +5,9 @@
*
* $RCSfile: Settings.xdl,v $
*
- * $Revision: 1.4 $
+ * $Revision: 1.5 $
*
- * last change: $Author: mav $ $Date: 2008-01-21 12:57:52 $
+ * last change: $Author: mav $ $Date: 2008-01-30 19:02:05 $
*
* The Contents of this file are made available subject to
* the terms of GNU Lesser General Public License Version 2.1.
@@ -47,6 +47,7 @@
</dlg:button>
<dlg:menulist dlg:id="WikiList" dlg:tab-index="0" dlg:left="6" dlg:top="6" dlg:width="188" dlg:height="150" dlg:help-url="HID:31681" dlg:multiselection="true">
<script:event script:event-name="on-itemstatechange" script:macro-name="vnd.sun.star.UNO:ListStatus" script:language="UNO"/>
+ <script:event script:event-name="on-performaction" script:macro-name="vnd.sun.star.UNO:ListEdit" script:language="UNO"/>
</dlg:menulist>
</dlg:bulletinboard>
</dlg:window>
diff --git a/swext/mediawiki/src/com/sun/star/wiki/Helper.java b/swext/mediawiki/src/com/sun/star/wiki/Helper.java
index ae1db647b4be..a62bf189bcd5 100644
--- a/swext/mediawiki/src/com/sun/star/wiki/Helper.java
+++ b/swext/mediawiki/src/com/sun/star/wiki/Helper.java
@@ -4,9 +4,9 @@
*
* $RCSfile: Helper.java,v $
*
- * $Revision: 1.12 $
+ * $Revision: 1.13 $
*
- * last change: $Author: mav $ $Date: 2008-01-30 16:08:26 $
+ * last change: $Author: mav $ $Date: 2008-01-30 19:02:16 $
*
* The Contents of this file are made available subject to
* the terms of GNU Lesser General Public License Version 2.1.
@@ -1052,5 +1052,27 @@ public class Helper
return null;
}
+
+ protected static boolean AllowThreadUsage( XComponentContext xContext )
+ {
+ if ( xContext != null )
+ {
+ try
+ {
+ XMultiComponentFactory xFactory = xContext.getServiceManager();
+ if ( xFactory == null )
+ throw new com.sun.star.uno.RuntimeException();
+
+ Object oCheckCallback = xFactory.createInstanceWithContext( "com.sun.star.awt.AsyncCallback", xContext );
+ return ( oCheckCallback != null );
+ }
+ catch( Exception e )
+ {
+ e.printStackTrace();
+ }
+ }
+
+ return false;
+ }
}
diff --git a/swext/mediawiki/src/com/sun/star/wiki/WikiArticle.java b/swext/mediawiki/src/com/sun/star/wiki/WikiArticle.java
index 6273f931ff72..732682e7151c 100644
--- a/swext/mediawiki/src/com/sun/star/wiki/WikiArticle.java
+++ b/swext/mediawiki/src/com/sun/star/wiki/WikiArticle.java
@@ -4,9 +4,9 @@
*
* $RCSfile: WikiArticle.java,v $
*
- * $Revision: 1.3 $
+ * $Revision: 1.4 $
*
- * last change: $Author: mav $ $Date: 2008-01-29 11:01:28 $
+ * last change: $Author: mav $ $Date: 2008-01-30 19:02:16 $
*
* The Contents of this file are made available subject to
* the terms of GNU Lesser General Public License Version 2.1.
@@ -103,7 +103,7 @@ public class WikiArticle
while( bLogin && !bGotLogin && !Login() )
{
// TODO: be sure that this is no main thread
- WikiEditSettingDialog wd = new WikiEditSettingDialog(m_xContext, "vnd.sun.star.script:WikiEditor.EditSetting?location=application", wikiSettings );
+ WikiEditSettingDialog wd = new WikiEditSettingDialog(m_xContext, "vnd.sun.star.script:WikiEditor.EditSetting?location=application", wikiSettings, false );
if ( aPropDialog != null )
aPropDialog.SetThrobberActive( false );
diff --git a/swext/mediawiki/src/com/sun/star/wiki/WikiEditSettingDialog.java b/swext/mediawiki/src/com/sun/star/wiki/WikiEditSettingDialog.java
index eac008cf86da..11c87c42a7ba 100644
--- a/swext/mediawiki/src/com/sun/star/wiki/WikiEditSettingDialog.java
+++ b/swext/mediawiki/src/com/sun/star/wiki/WikiEditSettingDialog.java
@@ -4,9 +4,9 @@
*
* $RCSfile: WikiEditSettingDialog.java,v $
*
- * $Revision: 1.11 $
+ * $Revision: 1.12 $
*
- * last change: $Author: mav $ $Date: 2008-01-30 14:27:32 $
+ * last change: $Author: mav $ $Date: 2008-01-30 19:02:16 $
*
* The Contents of this file are made available subject to
* the terms of GNU Lesser General Public License Version 2.1.
@@ -63,6 +63,7 @@ public class WikiEditSettingDialog extends WikiDialog
{sOKMethod, sCancelMethod, sHelpMethod};
private Hashtable setting;
private boolean addMode;
+ private boolean m_bAllowURLChange = true;
public WikiEditSettingDialog( XComponentContext xContext, String DialogURL )
{
@@ -75,7 +76,7 @@ public class WikiEditSettingDialog extends WikiDialog
InitSaveCheckbox( xContext );
}
- public WikiEditSettingDialog( XComponentContext xContext, String DialogURL, Hashtable ht )
+ public WikiEditSettingDialog( XComponentContext xContext, String DialogURL, Hashtable ht, boolean bAllowURLChange )
{
super( xContext, DialogURL );
super.setMethods( Methods );
@@ -85,7 +86,6 @@ public class WikiEditSettingDialog extends WikiDialog
XPropertySet xUrlField = GetPropSet( "UrlField" );
xUrlField.setPropertyValue( "Text", ht.get( "Url" ) );
- xUrlField.setPropertyValue( "Enabled", Boolean.FALSE );
GetPropSet( "UsernameField" ).setPropertyValue( "Text", ht.get( "Username" ));
GetPropSet( "PasswordField" ).setPropertyValue( "Text", ht.get( "Password" ));
}
@@ -93,12 +93,42 @@ public class WikiEditSettingDialog extends WikiDialog
{
ex.printStackTrace();
}
+
addMode = false;
+ m_bAllowURLChange = bAllowURLChange;
InitStrings( xContext );
InitSaveCheckbox( xContext );
}
+ public boolean show( )
+ {
+ EnableControls( true );
+ return super.show();
+ }
+
+ private void EnableControls( boolean bEnable )
+ {
+ try
+ {
+ GetPropSet( "UrlField" ).setPropertyValue( "Enabled", new Boolean( m_bAllowURLChange ) );
+ GetPropSet( "UsernameField" ).setPropertyValue( "Enabled", new Boolean( bEnable ) );
+ GetPropSet( "PasswordField" ).setPropertyValue( "Enabled", new Boolean( bEnable ) );
+ GetPropSet( "OkButton" ).setPropertyValue( "Enabled", new Boolean( bEnable ) );
+ GetPropSet( "HelpButton" ).setPropertyValue( "Enabled", new Boolean( bEnable ) );
+
+ if ( bEnable )
+ GetPropSet( "SaveBox" ).setPropertyValue( "Enabled", new Boolean( Helper.PasswordStoringIsAllowed( m_xContext ) ) );
+ else
+ GetPropSet( "SaveBox" ).setPropertyValue( "Enabled", Boolean.FALSE );
+
+ }
+ catch ( Exception ex )
+ {
+ ex.printStackTrace();
+ }
+ }
+
private void InitStrings( XComponentContext xContext )
{
try
@@ -134,161 +164,210 @@ public class WikiEditSettingDialog extends WikiDialog
}
}
- public boolean callHandlerMethod( XDialog xDialog, Object EventObject, String MethodName )
+ public void DoLogin( XDialog xDialog )
{
- if ( MethodName.equals( sOKMethod ) )
+ String sRedirectURL = "";
+ String sURL = "";
+ try
{
- String sRedirectURL = "";
- String sURL = "";
- try
- {
- sURL = ( String ) GetPropSet( "UrlField" ).getPropertyValue( "Text" );
- String sUserName = ( String ) GetPropSet( "UsernameField" ).getPropertyValue( "Text" );
- String sPassword = ( String ) GetPropSet( "PasswordField" ).getPropertyValue( "Text" );
+ sURL = ( String ) GetPropSet( "UrlField" ).getPropertyValue( "Text" );
+ String sUserName = ( String ) GetPropSet( "UsernameField" ).getPropertyValue( "Text" );
+ String sPassword = ( String ) GetPropSet( "PasswordField" ).getPropertyValue( "Text" );
- HostConfiguration aHostConfig = new HostConfiguration();
- boolean bInitHost = true;
+ HostConfiguration aHostConfig = new HostConfiguration();
+ boolean bInitHost = true;
- do
+ do
+ {
+ if ( sRedirectURL.length() > 0 )
{
- if ( sRedirectURL.length() > 0 )
- {
- sURL = sRedirectURL;
- sRedirectURL = "";
- }
+ sURL = sRedirectURL;
+ sRedirectURL = "";
+ }
+
+ if ( sURL.length() > 0 )
+ {
+ URI aURI = new URI( sURL );
+ GetMethod aRequest = new GetMethod( aURI.getEscapedPathQuery() );
+ aRequest.setFollowRedirects( false );
+ Helper.ExecuteMethod( aRequest, aHostConfig, aURI, m_xContext, bInitHost );
+ bInitHost = false;
+
+ int nResultCode = aRequest.getStatusCode();
+ String sWebPage = null;
+ if ( nResultCode == 200 )
+ sWebPage = aRequest.getResponseBodyAsString();
+ else if ( nResultCode >= 301 && nResultCode <= 303 || nResultCode == 307 )
+ sRedirectURL = aRequest.getResponseHeader( "Location" ).getValue();
+
+ aRequest.releaseConnection();
- if ( sURL.length() > 0 )
+ if ( sWebPage != null && sWebPage.length() > 0 )
{
- URI aURI = new URI( sURL );
- GetMethod aRequest = new GetMethod( aURI.getEscapedPathQuery() );
- aRequest.setFollowRedirects( false );
- Helper.ExecuteMethod( aRequest, aHostConfig, aURI, m_xContext, bInitHost );
- bInitHost = false;
-
- int nResultCode = aRequest.getStatusCode();
- String sWebPage = null;
- if ( nResultCode == 200 )
- sWebPage = aRequest.getResponseBodyAsString();
- else if ( nResultCode >= 301 && nResultCode <= 303 || nResultCode == 307 )
- sRedirectURL = aRequest.getResponseHeader( "Location" ).getValue();
-
- aRequest.releaseConnection();
-
- if ( sWebPage != null && sWebPage.length() > 0 )
- {
- //the URL is valid
- String sMainURL = Helper.GetMainURL( sWebPage, sURL );
+ //the URL is valid
+ String sMainURL = Helper.GetMainURL( sWebPage, sURL );
- if ( sMainURL.equals( "" ) )
+ if ( sMainURL.equals( "" ) )
+ {
+ // TODO:
+ // it's not a Wiki Page, check first whether a redirect is requested
+ // happens usually in case of https
+ sRedirectURL = Helper.GetRedirectURL( sWebPage, sURL );
+ if ( sRedirectURL.equals( "" ) )
{
- // TODO:
- // it's not a Wiki Page, check first whether a redirect is requested
- // happens usually in case of https
- sRedirectURL = Helper.GetRedirectURL( sWebPage, sURL );
- if ( sRedirectURL.equals( "" ) )
- {
- // show error
- Helper.ShowError( m_xContext,
- m_xDialog,
- Helper.DLG_MEDIAWIKI_TITLE,
- Helper.NOURLCONNECTION_ERROR,
- sURL,
- false );
- }
+ // show error
+ Helper.ShowError( m_xContext,
+ m_xDialog,
+ Helper.DLG_MEDIAWIKI_TITLE,
+ Helper.NOURLCONNECTION_ERROR,
+ sURL,
+ false );
+ }
+ }
+ else
+ {
+ if ( ( sUserName.length() > 0 || sPassword.length() > 0 )
+ && Helper.Login( new URI( sMainURL ), sUserName, sPassword, m_xContext ) == null )
+ {
+ // a wrong login information is provided
+ // show error
+ Helper.ShowError( m_xContext,
+ m_xDialog,
+ Helper.DLG_MEDIAWIKI_TITLE,
+ Helper.WRONGLOGIN_ERROR,
+ null,
+ false );
}
else
{
- if ( ( sUserName.length() > 0 || sPassword.length() > 0 )
- && Helper.Login( new URI( sMainURL ), sUserName, sPassword, m_xContext ) == null )
+ setting.put( "Url",sMainURL );
+ setting.put( "Username", sUserName );
+ setting.put( "Password", sPassword );
+ if ( addMode )
{
- // a wrong login information is provided
- // show error
- Helper.ShowError( m_xContext,
- m_xDialog,
- Helper.DLG_MEDIAWIKI_TITLE,
- Helper.WRONGLOGIN_ERROR,
- null,
- false );
+ Settings.getSettings( m_xContext ).addWikiCon( setting );
+ Settings.getSettings( m_xContext ).storeConfiguration();
}
- else
+
+ if ( Helper.PasswordStoringIsAllowed( m_xContext )
+ && ( (Short)( GetPropSet( "SaveBox" ).getPropertyValue("State") ) ).shortValue() != (short)0 )
{
- setting.put( "Url",sMainURL );
- setting.put( "Username", sUserName );
- setting.put( "Password", sPassword );
- if ( addMode )
+ String[] pPasswords = { sPassword };
+ try
{
- Settings.getSettings( m_xContext ).addWikiCon( setting );
- Settings.getSettings( m_xContext ).storeConfiguration();
+ Helper.GetPasswordContainer( m_xContext ).addPersistent( sMainURL, sUserName, pPasswords, Helper.GetInteractionHandler( m_xContext ) );
}
-
- if ( Helper.PasswordStoringIsAllowed( m_xContext )
- && ( (Short)( GetPropSet( "SaveBox" ).getPropertyValue("State") ) ).shortValue() != (short)0 )
+ catch( Exception e )
{
- String[] pPasswords = { sPassword };
- try
- {
- Helper.GetPasswordContainer( m_xContext ).addPersistent( sMainURL, sUserName, pPasswords, Helper.GetInteractionHandler( m_xContext ) );
- }
- catch( Exception e )
- {
- e.printStackTrace();
- }
+ e.printStackTrace();
}
-
- m_bAction = true;
- xDialog.endExecute();
}
+
+ m_bAction = true;
+ xDialog.endExecute();
}
}
- else if ( sRedirectURL == null || sRedirectURL.length() == 0 )
- {
- // URL invalid
- // show error
- Helper.ShowError( m_xContext,
- m_xDialog,
- Helper.DLG_MEDIAWIKI_TITLE,
- Helper.INVALIDURL_ERROR,
- null,
- false );
- }
}
- else
+ else if ( sRedirectURL == null || sRedirectURL.length() == 0 )
{
- // URL field empty
+ // URL invalid
// show error
Helper.ShowError( m_xContext,
m_xDialog,
Helper.DLG_MEDIAWIKI_TITLE,
- Helper.NOURL_ERROR,
+ Helper.INVALIDURL_ERROR,
null,
false );
}
- } while ( sRedirectURL.length() > 0 );
- }
- catch ( SSLException essl )
+ }
+ else
+ {
+ // URL field empty
+ // show error
+ Helper.ShowError( m_xContext,
+ m_xDialog,
+ Helper.DLG_MEDIAWIKI_TITLE,
+ Helper.NOURL_ERROR,
+ null,
+ false );
+ }
+ } while ( sRedirectURL.length() > 0 );
+ }
+ catch ( SSLException essl )
+ {
+ Helper.ShowError( m_xContext,
+ m_xDialog,
+ Helper.DLG_MEDIAWIKI_TITLE,
+ Helper.UNKNOWNCERT_ERROR,
+ null,
+ false );
+ essl.printStackTrace();
+ }
+ catch ( Exception ex )
+ {
+ Helper.ShowError( m_xContext,
+ m_xDialog,
+ Helper.DLG_MEDIAWIKI_TITLE,
+ Helper.NOURLCONNECTION_ERROR,
+ sURL,
+ false );
+ ex.printStackTrace();
+ }
+
+ }
+
+ public boolean callHandlerMethod( XDialog xDialog, Object EventObject, String MethodName )
+ {
+ if ( MethodName.equals( sOKMethod ) )
+ {
+ EnableControls( false );
+
+ if ( Helper.AllowThreadUsage( m_xContext ) )
{
- Helper.ShowError( m_xContext,
- m_xDialog,
- Helper.DLG_MEDIAWIKI_TITLE,
- Helper.UNKNOWNCERT_ERROR,
- null,
- false );
- essl.printStackTrace();
+ final XDialog xDialogForThread = xDialog;
+
+ // the thread name is used to allow the error dialogs
+ Thread aLoginThread = new Thread( "com.sun.star.thread.WikiEditorSendingThread" )
+ {
+ public void run()
+ {
+ try
+ {
+ Thread.yield();
+ DoLogin( xDialogForThread );
+ m_bAction = true;
+ } catch( java.lang.Exception e )
+ {}
+ finally
+ {
+ xDialogForThread.endExecute();
+ Helper.AllowConnection( true );
+ }
+ }
+ };
+
+ aLoginThread.start();
}
- catch ( Exception ex )
+ else
{
- Helper.ShowError( m_xContext,
- m_xDialog,
- Helper.DLG_MEDIAWIKI_TITLE,
- Helper.NOURLCONNECTION_ERROR,
- sURL,
- false );
- ex.printStackTrace();
+ try
+ {
+ DoLogin( xDialog );
+ m_bAction = true;
+ } catch( java.lang.Exception e )
+ {}
+ finally
+ {
+ xDialog.endExecute();
+ Helper.AllowConnection( true );
+ }
}
+
return true;
}
else if ( MethodName.equals( sCancelMethod ) )
{
+ Helper.AllowConnection( false );
xDialog.endExecute();
return true;
}
diff --git a/swext/mediawiki/src/com/sun/star/wiki/WikiOptionsEventHandlerImpl.java b/swext/mediawiki/src/com/sun/star/wiki/WikiOptionsEventHandlerImpl.java
index 82986ef80611..59d1f0a3299f 100644
--- a/swext/mediawiki/src/com/sun/star/wiki/WikiOptionsEventHandlerImpl.java
+++ b/swext/mediawiki/src/com/sun/star/wiki/WikiOptionsEventHandlerImpl.java
@@ -4,9 +4,9 @@
*
* $RCSfile: WikiOptionsEventHandlerImpl.java,v $
*
- * $Revision: 1.2 $
+ * $Revision: 1.3 $
*
- * last change: $Author: mav $ $Date: 2008-01-21 12:57:53 $
+ * last change: $Author: mav $ $Date: 2008-01-30 19:02:16 $
*
* The Contents of this file are made available subject to
* the terms of GNU Lesser General Public License Version 2.1.
@@ -61,6 +61,7 @@ public final class WikiOptionsEventHandlerImpl extends WeakBase
static final String sEdit = "Edit";
static final String sRemove = "Remove";
static final String sListStatus = "ListStatus";
+ static final String sListEdit = "ListEdit";
static final String sInitialize = "initialize";
static final String sOk = "ok";
static final String sBack = "back";
@@ -158,7 +159,7 @@ public final class WikiOptionsEventHandlerImpl extends WeakBase
ex.printStackTrace();
}
- WikiEditSettingDialog aSettingDialog = new WikiEditSettingDialog(m_xContext, "vnd.sun.star.script:WikiEditor.EditSetting?location=application", ht);
+ WikiEditSettingDialog aSettingDialog = new WikiEditSettingDialog(m_xContext, "vnd.sun.star.script:WikiEditor.EditSetting?location=application", ht, true );
if ( aSettingDialog.show() )
RefreshView();
}
@@ -279,7 +280,7 @@ public final class WikiOptionsEventHandlerImpl extends WeakBase
{
AddSetting();
}
- else if ( sMethod.equals( sEdit ) )
+ else if ( sMethod.equals( sEdit ) || sMethod.equals( sListEdit ) )
{
EditSetting();
}
diff --git a/swext/mediawiki/src/com/sun/star/wiki/WikiPropDialog.java b/swext/mediawiki/src/com/sun/star/wiki/WikiPropDialog.java
index 9cd9d8456e6b..b515ee2bbece 100644
--- a/swext/mediawiki/src/com/sun/star/wiki/WikiPropDialog.java
+++ b/swext/mediawiki/src/com/sun/star/wiki/WikiPropDialog.java
@@ -4,9 +4,9 @@
*
* $RCSfile: WikiPropDialog.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 19:02:16 $
*
* The Contents of this file are made available subject to
* the terms of GNU Lesser General Public License Version 2.1.
@@ -244,25 +244,10 @@ public class WikiPropDialog extends WikiDialog{
final WikiPropDialog aThisDialog = this;
final XDialog xDialogToClose = xDialog;
- boolean bAllowThreadUsage = false;
- try
- {
- XMultiComponentFactory xFactory = m_xContext.getServiceManager();
- if ( xFactory == null )
- throw new com.sun.star.uno.RuntimeException();
-
- Object oCheckCallback = xFactory.createInstanceWithContext( "com.sun.star.awt.AsyncCallback", m_xContext );
- bAllowThreadUsage = ( oCheckCallback != null );
- }
- catch( Exception e )
- {
- e.printStackTrace();
- }
-
// start spinning
SetThrobberActive( true );
- if ( bAllowThreadUsage )
+ if ( Helper.AllowThreadUsage( m_xContext ) )
{
m_aSendingThread = new Thread( "com.sun.star.thread.WikiEditorSendingThread" )
{