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

prepare for localization

üst 28755a36
......@@ -5,9 +5,9 @@
*
* $RCSfile: EditSetting.xdl,v $
*
* $Revision: 1.3 $
* $Revision: 1.4 $
*
* last change: $Author: mav $ $Date: 2007-12-13 15:11:05 $
* last change: $Author: mav $ $Date: 2008-01-21 12:57:52 $
*
* The Contents of this file are made available subject to
* the terms of GNU Lesser General Public License Version 2.1.
......@@ -34,26 +34,26 @@
*
************************************************************************ -->
<!DOCTYPE dlg:window PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "dialog.dtd">
<dlg:window xmlns:dlg="http://openoffice.org/2000/dialog" xmlns:script="http://openoffice.org/2000/script" dlg:id="EditSetting" dlg:left="180" dlg:top="89" dlg:width="186" dlg:height="156" dlg:closeable="true" dlg:moveable="true">
<dlg:window xmlns:dlg="http://openoffice.org/2000/dialog" xmlns:script="http://openoffice.org/2000/script" dlg:id="EditSetting" dlg:left="180" dlg:top="89" dlg:width="186" dlg:height="156" dlg:closeable="true" dlg:moveable="true" dlg:title="TOREPLACE">
<dlg:bulletinboard>
<dlg:text dlg:id="UrlLabel" dlg:tab-index="4" dlg:left="6" dlg:top="33" dlg:width="50" dlg:height="8" dlg:value="URL" dlg:tabstop="false"/>
<dlg:text dlg:id="UrlLabel" dlg:tab-index="4" dlg:left="6" dlg:top="33" dlg:width="50" dlg:height="8" dlg:value="TOREPLACE" dlg:tabstop="false"/>
<dlg:textfield dlg:id="UrlField" dlg:tab-index="5" dlg:left="58" dlg:top="31" dlg:width="122" dlg:height="12" dlg:help-url="HID:31696"/>
<dlg:textfield dlg:id="UsernameField" dlg:tab-index="7" dlg:left="58" dlg:top="91" dlg:width="122" dlg:height="12" dlg:help-url="HID:31697"/>
<dlg:textfield dlg:id="PasswordField" dlg:tab-index="9" dlg:left="58" dlg:top="107" dlg:width="122" dlg:height="12" dlg:help-url="HID:31698" dlg:echochar="*"/>
<dlg:button dlg:id="All.OkButton" dlg:tab-index="12" dlg:left="77" dlg:top="139" dlg:width="50" dlg:height="14" dlg:help-url="HID:31700" dlg:default="true" dlg:value="OK">
<dlg:button dlg:id="OkButton" dlg:tab-index="12" dlg:left="77" dlg:top="139" dlg:width="50" dlg:height="14" dlg:help-url="HID:31700" dlg:default="true" dlg:value="TOREPLACE">
<script:event script:event-name="on-performaction" script:macro-name="vnd.sun.star.UNO:OK" script:language="UNO"/>
</dlg:button>
<dlg:button dlg:id="All.CancelButton" dlg:tab-index="13" dlg:left="130" dlg:top="139" dlg:width="50" dlg:height="14" dlg:help-url="HID:31701" dlg:value="Cancel">
<dlg:button dlg:id="CancelButton" dlg:tab-index="13" dlg:left="130" dlg:top="139" dlg:width="50" dlg:height="14" dlg:help-url="HID:31701" dlg:value="TOREPLACE">
<script:event script:event-name="on-performaction" script:macro-name="vnd.sun.star.UNO:Cancel" script:language="UNO"/>
</dlg:button>
<dlg:button dlg:id="All.HelpButton" dlg:tab-index="11" dlg:left="6" dlg:top="139" dlg:width="50" dlg:height="14" dlg:help-url="HID:31702" dlg:value="Help">
<dlg:button dlg:id="HelpButton" dlg:tab-index="11" dlg:left="6" dlg:top="139" dlg:width="50" dlg:height="14" dlg:help-url="HID:31702" dlg:value="TOREPLACE">
<script:event script:event-name="on-performaction" script:macro-name="vnd.sun.star.UNO:Help" script:language="UNO"/>
</dlg:button>
<dlg:text dlg:id="All.UsernameLabel" dlg:tab-index="6" dlg:left="6" dlg:top="93" dlg:width="46" dlg:height="8" dlg:value="Username" dlg:tabstop="false"/>
<dlg:text dlg:id="All.PasswordLabel" dlg:tab-index="8" dlg:left="6" dlg:top="109" dlg:width="46" dlg:height="8" dlg:value="Password" dlg:tabstop="false"/>
<dlg:checkbox dlg:id="SaveBox" dlg:tab-index="10" dlg:left="58" dlg:top="123" dlg:width="116" dlg:height="8" dlg:help-url="HID:31699" dlg:value="Save password" dlg:checked="false"/>
<dlg:text dlg:id="UsernameLabel" dlg:tab-index="6" dlg:left="6" dlg:top="93" dlg:width="46" dlg:height="8" dlg:value="TOREPLACE" dlg:tabstop="false"/>
<dlg:text dlg:id="PasswordLabel" dlg:tab-index="8" dlg:left="6" dlg:top="109" dlg:width="46" dlg:height="8" dlg:value="TOREPLACE" dlg:tabstop="false"/>
<dlg:checkbox dlg:id="SaveBox" dlg:tab-index="10" dlg:left="58" dlg:top="123" dlg:width="116" dlg:height="8" dlg:help-url="HID:31699" dlg:value="TOREPLACE" dlg:checked="false"/>
<dlg:fixedline dlg:id="BottomLine" dlg:tab-index="1" dlg:left="0" dlg:top="131" dlg:width="186" dlg:height="8"/>
<dlg:fixedline dlg:id="AccountLine" dlg:tab-index="2" dlg:left="3" dlg:top="80" dlg:width="180" dlg:height="8" dlg:value="Account"/>
<dlg:fixedline dlg:id="WikiLine" dlg:tab-index="3" dlg:left="3" dlg:top="4" dlg:width="180" dlg:height="8" dlg:value="Wiki"/>
<dlg:fixedline dlg:id="AccountLine" dlg:tab-index="2" dlg:left="3" dlg:top="80" dlg:width="180" dlg:height="8" dlg:value="TOREPLACE"/>
<dlg:fixedline dlg:id="WikiLine" dlg:tab-index="3" dlg:left="3" dlg:top="4" dlg:width="180" dlg:height="8" dlg:value="TOREPLACE"/>
</dlg:bulletinboard>
</dlg:window>
......@@ -5,9 +5,9 @@
*
* $RCSfile: SendToMediaWiki.xdl,v $
*
* $Revision: 1.4 $
* $Revision: 1.5 $
*
* last change: $Author: mav $ $Date: 2007-12-13 15:11:05 $
* last change: $Author: mav $ $Date: 2008-01-21 12:57:52 $
*
* The Contents of this file are made available subject to
* the terms of GNU Lesser General Public License Version 2.1.
......@@ -34,11 +34,11 @@
*
************************************************************************ -->
<!DOCTYPE dlg:window PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "dialog.dtd">
<dlg:window xmlns:dlg="http://openoffice.org/2000/dialog" xmlns:script="http://openoffice.org/2000/script" dlg:id="SendToMediaWiki" dlg:left="62" dlg:top="57" dlg:width="288" dlg:height="129" dlg:closeable="true" dlg:moveable="true" dlg:title="Send to MediaWiki">
<dlg:window xmlns:dlg="http://openoffice.org/2000/dialog" xmlns:script="http://openoffice.org/2000/script" dlg:id="SendToMediaWiki" dlg:left="62" dlg:top="57" dlg:width="288" dlg:height="129" dlg:closeable="true" dlg:moveable="true" dlg:title="TOREPLACE">
<dlg:bulletinboard>
<dlg:text dlg:id="Label1" dlg:tab-index="0" dlg:left="9" dlg:top="10" dlg:width="62" dlg:height="10" dlg:value="~MediaWiki Server" dlg:tabstop="false"/>
<dlg:text dlg:id="Label2" dlg:tab-index="2" dlg:left="9" dlg:top="27" dlg:width="62" dlg:height="10" dlg:value="~Title"/>
<dlg:text dlg:id="Label3" dlg:tab-index="4" dlg:left="9" dlg:top="43" dlg:width="62" dlg:height="10" dlg:value="S~ummary"/>
<dlg:text dlg:id="Label1" dlg:tab-index="0" dlg:left="9" dlg:top="10" dlg:width="62" dlg:height="10" dlg:value="TOREPLACE"/>
<dlg:text dlg:id="Label2" dlg:tab-index="2" dlg:left="9" dlg:top="27" dlg:width="62" dlg:height="10" dlg:value="TOREPLACE"/>
<dlg:text dlg:id="Label3" dlg:tab-index="4" dlg:left="9" dlg:top="43" dlg:width="62" dlg:height="10" dlg:value="TOREPLACE"/>
<dlg:menulist dlg:id="WikiList" dlg:tab-index="1" dlg:left="73" dlg:top="7" dlg:width="142" dlg:height="14" dlg:spin="true">
<script:event script:event-name="on-itemstatechange" script:macro-name="vnd.sun.star.UNO:WikiListChange" script:language="UNO"/>
</dlg:menulist>
......@@ -46,19 +46,19 @@
<script:event script:event-name="on-textchange" script:macro-name="vnd.sun.star.UNO:ArticleTextChange" script:language="UNO"/>
</dlg:combobox>
<dlg:textfield dlg:id="CommentText" dlg:tab-index="5" dlg:left="73" dlg:top="41" dlg:width="142" dlg:height="20" dlg:multiline="true"/>
<dlg:button dlg:id="AddButton" dlg:tab-index="6" dlg:left="219" dlg:top="7" dlg:width="63" dlg:height="16" dlg:value="~Add...">
<dlg:button dlg:id="AddButton" dlg:tab-index="6" dlg:left="219" dlg:top="7" dlg:width="63" dlg:height="16" dlg:value="TOREPLACE">
<script:event script:event-name="on-performaction" script:macro-name="vnd.sun.star.UNO:AddWiki" script:language="UNO"/>
</dlg:button>
<dlg:checkbox dlg:id="MinorCheck" dlg:tab-index="7" dlg:left="73" dlg:top="66" dlg:width="142" dlg:height="10" dlg:value="This is a minor edit" dlg:checked="false"/>
<dlg:checkbox dlg:id="BrowserCheck" dlg:tab-index="8" dlg:left="73" dlg:top="79" dlg:width="142" dlg:height="10" dlg:value="Show in web ~browser" dlg:checked="false"/>
<dlg:checkbox dlg:id="MinorCheck" dlg:tab-index="7" dlg:left="73" dlg:top="66" dlg:width="142" dlg:height="10" dlg:value="TOREPLACE" dlg:checked="false"/>
<dlg:checkbox dlg:id="BrowserCheck" dlg:tab-index="8" dlg:left="73" dlg:top="79" dlg:width="142" dlg:height="10" dlg:value="TOREPLACE" dlg:checked="false"/>
<dlg:fixedline dlg:id="FixedLine1" dlg:tab-index="9" dlg:left="-5" dlg:top="100" dlg:width="294" dlg:height="4"/>
<dlg:button dlg:id="CancelButton" dlg:tab-index="10" dlg:left="219" dlg:top="108" dlg:width="63" dlg:height="16" dlg:value="Cancel">
<dlg:button dlg:id="CancelButton" dlg:tab-index="10" dlg:left="219" dlg:top="108" dlg:width="63" dlg:height="16" dlg:value="TOREPLACE">
<script:event script:event-name="on-performaction" script:macro-name="vnd.sun.star.UNO:Cancel" script:language="UNO"/>
</dlg:button>
<dlg:button dlg:id="SendButton" dlg:tab-index="11" dlg:disabled="true" dlg:left="153" dlg:top="108" dlg:width="63" dlg:height="16" dlg:value="~Send">
<dlg:button dlg:id="SendButton" dlg:tab-index="11" dlg:disabled="true" dlg:left="153" dlg:top="108" dlg:width="63" dlg:height="16" dlg:value="TOREPLACE">
<script:event script:event-name="on-performaction" script:macro-name="vnd.sun.star.UNO:Send" script:language="UNO"/>
</dlg:button>
<dlg:button dlg:id="HelpButton" dlg:tab-index="12" dlg:left="6" dlg:top="108" dlg:width="63" dlg:height="16" dlg:value="~Help">
<dlg:button dlg:id="HelpButton" dlg:tab-index="12" dlg:left="6" dlg:top="108" dlg:width="63" dlg:height="16" dlg:value="TOREPLACE">
<script:event script:event-name="on-performaction" script:macro-name="vnd.sun.star.UNO:Help" script:language="UNO"/>
</dlg:button>
</dlg:bulletinboard>
......
......@@ -5,9 +5,9 @@
*
* $RCSfile: Settings.xdl,v $
*
* $Revision: 1.3 $
* $Revision: 1.4 $
*
* last change: $Author: mav $ $Date: 2007-11-28 16:43:08 $
* last change: $Author: mav $ $Date: 2008-01-21 12:57:52 $
*
* The Contents of this file are made available subject to
* the terms of GNU Lesser General Public License Version 2.1.
......@@ -36,13 +36,13 @@
<!DOCTYPE dlg:window PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "dialog.dtd">
<dlg:window xmlns:dlg="http://openoffice.org/2000/dialog" xmlns:script="http://openoffice.org/2000/script" dlg:id="Settings" dlg:left="142" dlg:top="89" dlg:width="260" dlg:height="185" dlg:closeable="true" dlg:withtitlebar="false">
<dlg:bulletinboard>
<dlg:button dlg:id="AddButton" dlg:tab-index="1" dlg:left="205" dlg:top="6" dlg:width="50" dlg:height="14" dlg:help-url="HID:31682" dlg:value="Add...">
<dlg:button dlg:id="AddButton" dlg:tab-index="1" dlg:left="205" dlg:top="6" dlg:width="50" dlg:height="14" dlg:help-url="HID:31682" dlg:value="TOREPLACE">
<script:event script:event-name="on-performaction" script:macro-name="vnd.sun.star.UNO:Add" script:language="UNO"/>
</dlg:button>
<dlg:button dlg:id="EditButton" dlg:tab-index="2" dlg:left="205" dlg:top="22" dlg:width="50" dlg:height="14" dlg:help-url="HID:31683" dlg:value="Edit...">
<dlg:button dlg:id="EditButton" dlg:tab-index="2" dlg:left="205" dlg:top="22" dlg:width="50" dlg:height="14" dlg:help-url="HID:31683" dlg:value="TOREPLACE">
<script:event script:event-name="on-performaction" script:macro-name="vnd.sun.star.UNO:Edit" script:language="UNO"/>
</dlg:button>
<dlg:button dlg:id="RemoveButton" dlg:tab-index="3" dlg:left="205" dlg:top="38" dlg:width="50" dlg:height="14" dlg:help-url="HID:31685" dlg:value="Remove">
<dlg:button dlg:id="RemoveButton" dlg:tab-index="3" dlg:left="205" dlg:top="38" dlg:width="50" dlg:height="14" dlg:help-url="HID:31685" dlg:value="TOREPLACE">
<script:event script:event-name="on-performaction" script:macro-name="vnd.sun.star.UNO:Remove" script:language="UNO"/>
</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">
......
......@@ -4,9 +4,9 @@
*
* $RCSfile: Helper.java,v $
*
* $Revision: 1.5 $
* $Revision: 1.6 $
*
* last change: $Author: mav $ $Date: 2007-12-14 13:03:53 $
* last change: $Author: mav $ $Date: 2008-01-21 12:57:53 $
*
* The Contents of this file are made available subject to
* the terms of GNU Lesser General Public License Version 2.1.
......@@ -85,6 +85,76 @@ import org.apache.commons.httpclient.methods.PostMethod;
public class Helper
{
public final static int GENERALSEND_ERROR = 0;
public final static int NOWIKIFILTER_ERROR = 1;
public final static int NOURLCONNECTION_ERROR = 2;
public final static int WRONGLOGIN_ERROR = 3;
public final static int INVALIDURL_ERROR = 4;
public final static int NOURL_ERROR = 5;
public final static int DLG_SENDTITLE = 6;
public final static int DLG_CANCEL = 7;
public final static int DLG_NO = 8;
public final static int DLG_OK = 9;
public final static int DLG_YES = 10;
public final static int DLG_HELP = 11;
public final static int DLG_ADDBUTTON = 12;
public final static int DLG_EDITBUTTON = 13;
public final static int DLG_SENDBUTTON = 14;
public final static int DLG_REMOVEBUTTON = 15;
public final static int DLG_EDITSETTING_URLLABEL = 16;
public final static int DLG_EDITSETTING_USERNAMELABEL = 17;
public final static int DLG_EDITSETTING_PASSWORDLABEL = 18;
public final static int DLG_NEWWIKIPAGE_LABEL1 = 19;
public final static int DLG_SENDTOMEDIAWIKI_LABEL1 = 20;
public final static int DLG_SENDTOMEDIAWIKI_LABEL2 = 21;
public final static int DLG_SENDTOMEDIAWIKI_LABEL3 = 22;
public final static int DLG_SENDTOMEDIAWIKI_MINORCHECK = 23;
public final static int DLG_SENDTOMEDIAWIKI_BROWSERCHECK = 24;
public final static int DLG_UNKNOWNCERTDIALOG_LABEL1 = 25;
public final static int DLG_MEDIAWIKI_TITLE = 26;
public final static int DLG_EDITSETTING_ACCOUNTLINE = 27;
public final static int DLG_EDITSETTING_WIKILINE = 28;
public final static int DLG_EDITSETTING_SAVEBOX = 29;
public final static int CANCELSENDING_ERROR = 30;
public final static int STRINGS_NUM = 31;
private final static String[] m_pEntryNames = { "GeneralSendError",
"NoWikiFilter",
"NoConnectionToURL",
"WrongLogin",
"InvalidURL",
"NoURL",
"Dlg_SendTitle",
"Dlg_Cancel",
"Dlg_No",
"Dlg_OK",
"Dlg_Yes",
"Dlg_Help",
"Dlg_AddButton",
"Dlg_EditButton",
"Dlg_SendButton",
"Dlg_RemoveButton",
"Dlg_EditSetting_UrlLabel",
"Dlg_EditSetting_UsernameLabel",
"Dlg_EditSetting_PasswordLabel",
"Dlg_NewWikiPage_Label1",
"Dlg_SendToMediaWiki_Label1",
"Dlg_SendToMediaWiki_Label2",
"Dlg_SendToMediaWiki_Label3",
"Dlg_SendToMediaWiki_MinorCheck",
"Dlg_SendToMediaWiki_BrowserCheck",
"Dlg_UnknownCertDialog_Label1",
"Dlg_MediaWiki_Title",
"Dlg_EditSetting_AccountLine",
"Dlg_EditSetting_WikiLine",
"Dlg_EditSetting_SaveBox",
"CancelSending" };
private static String[] m_pConfigStrings;
private static final String sHTMLHeader = "<HTML><HEAD><meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" /><TITLE></TITLE></HEAD><BODY>";
private static final String sHTMLFooter = "</BODY></HTML>";
......@@ -98,6 +168,38 @@ public class Helper
private static XPasswordContainer m_xPasswordContainer;
private static XInteractionHandler m_xInteractionHandler;
synchronized protected static String GetLocalizedString( XComponentContext xContext, int nID )
throws com.sun.star.uno.Exception
{
if ( nID >= STRINGS_NUM )
throw new com.sun.star.uno.RuntimeException();
if ( m_pConfigStrings == null )
{
PropertyValue aVal = new PropertyValue();
aVal.Name = "nodepath";
aVal.Value = "org.openoffice.Office.Custom.WikiExtension/Strings";
Object[] aArgs = new Object[1];
aArgs[0] = aVal;
Object oSettings = GetConfigurationProvider( xContext ).createInstanceWithArguments(
"com.sun.star.configuration.ConfigurationAccess",
aArgs );
XNameAccess xNameAccess = ( XNameAccess ) UnoRuntime.queryInterface( XNameAccess.class, oSettings );
if ( xNameAccess == null )
throw new com.sun.star.uno.RuntimeException();
String[] pStrings = new String[STRINGS_NUM];
for ( int nInd = 0; nInd < STRINGS_NUM; nInd++ )
pStrings[nInd] = AnyConverter.toString( xNameAccess.getByName( m_pEntryNames[nInd] ) );
m_pConfigStrings = pStrings;
}
return m_pConfigStrings[nID];
}
synchronized protected static HttpClient GetHttpClient()
throws WikiCancelException
{
......@@ -550,7 +652,15 @@ public class Helper
if ( aURI.getScheme().equals( "https" ) )
{
// the complete secure connection seems to be impossible
XDialog xAskDialog = WikiDialog.CreateSimpleDialog( xContext, "vnd.sun.star.script:WikiEditor.UnknownCertDialog?location=application" );
String[] pControls = { "Label1", "CommandButton1", "CommandButton2" };
int[] pStringIDs = { DLG_UNKNOWNCERTDIALOG_LABEL1, DLG_YES, DLG_NO };
XDialog xAskDialog = WikiDialog.CreateSimpleDialog(
xContext,
"vnd.sun.star.script:WikiEditor.UnknownCertDialog?location=application",
DLG_MEDIAWIKI_TITLE,
pControls,
pStringIDs );
if ( xAskDialog != null && MainThreadDialogExecutor.Execute( xContext, xAskDialog ) )
{
if ( m_aAcceptedUnknownCerts == null )
......@@ -728,21 +838,37 @@ public class Helper
return bResult;
}
protected static void ShowError( XComponentContext xContext, XDialog xDialog, String sError )
protected static void ShowError( XComponentContext xContext, XDialog xDialog, int nErrorID, String sArg )
{
XWindowPeer xPeer = null;
XControl xControl = (XControl)UnoRuntime.queryInterface( XControl.class, xDialog );
if ( xControl != null )
xPeer = xControl.getPeer();
ShowError( xContext, xPeer, sError );
ShowError( xContext, xPeer, nErrorID, sArg );
}
protected static void ShowError( XComponentContext xContext, XWindowPeer xParentPeer, String sError )
protected static void ShowError( XComponentContext xContext, XWindowPeer xParentPeer, int nErrorID, String sArg )
{
if ( xContext != null && sError != null )
if ( xContext != null && nErrorID >= 0 && nErrorID < STRINGS_NUM )
{
boolean bShown = false;
String sError = null;
try
{
sError = GetLocalizedString( xContext, nErrorID );
if ( sError != null && sArg != null )
sError.replaceAll( "\\$ARG1", sArg );
}
catch( Exception e )
{
e.printStackTrace();
}
if ( sError == null )
sError = "Error: " + nErrorID;
if ( xParentPeer != null )
{
try
......
......@@ -4,9 +4,9 @@
*
* $RCSfile: WikiDialog.java,v $
*
* $Revision: 1.2 $
* $Revision: 1.3 $
*
* last change: $Author: mav $ $Date: 2007-12-13 10:34:07 $
* last change: $Author: mav $ $Date: 2008-01-21 12:57:53 $
*
* The Contents of this file are made available subject to
* the terms of GNU Lesser General Public License Version 2.1.
......@@ -45,7 +45,8 @@ import com.sun.star.lang.XMultiComponentFactory;
import com.sun.star.uno.UnoRuntime;
import com.sun.star.uno.XComponentContext;
public class WikiDialog implements XDialogEventHandler{
public class WikiDialog implements XDialogEventHandler
{
XComponentContext m_xContext;
XControlContainer m_xControlContainer;
......@@ -56,54 +57,94 @@ public class WikiDialog implements XDialogEventHandler{
/** Creates a new instance of WikiDialog */
public WikiDialog(XComponentContext c, String DialogURL) {
public WikiDialog(XComponentContext c, String DialogURL)
{
this.m_xContext = c;
XMultiComponentFactory xMCF = m_xContext.getServiceManager();
m_aSettings = Settings.getSettings(m_xContext);
try {
try
{
Object obj;
obj = xMCF.createInstanceWithContext("com.sun.star.awt.DialogProvider2", m_xContext );
XDialogProvider2 xDialogProvider = (XDialogProvider2) UnoRuntime.queryInterface( XDialogProvider2.class, obj );
m_xDialog = xDialogProvider.createDialogWithHandler( DialogURL, this );
m_xControlContainer = (XControlContainer)UnoRuntime.queryInterface(XControlContainer.class, m_xDialog );
} catch (com.sun.star.uno.Exception ex) {
}
catch (com.sun.star.uno.Exception ex)
{
ex.printStackTrace();
}
}
protected void setMethods (String [] Methods) {
protected void setMethods (String [] Methods)
{
this.m_aMethods = Methods;
}
public boolean show( ) {
public boolean show( )
{
if( m_xDialog != null ) m_xDialog.execute();
return m_bAction;
}
public String[] getSupportedMethodNames() {
public String[] getSupportedMethodNames()
{
return m_aMethods;
}
public boolean callHandlerMethod( XDialog xDialog, Object EventObject, String MethodName ) {
public boolean callHandlerMethod( XDialog xDialog, Object EventObject, String MethodName )
{
return true;
}
public void SetTitle( String sTitle )
throws Exception
{
SetTitle( m_xDialog, sTitle );
}
public static void SetTitle( XDialog xDialog, String sTitle )
throws Exception
{
if ( xDialog != null && sTitle != null )
{
XControl xDialogControl = (XControl)UnoRuntime.queryInterface( XControl.class, xDialog );
if ( xDialogControl != null )
{
XPropertySet xPropSet = (XPropertySet)UnoRuntime.queryInterface( XPropertySet.class, xDialogControl.getModel() );
if ( xPropSet != null )
xPropSet.setPropertyValue( "Title", sTitle );
}
}
}
protected XPropertySet GetPropSet(String sControl)
{
return GetPropSet( m_xControlContainer, sControl );
}
protected static XPropertySet GetPropSet( XControlContainer xControlContainer, String sControl )
{
XPropertySet xPS = null;
if ( xControlContainer != null && sControl != null )
{
XControl xControl = xControlContainer.getControl(sControl);
xPS = (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class, xControl.getModel() );
}
protected XPropertySet getPropSet(String sControl) {
XControl xControl = m_xControlContainer.getControl(sControl);
XPropertySet xPS = (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class, xControl.getModel() );
if ( xPS == null )
throw new com.sun.star.uno.RuntimeException();
return xPS;
}
public static XDialog CreateSimpleDialog( XComponentContext xContext, String sURL )
public static XDialog CreateSimpleDialog( XComponentContext xContext, String sURL, int nTitleID, String[] pControls, int[] pStringIDs )
{
XDialog xResult = null;
......@@ -116,8 +157,19 @@ public class WikiDialog implements XDialogEventHandler{
if ( xDialogProvider != null )
xResult = xDialogProvider.createDialog( sURL );
if ( xResult != null )
{
SetTitle( xResult, Helper.GetLocalizedString( xContext, nTitleID ) );
if ( pControls != null && pStringIDs != null && pControls.length == pStringIDs.length )
{
XControlContainer xControlContainer = (XControlContainer)UnoRuntime.queryInterface( XControlContainer.class, xResult );
for ( int nInd = 0; nInd < pControls.length; nInd++ )
GetPropSet( xControlContainer, pControls[nInd] ).setPropertyValue( "Label", new Integer( pStringIDs[nInd] ) );
}
}
}
catch (com.sun.star.uno.Exception ex)
catch (Exception ex)
{
ex.printStackTrace();
}
......@@ -125,5 +177,4 @@ public class WikiDialog implements XDialogEventHandler{
return xResult;
}
}
......@@ -4,9 +4,9 @@
*
* $RCSfile: WikiEditSettingDialog.java,v $
*
* $Revision: 1.6 $
* $Revision: 1.7 $
*
* last change: $Author: mav $ $Date: 2007-12-14 13:03:54 $
* last change: $Author: mav $ $Date: 2008-01-21 12:57:53 $
*
* The Contents of this file are made available subject to
* the terms of GNU Lesser General Public License Version 2.1.
......@@ -69,8 +69,8 @@ public class WikiEditSettingDialog extends WikiDialog
super.setMethods( Methods );
setting = new Hashtable();
addMode = true;
;
InitStrings( xContext );
InitSaveCheckbox( xContext );
}
......@@ -81,9 +81,9 @@ public class WikiEditSettingDialog extends WikiDialog
setting = ht;
try
{
getPropSet( "UrlField" ).setPropertyValue( "Text", ht.get( "Url" ));
getPropSet( "UsernameField" ).setPropertyValue( "Text", ht.get( "Username" ));
getPropSet( "PasswordField" ).setPropertyValue( "Text", ht.get( "Password" ));
GetPropSet( "UrlField" ).setPropertyValue( "Text", ht.get( "Url" ));
GetPropSet( "UsernameField" ).setPropertyValue( "Text", ht.get( "Username" ));
GetPropSet( "PasswordField" ).setPropertyValue( "Text", ht.get( "Password" ));
}
catch ( Exception ex )
{
......@@ -91,12 +91,34 @@ public class WikiEditSettingDialog extends WikiDialog
}
addMode = false;
InitStrings( xContext );
InitSaveCheckbox( xContext );
}
private void InitStrings( XComponentContext xContext )
{
try
{
SetTitle( Helper.GetLocalizedString( xContext, Helper.DLG_MEDIAWIKI_TITLE ) );
GetPropSet( "UrlLabel" ).setPropertyValue( "Label", Helper.GetLocalizedString( xContext, Helper.DLG_EDITSETTING_URLLABEL ) );
GetPropSet( "UsernameLabel" ).setPropertyValue( "Label", Helper.GetLocalizedString( xContext, Helper.DLG_EDITSETTING_USERNAMELABEL ) );
GetPropSet( "PasswordLabel" ).setPropertyValue( "Label", Helper.GetLocalizedString( xContext, Helper.DLG_EDITSETTING_PASSWORDLABEL ) );
GetPropSet( "AccountLine" ).setPropertyValue( "Label", Helper.GetLocalizedString( xContext, Helper.DLG_EDITSETTING_ACCOUNTLINE ) );
GetPropSet( "WikiLine" ).setPropertyValue( "Label", Helper.GetLocalizedString( xContext, Helper.DLG_EDITSETTING_WIKILINE ) );
GetPropSet( "SaveBox" ).setPropertyValue( "Label", Helper.GetLocalizedString( xContext, Helper.DLG_EDITSETTING_SAVEBOX ) );
GetPropSet( "OkButton" ).setPropertyValue( "Label", Helper.GetLocalizedString( xContext, Helper.DLG_OK ) );
GetPropSet( "HelpButton" ).setPropertyValue( "Label", Helper.GetLocalizedString( xContext, Helper.DLG_HELP ) );
GetPropSet( "CancelButton" ).setPropertyValue( "Label", Helper.GetLocalizedString( xContext, Helper.DLG_CANCEL ) );
}
catch( Exception e )
{
e.printStackTrace();
}
}
private void InitSaveCheckbox( XComponentContext xContext )
{
XPropertySet xSaveCheck = getPropSet( "SaveBox" );
XPropertySet xSaveCheck = GetPropSet( "SaveBox" );
try
{
xSaveCheck.setPropertyValue( "State", new Short( (short)0 ) );
......@@ -116,9 +138,9 @@ public class WikiEditSettingDialog extends WikiDialog
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;
......@@ -164,7 +186,8 @@ public class WikiEditSettingDialog extends WikiDialog
// show error
Helper.ShowError( m_xContext,
m_xDialog,
m_sNoConnectionToURL1 + sURL + m_sNoConnectionToURL2 );
Helper.NOURLCONNECTION_ERROR,
sURL );
}
}
else
......@@ -176,7 +199,8 @@ public class WikiEditSettingDialog extends WikiDialog
// show error
Helper.ShowError( m_xContext,
m_xDialog,
m_sWrongLogin );
Helper.WRONGLOGIN_ERROR,
null );
}
else
{
......@@ -187,7 +211,7 @@ public class WikiEditSettingDialog extends WikiDialog
Settings.getSettings( m_xContext ).addWikiCon( setting );
if ( Helper.PasswordStoringIsAllowed( m_xContext )
&& ( (Short)( getPropSet( "SaveBox" ).getPropertyValue("State") ) ).shortValue() != (short)0 )
&& ( (Short)( GetPropSet( "SaveBox" ).getPropertyValue("State") ) ).shortValue() != (short)0 )
{
String[] pPasswords = { sPassword };
try
......@@ -211,7 +235,8 @@ public class WikiEditSettingDialog extends WikiDialog
// show error
Helper.ShowError( m_xContext,
m_xDialog,
m_sInvalidURL );
Helper.INVALIDURL_ERROR,
null );
}
}
else
......@@ -220,7 +245,8 @@ public class WikiEditSettingDialog extends WikiDialog
// show error
Helper.ShowError( m_xContext,
m_xDialog,
m_sNoURL );
Helper.NOURL_ERROR,
null );
}
} while ( sRedirectURL.length() > 0 );
}
......@@ -228,7 +254,8 @@ public class WikiEditSettingDialog extends WikiDialog
{
Helper.ShowError( m_xContext,
m_xDialog,
m_sNoConnectionToURL1 + sURL + m_sNoConnectionToURL2 );
Helper.NOURLCONNECTION_ERROR,
sURL );
ex.printStackTrace();
}
return true;
......
......@@ -4,9 +4,9 @@
*
* $RCSfile: WikiEditorImpl.java,v $
*
* $Revision: 1.3 $
* $Revision: 1.4 $
*
* last change: $Author: mav $ $Date: 2007-12-14 09:40:43 $
* last change: $Author: mav $ $Date: 2008-01-21 12:57:53 $
*
* The Contents of this file are made available subject to
* the terms of GNU Lesser General Public License Version 2.1.
......@@ -76,8 +76,6 @@ public final class WikiEditorImpl extends WeakBase
private final XComponentContext m_xContext;
private static final String m_implementationName = WikiEditorImpl.class.getName();
private static final String[] m_serviceNames = {"com.sun.star.wiki.WikiEditor" };
private static final String m_sGeneralSendError = "The operation 'Send to MediaWiki' could not be completed successfully.";
private static final String m_sNoWikiFilter = "The MediaWiki export filter cannot be found. Choose 'Tools-XML Filter Settings' to install the filter, or use the setup to install the component.";
// information needed for component registration
public static final String[] supportedServiceNames = {"com.sun.star.frame.ProtocolHandler"};
......@@ -404,7 +402,8 @@ public final class WikiEditorImpl extends WeakBase
{
Helper.ShowError( m_xContext,
(XWindowPeer)UnoRuntime.queryInterface( XWindowPeer.class, m_xFrame.getContainerWindow() ),
m_sNoWikiFilter );
Helper.NOWIKIFILTER_ERROR,
null );
throw new com.sun.star.uno.RuntimeException();
}
......@@ -442,7 +441,15 @@ public final class WikiEditorImpl extends WeakBase
if ( aArticle.NotExist() )
{
// ask whether creation of a new page is allowed
XDialog xDialog = WikiDialog.CreateSimpleDialog( m_xContext, "vnd.sun.star.script:WikiEditor.NewWikiPage?location=application" );
String[] pControls = { "Label1", "CommandButton1", "CommandButton2" };
int[] pStringIDs = { Helper.DLG_NEWWIKIPAGE_LABEL1, Helper.DLG_YES, Helper.DLG_NO };
XDialog xDialog = WikiDialog.CreateSimpleDialog(
m_xContext,
"vnd.sun.star.script:WikiEditor.NewWikiPage?location=application",
Helper.DLG_SENDTITLE,
pControls,
pStringIDs );
if ( xDialog != null )
{
Helper.SetControlPropInDialog( xDialog, "Label1", "Label", "A wiki article with the title " + aSendDialog.m_sWikiTitle + " does not exist yet. Do you want to create a new article with that name?" );
......@@ -494,7 +501,8 @@ public final class WikiEditorImpl extends WeakBase
{
Helper.ShowError( m_xContext,
(XWindowPeer)UnoRuntime.queryInterface( XWindowPeer.class, m_xFrame.getContainerWindow() ),
m_sGeneralSendError );
Helper.GENERALSEND_ERROR,
null );
}
}
}
......@@ -509,7 +517,8 @@ public final class WikiEditorImpl extends WeakBase
// report the error only if sending was not cancelled
Helper.ShowError( m_xContext,
(XWindowPeer)UnoRuntime.queryInterface( XWindowPeer.class, m_xFrame.getContainerWindow() ),
m_sGeneralSendError );
Helper.GENERALSEND_ERROR,
null );
}
e.printStackTrace();
}
......
......@@ -4,9 +4,9 @@
*
* $RCSfile: WikiOptionsEventHandlerImpl.java,v $
*
* $Revision: 1.1 $
* $Revision: 1.2 $
*
* last change: $Author: mav $ $Date: 2007-11-28 11:15:20 $
* last change: $Author: mav $ $Date: 2008-01-21 12:57:53 $
*
* The Contents of this file are made available subject to
* the terms of GNU Lesser General Public License Version 2.1.
......@@ -186,6 +186,20 @@ public final class WikiOptionsEventHandlerImpl extends WeakBase
}
}
private void InitStrings()
{
try
{
GetPropSet( "AddButton" ).setPropertyValue( "Label", Helper.GetLocalizedString( m_xContext, Helper.DLG_ADDBUTTON ) );
GetPropSet( "EditButton" ).setPropertyValue( "Label", Helper.GetLocalizedString( m_xContext, Helper.DLG_SENDBUTTON ) );
GetPropSet( "RemoveButton" ).setPropertyValue( "Label", Helper.GetLocalizedString( m_xContext, Helper.DLG_REMOVEBUTTON ) );
}
catch( Exception e )
{
e.printStackTrace();
}
}
// com.sun.star.lang.XServiceInfo:
public String getImplementationName()
{
......@@ -233,6 +247,7 @@ public final class WikiOptionsEventHandlerImpl extends WeakBase
m_xControlContainer = (XControlContainer)UnoRuntime.queryInterface(
XControlContainer.class, m_xDialog );
m_aSettings = Settings.getSettings( m_xContext );
InitStrings();
}
else if ( m_aSettings != null )
m_aSettings.loadConfiguration(); // throw away all the changes
......
......@@ -4,9 +4,9 @@
*
* $RCSfile: WikiPropDialog.java,v $
*
* $Revision: 1.4 $
* $Revision: 1.5 $
*
* last change: $Author: mav $ $Date: 2007-12-14 13:03:54 $
* last change: $Author: mav $ $Date: 2008-01-21 12:57:53 $
*
* The Contents of this file are made available subject to
* the terms of GNU Lesser General Public License Version 2.1.
......@@ -51,7 +51,6 @@ import com.sun.star.uno.XComponentContext;
public class WikiPropDialog extends WikiDialog{
private static final String m_sCancelSending = "The transfer has been interrupted. Please check the integrity of the wiki article.";
WikiEditorImpl m_aWikiEditor;
private final String sSendMethod = "Send";
......@@ -62,7 +61,7 @@ public class WikiPropDialog extends WikiDialog{
private final String sArticleTextMethod = "ArticleTextChange";
private final String sAddWikiMethod = "AddWiki";
String[] Methods = {sSendMethod, sCancelMethod, sHelpMethod, sLoadMethod, sWikiListMethod, sArticleTextMethod, sAddWikiMethod};
String[] m_pMethods = {sSendMethod, sCancelMethod, sHelpMethod, sLoadMethod, sWikiListMethod, sArticleTextMethod, sAddWikiMethod};
protected String m_sWikiEngineURL = "";
protected String m_sWikiTitle = "";
......@@ -73,18 +72,40 @@ public class WikiPropDialog extends WikiDialog{
private Thread m_aSendingThread;
/** Creates a new instance of WikiPropDialog */
public WikiPropDialog(XComponentContext c, String DialogURL, WikiEditorImpl aWikiEditorForThrobber )
public WikiPropDialog(XComponentContext xContext, String DialogURL, WikiEditorImpl aWikiEditorForThrobber )
{
super(c, DialogURL);
super.setMethods(Methods);
super(xContext, DialogURL);
super.setMethods(m_pMethods);
if ( aWikiEditorForThrobber != null )
{
InsertThrobber();
m_aWikiEditor = aWikiEditorForThrobber;
}
InitStrings( xContext );
}
private void InitStrings( XComponentContext xContext )
{
try
{
SetTitle( Helper.GetLocalizedString( xContext, Helper.DLG_SENDTITLE ) );
GetPropSet( "Label1" ).setPropertyValue( "Label", Helper.GetLocalizedString( xContext, Helper.DLG_SENDTOMEDIAWIKI_LABEL1 ) );
GetPropSet( "Label2" ).setPropertyValue( "Label", Helper.GetLocalizedString( xContext, Helper.DLG_SENDTOMEDIAWIKI_LABEL2 ) );
GetPropSet( "Label3" ).setPropertyValue( "Label", Helper.GetLocalizedString( xContext, Helper.DLG_SENDTOMEDIAWIKI_LABEL3 ) );
GetPropSet( "MinorCheck" ).setPropertyValue( "Label", Helper.GetLocalizedString( xContext, Helper.DLG_SENDTOMEDIAWIKI_MINORCHECK ) );
GetPropSet( "BrowserCheck" ).setPropertyValue( "Label", Helper.GetLocalizedString( xContext, Helper.DLG_SENDTOMEDIAWIKI_BROWSERCHECK ) );
GetPropSet( "HelpButton" ).setPropertyValue( "Label", Helper.GetLocalizedString( xContext, Helper.DLG_HELP ) );
GetPropSet( "CancelButton" ).setPropertyValue( "Label", Helper.GetLocalizedString( xContext, Helper.DLG_CANCEL ) );
GetPropSet( "AddButton" ).setPropertyValue( "Label", Helper.GetLocalizedString( xContext, Helper.DLG_ADDBUTTON ) );
GetPropSet( "SendButton" ).setPropertyValue( "Label", Helper.GetLocalizedString( xContext, Helper.DLG_SENDBUTTON ) );
}
catch( Exception e )
{
e.printStackTrace();
}
}
public void fillWikiList()
{
......@@ -92,7 +113,7 @@ public class WikiPropDialog extends WikiDialog{
try
{
XPropertySet xPS = getPropSet("WikiList");
XPropertySet xPS = GetPropSet("WikiList");
xPS.setPropertyValue("StringItemList", WikiList);
// short [] nSel = new short[1];
// nSel[0] = (short) m_aSettings.getLastUsedWikiServer();
......@@ -106,10 +127,10 @@ public class WikiPropDialog extends WikiDialog{
public void fillDocList()
{
XPropertySet xPS = getPropSet("ArticleText");
XPropertySet xPS = GetPropSet("ArticleText");
try
{
short [] sel = (short[]) getPropSet("WikiList").getPropertyValue("SelectedItems");
short [] sel = (short[]) GetPropSet("WikiList").getPropertyValue("SelectedItems");
xPS.setPropertyValue("StringItemList", m_aSettings.getWikiDocList(sel[0], 5));
}
catch (Exception ex)
......@@ -124,7 +145,7 @@ public class WikiPropDialog extends WikiDialog{
this.m_sWikiTitle = sArticle;
try
{
XPropertySet xPS = getPropSet("ArticleText");
XPropertySet xPS = GetPropSet("ArticleText");
xPS.setPropertyValue("Text", sArticle);
}
catch (Exception ex)
......@@ -136,16 +157,16 @@ public class WikiPropDialog extends WikiDialog{
public void switchSendButtonIfNecessary()
{
XPropertySet xSendButton = getPropSet( "SendButton" );
XPropertySet xSendButton = GetPropSet( "SendButton" );
if ( xSendButton != null )
{
XPropertySet xWikiListProps = getPropSet( "WikiList" );
XPropertySet xArticleProps = getPropSet( "ArticleText" );
XPropertySet xWikiListProps = GetPropSet( "WikiList" );
XPropertySet xArticleProps = GetPropSet( "ArticleText" );
if ( xWikiListProps != null && xArticleProps != null )
{
try
{
short [] pSel = (short[]) getPropSet("WikiList").getPropertyValue("SelectedItems");
short [] pSel = (short[]) GetPropSet("WikiList").getPropertyValue("SelectedItems");
String sArticle = (String)xArticleProps.getPropertyValue( "Text" );
if ( pSel != null && pSel.length > 0 && sArticle != null && sArticle.length() != 0 )
xSendButton.setPropertyValue( "Enabled", Boolean.TRUE );
......@@ -167,14 +188,14 @@ public class WikiPropDialog extends WikiDialog{
{
try
{
XPropertySet aWikiListProps = getPropSet( "WikiList" );
XPropertySet aArticleTextProps = getPropSet( "ArticleText" );
XPropertySet aCommentTextProps = getPropSet( "CommentText" );
XPropertySet aMinorCheckProps = getPropSet( "MinorCheck" );
XPropertySet aBrowserCheckProps = getPropSet( "BrowserCheck" );
XPropertySet aHelpButtonProps = getPropSet( "HelpButton" );
XPropertySet aSendButtonProps = getPropSet( "SendButton" );
XPropertySet aAddButtonProps = getPropSet( "AddButton" );
XPropertySet aWikiListProps = GetPropSet( "WikiList" );
XPropertySet aArticleTextProps = GetPropSet( "ArticleText" );
XPropertySet aCommentTextProps = GetPropSet( "CommentText" );
XPropertySet aMinorCheckProps = GetPropSet( "MinorCheck" );
XPropertySet aBrowserCheckProps = GetPropSet( "BrowserCheck" );
XPropertySet aHelpButtonProps = GetPropSet( "HelpButton" );
XPropertySet aSendButtonProps = GetPropSet( "SendButton" );
XPropertySet aAddButtonProps = GetPropSet( "AddButton" );
short [] sel = (short[]) aWikiListProps.getPropertyValue("SelectedItems");
String [] items = (String []) aWikiListProps.getPropertyValue("StringItemList");
......@@ -277,11 +298,11 @@ public class WikiPropDialog extends WikiDialog{
{
try
{
short [] sel = (short[]) getPropSet("WikiList").getPropertyValue("SelectedItems");
String [] items = (String []) getPropSet("WikiList").getPropertyValue("StringItemList");
short [] sel = (short[]) GetPropSet("WikiList").getPropertyValue("SelectedItems");
String [] items = (String []) GetPropSet("WikiList").getPropertyValue("StringItemList");
m_sWikiEngineURL = items[sel[0]];
m_aSettings.setLastUsedWikiServer(sel[0]);
m_sWikiTitle = (String) getPropSet("ArticleText").getPropertyValue("Text");
m_sWikiTitle = (String) GetPropSet("ArticleText").getPropertyValue("Text");
}
catch (UnknownPropertyException ex)
{
......@@ -309,7 +330,8 @@ public class WikiPropDialog extends WikiDialog{
{
Helper.ShowError( m_xContext,
m_xDialog,
m_sCancelSending );
Helper.CANCELSENDING_ERROR,
null );
}
return true;
......
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