Re: [dev] Options dialog in the extension

2009-01-05 Thread Joachim Lingner

Karthik Sudarshan wrote:

Hi all,

  I've downloaded the sample OptionsPageDemo Netbeans project and I've 
been able to successfully install the add-on and I also see the Options 
dialog. But when I create my own add-on and want to add an Options page 
I don't see it! There are no errors while installing my add-on, but the 
options button (in the Extension manager) is not enabled, which suggests 
that the Options dialog functionality is not present for my add-on.


  I'm attaching my OptionsDialog.xcu file, and my EventHandler java file 
(which doesn't do much really), along with the .xdl file I've created 
for the testing purposes, with a simple server url, username and 
password fields. The EventHandler is appropriately placed in the 
com.example package and the DLDialog.xdl file is in the dialogs 
directory and it is present in the dialogs directory at the root of the 
final .oxt file created, i.e., all the files are at the appropriate 
places they are supposed to be.


  Can someone please help me with this? I don't know what exactly I'm 
doing wrong here.


Regards,
Karthik





Make sure that the Id of the leaf has is the extensions identifier. See 
also the schema in 
officecfg/registry/schema/org/openoffice/Office/OptionsDialog.xcs



...
  prop oor:name=Id oor:type=xs:string
info
  descThe unique identifier of the Leaf. This must be the extension
identifier if this Leaf was defined by an extension./desc
/info
  /prop



The first part is wrong. An extension may define several leaves, which 
must all have the extension identifyer set as property Id. The only use 
of this property is that the Extension Manager can determine that for a 
given extension exist on or more leaves. Only then it will enable the 
options button.



Hope that helps,
Joachim



-
To unsubscribe, e-mail: dev-unsubscr...@openoffice.org
For additional commands, e-mail: dev-h...@openoffice.org



-
To unsubscribe, e-mail: dev-unsubscr...@openoffice.org
For additional commands, e-mail: dev-h...@openoffice.org



[dev] Options dialog in the extension

2008-12-24 Thread Karthik Sudarshan

Hi all,

  I've downloaded the sample OptionsPageDemo Netbeans project and I've 
been able to successfully install the add-on and I also see the Options 
dialog. But when I create my own add-on and want to add an Options page 
I don't see it! There are no errors while installing my add-on, but the 
options button (in the Extension manager) is not enabled, which suggests 
that the Options dialog functionality is not present for my add-on.


  I'm attaching my OptionsDialog.xcu file, and my EventHandler java 
file (which doesn't do much really), along with the .xdl file I've 
created for the testing purposes, with a simple server url, username and 
password fields. The EventHandler is appropriately placed in the 
com.example package and the DLDialog.xdl file is in the dialogs 
directory and it is present in the dialogs directory at the root of the 
final .oxt file created, i.e., all the files are at the appropriate 
places they are supposed to be.


  Can someone please help me with this? I don't know what exactly I'm 
doing wrong here.


Regards,
Karthik


?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=DocumentLibraryConfig dlg:left=221 dlg:top=98 dlg:width=201 dlg:height=164 dlg:closeable=true dlg:moveable=true
 dlg:styles
  dlg:style dlg:style-id=0 dlg:text-color=0xff dlg:font-name=Verdana dlg:font-height=10 dlg:font-stylename=Regular dlg:font-family=swiss/
 /dlg:styles
 dlg:bulletinboard
  dlg:text dlg:style-id=0 dlg:id=label1 dlg:tab-index=0 dlg:left=14 dlg:top=19 dlg:width=72 dlg:height=12 dlg:value=Configuration Details/
  dlg:text dlg:id=Label1 dlg:tab-index=2 dlg:left=12 dlg:top=58 dlg:width=29 dlg:height=9 dlg:value=Server URL/
  dlg:textfield dlg:id=serverURL dlg:tab-index=1 dlg:left=47 dlg:top=54 dlg:width=126 dlg:height=14 dlg:value=http://localhost:8080/
  dlg:fixedline dlg:id=FixedLine1 dlg:tab-index=4 dlg:left=86 dlg:top=24 dlg:width=99 dlg:height=2/
  dlg:text dlg:id=Label3 dlg:tab-index=3 dlg:left=12 dlg:top=78 dlg:width=29 dlg:height=9 dlg:value=Username/
  dlg:textfield dlg:id=emailId dlg:tab-index=5 dlg:left=47 dlg:top=74 dlg:width=126 dlg:height=14 dlg:value=t...@example.com/
  dlg:text dlg:id=Label4 dlg:tab-index=6 dlg:left=12 dlg:top=96 dlg:width=29 dlg:height=9 dlg:value=Password/
  dlg:textfield dlg:id=password dlg:tab-index=7 dlg:left=47 dlg:top=92 dlg:width=126 dlg:height=14 dlg:value=test dlg:echochar=*/
  dlg:fixedline dlg:id=FixedLine2 dlg:tab-index=8 dlg:left=185 dlg:top=24 dlg:width=4 dlg:height=102 dlg:align=vertical/
  dlg:fixedline dlg:id=FixedLine3 dlg:tab-index=9 dlg:left=8 dlg:top=124 dlg:width=181 dlg:height=2/
  dlg:fixedline dlg:id=FixedLine4 dlg:tab-index=10 dlg:left=6 dlg:top=24 dlg:width=2 dlg:height=100 dlg:align=vertical/
  dlg:fixedline dlg:id=FixedLine5 dlg:tab-index=11 dlg:left=6 dlg:top=24 dlg:width=8 dlg:height=2/
 /dlg:bulletinboard
/dlg:window
?xml version=1.0 encoding=UTF-8?

oor:component-data oor:name=OptionsDialog oor:package=com.example
  xmlns:oor=http://openoffice.org/2001/registry;
  xmlns:xs=http://www.w2.org/2001/XMLSchema;
  xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance;
node oor:name=Nodes
  node oor:name=Writer oor:op=fuse
node oor:name=Leaves
node oor:name=com.example.leaf oor:op=fuse
prop oor:name=Id
  valuecom.example.leaf/value
/prop
prop oor:name=Label
  value xml:lang=en-USDemo Options/value
/prop
prop oor:name=OptionsPage
  value%origin%/dialogs/DLDialog.xdl/value
/prop
prop oor:name=EventHandlerService
  valuecom.example.EventHandler/value
/prop
/node
  /node
  /node
/node
/oor:component-data
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.example;

import com.sun.star.awt.XContainerWindowEventHandler;
import com.sun.star.lang.WrappedTargetException;
import com.sun.star.uno.AnyConverter;
import javax.swing.JFrame;
import javax.swing.JOptionPane;

/**
 *
 * @author Karthik
 */
public class EventHandler implements XContainerWindowEventHandler {

public boolean callHandlerMethod(com.sun.star.awt.XWindow aWindow,
Object aEventObject, String sMethod)
throws WrappedTargetException {
if (sMethod.equals(external_event)) {
try {
return handleExternalEvent(aWindow, 
aEventObject);
} catch (com.sun.star.uno.RuntimeException re) {
throw re;
} catch (com.sun.star.uno.Exception e) {
throw new WrappedTargetException(sMethod, this, 
e);
}
} else if 

Re: [dev] Options dialog in the extension

2008-12-24 Thread Oliver Brinzing
Hi,

   Can someone please help me with this? I don't know what exactly I'm
 doing wrong here.

are you sure that your com.example.EventHandler class is an uno service ?

from the dialog demo:

public static class _DialogEventHandler extends WeakBase
   implements XServiceInfo, XContainerWindowEventHandler

BTW: i cannot find any namespace declarations in your *.xdl and *.xcu files

Oliver

-- 

GnuPG key 0xCFD04A45: 8822 057F 4956 46D3 352C 1A06 4E2C AB40 CFD0 4A45



signature.asc
Description: OpenPGP digital signature


Re: [dev] Options dialog in the extension

2008-12-24 Thread Karthik Sudarshan

Hi Oliver,
   Thanks for the reply. The handler was not a uno service. I added the 
inner class which was present in the Dialog demo to the class, but still 
it is not working :(


I'm attaching the new Event handler to the mail.

I didn't get you when you said namespaces in *.xdl and *.xcu files. The 
xmlns is defined in the beginning of the files. Am I supposed to add 
anything more? The name and the package should be project specific from 
what I read, so I've put those values.


Any help would be great.

-Karthik

PS : I'm really stuck with this, as I've an entire extension working but 
my configuration dialog is part of a menu. Since OpenOffice suggests 
Tools-Options as the correct place to put any configuration related 
information, I'm trying this out. If this dummy project works then I can 
put my real configuration data in the extension project and continue.



Oliver Brinzing wrote:

Hi,

  

  Can someone please help me with this? I don't know what exactly I'm
doing wrong here.



are you sure that your com.example.EventHandler class is an uno service ?

from the dialog demo:

  

public static class _DialogEventHandler extends WeakBase
  implements XServiceInfo, XContainerWindowEventHandler



BTW: i cannot find any namespace declarations in your *.xdl and *.xcu files

Oliver

  


/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.example;

import com.sun.star.awt.XContainerWindowEventHandler;
import com.sun.star.awt.XControl;
import com.sun.star.awt.XControlModel;
import com.sun.star.beans.XPropertySet;
import com.sun.star.container.XNameAccess;
import com.sun.star.lang.WrappedTargetException;
import com.sun.star.lang.XServiceInfo;
import com.sun.star.lib.uno.helper.WeakBase;
import com.sun.star.uno.AnyConverter;
import com.sun.star.uno.UnoRuntime;
import com.sun.star.uno.XComponentContext;
import java.awt.Component;
import javax.swing.JFrame;
import javax.swing.JOptionPane;

/**
 *
 * @author Karthik
 */
public class EventHandler {

 public static class _DialogEventHandler extends WeakBase
implements XServiceInfo, XContainerWindowEventHandler
  {
/**
 * Names of supported options pages. The name derives from the
 * actual file names of the .xdl files not a XML attribute.
 */
public static String[] SupportedWindowNames = {DLDialog};

static private final String __serviceName = com.example.EventHandler;

private XComponentContext context;
private Component frame = new JFrame();

public _DialogEventHandler(XComponentContext xCompContext)
{
  this.context = xCompContext;
}

/**
 * This method returns an array of all supported service names.
 * @return Array of supported service names.
 */
public String[] getSupportedServiceNames()
{
  return getServiceNames();
}

/**
 * This method is a simple helper function to used in the
 * static component initialisation functions as well as in
 * getSupportedServiceNames.
 */
public static String[] getServiceNames()
{
  String[] sSupportedServiceNames = { __serviceName };
  return sSupportedServiceNames;
}

/** This method returns true, if the given service will be
  * supported by the component.
  * @param sServiceName Service name.
  * @return True, if the given service name will be supported.
  */
public boolean supportsService( String sServiceName )
{
  return sServiceName.equals( __serviceName );
}

/**
 * Return the class name of the component.
 * @return Class name of the component.
 */
public String getImplementationName()
{
  return _DialogEventHandler.class.getName();
}

/**
 * Is called by the OOo event system.
 * @param aWindow
 * @param aEventObject
 * @param sMethod
 * @return
 * @throws com.sun.star.lang.WrappedTargetException
 */
public boolean callHandlerMethod(com.sun.star.awt.XWindow aWindow, Object 
aEventObject, String sMethod)
  throws WrappedTargetException
{

  if (sMethod.equals(external_event) )
  {
try
{
  return handleExternalEvent(aWindow, aEventObject);
}
catch (com.sun.star.uno.RuntimeException re)
{
  throw re;
}
catch (com.sun.star.uno.Exception e)
{
  e.printStackTrace();
  throw new WrappedTargetException(sMethod, this, e);
}
  }

  // return false when event was not handled
  return false;
}

/**
 * @return A String array containing the method names supported by this 
handler.
 */
public String[] getSupportedMethodNames()
{
  return new String[] {external_event};
}

private boolean handleExternalEvent(com.sun.star.awt.XWindow aWindow, 
Object aEventObject)
throws com.sun.star.uno.Exception {
try {