diff options
author | Rüdiger Timm <rt@openoffice.org> | 2004-05-19 07:20:19 +0000 |
---|---|---|
committer | Rüdiger Timm <rt@openoffice.org> | 2004-05-19 07:20:19 +0000 |
commit | 1dc2f1519bd3d00363442b4bbf7495377d6bd370 (patch) | |
tree | 20891c569d21d76f7b7102d4eb1f6c90982cbb5a /scripting | |
parent | f167316afe16999bf0c4a658b63b8900583e5648 (diff) |
INTEGRATION: CWS scriptingf4 (1.9.4); FILE MERGED
2004/05/11 09:19:07 dfoster 1.9.4.6: #i26923#
Fixed renaming of scripts/parcels.
Issue number:
Submitted by:
Reviewed by:
2004/05/07 17:18:25 npower 1.9.4.5: #i28818#
Changes to support Scripting context created from the ScriptProvider, not created in BrowseNodes any more. Behavior of the ScriptContext class has been changed so that for and application script ( e.g. user or share ) the getDocument() method will rerturn the currently selected document. If it is a document script then the getDocument() method will return the document for the location of the script.
2004/05/07 10:01:15 dfoster 1.9.4.4: #i26923#
Issue number: #i26923#
Submitted by:
Reviewed by:
2004/05/06 13:47:01 npower 1.9.4.3: #i28818# Using EditorScriptContext when invoking IDE, this will ensure that the getDocument() method will always return the currently selected OO document which the script can act on
Issue number:
Submitted by:
Reviewed by:
2004/04/30 10:54:02 dfoster 1.9.4.2: #i26923#
Issue number:
Submitted by:
Reviewed by:
2004/04/29 14:09:20 dfoster 1.9.4.1: #i28384# - implement Macro Selector specification
Issue number:
Submitted by:
Reviewed by:
Diffstat (limited to 'scripting')
-rw-r--r-- | scripting/java/com/sun/star/script/framework/browse/ScriptBrowseNode.java | 93 |
1 files changed, 80 insertions, 13 deletions
diff --git a/scripting/java/com/sun/star/script/framework/browse/ScriptBrowseNode.java b/scripting/java/com/sun/star/script/framework/browse/ScriptBrowseNode.java index 951b17d56162..e8ea517119e3 100644 --- a/scripting/java/com/sun/star/script/framework/browse/ScriptBrowseNode.java +++ b/scripting/java/com/sun/star/script/framework/browse/ScriptBrowseNode.java @@ -2,9 +2,9 @@ * * $RCSfile: ScriptBrowseNode.java,v $ * - * $Revision: 1.9 $ + * $Revision: 1.10 $ * - * last change: $Author: svesik $ $Date: 2004-04-19 23:03:18 $ + * last change: $Author: rt $ $Date: 2004-05-19 08:20:19 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -91,8 +91,10 @@ public class ScriptBrowseNode extends PropertySet private Parcel parent; private String name; public String uri; + public String description; public boolean editable = false; public boolean deletable = false; + public boolean renamable = false; public ScriptBrowseNode( ScriptProvider provider, Parcel parent, String name ) @@ -111,19 +113,27 @@ public class ScriptBrowseNode extends PropertySet { LogUtils.DEBUG("** caught exception getting script data for " + name + " ->" + e.toString() ); } + uri = data.getShortFormScriptURL(); + description = data.getDescription(); + if (provider.hasScriptEditor() == true) { this.editable = true; this.deletable = true; + this.renamable = true; } registerProperty("Deletable", new Type(boolean.class), (short)0, "deletable"); registerProperty("Editable", new Type(boolean.class), (short)0, "editable"); + registerProperty("Renamable", new Type(boolean.class), + (short)0, "renamable"); registerProperty("URI", new Type(String.class), (short)0, "uri"); + registerProperty("DESCRIPTION", new Type(String.class), + (short)0, "description"); } @@ -147,6 +157,22 @@ public class ScriptBrowseNode extends PropertySet return getName(); } + public void updateURI( Parcel p ) { + parent = p; + ScriptMetaData data = null; + try + { + data = (ScriptMetaData)parent.getByName( name ); + } + + // TODO fix exception types to be caught here, should we rethrow? + catch ( Exception e ) + { + LogUtils.DEBUG("** caught exception getting script data for " + name + " ->" + e.toString() ); + } + uri = data.getShortFormScriptURL(); + } + // implementation of XInvocation interface public XIntrospectionAccess getIntrospection() { return null; @@ -173,15 +199,8 @@ public class ScriptBrowseNode extends PropertySet "Script not editable"); } - if (aParams == null || aParams.length < 1 || - AnyConverter.isObject(aParams[0]) == false) - { - throw new com.sun.star.lang.IllegalArgumentException( - "XScriptContext not provided"); - } - XScriptContext ctxt = (XScriptContext) AnyConverter.toObject( - new com.sun.star.uno.Type(XScriptContext.class), aParams[0]); + XScriptContext ctxt = provider.getScriptingContext(); ScriptMetaData data = null; try { @@ -207,8 +226,9 @@ public class ScriptBrowseNode extends PropertySet try { - boolean goAhead = false; + boolean goAhead = true; + /* prompting in svx/source/dialogs/scriptdlg.cxx String prompt = "Do you really want to delete this Script?"; String title = "Delete Script"; @@ -234,11 +254,10 @@ public class ScriptBrowseNode extends PropertySet { goAhead = false; } - } + } */ if (goAhead == true) { - parent.removeByName( name ); result = new Any(new Type(Boolean.class), Boolean.TRUE); } @@ -250,6 +269,54 @@ public class ScriptBrowseNode extends PropertySet // TODO Exception handling TBD catch (Exception e) { + LogUtils.DEBUG("** caught exception removing " + name + " ->" + e.toString() ); + result = new Any(new Type(Boolean.class), Boolean.FALSE); + + // throw new com.sun.star.reflection.InvocationTargetException( + // "Error deleting script: " + e.getMessage()); + } + } + else if (aFunctionName.equals("Renamable")) + { + if (!renamable) + { + throw new com.sun.star.reflection.InvocationTargetException( + "Script not renamable"); + } + + + try + { + boolean goAhead = true; + + if (goAhead == true) + { + String newName = (String) AnyConverter.toString(aParams[0]); + ScriptMetaData oldData = (ScriptMetaData)parent.getByName( name ); + String oldSource = oldData.getSource(); + LogUtils.DEBUG("remove old script"); + parent.removeByName( name ); + LogUtils.DEBUG("now create renamed script"); + String languageName = newName + "." + provider.getScriptEditor().getExtension(); + String language = provider.getName(); + + ScriptEntry entry = new ScriptEntry( language, languageName, languageName, "", new HashMap() ); + + ScriptMetaData data = new ScriptMetaData( parent, entry, oldSource ); + parent.insertByName( languageName, data ); + uri = data.getShortFormScriptURL(); + name = languageName; + result = new Any(new Type(XBrowseNode.class), this); + } + else + { + result = new Any(new Type(Boolean.class), Boolean.FALSE); + } + } + // TODO Exception handling TBD + catch (Exception e) + { + LogUtils.DEBUG("** caught exception removing " + name + " ->" + e.toString() ); result = new Any(new Type(Boolean.class), Boolean.FALSE); // throw new com.sun.star.reflection.InvocationTargetException( |