diff --git a/swext/mediawiki/src/com/sun/star/wiki/WikiDialog.java b/swext/mediawiki/src/com/sun/star/wiki/WikiDialog.java index 93b49faa66cf..953939cfb63e 100644 --- a/swext/mediawiki/src/com/sun/star/wiki/WikiDialog.java +++ b/swext/mediawiki/src/com/sun/star/wiki/WikiDialog.java @@ -4,9 +4,9 @@ * * $RCSfile: WikiDialog.java,v $ * - * $Revision: 1.6 $ + * $Revision: 1.7 $ * - * last change: $Author: mav $ $Date: 2008-02-05 17:22:59 $ + * last change: $Author: mav $ $Date: 2008-02-05 18:23:34 $ * * The Contents of this file are made available subject to * the terms of GNU Lesser General Public License Version 2.1. @@ -62,6 +62,9 @@ public class WikiDialog implements XDialogEventHandler, XTopWindowListener boolean m_bAction = false; Settings m_aSettings; + protected Thread m_aThread; + protected boolean m_bThreadFinished = false; + /** Creates a new instance of WikiDialog */ public WikiDialog(XComponentContext c, String DialogURL) @@ -87,6 +90,30 @@ public class WikiDialog implements XDialogEventHandler, XTopWindowListener } } + public synchronized void ThreadStop( boolean bSelf ) + { + if ( !bSelf ) + { + if ( m_aThread != null && !m_bThreadFinished ) + { + try + { + Helper.AllowConnection( false ); + } + catch( Exception ex ) + { + ex.printStackTrace(); + } + finally + { + } + } + } + + m_aThread = null; + m_bThreadFinished = true; + } + protected void setMethods (String [] Methods) { this.m_aMethods = Methods; @@ -95,6 +122,8 @@ public class WikiDialog implements XDialogEventHandler, XTopWindowListener public boolean show( ) { + m_bThreadFinished = false; + if( m_xDialog != null ) m_xDialog.execute(); return m_bAction; } diff --git a/swext/mediawiki/src/com/sun/star/wiki/WikiEditSettingDialog.java b/swext/mediawiki/src/com/sun/star/wiki/WikiEditSettingDialog.java index 5e77ec70f349..b936021b4832 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.17 $ + * $Revision: 1.18 $ * - * last change: $Author: mav $ $Date: 2008-02-05 17:22:59 $ + * last change: $Author: mav $ $Date: 2008-02-05 18:23:34 $ * * The Contents of this file are made available subject to * the terms of GNU Lesser General Public License Version 2.1. @@ -59,8 +59,6 @@ public class WikiEditSettingDialog extends WikiDialog private Hashtable setting; private boolean addMode; private boolean m_bAllowURLChange = true; - private Thread m_aLoginThread; - private boolean m_bThreadFinished = false; public WikiEditSettingDialog( XComponentContext xContext, String DialogURL ) { @@ -103,7 +101,6 @@ public class WikiEditSettingDialog extends WikiDialog public boolean show( ) { SetThrobberVisible( false ); - m_bThreadFinished = false; EnableControls( true ); return super.show(); } @@ -300,6 +297,9 @@ public class WikiEditSettingDialog extends WikiDialog } } while ( sRedirectURL.length() > 0 ); } + catch ( WikiCancelException ce ) + { + } catch ( SSLException essl ) { if ( Helper.IsConnectionAllowed() ) @@ -326,7 +326,6 @@ public class WikiEditSettingDialog extends WikiDialog } ex.printStackTrace(); } - } public boolean callHandlerMethod( XDialog xDialog, Object EventObject, String MethodName ) @@ -344,7 +343,7 @@ public class WikiEditSettingDialog extends WikiDialog final WikiEditSettingDialog aThis = this; // the thread name is used to allow the error dialogs - m_aLoginThread = new Thread( "com.sun.star.thread.WikiEditorSendingThread" ) + m_aThread = new Thread( "com.sun.star.thread.WikiEditorSendingThread" ) { public void run() { @@ -352,25 +351,24 @@ public class WikiEditSettingDialog extends WikiDialog { Thread.yield(); DoLogin( xDialogForThread ); - m_bThreadFinished = true; } catch( java.lang.Exception e ) {} finally { + ThreadStop( true ); MainThreadDialogExecutor.Close( xContext, xDialogForThread ); Helper.AllowConnection( true ); } } }; - m_aLoginThread.start(); + m_aThread.start(); } else { try { DoLogin( xDialog ); - m_bThreadFinished = true; } catch( java.lang.Exception e ) {} finally @@ -392,23 +390,7 @@ public class WikiEditSettingDialog extends WikiDialog public void windowClosed( EventObject e ) { - if ( m_aLoginThread != null && !m_bThreadFinished ) - { - try - { - Helper.AllowConnection( false ); - m_aLoginThread.join(); - } - catch( Exception ex ) - { - ex.printStackTrace(); - } - finally - { - m_aLoginThread = null; - Helper.AllowConnection( true ); - } - } + ThreadStop( false ); } } diff --git a/swext/mediawiki/src/com/sun/star/wiki/WikiPropDialog.java b/swext/mediawiki/src/com/sun/star/wiki/WikiPropDialog.java index 05a8b96fec19..f9b0210c3840 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.12 $ + * $Revision: 1.13 $ * - * last change: $Author: mav $ $Date: 2008-02-05 17:22:59 $ + * last change: $Author: mav $ $Date: 2008-02-05 18:23:34 $ * * The Contents of this file are made available subject to * the terms of GNU Lesser General Public License Version 2.1. @@ -67,8 +67,6 @@ public class WikiPropDialog extends WikiDialog{ protected String m_sWikiComment = ""; protected boolean m_bWikiMinorEdit = false; - private Thread m_aSendingThread; - /** Creates a new instance of WikiPropDialog */ public WikiPropDialog(XComponentContext xContext, String DialogURL, WikiEditorImpl aWikiEditorForThrobber ) { @@ -118,6 +116,21 @@ public class WikiPropDialog extends WikiDialog{ } } + public synchronized void ThreadStop( boolean bSelf ) + { + boolean bShowError = ( !bSelf && m_aThread != null && !m_bThreadFinished ); + + super.ThreadStop( bSelf ); + + if ( bShowError ) + Helper.ShowError( m_xContext, + m_xDialog, + Helper.DLG_SENDTITLE, + Helper.CANCELSENDING_ERROR, + null, + false ); + } + public void fillWikiList() { String [] WikiList = m_aSettings.getWikiURLs(); @@ -250,7 +263,7 @@ public class WikiPropDialog extends WikiDialog{ if ( Helper.AllowThreadUsage( m_xContext ) ) { - m_aSendingThread = new Thread( "com.sun.star.thread.WikiEditorSendingThread" ) + m_aThread = new Thread( "com.sun.star.thread.WikiEditorSendingThread" ) { public void run() { @@ -266,13 +279,15 @@ public class WikiPropDialog extends WikiDialog{ {} finally { + ThreadStop( true ); MainThreadDialogExecutor.Close( xContext, xDialogToClose ); + // should be marked as finished after dialog closing if an exception was thrown Helper.AllowConnection( true ); } } }; - m_aSendingThread.start(); + m_aThread.start(); } else { @@ -325,30 +340,7 @@ public class WikiPropDialog extends WikiDialog{ public void windowClosed( EventObject e ) { - if ( m_aSendingThread != null && !m_bAction ) - { - try - { - Helper.AllowConnection( false ); - m_aSendingThread.join(); - } - catch ( Exception ex ) - { - ex.printStackTrace(); - } - finally - { - m_aSendingThread = null; - Helper.AllowConnection( true ); - - Helper.ShowError( m_xContext, - m_xDialog, - Helper.DLG_SENDTITLE, - Helper.CANCELSENDING_ERROR, - null, - false ); - } - } + ThreadStop( false ); } }