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]);