Hi,
See below,
cristinas (SVN) wrote:
Author: cristinas
Date: 2009-05-31 09:54:20 +0200 (Sun, 31 May 2009)
New Revision: 20663
Added:
sandbox/gsoc/xoo/src/main/java/org/xwiki/xoo/Debug.java
sandbox/gsoc/xoo/src/main/java/org/xwiki/xoo/Settings.java
sandbox/gsoc/xoo/src/main/java/org/xwiki/xoo/SettingsDialog.java
sandbox/gsoc/xoo/src/main/java/org/xwiki/xoo/Utils.java
sandbox/gsoc/xoo/src/main/java/org/xwiki/xoo/XWikiAddIn.java
sandbox/gsoc/xoo/src/main/java/org/xwiki/xoo/XWikiDialog.java
sandbox/gsoc/xoo/src/main/oxt/dialogLibrary/
sandbox/gsoc/xoo/src/main/oxt/dialogLibrary/Login.xdl
sandbox/gsoc/xoo/src/main/oxt/dialogLibrary/Module1.xba
sandbox/gsoc/xoo/src/main/oxt/dialogLibrary/dialog.xlb
sandbox/gsoc/xoo/src/main/oxt/dialogLibrary/script.xlb
Modified:
sandbox/gsoc/xoo/pom.xml
sandbox/gsoc/xoo/src/main/assembly/dep.xml
sandbox/gsoc/xoo/src/main/java/org/xwiki/xoo/IConstants.java
sandbox/gsoc/xoo/src/main/java/org/xwiki/xoo/XOO.java
sandbox/gsoc/xoo/src/main/oxt/META-INF/manifest.xml
Log:
connection wizard added
Modified: sandbox/gsoc/xoo/pom.xml
===================================================================
--- sandbox/gsoc/xoo/pom.xml 2009-05-31 04:19:18 UTC (rev 20662)
+++ sandbox/gsoc/xoo/pom.xml 2009-05-31 07:54:20 UTC (rev 20663)
@@ -1,9 +1,8 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<project>
+<project
xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.xwiki.xoo</groupId>
<artifactId>xoo</artifactId>
- <version>1.0</version>
+ <version>1.0-SNAPSHOT</version>
<description>XWiki
OpenOffice.org Integration</description>
<build>
<plugins>
@@ -72,21 +71,27 @@
<dependency>
<groupId>org.openoffice</groupId>
<artifactId>jurt</artifactId>
- <version>2.1.0</version>
+ <version>3.0.0</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.openoffice</groupId>
<artifactId>ridl</artifactId>
- <version>2.1.0</version>
+ <version>3.0.0</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.openoffice</groupId>
<artifactId>unoil</artifactId>
- <version>2.1.0</version>
+ <version>3.0.0</version>
<scope>compile</scope>
</dependency>
+ <dependency>
+ <groupId>org.xwiki.platform</groupId>
+ <artifactId>xwiki-core-xmlrpc-client</artifactId>
+ <version>1.9-SNAPSHOT</version>
+ <scope>compile</scope>
+ </dependency>
</dependencies>
</project>
Modified: sandbox/gsoc/xoo/src/main/assembly/dep.xml
===================================================================
--- sandbox/gsoc/xoo/src/main/assembly/dep.xml 2009-05-31 04:19:18 UTC (rev 20662)
+++ sandbox/gsoc/xoo/src/main/assembly/dep.xml 2009-05-31 07:54:20 UTC (rev 20663)
@@ -1,9 +1,12 @@
<assembly>
- <id>bin</id>
<formats>
<format>zip</format>
</formats>
<includeBaseDirectory>false</includeBaseDirectory>
+ <dependencySets>
+ <dependencySet>
+ </dependencySet>
+ </dependencySets>
<fileSets>
<fileSet>
<directory>src/main/oxt</directory>
@@ -20,6 +23,10 @@
<directory>src/main/oxt/META-INF</directory>
<outputDirectory>/META-INF</outputDirectory>
</fileSet>
+ <fileSet>
+ <directory>src/main/oxt/dialogLibrary</directory>
+ <outputDirectory>/dialogLibrary</outputDirectory>
+ </fileSet>
<fileSet>
<directory>target</directory>
<outputDirectory></outputDirectory>
Added: sandbox/gsoc/xoo/src/main/java/org/xwiki/xoo/Debug.java
===================================================================
--- sandbox/gsoc/xoo/src/main/java/org/xwiki/xoo/Debug.java (rev
0)
+++ sandbox/gsoc/xoo/src/main/java/org/xwiki/xoo/Debug.java 2009-05-31 07:54:20 UTC (rev
20663)
@@ -0,0 +1,107 @@
+/*
+ * See the NOTICE file distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+
+package org.xwiki.xoo;
+
+import com.sun.star.awt.Rectangle;
+import com.sun.star.awt.WindowAttribute;
+import com.sun.star.awt.WindowClass;
+import com.sun.star.awt.WindowDescriptor;
+import com.sun.star.awt.XMessageBox;
+import com.sun.star.awt.XToolkit;
+import com.sun.star.awt.XWindowPeer;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.frame.XFrame;
+
+public class Debug {
+
+ private static Debug _instance;
+
+ private XFrame m_xFrame;
+ private XToolkit m_xToolkit;
+
+ /**
+ *
+ */
+ private Debug() {
+ }
+
+ /**
+ *
+ * @param m_xFrame
+ * @param m_xToolkit
+ */
+ public void setContext(XFrame m_xFrame, XToolkit m_xToolkit) {
+ this.m_xFrame = m_xFrame;
+ this.m_xToolkit = m_xToolkit;
+ }
+
+ /**
+ *
+ * @return
+ */
+ public static Debug getInstance() {
+ if (null == _instance) {
+ _instance = new Debug();
+ }
+ return _instance;
+ }
+
+ /**
+ * Shows a dialog used for debugging
+ *
+ * @param sTitle
+ * the title of the dialog
+ * @param sMessage
+ * the message to be displayed
+ */
+ public void showMessageBox(String sMessage) {
+ try {
+ if (null != m_xFrame && null != m_xToolkit) {
+
+ // describe window properties.
+ WindowDescriptor aDescriptor = new WindowDescriptor();
+ aDescriptor.Type = WindowClass.MODALTOP;
+ aDescriptor.WindowServiceName = new String("infobox");
+ aDescriptor.ParentIndex = -1;
+ aDescriptor.Parent = (XWindowPeer) UnoRuntime.queryInterface(
+ XWindowPeer.class, m_xFrame.getContainerWindow());
+ aDescriptor.Bounds = new Rectangle(0, 0, 300, 200);
+ aDescriptor.WindowAttributes = WindowAttribute.BORDER
+ | WindowAttribute.MOVEABLE | WindowAttribute.CLOSEABLE;
+
+ XWindowPeer xPeer = m_xToolkit.createWindow(aDescriptor);
+ if (null != xPeer) {
+ XMessageBox xMsgBox = (XMessageBox) UnoRuntime
+ .queryInterface(XMessageBox.class, xPeer);
+ if (null != xMsgBox) {
+ xMsgBox.setCaptionText("Debug");
+ xMsgBox.setMessageText(sMessage);
+ xMsgBox.execute();
+ }
+ }
+ }
+ } catch (com.sun.star.uno.Exception e) {
+ // TODO error handling
+
+ }
+ }
+
+}
Modified: sandbox/gsoc/xoo/src/main/java/org/xwiki/xoo/IConstants.java
===================================================================
--- sandbox/gsoc/xoo/src/main/java/org/xwiki/xoo/IConstants.java 2009-05-31 04:19:18 UTC
(rev 20662)
+++ sandbox/gsoc/xoo/src/main/java/org/xwiki/xoo/IConstants.java 2009-05-31 07:54:20 UTC
(rev 20663)
@@ -25,8 +25,19 @@
*/
public interface IConstants {
Why do you need an interface for this?
This looks like a .net interface naming convention, but I did not see it
in the java world. The XWiki convention is documented here:
-
http://dev.xwiki.org/xwiki/bin/view/Community/CodeStyle#HClass2FInterfacena…
-
- public final static String PROTOCOL_XOO = "org.xwiki.xoo.xoo:";
- public final static String CMD_LOGIN = "cmdLogin";
-
+
+ final static String PROTOCOL_XOO = "org.xwiki.xoo.xoo:";
+ final static String CMD_LOGIN = "cmdLogin";
+ final static String SETTINGS_DIALOG =
"vnd.sun.star.script:dialogLibrary.Login?location=application";
+
+ final static int TYPE_INFO = 0;
+ final static int TYPE_ERROR = 1;
+
+ final static String TITLE_ERROR = "XWiki Error";
+ final static String TITLE_XWIKI = "XWiki";
+
+ final static int ERROR_LOGINFAILED = 0;
+ final static String[] errorMessages = { "Login failed! Please check the server
URL, the username and password " };
+ final static int MESS_LOGINSUCC = 0;
+ final static String[] Messages = { "Login succeed!" };
}
Added: sandbox/gsoc/xoo/src/main/java/org/xwiki/xoo/Settings.java
===================================================================
--- sandbox/gsoc/xoo/src/main/java/org/xwiki/xoo/Settings.java
(rev 0)
+++ sandbox/gsoc/xoo/src/main/java/org/xwiki/xoo/Settings.java 2009-05-31 07:54:20 UTC
(rev 20663)
@@ -0,0 +1,63 @@
+/*
+ * See the NOTICE file distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+
+package org.xwiki.xoo;
+
+public class Settings {
I this a generic settings class or will it store just authentication
settings?
+
+ private String serverURL;
+ private String username;
+ private String password;
+
+ public Settings(String serverURL, String username, String password) {
+ this.serverURL = serverURL;
+ this.username = username;
+ this.password = password;
+ }
+
+ public String getServerURL() {
+ return serverURL;
+ }
+
+ public void setServerURL(String serverURL) {
+ this.serverURL = serverURL;
+ }
+
+ public String getUsername() {
+ return username;
+ }
+
+ public void setUsername(String username) {
+ this.username = username;
+ }
+
+ public String getPassword() {
+ return password;
+ }
+
+ public void setPassword(String password) {
+ this.password = password;
+ }
+
+ public String toString() {
+ return serverURL + " " + username + " " + password;
+ }
+
+}
Added: sandbox/gsoc/xoo/src/main/java/org/xwiki/xoo/SettingsDialog.java
===================================================================
--- sandbox/gsoc/xoo/src/main/java/org/xwiki/xoo/SettingsDialog.java
(rev 0)
+++ sandbox/gsoc/xoo/src/main/java/org/xwiki/xoo/SettingsDialog.java 2009-05-31 07:54:20
UTC (rev 20663)
@@ -0,0 +1,106 @@
+/*
+ * See the NOTICE file distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+
+package org.xwiki.xoo;
+
+import org.xwiki.xmlrpc.XWikiXmlRpcClient;
+
+import com.sun.star.awt.XDialog;
+import com.sun.star.beans.UnknownPropertyException;
+import com.sun.star.lang.WrappedTargetException;
+import com.sun.star.uno.XComponentContext;
+
+public class SettingsDialog extends XWikiDialog {
+
+ private final String sOKMethod = "btnOK_Clicked";
+ private final String sCancelMethod = "btnCancel_Clicked";
+
+ /**
+ *
+ * @param c
+ */
+ public SettingsDialog(XComponentContext c) {
+ super(c, IConstants.SETTINGS_DIALOG);
+ }
+
+ /**
+ *
+ */
+ public boolean callHandlerMethod(XDialog xDialog, Object EventObject,
+ String MethodName) {
+
+ if (MethodName.equals(sOKMethod)) {
+ btnOK_Clicked();
+ }
+ if (MethodName.equals(sCancelMethod)) {
+ btnCancel_Clicked();
+ }
+ return true;
+ }
+
+ /**
+ *
+ */
+ public void btnOK_Clicked() {
+
+ boolean bResult = false;
+
+ try {
+ String sURL = (String) GetPropSet("txtServerURL").getPropertyValue(
+ "Text");
+ String sUserName = (String) GetPropSet("txtUsername")
+ .getPropertyValue("Text");
+ String sPassword = (String) GetPropSet("txtPassword")
+ .getPropertyValue("Text");
+ Settings set = new Settings(sURL, sUserName, sPassword);
+
+ XWikiAddIn xWikiAddIn = XWikiAddIn.getInstance();
+ xWikiAddIn.setSettings(set);
+ XWikiXmlRpcClient client = xWikiAddIn.getClient();
+ if (client != null) {
+ bResult = xWikiAddIn.doLogin();
+ }
+ if (bResult) {
+ m_xDialog.endExecute();
+ Utils.ShowMessage(m_xContext, m_xDialog,
+ IConstants.TITLE_XWIKI, IConstants.MESS_LOGINSUCC,
+ IConstants.TYPE_INFO, false);
+ } else {
+ Utils.ShowMessage(m_xContext, m_xDialog,
+ IConstants.TITLE_ERROR, IConstants.ERROR_LOGINFAILED,
+ IConstants.TYPE_ERROR, false);
+ }
+ } catch (UnknownPropertyException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (WrappedTargetException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ }
+
+ /**
+ *
+ */
+ public void btnCancel_Clicked() {
+ m_xDialog.endExecute();
+ }
You have missing javadoc on every method in this class. Why are the
mouse clicked methods public?
+}
\ No newline at end of file
Added: sandbox/gsoc/xoo/src/main/java/org/xwiki/xoo/Utils.java
===================================================================
--- sandbox/gsoc/xoo/src/main/java/org/xwiki/xoo/Utils.java (rev
0)
+++ sandbox/gsoc/xoo/src/main/java/org/xwiki/xoo/Utils.java 2009-05-31 07:54:20 UTC (rev
20663)
@@ -0,0 +1,169 @@
+/*
+ * See the NOTICE file distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+
+package org.xwiki.xoo;
+
+import com.sun.star.awt.MessageBoxButtons;
+import com.sun.star.awt.XControl;
+import com.sun.star.awt.XDialog;
+import com.sun.star.awt.XMessageBox;
+import com.sun.star.awt.XMessageBoxFactory;
+import com.sun.star.awt.XWindowPeer;
+import com.sun.star.lang.XComponent;
+import com.sun.star.lang.XMultiComponentFactory;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.uno.XComponentContext;
+
+public class Utils {
+
+ /**
+ *
+ * @param nMessID
+ * @param nTypeID
+ * @return
+ */
+ private static String getText(int nMessID, int nTypeID) {
+ String sMessage = null;
+
+ switch (nTypeID) {
+ case IConstants.TYPE_ERROR:
+ sMessage = (IConstants.errorMessages.length > nMessID) ?
IConstants.errorMessages[nMessID]
+ : "Error: " + nMessID;
+ break;
+ case IConstants.TYPE_INFO:
+ sMessage = (IConstants.Messages.length > nMessID) ? IConstants.Messages[nMessID]
+ : "Error: " + nMessID;
+ break;
+ }
+ return sMessage;
+ }
+
+ /**
+ *
+ * @param xContext
+ * @param xDialog
+ * @param sTitle
+ * @param nMessID
+ * @param nTypeID
+ * @param bQuery
+ */
+ protected static void ShowMessage(XComponentContext xContext,
+ XDialog xDialog, String sTitle, int nMessID, int nTypeID,
+ boolean bQuery) {
+ XWindowPeer xPeer = null;
+ XControl xControl = (XControl) UnoRuntime.queryInterface(
+ XControl.class, xDialog);
+ if (xControl != null)
+ xPeer = xControl.getPeer();
+ ShowMessage(xContext, xPeer, sTitle, nMessID, nTypeID, bQuery);
+ }
+
+ /**
+ *
+ * @param xContext
+ * @param xParentPeer
+ * @param sTitle
+ * @param nMessID
+ * @param nTypeID
+ * @param bQuery
+ * @return
+ */
+ protected static boolean ShowMessage(XComponentContext xContext,
+ XWindowPeer xParentPeer, String sTitle, int nMessID, int nTypeID,
+ boolean bQuery) {
+ boolean bResult = false;
+
+ if (xContext != null) {
+ String sMessage = getText(nMessID, nTypeID);
+
+ if (xParentPeer != null) {
+ XMessageBoxFactory xMBFactory = null;
+ XMessageBox xMB = null;
+ try {
+ XMultiComponentFactory xFactory = xContext
+ .getServiceManager();
+ if (xFactory != null)
+ xMBFactory = (XMessageBoxFactory) UnoRuntime
+ .queryInterface(XMessageBoxFactory.class,
+ xFactory.createInstanceWithContext(
+ "com.sun.star.awt.Toolkit",
+ xContext));
+
+ if (xMBFactory != null) {
+ if (bQuery) {
+ xMB = xMBFactory
+ .createMessageBox(
+ xParentPeer,
+ new com.sun.star.awt.Rectangle(),
+ "querybox",
+ MessageBoxButtons.BUTTONS_YES_NO
+ | MessageBoxButtons.DEFAULT_BUTTON_NO,
+ sTitle, sMessage);
+ } else if (nTypeID == IConstants.TYPE_INFO) {
+ xMB = xMBFactory.createMessageBox(xParentPeer,
+ new com.sun.star.awt.Rectangle(),
+ "infobox",
+ MessageBoxButtons.BUTTONS_YES_NO, sTitle,
+ sMessage);
+ }
+
+ else {
+ xMB = xMBFactory.createMessageBox(xParentPeer,
+ new com.sun.star.awt.Rectangle(),
+ "errorbox", MessageBoxButtons.BUTTONS_OK,
+ sTitle, sMessage);
+ }
+ if (xMB != null) {
+ xMB.execute();
+ bResult = true;
+ }
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ // TODO error Handling
+
+ } finally {
+ if (xMB != null)
+ Dispose(xMB);
+ }
+ }
+ }
+
+ return bResult;
+ }
+
+ /**
+ *
+ * @param oObject
+ */
+ public static void Dispose(Object oObject) {
+ if (oObject != null) {
+ try {
+ XComponent xComp = (XComponent) UnoRuntime.queryInterface(
+ XComponent.class, oObject);
+ if (xComp != null)
+ xComp.dispose();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+ }
+
+}
Modified: sandbox/gsoc/xoo/src/main/java/org/xwiki/xoo/XOO.java
===================================================================
--- sandbox/gsoc/xoo/src/main/java/org/xwiki/xoo/XOO.java 2009-05-31 04:19:18 UTC (rev
20662)
+++ sandbox/gsoc/xoo/src/main/java/org/xwiki/xoo/XOO.java 2009-05-31 07:54:20 UTC (rev
20663)
@@ -25,14 +25,7 @@
import com.sun.star.lang.XSingleComponentFactory;
import com.sun.star.registry.XRegistryKey;
import com.sun.star.lib.uno.helper.WeakBase;
-
import com.sun.star.awt.XToolkit;
-import com.sun.star.awt.XWindowPeer;
-import com.sun.star.awt.XMessageBox;
-import com.sun.star.awt.WindowAttribute;
-import com.sun.star.awt.WindowClass;
-import com.sun.star.awt.WindowDescriptor;
-import com.sun.star.awt.Rectangle;
/**
*
@@ -163,6 +156,8 @@
m_xFrame =
(com.sun.star.frame.XFrame)
UnoRuntime.queryInterface(com.sun.star.frame.XFrame.class, object[0]);
}
+ Debug debug = Debug.getInstance();
+ debug.setContext(m_xFrame, m_xToolkit);
}
/**
@@ -175,7 +170,9 @@
{
if (aURL.Protocol.compareTo(IConstants.PROTOCOL_XOO) == 0) {
if (aURL.Path.compareTo(IConstants.CMD_LOGIN) == 0) {
- showMessageBox("Test", "Test");
+ //showMessageBox("Test", "Test");
+ SettingsDialog set = new SettingsDialog(m_xContext);
+ set.show();
return;
}
}
@@ -203,41 +200,4 @@
// TODO add code
}
- /**
- * Shows a dialog used for debugging
- * @param sTitle the title of the dialog
- * @param sMessage the message to be displayed
- */
- public void showMessageBox(String sTitle, String sMessage)
- {
- try {
- if (null != m_xFrame && null != m_xToolkit) {
-
- // describe window properties.
- WindowDescriptor aDescriptor = new WindowDescriptor();
- aDescriptor.Type = WindowClass.MODALTOP;
- aDescriptor.WindowServiceName = new String("infobox");
- aDescriptor.ParentIndex = -1;
- aDescriptor.Parent =
- (XWindowPeer) UnoRuntime.queryInterface(XWindowPeer.class,
m_xFrame.getContainerWindow());
- aDescriptor.Bounds = new Rectangle(0, 0, 300, 200);
- aDescriptor.WindowAttributes =
- WindowAttribute.BORDER | WindowAttribute.MOVEABLE |
WindowAttribute.CLOSEABLE;
-
- XWindowPeer xPeer = m_xToolkit.createWindow(aDescriptor);
- if (null != xPeer) {
- XMessageBox xMsgBox = (XMessageBox)
UnoRuntime.queryInterface(XMessageBox.class, xPeer);
- if (null != xMsgBox) {
- xMsgBox.setCaptionText(sTitle);
- xMsgBox.setMessageText(sMessage);
- xMsgBox.execute();
- }
- }
- }
- } catch (com.sun.star.uno.Exception e) {
- // TODO error handling
-
- }
- }
-
}
Added: sandbox/gsoc/xoo/src/main/java/org/xwiki/xoo/XWikiAddIn.java
===================================================================
--- sandbox/gsoc/xoo/src/main/java/org/xwiki/xoo/XWikiAddIn.java
(rev 0)
+++ sandbox/gsoc/xoo/src/main/java/org/xwiki/xoo/XWikiAddIn.java 2009-05-31 07:54:20 UTC
(rev 20663)
@@ -0,0 +1,93 @@
+/*
+ * See the NOTICE file distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+
+package org.xwiki.xoo;
+
+import java.net.MalformedURLException;
+
+import org.apache.xmlrpc.XmlRpcException;
+import org.xwiki.xmlrpc.XWikiXmlRpcClient;
+
+public class XWikiAddIn {
Can you explain a bit what is the role of this class? I hope this
doesn't become a massive singleton that will be used everywhere across
the sources.
You are using the add-in and add-on terms in your sources. We should
respect the OOo naming and call it 'extension'.
+
+ static private XWikiAddIn _instance = null;
+
+ private XWikiXmlRpcClient client = null;
+ private Settings settings;
+
+ /**
+ *
+ */
+ private XWikiAddIn() {
+ }
+
+ /**
+ *
+ * @return
+ */
+ public static synchronized XWikiAddIn getInstance() {
+ if (null == _instance) {
+ _instance = new XWikiAddIn();
+ }
+ return _instance;
+ }
+
+ /**
+ *
+ * @return
+ */
+ public XWikiXmlRpcClient getClient() {
+ return client;
+ }
+
+ /**
+ *
+ * @param set
+ */
+ public void setSettings(Settings set) {
+ this.settings = set;
+ try {
+ client = new XWikiXmlRpcClient(set.getServerURL());
+ } catch (MalformedURLException e) {
+ }
+ }
+
+ /**
+ *
+ * @return
+ */
+ public Settings getSettings() {
+ return settings;
+ }
+
+ /**
+ *
+ * @return
+ */
+ public boolean doLogin() {
+ boolean bResult = true;
+ try {
+ client.login(settings.getUsername(), settings.getPassword());
+ } catch (XmlRpcException e) {
+ bResult = false;
+ }
+ return bResult;
+ }
+}
Added: sandbox/gsoc/xoo/src/main/java/org/xwiki/xoo/XWikiDialog.java
===================================================================
--- sandbox/gsoc/xoo/src/main/java/org/xwiki/xoo/XWikiDialog.java
(rev 0)
+++ sandbox/gsoc/xoo/src/main/java/org/xwiki/xoo/XWikiDialog.java 2009-05-31 07:54:20 UTC
(rev 20663)
@@ -0,0 +1,158 @@
+/*
+ * See the NOTICE file distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+
+package org.xwiki.xoo;
+
+import com.sun.star.awt.XControl;
+import com.sun.star.awt.XControlContainer;
+import com.sun.star.awt.XControlModel;
+import com.sun.star.awt.XDialog;
+import com.sun.star.awt.XDialogEventHandler;
+import com.sun.star.awt.XDialogProvider2;
+import com.sun.star.beans.XPropertySet;
+import com.sun.star.lang.XMultiComponentFactory;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.uno.XComponentContext;
+import com.sun.star.awt.XTopWindow;
+import com.sun.star.awt.XTopWindowListener;
+import com.sun.star.awt.XWindow;
+import com.sun.star.container.XNameContainer;
+import com.sun.star.lang.EventObject;
+import com.sun.star.lang.XMultiServiceFactory;
+
+public class XWikiDialog implements XDialogEventHandler, XTopWindowListener {
+
+ XComponentContext m_xContext;
+ XControlContainer m_xControlContainer;
+ XDialog m_xDialog;
+ String[] m_aMethods;
+ boolean m_bAction = false;
+
+ protected Thread m_aThread;
+ protected boolean m_bThreadFinished = false;
+
+ /** Creates a new instance of XWikiDialog */
+ public XWikiDialog(XComponentContext c, String DialogURL) {
+ this.m_xContext = c;
+ XMultiComponentFactory xMCF = m_xContext.getServiceManager();
+ 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);
+ XTopWindow xTopWindow = (XTopWindow) UnoRuntime.queryInterface(
+ XTopWindow.class, m_xDialog);
+ if (xTopWindow != null)
+ xTopWindow.addTopWindowListener(this);
+ } catch (com.sun.star.uno.Exception ex) {
+ ex.printStackTrace();
+ }
+ }
+
+ /**
+ * Shows the Dialog.
+ */
+ public void show() {
+ if (m_xDialog != null)
+ m_xDialog.execute();
+ }
+
+ /**
+ *
+ * @param sControl The control for
+ * @return
+ */
+ 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());
+ }
+
+ if (xPS == null)
+ throw new com.sun.star.uno.RuntimeException();
+
+ return xPS;
+ }
+
+ public void DisposeDialog() {
+ }
+
+ public void SetFocusTo(String aControl) {
+ if (m_xControlContainer != null) {
+ try {
+ XWindow xWindow = (XWindow) UnoRuntime
+ .queryInterface(XWindow.class, m_xControlContainer
+ .getControl(aControl));
+ if (xWindow != null)
+ xWindow.setFocus();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+ }
+
+ public boolean callHandlerMethod(XDialog arg0, Object arg1, String arg2) {
+ return true;
+ }
+
+ public String[] getSupportedMethodNames() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public void windowActivated(EventObject arg0) {
+ }
+
+ public void windowClosed(EventObject arg0) {
+ }
+
+ public void windowClosing(EventObject arg0) {
+ }
+
+ public void windowDeactivated(EventObject arg0) {
+ }
+
+ public void windowMinimized(EventObject arg0) {
+ }
+
+ public void windowNormalized(EventObject arg0) {
+ }
+
+ public void windowOpened(EventObject arg0) {
+ }
+
+ public void disposing(EventObject arg0) {
+ }
+
+}
Modified: sandbox/gsoc/xoo/src/main/oxt/META-INF/manifest.xml
===================================================================
--- sandbox/gsoc/xoo/src/main/oxt/META-INF/manifest.xml 2009-05-31 04:19:18 UTC (rev
20662)
+++ sandbox/gsoc/xoo/src/main/oxt/META-INF/manifest.xml 2009-05-31 07:54:20 UTC (rev
20663)
@@ -4,6 +4,8 @@
manifest:full-path="xoo-1.0.jar"/>
<manifest:file-entry
manifest:media-type="application/vnd.sun.star.configuration-data"
manifest:full-path="registry/data/org/openoffice/Office/ProtocolHandler.xcu"/>
+ <manifest:file-entry manifest:full-path="dialogLibrary/"
+
manifest:media-type="application/vnd.sun.star.basic-library"/>
<manifest:file-entry
manifest:media-type="application/vnd.sun.star.configuration-data"
manifest:full-path="registry/data/org/openoffice/Office/Addons.xcu"/>
</manifest:manifest>
Added: sandbox/gsoc/xoo/src/main/oxt/dialogLibrary/Login.xdl
===================================================================
--- sandbox/gsoc/xoo/src/main/oxt/dialogLibrary/Login.xdl (rev
0)
+++ sandbox/gsoc/xoo/src/main/oxt/dialogLibrary/Login.xdl 2009-05-31 07:54:20 UTC (rev
20663)
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!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="Login"
dlg:left="101" dlg:top="52" dlg:width="143"
dlg:height="108" dlg:closeable="true" dlg:moveable="true"
dlg:title="Connection Settings">
+ <dlg:bulletinboard>
+ <dlg:button dlg:id="btnOK" dlg:tab-index="0"
dlg:left="26" dlg:top="86" dlg:width="37"
dlg:height="16" dlg:value="OK">
+ <script:event script:event-name="on-performaction"
script:macro-name="vnd.sun.star.UNO:btnOK_Clicked"
script:language="UNO"/>
+ </dlg:button>
+ <dlg:button dlg:id="btnCancel" dlg:tab-index="2"
dlg:left="102" dlg:top="86" dlg:width="37"
dlg:height="16" dlg:value="Cancel">
+ <script:event script:event-name="on-performaction"
script:macro-name="vnd.sun.star.UNO:btnCancel_Clicked"
script:language="UNO"/>
+ </dlg:button>
+ <dlg:text dlg:id="lblURL" dlg:tab-index="3"
dlg:left="5" dlg:top="25" dlg:width="34"
dlg:height="10" dlg:value="Server URL"/>
+ <dlg:text dlg:id="lblUser" dlg:tab-index="4"
dlg:left="5" dlg:top="43" dlg:width="34"
dlg:height="10" dlg:value="Username"/>
+ <dlg:text dlg:id="lblPass" dlg:tab-index="8"
dlg:left="5" dlg:top="61" dlg:width="34"
dlg:height="10" dlg:value="Password"/>
+ <dlg:titledbox dlg:id="FrameControl2" dlg:tab-index="9"
dlg:left="-1" dlg:top="29" dlg:width="1"
dlg:height="6">
+ <dlg:title dlg:value="FrameControl2"/>
+ </dlg:titledbox>
+ <dlg:titledbox dlg:id="frmSettings" dlg:tab-index="10"
dlg:left="3" dlg:top="5" dlg:width="137"
dlg:height="75">
+ <dlg:title dlg:value="Server settings"/>
+ </dlg:titledbox>
+ <dlg:textfield dlg:id="txtServerURL" dlg:tab-index="5"
dlg:left="54" dlg:top="25" dlg:width="82"
dlg:height="10" dlg:value="http://localhost:8080"/>
+ <dlg:textfield dlg:id="txtUsername" dlg:tab-index="6"
dlg:left="54" dlg:top="43" dlg:width="82"
dlg:height="10"/>
+ <dlg:button dlg:id="btnApply" dlg:tab-index="1"
dlg:left="64" dlg:top="86" dlg:width="37"
dlg:height="16" dlg:value="Apply">
+ <script:event script:event-name="on-itemstatechange"
script:macro-name="vnd.sun.star.UNO:btnCancel_Clicked"
script:language="UNO"/>
+ </dlg:button>
+ <dlg:textfield dlg:id="txtPassword" dlg:tab-index="7"
dlg:left="54" dlg:top="61" dlg:width="82"
dlg:height="10" dlg:echochar="*"/>
+ </dlg:bulletinboard>
+</dlg:window>
\ No newline at end of file
Added: sandbox/gsoc/xoo/src/main/oxt/dialogLibrary/Module1.xba
===================================================================
--- sandbox/gsoc/xoo/src/main/oxt/dialogLibrary/Module1.xba (rev
0)
+++ sandbox/gsoc/xoo/src/main/oxt/dialogLibrary/Module1.xba 2009-05-31 07:54:20 UTC (rev
20663)
@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE script:module PUBLIC "-//OpenOffice.org//DTD OfficeDocument
1.0//EN" "module.dtd">
+<script:module
xmlns:script="http://openoffice.org/2000/script"
script:name="Module1" script:language="StarBasic">REM ***** BASIC
*****
+
+Sub Main
+
+
+
+ oDialog = createUnoDialog(DialogLibraries.dialogLibrary.Login)
+ oDialog.execute
+
+
+End Sub
+</script:module>
\ No newline at end of file
Added: sandbox/gsoc/xoo/src/main/oxt/dialogLibrary/dialog.xlb
===================================================================
--- sandbox/gsoc/xoo/src/main/oxt/dialogLibrary/dialog.xlb (rev
0)
+++ sandbox/gsoc/xoo/src/main/oxt/dialogLibrary/dialog.xlb 2009-05-31 07:54:20 UTC (rev
20663)
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE library:library PUBLIC "-//OpenOffice.org//DTD OfficeDocument
1.0//EN" "library.dtd">
+<library:library
xmlns:library="http://openoffice.org/2000/library"
library:name="dialogLibrary" library:readonly="false"
library:passwordprotected="false">
+ <library:element library:name="Login"/>
+</library:library>
\ No newline at end of file
Added: sandbox/gsoc/xoo/src/main/oxt/dialogLibrary/script.xlb
===================================================================
--- sandbox/gsoc/xoo/src/main/oxt/dialogLibrary/script.xlb (rev
0)
+++ sandbox/gsoc/xoo/src/main/oxt/dialogLibrary/script.xlb 2009-05-31 07:54:20 UTC (rev
20663)
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE library:library PUBLIC "-//OpenOffice.org//DTD OfficeDocument
1.0//EN" "library.dtd">
+<library:library
xmlns:library="http://openoffice.org/2000/library"
library:name="dialogLibrary" library:readonly="false"
library:passwordprotected="false">
+ <library:element library:name="Module1"/>
+</library:library>
\ No newline at end of file
_______________________________________________
notifications mailing list
notifications(a)xwiki.org
http://lists.xwiki.org/mailman/listinfo/notifications