// Initialise the out paramters - not used but prevents error in
// UNO bridge
aOutParamIndex[0] = new short[0];
aOutParam[0] = new Object[0];
Any result = new Any(new Type(Boolean.class), Boolean.TRUE);
if (aFunctionName.equals("Creatable"))
{
try
{
String newName;
if (aParams == null || aParams.length < 1 ||
AnyConverter.isString(aParams[0]) == false)
{
String prompt = "Enter name for new Script";
String title = "Create Script";
// try to get a DialogFactory instance, if it fails
// just use a Swing JOptionPane to prompt for the name
try
{
DialogFactory dialogFactory =
DialogFactory.getDialogFactory();
newName = dialogFactory.showInputDialog(title, prompt);
}
catch (Exception e)
{
newName = JOptionPane.showInputDialog(null, prompt, title,
JOptionPane.QUESTION_MESSAGE);
}
}
else {
newName = (String) AnyConverter.toString(aParams[0]);
}
if ( newName == null || newName.equals(""))
{
result = new Any(new Type(Boolean.class), Boolean.FALSE);
}
else
{
String source = new String(provider.getScriptEditor().getTemplate().getBytes());
String languageName = newName + "." + provider.getScriptEditor().getExtension();
String language = container.getLanguage();
ScriptEntry entry = new ScriptEntry( language, languageName, languageName, "", new HashMap() );
Parcel parcel = (Parcel)container.getByName( getName() );
ScriptMetaData data = new ScriptMetaData( parcel, entry, source );
parcel.insertByName( languageName, data );
ScriptBrowseNode sbn = new ScriptBrowseNode( provider, parcel, languageName );
if(browsenodes==null)
{
LogUtils.DEBUG("browsenodes null!!");
browsenodes = new ArrayList(4);
}
browsenodes.add(sbn);
result = new Any(new Type(XBrowseNode.class), sbn);
}
}
catch (Exception e)
{
LogUtils.DEBUG("ParcelBrowseNode[create] failed with: " + e );
LogUtils.DEBUG( LogUtils.getTrace( e ) );
result = new Any(new Type(Boolean.class), Boolean.FALSE);
// throw new com.sun.star.reflection.InvocationTargetException(
// "Error creating script: " + e.getMessage());
}
}
else if (aFunctionName.equals("Deletable"))
{
try
{
if ( container.deleteParcel(getName()) )
{
result = new Any(new Type(Boolean.class), Boolean.TRUE);
}
else
{
result = new Any(new Type(Boolean.class), Boolean.FALSE);
}
}
catch (Exception e)
{
result = new Any(new Type(Boolean.class), Boolean.FALSE);
// throw new com.sun.star.reflection.InvocationTargetException(
// "Error deleting parcel: " + e.getMessage());
}
}
else if (aFunctionName.equals("Renamable"))
{
String newName = null;
try
{
if (aParams == null || aParams.length < 1 ||
AnyConverter.isString(aParams[0]) == false)
{
String prompt = "Enter new name for Library";
String title = "Rename Library";
// try to get a DialogFactory instance, if it fails
// just use a Swing JOptionPane to prompt for the name
try
{
DialogFactory dialogFactory =
DialogFactory.getDialogFactory();
newName = dialogFactory.showInputDialog(title, prompt);
}
catch (Exception e)
{
newName = JOptionPane.showInputDialog(null, prompt, title,
JOptionPane.QUESTION_MESSAGE);
}
}
else {
newName = (String) AnyConverter.toString(aParams[0]);
}
container.renameParcel( getName(), newName );
Parcel p = (Parcel)container.getByName( newName );
if(browsenodes == null )
{
getChildNodes();
}
ScriptBrowseNode[] childNodes = (ScriptBrowseNode[])browsenodes.toArray(new ScriptBrowseNode[0]);
for ( int index = 0; index < childNodes.length; index++ )
{
childNodes[ index ].updateURI( p );
}
result = new Any(new Type(XBrowseNode.class), this);
}
catch (Exception e)
{
result = new Any(new Type(Boolean.class), Boolean.FALSE);
// throw new com.sun.star.reflection.InvocationTargetException(
// "Error renaming parcel: " + e.getMessage());
}
}