summaryrefslogtreecommitdiff
path: root/scripting
diff options
context:
space:
mode:
authorRobert Antoni Buj i Gelonch <robert.buj@gmail.com>2014-09-25 19:41:12 +0200
committerDavid Tardon <dtardon@redhat.com>2014-10-02 15:25:29 +0200
commit6f42a714399f4d0c46dad95c7c11bcd513c27eaa (patch)
treeb5ea97f0171124e8232fe909e86ac0a087e8a3d0 /scripting
parent36d24bced0ea5fcbbd380b15e9d1a813fbef32cf (diff)
scripting: Format_java_code.sh initial run
Conflicts: scripting/java/com/sun/star/script/framework/io/UCBStreamHandler.java Change-Id: I09b94d8c96dfbaf498bd93a0088feb80a9e4afb6
Diffstat (limited to 'scripting')
-rw-r--r--scripting/examples/java/HelloWorld/HelloWorld.java16
-rw-r--r--scripting/examples/java/Highlight/HighlightText.java89
-rw-r--r--scripting/examples/java/MemoryUsage/MemoryUsage.java55
-rw-r--r--scripting/examples/java/Newsgroup/MimeConfiguration.java170
-rw-r--r--scripting/examples/java/Newsgroup/NewsGroup.java12
-rw-r--r--scripting/examples/java/Newsgroup/OfficeAttachment.java228
-rw-r--r--scripting/examples/java/Newsgroup/PostNewsgroup.java560
-rw-r--r--scripting/examples/java/Newsgroup/Sender.java96
-rw-r--r--scripting/examples/java/Newsgroup/StatusWindow.java128
-rw-r--r--scripting/examples/java/Newsgroup/SubscribedNewsgroups.java267
-rw-r--r--scripting/examples/java/debugger/DebugRunner.java24
-rw-r--r--scripting/examples/java/debugger/OOBeanShellDebugger.java71
-rw-r--r--scripting/examples/java/debugger/OORhinoDebugger.java40
-rw-r--r--scripting/examples/java/selector/ScriptSelector.java242
-rw-r--r--scripting/java/Framework/com/sun/star/script/framework/security/SecurityDialog.java460
-rw-r--r--scripting/java/com/sun/star/script/framework/browse/DialogFactory.java135
-rw-r--r--scripting/java/com/sun/star/script/framework/browse/ParcelBrowseNode.java215
-rw-r--r--scripting/java/com/sun/star/script/framework/browse/PkgProviderBrowseNode.java19
-rw-r--r--scripting/java/com/sun/star/script/framework/browse/ProviderBrowseNode.java154
-rw-r--r--scripting/java/com/sun/star/script/framework/browse/ScriptBrowseNode.java187
-rw-r--r--scripting/java/com/sun/star/script/framework/container/DeployedUnoPackagesDB.java99
-rw-r--r--scripting/java/com/sun/star/script/framework/container/Parcel.java265
-rw-r--r--scripting/java/com/sun/star/script/framework/container/ParcelContainer.java616
-rw-r--r--scripting/java/com/sun/star/script/framework/container/ParcelDescriptor.java87
-rw-r--r--scripting/java/com/sun/star/script/framework/container/ParsedScriptUri.java3
-rw-r--r--scripting/java/com/sun/star/script/framework/container/ScriptEntry.java29
-rw-r--r--scripting/java/com/sun/star/script/framework/container/ScriptMetaData.java317
-rw-r--r--scripting/java/com/sun/star/script/framework/container/UnoPkgContainer.java418
-rw-r--r--scripting/java/com/sun/star/script/framework/container/XMLParserFactory.java40
-rw-r--r--scripting/java/com/sun/star/script/framework/io/UCBStreamHandler.java143
-rw-r--r--scripting/java/com/sun/star/script/framework/io/XInputStreamImpl.java78
-rw-r--r--scripting/java/com/sun/star/script/framework/io/XInputStreamWrapper.java38
-rw-r--r--scripting/java/com/sun/star/script/framework/io/XOutputStreamWrapper.java156
-rw-r--r--scripting/java/com/sun/star/script/framework/io/XStorageHelper.java207
-rw-r--r--scripting/java/com/sun/star/script/framework/log/LogUtils.java44
-rw-r--r--scripting/java/com/sun/star/script/framework/provider/ClassLoaderFactory.java23
-rw-r--r--scripting/java/com/sun/star/script/framework/provider/EditorScriptContext.java28
-rw-r--r--scripting/java/com/sun/star/script/framework/provider/NoSuitableClassLoaderException.java9
-rw-r--r--scripting/java/com/sun/star/script/framework/provider/PathUtils.java59
-rw-r--r--scripting/java/com/sun/star/script/framework/provider/ScriptContext.java68
-rw-r--r--scripting/java/com/sun/star/script/framework/provider/ScriptEditor.java5
-rw-r--r--scripting/java/com/sun/star/script/framework/provider/ScriptProvider.java549
-rw-r--r--scripting/java/com/sun/star/script/framework/provider/SwingInvocation.java6
-rw-r--r--scripting/java/com/sun/star/script/framework/provider/beanshell/PlainSourceView.java15
-rw-r--r--scripting/java/com/sun/star/script/framework/provider/beanshell/ScriptEditorForBeanShell.java179
-rw-r--r--scripting/java/com/sun/star/script/framework/provider/beanshell/ScriptProviderForBeanShell.java442
-rw-r--r--scripting/java/com/sun/star/script/framework/provider/beanshell/ScriptSourceModel.java96
-rw-r--r--scripting/java/com/sun/star/script/framework/provider/java/Resolver.java2
-rw-r--r--scripting/java/com/sun/star/script/framework/provider/java/ScriptDescriptor.java85
-rw-r--r--scripting/java/com/sun/star/script/framework/provider/java/ScriptProviderForJava.java417
-rw-r--r--scripting/java/com/sun/star/script/framework/provider/java/ScriptProxy.java16
-rw-r--r--scripting/java/com/sun/star/script/framework/provider/java/StrictResolver.java72
-rw-r--r--scripting/java/com/sun/star/script/framework/provider/javascript/ScriptEditorForJavaScript.java154
-rw-r--r--scripting/java/com/sun/star/script/framework/provider/javascript/ScriptProviderForJavaScript.java417
-rw-r--r--scripting/java/org/openoffice/idesupport/CommandLineTools.java92
-rw-r--r--scripting/java/org/openoffice/idesupport/ExtensionFinder.java7
-rw-r--r--scripting/java/org/openoffice/idesupport/JavaFinder.java71
-rw-r--r--scripting/java/org/openoffice/idesupport/LocalOffice.java12
-rw-r--r--scripting/java/org/openoffice/idesupport/OfficeDocument.java38
-rw-r--r--scripting/java/org/openoffice/idesupport/OfficeInstallation.java3
-rw-r--r--scripting/java/org/openoffice/idesupport/SVersionRCFile.java63
-rw-r--r--scripting/java/org/openoffice/idesupport/filter/BinaryOnlyFilter.java1
-rw-r--r--scripting/java/org/openoffice/idesupport/filter/ExceptParcelFilter.java4
-rw-r--r--scripting/java/org/openoffice/idesupport/localoffice/LocalOfficeImpl.java52
-rw-r--r--scripting/java/org/openoffice/idesupport/ui/ConfigurePanel.java43
-rw-r--r--scripting/java/org/openoffice/idesupport/ui/ScriptPanel.java10
-rw-r--r--scripting/java/org/openoffice/idesupport/xml/Manifest.java17
-rw-r--r--scripting/java/org/openoffice/idesupport/zip/ParcelZipper.java41
-rw-r--r--scripting/java/org/openoffice/netbeans/editor/JavaKit.java21
-rw-r--r--scripting/java/org/openoffice/netbeans/editor/NetBeansSourceView.java31
-rw-r--r--scripting/java/org/openoffice/netbeans/modules/office/actions/BuildParcelAction.java2
-rw-r--r--scripting/java/org/openoffice/netbeans/modules/office/actions/ConfigureParcelAction.java6
-rw-r--r--scripting/java/org/openoffice/netbeans/modules/office/actions/DeployParcelAction.java33
-rw-r--r--scripting/java/org/openoffice/netbeans/modules/office/actions/MountDocumentAction.java34
-rw-r--r--scripting/java/org/openoffice/netbeans/modules/office/actions/MountParcelAction.java34
-rw-r--r--scripting/java/org/openoffice/netbeans/modules/office/actions/OfficeDocumentCookie.java3
-rw-r--r--scripting/java/org/openoffice/netbeans/modules/office/actions/OfficeDocumentSupport.java25
-rw-r--r--scripting/java/org/openoffice/netbeans/modules/office/actions/ParcelCookie.java3
-rw-r--r--scripting/java/org/openoffice/netbeans/modules/office/actions/ParcelDescriptorEditorSupport.java14
-rw-r--r--scripting/java/org/openoffice/netbeans/modules/office/actions/ParcelDescriptorParserCookie.java3
-rw-r--r--scripting/java/org/openoffice/netbeans/modules/office/actions/ParcelDescriptorParserSupport.java23
-rw-r--r--scripting/java/org/openoffice/netbeans/modules/office/actions/ParcelFolderCookie.java3
-rw-r--r--scripting/java/org/openoffice/netbeans/modules/office/actions/ParcelFolderSupport.java76
-rw-r--r--scripting/java/org/openoffice/netbeans/modules/office/actions/ParcelSupport.java56
-rw-r--r--scripting/java/org/openoffice/netbeans/modules/office/filesystem/OpenOfficeDocFileSystem.java546
-rw-r--r--scripting/java/org/openoffice/netbeans/modules/office/filesystem/OpenOfficeDocFileSystemBeanInfo.java44
-rw-r--r--scripting/java/org/openoffice/netbeans/modules/office/loader/OfficeDocumentDataLoader.java33
-rw-r--r--scripting/java/org/openoffice/netbeans/modules/office/loader/OfficeDocumentDataNode.java15
-rw-r--r--scripting/java/org/openoffice/netbeans/modules/office/loader/OfficeDocumentDataObject.java3
-rw-r--r--scripting/java/org/openoffice/netbeans/modules/office/loader/ParcelContentsFolder.java36
-rw-r--r--scripting/java/org/openoffice/netbeans/modules/office/loader/ParcelContentsFolderDataLoader.java15
-rw-r--r--scripting/java/org/openoffice/netbeans/modules/office/loader/ParcelDataLoader.java23
-rw-r--r--scripting/java/org/openoffice/netbeans/modules/office/loader/ParcelDataNode.java10
-rw-r--r--scripting/java/org/openoffice/netbeans/modules/office/loader/ParcelDataObject.java3
-rw-r--r--scripting/java/org/openoffice/netbeans/modules/office/loader/ParcelDescriptorDataLoader.java25
-rw-r--r--scripting/java/org/openoffice/netbeans/modules/office/loader/ParcelDescriptorDataObject.java5
-rw-r--r--scripting/java/org/openoffice/netbeans/modules/office/loader/ParcelFolder.java208
-rw-r--r--scripting/java/org/openoffice/netbeans/modules/office/loader/ParcelFolderDataLoader.java35
-rw-r--r--scripting/java/org/openoffice/netbeans/modules/office/nodes/OfficeDocumentChildren.java14
-rw-r--r--scripting/java/org/openoffice/netbeans/modules/office/nodes/ParcelDescriptorChildren.java5
-rw-r--r--scripting/java/org/openoffice/netbeans/modules/office/nodes/ScriptNode.java15
-rw-r--r--scripting/java/org/openoffice/netbeans/modules/office/options/OfficeSettings.java3
-rw-r--r--scripting/java/org/openoffice/netbeans/modules/office/options/OfficeSettingsBeanInfo.java57
-rw-r--r--scripting/java/org/openoffice/netbeans/modules/office/utils/FrameworkJarChecker.java48
-rw-r--r--scripting/java/org/openoffice/netbeans/modules/office/utils/ManifestParser.java10
-rw-r--r--scripting/java/org/openoffice/netbeans/modules/office/utils/NagDialog.java22
-rw-r--r--scripting/java/org/openoffice/netbeans/modules/office/utils/OfficeModule.java11
-rw-r--r--scripting/java/org/openoffice/netbeans/modules/office/utils/PackageRemover.java17
-rw-r--r--scripting/java/org/openoffice/netbeans/modules/office/utils/ZipMounter.java24
-rw-r--r--scripting/java/org/openoffice/netbeans/modules/office/wizard/InstallationPathDescriptor.java3
-rw-r--r--scripting/java/org/openoffice/netbeans/modules/office/wizard/InstallationPathIterator.java14
-rw-r--r--scripting/java/org/openoffice/netbeans/modules/office/wizard/JavaScriptIterator.java37
-rw-r--r--scripting/java/org/openoffice/netbeans/modules/office/wizard/ParcelContentsIterator.java25
-rw-r--r--scripting/java/org/openoffice/netbeans/modules/office/wizard/ParcelPropertiesPanel.java1
-rw-r--r--scripting/java/org/openoffice/netbeans/modules/office/wizard/ParcelPropertiesVisualPanel.java17
-rw-r--r--scripting/java/org/openoffice/netbeans/modules/office/wizard/SelectPathPanel.java10
-rw-r--r--scripting/java/org/openoffice/netbeans/modules/office/wizard/SelectPathVisualPanel.java21
-rw-r--r--scripting/workben/ifc/scripting/ScriptingUtils.java17
-rw-r--r--scripting/workben/ifc/scripting/SecurityDialogUtil.java188
-rw-r--r--scripting/workben/ifc/scripting/_XFunction.java29
-rw-r--r--scripting/workben/ifc/scripting/_XFunctionProvider.java3
-rw-r--r--scripting/workben/ifc/scripting/_XScriptInfo.java32
-rw-r--r--scripting/workben/ifc/scripting/_XScriptInfoAccess.java51
-rw-r--r--scripting/workben/ifc/scripting/_XScriptInvocation.java48
-rw-r--r--scripting/workben/ifc/scripting/_XScriptNameResolver.java32
-rw-r--r--scripting/workben/ifc/scripting/_XScriptSecurity.java285
-rw-r--r--scripting/workben/ifc/scripting/_XScriptStorageManager.java33
-rw-r--r--scripting/workben/ifc/scripting/_XScriptStorageRefresh.java5
-rw-r--r--scripting/workben/installer/Banner.java15
-rw-r--r--scripting/workben/installer/ExceptionTraceHelper.java35
-rw-r--r--scripting/workben/installer/ExecCmd.java149
-rw-r--r--scripting/workben/installer/FileUpdater.java219
-rw-r--r--scripting/workben/installer/Final.java82
-rw-r--r--scripting/workben/installer/IdeFinal.java64
-rw-r--r--scripting/workben/installer/IdeUpdater.java77
-rw-r--r--scripting/workben/installer/IdeVersion.java147
-rw-r--r--scripting/workben/installer/IdeWelcome.java16
-rw-r--r--scripting/workben/installer/InstUtil.java248
-rw-r--r--scripting/workben/installer/InstallListener.java3
-rw-r--r--scripting/workben/installer/InstallWizard.java235
-rw-r--r--scripting/workben/installer/InstallationEvent.java12
-rw-r--r--scripting/workben/installer/LogStream.java44
-rw-r--r--scripting/workben/installer/NavPanel.java29
-rw-r--r--scripting/workben/installer/Register.java83
-rw-r--r--scripting/workben/installer/Version.java122
-rw-r--r--scripting/workben/installer/Welcome.java25
-rw-r--r--scripting/workben/installer/XmlUpdater.java238
-rw-r--r--scripting/workben/installer/ZipData.java19
-rw-r--r--scripting/workben/mod/_scripting/Dispatch.java35
-rw-r--r--scripting/workben/mod/_scripting/Function.java27
-rw-r--r--scripting/workben/mod/_scripting/FunctionProvider.java21
-rw-r--r--scripting/workben/mod/_scripting/ScriptInfo.java56
-rw-r--r--scripting/workben/mod/_scripting/ScriptRuntimeManager.java12
-rw-r--r--scripting/workben/mod/_scripting/ScriptStorage.java50
-rw-r--r--scripting/workben/mod/_scripting/ScriptStorageManager.java26
-rw-r--r--scripting/workben/mod/_scripting/TestDataLoader.java11
156 files changed, 6399 insertions, 6950 deletions
diff --git a/scripting/examples/java/HelloWorld/HelloWorld.java b/scripting/examples/java/HelloWorld/HelloWorld.java
index 3f117a28e8c9..1c960da3244b 100644
--- a/scripting/examples/java/HelloWorld/HelloWorld.java
+++ b/scripting/examples/java/HelloWorld/HelloWorld.java
@@ -28,15 +28,15 @@ import com.sun.star.text.XText;
*
*/
public class HelloWorld {
- public static void printHW(XScriptContext xSc) {
+ public static void printHW(XScriptContext xSc) {
- // getting the text document object
- XTextDocument xtextdocument = (XTextDocument) UnoRuntime.queryInterface(
-XTextDocument.class, xSc.getDocument());
- XText xText = xtextdocument.getText();
- XTextRange xTextRange = xText.getEnd();
- xTextRange.setString( "Hello World (in Java)" );
+ // getting the text document object
+ XTextDocument xtextdocument = (XTextDocument) UnoRuntime.queryInterface(
+ XTextDocument.class, xSc.getDocument());
+ XText xText = xtextdocument.getText();
+ XTextRange xTextRange = xText.getEnd();
+ xTextRange.setString("Hello World (in Java)");
- }// printHW
+ }// printHW
}
diff --git a/scripting/examples/java/Highlight/HighlightText.java b/scripting/examples/java/Highlight/HighlightText.java
index 46c6f738f1bf..f39ccbfa22bf 100644
--- a/scripting/examples/java/Highlight/HighlightText.java
+++ b/scripting/examples/java/Highlight/HighlightText.java
@@ -54,65 +54,63 @@ public class HighlightText implements com.sun.star.awt.XActionListener {
args[0] = context.getDocument();
Object obj;
+
try {
obj = xmcf.createInstanceWithArgumentsAndContext(
- "com.sun.star.awt.DialogProvider", args,
- context.getComponentContext());
- }
- catch (com.sun.star.uno.Exception e) {
+ "com.sun.star.awt.DialogProvider", args,
+ context.getComponentContext());
+ } catch (com.sun.star.uno.Exception e) {
System.err.println("Error getting DialogProvider object");
return;
}
XDialogProvider xDialogProvider = (XDialogProvider)
- UnoRuntime.queryInterface(XDialogProvider.class, obj);
+ UnoRuntime.queryInterface(XDialogProvider.class, obj);
System.err.println("Got DialogProvider, now get dialog");
try {
findDialog = xDialogProvider.createDialog(
- "vnd.sun.star.script:" +
- "ScriptBindingLibrary.Highlight?location=application");
- }
- catch (java.lang.Exception e) {
+ "vnd.sun.star.script:" +
+ "ScriptBindingLibrary.Highlight?location=application");
+ } catch (java.lang.Exception e) {
System.err.println("Got exception on first creating dialog: " +
- e.getMessage());
+ e.getMessage());
}
if (findDialog == null) {
if (!tryLoadingLibrary(xmcf, context, "Dialog") ||
- !tryLoadingLibrary(xmcf, context, "Script"))
- {
+ !tryLoadingLibrary(xmcf, context, "Script")) {
System.err.println("Error loading ScriptBindingLibrary");
return;
}
+
try {
findDialog = xDialogProvider.createDialog(
- "vnd.sun.star.script://" +
- "ScriptBindingLibrary.Highlight?location=application");
- }
- catch (com.sun.star.lang.IllegalArgumentException iae) {
+ "vnd.sun.star.script://" +
+ "ScriptBindingLibrary.Highlight?location=application");
+ } catch (com.sun.star.lang.IllegalArgumentException iae) {
System.err.println("Error loading ScriptBindingLibrary");
return;
}
}
XControlContainer controls = (XControlContainer)
- UnoRuntime.queryInterface(XControlContainer.class, findDialog);
+ UnoRuntime.queryInterface(XControlContainer.class, findDialog);
XButton highlightButton = (XButton) UnoRuntime.queryInterface(
- XButton.class, controls.getControl("HighlightButton"));
+ XButton.class, controls.getControl("HighlightButton"));
highlightButton.setActionCommand("Highlight");
findTextBox = (XTextComponent) UnoRuntime.queryInterface(
- XTextComponent.class, controls.getControl("HighlightTextField"));
+ XTextComponent.class, controls.getControl("HighlightTextField"));
XButton exitButton = (XButton) UnoRuntime.queryInterface(
- XButton.class, controls.getControl("ExitButton"));
+ XButton.class, controls.getControl("ExitButton"));
exitButton.setActionCommand("Exit");
theDocument = (XTextDocument) UnoRuntime.queryInterface(
- XTextDocument.class, context.getDocument());
+ XTextDocument.class, context.getDocument());
highlightButton.addActionListener(this);
exitButton.addActionListener(this);
@@ -124,8 +122,7 @@ public class HighlightText implements com.sun.star.awt.XActionListener {
if (e.ActionCommand.equals("Exit")) {
findDialog.endExecute();
return;
- }
- else if (e.ActionCommand.equals("Highlight")) {
+ } else if (e.ActionCommand.equals("Highlight")) {
searchKey = findTextBox.getText();
// highlight the text in red
@@ -133,7 +130,7 @@ public class HighlightText implements com.sun.star.awt.XActionListener {
int red = cRed.getRGB();
XReplaceable replaceable = (XReplaceable)
- UnoRuntime.queryInterface(XReplaceable.class, theDocument);
+ UnoRuntime.queryInterface(XReplaceable.class, theDocument);
XReplaceDescriptor descriptor =
(XReplaceDescriptor) replaceable.createReplaceDescriptor();
@@ -141,17 +138,17 @@ public class HighlightText implements com.sun.star.awt.XActionListener {
// Gets a XPropertyReplace object for altering the properties
// of the replaced text
XPropertyReplace xPropertyReplace = (XPropertyReplace)
- UnoRuntime.queryInterface(XPropertyReplace.class, descriptor);
+ UnoRuntime.queryInterface(XPropertyReplace.class, descriptor);
// Sets the replaced text property fontweight value to Bold
PropertyValue wv = new PropertyValue("CharWeight", -1,
- new Float(com.sun.star.awt.FontWeight.BOLD),
- com.sun.star.beans.PropertyState.DIRECT_VALUE);
+ new Float(com.sun.star.awt.FontWeight.BOLD),
+ com.sun.star.beans.PropertyState.DIRECT_VALUE);
// Sets the replaced text property color value to RGB parameter
PropertyValue cv = new PropertyValue("CharColor", -1,
- Integer.valueOf(red),
- com.sun.star.beans.PropertyState.DIRECT_VALUE);
+ Integer.valueOf(red),
+ com.sun.star.beans.PropertyState.DIRECT_VALUE);
// Apply the properties
PropertyValue[] props = new PropertyValue[] { cv, wv };
@@ -163,20 +160,16 @@ public class HighlightText implements com.sun.star.awt.XActionListener {
descriptor.setPropertyValue(
"SearchCaseSensitive", Boolean.TRUE);
descriptor.setPropertyValue("SearchWords", Boolean.TRUE);
- }
- catch (com.sun.star.beans.UnknownPropertyException upe) {
+ } catch (com.sun.star.beans.UnknownPropertyException upe) {
System.err.println("Error setting up search properties");
return;
- }
- catch (com.sun.star.beans.PropertyVetoException pve) {
+ } catch (com.sun.star.beans.PropertyVetoException pve) {
System.err.println("Error setting up search properties");
return;
- }
- catch (com.sun.star.lang.WrappedTargetException wte) {
+ } catch (com.sun.star.lang.WrappedTargetException wte) {
System.err.println("Error setting up search properties");
return;
- }
- catch (com.sun.star.lang.IllegalArgumentException iae) {
+ } catch (com.sun.star.lang.IllegalArgumentException iae) {
System.err.println("Error setting up search properties");
return;
}
@@ -189,40 +182,39 @@ public class HighlightText implements com.sun.star.awt.XActionListener {
}
}
- public void disposing(EventObject o)
- {
+ public void disposing(EventObject o) {
// do nothing
}
private boolean tryLoadingLibrary(
- XMultiComponentFactory xmcf, XScriptContext context, String name)
- {
+ XMultiComponentFactory xmcf, XScriptContext context, String name) {
System.err.println("Try to load ScriptBindingLibrary");
try {
Object obj = xmcf.createInstanceWithContext(
- "com.sun.star.script.Application" + name + "LibraryContainer",
- context.getComponentContext());
+ "com.sun.star.script.Application" + name + "LibraryContainer",
+ context.getComponentContext());
XLibraryContainer xLibraryContainer = (XLibraryContainer)
- UnoRuntime.queryInterface(XLibraryContainer.class, obj);
+ UnoRuntime.queryInterface(XLibraryContainer.class, obj);
System.err.println("Got XLibraryContainer");
Object serviceObj = context.getComponentContext().getValueByName(
- "/singletons/com.sun.star.util.theMacroExpander");
+ "/singletons/com.sun.star.util.theMacroExpander");
XMacroExpander xme = (XMacroExpander) AnyConverter.toObject(
- new Type(XMacroExpander.class), serviceObj);
+ new Type(XMacroExpander.class), serviceObj);
String bootstrapName = "bootstraprc";
+
if (System.getProperty("os.name").startsWith("Windows")) {
bootstrapName = "bootstrap.ini";
}
String libURL = xme.expandMacros(
- "$BRAND_BASE_DIR/$BRAND_SHARE_SUBDIR/basic/ScriptBindingLibrary/" +
- name.toLowerCase() + ".xlb/");
+ "$BRAND_BASE_DIR/$BRAND_SHARE_SUBDIR/basic/ScriptBindingLibrary/" +
+ name.toLowerCase() + ".xlb/");
System.err.println("libURL is: " + libURL);
@@ -235,6 +227,7 @@ public class HighlightText implements com.sun.star.awt.XActionListener {
System.err.println("Got an exception loading lib: " + e.getMessage());
return false;
}
+
return true;
}
}
diff --git a/scripting/examples/java/MemoryUsage/MemoryUsage.java b/scripting/examples/java/MemoryUsage/MemoryUsage.java
index 63a643e90621..a01d2baceff8 100644
--- a/scripting/examples/java/MemoryUsage/MemoryUsage.java
+++ b/scripting/examples/java/MemoryUsage/MemoryUsage.java
@@ -39,11 +39,9 @@ import com.sun.star.sheet.*;
import com.sun.star.script.provider.XScriptContext;
-public class MemoryUsage
-{
+public class MemoryUsage {
public void updateMemoryUsage(XScriptContext ctxt)
- throws Exception
- {
+ throws Exception {
XSpreadsheet sheet = createSpreadsheet(ctxt);
Runtime runtime = Runtime.getRuntime();
@@ -55,37 +53,35 @@ public class MemoryUsage
byte[] bytes = new byte[len];
addData(sheet, date.toString(),
- runtime.totalMemory(), runtime.freeMemory());
+ runtime.totalMemory(), runtime.freeMemory());
addChart(sheet);
}
private XSpreadsheet createSpreadsheet(XScriptContext ctxt)
- throws Exception
- {
+ throws Exception {
XComponentLoader loader = (XComponentLoader)
- UnoRuntime.queryInterface(
- XComponentLoader.class, ctxt.getDesktop());
+ UnoRuntime.queryInterface(
+ XComponentLoader.class, ctxt.getDesktop());
XComponent comp = loader.loadComponentFromURL(
- "private:factory/scalc", "_blank", 4, new PropertyValue[0]);
+ "private:factory/scalc", "_blank", 4, new PropertyValue[0]);
XSpreadsheetDocument doc = (XSpreadsheetDocument)
- UnoRuntime.queryInterface(XSpreadsheetDocument.class, comp);
+ UnoRuntime.queryInterface(XSpreadsheetDocument.class, comp);
XIndexAccess index = (XIndexAccess)
- UnoRuntime.queryInterface(XIndexAccess.class, doc.getSheets());
+ UnoRuntime.queryInterface(XIndexAccess.class, doc.getSheets());
XSpreadsheet sheet = (XSpreadsheet) AnyConverter.toObject(
- new Type(com.sun.star.sheet.XSpreadsheet.class), index.getByIndex(0));
+ new Type(com.sun.star.sheet.XSpreadsheet.class), index.getByIndex(0));
return sheet;
}
private void addData(
XSpreadsheet sheet, String date, long total, long free)
- throws Exception
- {
+ throws Exception {
sheet.getCellByPosition(0, 0).setFormula("Used");
sheet.getCellByPosition(0, 1).setFormula("Free");
sheet.getCellByPosition(0, 2).setFormula("Total");
@@ -96,8 +92,7 @@ public class MemoryUsage
}
private void addChart(XSpreadsheet sheet)
- throws Exception
- {
+ throws Exception {
Rectangle rect = new Rectangle();
rect.X = 500;
rect.Y = 3000;
@@ -105,13 +100,13 @@ public class MemoryUsage
rect.Height = 8000;
XCellRange range = (XCellRange)
- UnoRuntime.queryInterface(XCellRange.class, sheet);
+ UnoRuntime.queryInterface(XCellRange.class, sheet);
XCellRange myRange =
range.getCellRangeByName("A1:B2");
XCellRangeAddressable rangeAddr = (XCellRangeAddressable)
- UnoRuntime.queryInterface(XCellRangeAddressable.class, myRange);
+ UnoRuntime.queryInterface(XCellRangeAddressable.class, myRange);
CellRangeAddress myAddr = rangeAddr.getRangeAddress();
@@ -119,42 +114,44 @@ public class MemoryUsage
addr[0] = myAddr;
XTableChartsSupplier supp = (XTableChartsSupplier)
- UnoRuntime.queryInterface( XTableChartsSupplier.class, sheet);
+ UnoRuntime.queryInterface(XTableChartsSupplier.class, sheet);
XTableCharts charts = supp.getCharts();
charts.addNewByName("Example", rect, addr, false, true);
- try { Thread.sleep(3000); } catch (InterruptedException e) { }
+ try {
+ Thread.sleep(3000);
+ } catch (InterruptedException e) { }
// get the diagram and Change some of the properties
XNameAccess chartsAccess = (XNameAccess)
- UnoRuntime.queryInterface( XNameAccess.class, charts);
+ UnoRuntime.queryInterface(XNameAccess.class, charts);
XTableChart tchart = (XTableChart)
- UnoRuntime.queryInterface(
- XTableChart.class, chartsAccess.getByName("Example"));
+ UnoRuntime.queryInterface(
+ XTableChart.class, chartsAccess.getByName("Example"));
XEmbeddedObjectSupplier eos = (XEmbeddedObjectSupplier)
- UnoRuntime.queryInterface( XEmbeddedObjectSupplier.class, tchart );
+ UnoRuntime.queryInterface(XEmbeddedObjectSupplier.class, tchart);
XInterface xifc = eos.getEmbeddedObject();
XChartDocument xChart = (XChartDocument)
- UnoRuntime.queryInterface(XChartDocument.class, xifc);
+ UnoRuntime.queryInterface(XChartDocument.class, xifc);
XMultiServiceFactory xDocMSF = (XMultiServiceFactory)
- UnoRuntime.queryInterface(XMultiServiceFactory.class, xChart);
+ UnoRuntime.queryInterface(XMultiServiceFactory.class, xChart);
Object diagObject =
xDocMSF.createInstance("com.sun.star.chart.PieDiagram");
XDiagram xDiagram = (XDiagram)
- UnoRuntime.queryInterface(XDiagram.class, diagObject);
+ UnoRuntime.queryInterface(XDiagram.class, diagObject);
xChart.setDiagram(xDiagram);
XPropertySet propset = (XPropertySet)
- UnoRuntime.queryInterface( XPropertySet.class, xChart.getTitle() );
+ UnoRuntime.queryInterface(XPropertySet.class, xChart.getTitle());
propset.setPropertyValue("String", "JVM Memory Usage");
}
}
diff --git a/scripting/examples/java/Newsgroup/MimeConfiguration.java b/scripting/examples/java/Newsgroup/MimeConfiguration.java
index 03e6c1b03116..03b964834384 100644
--- a/scripting/examples/java/Newsgroup/MimeConfiguration.java
+++ b/scripting/examples/java/Newsgroup/MimeConfiguration.java
@@ -30,33 +30,29 @@ import javax.activation.*;
import java.io.*;
-public class MimeConfiguration
-{
+public class MimeConfiguration {
// Office Installation path
private static String instPath = "";
- public static boolean createFiles( XScriptContext xsc )
- {
- try
- {
+ public static boolean createFiles(XScriptContext xsc) {
+ try {
XComponentContext xcc = xsc.getComponentContext();
XMultiComponentFactory xmf = xcc.getServiceManager();
- Object pathSub = xmf.createInstanceWithContext( "com.sun.star.comp.framework.PathSubstitution", xcc );
- XStringSubstitution stringSub = ( XStringSubstitution ) UnoRuntime.queryInterface( XStringSubstitution.class, pathSub );
- instPath = stringSub.getSubstituteVariableValue( "$(inst)" );
+ Object pathSub =
+ xmf.createInstanceWithContext("com.sun.star.comp.framework.PathSubstitution",
+ xcc);
+ XStringSubstitution stringSub = (XStringSubstitution) UnoRuntime.queryInterface(
+ XStringSubstitution.class, pathSub);
+ instPath = stringSub.getSubstituteVariableValue("$(inst)");
- }
- catch( com.sun.star.beans.UnknownPropertyException upe )
- {
- System.out.println( "com.sun.star.beans.UnknownPropertyException" );
+ } catch (com.sun.star.beans.UnknownPropertyException upe) {
+ System.out.println("com.sun.star.beans.UnknownPropertyException");
upe.printStackTrace();
- }
- catch( com.sun.star.uno.Exception e )
- {
- System.out.println( "com.sun.star.uno.Exception" );
+ } catch (com.sun.star.uno.Exception e) {
+ System.out.println("com.sun.star.uno.Exception");
e.printStackTrace();
}
@@ -70,46 +66,38 @@ public class MimeConfiguration
- private static void writeMailCap()
- {
- String mailcapPath = getConfigDir() + System.getProperty( "file.separator" ) + "mailcap";
+ private static void writeMailCap() {
+ String mailcapPath = getConfigDir() + System.getProperty("file.separator") +
+ "mailcap";
- try
- {
- if( ! new File( java.net.URLDecoder.decode( mailcapPath ) ).exists() )
- {
- File mailcapFile = new File( mailcapPath );
- FileWriter out = new FileWriter( mailcapFile );
+ try {
+ if (! new File(java.net.URLDecoder.decode(mailcapPath)).exists()) {
+ File mailcapFile = new File(mailcapPath);
+ FileWriter out = new FileWriter(mailcapFile);
String[] lines = getMailcapText();
- for( int i=0; i<lines.length; i++ )
- {
- out.write( lines[i], 0, lines[i].length() );
+
+ for (int i = 0; i < lines.length; i++) {
+ out.write(lines[i], 0, lines[i].length());
}
+
out.close();
- }
- else
- {
- }
+ } else {
+ }
// use prog dir, if not there then java.io to create/write new file
- MailcapCommandMap map = new MailcapCommandMap( mailcapPath );
- CommandMap.setDefaultCommandMap ( map );
- }
- catch( IOException ioe )
- {
+ MailcapCommandMap map = new MailcapCommandMap(mailcapPath);
+ CommandMap.setDefaultCommandMap(map);
+ } catch (IOException ioe) {
ioe.printStackTrace();
- }
- catch( Exception e )
- {
+ } catch (Exception e) {
e.printStackTrace();
}
}
- private static String[] getMailcapText()
- {
+ private static String[] getMailcapText() {
String[] mailcapText = {
"#\n",
"# Default mailcap file for the JavaMail System.\n",
@@ -130,43 +118,35 @@ public class MimeConfiguration
- private static void writeMimeTypes()
- {
- String mimetypesPath = getConfigDir() + System.getProperty( "file.separator" ) + "mimetypes.default";
+ private static void writeMimeTypes() {
+ String mimetypesPath = getConfigDir() + System.getProperty("file.separator") +
+ "mimetypes.default";
- try
- {
- if( ! new File( java.net.URLDecoder.decode( mimetypesPath ) ).exists() )
- {
- File mimetypesFile = new File( mimetypesPath );
- FileWriter out = new FileWriter( mimetypesFile );
+ try {
+ if (! new File(java.net.URLDecoder.decode(mimetypesPath)).exists()) {
+ File mimetypesFile = new File(mimetypesPath);
+ FileWriter out = new FileWriter(mimetypesFile);
String[] lines = getMimeTypesText();
- for( int i=0; i<lines.length; i++ )
- {
- out.write( lines[i], 0, lines[i].length() );
+
+ for (int i = 0; i < lines.length; i++) {
+ out.write(lines[i], 0, lines[i].length());
}
+
out.close();
- }
- else
- {
- }
+ } else {
+ }
- MimetypesFileTypeMap mimeTypes = new MimetypesFileTypeMap( mimetypesPath );
- FileTypeMap.setDefaultFileTypeMap( mimeTypes );
- }
- catch( IOException ioe )
- {
+ MimetypesFileTypeMap mimeTypes = new MimetypesFileTypeMap(mimetypesPath);
+ FileTypeMap.setDefaultFileTypeMap(mimeTypes);
+ } catch (IOException ioe) {
ioe.printStackTrace();
- }
- catch( Exception e )
- {
+ } catch (Exception e) {
e.printStackTrace();
}
}
- private static String[] getMimeTypesText()
- {
+ private static String[] getMimeTypesText() {
String[] mimesText = {
"#\n",
"# A simple, old format, mime.types file\n",
@@ -198,36 +178,32 @@ public class MimeConfiguration
}
- private static String getConfigDir()
- {
+ private static String getConfigDir() {
// mailcap file must be written to the Office user/config directory
- // instPath is a URL, needs to be converted to a system pathname
- String config = instPath + "/user/config";
- String configNonURL = "";
-
- if( System.getProperty( "os.name" ).indexOf( "Windows" ) != -1 )
- {
- // Windows
- // removes "file:///"
- int start = 8;
- configNonURL = config.substring( start, config.length() );
- // Convert forward to back-slashes
- while( configNonURL.indexOf( "/" ) != -1 )
- {
- int fSlash = configNonURL.indexOf( "/" );
- String firstPart = configNonURL.substring( 0, fSlash );
- String secondPart = configNonURL.substring( fSlash + 1, configNonURL.length() );
- configNonURL = firstPart + "\\" + secondPart;
- }
- }
- else
- {
- // Unix/Linux
- // removes "file://"
- int start = 7;
- configNonURL = config.substring( start, config.length() );
- }
+ // instPath is a URL, needs to be converted to a system pathname
+ String config = instPath + "/user/config";
+ String configNonURL = "";
+
+ if (System.getProperty("os.name").indexOf("Windows") != -1) {
+ // Windows
+ // removes "file:///"
+ int start = 8;
+ configNonURL = config.substring(start, config.length());
+
+ // Convert forward to back-slashes
+ while (configNonURL.indexOf("/") != -1) {
+ int fSlash = configNonURL.indexOf("/");
+ String firstPart = configNonURL.substring(0, fSlash);
+ String secondPart = configNonURL.substring(fSlash + 1, configNonURL.length());
+ configNonURL = firstPart + "\\" + secondPart;
+ }
+ } else {
+ // Unix/Linux
+ // removes "file://"
+ int start = 7;
+ configNonURL = config.substring(start, config.length());
+ }
return configNonURL;
}
diff --git a/scripting/examples/java/Newsgroup/NewsGroup.java b/scripting/examples/java/Newsgroup/NewsGroup.java
index 6042dbe084de..4c1708a059c5 100644
--- a/scripting/examples/java/Newsgroup/NewsGroup.java
+++ b/scripting/examples/java/Newsgroup/NewsGroup.java
@@ -18,25 +18,21 @@
package org.libreoffice.example.java_scripts;
-public class NewsGroup
-{
+public class NewsGroup {
private String hostname = "";
private String newsgroupName = "";
- public NewsGroup( String host, String group )
- {
+ public NewsGroup(String host, String group) {
hostname = host;
newsgroupName = group;
}
- public String getHostName()
- {
+ public String getHostName() {
return hostname;
}
- public String getNewsgroupName()
- {
+ public String getNewsgroupName() {
return newsgroupName;
}
diff --git a/scripting/examples/java/Newsgroup/OfficeAttachment.java b/scripting/examples/java/Newsgroup/OfficeAttachment.java
index 8a008ae18ea8..75c0f4d458c8 100644
--- a/scripting/examples/java/Newsgroup/OfficeAttachment.java
+++ b/scripting/examples/java/Newsgroup/OfficeAttachment.java
@@ -31,8 +31,7 @@ import com.sun.star.script.framework.runtime.XScriptContext;
// for debug only
import javax.swing.JOptionPane;
-public class OfficeAttachment
-{
+public class OfficeAttachment {
private StatusWindow status = null;
private XStorable storedDoc = null;
@@ -45,137 +44,124 @@ public class OfficeAttachment
private String attachmentName = "";
private String statusLine = "";
- public OfficeAttachment( XScriptContext xsc, StatusWindow sw, boolean html, boolean office )
- {
+ public OfficeAttachment(XScriptContext xsc, StatusWindow sw, boolean html,
+ boolean office) {
status = sw;
isHtmlDoc = html;
isOfficeDoc = office;
- templocationSystem = templocationURL = System.getProperty( "user.home" );
- if( System.getProperty( "os.name" ).indexOf( "Windows" ) != -1 )
- {
- while( templocationURL.indexOf( "\\" ) != -1 )
- {
- int sepPos = templocationURL.indexOf( "\\" );
- String firstPart = templocationURL.substring( 0, sepPos );
- String lastPart = templocationURL.substring( sepPos + 1, templocationURL.length() );
+ templocationSystem = templocationURL = System.getProperty("user.home");
+
+ if (System.getProperty("os.name").indexOf("Windows") != -1) {
+ while (templocationURL.indexOf("\\") != -1) {
+ int sepPos = templocationURL.indexOf("\\");
+ String firstPart = templocationURL.substring(0, sepPos);
+ String lastPart = templocationURL.substring(sepPos + 1,
+ templocationURL.length());
templocationURL = firstPart + "/" + lastPart;
}
}
- try
- {
+ try {
statusLine = "Querying Office for current document";
- status.setStatus( 1, statusLine );
+ status.setStatus(1, statusLine);
XScriptContext scriptcontext = xsc;
XModel xmodel = scriptcontext.getDocument();
storedDoc = (XStorable) UnoRuntime.queryInterface(XStorable.class, xmodel);
// find document name from storedDoc
attachmentName = storedDoc.getLocation();
- }
- catch( Exception e )
- {
+ } catch (Exception e) {
//UNO error
- status.setStatus( 1, "Error: " + statusLine );
+ status.setStatus(1, "Error: " + statusLine);
}
- if( attachmentName.equalsIgnoreCase( "" ) )
- {
+ if (attachmentName.equalsIgnoreCase("")) {
attachmentName = "Attachment";
- }
- else
- {
- int lastSep = attachmentName.lastIndexOf( "/" );
- attachmentName = attachmentName.substring( lastSep + 1, attachmentName.length() );
- int dot = attachmentName.indexOf( "." );
- attachmentName = attachmentName.substring( 0, dot );
+ } else {
+ int lastSep = attachmentName.lastIndexOf("/");
+ attachmentName = attachmentName.substring(lastSep + 1, attachmentName.length());
+ int dot = attachmentName.indexOf(".");
+ attachmentName = attachmentName.substring(0, dot);
}
}
- public boolean createTempDocs()
- {
+ public boolean createTempDocs() {
String filenameURL = "file:///" + templocationURL + "/" + attachmentName;
- try
- {
- if( isHtmlDoc )
- {
+
+ try {
+ if (isHtmlDoc) {
statusLine = "Saving doc in HTML format";
- status.setStatus( 4, statusLine );
- PropertyValue[] propertyvalue_html = new PropertyValue[2];
- propertyvalue_html[0] = new PropertyValue();
- propertyvalue_html[0].Name = "Overwrite";
- propertyvalue_html[0].Value = Boolean.TRUE;
- propertyvalue_html[1] = new PropertyValue();
- propertyvalue_html[1].Name = ("FilterName");
- propertyvalue_html[1].Value = "swriter: HTML (StarWriter)";
- storedDoc.storeAsURL( filenameURL + ".html", propertyvalue_html);
-
- File homedir = new File( templocationSystem );
+ status.setStatus(4, statusLine);
+ PropertyValue[] propertyvalue_html = new PropertyValue[2];
+ propertyvalue_html[0] = new PropertyValue();
+ propertyvalue_html[0].Name = "Overwrite";
+ propertyvalue_html[0].Value = Boolean.TRUE;
+ propertyvalue_html[1] = new PropertyValue();
+ propertyvalue_html[1].Name = ("FilterName");
+ propertyvalue_html[1].Value = "swriter: HTML (StarWriter)";
+ storedDoc.storeAsURL(filenameURL + ".html", propertyvalue_html);
+
+ File homedir = new File(templocationSystem);
File homefiles[] = homedir.listFiles();
String file = "";
- for(int i=0; i < homefiles.length; i++ )
- {
- if( homefiles[i].getName().equals( attachmentName + ".html" ) )
- {
+
+ for (int i = 0; i < homefiles.length; i++) {
+ if (homefiles[i].getName().equals(attachmentName + ".html")) {
file = homefiles[i].getAbsolutePath();
}
}
- htmlFile = new File( file );
+
+ htmlFile = new File(file);
}
- if( isOfficeDoc )
- {
+ if (isOfficeDoc) {
statusLine = "Saving doc in .sxw format";
- status.setStatus( 4, statusLine );
+ status.setStatus(4, statusLine);
PropertyValue[] propertyvalue_sxw = new PropertyValue[2];
- propertyvalue_sxw[0] = new PropertyValue();
- propertyvalue_sxw[0].Name = "Overwrite";
- propertyvalue_sxw[0].Value = Boolean.TRUE;
- propertyvalue_sxw[1] = new PropertyValue();
- propertyvalue_sxw[1].Name = "Overwrite";
- propertyvalue_sxw[1].Value = Boolean.TRUE;
- storedDoc.storeAsURL( filenameURL + ".sxw", propertyvalue_sxw);
+ propertyvalue_sxw[0] = new PropertyValue();
+ propertyvalue_sxw[0].Name = "Overwrite";
+ propertyvalue_sxw[0].Value = Boolean.TRUE;
+ propertyvalue_sxw[1] = new PropertyValue();
+ propertyvalue_sxw[1].Name = "Overwrite";
+ propertyvalue_sxw[1].Value = Boolean.TRUE;
+ storedDoc.storeAsURL(filenameURL + ".sxw", propertyvalue_sxw);
- File homedir = new File( templocationSystem );
+ File homedir = new File(templocationSystem);
- File homefiles[] = homedir.listFiles();
+ File homefiles[] = homedir.listFiles();
String file = "";
- for(int i=0; i < homefiles.length; i++ )
- {
- if( homefiles[i].getName().equals( attachmentName + ".sxw" ) )
- {
+
+ for (int i = 0; i < homefiles.length; i++) {
+ if (homefiles[i].getName().equals(attachmentName + ".sxw")) {
file = homefiles[i].getAbsolutePath();
- }
- }
- officeFile = new File( file );
+ }
+ }
+
+ officeFile = new File(file);
}
- }
- catch( SecurityException se )
- {
- status.setStatus( 4, "Error: " + statusLine );
- System.out.println( "Security error while saving temporary Document(s). Check file permissions in home directory." );
+ } catch (SecurityException se) {
+ status.setStatus(4, "Error: " + statusLine);
+ System.out.println("Security error while saving temporary Document(s). Check file permissions in home directory.");
se.printStackTrace();
htmlFile = null;
officeFile = null;
return false;
- }
- catch( Exception e )
- {
- status.setStatus( 4, "Error: " + statusLine );
- System.out.println( "Error saving temporary Document(s)" );
+ } catch (Exception e) {
+ status.setStatus(4, "Error: " + statusLine);
+ System.out.println("Error saving temporary Document(s)");
e.printStackTrace();
htmlFile = null;
officeFile = null;
return false;
}
+
return true;
}
- public boolean removeTempDocs()
- {
+ public boolean removeTempDocs() {
/*
if( !htmlFile.exists() && !officeFile.exists() )
{
@@ -184,89 +170,65 @@ public class OfficeAttachment
*/
statusLine = "Removing temp docs";
- status.setStatus( 13, statusLine );
+ status.setStatus(13, statusLine);
- try
- {
- if( isOfficeDoc && isHtmlDoc )
- {
+ try {
+ if (isOfficeDoc && isHtmlDoc) {
htmlFile.delete();
officeFile.delete();
- }
- else
- {
- if( isOfficeDoc )
- {
+ } else {
+ if (isOfficeDoc) {
officeFile.delete();
- }
- else
- {
+ } else {
htmlFile.delete();
}
}
- }
- catch( SecurityException se )
- {
- status.setStatus( 13, "Error: " + statusLine );
- System.out.println( "Security Error while deleting temporary Document(s). Check file permissions in home directory." );
+ } catch (SecurityException se) {
+ status.setStatus(13, "Error: " + statusLine);
+ System.out.println("Security Error while deleting temporary Document(s). Check file permissions in home directory.");
se.printStackTrace();
return false;
}
+
return true;
}
- public void cleanUpOnError()
- {
- try
- {
- if( isOfficeDoc && isHtmlDoc )
- {
+ public void cleanUpOnError() {
+ try {
+ if (isOfficeDoc && isHtmlDoc) {
htmlFile.delete();
officeFile.delete();
- }
- else
- {
- if( isOfficeDoc )
- {
+ } else {
+ if (isOfficeDoc) {
officeFile.delete();
- }
- else
- {
+ } else {
htmlFile.delete();
}
}
- }
- catch( SecurityException se )
- {
- System.out.println( "Security Error while deleting temporary Document(s). Check file permissions in home directory." );
+ } catch (SecurityException se) {
+ System.out.println("Security Error while deleting temporary Document(s). Check file permissions in home directory.");
se.printStackTrace();
}
}
- public File[] getAttachments()
- {
+ public File[] getAttachments() {
statusLine = "Retrieving temp docs";
- status.setStatus( 8, statusLine );
+ status.setStatus(8, statusLine);
File attachments[] = null;
- if( isOfficeDoc && isHtmlDoc )
- {
+
+ if (isOfficeDoc && isHtmlDoc) {
attachments = new File[2];
attachments[0] = htmlFile;
attachments[1] = officeFile;
- }
- else
- {
- if( isOfficeDoc )
- {
+ } else {
+ if (isOfficeDoc) {
attachments = new File[1];
attachments[0] = officeFile;
- }
- else
- {
+ } else {
attachments = new File[1];
attachments[0] = htmlFile;
}
@@ -276,14 +238,12 @@ public class OfficeAttachment
}
- public boolean isHtmlAttachment()
- {
+ public boolean isHtmlAttachment() {
return isHtmlDoc;
}
- public boolean isOfficeAttachment()
- {
+ public boolean isOfficeAttachment() {
return isOfficeDoc;
}
diff --git a/scripting/examples/java/Newsgroup/PostNewsgroup.java b/scripting/examples/java/Newsgroup/PostNewsgroup.java
index 83e90ad5aa36..f8320f48c818 100644
--- a/scripting/examples/java/Newsgroup/PostNewsgroup.java
+++ b/scripting/examples/java/Newsgroup/PostNewsgroup.java
@@ -26,8 +26,7 @@ import java.util.Vector;
import com.sun.star.script.framework.runtime.XScriptContext;
-public class PostNewsgroup extends JFrame
-{
+public class PostNewsgroup extends JFrame {
// Post to newsgroup objects
private NewsGroup[] subscribedNewsgroups = null;
@@ -63,40 +62,37 @@ public class PostNewsgroup extends JFrame
private final String replyText = "Email address to reply to";
private final String subjectText = "Subject title for the mail";
private final String commentText = "Additional comment on mail";
- private final String officeHtmlText = "Post as both Office and HTML attachments";
+ private final String officeHtmlText =
+ "Post as both Office and HTML attachments";
private final String officeText = "Post as Office attachment only";
private final String htmlText = "Post as HTML attachment only";
private final String postText = "Post to newsgroup";
private final String cancelText = "Cancel post to newsgroup";
- public void post( XScriptContext xsc )
- {
+ public void post(XScriptContext xsc) {
xscriptcontext = xsc;
window = this;
// create mailcap and mimetypes files (fix for classloader problem)
- MimeConfiguration.createFiles( xscriptcontext );
+ MimeConfiguration.createFiles(xscriptcontext);
- this.setTitle( "Post Document To Newsgroup" );
- this.setLocation( FRAMEX, FRAMEY );
+ this.setTitle("Post Document To Newsgroup");
+ this.setLocation(FRAMEX, FRAMEY);
- this.addFocusListener( new FocusAdapter()
- {
- public void focusGained( FocusEvent event )
- {
- System.out.println( "Focus gained" );
- window.update( window.getGraphics() );
+ this.addFocusListener(new FocusAdapter() {
+ public void focusGained(FocusEvent event) {
+ System.out.println("Focus gained");
+ window.update(window.getGraphics());
}
- public void focusLost( FocusEvent event )
- {
- System.out.println( "Focus lost" );
- }
+ public void focusLost(FocusEvent event) {
+ System.out.println("Focus lost");
+ }
});
Container container = getContentPane();
- container.setLayout( new GridBagLayout() );;
+ container.setLayout(new GridBagLayout());;
GridBagConstraints constraints = new GridBagConstraints();
constraints.fill = GridBagConstraints.BOTH;
@@ -109,204 +105,200 @@ public class PostNewsgroup extends JFrame
constraints.gridy = 0;
constraints.gridwidth = 1;
constraints.gridheight = 3;
- constraints.insets = new Insets( 15, 15, 5, 5 );
- container.add( labelPanel, constraints );
+ constraints.insets = new Insets(15, 15, 5, 5);
+ container.add(labelPanel, constraints);
constraints.gridx = 1;
constraints.gridy = 0;
constraints.gridwidth = 4;
constraints.gridheight = 3;
- constraints.insets = new Insets( 15, 5, 5, 15 );
- container.add( textPanel, constraints );
+ constraints.insets = new Insets(15, 5, 5, 15);
+ container.add(textPanel, constraints);
constraints.gridx = 0;
constraints.gridy = 3;
constraints.gridwidth = 5;
constraints.gridheight = 1;
- constraints.insets = new Insets( 5, 15, 5, 15 );
- container.add( optionPanel, constraints );
+ constraints.insets = new Insets(5, 15, 5, 15);
+ container.add(optionPanel, constraints);
constraints.gridx = 0;
constraints.gridy = 4;
constraints.gridwidth = 5;
constraints.gridheight = 1;
- constraints.insets = new Insets( 5, 5, 5, 5 );
- container.add( buttonPanel, constraints );
+ constraints.insets = new Insets(5, 5, 5, 5);
+ container.add(buttonPanel, constraints);
this.pack();
- this.setResizable( false );
- this.setVisible( true );
+ this.setResizable(false);
+ this.setVisible(true);
}
- private JPanel constructLabelPanel()
- {
- JLabel newsgroupLabel = new JLabel( "Newsgroup:" );
- JLabel hostLabel = new JLabel( "Host:" );
- JLabel replyLabel = new JLabel( "Reply:" );
- JLabel subjectLabel = new JLabel( "Subject:" );
- JLabel commentLabel = new JLabel( "Comment:" );
+ private JPanel constructLabelPanel() {
+ JLabel newsgroupLabel = new JLabel("Newsgroup:");
+ JLabel hostLabel = new JLabel("Host:");
+ JLabel replyLabel = new JLabel("Reply:");
+ JLabel subjectLabel = new JLabel("Subject:");
+ JLabel commentLabel = new JLabel("Comment:");
- newsgroupLabel.setToolTipText( newsgroupText );
- hostLabel.setToolTipText( hostText );
- replyLabel.setToolTipText( replyText );
- subjectLabel.setToolTipText( subjectText );
- commentLabel.setToolTipText( commentText );
+ newsgroupLabel.setToolTipText(newsgroupText);
+ hostLabel.setToolTipText(hostText);
+ replyLabel.setToolTipText(replyText);
+ subjectLabel.setToolTipText(subjectText);
+ commentLabel.setToolTipText(commentText);
JPanel newsgroupPanel = new JPanel();
- newsgroupPanel.setLayout( new BorderLayout() );
- newsgroupPanel.add( newsgroupLabel, "West" );
+ newsgroupPanel.setLayout(new BorderLayout());
+ newsgroupPanel.add(newsgroupLabel, "West");
JPanel hostPanel = new JPanel();
- hostPanel.setLayout( new BorderLayout() );
- hostPanel.add( hostLabel, "West" );
+ hostPanel.setLayout(new BorderLayout());
+ hostPanel.add(hostLabel, "West");
JPanel replyPanel = new JPanel();
- replyPanel.setLayout( new BorderLayout() );
- replyPanel.add( replyLabel, "West" );
+ replyPanel.setLayout(new BorderLayout());
+ replyPanel.add(replyLabel, "West");
JPanel subjectPanel = new JPanel();
- subjectPanel.setLayout( new BorderLayout() );
- subjectPanel.add( subjectLabel, "West" );
+ subjectPanel.setLayout(new BorderLayout());
+ subjectPanel.add(subjectLabel, "West");
JPanel commentPanel = new JPanel();
- commentPanel.setLayout( new BorderLayout() );
- commentPanel.add( commentLabel, "West" );
+ commentPanel.setLayout(new BorderLayout());
+ commentPanel.add(commentLabel, "West");
JPanel emptyPanel = new JPanel();
final int labelWidth = 80;
- newsgroupPanel.setPreferredSize( new Dimension( labelWidth, TEXTBOXHEIGHT ) );
- hostPanel.setPreferredSize( new Dimension( labelWidth, TEXTBOXHEIGHT ) );
- replyPanel.setPreferredSize( new Dimension( labelWidth, TEXTBOXHEIGHT ) );
- subjectPanel.setPreferredSize( new Dimension( labelWidth, TEXTBOXHEIGHT ) );
- commentPanel.setPreferredSize( new Dimension( labelWidth, TEXTBOXHEIGHT ) );
+ newsgroupPanel.setPreferredSize(new Dimension(labelWidth, TEXTBOXHEIGHT));
+ hostPanel.setPreferredSize(new Dimension(labelWidth, TEXTBOXHEIGHT));
+ replyPanel.setPreferredSize(new Dimension(labelWidth, TEXTBOXHEIGHT));
+ subjectPanel.setPreferredSize(new Dimension(labelWidth, TEXTBOXHEIGHT));
+ commentPanel.setPreferredSize(new Dimension(labelWidth, TEXTBOXHEIGHT));
JPanel panel = new JPanel();
- panel.setLayout( new GridBagLayout() );
+ panel.setLayout(new GridBagLayout());
GridBagConstraints constraints = new GridBagConstraints();
constraints.fill = GridBagConstraints.BOTH;
- constraints.insets = new Insets( 5, 5, 5, 5 );
+ constraints.insets = new Insets(5, 5, 5, 5);
constraints.gridx = 0;
constraints.gridy = 0;
constraints.gridwidth = 1;
constraints.gridheight = 1;
constraints.weightx = constraints.weighty = 0.0;
- panel.add( newsgroupPanel, constraints );
+ panel.add(newsgroupPanel, constraints);
constraints.gridx = 0;
constraints.gridy = 1;
constraints.gridwidth = 1;
constraints.gridheight = 1;
- panel.add( hostPanel, constraints );
+ panel.add(hostPanel, constraints);
constraints.gridx = 0;
constraints.gridy = 2;
constraints.gridwidth = 1;
constraints.gridheight = 1;
- panel.add( replyPanel, constraints );
+ panel.add(replyPanel, constraints);
constraints.gridx = 0;
constraints.gridy = 3;
constraints.gridwidth = 1;
constraints.gridheight = 1;
- panel.add( subjectPanel, constraints );
+ panel.add(subjectPanel, constraints);
constraints.gridx = 0;
constraints.gridy = 4;
constraints.gridwidth = 1;
constraints.gridheight = 1;
- panel.add( commentPanel, constraints );
+ panel.add(commentPanel, constraints);
constraints.gridx = 0;
constraints.gridy = 5;
constraints.gridwidth = 1;
constraints.gridheight = 1;
constraints.weightx = constraints.weighty = 1.0;
- panel.add( emptyPanel, constraints );
+ panel.add(emptyPanel, constraints);
return panel;
}
- private JPanel constructTextPanel()
- {
+ private JPanel constructTextPanel() {
hostTextField = new JTextField();
- hostTextField.setPreferredSize( new Dimension( TEXTBOXWIDTH, TEXTBOXHEIGHT ) );
- hostTextField.setToolTipText( hostText );
- hostTextField.setBorder( new EtchedBorder() );
+ hostTextField.setPreferredSize(new Dimension(TEXTBOXWIDTH, TEXTBOXHEIGHT));
+ hostTextField.setToolTipText(hostText);
+ hostTextField.setBorder(new EtchedBorder());
//optionPanel.setBorder( new TitledBorder( new EtchedBorder(), "Document Format" ) );
newsgroupComboBox = getNewsgroupCombo();
replyTextField = new JTextField();
- replyTextField.setPreferredSize( new Dimension( TEXTBOXWIDTH, TEXTBOXHEIGHT ) );
- replyTextField.setToolTipText( replyText );
- replyTextField.setBorder( new EtchedBorder() );
+ replyTextField.setPreferredSize(new Dimension(TEXTBOXWIDTH, TEXTBOXHEIGHT));
+ replyTextField.setToolTipText(replyText);
+ replyTextField.setBorder(new EtchedBorder());
subjectTextField = new JTextField();
- subjectTextField.setPreferredSize( new Dimension( TEXTBOXWIDTH, TEXTBOXHEIGHT ) );
- subjectTextField.setToolTipText( subjectText );
- subjectTextField.setBorder( new EtchedBorder() );
+ subjectTextField.setPreferredSize(new Dimension(TEXTBOXWIDTH, TEXTBOXHEIGHT));
+ subjectTextField.setToolTipText(subjectText);
+ subjectTextField.setBorder(new EtchedBorder());
commentTextArea = new JTextArea();
- commentTextArea.setPreferredSize( new Dimension( TEXTBOXWIDTH, TEXTAREAHEIGHT ) );
- commentTextArea.setToolTipText( commentText );
- commentTextArea.setBorder( new EtchedBorder() );
+ commentTextArea.setPreferredSize(new Dimension(TEXTBOXWIDTH, TEXTAREAHEIGHT));
+ commentTextArea.setToolTipText(commentText);
+ commentTextArea.setBorder(new EtchedBorder());
JPanel panel = new JPanel();
- panel.setLayout( new GridBagLayout() );
+ panel.setLayout(new GridBagLayout());
GridBagConstraints constraints = new GridBagConstraints();
constraints.fill = GridBagConstraints.BOTH;
- constraints.insets = new Insets( 5, 5, 5, 5 );
+ constraints.insets = new Insets(5, 5, 5, 5);
constraints.gridx = 0;
constraints.gridy = 0;
constraints.gridwidth = 1;
constraints.gridheight = 1;
- panel.add( newsgroupComboBox, constraints );
+ panel.add(newsgroupComboBox, constraints);
constraints.gridx = 0;
constraints.gridy = 1;
constraints.gridwidth = 1;
constraints.gridheight = 1;
- panel.add( hostTextField, constraints );
+ panel.add(hostTextField, constraints);
constraints.gridx = 0;
constraints.gridy = 2;
constraints.gridwidth = 1;
constraints.gridheight = 1;
- panel.add( replyTextField, constraints );
+ panel.add(replyTextField, constraints);
constraints.gridx = 0;
constraints.gridy = 3;
constraints.gridwidth = 1;
constraints.gridheight = 1;
- panel.add( subjectTextField, constraints );
+ panel.add(subjectTextField, constraints);
constraints.gridx = 0;
constraints.gridy = 4;
constraints.gridwidth = 1;
constraints.gridheight = 2;
- panel.add( commentTextArea, constraints );
+ panel.add(commentTextArea, constraints);
return panel;
}
- private JComboBox getNewsgroupCombo()
- {
+ private JComboBox getNewsgroupCombo() {
newsgroupComboBox = new JComboBox();
//newsgroupComboBox.setBorder( new EtchedBorder() );
- newsgroupComboBox.addActionListener(new ActionListener()
- {
- public void actionPerformed(ActionEvent e)
- {
+ newsgroupComboBox.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent e) {
// when newsgroup is selected
- if( subscribedNewsgroups != null )
- {
+ if (subscribedNewsgroups != null) {
int position = newsgroupComboBox.getSelectedIndex();
- if( position != -1 )
- {
- hostTextField.setText( subscribedNewsgroups[ position ].getHostName() );
- newsgroupComboBox.setToolTipText( "Newsgroup name: " + subscribedNewsgroups[ position ].getNewsgroupName() + " (Host name: " + subscribedNewsgroups[ position ].getHostName() + ")" );
+
+ if (position != -1) {
+ hostTextField.setText(subscribedNewsgroups[ position ].getHostName());
+ newsgroupComboBox.setToolTipText("Newsgroup name: " +
+ subscribedNewsgroups[ position ].getNewsgroupName() + " (Host name: " +
+ subscribedNewsgroups[ position ].getHostName() + ")");
}
}
}
@@ -319,310 +311,318 @@ public class PostNewsgroup extends JFrame
// Test for no .mozilla or no subscribed newsgroups
// subscribedNewsgroups = null;
- if( subscribedNewsgroups == null )
- {
- JOptionPane.showMessageDialog( window, "No subscribed newsgroups found in mozilla/netscape profile \nPlease enter newsgroup and host name",
- "Newsgroups Information", JOptionPane.INFORMATION_MESSAGE );
- }
- else
- {
+ if (subscribedNewsgroups == null) {
+ JOptionPane.showMessageDialog(window,
+ "No subscribed newsgroups found in mozilla/netscape profile \nPlease enter newsgroup and host name",
+ "Newsgroups Information", JOptionPane.INFORMATION_MESSAGE);
+ } else {
// Copy all newsgroups into a vector for comparison
// Alter entries (to include host name) if duplication is found
- ArrayList vector = new ArrayList( subscribedNewsgroups.length );
- for(int i=0; i < subscribedNewsgroups.length; i++ )
- {
- vector.add( subscribedNewsgroups[i].getNewsgroupName() );
+ ArrayList vector = new ArrayList(subscribedNewsgroups.length);
+
+ for (int i = 0; i < subscribedNewsgroups.length; i++) {
+ vector.add(subscribedNewsgroups[i].getNewsgroupName());
}
+
// Compare and alter
- for(int i=0; i < subscribedNewsgroups.length; i++ )
- {
+ for (int i = 0; i < subscribedNewsgroups.length; i++) {
// check if combo box already has a newsgroup with same name
// then add host name to differentiate
- for(int j=0; j < subscribedNewsgroups.length; j++ )
- {
- if( j != i && subscribedNewsgroups[j].getNewsgroupName().equalsIgnoreCase( subscribedNewsgroups[i].getNewsgroupName() ) )
- {
- vector.set( j, subscribedNewsgroups[j].getNewsgroupName() + " (" + subscribedNewsgroups[j].getHostName() + ")" );
- vector.set( i, subscribedNewsgroups[i].getNewsgroupName() + " (" + subscribedNewsgroups[i].getHostName() + ")" );
+ for (int j = 0; j < subscribedNewsgroups.length; j++) {
+ if (j != i
+ && subscribedNewsgroups[j].getNewsgroupName().equalsIgnoreCase(
+ subscribedNewsgroups[i].getNewsgroupName())) {
+ vector.set(j, subscribedNewsgroups[j].getNewsgroupName() + " (" +
+ subscribedNewsgroups[j].getHostName() + ")");
+ vector.set(i, subscribedNewsgroups[i].getNewsgroupName() + " (" +
+ subscribedNewsgroups[i].getHostName() + ")");
}
}
}
+
// Copy converted newsgroups from vector to combo box
- for(int i=0; i < subscribedNewsgroups.length; i++ )
- {
- newsgroupComboBox.addItem( vector.elementAt(i) );
+ for (int i = 0; i < subscribedNewsgroups.length; i++) {
+ newsgroupComboBox.addItem(vector.elementAt(i));
}
}// else
- newsgroupComboBox.setPreferredSize( new Dimension( TEXTBOXWIDTH, TEXTBOXHEIGHT ) );
- newsgroupComboBox.setEditable( true );
+ newsgroupComboBox.setPreferredSize(new Dimension(TEXTBOXWIDTH, TEXTBOXHEIGHT));
+ newsgroupComboBox.setEditable(true);
return newsgroupComboBox;
}
- private JPanel constructOptionPanel()
- {
- officeHtmlButton = new JRadioButton( "Office and HTML", true );
- officeHtmlButton.setToolTipText( officeHtmlText );
+ private JPanel constructOptionPanel() {
+ officeHtmlButton = new JRadioButton("Office and HTML", true);
+ officeHtmlButton.setToolTipText(officeHtmlText);
- officeButton = new JRadioButton( "Office" );
- officeButton.setToolTipText( officeText );
+ officeButton = new JRadioButton("Office");
+ officeButton.setToolTipText(officeText);
- htmlButton = new JRadioButton( "HTML" );
- htmlButton.setToolTipText( htmlText );
+ htmlButton = new JRadioButton("HTML");
+ htmlButton.setToolTipText(htmlText);
JRadioButton[] rbuttons = { officeHtmlButton, officeButton, htmlButton };
ButtonGroup radioButtonGroup = new ButtonGroup();
- for( int i=0; i < rbuttons.length; i++ )
- {
- radioButtonGroup.add( rbuttons[i] );
+
+ for (int i = 0; i < rbuttons.length; i++) {
+ radioButtonGroup.add(rbuttons[i]);
}
JPanel optionPanel = new JPanel();
- optionPanel.setBorder( new TitledBorder( new EtchedBorder(), "Document Format" ) );
- optionPanel.setLayout( new GridBagLayout() );
+ optionPanel.setBorder(new TitledBorder(new EtchedBorder(), "Document Format"));
+ optionPanel.setLayout(new GridBagLayout());
GridBagConstraints constraints = new GridBagConstraints();
constraints.fill = GridBagConstraints.BOTH;
constraints.gridx = 0;
- constraints.gridy = 0;
- constraints.gridwidth = 1;
- constraints.gridheight = 1;
- constraints.insets = new Insets( 5, 5, 5, 30 );
- optionPanel.add( officeHtmlButton, constraints );
+ constraints.gridy = 0;
+ constraints.gridwidth = 1;
+ constraints.gridheight = 1;
+ constraints.insets = new Insets(5, 5, 5, 30);
+ optionPanel.add(officeHtmlButton, constraints);
constraints.gridx = 1;
- constraints.gridy = 0;
- constraints.gridwidth = 1;
- constraints.gridheight = 1;
- constraints.insets = new Insets( 5, 20, 5, 30 );
- optionPanel.add( officeButton, constraints );
+ constraints.gridy = 0;
+ constraints.gridwidth = 1;
+ constraints.gridheight = 1;
+ constraints.insets = new Insets(5, 20, 5, 30);
+ optionPanel.add(officeButton, constraints);
constraints.gridx = 2;
- constraints.gridy = 0;
- constraints.gridwidth = 1;
- constraints.gridheight = 1;
- constraints.insets = new Insets( 5, 20, 5, 5 );
- optionPanel.add( htmlButton, constraints );
+ constraints.gridy = 0;
+ constraints.gridwidth = 1;
+ constraints.gridheight = 1;
+ constraints.insets = new Insets(5, 20, 5, 5);
+ optionPanel.add(htmlButton, constraints);
- return optionPanel;
+ return optionPanel;
}
- public boolean sendingActions()
- {
- // posting actions
- // Validate the data
- if( isValidData() )
- {
- // Create status window
- StatusWindow statusWindow = new StatusWindow( window, "Posting to Newsgroup", FRAMEX, FRAMEY );
-
- statusWindow.setVisible( true );
- statusLine = "Ready to send...";
- statusWindow.setStatus( 0, statusLine );
-
- // Get the boolean values for HTML/Office document
- // params: ( XScriptContext, StatusWindow, html document, office document )
-
- boolean html = false;
- boolean office = false;
- if( officeHtmlButton.isSelected() ) { html = true; office = true; }
- if( officeButton.isSelected() ) { office = true; html = false; }
- if( htmlButton.isSelected() ) { html = true; office = false; }
-
- OfficeAttachment officeAttach = new OfficeAttachment( xscriptcontext, statusWindow, html, office );
-
- statusLine = "Getting user input";
- statusWindow.setStatus( 2, statusLine );
- // Get replyto, subject, comment from textboxes
- String replyto = replyTextField.getText();
- String subject = subjectTextField.getText();
- String comment = commentTextArea.getText();
-
- // Get newsgroup from combo box (corresponding position)
- String host = "";
- String group = "";
- int position = newsgroupComboBox.getSelectedIndex();
- if( subscribedNewsgroups == null || position == -1 )
- {
- host = hostTextField.getText();
- group = newsgroupComboBox.getSelectedItem().toString();
- }
- else
- {
- host = subscribedNewsgroups[ position ].getHostName();
- group = subscribedNewsgroups[ position ].getNewsgroupName();
- }
+ public boolean sendingActions() {
+ // posting actions
+ // Validate the data
+ if (isValidData()) {
+ // Create status window
+ StatusWindow statusWindow = new StatusWindow(window, "Posting to Newsgroup",
+ FRAMEX, FRAMEY);
- statusLine = "Creating sender object";
- statusWindow.setStatus( 3, statusLine );
- Sender sender = new Sender( statusWindow, officeAttach, replyto, subject, comment, host, group );
- if( !sender.sendMail() )
- {
- statusWindow.enableCancelButton( true );
- officeAttach.cleanUpOnError();
- return false;
- }
+ statusWindow.setVisible(true);
+ statusLine = "Ready to send...";
+ statusWindow.setStatus(0, statusLine);
+
+ // Get the boolean values for HTML/Office document
+ // params: ( XScriptContext, StatusWindow, html document, office document )
+
+ boolean html = false;
+ boolean office = false;
- statusLine = "Send is complete";
- statusWindow.setStatus( 14, statusLine );
+ if (officeHtmlButton.isSelected()) {
+ html = true;
+ office = true;
}
- else
- {
+
+ if (officeButton.isSelected()) {
+ office = true;
+ html = false;
+ }
+
+ if (htmlButton.isSelected()) {
+ html = true;
+ office = false;
+ }
+
+ OfficeAttachment officeAttach = new OfficeAttachment(xscriptcontext,
+ statusWindow, html, office);
+
+ statusLine = "Getting user input";
+ statusWindow.setStatus(2, statusLine);
+ // Get replyto, subject, comment from textboxes
+ String replyto = replyTextField.getText();
+ String subject = subjectTextField.getText();
+ String comment = commentTextArea.getText();
+
+ // Get newsgroup from combo box (corresponding position)
+ String host = "";
+ String group = "";
+ int position = newsgroupComboBox.getSelectedIndex();
+
+ if (subscribedNewsgroups == null || position == -1) {
+ host = hostTextField.getText();
+ group = newsgroupComboBox.getSelectedItem().toString();
+ } else {
+ host = subscribedNewsgroups[ position ].getHostName();
+ group = subscribedNewsgroups[ position ].getNewsgroupName();
+ }
+
+ statusLine = "Creating sender object";
+ statusWindow.setStatus(3, statusLine);
+ Sender sender = new Sender(statusWindow, officeAttach, replyto, subject,
+ comment, host, group);
+
+ if (!sender.sendMail()) {
+ statusWindow.enableCancelButton(true);
+ officeAttach.cleanUpOnError();
return false;
}
- return true;
+
+ statusLine = "Send is complete";
+ statusWindow.setStatus(14, statusLine);
+ } else {
+ return false;
+ }
+
+ return true;
}
- private JPanel constructButtonPanel()
- {
+ private JPanel constructButtonPanel() {
Action postAction = new AbstractAction() {
- public void actionPerformed( ActionEvent event ) {
+ public void actionPerformed(ActionEvent event) {
// posting actions
sendingActions();
}// actionPerformed
};
Action cancelAction = new AbstractAction() {
- public void actionPerformed( ActionEvent event ) {
- // cancelling actions
+ public void actionPerformed(ActionEvent event) {
+ // cancelling actions
window.dispose();
- }
- };
+ }
+ };
postButton = new JButton();
- postButton.setAction( postAction );
- postButton.setToolTipText( postText );
- postButton.setText( "Post" );
- postButton.setPreferredSize( new Dimension( BUTTONWIDTH + 20, BUTTONHEIGHT ) );
+ postButton.setAction(postAction);
+ postButton.setToolTipText(postText);
+ postButton.setText("Post");
+ postButton.setPreferredSize(new Dimension(BUTTONWIDTH + 20, BUTTONHEIGHT));
cancelButton = new JButton();
- cancelButton.setAction( cancelAction );
- cancelButton.setToolTipText( cancelText );
- cancelButton.setText( "Cancel" );
- cancelButton.setPreferredSize( new Dimension( BUTTONWIDTH + 20, BUTTONHEIGHT ) );
+ cancelButton.setAction(cancelAction);
+ cancelButton.setToolTipText(cancelText);
+ cancelButton.setText("Cancel");
+ cancelButton.setPreferredSize(new Dimension(BUTTONWIDTH + 20, BUTTONHEIGHT));
- JSeparator sep = new JSeparator( SwingConstants.HORIZONTAL );
+ JSeparator sep = new JSeparator(SwingConstants.HORIZONTAL);
JPanel buttonPanel = new JPanel();
- buttonPanel.setLayout( new GridBagLayout() );
+ buttonPanel.setLayout(new GridBagLayout());
GridBagConstraints constraints = new GridBagConstraints();
constraints.fill = GridBagConstraints.BOTH;
- constraints.insets = new Insets( 5, 5, 5, 5 );
+ constraints.insets = new Insets(5, 5, 5, 5);
JPanel emptyPanel1 = new JPanel();
- emptyPanel1.setPreferredSize( new Dimension( BUTTONWIDTH, BUTTONHEIGHT ) );
+ emptyPanel1.setPreferredSize(new Dimension(BUTTONWIDTH, BUTTONHEIGHT));
JPanel emptyPanel2 = new JPanel();
- emptyPanel2.setPreferredSize( new Dimension( BUTTONWIDTH, BUTTONHEIGHT ) );
+ emptyPanel2.setPreferredSize(new Dimension(BUTTONWIDTH, BUTTONHEIGHT));
constraints.gridx = 0;
- constraints.gridy = 0;
- constraints.gridwidth = 4;
- constraints.gridheight = 1;
- buttonPanel.add( sep, constraints );
+ constraints.gridy = 0;
+ constraints.gridwidth = 4;
+ constraints.gridheight = 1;
+ buttonPanel.add(sep, constraints);
constraints.gridx = 0;
- constraints.gridy = 1;
- constraints.gridwidth = 1;
- constraints.gridheight = 1;
- buttonPanel.add( emptyPanel1, constraints );
+ constraints.gridy = 1;
+ constraints.gridwidth = 1;
+ constraints.gridheight = 1;
+ buttonPanel.add(emptyPanel1, constraints);
- constraints.gridx = 1;
- constraints.gridy = 1;
- constraints.gridwidth = 1;
- constraints.gridheight = 1;
- buttonPanel.add( emptyPanel2, constraints );
+ constraints.gridx = 1;
+ constraints.gridy = 1;
+ constraints.gridwidth = 1;
+ constraints.gridheight = 1;
+ buttonPanel.add(emptyPanel2, constraints);
constraints.gridx = 2;
constraints.gridy = 1;
constraints.gridwidth = 1;
constraints.gridheight = 1;
- buttonPanel.add( postButton, constraints );
+ buttonPanel.add(postButton, constraints);
constraints.gridx = 3;
constraints.gridy = 1;
constraints.gridwidth = 1;
constraints.gridheight = 1;
- constraints.insets = new Insets( 5, 5, 5, 0 );
- buttonPanel.add( cancelButton, constraints );
+ constraints.insets = new Insets(5, 5, 5, 0);
+ buttonPanel.add(cancelButton, constraints);
- return buttonPanel;
+ return buttonPanel;
}
- public void enableButtons( boolean enable )
- {
- if( enable )
- {
- postButton.setEnabled( true );
- cancelButton.setEnabled( true );
- }
- else
- {
- postButton.setEnabled( false );
- cancelButton.setEnabled( false );
+ public void enableButtons(boolean enable) {
+ if (enable) {
+ postButton.setEnabled(true);
+ cancelButton.setEnabled(true);
+ } else {
+ postButton.setEnabled(false);
+ cancelButton.setEnabled(false);
}
}
- private boolean isValidData()
- {
+ private boolean isValidData() {
// newsgroupComboBox must not be blank (format? dots and whitespace)
String newsgroupString = "";
int position = newsgroupComboBox.getSelectedIndex();
- if( subscribedNewsgroups == null || position == -1 )
- {
+
+ if (subscribedNewsgroups == null || position == -1) {
newsgroupString = newsgroupComboBox.getSelectedItem().toString();
- }
- else
- {
+ } else {
newsgroupString = subscribedNewsgroups[ position ].getNewsgroupName();
}
- if( newsgroupString.length() == 0 )
- {
+
+ if (newsgroupString.length() == 0) {
newsgroupComboBox.requestFocus();
- JOptionPane.showMessageDialog( window, "Please enter a newsgroup name", "Input Error", JOptionPane.ERROR_MESSAGE );
+ JOptionPane.showMessageDialog(window, "Please enter a newsgroup name",
+ "Input Error", JOptionPane.ERROR_MESSAGE);
return false;
}
// hostTextField must not be blank (format?)
String hostString = hostTextField.getText();
- if( hostString.length() == 0 )
- {
+
+ if (hostString.length() == 0) {
hostTextField.requestFocus();
- JOptionPane.showMessageDialog( window, "Please enter a hostname", "Input Error", JOptionPane.ERROR_MESSAGE );
- return false;
- }
+ JOptionPane.showMessageDialog(window, "Please enter a hostname", "Input Error",
+ JOptionPane.ERROR_MESSAGE);
+ return false;
+ }
// replyTextField must have <string>@<string>.<string>
// (string at least 2 chars long)
// consider <s>.<s>@<s>.<s>.<s> format? (array of dot positons?)
String replyString = replyTextField.getText();
- int atPos = replyString.indexOf( "@" );
- int dotPos = replyString.lastIndexOf( "." );
+ int atPos = replyString.indexOf("@");
+ int dotPos = replyString.lastIndexOf(".");
int length = replyString.length();
- if( length == 0 || atPos == -1 || dotPos == -1 || atPos < 2 || dotPos < atPos || dotPos + 2 == length || atPos + 2 == dotPos || atPos != replyString.lastIndexOf( "@" ) || replyString.indexOf(" ") != -1 )
- {
+
+ if (length == 0 || atPos == -1 || dotPos == -1 || atPos < 2 || dotPos < atPos
+ || dotPos + 2 == length || atPos + 2 == dotPos
+ || atPos != replyString.lastIndexOf("@") || replyString.indexOf(" ") != -1) {
replyTextField.requestFocus();
- JOptionPane.showMessageDialog( window, "Please enter a valid reply to email address", "Input Error", JOptionPane.ERROR_MESSAGE );
+ JOptionPane.showMessageDialog(window,
+ "Please enter a valid reply to email address", "Input Error",
+ JOptionPane.ERROR_MESSAGE);
return false;
}
// subjectTextField must not be blank?
String subjectString = subjectTextField.getText();
- if( subjectString.length() == 0 )
- {
+
+ if (subjectString.length() == 0) {
subjectTextField.requestFocus();
- JOptionPane.showMessageDialog( window, "Please enter subject title", "Input Error", JOptionPane.ERROR_MESSAGE );
+ JOptionPane.showMessageDialog(window, "Please enter subject title",
+ "Input Error", JOptionPane.ERROR_MESSAGE);
return false;
}
diff --git a/scripting/examples/java/Newsgroup/Sender.java b/scripting/examples/java/Newsgroup/Sender.java
index efa3ed4c6753..00b3db87bacb 100644
--- a/scripting/examples/java/Newsgroup/Sender.java
+++ b/scripting/examples/java/Newsgroup/Sender.java
@@ -26,116 +26,112 @@ import java.io.*;
import javax.activation.*;
-public class Sender
-{
+public class Sender {
// Constructor params:
private StatusWindow status = null;
private OfficeAttachment attachments = null;
private String replyto = "";
- private String subject = "";
- private String comment = "";
- private String hostname = "";
- private String newsgroup = "";
+ private String subject = "";
+ private String comment = "";
+ private String hostname = "";
+ private String newsgroup = "";
private String statusLine = "";
- public Sender( StatusWindow sw, OfficeAttachment attach, String reply,
- String sub, String com, String host, String group )
- {
+ public Sender(StatusWindow sw, OfficeAttachment attach, String reply,
+ String sub, String com, String host, String group) {
status = sw;
attachments = attach;
- replyto = reply;
- subject = sub;
- comment = com;
- hostname = host;
- newsgroup = group;
+ replyto = reply;
+ subject = sub;
+ comment = com;
+ hostname = host;
+ newsgroup = group;
}
- public boolean sendMail()
- {
+ public boolean sendMail() {
int statusPos = 5;
- try
- {
+
+ try {
attachments.createTempDocs();
// Property for any information
Properties props = new Properties();
// Create unique session (null is unused authenticator info)
statusLine = "Creating unique session";
- status.setStatus( statusPos, statusLine ); // 5
- Session session = Session.getInstance( props, null );
+ status.setStatus(statusPos, statusLine); // 5
+ Session session = Session.getInstance(props, null);
// Create message
statusPos++; // 6
statusLine = "Creating message";
- status.setStatus( statusPos, statusLine );
- MimeMessage message = new MimeMessage( session );
- message.setFrom( new InternetAddress( replyto ) );
- message.setSubject( subject );
- message.setText( comment );
- message.addHeader( "Newsgroups", newsgroup );
+ status.setStatus(statusPos, statusLine);
+ MimeMessage message = new MimeMessage(session);
+ message.setFrom(new InternetAddress(replyto));
+ message.setSubject(subject);
+ message.setText(comment);
+ message.addHeader("Newsgroups", newsgroup);
// Buildup bodypart with text and attachments
Multipart multipart = new MimeMultipart();
BodyPart messageBodyPart = new MimeBodyPart();
- messageBodyPart.setText( comment );
- multipart.addBodyPart( messageBodyPart );
+ messageBodyPart.setText(comment);
+ multipart.addBodyPart(messageBodyPart);
statusPos++; // 7
statusLine = "Adding attachment(s)";
- status.setStatus( statusPos, statusLine );
+ status.setStatus(statusPos, statusLine);
File attachs[] = attachments.getAttachments();
- for(int i=0; i < attachs.length; i++ )
- {
+
+ for (int i = 0; i < attachs.length; i++) {
messageBodyPart = new MimeBodyPart();
- DataSource filesource = new FileDataSource( attachs[i] );
- messageBodyPart.setDataHandler( new DataHandler( filesource ));
- messageBodyPart.setFileName( attachs[i].getName() );
- multipart.addBodyPart( messageBodyPart );
+ DataSource filesource = new FileDataSource(attachs[i]);
+ messageBodyPart.setDataHandler(new DataHandler(filesource));
+ messageBodyPart.setFileName(attachs[i].getName());
+ multipart.addBodyPart(messageBodyPart);
}
// Add multipart to mail
- message.setContent( multipart );
+ message.setContent(multipart);
// Create and send NNTP transport
statusPos += 2; // 9
statusLine = "Creating NNTP transport";
- status.setStatus( statusPos, statusLine );
- Transport transport = new NNTPTransport( session, new URLName( "news:" + newsgroup ));
+ status.setStatus(statusPos, statusLine);
+ Transport transport = new NNTPTransport(session,
+ new URLName("news:" + newsgroup));
// Null parameters are for user name and password
statusPos++; // 10
statusLine = "Connecting to mail server";
- status.setStatus( statusPos, statusLine );
- transport.connect( hostname, null, null );
+ status.setStatus(statusPos, statusLine);
+ transport.connect(hostname, null, null);
statusPos++; // 11
statusLine = "Sending message";
- status.setStatus( statusPos, statusLine );
- transport.sendMessage( message, message.getAllRecipients() );
+ status.setStatus(statusPos, statusLine);
+ transport.sendMessage(message, message.getAllRecipients());
statusPos++; // 12
statusLine = "Closing transport";
- status.setStatus( statusPos, statusLine );
+ status.setStatus(statusPos, statusLine);
transport.close();
// Clean up when finished
attachments.removeTempDocs();
return true;
- }
- catch( MessagingException me )
- {
- if( statusPos == 10 )
- {
+ } catch (MessagingException me) {
+ if (statusPos == 10) {
statusLine = "Error connecting (User authentication?)";
}
- status.setStatus( statusPos, statusLine );
- System.out.println( "Error sending message: ");
+
+ status.setStatus(statusPos, statusLine);
+ System.out.println("Error sending message: ");
me.printStackTrace();
return false;
}
diff --git a/scripting/examples/java/Newsgroup/StatusWindow.java b/scripting/examples/java/Newsgroup/StatusWindow.java
index b95fb3a91b07..7b37c8fa79d0 100644
--- a/scripting/examples/java/Newsgroup/StatusWindow.java
+++ b/scripting/examples/java/Newsgroup/StatusWindow.java
@@ -23,8 +23,7 @@ import java.awt.event.*;
import javax.swing.*;
import javax.swing.border.*;
-public class StatusWindow extends JFrame
-{
+public class StatusWindow extends JFrame {
private JProgressBar progressBar = null;
private JTextField statusLabel = null;
@@ -36,62 +35,59 @@ public class StatusWindow extends JFrame
private final int MINPROGRESS = 0;
- public StatusWindow( PostNewsgroup mw, String title, int parentX, int parentY )
- {
- this.setTitle( title );
- this.setLocation( parentX + 100, parentY + 100 );
+ public StatusWindow(PostNewsgroup mw, String title, int parentX, int parentY) {
+ this.setTitle(title);
+ this.setLocation(parentX + 100, parentY + 100);
statusWindow = this;
mainWindow = mw;
- mainWindow.enableButtons( false );
+ mainWindow.enableButtons(false);
- statusWindow.addWindowListener( new WindowAdapter()
- {
- public void windowClosing( WindowEvent event ) {
- mainWindow.enableButtons( true );
+ statusWindow.addWindowListener(new WindowAdapter() {
+ public void windowClosing(WindowEvent event) {
+ mainWindow.enableButtons(true);
}
});
progressBar = new JProgressBar();
- progressBar.setStringPainted( true );
- progressBar.setMaximum( MAXPROGRESS );
- progressBar.setMinimum( MINPROGRESS );
- progressBar.setSize( 30, 400 );
+ progressBar.setStringPainted(true);
+ progressBar.setMaximum(MAXPROGRESS);
+ progressBar.setMinimum(MINPROGRESS);
+ progressBar.setSize(30, 400);
- JLabel progLabel = new JLabel( "Progress:" );
+ JLabel progLabel = new JLabel("Progress:");
JPanel progressPanel = new JPanel();
- progressPanel.setLayout( new BorderLayout( 10, 0 ) );
- progressPanel.add( progLabel, "West" );
- progressPanel.add( progressBar, "East" );
+ progressPanel.setLayout(new BorderLayout(10, 0));
+ progressPanel.add(progLabel, "West");
+ progressPanel.add(progressBar, "East");
statusLabel = new JTextField();
- statusLabel.setColumns( 25 );
- statusLabel.setEditable( false );
- statusLabel.setBorder( null );
+ statusLabel.setColumns(25);
+ statusLabel.setEditable(false);
+ statusLabel.setBorder(null);
JPanel statusPanel = new JPanel();
- statusPanel.setLayout( new BorderLayout() );
- statusPanel.add( statusLabel, "West" );
-
- cancelButton = new JButton( "Cancel" );
- cancelButton.setSize( 30, 100 );
- cancelButton.setEnabled( false );
- cancelButton.addActionListener( new ActionListener()
- {
- public void actionPerformed( ActionEvent event ) {
- // cancelling actions
- mainWindow.enableButtons( true );
+ statusPanel.setLayout(new BorderLayout());
+ statusPanel.add(statusLabel, "West");
+
+ cancelButton = new JButton("Cancel");
+ cancelButton.setSize(30, 100);
+ cancelButton.setEnabled(false);
+ cancelButton.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent event) {
+ // cancelling actions
+ mainWindow.enableButtons(true);
statusWindow.dispose();
- }
- });
+ }
+ });
JPanel buttonPanel = new JPanel();
- buttonPanel.setLayout( new BorderLayout( 0, 5 ) );
- buttonPanel.add( cancelButton, "East" );
- buttonPanel.add( new JSeparator( SwingConstants.HORIZONTAL ), "North" );
+ buttonPanel.setLayout(new BorderLayout(0, 5));
+ buttonPanel.add(cancelButton, "East");
+ buttonPanel.add(new JSeparator(SwingConstants.HORIZONTAL), "North");
Container container = getContentPane();
- container.setLayout( new GridBagLayout() );
+ container.setLayout(new GridBagLayout());
GridBagConstraints constraints = new GridBagConstraints();
constraints.fill = GridBagConstraints.BOTH;
@@ -99,55 +95,51 @@ public class StatusWindow extends JFrame
constraints.gridy = 0;
constraints.gridwidth = 1;
constraints.gridheight = 1;
- constraints.insets = new Insets( 15, 15, 10, 15 );
- container.add( progressPanel, constraints );
+ constraints.insets = new Insets(15, 15, 10, 15);
+ container.add(progressPanel, constraints);
constraints.gridx = 0;
constraints.gridy = 1;
constraints.gridwidth = 1;
constraints.gridheight = 1;
- constraints.insets = new Insets( 10, 15, 10, 15 );
- container.add( statusPanel, constraints );
+ constraints.insets = new Insets(10, 15, 10, 15);
+ container.add(statusPanel, constraints);
constraints.gridx = 0;
constraints.gridy = 2;
constraints.gridwidth = 1;
constraints.gridheight = 1;
- constraints.insets = new Insets( 10, 15, 5, 15 );
- container.add( buttonPanel, constraints );
+ constraints.insets = new Insets(10, 15, 5, 15);
+ container.add(buttonPanel, constraints);
this.pack();
- this.setResizable( false );
+ this.setResizable(false);
}
- public void setStatus( int progress, String status )
- {
- progressBar.setValue( progress );
- statusLabel.setText( status );
- statusLabel.setToolTipText( status );
- if( progress == MAXPROGRESS )
- {
- cancelButton.setEnabled( true );
- cancelButton.setText( "Close" );
+ public void setStatus(int progress, String status) {
+ progressBar.setValue(progress);
+ statusLabel.setText(status);
+ statusLabel.setToolTipText(status);
+
+ if (progress == MAXPROGRESS) {
+ cancelButton.setEnabled(true);
+ cancelButton.setText("Close");
}
- update( getGraphics() );
- mainWindow.update( mainWindow.getGraphics() );
+
+ update(getGraphics());
+ mainWindow.update(mainWindow.getGraphics());
}
- public void enableCancelButton( boolean enable )
- {
- if( enable )
- {
- cancelButton.setEnabled( true );
- cancelButton.setText( "Finish" );
- }
- else
- {
- cancelButton.setEnabled( false );
- cancelButton.setText( "Cancel" );
+ public void enableCancelButton(boolean enable) {
+ if (enable) {
+ cancelButton.setEnabled(true);
+ cancelButton.setText("Finish");
+ } else {
+ cancelButton.setEnabled(false);
+ cancelButton.setText("Cancel");
}
}
diff --git a/scripting/examples/java/Newsgroup/SubscribedNewsgroups.java b/scripting/examples/java/Newsgroup/SubscribedNewsgroups.java
index a4f230becee7..eb135a3e8f3d 100644
--- a/scripting/examples/java/Newsgroup/SubscribedNewsgroups.java
+++ b/scripting/examples/java/Newsgroup/SubscribedNewsgroups.java
@@ -28,21 +28,18 @@ public class SubscribedNewsgroups {
private static NewsGroup[] allSubscribed = null;
private static boolean windows = false;
- public static void main( String[] args ) {
+ public static void main(String[] args) {
// Test the class
SubscribedNewsgroups subscribed = new SubscribedNewsgroups();
NewsGroup allGroups[] = subscribed.getNewsGroups();
- if( allGroups == null )
- {
+ if (allGroups == null) {
System.out.println("Could not find subscribed newsgroups from mozilla/netscape mailrc files");
- }
- else
- {
- for( int i=0; i < allGroups.length; i++ )
- {
- System.out.println( "Hostname is: " + allGroups[i].getHostName() + " Newsgroup is: " + allGroups[i].getNewsgroupName() );
+ } else {
+ for (int i = 0; i < allGroups.length; i++) {
+ System.out.println("Hostname is: " + allGroups[i].getHostName() +
+ " Newsgroup is: " + allGroups[i].getNewsgroupName());
}
}
}
@@ -51,84 +48,87 @@ public class SubscribedNewsgroups {
// Only public method of the class
// Returns and array of unique NewsGroup objects
- public NewsGroup[] getNewsGroups()
- {
+ public NewsGroup[] getNewsGroups() {
windows = false;
- if( System.getProperty( "os.name" ).indexOf( "Windows" ) != -1 )
- {
+
+ if (System.getProperty("os.name").indexOf("Windows") != -1) {
windows = true;
}
String mozillaHome = "";
- if( windows )
- {
- mozillaHome = System.getProperty( "user.home" ) + System.getProperty( "file.separator" ) + "Application Data" + System.getProperty( "file.separator" ) + "Mozilla" + System.getProperty( "file.separator" ) + "Profiles";
- }
- else
- {
- mozillaHome = System.getProperty( "user.home" ) + System.getProperty( "file.separator" ) + ".mozilla";
+
+ if (windows) {
+ mozillaHome = System.getProperty("user.home") +
+ System.getProperty("file.separator") + "Application Data" +
+ System.getProperty("file.separator") + "Mozilla" +
+ System.getProperty("file.separator") + "Profiles";
+ } else {
+ mozillaHome = System.getProperty("user.home") +
+ System.getProperty("file.separator") + ".mozilla";
}
- if( !new File( mozillaHome ).isDirectory() )
- {
+
+ if (!new File(mozillaHome).isDirectory()) {
return null;
}
// Get all the profiles belonging to the user
- File profiles[] = findProfiles( new File ( mozillaHome ) );
- if( profiles.length < 1 )
- {
+ File profiles[] = findProfiles(new File(mozillaHome));
+
+ if (profiles.length < 1) {
return null;
}
// Get the News directory for each profile
File allNewsDirs[] = new File[ profiles.length ];
- for( int i=0; i < profiles.length; i++ ) {
- File newsDir = findNewsDir( profiles[i] );
+
+ for (int i = 0; i < profiles.length; i++) {
+ File newsDir = findNewsDir(profiles[i]);
allNewsDirs[i] = newsDir;
}
+
// Check that at least one News directory exists and remove nulls
boolean newsFound = false;
- for( int i=0; i < allNewsDirs.length; i++ ) {
- if( allNewsDirs[i] != null ) {
+
+ for (int i = 0; i < allNewsDirs.length; i++) {
+ if (allNewsDirs[i] != null) {
newsFound = true;
break;
}
}
- if( !newsFound )
- {
+
+ if (!newsFound) {
return null;
}
// Get all the mailrc files for each News directory
- File allMailrcs[] = findMailrcFiles( allNewsDirs );
- if( allMailrcs == null )
- {
+ File allMailrcs[] = findMailrcFiles(allNewsDirs);
+
+ if (allMailrcs == null) {
return null;
}
ArrayList<NewsGroup> subscribed = new ArrayList<NewsGroup>();
+
// Get the newsgroups in each mailrc file
- for( int i=0; i < allMailrcs.length; i++ )
- {
+ for (int i = 0; i < allMailrcs.length; i++) {
File mailrc = (File) allMailrcs[i];
- NewsGroup newsgroup[] = findNewsgroups( mailrc );
+ NewsGroup newsgroup[] = findNewsgroups(mailrc);
+
//if the Newsgroup has not already been added to the list
- for( int j=0; j < newsgroup.length; j++ )
- {
+ for (int j = 0; j < newsgroup.length; j++) {
// if newsgroup is unique then add to the list
- if( !listed( newsgroup[j], subscribed ) )
- {
- subscribed.addElement( newsgroup[j] );
+ if (!listed(newsgroup[j], subscribed)) {
+ subscribed.addElement(newsgroup[j]);
}
}
}
// Copy all unique Newsgroups into the global array
allSubscribed = new NewsGroup[ subscribed.size() ];
- subscribed.toArray( allSubscribed );
+ subscribed.toArray(allSubscribed);
+
// Test that at least one subscribed newsgroup has been found
- if( allSubscribed.length < 1 )
- {
+ if (allSubscribed.length < 1) {
return null;
}
@@ -139,16 +139,17 @@ public class SubscribedNewsgroups {
// Tests if the NewsGroup object has already been listed by another mailrc file
- private static boolean listed( NewsGroup newsgroup, ArrayList<NewsGroup> uniqueSubscription )
- {
- for(int i=0; i < uniqueSubscription.size(); i++)
- {
+ private static boolean listed(NewsGroup newsgroup,
+ ArrayList<NewsGroup> uniqueSubscription) {
+ for (int i = 0; i < uniqueSubscription.size(); i++) {
NewsGroup tempGroup = uniqueSubscription.elementAt(i);
+
// Test for duplication
- if(newsgroup.getHostName().equalsIgnoreCase( tempGroup.getHostName()) &&
- newsgroup.getNewsgroupName().equalsIgnoreCase( tempGroup.getNewsgroupName() ) )
+ if (newsgroup.getHostName().equalsIgnoreCase(tempGroup.getHostName()) &&
+ newsgroup.getNewsgroupName().equalsIgnoreCase(tempGroup.getNewsgroupName()))
return true;
}
+
return false;
}
@@ -156,8 +157,7 @@ public class SubscribedNewsgroups {
// Finds all the NewsGroups in an individual mailrc file
- private static NewsGroup[] findNewsgroups(File mailrcfile )
- {
+ private static NewsGroup[] findNewsgroups(File mailrcfile) {
String hostname = "";
String newsgroup = "";
@@ -168,46 +168,45 @@ public class SubscribedNewsgroups {
//If the newsgroup is not already contained in the global NewsGroup[] array then add it
String filename = mailrcfile.getPath();
- if( windows )
- {
+
+ if (windows) {
// Windows format "staroffice-news.germany.sun.com.rc"
int hostNameStart = filename.lastIndexOf("\\") + 1;
int hostNameEnd = filename.indexOf(".rc");
- hostname = filename.substring( hostNameStart, hostNameEnd );
- }
- else
- {
+ hostname = filename.substring(hostNameStart, hostNameEnd);
+ } else {
// Unix/Linux format "newsrc-staroffice-news.germany.sun.com"
int hostNameStart = filename.lastIndexOf("newsrc-") + 7;
- hostname = filename.substring( hostNameStart, filename.length() );
+ hostname = filename.substring(hostNameStart, filename.length());
}
// Assumes the content format in Window is the same as Unix/Linux (unknown at the moment)
// i.e. a list of newsgroups each ending with a ":"
LineNumberReader in = null;
+
try {
- in = new LineNumberReader( new FileReader( mailrcfile ) );
+ in = new LineNumberReader(new FileReader(mailrcfile));
ArrayList groups = new ArrayList();
String inString = "";
int line = 0;
- while( inString != null )
- {
- in.setLineNumber( line );
+
+ while (inString != null) {
+ in.setLineNumber(line);
inString = in.readLine();
line++;
- if( inString != null )
- {
+
+ if (inString != null) {
int newsgroupEnd = inString.indexOf(":");
- newsgroup = inString.substring( 0, newsgroupEnd );
- NewsGroup group = new NewsGroup( hostname, newsgroup );
- groups.addElement( group );
+ newsgroup = inString.substring(0, newsgroupEnd);
+ NewsGroup group = new NewsGroup(hostname, newsgroup);
+ groups.addElement(group);
}
}
+
mailrcNewsGroups = new NewsGroup[ groups.size() ];
groups.copyInto(mailrcNewsGroups);
in.close();
- }
- catch( IOException ioe ) {
+ } catch (IOException ioe) {
ioe.printStackTrace();
}
@@ -216,28 +215,25 @@ public class SubscribedNewsgroups {
// Finds all the mailrc files for all the given News directories
- private static File[] findMailrcFiles(File[] newsDirs)
- {
+ private static File[] findMailrcFiles(File[] newsDirs) {
ArrayList allFiles = new ArrayList();
- for( int i=0; i < newsDirs.length; i++ )
- {
- if( newsDirs[i] != null )
- {
- File mailrcFiles[] = newsDirs[i].listFiles( new VersionFilter() );
- if( mailrcFiles != null )
- {
- for( int j=0; j < mailrcFiles.length; j++ )
- {
- allFiles.addElement( mailrcFiles[j] );
+ for (int i = 0; i < newsDirs.length; i++) {
+ if (newsDirs[i] != null) {
+ File mailrcFiles[] = newsDirs[i].listFiles(new VersionFilter());
+
+ if (mailrcFiles != null) {
+ for (int j = 0; j < mailrcFiles.length; j++) {
+ allFiles.addElement(mailrcFiles[j]);
}
}
}
}
+
File allMailrcFiles[] = new File[ allFiles.size() ];
allFiles.copyInto(allMailrcFiles);
- if( allMailrcFiles.length == 0 ) {
+ if (allMailrcFiles.length == 0) {
return null;
}
@@ -246,18 +242,15 @@ public class SubscribedNewsgroups {
// Finds all profiles belonging to one user (can be more than one)
- private static File[] findProfiles(File start)
- {
+ private static File[] findProfiles(File start) {
// Get all files and directories in .mozilla
File allFiles[] = start.listFiles();
File[] dirs = new File[allFiles.length];
int dirCounter = 0;
// Remove files leaving directories only
- for(int i=0; i < allFiles.length; i++ )
- {
- if(allFiles[i].isDirectory())
- {
+ for (int i = 0; i < allFiles.length; i++) {
+ if (allFiles[i].isDirectory()) {
dirs[dirCounter] = allFiles[i];
dirCounter++;
}
@@ -265,8 +258,8 @@ public class SubscribedNewsgroups {
// Add each directory to a user profile array
File[] profileDirs = new File[dirCounter];
- for( int i=0; i < dirCounter; i++ )
- {
+
+ for (int i = 0; i < dirCounter; i++) {
profileDirs[i] = dirs[i];
}
@@ -276,97 +269,81 @@ public class SubscribedNewsgroups {
// Recursively searches for the News directory for a given profile directory
- private static File findNewsDir(File start)
- {
- File mailrcFile = null;
+ private static File findNewsDir(File start) {
+ File mailrcFile = null;
// File array containing all matches for the version filter ("News")
- File files[] = start.listFiles(new VersionFilter());
+ File files[] = start.listFiles(new VersionFilter());
+
// If the array is empty then no matches were found
- if (files.length == 0)
- {
+ if (files.length == 0) {
// File array of all the directories in File start
- File dirs[] = start.listFiles(new DirFilter());
+ File dirs[] = start.listFiles(new DirFilter());
+
// for each of the directories check for a match
- for (int i=0; i< dirs.length; i++)
- {
- mailrcFile = findNewsDir(dirs[i]);
- if (mailrcFile != null)
- {
+ for (int i = 0; i < dirs.length; i++) {
+ mailrcFile = findNewsDir(dirs[i]);
+
+ if (mailrcFile != null) {
// break the for loop
- break;
- }
- }
+ break;
}
- else
- {
+ }
+ } else {
// end recursion
// Check for a News directory inside the News directory (fix for bug)
// Original solution had only "mailrcFile = files[0];"
boolean noChildNews = true;
File checkChildNewsDirs[] = files[0].listFiles(new VersionFilter());
- if( checkChildNewsDirs != null )
- {
- for( int i=0; i < checkChildNewsDirs.length; i++ )
- {
- if( checkChildNewsDirs[i].getName().equals( "News" ) )
- {
+
+ if (checkChildNewsDirs != null) {
+ for (int i = 0; i < checkChildNewsDirs.length; i++) {
+ if (checkChildNewsDirs[i].getName().equals("News")) {
noChildNews = false;
break;
}
}
}
- if( noChildNews )
- {
- mailrcFile = files[0];
- }
- else
- {
- String childNewsPathName = files[0].getAbsolutePath() + System.getProperty( "file.separator" ) + "News";
- mailrcFile = new File( childNewsPathName );
+ if (noChildNews) {
+ mailrcFile = files[0];
+ } else {
+ String childNewsPathName = files[0].getAbsolutePath() +
+ System.getProperty("file.separator") + "News";
+ mailrcFile = new File(childNewsPathName);
}
}
// return a File representing the News dir in a profile
- return mailrcFile;
+ return mailrcFile;
}
}
-class DirFilter implements FileFilter
-{
- public boolean accept(File aFile)
- {
- return aFile.isDirectory();
- }
+class DirFilter implements FileFilter {
+ public boolean accept(File aFile) {
+ return aFile.isDirectory();
+ }
}
-class VersionFilter implements FileFilter
-{
- public boolean accept(File aFile)
- {
- if( System.getProperty( "os.name" ).indexOf( "Windows" ) != -1 )
- {
+class VersionFilter implements FileFilter {
+ public boolean accept(File aFile) {
+ if (System.getProperty("os.name").indexOf("Windows") != -1) {
if (aFile.getName().compareToIgnoreCase("News") == 0 ||
- aFile.getName().indexOf(".rc") != -1 )
- {
+ aFile.getName().indexOf(".rc") != -1) {
return true;
}
- }
- else
- {
+ } else {
if (aFile.getName().compareToIgnoreCase("News") == 0 ||
- aFile.getName().indexOf("newsrc") != -1 )
- {
+ aFile.getName().indexOf("newsrc") != -1) {
return true;
}
}
- return false;
- }
+ return false;
+ }
}
diff --git a/scripting/examples/java/debugger/DebugRunner.java b/scripting/examples/java/debugger/DebugRunner.java
index 4a5ee119608e..8e6c1438a8fc 100644
--- a/scripting/examples/java/debugger/DebugRunner.java
+++ b/scripting/examples/java/debugger/DebugRunner.java
@@ -31,22 +31,20 @@ import com.sun.star.script.framework.runtime.XScriptContext;
public class DebugRunner {
private static final String FILE_URL_PREFIX =
- System.getProperty("os.name").startsWith("Windows") == true ?
- "file:///" : "file://";
+ System.getProperty("os.name").startsWith("Windows") == true ?
+ "file:///" : "file://";
public void go(final XScriptContext xsctxt, String language, String uri,
- String filename) {
+ String filename) {
OOScriptDebugger debugger;
String path = "";
if (language.equals("JavaScript")) {
debugger = new OORhinoDebugger();
- }
- else if (language.equals("BeanShell")) {
+ } else if (language.equals("BeanShell")) {
debugger = new OOBeanShellDebugger();
- }
- else {
+ } else {
return;
}
@@ -60,14 +58,13 @@ public class DebugRunner {
if (!filename.equals("")) {
path = new File(f, filename).getAbsolutePath();
}
- }
- else {
+ } else {
path = f.getAbsolutePath();
}
}
+
debugger.go(xsctxt, path);
- }
- else {
+ } else {
if (!uri.endsWith("/")) {
uri += "/";
}
@@ -77,13 +74,12 @@ public class DebugRunner {
try {
is = PathUtils.getScriptFileStream(
- script, xsctxt.getComponentContext());
+ script, xsctxt.getComponentContext());
if (is != null) {
debugger.go(xsctxt, is);
}
- }
- catch (IOException ioe) {
+ } catch (IOException ioe) {
System.out.println("Error loading script: " + script);
}
}
diff --git a/scripting/examples/java/debugger/OOBeanShellDebugger.java b/scripting/examples/java/debugger/OOBeanShellDebugger.java
index a3286fbc0546..23811fd6aa49 100644
--- a/scripting/examples/java/debugger/OOBeanShellDebugger.java
+++ b/scripting/examples/java/debugger/OOBeanShellDebugger.java
@@ -50,7 +50,8 @@ import java.io.IOException;
import drafts.com.sun.star.script.framework.runtime.XScriptContext;
import bsh.Interpreter;
-public class OOBeanShellDebugger implements OOScriptDebugger, ActionListener, DocumentListener {
+public class OOBeanShellDebugger implements OOScriptDebugger, ActionListener,
+ DocumentListener {
private JFrame frame;
private JTextArea ta;
@@ -69,11 +70,10 @@ public class OOBeanShellDebugger implements OOScriptDebugger, ActionListener, Do
FileInputStream fis = new FileInputStream(filename);
this.filename = filename;
go(context, fis);
- }
- catch (IOException ioe) {
+ } catch (IOException ioe) {
JOptionPane.showMessageDialog(frame,
- "Error loading file: " + ioe.getMessage(),
- "Error", JOptionPane.ERROR_MESSAGE);
+ "Error loading file: " + ioe.getMessage(),
+ "Error", JOptionPane.ERROR_MESSAGE);
}
}
}
@@ -86,11 +86,10 @@ public class OOBeanShellDebugger implements OOScriptDebugger, ActionListener, Do
if (in != null) {
try {
loadFile(in);
- }
- catch (IOException ioe) {
+ } catch (IOException ioe) {
JOptionPane.showMessageDialog(frame,
- "Error loading stream: " + ioe.getMessage(),
- "Error", JOptionPane.ERROR_MESSAGE);
+ "Error loading stream: " + ioe.getMessage(),
+ "Error", JOptionPane.ERROR_MESSAGE);
}
}
}
@@ -111,8 +110,7 @@ public class OOBeanShellDebugger implements OOScriptDebugger, ActionListener, Do
try {
in.close();
- }
- catch (IOException ignore) {
+ } catch (IOException ignore) {
}
/* Update the GlyphGutter and add back the DocumentListener */
@@ -190,29 +188,28 @@ public class OOBeanShellDebugger implements OOScriptDebugger, ActionListener, Do
try {
interpreter.set("context", context);
interpreter.eval(ta.getText());
- }
- catch (bsh.EvalError err) {
+ } catch (bsh.EvalError err) {
currentPosition = err.getErrorLineNumber() - 1;
+
try {
// scroll to line of the error
int line = ta.getLineStartOffset(currentPosition);
Rectangle rect = ta.modelToView(line);
ta.scrollRectToVisible(rect);
- }
- catch (Exception e) {
+ } catch (Exception e) {
// couldn't scroll to line, do nothing
}
+
gg.repaint();
JOptionPane.showMessageDialog(frame, "Error at line " +
- String.valueOf(err.getErrorLineNumber()) +
- "\n\n: " + err.getErrorText(),
- "Error", JOptionPane.ERROR_MESSAGE);
- }
- catch (Exception e) {
+ String.valueOf(err.getErrorLineNumber()) +
+ "\n\n: " + err.getErrorText(),
+ "Error", JOptionPane.ERROR_MESSAGE);
+ } catch (Exception e) {
JOptionPane.showMessageDialog(frame,
- "Error: " + e.getMessage(),
- "Error", JOptionPane.ERROR_MESSAGE);
+ "Error: " + e.getMessage(),
+ "Error", JOptionPane.ERROR_MESSAGE);
}
}
};
@@ -226,6 +223,7 @@ public class OOBeanShellDebugger implements OOScriptDebugger, ActionListener, Do
if (f.isDirectory() || f.getName().endsWith(".bsh")) {
return true;
}
+
return false;
}
@@ -238,6 +236,7 @@ public class OOBeanShellDebugger implements OOScriptDebugger, ActionListener, Do
if (ret == JFileChooser.APPROVE_OPTION) {
filename = chooser.getSelectedFile().getAbsolutePath();
+
if (!filename.endsWith(".bsh")) {
filename += ".bsh";
}
@@ -251,24 +250,22 @@ public class OOBeanShellDebugger implements OOScriptDebugger, ActionListener, Do
}
FileOutputStream fos = null;
+
if (filename != null) {
try {
File f = new File(filename);
fos = new FileOutputStream(f);
String s = ta.getText();
fos.write(s.getBytes(), 0, s.length());
- }
- catch (IOException ioe) {
+ } catch (IOException ioe) {
JOptionPane.showMessageDialog(frame,
- "Error saving file: " + ioe.getMessage(),
- "Error", JOptionPane.ERROR_MESSAGE);
- }
- finally {
+ "Error saving file: " + ioe.getMessage(),
+ "Error", JOptionPane.ERROR_MESSAGE);
+ } finally {
if (fos != null) {
try {
fos.close();
- }
- catch (IOException ignore) {
+ } catch (IOException ignore) {
}
}
}
@@ -278,14 +275,11 @@ public class OOBeanShellDebugger implements OOScriptDebugger, ActionListener, Do
public void actionPerformed(ActionEvent e) {
if (e.getActionCommand().equals("Run")) {
startExecution();
- }
- else if (e.getActionCommand().equals("Close")) {
+ } else if (e.getActionCommand().equals("Close")) {
frame.dispose();
- }
- else if (e.getActionCommand().equals("Save")) {
+ } else if (e.getActionCommand().equals("Save")) {
saveTextArea();
- }
- else if (e.getActionCommand().equals("Clear")) {
+ } else if (e.getActionCommand().equals("Clear")) {
ta.setText("");
}
}
@@ -319,6 +313,7 @@ class GlyphGutter extends JComponent {
int lineCount = textArea.getLineCount() + 1;
String dummy = Integer.toString(lineCount);
+
if (dummy.length() < 2) {
dummy = DUMMY_STRING;
}
@@ -349,6 +344,7 @@ class GlyphGutter extends JComponent {
int startLine = clip.y / h;
int endLine = (clip.y + clip.height) / h + 1;
int width = getWidth();
+
if (endLine > lineCount) {
endLine = lineCount;
}
@@ -376,12 +372,15 @@ class GlyphGutter extends JComponent {
int dy = y;
arrow.addPoint(dx, dy + 3);
arrow.addPoint(dx + 5, dy + 3);
+
for (x = dx + 5; x <= dx + 10; x++, y++) {
arrow.addPoint(x, y);
}
+
for (x = dx + 9; x >= dx + 5; x--, y++) {
arrow.addPoint(x, y);
}
+
arrow.addPoint(dx + 5, dy + 7);
arrow.addPoint(dx, dy + 7);
diff --git a/scripting/examples/java/debugger/OORhinoDebugger.java b/scripting/examples/java/debugger/OORhinoDebugger.java
index b4858e40c278..f0d7aee3c0fa 100644
--- a/scripting/examples/java/debugger/OORhinoDebugger.java
+++ b/scripting/examples/java/debugger/OORhinoDebugger.java
@@ -52,32 +52,33 @@ public class OORhinoDebugger implements OOScriptDebugger {
try {
final Main sdb = new Main("Rhino JavaScript Debugger");
swingInvoke(new Runnable() {
- public void run() {
- sdb.pack();
- sdb.setSize(640, 640);
- sdb.setVisible(true);
- }
- });
+ public void run() {
+ sdb.pack();
+ sdb.setSize(640, 640);
+ sdb.setVisible(true);
+ }
+ });
sdb.setExitAction(new Runnable() {
- public void run() {
- sdb.dispose();
- }
- });
+ public void run() {
+ sdb.dispose();
+ }
+ });
Context.addContextListener(sdb);
sdb.setScopeProvider(new ScopeProvider() {
- public Scriptable getScope() {
- Context ctxt = Context.enter();
- ImporterTopLevel scope = new ImporterTopLevel(ctxt);
- Scriptable jsArgs = Context.toObject(xsctxt, scope);
- scope.put("XSCRIPTCONTEXT", scope, jsArgs);
- Context.exit();
- return scope;
- }
- });
+ public Scriptable getScope() {
+ Context ctxt = Context.enter();
+ ImporterTopLevel scope = new ImporterTopLevel(ctxt);
+ Scriptable jsArgs = Context.toObject(xsctxt, scope);
+ scope.put("XSCRIPTCONTEXT", scope, jsArgs);
+ Context.exit();
+ return scope;
+ }
+ });
return sdb;
} catch (Exception exc) {
exc.printStackTrace();
}
+
return null;
}
@@ -86,6 +87,7 @@ public class OORhinoDebugger implements OOScriptDebugger {
f.run();
return;
}
+
try {
SwingUtilities.invokeAndWait(f);
} catch (Exception exc) {
diff --git a/scripting/examples/java/selector/ScriptSelector.java b/scripting/examples/java/selector/ScriptSelector.java
index e0ff41e65cdf..ed3cfd441ab5 100644
--- a/scripting/examples/java/selector/ScriptSelector.java
+++ b/scripting/examples/java/selector/ScriptSelector.java
@@ -63,25 +63,23 @@ public class ScriptSelector {
private ScriptSelectorPanel selectorPanel;
- public ScriptSelector()
- {
+ public ScriptSelector() {
}
- public void showOrganizer(final XScriptContext ctxt)
- {
+ public void showOrganizer(final XScriptContext ctxt) {
try {
XBrowseNode root = getRootNode(ctxt);
final XScriptProvider msp =
(XScriptProvider)UnoRuntime.queryInterface(
- XScriptProvider.class, root);
+ XScriptProvider.class, root);
final JFrame client = new JFrame("Script");
selectorPanel = new ScriptSelectorPanel(root);
final JButton runButton, closeButton, createButton,
- editButton, deleteButton;
+ editButton, deleteButton;
runButton = new JButton("Run");
runButton.setEnabled(false);
@@ -111,27 +109,24 @@ public class ScriptSelector {
southButtons.add(deleteButton);
selectorPanel.tree.addTreeSelectionListener(
- new TreeSelectionListener() {
- public void valueChanged(TreeSelectionEvent e) {
- XBrowseNode xbn = selectorPanel.getSelection();
- XPropertySet props = (XPropertySet)
- UnoRuntime.queryInterface(XPropertySet.class, xbn);
-
- checkEnabled(props, "Creatable", createButton);
- checkEnabled(props, "Deletable", deleteButton);
- checkEnabled(props, "Editable", editButton);
-
- if (xbn != null &&
- xbn.getType() == BrowseNodeTypes.SCRIPT)
- {
- runButton.setEnabled(true);
- }
- else
- {
- runButton.setEnabled(false);
- }
+ new TreeSelectionListener() {
+ public void valueChanged(TreeSelectionEvent e) {
+ XBrowseNode xbn = selectorPanel.getSelection();
+ XPropertySet props = (XPropertySet)
+ UnoRuntime.queryInterface(XPropertySet.class, xbn);
+
+ checkEnabled(props, "Creatable", createButton);
+ checkEnabled(props, "Deletable", deleteButton);
+ checkEnabled(props, "Editable", editButton);
+
+ if (xbn != null &&
+ xbn.getType() == BrowseNodeTypes.SCRIPT) {
+ runButton.setEnabled(true);
+ } else {
+ runButton.setEnabled(false);
}
}
+ }
);
ActionListener listener = new ActionListener() {
@@ -149,36 +144,31 @@ public class ScriptSelector {
num[0] = new short[0];
script.invoke(new Object[0], num, out);
- }
- catch (Exception e) {
+ } catch (Exception e) {
e.printStackTrace();
}
- }
- else if (event.getSource() == closeButton) {
+ } else if (event.getSource() == closeButton) {
client.dispose();
- }
- else if (event.getSource() == editButton) {
+ } else if (event.getSource() == editButton) {
DefaultMutableTreeNode node =
- (DefaultMutableTreeNode)
- selectorPanel.tree.getLastSelectedPathComponent();
+ (DefaultMutableTreeNode)
+ selectorPanel.tree.getLastSelectedPathComponent();
if (node == null) return;
showEditor(ctxt, node);
- }
- else if (event.getSource() == createButton) {
+ } else if (event.getSource() == createButton) {
DefaultMutableTreeNode node =
- (DefaultMutableTreeNode)
- selectorPanel.tree.getLastSelectedPathComponent();
+ (DefaultMutableTreeNode)
+ selectorPanel.tree.getLastSelectedPathComponent();
if (node == null) return;
doCreate(ctxt, node);
- }
- else if (event.getSource() == deleteButton) {
+ } else if (event.getSource() == deleteButton) {
DefaultMutableTreeNode node =
- (DefaultMutableTreeNode)
- selectorPanel.tree.getLastSelectedPathComponent();
+ (DefaultMutableTreeNode)
+ selectorPanel.tree.getLastSelectedPathComponent();
if (node == null) return;
@@ -217,114 +207,96 @@ public class ScriptSelector {
client.setLocation(x, y);
client.show();
- }
- catch (com.sun.star.uno.RuntimeException rue) {
+ } catch (com.sun.star.uno.RuntimeException rue) {
rue.printStackTrace();
- }
- catch (java.lang.Exception e) {
+ } catch (java.lang.Exception e) {
e.printStackTrace();
}
}
public void showOrganizer(final XScriptContext ctxt,
- final com.sun.star.awt.MouseEvent e)
- {
+ final com.sun.star.awt.MouseEvent e) {
showOrganizer(ctxt);
}
public void showOrganizer(final XScriptContext ctxt,
- final com.sun.star.awt.ActionEvent e)
- {
+ final com.sun.star.awt.ActionEvent e) {
showOrganizer(ctxt);
}
private void doDelete(
- XScriptContext ctxt, DefaultMutableTreeNode node)
- {
+ XScriptContext ctxt, DefaultMutableTreeNode node) {
Object obj = node.getUserObject();
XInvocation inv =
(XInvocation)UnoRuntime.queryInterface(
- XInvocation.class, obj);
+ XInvocation.class, obj);
Object[] args = new Object[] { ctxt };
+
try {
Object result = inv.invoke("Deletable", args,
- new short[1][0], new Object[1][0]);
+ new short[1][0], new Object[1][0]);
- if (result != null && AnyConverter.toBoolean(result) == true)
- {
+ if (result != null && AnyConverter.toBoolean(result) == true) {
selectorPanel.removeNode(node);
}
- }
- catch (Exception e) {
+ } catch (Exception e) {
e.printStackTrace();
}
}
private void doCreate(
- XScriptContext ctxt, DefaultMutableTreeNode node)
- {
+ XScriptContext ctxt, DefaultMutableTreeNode node) {
Object obj = node.getUserObject();
XInvocation inv =
(XInvocation)UnoRuntime.queryInterface(
- XInvocation.class, obj);
+ XInvocation.class, obj);
Object[] args = new Object[] { ctxt };
+
try {
Object result = inv.invoke("Creatable", args,
- new short[1][0], new Object[1][0]);
+ new short[1][0], new Object[1][0]);
- if (result != null)
- {
+ if (result != null) {
XBrowseNode xbn = (XBrowseNode)
- AnyConverter.toObject(new Type(XBrowseNode.class), result);
+ AnyConverter.toObject(new Type(XBrowseNode.class), result);
selectorPanel.addNode(node, xbn);
}
- }
- catch (Exception e) {
+ } catch (Exception e) {
e.printStackTrace();
}
}
private void showEditor(
- XScriptContext ctxt, DefaultMutableTreeNode node)
- {
+ XScriptContext ctxt, DefaultMutableTreeNode node) {
Object obj = node.getUserObject();
XInvocation inv =
(XInvocation)UnoRuntime.queryInterface(
- XInvocation.class, obj);
+ XInvocation.class, obj);
Object[] args = new Object[] { ctxt };
+
try {
inv.invoke("Editable", args,
- new short[1][0], new Object[1][0]);
- }
- catch (Exception e) {
+ new short[1][0], new Object[1][0]);
+ } catch (Exception e) {
e.printStackTrace();
}
}
private void checkEnabled(XPropertySet props, String name,
- JButton button)
- {
+ JButton button) {
boolean enable = false;
- try
- {
- if (props != null)
- {
+ try {
+ if (props != null) {
Object o = props.getPropertyValue(name);
enable = AnyConverter.toBoolean(
- props.getPropertyValue(name));
+ props.getPropertyValue(name));
}
- }
- catch (com.sun.star.lang.IllegalArgumentException iae)
- {
+ } catch (com.sun.star.lang.IllegalArgumentException iae) {
// leave enable set to false
- }
- catch (com.sun.star.beans.UnknownPropertyException upe)
- {
+ } catch (com.sun.star.beans.UnknownPropertyException upe) {
// leave enable set to false
- }
- catch (com.sun.star.lang.WrappedTargetException wte)
- {
+ } catch (com.sun.star.lang.WrappedTargetException wte) {
// leave enable set to false
}
@@ -339,12 +311,13 @@ public class ScriptSelector {
XComponentContext xcc = ctxt.getComponentContext();
XMultiComponentFactory xmcf = xcc.getServiceManager();
XBrowseNodeFactory xBrowseFac = (XBrowseNodeFactory)
- UnoRuntime.queryInterface( XBrowseNodeFactory.class, xcc.getValueByName(
- "/singletons/com.sun.star.script.browse.theBrowseNodeFactory") );
+ UnoRuntime.queryInterface(XBrowseNodeFactory.class, xcc.getValueByName(
+ "/singletons/com.sun.star.script.browse.theBrowseNodeFactory"));
result = (XBrowseNode)UnoRuntime.queryInterface(
- XBrowseNode.class, xBrowseFac.createView( BrowseNodeFactoryViewTypes.MACROORGANIZER ) );
+ XBrowseNode.class, xBrowseFac.createView(
+ BrowseNodeFactoryViewTypes.MACROORGANIZER));
return result;
}
}
@@ -356,15 +329,14 @@ class ScriptSelectorPanel extends JPanel {
public JTree tree;
public DefaultTreeModel treeModel;
- public ScriptSelectorPanel(XBrowseNode root)
- {
+ public ScriptSelectorPanel(XBrowseNode root) {
this.myrootnode = root;
initUI();
}
public XBrowseNode getSelection() {
DefaultMutableTreeNode node = (DefaultMutableTreeNode)
- tree.getLastSelectedPathComponent();
+ tree.getLastSelectedPathComponent();
if (node == null) {
return null;
@@ -377,11 +349,11 @@ class ScriptSelectorPanel extends JPanel {
setLayout(new BorderLayout());
DefaultMutableTreeNode top =
- new DefaultMutableTreeNode(myrootnode) {
- public String toString() {
- return ((XBrowseNode)getUserObject()).getName();
- }
- };
+ new DefaultMutableTreeNode(myrootnode) {
+ public String toString() {
+ return ((XBrowseNode)getUserObject()).getName();
+ }
+ };
initNodes(myrootnode, top);
treeModel = new DefaultTreeModel(top);
tree = new JTree(treeModel);
@@ -389,13 +361,13 @@ class ScriptSelectorPanel extends JPanel {
tree.setCellRenderer(new ScriptTreeRenderer());
tree.getSelectionModel().setSelectionMode
- (TreeSelectionModel.SINGLE_TREE_SELECTION);
+ (TreeSelectionModel.SINGLE_TREE_SELECTION);
tree.addTreeSelectionListener(new TreeSelectionListener() {
public void valueChanged(TreeSelectionEvent e) {
XBrowseNode xbn = getSelection();
XPropertySet props = (XPropertySet)UnoRuntime.queryInterface(
- XPropertySet.class, xbn);
+ XPropertySet.class, xbn);
if (xbn == null) {
textField.setText("");
@@ -403,16 +375,16 @@ class ScriptSelectorPanel extends JPanel {
}
String str = xbn.getName();
- if (xbn.getType() == BrowseNodeTypes.SCRIPT && props != null)
- {
+
+ if (xbn.getType() == BrowseNodeTypes.SCRIPT && props != null) {
try {
str = AnyConverter.toString(
- props.getPropertyValue("URI"));
- }
- catch (Exception ignore) {
+ props.getPropertyValue("URI"));
+ } catch (Exception ignore) {
// default will be used
}
}
+
textField.setText(str);
}
});
@@ -426,6 +398,7 @@ class ScriptSelectorPanel extends JPanel {
public void removeNode(DefaultMutableTreeNode node) {
MutableTreeNode parent = (MutableTreeNode)(node.getParent());
+
if (parent != null) {
treeModel.removeNodeFromParent(node);
}
@@ -433,19 +406,18 @@ class ScriptSelectorPanel extends JPanel {
public void addNode(DefaultMutableTreeNode parent, XBrowseNode xbn) {
DefaultMutableTreeNode newNode =
- new DefaultMutableTreeNode(xbn) {
- public String toString() {
- return ((XBrowseNode)getUserObject()).getName();
- }
- };
+ new DefaultMutableTreeNode(xbn) {
+ public String toString() {
+ return ((XBrowseNode)getUserObject()).getName();
+ }
+ };
treeModel.insertNodeInto(newNode, parent, parent.getChildCount());
tree.scrollPathToVisible(new TreePath(newNode.getPath()));
}
private void initNodes(XBrowseNode parent, DefaultMutableTreeNode top) {
- if ( parent == null || parent.hasChildNodes() == false )
- {
+ if (parent == null || parent.hasChildNodes() == false) {
return;
}
@@ -454,22 +426,21 @@ class ScriptSelectorPanel extends JPanel {
try {
if (children != null) {
for (int i = 0; i < children.length; i++) {
- if ( children[i] == null )
- {
+ if (children[i] == null) {
continue;
}
+
DefaultMutableTreeNode newNode =
- new DefaultMutableTreeNode(children[i]) {
- public String toString() {
- return ((XBrowseNode)getUserObject()).getName();
- }
- };
+ new DefaultMutableTreeNode(children[i]) {
+ public String toString() {
+ return ((XBrowseNode)getUserObject()).getName();
+ }
+ };
top.add(newNode);
initNodes(children[i], newNode);
}
}
- }
- catch (java.lang.Exception e) {
+ } catch (java.lang.Exception e) {
e.printStackTrace();
}
}
@@ -488,28 +459,27 @@ class ScriptTreeRenderer extends DefaultTreeCellRenderer {
}
public Component getTreeCellRendererComponent(
- JTree tree,
- Object value,
- boolean sel,
- boolean expanded,
- boolean leaf,
- int row,
- boolean hasFocus) {
+ JTree tree,
+ Object value,
+ boolean sel,
+ boolean expanded,
+ boolean leaf,
+ int row,
+ boolean hasFocus) {
super.getTreeCellRendererComponent(
- tree, value, sel,
- expanded, leaf, row,
- hasFocus);
+ tree, value, sel,
+ expanded, leaf, row,
+ hasFocus);
DefaultMutableTreeNode node = (DefaultMutableTreeNode)value;
XBrowseNode xbn = (XBrowseNode)node.getUserObject();
+
if (xbn.getType() == BrowseNodeTypes.SCRIPT) {
setIcon(scriptIcon);
- }
- else if(xbn.getType() == BrowseNodeTypes.CONTAINER) {
+ } else if (xbn.getType() == BrowseNodeTypes.CONTAINER) {
setIcon(containerIcon);
- }
- else if(xbn.getType() == BrowseNodeTypes.ROOT) {
+ } else if (xbn.getType() == BrowseNodeTypes.ROOT) {
setIcon(sofficeIcon);
}
diff --git a/scripting/java/Framework/com/sun/star/script/framework/security/SecurityDialog.java b/scripting/java/Framework/com/sun/star/script/framework/security/SecurityDialog.java
index a1088260f470..e789d86dd647 100644
--- a/scripting/java/Framework/com/sun/star/script/framework/security/SecurityDialog.java
+++ b/scripting/java/Framework/com/sun/star/script/framework/security/SecurityDialog.java
@@ -49,23 +49,29 @@ import com.sun.star.uno.XComponentContext;
import com.sun.star.script.framework.log.LogUtils;
-public class SecurityDialog extends WeakBase implements XComponent, XServiceInfo, XDialog,
-XInitialization {
+public class SecurityDialog extends WeakBase implements XComponent,
+ XServiceInfo, XDialog,
+ XInitialization {
- static final String __serviceName = "com.sun.star.script.framework.security.SecurityDialog";
+ static final String __serviceName =
+ "com.sun.star.script.framework.security.SecurityDialog";
private static final String _label1Name = "Label1";
- private static final String _label1String = "This document contains macros. Do you want to allow these macros to be run?";
+ private static final String _label1String =
+ "This document contains macros. Do you want to allow these macros to be run?";
private static final String _label2Name = "Label2";
- private static final String _label2String = "This document contains macros. According to the security settings, the";
+ private static final String _label2String =
+ "This document contains macros. According to the security settings, the";
private static final String _label3Name = "Label3";
- private static final String _label3String = "macros in this document should not be run. Do you want to run them";
+ private static final String _label3String =
+ "macros in this document should not be run. Do you want to run them";
private static final String _label4Name = "Label4";
private static final String _label4String = "anyway?";
private static final String _checkBoxName = "CheckBox";
- private static final String _checkBoxString = "Add this directory to the list of secure paths: ";
+ private static final String _checkBoxString =
+ "Add this directory to the list of secure paths: ";
private static final String _label5Name = "Label5";
private static final String _title = "Run Macro";
@@ -120,9 +126,9 @@ XInitialization {
private boolean checkBoxDialog;
private short _checkBoxState = 0;
- private boolean extraPathLine=false;
- private String checkBoxPath="";
- private String checkBoxPath2="";
+ private boolean extraPathLine = false;
+ private String checkBoxPath = "";
+ private String checkBoxPath2 = "";
private static final int lineWrapLength = 21;
private static final int lineWrapH = 12;
private String _pushed = _doNotRunButtonName;
@@ -130,96 +136,89 @@ XInitialization {
private XComponentContext _xComponentContext;
private XDialog _xDialog;
- public SecurityDialog( XComponentContext xComponentContext )
- {
- LogUtils.DEBUG( "SecurityDialog ctor" );
+ public SecurityDialog(XComponentContext xComponentContext) {
+ LogUtils.DEBUG("SecurityDialog ctor");
_xComponentContext = xComponentContext;
}
- public void initialize( Object[] args ) throws RuntimeException
- {
- LogUtils.DEBUG( "SecurityDialog init" );
+ public void initialize(Object[] args) throws RuntimeException {
+ LogUtils.DEBUG("SecurityDialog init");
+
// figure out if we need a checkbox
- if ( args.length == 1 && AnyConverter.isString( args[0] ) )
- {
+ if (args.length == 1 && AnyConverter.isString(args[0])) {
//check args is a path
// set checkBoxPath with the arg
- LogUtils.DEBUG( "checkbox" );
- try
- {
- checkBoxPath = AnyConverter.toString( args[0] );
- }
- catch ( IllegalArgumentException e )
- {
- throw new RuntimeException( "SecurityDialog::initialize: " + e.getMessage() );
+ LogUtils.DEBUG("checkbox");
+
+ try {
+ checkBoxPath = AnyConverter.toString(args[0]);
+ } catch (IllegalArgumentException e) {
+ throw new RuntimeException("SecurityDialog::initialize: " + e.getMessage());
}
- LogUtils.DEBUG( "path: " + checkBoxPath );
+
+ LogUtils.DEBUG("path: " + checkBoxPath);
checkBoxDialog = true;
- if( checkBoxPath.length() > lineWrapLength )
- {
+
+ if (checkBoxPath.length() > lineWrapLength) {
extraPathLine = true;
cbIncrH += lineWrapH;
- checkBoxPath2 = checkBoxPath.substring( lineWrapLength );
- checkBoxPath = checkBoxPath.substring( 0, lineWrapLength );
+ checkBoxPath2 = checkBoxPath.substring(lineWrapLength);
+ checkBoxPath = checkBoxPath.substring(0, lineWrapLength);
}
- }
- else
- {
- LogUtils.DEBUG( "no checkbox: # of args=" +
- args.length );
+ } else {
+ LogUtils.DEBUG("no checkbox: # of args=" +
+ args.length);
cbIncrW = 0;
cbIncrH = 0;
checkBoxDialog = false;
}
// now try and create the dialog
- try
- {
+ try {
_xDialog = createDialog();
- }
- catch ( com.sun.star.uno.Exception e )
- {
- LogUtils.DEBUG( "Couldn't create dialog" );
- LogUtils.DEBUG( "uno message: " + e.getMessage());
- throw new RuntimeException( e.getMessage() );
- }
- catch ( Exception e )
- {
- LogUtils.DEBUG( "Couldn't create dialog" );
- LogUtils.DEBUG( "message: " + e.getMessage());
- throw new RuntimeException( e.getMessage() );
+ } catch (com.sun.star.uno.Exception e) {
+ LogUtils.DEBUG("Couldn't create dialog");
+ LogUtils.DEBUG("uno message: " + e.getMessage());
+ throw new RuntimeException(e.getMessage());
+ } catch (Exception e) {
+ LogUtils.DEBUG("Couldn't create dialog");
+ LogUtils.DEBUG("message: " + e.getMessage());
+ throw new RuntimeException(e.getMessage());
}
}
// static component operations
- public static XSingleServiceFactory __getServiceFactory( String implName,
- XMultiServiceFactory multiFactory,
- XRegistryKey regKey ) {
+ public static XSingleServiceFactory __getServiceFactory(String implName,
+ XMultiServiceFactory multiFactory,
+ XRegistryKey regKey) {
XSingleServiceFactory xSingleServiceFactory = null;
- if ( implName.equals( SecurityDialog.class.getName() ) ) {
+
+ if (implName.equals(SecurityDialog.class.getName())) {
xSingleServiceFactory = FactoryHelper.getServiceFactory(
- SecurityDialog.class, SecurityDialog.__serviceName, multiFactory, regKey );
+ SecurityDialog.class, SecurityDialog.__serviceName, multiFactory, regKey);
}
+
return xSingleServiceFactory;
}
// XServiceInfo
- public String getImplementationName( ) {
+ public String getImplementationName() {
return getClass().getName();
}
// XServiceInfo
- public boolean supportsService( /*IN*/String serviceName ) {
- if ( serviceName.equals( __serviceName))
+ public boolean supportsService(/*IN*/String serviceName) {
+ if (serviceName.equals(__serviceName))
return true;
+
return false;
}
// XServiceInfo
- public String[] getSupportedServiceNames( ) {
- String[] retValue= new String[0];
+ public String[] getSupportedServiceNames() {
+ String[] retValue = new String[0];
retValue[0] = __serviceName;
return retValue;
}
@@ -230,299 +229,292 @@ XInitialization {
private XDialog createDialog() throws com.sun.star.uno.Exception {
// get the service manager from the component context
- XMultiComponentFactory xMultiComponentFactory = _xComponentContext.getServiceManager();
+ XMultiComponentFactory xMultiComponentFactory =
+ _xComponentContext.getServiceManager();
// create the dialog model and set the properties
Object dialogModel = xMultiComponentFactory.createInstanceWithContext(
- "com.sun.star.awt.UnoControlDialogModel", _xComponentContext );
+ "com.sun.star.awt.UnoControlDialogModel", _xComponentContext);
XPropertySet xPSetDialog = UnoRuntime.queryInterface(
- XPropertySet.class, dialogModel );
- xPSetDialog.setPropertyValue( "PositionX", Integer.valueOf( dialogX) );
- xPSetDialog.setPropertyValue( "PositionY", Integer.valueOf( dialogY));
- xPSetDialog.setPropertyValue( "Width", Integer.valueOf( dialogW+cbIncrW ));
- xPSetDialog.setPropertyValue( "Height", Integer.valueOf( dialogH+cbIncrH ));
- xPSetDialog.setPropertyValue( "Title", _title );
+ XPropertySet.class, dialogModel);
+ xPSetDialog.setPropertyValue("PositionX", Integer.valueOf(dialogX));
+ xPSetDialog.setPropertyValue("PositionY", Integer.valueOf(dialogY));
+ xPSetDialog.setPropertyValue("Width", Integer.valueOf(dialogW + cbIncrW));
+ xPSetDialog.setPropertyValue("Height", Integer.valueOf(dialogH + cbIncrH));
+ xPSetDialog.setPropertyValue("Title", _title);
// get the service manager from the dialog model
XMultiServiceFactory xMultiServiceFactory = UnoRuntime.queryInterface(
- XMultiServiceFactory.class, dialogModel );
+ XMultiServiceFactory.class, dialogModel);
// create the Run Macro button model and set the properties
Object runButtonModel = xMultiServiceFactory.createInstance(
- "com.sun.star.awt.UnoControlButtonModel" );
+ "com.sun.star.awt.UnoControlButtonModel");
XPropertySet xPSetButton = UnoRuntime.queryInterface(
- XPropertySet.class, runButtonModel );
- LogUtils.DEBUG("run: x="+(((dialogW+cbIncrW)/2)-runButtonW -1) );
- LogUtils.DEBUG("run: y="+(dialogH+cbIncrH-runButtonH-1));
- xPSetButton.setPropertyValue( "PositionX", Integer.valueOf( (((dialogW+cbIncrW)/2)-runButtonW -1) ));
- xPSetButton.setPropertyValue( "PositionY", Integer.valueOf( dialogH+cbIncrH-runButtonH-1));
- xPSetButton.setPropertyValue( "Width", Integer.valueOf( runButtonW ));
- xPSetButton.setPropertyValue( "Height", Integer.valueOf( runButtonH ));
- xPSetButton.setPropertyValue( "Name", _runButtonName );
- xPSetButton.setPropertyValue( "TabIndex", Short.valueOf( (short)1 ) );
- xPSetButton.setPropertyValue( "Label", _runMacro );
+ XPropertySet.class, runButtonModel);
+ LogUtils.DEBUG("run: x=" + (((dialogW + cbIncrW) / 2) - runButtonW - 1));
+ LogUtils.DEBUG("run: y=" + (dialogH + cbIncrH - runButtonH - 1));
+ xPSetButton.setPropertyValue("PositionX",
+ Integer.valueOf((((dialogW + cbIncrW) / 2) - runButtonW - 1)));
+ xPSetButton.setPropertyValue("PositionY",
+ Integer.valueOf(dialogH + cbIncrH - runButtonH - 1));
+ xPSetButton.setPropertyValue("Width", Integer.valueOf(runButtonW));
+ xPSetButton.setPropertyValue("Height", Integer.valueOf(runButtonH));
+ xPSetButton.setPropertyValue("Name", _runButtonName);
+ xPSetButton.setPropertyValue("TabIndex", Short.valueOf((short)1));
+ xPSetButton.setPropertyValue("Label", _runMacro);
// create the Dont Run Macro button model and set the properties
Object doNotRunButtonModel = xMultiServiceFactory.createInstance(
- "com.sun.star.awt.UnoControlButtonModel" );
+ "com.sun.star.awt.UnoControlButtonModel");
xPSetButton = UnoRuntime.queryInterface(
- XPropertySet.class, doNotRunButtonModel );
- LogUtils.DEBUG("dontrun: x="+(((dialogW+cbIncrW)/2)-1) );
- LogUtils.DEBUG("dontrun: y="+(dialogH+cbIncrH-doNotRunButtonH-1 ));
- xPSetButton.setPropertyValue( "PositionX", Integer.valueOf( (((dialogW+cbIncrW)/2) + 1) ));
- xPSetButton.setPropertyValue( "PositionY", Integer.valueOf( (dialogH+cbIncrH-doNotRunButtonH-1 ) ));
- xPSetButton.setPropertyValue( "Width", Integer.valueOf( doNotRunButtonW ));
- xPSetButton.setPropertyValue( "Height", Integer.valueOf( doNotRunButtonH ));
- xPSetButton.setPropertyValue( "Name", _doNotRunButtonName );
- xPSetButton.setPropertyValue( "TabIndex", Short.valueOf( (short)0 ) );
- xPSetButton.setPropertyValue( "Label", _doNotRunMacro );
+ XPropertySet.class, doNotRunButtonModel);
+ LogUtils.DEBUG("dontrun: x=" + (((dialogW + cbIncrW) / 2) - 1));
+ LogUtils.DEBUG("dontrun: y=" + (dialogH + cbIncrH - doNotRunButtonH - 1));
+ xPSetButton.setPropertyValue("PositionX",
+ Integer.valueOf((((dialogW + cbIncrW) / 2) + 1)));
+ xPSetButton.setPropertyValue("PositionY",
+ Integer.valueOf((dialogH + cbIncrH - doNotRunButtonH - 1)));
+ xPSetButton.setPropertyValue("Width", Integer.valueOf(doNotRunButtonW));
+ xPSetButton.setPropertyValue("Height", Integer.valueOf(doNotRunButtonH));
+ xPSetButton.setPropertyValue("Name", _doNotRunButtonName);
+ xPSetButton.setPropertyValue("TabIndex", Short.valueOf((short)0));
+ xPSetButton.setPropertyValue("Label", _doNotRunMacro);
// insert the control models into the dialog model
XNameContainer xNameCont = UnoRuntime.queryInterface(
- XNameContainer.class, dialogModel );
- xNameCont.insertByName( _runButtonName, runButtonModel );
- xNameCont.insertByName( _doNotRunButtonName, doNotRunButtonModel );
+ XNameContainer.class, dialogModel);
+ xNameCont.insertByName(_runButtonName, runButtonModel);
+ xNameCont.insertByName(_doNotRunButtonName, doNotRunButtonModel);
- if ( checkBoxDialog )
- {
+ if (checkBoxDialog) {
LogUtils.DEBUG("creating label & checkbox");
// create the label model and set the properties
Object label2Model = xMultiServiceFactory.createInstance(
- "com.sun.star.awt.UnoControlFixedTextModel" );
+ "com.sun.star.awt.UnoControlFixedTextModel");
XPropertySet xPSetLabel = UnoRuntime.queryInterface(
- XPropertySet.class, label2Model );
- xPSetLabel.setPropertyValue( "PositionX", Integer.valueOf( label2X ));
- xPSetLabel.setPropertyValue( "PositionY", Integer.valueOf( label2Y ));
- xPSetLabel.setPropertyValue( "Width", Integer.valueOf( label2W ));
- xPSetLabel.setPropertyValue( "Height", Integer.valueOf( label2H ));
- xPSetLabel.setPropertyValue( "Name", _label2Name );
- xPSetLabel.setPropertyValue( "TabIndex", Short.valueOf( (short)1 ) );
- xPSetLabel.setPropertyValue( "Label", _label2String );
+ XPropertySet.class, label2Model);
+ xPSetLabel.setPropertyValue("PositionX", Integer.valueOf(label2X));
+ xPSetLabel.setPropertyValue("PositionY", Integer.valueOf(label2Y));
+ xPSetLabel.setPropertyValue("Width", Integer.valueOf(label2W));
+ xPSetLabel.setPropertyValue("Height", Integer.valueOf(label2H));
+ xPSetLabel.setPropertyValue("Name", _label2Name);
+ xPSetLabel.setPropertyValue("TabIndex", Short.valueOf((short)1));
+ xPSetLabel.setPropertyValue("Label", _label2String);
// create the label model and set the properties
Object label3Model = xMultiServiceFactory.createInstance(
- "com.sun.star.awt.UnoControlFixedTextModel" );
+ "com.sun.star.awt.UnoControlFixedTextModel");
XPropertySet xPSetLabel3 = UnoRuntime.queryInterface(
- XPropertySet.class, label3Model );
- xPSetLabel3.setPropertyValue( "PositionX", Integer.valueOf( label3X ));
- xPSetLabel3.setPropertyValue( "PositionY", Integer.valueOf( label3Y ));
- xPSetLabel3.setPropertyValue( "Width", Integer.valueOf( label3W ));
- xPSetLabel3.setPropertyValue( "Height", Integer.valueOf( label3H ));
- xPSetLabel3.setPropertyValue( "Name", _label3Name );
- xPSetLabel3.setPropertyValue( "TabIndex", Short.valueOf( (short)1 ) );
- xPSetLabel3.setPropertyValue( "Label", _label3String );
+ XPropertySet.class, label3Model);
+ xPSetLabel3.setPropertyValue("PositionX", Integer.valueOf(label3X));
+ xPSetLabel3.setPropertyValue("PositionY", Integer.valueOf(label3Y));
+ xPSetLabel3.setPropertyValue("Width", Integer.valueOf(label3W));
+ xPSetLabel3.setPropertyValue("Height", Integer.valueOf(label3H));
+ xPSetLabel3.setPropertyValue("Name", _label3Name);
+ xPSetLabel3.setPropertyValue("TabIndex", Short.valueOf((short)1));
+ xPSetLabel3.setPropertyValue("Label", _label3String);
// create the label model and set the properties
Object label4Model = xMultiServiceFactory.createInstance(
- "com.sun.star.awt.UnoControlFixedTextModel" );
+ "com.sun.star.awt.UnoControlFixedTextModel");
XPropertySet xPSetLabel4 = UnoRuntime.queryInterface(
- XPropertySet.class, label4Model );
- xPSetLabel4.setPropertyValue( "PositionX", Integer.valueOf( label4X ));
- xPSetLabel4.setPropertyValue( "PositionY", Integer.valueOf( label4Y ));
- xPSetLabel4.setPropertyValue( "Width", Integer.valueOf( label4W ));
- xPSetLabel4.setPropertyValue( "Height", Integer.valueOf( label4H ));
- xPSetLabel4.setPropertyValue( "Name", _label4Name );
- xPSetLabel4.setPropertyValue( "TabIndex", Short.valueOf( (short)1 ) );
- xPSetLabel4.setPropertyValue( "Label", _label4String );
+ XPropertySet.class, label4Model);
+ xPSetLabel4.setPropertyValue("PositionX", Integer.valueOf(label4X));
+ xPSetLabel4.setPropertyValue("PositionY", Integer.valueOf(label4Y));
+ xPSetLabel4.setPropertyValue("Width", Integer.valueOf(label4W));
+ xPSetLabel4.setPropertyValue("Height", Integer.valueOf(label4H));
+ xPSetLabel4.setPropertyValue("Name", _label4Name);
+ xPSetLabel4.setPropertyValue("TabIndex", Short.valueOf((short)1));
+ xPSetLabel4.setPropertyValue("Label", _label4String);
// create the checkbox model and set the properties
Object checkBoxModel = xMultiServiceFactory.createInstance(
- "com.sun.star.awt.UnoControlCheckBoxModel" );
+ "com.sun.star.awt.UnoControlCheckBoxModel");
XPropertySet xPSetCheckBox = UnoRuntime.queryInterface(
- XPropertySet.class, checkBoxModel );
- xPSetCheckBox.setPropertyValue( "PositionX", Integer.valueOf( checkBoxX ));
- xPSetCheckBox.setPropertyValue( "PositionY", Integer.valueOf( checkBoxY ));
- xPSetCheckBox.setPropertyValue( "Width", Integer.valueOf( checkBoxW ));
- xPSetCheckBox.setPropertyValue( "Height", Integer.valueOf( checkBoxH ));
- xPSetCheckBox.setPropertyValue( "State", Short.valueOf((short)0) );
- xPSetCheckBox.setPropertyValue( "Name", _checkBoxName );
- xPSetCheckBox.setPropertyValue( "TabIndex", Short.valueOf( (short)1 ) );
- xPSetCheckBox.setPropertyValue( "Label", _checkBoxString +checkBoxPath );
+ XPropertySet.class, checkBoxModel);
+ xPSetCheckBox.setPropertyValue("PositionX", Integer.valueOf(checkBoxX));
+ xPSetCheckBox.setPropertyValue("PositionY", Integer.valueOf(checkBoxY));
+ xPSetCheckBox.setPropertyValue("Width", Integer.valueOf(checkBoxW));
+ xPSetCheckBox.setPropertyValue("Height", Integer.valueOf(checkBoxH));
+ xPSetCheckBox.setPropertyValue("State", Short.valueOf((short)0));
+ xPSetCheckBox.setPropertyValue("Name", _checkBoxName);
+ xPSetCheckBox.setPropertyValue("TabIndex", Short.valueOf((short)1));
+ xPSetCheckBox.setPropertyValue("Label", _checkBoxString + checkBoxPath);
// insert the control models into the dialog model
- xNameCont.insertByName( _label2Name, label2Model );
- xNameCont.insertByName( _label3Name, label3Model );
- xNameCont.insertByName( _label4Name, label4Model );
- xNameCont.insertByName( _checkBoxName, checkBoxModel );
-
- if ( extraPathLine )
- {
- // create the label model and set the properties
- Object label5Model = xMultiServiceFactory.createInstance(
- "com.sun.star.awt.UnoControlFixedTextModel" );
- XPropertySet xPSetLabel5 = UnoRuntime.queryInterface(
- XPropertySet.class, label5Model );
- xPSetLabel5.setPropertyValue( "PositionX", Integer.valueOf( label5X ));
- xPSetLabel5.setPropertyValue( "PositionY", Integer.valueOf( label5Y ));
- xPSetLabel5.setPropertyValue( "Width", Integer.valueOf( label5W ));
- xPSetLabel5.setPropertyValue( "Height", Integer.valueOf( label5H ));
- xPSetLabel5.setPropertyValue( "Name", _label5Name );
- xPSetLabel5.setPropertyValue( "TabIndex", Short.valueOf( (short)1 ) );
- xPSetLabel5.setPropertyValue( "Label", checkBoxPath2 );
- xNameCont.insertByName( _label5Name, label5Model );
+ xNameCont.insertByName(_label2Name, label2Model);
+ xNameCont.insertByName(_label3Name, label3Model);
+ xNameCont.insertByName(_label4Name, label4Model);
+ xNameCont.insertByName(_checkBoxName, checkBoxModel);
+
+ if (extraPathLine) {
+ // create the label model and set the properties
+ Object label5Model = xMultiServiceFactory.createInstance(
+ "com.sun.star.awt.UnoControlFixedTextModel");
+ XPropertySet xPSetLabel5 = UnoRuntime.queryInterface(
+ XPropertySet.class, label5Model);
+ xPSetLabel5.setPropertyValue("PositionX", Integer.valueOf(label5X));
+ xPSetLabel5.setPropertyValue("PositionY", Integer.valueOf(label5Y));
+ xPSetLabel5.setPropertyValue("Width", Integer.valueOf(label5W));
+ xPSetLabel5.setPropertyValue("Height", Integer.valueOf(label5H));
+ xPSetLabel5.setPropertyValue("Name", _label5Name);
+ xPSetLabel5.setPropertyValue("TabIndex", Short.valueOf((short)1));
+ xPSetLabel5.setPropertyValue("Label", checkBoxPath2);
+ xNameCont.insertByName(_label5Name, label5Model);
}
- }
- else
- {
+ } else {
// create the label model and set the properties
Object labelModel = xMultiServiceFactory.createInstance(
- "com.sun.star.awt.UnoControlFixedTextModel" );
+ "com.sun.star.awt.UnoControlFixedTextModel");
XPropertySet xPSetLabel = UnoRuntime.queryInterface(
- XPropertySet.class, labelModel );
- xPSetLabel.setPropertyValue( "PositionX", Integer.valueOf( label1X ));
- xPSetLabel.setPropertyValue( "PositionY", Integer.valueOf( label1Y ));
- xPSetLabel.setPropertyValue( "Width", Integer.valueOf( label1W ));
- xPSetLabel.setPropertyValue( "Height", Integer.valueOf( label1H ));
- xPSetLabel.setPropertyValue( "Name", _label1Name );
- xPSetLabel.setPropertyValue( "TabIndex", Short.valueOf( (short)1 ) );
- xPSetLabel.setPropertyValue( "Label", _label1String );
+ XPropertySet.class, labelModel);
+ xPSetLabel.setPropertyValue("PositionX", Integer.valueOf(label1X));
+ xPSetLabel.setPropertyValue("PositionY", Integer.valueOf(label1Y));
+ xPSetLabel.setPropertyValue("Width", Integer.valueOf(label1W));
+ xPSetLabel.setPropertyValue("Height", Integer.valueOf(label1H));
+ xPSetLabel.setPropertyValue("Name", _label1Name);
+ xPSetLabel.setPropertyValue("TabIndex", Short.valueOf((short)1));
+ xPSetLabel.setPropertyValue("Label", _label1String);
// insert the control models into the dialog model
- xNameCont.insertByName( _label1Name, labelModel );
+ xNameCont.insertByName(_label1Name, labelModel);
}
// create the dialog control and set the model
Object dialog = xMultiComponentFactory.createInstanceWithContext(
- "com.sun.star.awt.UnoControlDialog", _xComponentContext );
+ "com.sun.star.awt.UnoControlDialog", _xComponentContext);
XControl xControl = UnoRuntime.queryInterface(
- XControl.class, dialog );
+ XControl.class, dialog);
XControlModel xControlModel = UnoRuntime.queryInterface(
- XControlModel.class, dialogModel );
- xControl.setModel( xControlModel );
+ XControlModel.class, dialogModel);
+ xControl.setModel(xControlModel);
// add an action listener to the button control
XControlContainer xControlCont = UnoRuntime.queryInterface(
- XControlContainer.class, dialog );
+ XControlContainer.class, dialog);
// Add to yes button
- Object objectButton = xControlCont.getControl( _runButtonName );
+ Object objectButton = xControlCont.getControl(_runButtonName);
XButton xButton = UnoRuntime.queryInterface(
- XButton.class, objectButton );
- xButton.addActionListener( new ActionListenerImpl( _runButtonName ) );
+ XButton.class, objectButton);
+ xButton.addActionListener(new ActionListenerImpl(_runButtonName));
// add to no button
- objectButton = xControlCont.getControl( _doNotRunButtonName );
+ objectButton = xControlCont.getControl(_doNotRunButtonName);
xButton = UnoRuntime.queryInterface(
- XButton.class, objectButton );
- xButton.addActionListener( new ActionListenerImpl( _doNotRunButtonName ) );
+ XButton.class, objectButton);
+ xButton.addActionListener(new ActionListenerImpl(_doNotRunButtonName));
- if ( checkBoxDialog )
- {
+ if (checkBoxDialog) {
// add to checkbox
- Object objectCheckBox = xControlCont.getControl( _checkBoxName );
+ Object objectCheckBox = xControlCont.getControl(_checkBoxName);
XCheckBox xCheckBox = UnoRuntime.queryInterface(
- XCheckBox.class, objectCheckBox );
- xCheckBox.addItemListener(new ItemListenerImpl( xControlCont ) );
+ XCheckBox.class, objectCheckBox);
+ xCheckBox.addItemListener(new ItemListenerImpl(xControlCont));
}
// create a peer
Object toolkit = xMultiComponentFactory.createInstanceWithContext(
- "com.sun.star.awt.ExtToolkit", _xComponentContext );
+ "com.sun.star.awt.ExtToolkit", _xComponentContext);
XToolkit xToolkit = UnoRuntime.queryInterface(
- XToolkit.class, toolkit );
+ XToolkit.class, toolkit);
XWindow xWindow = UnoRuntime.queryInterface(
- XWindow.class, xControl );
- xWindow.setVisible( false );
- xControl.createPeer( xToolkit, null );
+ XWindow.class, xControl);
+ xWindow.setVisible(false);
+ xControl.createPeer(xToolkit, null);
// return the dialog
XDialog xDialog = UnoRuntime.queryInterface(
- XDialog.class, dialog );
+ XDialog.class, dialog);
return xDialog;
}
- public short execute()
- {
+ public short execute() {
short result = 0;
_pushed = _doNotRunButtonName;
- LogUtils.DEBUG("*DF* Before execute " );
+ LogUtils.DEBUG("*DF* Before execute ");
_xDialog.execute();
- LogUtils.DEBUG("*DF* After execute " );
+ LogUtils.DEBUG("*DF* After execute ");
- if ( _pushed.equals( _runButtonName ) )
- {
+ if (_pushed.equals(_runButtonName)) {
result += 1;
}
- if ( _checkBoxState == 1 )
- {
- result +=2;
+
+ if (_checkBoxState == 1) {
+ result += 2;
}
+
return result;
}
- public void endExecute()
- {
+ public void endExecute() {
_xDialog.endExecute();
}
- public String getTitle()
- {
+ public String getTitle() {
return _xDialog.getTitle();
- }
+ }
- public void setTitle( String Title )
- {
- _xDialog.setTitle( Title );
- }
+ public void setTitle(String Title) {
+ _xDialog.setTitle(Title);
+ }
- public void dispose ()
- {
+ public void dispose() {
XComponent xComponent = UnoRuntime.queryInterface(
- XComponent.class, _xDialog );
- xComponent.dispose();
- }
+ XComponent.class, _xDialog);
+ xComponent.dispose();
+ }
- public void addEventListener ( com.sun.star.lang.XEventListener xListener )
- {
+ public void addEventListener(com.sun.star.lang.XEventListener xListener) {
XComponent xComponent = UnoRuntime.queryInterface(
- XComponent.class, _xDialog );
- xComponent.addEventListener( xListener );
- }
+ XComponent.class, _xDialog);
+ xComponent.addEventListener(xListener);
+ }
- public void removeEventListener ( com.sun.star.lang.XEventListener aListener )
- {
+ public void removeEventListener(com.sun.star.lang.XEventListener aListener) {
XComponent xComponent = UnoRuntime.queryInterface(
- XComponent.class, _xDialog );
- xComponent.removeEventListener( aListener );
- }
+ XComponent.class, _xDialog);
+ xComponent.removeEventListener(aListener);
+ }
private class ActionListenerImpl implements com.sun.star.awt.XActionListener {
private String _buttonName;
- private ActionListenerImpl( String buttonName ) {
+ private ActionListenerImpl(String buttonName) {
_buttonName = buttonName;
}
// XEventListener
- public void disposing( EventObject eventObject ) {
+ public void disposing(EventObject eventObject) {
}
// XActionListener
- public void actionPerformed( ActionEvent actionEvent ) {
- _pushed = _buttonName;
- LogUtils.DEBUG("** Button pushed ->" + _pushed );
+ public void actionPerformed(ActionEvent actionEvent) {
+ _pushed = _buttonName;
+ LogUtils.DEBUG("** Button pushed ->" + _pushed);
- _xDialog.endExecute();
+ _xDialog.endExecute();
}
}
private class ItemListenerImpl implements com.sun.star.awt.XItemListener {
private XCheckBox _xCheckBox;
- private ItemListenerImpl( XControlContainer xControlCont ) {
- Object objectCheckBox = xControlCont.getControl( _checkBoxName );
+ private ItemListenerImpl(XControlContainer xControlCont) {
+ Object objectCheckBox = xControlCont.getControl(_checkBoxName);
_xCheckBox = UnoRuntime.queryInterface(
- XCheckBox.class, objectCheckBox );
+ XCheckBox.class, objectCheckBox);
}
// XEventListener
- public void disposing( EventObject eventObject ) {
+ public void disposing(EventObject eventObject) {
_xCheckBox = null;
}
// XAdjustmentListener
- public void itemStateChanged( ItemEvent itemEvent ) {
- _checkBoxState = _xCheckBox.getState();
- LogUtils.DEBUG("** checkbox state ->" + _checkBoxState );
+ public void itemStateChanged(ItemEvent itemEvent) {
+ _checkBoxState = _xCheckBox.getState();
+ LogUtils.DEBUG("** checkbox state ->" + _checkBoxState);
}
}
}
diff --git a/scripting/java/com/sun/star/script/framework/browse/DialogFactory.java b/scripting/java/com/sun/star/script/framework/browse/DialogFactory.java
index 1708bdc60888..1883b0d2e05a 100644
--- a/scripting/java/com/sun/star/script/framework/browse/DialogFactory.java
+++ b/scripting/java/com/sun/star/script/framework/browse/DialogFactory.java
@@ -31,26 +31,20 @@ import com.sun.star.container.XNameContainer;
import com.sun.star.awt.*;
-public class DialogFactory
-{
+public class DialogFactory {
private static DialogFactory factory;
private XComponentContext xComponentContext;
// singleton
- private DialogFactory(XComponentContext xComponentContext)
- {
+ private DialogFactory(XComponentContext xComponentContext) {
this.xComponentContext = xComponentContext;
factory = this;
- }
-
- public static void createDialogFactory(XComponentContext xComponentContext)
- {
- if (factory == null)
- {
- synchronized(DialogFactory.class)
- {
- if (factory == null)
- {
+ }
+
+ public static void createDialogFactory(XComponentContext xComponentContext) {
+ if (factory == null) {
+ synchronized (DialogFactory.class) {
+ if (factory == null) {
factory = new DialogFactory(xComponentContext);
}
}
@@ -58,65 +52,58 @@ public class DialogFactory
}
public static DialogFactory getDialogFactory()
- throws java.lang.Exception
- {
- if (factory == null)
- {
+ throws java.lang.Exception {
+ if (factory == null) {
throw new java.lang.Exception("DialogFactory not initialized");
}
+
return factory;
}
- public String showInputDialog(String title, String prompt)
- {
+ public String showInputDialog(String title, String prompt) {
final XDialog xDialog;
- try
- {
+
+ try {
xDialog = createInputDialog(title, prompt);
- }
- catch (com.sun.star.uno.Exception e)
- {
+ } catch (com.sun.star.uno.Exception e) {
return null;
}
// add an action listener to the button controls
- XControlContainer controls = UnoRuntime.queryInterface(XControlContainer.class, xDialog);
+ XControlContainer controls = UnoRuntime.queryInterface(XControlContainer.class,
+ xDialog);
XButton okButton = UnoRuntime.queryInterface(
- XButton.class, controls.getControl("Ok"));
+ XButton.class, controls.getControl("Ok"));
okButton.setActionCommand("Ok");
XButton cancelButton = UnoRuntime.queryInterface(
- XButton.class, controls.getControl("Cancel"));
+ XButton.class, controls.getControl("Cancel"));
cancelButton.setActionCommand("Cancel");
final XTextComponent textField = UnoRuntime.queryInterface(
- XTextComponent.class, controls.getControl("NameField"));
+ XTextComponent.class, controls.getControl("NameField"));
final ResultHolder resultHolder = new ResultHolder();
com.sun.star.awt.XActionListener listener =
- new com.sun.star.awt.XActionListener()
- {
- public void actionPerformed(com.sun.star.awt.ActionEvent e) {
- if (e.ActionCommand.equals("Cancel"))
- {
- resultHolder.setResult(null);
- xDialog.endExecute();
- }
- else
- {
- resultHolder.setResult(textField.getText());
- xDialog.endExecute();
- }
+ new com.sun.star.awt.XActionListener() {
+ public void actionPerformed(com.sun.star.awt.ActionEvent e) {
+ if (e.ActionCommand.equals("Cancel")) {
+ resultHolder.setResult(null);
+ xDialog.endExecute();
+ } else {
+ resultHolder.setResult(textField.getText());
+ xDialog.endExecute();
}
+ }
- public void disposing(EventObject o) {
- // does nothing
- }
- };
+ public void disposing(EventObject o) {
+ // does nothing
+ }
+ };
okButton.addActionListener(listener);
cancelButton.addActionListener(listener);
@@ -127,8 +114,7 @@ public class DialogFactory
}
private void setDimensions(Object o, int x, int y, int width, int height)
- throws com.sun.star.uno.Exception
- {
+ throws com.sun.star.uno.Exception {
XPropertySet props = UnoRuntime.queryInterface(XPropertySet.class, o);
props.setPropertyValue("PositionX", Integer.valueOf(x));
@@ -138,15 +124,12 @@ public class DialogFactory
}
private XDialog createInputDialog(String title, String prompt)
- throws com.sun.star.uno.Exception
- {
- if (title == null || title.length() == 0)
- {
+ throws com.sun.star.uno.Exception {
+ if (title == null || title.length() == 0) {
title = "Scripting Framework";
}
- if (prompt == null || prompt.length() == 0)
- {
+ if (prompt == null || prompt.length() == 0) {
prompt = "Enter name";
}
@@ -156,64 +139,65 @@ public class DialogFactory
// create the dialog model and set the properties
Object dialogModel = xMultiComponentFactory.createInstanceWithContext(
- "com.sun.star.awt.UnoControlDialogModel", xComponentContext);
+ "com.sun.star.awt.UnoControlDialogModel", xComponentContext);
setDimensions(dialogModel, 100, 100, 157, 58);
XPropertySet props = UnoRuntime.queryInterface(
- XPropertySet.class, dialogModel);
+ XPropertySet.class, dialogModel);
props.setPropertyValue("Title", title);
// get the service manager from the dialog model
XMultiServiceFactory xMultiServiceFactory =
UnoRuntime.queryInterface(
- XMultiServiceFactory.class, dialogModel);
+ XMultiServiceFactory.class, dialogModel);
// create the label model and set the properties
Object label = xMultiServiceFactory.createInstance(
- "com.sun.star.awt.UnoControlFixedTextModel");
+ "com.sun.star.awt.UnoControlFixedTextModel");
setDimensions(label, 15, 5, 134, 12);
XPropertySet labelProps = UnoRuntime.queryInterface(
- XPropertySet.class, label);
+ XPropertySet.class, label);
labelProps.setPropertyValue("Name", "PromptLabel");
labelProps.setPropertyValue("Label", prompt);
// create the text field
Object edit = xMultiServiceFactory.createInstance(
- "com.sun.star.awt.UnoControlEditModel");
+ "com.sun.star.awt.UnoControlEditModel");
setDimensions(edit, 15, 18, 134, 12);
XPropertySet editProps = UnoRuntime.queryInterface(
- XPropertySet.class, edit);
+ XPropertySet.class, edit);
editProps.setPropertyValue("Name", "NameField");
// create the OK button
Object okButtonModel = xMultiServiceFactory.createInstance(
- "com.sun.star.awt.UnoControlButtonModel");
+ "com.sun.star.awt.UnoControlButtonModel");
setDimensions(okButtonModel, 40, 39, 38, 15);
XPropertySet buttonProps = UnoRuntime.queryInterface(
- XPropertySet.class, okButtonModel);
+ XPropertySet.class, okButtonModel);
buttonProps.setPropertyValue("Name", "Ok");
buttonProps.setPropertyValue("Label", "Ok");
// create the Cancel button
Object cancelButtonModel = xMultiServiceFactory.createInstance(
- "com.sun.star.awt.UnoControlButtonModel");
+ "com.sun.star.awt.UnoControlButtonModel");
setDimensions(cancelButtonModel, 83, 39, 38, 15);
buttonProps = UnoRuntime.queryInterface(
- XPropertySet.class, cancelButtonModel);
+ XPropertySet.class, cancelButtonModel);
buttonProps.setPropertyValue("Name", "Cancel");
buttonProps.setPropertyValue("Label", "Cancel");
// insert the control models into the dialog model
- XNameContainer xNameCont = UnoRuntime.queryInterface(XNameContainer.class, dialogModel);
+ XNameContainer xNameCont = UnoRuntime.queryInterface(XNameContainer.class,
+ dialogModel);
xNameCont.insertByName("PromptLabel", label);
xNameCont.insertByName("NameField", edit);
@@ -222,20 +206,21 @@ public class DialogFactory
// create the dialog control and set the model
Object dialog = xMultiComponentFactory.createInstanceWithContext(
- "com.sun.star.awt.UnoControlDialog", xComponentContext);
+ "com.sun.star.awt.UnoControlDialog", xComponentContext);
XControl xControl = UnoRuntime.queryInterface(
- XControl.class, dialog);
+ XControl.class, dialog);
- XControlModel xControlModel = UnoRuntime.queryInterface(XControlModel.class, dialogModel);
+ XControlModel xControlModel = UnoRuntime.queryInterface(XControlModel.class,
+ dialogModel);
xControl.setModel(xControlModel);
// create a peer
Object toolkit = xMultiComponentFactory.createInstanceWithContext(
- "com.sun.star.awt.ExtToolkit", xComponentContext);
+ "com.sun.star.awt.ExtToolkit", xComponentContext);
XToolkit xToolkit = UnoRuntime.queryInterface(
- XToolkit.class, toolkit);
+ XToolkit.class, toolkit);
XWindow xWindow = UnoRuntime.queryInterface(
- XWindow.class, xControl);
+ XWindow.class, xControl);
xWindow.setVisible(false);
xControl.createPeer(xToolkit, null);
@@ -245,13 +230,11 @@ public class DialogFactory
private static class ResultHolder {
private Object result = null;
- public Object getResult()
- {
+ public Object getResult() {
return result;
}
- public void setResult(Object result)
- {
+ public void setResult(Object result) {
this.result = result;
}
}
diff --git a/scripting/java/com/sun/star/script/framework/browse/ParcelBrowseNode.java b/scripting/java/com/sun/star/script/framework/browse/ParcelBrowseNode.java
index a2e2423ffd56..0e4f2bdea05e 100644
--- a/scripting/java/com/sun/star/script/framework/browse/ParcelBrowseNode.java
+++ b/scripting/java/com/sun/star/script/framework/browse/ParcelBrowseNode.java
@@ -50,8 +50,7 @@ import java.util.*;
import javax.swing.JOptionPane;
public class ParcelBrowseNode extends PropertySet
- implements XBrowseNode, XInvocation
-{
+ implements XBrowseNode, XInvocation {
private ScriptProvider provider;
private Collection<XBrowseNode> browsenodes;
private ParcelContainer container;
@@ -61,46 +60,43 @@ public class ParcelBrowseNode extends PropertySet
- public ParcelBrowseNode( ScriptProvider provider, ParcelContainer container, String parcelName ) {
+ public ParcelBrowseNode(ScriptProvider provider, ParcelContainer container,
+ String parcelName) {
this.provider = provider;
this.container = container;
// TODO decide whether exception is propagated out or not
- try
- {
- this.parcel = (Parcel)this.container.getByName( parcelName );
- }
- catch ( Exception e )
- {
+ try {
+ this.parcel = (Parcel)this.container.getByName(parcelName);
+ } catch (Exception e) {
- LogUtils.DEBUG("** Exception: " + e );
+ LogUtils.DEBUG("** Exception: " + e);
LogUtils.DEBUG(" ** Failed to get parcel named " +
- parcelName + " from container" );
+ parcelName + " from container");
}
+
registerProperty("Deletable", new Type(boolean.class),
- (short)0, "deletable");
+ (short)0, "deletable");
registerProperty("Editable", new Type(boolean.class),
- (short)0, "editable");
+ (short)0, "editable");
registerProperty("Creatable", new Type(boolean.class),
- (short)0, "creatable");
+ (short)0, "creatable");
registerProperty("Renamable", new Type(boolean.class),
- (short)0, "renamable");
+ (short)0, "renamable");
String parcelDirUrl = parcel.getPathToParcel();
XComponentContext xCtx = provider.getScriptingContext().getComponentContext();
XMultiComponentFactory xFac = xCtx.getServiceManager();
- try
- {
- XSimpleFileAccess xSFA = UnoRuntime.queryInterface( XSimpleFileAccess.class,
- xFac.createInstanceWithContext(
- "com.sun.star.ucb.SimpleFileAccess",
- xCtx ) );
- }
- catch ( com.sun.star.uno.Exception e )
- {
+
+ try {
+ XSimpleFileAccess xSFA = UnoRuntime.queryInterface(XSimpleFileAccess.class,
+ xFac.createInstanceWithContext(
+ "com.sun.star.ucb.SimpleFileAccess",
+ xCtx));
+ } catch (com.sun.star.uno.Exception e) {
// TODO propagate potential errors
- LogUtils.DEBUG( "Caught exception creating ParcelBrowseNode " + e );
- LogUtils.DEBUG( LogUtils.getTrace( e ) );
+ LogUtils.DEBUG("Caught exception creating ParcelBrowseNode " + e);
+ LogUtils.DEBUG(LogUtils.getTrace(e));
}
}
@@ -110,36 +106,30 @@ public class ParcelBrowseNode extends PropertySet
}
public XBrowseNode[] getChildNodes() {
- try
- {
+ try {
- if ( hasChildNodes() )
- {
+ if (hasChildNodes()) {
String[] names = parcel.getElementNames();
- browsenodes = new ArrayList<XBrowseNode>( names.length );
+ browsenodes = new ArrayList<XBrowseNode>(names.length);
for (String name : names) {
browsenodes.add(new ScriptBrowseNode(provider, parcel, name));
}
- }
- else
- {
- LogUtils.DEBUG("ParcelBrowseNode.getChildeNodes no children " );
+ } else {
+ LogUtils.DEBUG("ParcelBrowseNode.getChildeNodes no children ");
return new XBrowseNode[0];
}
- }
- catch ( Exception e )
- {
- LogUtils.DEBUG("Failed to getChildeNodes, exception: " + e );
- LogUtils.DEBUG( LogUtils.getTrace( e ) );
+ } catch (Exception e) {
+ LogUtils.DEBUG("Failed to getChildeNodes, exception: " + e);
+ LogUtils.DEBUG(LogUtils.getTrace(e));
return new XBrowseNode[0];
}
+
return browsenodes.toArray(new XBrowseNode[browsenodes.size()]);
}
public boolean hasChildNodes() {
- if ( container != null && container.hasByName( getName() ) && parcel != null )
- {
+ if (container != null && container.hasByName(getName()) && parcel != null) {
return parcel.hasElements();
}
@@ -151,8 +141,7 @@ public class ParcelBrowseNode extends PropertySet
}
@Override
- public String toString()
- {
+ public String toString() {
return getName();
}
@@ -163,11 +152,10 @@ public class ParcelBrowseNode extends PropertySet
public Object invoke(String aFunctionName, Object[] aParams,
short[][] aOutParamIndex, Object[][] aOutParam)
- throws com.sun.star.lang.IllegalArgumentException,
- com.sun.star.script.CannotConvertException,
- com.sun.star.reflection.InvocationTargetException
- {
- LogUtils.DEBUG("ParcelBrowseNode invoke for " + aFunctionName );
+ throws com.sun.star.lang.IllegalArgumentException,
+ com.sun.star.script.CannotConvertException,
+ com.sun.star.reflection.InvocationTargetException {
+ LogUtils.DEBUG("ParcelBrowseNode invoke for " + aFunctionName);
// Initialise the out parameters - not used but prevents error in
// UNO bridge
aOutParamIndex[0] = new short[0];
@@ -175,137 +163,112 @@ public class ParcelBrowseNode extends PropertySet
Any result = new Any(new Type(Boolean.class), Boolean.TRUE);
- if (aFunctionName.equals("Creatable"))
- {
- try
- {
+ if (aFunctionName.equals("Creatable")) {
+ try {
String newName;
if (aParams == null || aParams.length < 1 ||
- !AnyConverter.isString(aParams[0]))
- {
+ !AnyConverter.isString(aParams[0])) {
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
- {
+ try {
DialogFactory dialogFactory =
DialogFactory.getDialogFactory();
newName = dialogFactory.showInputDialog(title, prompt);
- }
- catch (Exception e)
- {
+ } catch (Exception e) {
newName = JOptionPane.showInputDialog(null, prompt, title,
- JOptionPane.QUESTION_MESSAGE);
+ JOptionPane.QUESTION_MESSAGE);
}
- }
- else {
+ } else {
newName = AnyConverter.toString(aParams[0]);
}
- if ( newName == null || newName.length() == 0)
- {
+ if (newName == null || newName.length() == 0) {
result = new Any(new Type(Boolean.class), Boolean.FALSE);
- }
- else
- {
+ } else {
String source = provider.getScriptEditor().getTemplate();
String languageName = newName + "." + provider.getScriptEditor().getExtension();
String language = container.getLanguage();
- ScriptEntry entry = new ScriptEntry( language, languageName, "", new HashMap<String,String>() );
+ ScriptEntry entry = new ScriptEntry(language, languageName, "",
+ new HashMap<String, String>());
- Parcel parcel = (Parcel)container.getByName( getName() );
- ScriptMetaData data = new ScriptMetaData( parcel, entry, source );
- parcel.insertByName( languageName, data );
+ Parcel parcel = (Parcel)container.getByName(getName());
+ ScriptMetaData data = new ScriptMetaData(parcel, entry, source);
+ parcel.insertByName(languageName, data);
- ScriptBrowseNode sbn = new ScriptBrowseNode( provider, parcel, languageName );
+ ScriptBrowseNode sbn = new ScriptBrowseNode(provider, parcel, languageName);
- if(browsenodes==null)
- {
- LogUtils.DEBUG("browsenodes null!!");
- browsenodes = new ArrayList<XBrowseNode>(4);
+ if (browsenodes == null) {
+ LogUtils.DEBUG("browsenodes null!!");
+ browsenodes = new ArrayList<XBrowseNode>(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 ) );
+ } catch (Exception e) {
+ LogUtils.DEBUG("ParcelBrowseNode[create] failed with: " + e);
+ LogUtils.DEBUG(LogUtils.getTrace(e));
result = new Any(new Type(Boolean.class), Boolean.FALSE);
}
- }
- else if (aFunctionName.equals("Deletable"))
- {
- try
- {
- if ( container.deleteParcel(getName()) )
- {
+ } else if (aFunctionName.equals("Deletable")) {
+ try {
+ if (container.deleteParcel(getName())) {
result = new Any(new Type(Boolean.class), Boolean.TRUE);
- }
- else
- {
+ } else {
result = new Any(new Type(Boolean.class), Boolean.FALSE);
}
- }
- catch (Exception e)
- {
+ } catch (Exception e) {
result = new Any(new Type(Boolean.class), Boolean.FALSE);
}
- }
- else if (aFunctionName.equals("Renamable"))
- {
+ } else if (aFunctionName.equals("Renamable")) {
String newName = null;
- try
- {
+
+ try {
if (aParams == null || aParams.length < 1 ||
- !AnyConverter.isString(aParams[0]))
- {
+ !AnyConverter.isString(aParams[0])) {
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
- {
+ try {
DialogFactory dialogFactory =
DialogFactory.getDialogFactory();
newName = dialogFactory.showInputDialog(title, prompt);
- }
- catch (Exception e)
- {
+ } catch (Exception e) {
newName = JOptionPane.showInputDialog(null, prompt, title,
- JOptionPane.QUESTION_MESSAGE);
+ JOptionPane.QUESTION_MESSAGE);
}
- }
- else {
+ } else {
newName = AnyConverter.toString(aParams[0]);
}
- container.renameParcel( getName(), newName );
- Parcel p = (Parcel)container.getByName( newName );
- if(browsenodes == null )
- {
+
+ container.renameParcel(getName(), newName);
+ Parcel p = (Parcel)container.getByName(newName);
+
+ if (browsenodes == null) {
getChildNodes();
}
- ScriptBrowseNode[] childNodes = browsenodes.toArray(new ScriptBrowseNode[browsenodes.size()]);
- for ( int index = 0; index < childNodes.length; index++ )
- {
- childNodes[ index ].updateURI( p );
+ ScriptBrowseNode[] childNodes = browsenodes.toArray(new
+ ScriptBrowseNode[browsenodes.size()]);
+
+ for (int index = 0; index < childNodes.length; index++) {
+ childNodes[ index ].updateURI(p);
}
+
result = new Any(new Type(XBrowseNode.class), this);
- }
- catch (Exception e)
- {
+ } catch (Exception e) {
result = new Any(new Type(Boolean.class), Boolean.FALSE);
}
}
@@ -319,15 +282,13 @@ public class ParcelBrowseNode extends PropertySet
}
public void setValue(String aPropertyName, Object aValue)
- throws com.sun.star.beans.UnknownPropertyException,
- com.sun.star.script.CannotConvertException,
- com.sun.star.reflection.InvocationTargetException
- {
+ throws com.sun.star.beans.UnknownPropertyException,
+ com.sun.star.script.CannotConvertException,
+ com.sun.star.reflection.InvocationTargetException {
}
public Object getValue(String aPropertyName)
- throws com.sun.star.beans.UnknownPropertyException
- {
+ throws com.sun.star.beans.UnknownPropertyException {
return null;
}
diff --git a/scripting/java/com/sun/star/script/framework/browse/PkgProviderBrowseNode.java b/scripting/java/com/sun/star/script/framework/browse/PkgProviderBrowseNode.java
index ca5d94de02a3..d611c074acfe 100644
--- a/scripting/java/com/sun/star/script/framework/browse/PkgProviderBrowseNode.java
+++ b/scripting/java/com/sun/star/script/framework/browse/PkgProviderBrowseNode.java
@@ -25,14 +25,17 @@ import com.sun.star.script.framework.log.*;
import com.sun.star.script.framework.container.*;
-public class PkgProviderBrowseNode extends ProviderBrowseNode
-{
-
- public PkgProviderBrowseNode( ScriptProvider provider, ParcelContainer container, XComponentContext xCtx ) {
- super( provider, container, xCtx );
- LogUtils.DEBUG("*** PkgProviderBrowseNode ctor container name = " + container.getName());
- LogUtils.DEBUG("*** PkgProviderBrowseNode ctor container path = " + container.getParcelContainerDir());
- LogUtils.DEBUG("*** PkgProviderBrowseNode ctor, container has num parcels = " + container.getElementNames().length);
+public class PkgProviderBrowseNode extends ProviderBrowseNode {
+
+ public PkgProviderBrowseNode(ScriptProvider provider, ParcelContainer container,
+ XComponentContext xCtx) {
+ super(provider, container, xCtx);
+ LogUtils.DEBUG("*** PkgProviderBrowseNode ctor container name = " +
+ container.getName());
+ LogUtils.DEBUG("*** PkgProviderBrowseNode ctor container path = " +
+ container.getParcelContainerDir());
+ LogUtils.DEBUG("*** PkgProviderBrowseNode ctor, container has num parcels = " +
+ container.getElementNames().length);
}
@Override
diff --git a/scripting/java/com/sun/star/script/framework/browse/ProviderBrowseNode.java b/scripting/java/com/sun/star/script/framework/browse/ProviderBrowseNode.java
index 18cefb0d817c..d9b74e5a7807 100644
--- a/scripting/java/com/sun/star/script/framework/browse/ProviderBrowseNode.java
+++ b/scripting/java/com/sun/star/script/framework/browse/ProviderBrowseNode.java
@@ -43,8 +43,7 @@ import java.util.*;
import javax.swing.JOptionPane;
public class ProviderBrowseNode extends PropertySet
- implements XBrowseNode, XInvocation
-{
+ implements XBrowseNode, XInvocation {
private ScriptProvider provider;
private Collection<XBrowseNode> browsenodes;
private String name;
@@ -56,7 +55,8 @@ public class ProviderBrowseNode extends PropertySet
- public ProviderBrowseNode( ScriptProvider provider, ParcelContainer container, XComponentContext xCtx ) {
+ public ProviderBrowseNode(ScriptProvider provider, ParcelContainer container,
+ XComponentContext xCtx) {
LogUtils.DEBUG("*** ProviderBrowseNode ctor");
this.container = container;
this.name = this.container.getLanguage();
@@ -64,25 +64,24 @@ public class ProviderBrowseNode extends PropertySet
this.m_xCtx = xCtx;
registerProperty("Deletable", new Type(boolean.class),
- (short)0, "deletable");
+ (short)0, "deletable");
registerProperty("Creatable", new Type(boolean.class),
- (short)0, "creatable");
+ (short)0, "creatable");
registerProperty("Editable", new Type(boolean.class),
- (short)0, "editable");
+ (short)0, "editable");
XSimpleFileAccess xSFA = null;
XMultiComponentFactory xFac = m_xCtx.getServiceManager();
- try
- {
- xSFA = UnoRuntime.queryInterface( XSimpleFileAccess.class,
- xFac.createInstanceWithContext(
- "com.sun.star.ucb.SimpleFileAccess",
- xCtx ) );
+
+ try {
+ xSFA = UnoRuntime.queryInterface(XSimpleFileAccess.class,
+ xFac.createInstanceWithContext(
+ "com.sun.star.ucb.SimpleFileAccess",
+ xCtx));
}
// TODO propage errors
- catch( com.sun.star.uno.Exception e )
- {
- LogUtils.DEBUG("Caught exception in creation of ProviderBrowseNode ");
- LogUtils.DEBUG( LogUtils.getTrace(e));
+ catch (com.sun.star.uno.Exception e) {
+ LogUtils.DEBUG("Caught exception in creation of ProviderBrowseNode ");
+ LogUtils.DEBUG(LogUtils.getTrace(e));
}
}
@@ -93,51 +92,55 @@ public class ProviderBrowseNode extends PropertySet
public XBrowseNode[] getChildNodes() {
LogUtils.DEBUG("***** ProviderBrowseNode.getChildNodes()");
- if ( hasChildNodes() )
- {
+
+ if (hasChildNodes()) {
// needs initialisation?
- LogUtils.DEBUG("** ProviderBrowseNode.getChildNodes(), container is " + container );
+ LogUtils.DEBUG("** ProviderBrowseNode.getChildNodes(), container is " +
+ container);
String[] parcels = container.getElementNames();
- browsenodes = new ArrayList<XBrowseNode>( parcels.length );
+ browsenodes = new ArrayList<XBrowseNode>(parcels.length);
+
for (String parcel : parcels) {
try {
XBrowseNode node = new ParcelBrowseNode(provider, container, parcel);
- browsenodes.add( node );
+ browsenodes.add(node);
} catch (Exception e) {
LogUtils.DEBUG("*** Failed to create parcel node for " + parcel);
- LogUtils.DEBUG( e.toString() );
+ LogUtils.DEBUG(e.toString());
}
}
+
ParcelContainer[] packageContainers = container.getChildContainers();
- LogUtils.DEBUG("**** For container named " + container.getName() + " with root path " + container.getParcelContainerDir() + " has " + packageContainers.length + " child containers " );
+ LogUtils.DEBUG("**** For container named " + container.getName() +
+ " with root path " + container.getParcelContainerDir() + " has " +
+ packageContainers.length + " child containers ");
for (ParcelContainer packageContainer : packageContainers) {
- XBrowseNode node = new PkgProviderBrowseNode(provider, packageContainer, m_xCtx);
- browsenodes.add( node );
+ XBrowseNode node = new PkgProviderBrowseNode(provider, packageContainer,
+ m_xCtx);
+ browsenodes.add(node);
}
- }
- else
- {
+ } else {
LogUtils.DEBUG("*** No container available");
return new XBrowseNode[0];
}
- return browsenodes.toArray( new XBrowseNode[browsenodes.size()] );
+
+ return browsenodes.toArray(new XBrowseNode[browsenodes.size()]);
}
public boolean hasChildNodes() {
boolean result = true;
- if ( container == null ||
- ( !container.hasElements() &&
- container.getChildContainers().length == 0 ) )
- {
+ if (container == null ||
+ (!container.hasElements() &&
+ container.getChildContainers().length == 0)) {
result = false;
}
LogUtils.DEBUG("***** ProviderBrowseNode.hasChildNodes(): " +
- "name=" + name +
- ", path=" + container.getParcelContainerDir() +
- ", result=" + result );
+ "name=" + name +
+ ", path=" + container.getParcelContainerDir() +
+ ", result=" + result);
return result;
}
@@ -147,8 +150,7 @@ public class ProviderBrowseNode extends PropertySet
}
@Override
- public String toString()
- {
+ public String toString() {
return getName();
}
@@ -159,10 +161,9 @@ public class ProviderBrowseNode extends PropertySet
public Object invoke(String aFunctionName, Object[] aParams,
short[][] aOutParamIndex, Object[][] aOutParam)
- throws com.sun.star.lang.IllegalArgumentException,
- com.sun.star.script.CannotConvertException,
- com.sun.star.reflection.InvocationTargetException
- {
+ throws com.sun.star.lang.IllegalArgumentException,
+ com.sun.star.script.CannotConvertException,
+ com.sun.star.reflection.InvocationTargetException {
// Initialise the out parameters - not used but prevents error in
// UNO bridge
aOutParamIndex[0] = new short[0];
@@ -170,57 +171,45 @@ public class ProviderBrowseNode extends PropertySet
Any result = new Any(new Type(Boolean.class), Boolean.TRUE);
- if (aFunctionName.equals("Creatable"))
- {
- try
- {
+ if (aFunctionName.equals("Creatable")) {
+ try {
String name;
if (aParams == null || aParams.length < 1 ||
- !AnyConverter.isString(aParams[0]))
- {
+ !AnyConverter.isString(aParams[0])) {
String prompt = "Enter name for new Parcel";
String title = "Create Parcel";
// try to get a DialogFactory instance, if it fails
// just use a Swing JOptionPane to prompt for the name
- try
- {
+ try {
DialogFactory dialogFactory =
DialogFactory.getDialogFactory();
name = dialogFactory.showInputDialog(title, prompt);
- }
- catch (Exception e)
- {
+ } catch (Exception e) {
name = JOptionPane.showInputDialog(null, prompt, title,
- JOptionPane.QUESTION_MESSAGE);
+ JOptionPane.QUESTION_MESSAGE);
}
- }
- else {
+ } else {
name = AnyConverter.toString(aParams[0]);
}
- if (name == null || name.length() == 0)
- {
+ if (name == null || name.length() == 0) {
result = new Any(new Type(Boolean.class), Boolean.FALSE);
- }
- else
- {
+ } else {
- Object newParcel = container.createParcel( name );
- LogUtils.DEBUG("Parcel created " + name + " " + newParcel );
- if ( newParcel == null )
- {
+ Object newParcel = container.createParcel(name);
+ LogUtils.DEBUG("Parcel created " + name + " " + newParcel);
+
+ if (newParcel == null) {
result = new Any(new Type(Boolean.class), Boolean.FALSE);
- }
- else
- {
- ParcelBrowseNode parcel = new ParcelBrowseNode( provider, container, name );
+ } else {
+ ParcelBrowseNode parcel = new ParcelBrowseNode(provider, container, name);
LogUtils.DEBUG("created parcel node ");
- if ( browsenodes == null )
- {
- browsenodes = new ArrayList<XBrowseNode>( 5 );
+
+ if (browsenodes == null) {
+ browsenodes = new ArrayList<XBrowseNode>(5);
}
browsenodes.add(parcel);
@@ -229,15 +218,12 @@ public class ProviderBrowseNode extends PropertySet
result = new Any(new Type(XBrowseNode.class), parcel);
}
}
- }
- catch (Exception e)
- {
- LogUtils.DEBUG("ProviderBrowseNode[create] failed with: " + e );
- LogUtils.DEBUG( LogUtils.getTrace( e ) );
+ } catch (Exception e) {
+ LogUtils.DEBUG("ProviderBrowseNode[create] failed with: " + e);
+ LogUtils.DEBUG(LogUtils.getTrace(e));
result = new Any(new Type(Boolean.class), Boolean.FALSE);
}
- }
- else {
+ } else {
throw new com.sun.star.lang.IllegalArgumentException(
"Function " + aFunctionName + " not supported.");
}
@@ -246,15 +232,13 @@ public class ProviderBrowseNode extends PropertySet
}
public void setValue(String aPropertyName, Object aValue)
- throws com.sun.star.beans.UnknownPropertyException,
- com.sun.star.script.CannotConvertException,
- com.sun.star.reflection.InvocationTargetException
- {
+ throws com.sun.star.beans.UnknownPropertyException,
+ com.sun.star.script.CannotConvertException,
+ com.sun.star.reflection.InvocationTargetException {
}
public Object getValue(String aPropertyName)
- throws com.sun.star.beans.UnknownPropertyException
- {
+ throws com.sun.star.beans.UnknownPropertyException {
return null;
}
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 6073eb03b243..f259da90f097 100644
--- a/scripting/java/com/sun/star/script/framework/browse/ScriptBrowseNode.java
+++ b/scripting/java/com/sun/star/script/framework/browse/ScriptBrowseNode.java
@@ -46,8 +46,7 @@ import com.sun.star.script.framework.provider.ScriptProvider;
import com.sun.star.script.framework.container.*;
public class ScriptBrowseNode extends PropertySet
- implements XBrowseNode, XInvocation
-{
+ implements XBrowseNode, XInvocation {
private ScriptProvider provider;
private Parcel parent;
@@ -58,37 +57,33 @@ public class ScriptBrowseNode extends PropertySet
private boolean deletable = false;
private boolean renamable = false;
- public ScriptBrowseNode( ScriptProvider provider, Parcel parent,
- String name )
- {
+ public ScriptBrowseNode(ScriptProvider provider, Parcel parent,
+ String name) {
this.provider = provider;
this.name = name;
this.parent = parent;
XComponentContext xCtx = provider.getScriptingContext().getComponentContext();
XMultiComponentFactory xFac = xCtx.getServiceManager();
- try
- {
- ScriptMetaData data = (ScriptMetaData)parent.getByName( name );
- XSimpleFileAccess xSFA = UnoRuntime.queryInterface( XSimpleFileAccess.class,
- xFac.createInstanceWithContext(
- "com.sun.star.ucb.SimpleFileAccess",
- xCtx ) );
-
- if (provider.hasScriptEditor())
- {
+
+ try {
+ ScriptMetaData data = (ScriptMetaData)parent.getByName(name);
+ XSimpleFileAccess xSFA = UnoRuntime.queryInterface(XSimpleFileAccess.class,
+ xFac.createInstanceWithContext(
+ "com.sun.star.ucb.SimpleFileAccess",
+ xCtx));
+
+ if (provider.hasScriptEditor()) {
this.editable = true;
- try
- {
+
+ try {
if (!parent.isUnoPkg()
- && !xSFA.isReadOnly(parent.getPathToParcel()))
- {
+ && !xSFA.isReadOnly(parent.getPathToParcel())) {
this.deletable = true;
this.renamable = true;
}
}
// TODO propagate errors
- catch (Exception e)
- {
+ catch (Exception e) {
LogUtils.DEBUG("Caught exception in creation of ScriptBrowseNode");
LogUtils.DEBUG(LogUtils.getTrace(e));
}
@@ -97,21 +92,21 @@ public class ScriptBrowseNode extends PropertySet
}
// 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() );
+ catch (Exception e) {
+ LogUtils.DEBUG("** caught exception getting script data for " + name + " ->" +
+ e.toString());
}
registerProperty("Deletable", new Type(boolean.class),
- (short)0, "deletable");
+ (short)0, "deletable");
registerProperty("Editable", new Type(boolean.class),
- (short)0, "editable");
+ (short)0, "editable");
registerProperty("Renamable", new Type(boolean.class),
- (short)0, "renamable");
+ (short)0, "renamable");
registerProperty("URI", new Type(String.class),
- (short)0, "uri");
+ (short)0, "uri");
registerProperty("Description", new Type(String.class),
- (short)0, "description");
+ (short)0, "description");
}
@@ -136,18 +131,18 @@ public class ScriptBrowseNode extends PropertySet
return getName();
}
- public void updateURI( Parcel p ) {
+ public void updateURI(Parcel p) {
parent = p;
ScriptMetaData data = null;
- try
- {
- data = (ScriptMetaData)parent.getByName( name );
+
+ 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() );
+ catch (Exception e) {
+ LogUtils.DEBUG("** caught exception getting script data for " + name + " ->" +
+ e.toString());
}
}
// implementation of XInvocation interface
@@ -157,10 +152,9 @@ public class ScriptBrowseNode extends PropertySet
public Object invoke(String aFunctionName, Object[] aParams,
short[][] aOutParamIndex, Object[][] aOutParam)
- throws com.sun.star.lang.IllegalArgumentException,
- com.sun.star.script.CannotConvertException,
- com.sun.star.reflection.InvocationTargetException
- {
+ throws com.sun.star.lang.IllegalArgumentException,
+ com.sun.star.script.CannotConvertException,
+ com.sun.star.reflection.InvocationTargetException {
// Initialise the out parameters - not used but prevents error in
// UNO bridge
aOutParamIndex[0] = new short[0];
@@ -168,83 +162,67 @@ public class ScriptBrowseNode extends PropertySet
Any result = new Any(new Type(Boolean.class), Boolean.TRUE);
- if (aFunctionName.equals("Editable"))
- {
- if (!editable)
- {
+ if (aFunctionName.equals("Editable")) {
+ if (!editable) {
NoSupportException nse = new NoSupportException(
- aFunctionName + " is not editable " );
+ aFunctionName + " is not editable ");
throw new InvocationTargetException(
- "Scripting framework error editing script", null, nse );
+ "Scripting framework error editing script", null, nse);
}
XScriptContext ctxt = provider.getScriptingContext();
ScriptMetaData data = null;
- try
- {
- data = (ScriptMetaData)parent.getByName( name );
- }
- catch ( NoSuchElementException nse )
- {
+
+ try {
+ data = (ScriptMetaData)parent.getByName(name);
+ } catch (NoSuchElementException nse) {
throw new com.sun.star.lang.IllegalArgumentException(
- name + " does not exist or can't be found " );
- }
- catch ( com.sun.star.lang.WrappedTargetException wte )
- {
+ name + " does not exist or can't be found ");
+ } catch (com.sun.star.lang.WrappedTargetException wte) {
// rethrow
throw new InvocationTargetException(
"Scripting framework editing script ",
- null, wte.TargetException );
+ null, wte.TargetException);
}
provider.getScriptEditor().edit(ctxt, data);
- }
- else if (aFunctionName.equals("Deletable"))
- {
- if (!deletable)
- {
+ } else if (aFunctionName.equals("Deletable")) {
+ if (!deletable) {
NoSupportException nse = new NoSupportException(
- aFunctionName + " is not supported for this node" );
+ aFunctionName + " is not supported for this node");
throw new InvocationTargetException(
- "Scripting framework error deleting script", null, nse );
+ "Scripting framework error deleting script", null, nse);
}
- try
- {
- parent.removeByName( name );
+
+ try {
+ parent.removeByName(name);
result = new Any(new Type(Boolean.class), Boolean.TRUE);
- }
- catch ( NoSuchElementException nse )
- {
+ } catch (NoSuchElementException nse) {
throw new com.sun.star.lang.IllegalArgumentException(
- name + " does not exist or can't be found " );
- }
- catch ( WrappedTargetException wte )
- {
+ name + " does not exist or can't be found ");
+ } catch (WrappedTargetException wte) {
// rethrow
throw new InvocationTargetException(
"Scripting framework deleting script ",
- null, wte.TargetException );
+ null, wte.TargetException);
}
- }
- else if (aFunctionName.equals("Renamable"))
- {
+ } else if (aFunctionName.equals("Renamable")) {
result = new Any(new Type(XBrowseNode.class), new XBrowseNode[0]);
- if (!renamable)
- {
+
+ if (!renamable) {
NoSupportException nse = new NoSupportException(
- aFunctionName + " is not supported for this node" );
+ aFunctionName + " is not supported for this node");
throw new InvocationTargetException(
- "Scripting framework error renaming script", null, nse );
+ "Scripting framework error renaming script", null, nse);
}
- try
- {
+ try {
String newName = AnyConverter.toString(aParams[0]);
- ScriptMetaData oldData = (ScriptMetaData)parent.getByName( name );
+ ScriptMetaData oldData = (ScriptMetaData)parent.getByName(name);
oldData.loadSource();
String oldSource = oldData.getSource();
@@ -254,40 +232,33 @@ public class ScriptBrowseNode extends PropertySet
String language = provider.getName();
ScriptEntry entry = new ScriptEntry(
- language, languageName, "", new HashMap<String,String>() );
+ language, languageName, "", new HashMap<String, String>());
ScriptMetaData data = new ScriptMetaData(
- parent, entry, oldSource );
+ parent, entry, oldSource);
- parent.insertByName( languageName, data );
+ parent.insertByName(languageName, data);
LogUtils.DEBUG("Now remove old script");
- parent.removeByName( name );
+ parent.removeByName(name);
name = languageName;
result = new Any(new Type(XBrowseNode.class), this);
- }
- catch ( NoSuchElementException nse )
- {
+ } catch (NoSuchElementException nse) {
throw new com.sun.star.lang.IllegalArgumentException(
- name + " does not exist or can't be found " );
- }
- catch ( ElementExistException eee )
- {
+ name + " does not exist or can't be found ");
+ } catch (ElementExistException eee) {
// rethrow
throw new InvocationTargetException(
"Scripting framework error renaming script ",
- null, eee );
- }
- catch ( WrappedTargetException wte )
- {
+ null, eee);
+ } catch (WrappedTargetException wte) {
// rethrow
throw new InvocationTargetException(
"Scripting framework rename script ",
- null, wte.TargetException );
+ null, wte.TargetException);
}
- }
- else {
+ } else {
throw new com.sun.star.lang.IllegalArgumentException(
"Function " + aFunctionName + " not supported.");
}
@@ -296,15 +267,13 @@ public class ScriptBrowseNode extends PropertySet
}
public void setValue(String aPropertyName, Object aValue)
- throws com.sun.star.beans.UnknownPropertyException,
- com.sun.star.script.CannotConvertException,
- com.sun.star.reflection.InvocationTargetException
- {
+ throws com.sun.star.beans.UnknownPropertyException,
+ com.sun.star.script.CannotConvertException,
+ com.sun.star.reflection.InvocationTargetException {
}
public Object getValue(String aPropertyName)
- throws com.sun.star.beans.UnknownPropertyException
- {
+ throws com.sun.star.beans.UnknownPropertyException {
return null;
}
diff --git a/scripting/java/com/sun/star/script/framework/container/DeployedUnoPackagesDB.java b/scripting/java/com/sun/star/script/framework/container/DeployedUnoPackagesDB.java
index efc9347d5d04..4ac952778c87 100644
--- a/scripting/java/com/sun/star/script/framework/container/DeployedUnoPackagesDB.java
+++ b/scripting/java/com/sun/star/script/framework/container/DeployedUnoPackagesDB.java
@@ -40,11 +40,11 @@ public class DeployedUnoPackagesDB {
public DeployedUnoPackagesDB() throws IOException {
ByteArrayInputStream bis = null;
+
try {
bis = new ByteArrayInputStream(EMPTY_DOCUMENT);
this.document = XMLParserFactory.getParser().parse(bis);
- }
- finally {
+ } finally {
if (bis != null)
bis.close();
}
@@ -58,8 +58,7 @@ public class DeployedUnoPackagesDB {
this(XMLParserFactory.getParser().parse(is));
}
- public String[] getDeployedPackages( String language )
- {
+ public String[] getDeployedPackages(String language) {
ArrayList<String> packageUrls = new ArrayList<String>(4);
Element main = document.getDocumentElement();
Element root = null;
@@ -67,38 +66,36 @@ public class DeployedUnoPackagesDB {
NodeList langNodes = null;
if ((langNodes = main.getElementsByTagName("language")) != null &&
- (len = langNodes.getLength()) != 0)
- {
- for ( int i=0; i<len; i++ )
- {
- Element e = (Element)langNodes.item( i );
- if ( e.getAttribute("value").equals(language) )
- {
+ (len = langNodes.getLength()) != 0) {
+ for (int i = 0; i < len; i++) {
+ Element e = (Element)langNodes.item(i);
+
+ if (e.getAttribute("value").equals(language)) {
root = e;
break;
}
}
}
- if ( root != null )
- {
+
+ if (root != null) {
len = 0;
NodeList packages = null;
+
if ((packages = root.getElementsByTagName("package")) != null &&
- (len = packages.getLength()) != 0)
- {
+ (len = packages.getLength()) != 0) {
- for ( int i=0; i<len; i++ )
- {
+ for (int i = 0; i < len; i++) {
- Element e = (Element)packages.item( i );
- packageUrls.add( e.getAttribute("value") );
+ Element e = (Element)packages.item(i);
+ packageUrls.add(e.getAttribute("value"));
}
}
}
- if ( !packageUrls.isEmpty() )
- {
- return packageUrls.toArray( new String[packageUrls.size()] );
+
+ if (!packageUrls.isEmpty()) {
+ return packageUrls.toArray(new String[packageUrls.size()]);
}
+
return new String[0];
}
@@ -111,52 +108,49 @@ public class DeployedUnoPackagesDB {
}
- public boolean removePackage( String language, String url )
- {
+ public boolean removePackage(String language, String url) {
Element main = document.getDocumentElement();
Element langNode = null;
int len = 0;
NodeList langNodes = null;
boolean result = false;
+
if ((langNodes = main.getElementsByTagName("language")) != null &&
- (len = langNodes.getLength()) != 0)
- {
- for ( int i=0; i<len; i++ )
- {
- Element e = (Element)langNodes.item( i );
- if ( e.getAttribute("value").equals(language) )
- {
+ (len = langNodes.getLength()) != 0) {
+ for (int i = 0; i < len; i++) {
+ Element e = (Element)langNodes.item(i);
+
+ if (e.getAttribute("value").equals(language)) {
langNode = e;
break;
}
}
}
- if ( langNode != null )
- {
+
+ if (langNode != null) {
len = 0;
NodeList packages = null;
+
if ((packages = langNode.getElementsByTagName("package")) != null &&
- (len = packages.getLength()) != 0)
- {
- for ( int i=0; i<len; i++ )
- {
+ (len = packages.getLength()) != 0) {
+ for (int i = 0; i < len; i++) {
- Element e = (Element)packages.item( i );
+ Element e = (Element)packages.item(i);
String value = e.getAttribute("value");
- if ( value.equals(url) )
- {
- langNode.removeChild( e );
+ if (value.equals(url)) {
+ langNode.removeChild(e);
result = true;
break;
}
}
}
}
+
return result;
}
- public void addPackage(String language, String url ) {
+ public void addPackage(String language, String url) {
Element main = document.getDocumentElement();
Element langNode = null;
Element pkgNode = null;
@@ -165,25 +159,24 @@ public class DeployedUnoPackagesDB {
NodeList langNodes = null;
if ((langNodes = document.getElementsByTagName("language")) != null &&
- (len = langNodes.getLength()) != 0)
- {
- for ( int i=0; i<len; i++ )
- {
- Element e = (Element)langNodes.item( i );
- if ( e.getAttribute("value").equals(language) )
- {
+ (len = langNodes.getLength()) != 0) {
+ for (int i = 0; i < len; i++) {
+ Element e = (Element)langNodes.item(i);
+
+ if (e.getAttribute("value").equals(language)) {
langNode = e;
break;
}
}
}
- if ( langNode == null )
- {
+
+ if (langNode == null) {
langNode = document.createElement("language");
- langNode.setAttribute( "value", language );
+ langNode.setAttribute("value", language);
}
+
pkgNode = document.createElement("package");
- pkgNode.setAttribute( "value", url );
+ pkgNode.setAttribute("value", url);
langNode.appendChild(pkgNode);
//add to the Top Element
diff --git a/scripting/java/com/sun/star/script/framework/container/Parcel.java b/scripting/java/com/sun/star/script/framework/container/Parcel.java
index bf47b60e1800..bcc24b66c2e3 100644
--- a/scripting/java/com/sun/star/script/framework/container/Parcel.java
+++ b/scripting/java/com/sun/star/script/framework/container/Parcel.java
@@ -28,20 +28,19 @@ import com.sun.star.ucb.XSimpleFileAccess2;
import java.io.*;
-public class Parcel implements XNameContainer
-{
+public class Parcel implements XNameContainer {
private ParcelDescriptor m_descriptor;
private String name;
protected ParcelContainer parent;
protected XSimpleFileAccess m_xSFA;
- public Parcel( XSimpleFileAccess xSFA, ParcelContainer parent, ParcelDescriptor desc, String parcelName )
- {
- this( parent, desc, parcelName );
- this.m_xSFA = xSFA;
+ public Parcel(XSimpleFileAccess xSFA, ParcelContainer parent,
+ ParcelDescriptor desc, String parcelName) {
+ this(parent, desc, parcelName);
+ this.m_xSFA = xSFA;
}
- private Parcel( ParcelContainer parent, ParcelDescriptor desc, String parcelName )
- {
+ private Parcel(ParcelContainer parent, ParcelDescriptor desc,
+ String parcelName) {
this.parent = parent;
this.m_descriptor = desc;
this.name = parcelName;
@@ -53,23 +52,24 @@ public class Parcel implements XNameContainer
*
* @return <tt>true</tt> if has parent <tt>false</tt> otherwise
*/
- public boolean isUnoPkg() { return parent.isUnoPkg(); }
+ public boolean isUnoPkg() {
+ return parent.isUnoPkg();
+ }
- public String getName()
- {
+ public String getName() {
return name;
}
- public java.lang.Object getByName( String aName ) throws com.sun.star.container.NoSuchElementException, com.sun.star.lang.WrappedTargetException
- {
- LogUtils.DEBUG("** Parcel.getByName for " + aName );
+ public java.lang.Object getByName(String aName) throws
+ com.sun.star.container.NoSuchElementException,
+ com.sun.star.lang.WrappedTargetException {
+ LogUtils.DEBUG("** Parcel.getByName for " + aName);
ScriptEntry thescript = null;
- try
- {
- if ( m_descriptor != null && hasElements() )
- {
+
+ try {
+ if (m_descriptor != null && hasElements()) {
ScriptEntry[] scripts = m_descriptor.getScriptEntries();
- if ( scripts.length != 0 )
- {
+
+ if (scripts.length != 0) {
for (ScriptEntry script : scripts) {
if (script.getLanguageName().equals(aName)) {
thescript = script;
@@ -80,51 +80,50 @@ public class Parcel implements XNameContainer
}
}
// catch unknown or un-checked exceptions
- catch ( Exception e )
- {
+ catch (Exception e) {
throw new com.sun.star.lang.WrappedTargetException(e);
}
- if ( thescript == null )
- {
- LogUtils.DEBUG("No script for " + aName );
- throw new com.sun.star.container.NoSuchElementException("No script named " + aName );
+
+ if (thescript == null) {
+ LogUtils.DEBUG("No script for " + aName);
+ throw new com.sun.star.container.NoSuchElementException("No script named " +
+ aName);
}
- ScriptMetaData data = new ScriptMetaData( this, thescript, null );
- LogUtils.DEBUG("returning date for " + aName );
+ ScriptMetaData data = new ScriptMetaData(this, thescript, null);
+
+ LogUtils.DEBUG("returning date for " + aName);
return data;
}
- public String[] getElementNames()
- {
+ public String[] getElementNames() {
String[] results = new String[0];
- if ( m_descriptor != null )
- {
+
+ if (m_descriptor != null) {
ScriptEntry[] scripts = m_descriptor.getScriptEntries();
results = new String[ scripts.length ];
- for ( int index = 0; index < scripts.length; index++ )
- {
+
+ for (int index = 0; index < scripts.length; index++) {
results[ index ] = scripts[ index ].getLanguageName();
}
}
+
return results;
}
- public boolean hasByName( String aName )
- {
+ public boolean hasByName(String aName) {
boolean result = true;
Object containee = null;
- try
- {
- containee = getByName( aName );
- if ( containee != null )
- {
+
+ try {
+ containee = getByName(aName);
+
+ if (containee != null) {
result = true;
}
- }
- catch( Exception e )
- {
+ } catch (Exception e) {
result = false;
}
+
return result;
}
@@ -136,68 +135,64 @@ public class Parcel implements XNameContainer
return new Type();
}
- public boolean hasElements()
- {
+ public boolean hasElements() {
return m_descriptor != null && m_descriptor.getScriptEntries().length > 0;
}
- public void replaceByName( String aName, java.lang.Object aElement ) throws com.sun.star.lang.IllegalArgumentException, com.sun.star.container.NoSuchElementException, com.sun.star.lang.WrappedTargetException
- {
- // TODO check type of aElement
- // if not ok, throw IllegalArgument
- if ( m_descriptor != null )
- {
- try
- {
- ScriptEntry script = (ScriptEntry)getByName( aName );
- if ( script != null )
- {
- //m_descriptor.removeScriptEntry( script );
- // TODO needs to create source file ( if there is one )
- //m_descriptor.write();
- }
- else
- {
- throw new com.sun.star.container.NoSuchElementException("No script named " + aName );
- }
-
-
- }
- // TO DO should catch specified exceptions
- catch ( Exception e )
- {
- throw new com.sun.star.lang.WrappedTargetException();
- }
-
- }
- }
+ public void replaceByName(String aName,
+ java.lang.Object aElement) throws com.sun.star.lang.IllegalArgumentException,
+ com.sun.star.container.NoSuchElementException,
+ com.sun.star.lang.WrappedTargetException {
+ // TODO check type of aElement
+ // if not ok, throw IllegalArgument
+ if (m_descriptor != null) {
+ try {
+ ScriptEntry script = (ScriptEntry)getByName(aName);
+
+ if (script != null) {
+ //m_descriptor.removeScriptEntry( script );
+ // TODO needs to create source file ( if there is one )
+ //m_descriptor.write();
+ } else {
+ throw new com.sun.star.container.NoSuchElementException("No script named " +
+ aName);
+ }
+
+
+ }
+ // TO DO should catch specified exceptions
+ catch (Exception e) {
+ throw new com.sun.star.lang.WrappedTargetException();
+ }
+
+ }
+ }
// create
- public void insertByName( String aName, java.lang.Object aElement ) throws com.sun.star.lang.IllegalArgumentException, ElementExistException, com.sun.star.lang.WrappedTargetException
- {
+ public void insertByName(String aName,
+ java.lang.Object aElement) throws com.sun.star.lang.IllegalArgumentException,
+ ElementExistException, com.sun.star.lang.WrappedTargetException {
// TODO check the type of aElement and throw#
// if not appropriate
- try
- {
- if ( hasByName( aName ) )
- {
- throw new ElementExistException( aName );
+ try {
+ if (hasByName(aName)) {
+ throw new ElementExistException(aName);
}
+
ScriptMetaData script = (ScriptMetaData)aElement;
- if ( script.hasSource() )
- {
+ if (script.hasSource()) {
LogUtils.DEBUG("Inserting source: " + script.getSource());
- if ( !script.writeSourceFile() )
- {
- throw new com.sun.star.lang.WrappedTargetException( "Failed to create source file " + script.getLanguageName() );
+
+ if (!script.writeSourceFile()) {
+ throw new com.sun.star.lang.WrappedTargetException("Failed to create source file "
+ + script.getLanguageName());
}
}
- m_descriptor.addScriptEntry( script );
+
+ m_descriptor.addScriptEntry(script);
writeParcelDescriptor();
- }
- catch ( Exception e )
- {
+ } catch (Exception e) {
LogUtils.DEBUG("Failed to insert entry " + aName + ": " + e.getMessage());
throw new com.sun.star.lang.WrappedTargetException(e);
}
@@ -205,82 +200,80 @@ public class Parcel implements XNameContainer
private void writeParcelDescriptor()
- throws com.sun.star.ucb.CommandAbortedException,
- com.sun.star.io.IOException,
- com.sun.star.uno.Exception, java.io.IOException
- {
+ throws com.sun.star.ucb.CommandAbortedException,
+ com.sun.star.io.IOException,
+ com.sun.star.uno.Exception, java.io.IOException {
String pathToDescriptor = PathUtils.make_url(
- getPathToParcel(), ParcelDescriptor.PARCEL_DESCRIPTOR_NAME );
+ getPathToParcel(), ParcelDescriptor.PARCEL_DESCRIPTOR_NAME);
- XSimpleFileAccess2 xSFA2 = UnoRuntime.queryInterface( XSimpleFileAccess2.class, m_xSFA );
+ XSimpleFileAccess2 xSFA2 = UnoRuntime.queryInterface(XSimpleFileAccess2.class,
+ m_xSFA);
- if ( xSFA2 != null )
- {
+ if (xSFA2 != null) {
ByteArrayOutputStream bos = null;
ByteArrayInputStream bis = null;
XInputStreamImpl xis = null;
- try
- {
- bos = new ByteArrayOutputStream( 1024 );
- m_descriptor.write( bos );
- bis = new ByteArrayInputStream( bos.toByteArray() );
-
- xis = new XInputStreamImpl( bis );
- xSFA2.writeFile( pathToDescriptor, xis );
- }
- finally
- {
+
+ try {
+ bos = new ByteArrayOutputStream(1024);
+ m_descriptor.write(bos);
+ bis = new ByteArrayInputStream(bos.toByteArray());
+
+ xis = new XInputStreamImpl(bis);
+ xSFA2.writeFile(pathToDescriptor, xis);
+ } finally {
if (bos != null) bos.close();
+
if (bis != null) bis.close();
+
if (xis != null) xis.closeInput();
}
}
}
// delete
- public void removeByName( String Name ) throws com.sun.star.container.NoSuchElementException, com.sun.star.lang.WrappedTargetException
- {
- try
- {
- ScriptMetaData script = (ScriptMetaData)getByName( Name );
- if ( script != null )
- {
- if ( !script.removeSourceFile() )
- {
+ public void removeByName(String Name) throws
+ com.sun.star.container.NoSuchElementException,
+ com.sun.star.lang.WrappedTargetException {
+ try {
+ ScriptMetaData script = (ScriptMetaData)getByName(Name);
+
+ if (script != null) {
+ if (!script.removeSourceFile()) {
LogUtils.DEBUG("** Parcel.removeByName Failed to remove script " + Name);
- throw new com.sun.star.lang.WrappedTargetException("Failed to remove script " + Name);
+ throw new com.sun.star.lang.WrappedTargetException("Failed to remove script " +
+ Name);
}
- LogUtils.DEBUG("** Parcel.removeByName have removed script source file " + Name);
- m_descriptor.removeScriptEntry( script );
+
+ LogUtils.DEBUG("** Parcel.removeByName have removed script source file " +
+ Name);
+ m_descriptor.removeScriptEntry(script);
writeParcelDescriptor();
- }
- else
- {
- throw new com.sun.star.container.NoSuchElementException( "No script named " + Name );
+ } else {
+ throw new com.sun.star.container.NoSuchElementException("No script named " +
+ Name);
}
- }
- catch ( Exception e )
- {
- LogUtils.DEBUG("** Parcel.removeByName Exception: " + e );
+ } catch (Exception e) {
+ LogUtils.DEBUG("** Parcel.removeByName Exception: " + e);
throw new com.sun.star.lang.WrappedTargetException(e);
}
}
// rename parcel
- public void rename( String name )
- {
+ public void rename(String name) {
this.name = name;
}
- public ParcelContainer getParent() { return parent; }
+ public ParcelContainer getParent() {
+ return parent;
+ }
/**
* Returns the path of this <tt>Parcel</tt>
*
* @return <tt>String</tt> path to parcel
*/
- public String getPathToParcel()
- {
+ public String getPathToParcel() {
String path = parent.getParcelContainerDir() + "/" + name;
return path;
}
diff --git a/scripting/java/com/sun/star/script/framework/container/ParcelContainer.java b/scripting/java/com/sun/star/script/framework/container/ParcelContainer.java
index 6e954af9b970..75cd6ce542ed 100644
--- a/scripting/java/com/sun/star/script/framework/container/ParcelContainer.java
+++ b/scripting/java/com/sun/star/script/framework/container/ParcelContainer.java
@@ -43,15 +43,15 @@ import com.sun.star.uri.XVndSunStarScriptUrl;
* ScripingFramework specific Libraries.
*/
-public class ParcelContainer implements XNameAccess
-{
+public class ParcelContainer implements XNameAccess {
protected String language;
protected String containerUrl;
private Collection<Parcel> parcels = new ArrayList<Parcel>(10);
static protected XSimpleFileAccess m_xSFA;
protected XComponentContext m_xCtx;
private ParcelContainer parent = null;
- private Collection<ParcelContainer> childContainers = new ArrayList<ParcelContainer>(10);
+ private Collection<ParcelContainer> childContainers = new
+ ArrayList<ParcelContainer>(10);
private boolean isPkgContainer = false;
/**
@@ -60,7 +60,9 @@ public class ParcelContainer implements XNameAccess
*
* @return <tt>true</tt> if has parent <tt>false</tt> otherwise
*/
- public boolean isUnoPkg() { return isPkgContainer; }
+ public boolean isUnoPkg() {
+ return isPkgContainer;
+ }
/**
@@ -68,8 +70,7 @@ public class ParcelContainer implements XNameAccess
*
* @return <tt>ParcelContainer</tt> if has parent null otherwise
*/
- public ParcelContainer parent()
- {
+ public ParcelContainer parent() {
return parent;
}
@@ -80,13 +81,12 @@ public class ParcelContainer implements XNameAccess
* @return a new array of ParcelContainers. A zero
* length array is returned if no child ParcelContainers.
*/
- public ParcelContainer[] getChildContainers()
- {
- if ( childContainers.isEmpty() )
- {
+ public ParcelContainer[] getChildContainers() {
+ if (childContainers.isEmpty()) {
return new ParcelContainer[0];
}
- return childContainers.toArray( new ParcelContainer[childContainers.size()] );
+
+ return childContainers.toArray(new ParcelContainer[childContainers.size()]);
}
/**
@@ -96,9 +96,8 @@ public class ParcelContainer implements XNameAccess
*
* @return <tt>true</tt> if child successfully removed
*/
- public boolean removeChildContainer( ParcelContainer child )
- {
- return childContainers.remove( child );
+ public boolean removeChildContainer(ParcelContainer child) {
+ return childContainers.remove(child);
}
/**
@@ -107,9 +106,8 @@ public class ParcelContainer implements XNameAccess
* @param child <tt>ParcelContainer</tt> to be added.
*
*/
- public void addChildContainer( ParcelContainer child )
- {
- childContainers.add( child );
+ public void addChildContainer(ParcelContainer child) {
+ childContainers.add(child);
}
/**
@@ -121,19 +119,19 @@ public class ParcelContainer implements XNameAccess
* @return child <tt>ParcelContainer</tt> or {@code null} if none
* found.
*/
- public ParcelContainer getChildContainer(String key)
- {
+ public ParcelContainer getChildContainer(String key) {
ParcelContainer result = null;
- for (ParcelContainer c : childContainers)
- {
+
+ for (ParcelContainer c : childContainers) {
String location = ScriptMetaData.getLocationPlaceHolder(
- c.containerUrl, c.getName());
- if ( key.equals( location ) )
- {
+ c.containerUrl, c.getName());
+
+ if (key.equals(location)) {
result = c;
break;
}
}
+
return result;
}
@@ -147,17 +145,16 @@ public class ParcelContainer implements XNameAccess
* @return child <tt>ParcelContainer</tt> or {@code null} if none
* found.
*/
- public ParcelContainer getChildContainerForURL( String containerUrl )
- {
+ public ParcelContainer getChildContainerForURL(String containerUrl) {
ParcelContainer result = null;
- for (ParcelContainer c : childContainers)
- {
- if ( containerUrl.equals( c.containerUrl ) )
- {
+
+ for (ParcelContainer c : childContainers) {
+ if (containerUrl.equals(c.containerUrl)) {
result = c;
break;
}
}
+
return result;
}
@@ -168,33 +165,28 @@ public class ParcelContainer implements XNameAccess
* @return name of <tt>ParcelContainer</tt>
* found.
*/
- public String getName()
- {
+ public String getName() {
String name = null;
+
// TODO handler package ParcelContainer?
- if ( !containerUrl.startsWith( "vnd.sun.star.tdoc:" ) )
- {
- try
- {
+ if (!containerUrl.startsWith("vnd.sun.star.tdoc:")) {
+ try {
// return name
- String decodedUrl = java.net.URLDecoder.decode( containerUrl, "UTF-8" );
+ String decodedUrl = java.net.URLDecoder.decode(containerUrl, "UTF-8");
int indexOfSlash = decodedUrl.lastIndexOf('/');
- if ( indexOfSlash != -1 )
- {
- name = decodedUrl.substring( indexOfSlash + 1 );
+
+ if (indexOfSlash != -1) {
+ name = decodedUrl.substring(indexOfSlash + 1);
}
- }
- catch (UnsupportedEncodingException e)
- {
+ } catch (UnsupportedEncodingException e) {
com.sun.star.uno.RuntimeException e2 = new com.sun.star.uno.RuntimeException();
e2.initCause(e);
throw e2;
}
- }
- else
- {
+ } else {
name = "document";
}
+
return name;
}
@@ -204,10 +196,12 @@ public class ParcelContainer implements XNameAccess
* @param containerUrl location of this container.
* @param language language for which entries are stored
*/
- public ParcelContainer( XComponentContext xCtx, String containerUrl, String language ) throws com.sun.star.lang.IllegalArgumentException, com.sun.star.lang.WrappedTargetException
+ public ParcelContainer(XComponentContext xCtx, String containerUrl,
+ String language) throws com.sun.star.lang.IllegalArgumentException,
+ com.sun.star.lang.WrappedTargetException
{
- this( null, xCtx, containerUrl, language, true );
+ this(null, xCtx, containerUrl, language, true);
}
/**
@@ -218,9 +212,11 @@ public class ParcelContainer implements XNameAccess
* @param loadParcels set to <tt>true</tt> if parcels are to be loaded
* on construction.
*/
- public ParcelContainer( XComponentContext xCtx, String containerUrl, String language, boolean loadParcels ) throws com.sun.star.lang.IllegalArgumentException, com.sun.star.lang.WrappedTargetException
- {
- this( null, xCtx, containerUrl, language, loadParcels );
+ public ParcelContainer(XComponentContext xCtx, String containerUrl,
+ String language, boolean loadParcels) throws
+ com.sun.star.lang.IllegalArgumentException,
+ com.sun.star.lang.WrappedTargetException {
+ this(null, xCtx, containerUrl, language, loadParcels);
}
/**
@@ -232,10 +228,14 @@ public class ParcelContainer implements XNameAccess
* @param loadParcels set to <tt>true</tt> if parcels are to be loaded
* on construction.
*/
- public ParcelContainer( ParcelContainer parent, XComponentContext xCtx, String containerUrl, String language, boolean loadParcels ) throws com.sun.star.lang.IllegalArgumentException, com.sun.star.lang.WrappedTargetException
+ public ParcelContainer(ParcelContainer parent, XComponentContext xCtx,
+ String containerUrl, String language,
+ boolean loadParcels) throws com.sun.star.lang.IllegalArgumentException,
+ com.sun.star.lang.WrappedTargetException
{
- LogUtils.DEBUG("Creating ParcelContainer for " + containerUrl + " loadParcels = " + loadParcels + " language = " + language );
+ LogUtils.DEBUG("Creating ParcelContainer for " + containerUrl +
+ " loadParcels = " + loadParcels + " language = " + language);
this.m_xCtx = xCtx;
this.language = language;
this.parent = parent;
@@ -244,437 +244,413 @@ public class ParcelContainer implements XNameAccess
initSimpleFileAccess();
boolean parentIsPkgContainer = false;
- if ( parent != null )
- {
+ if (parent != null) {
parentIsPkgContainer = parent.isUnoPkg();
}
- if ( containerUrl.endsWith("uno_packages") || parentIsPkgContainer )
- {
+ if (containerUrl.endsWith("uno_packages") || parentIsPkgContainer) {
isPkgContainer = true;
}
- if ( loadParcels )
- {
+ if (loadParcels) {
loadParcels();
}
}
- public String getContainerURL() { return this.containerUrl; }
+ public String getContainerURL() {
+ return this.containerUrl;
+ }
- private synchronized void initSimpleFileAccess()
- {
- if ( m_xSFA != null )
- {
+ private synchronized void initSimpleFileAccess() {
+ if (m_xSFA != null) {
return;
}
- try
- {
+
+ try {
m_xSFA = UnoRuntime.queryInterface(
- XSimpleFileAccess.class,
- m_xCtx.getServiceManager().createInstanceWithContext(
- "com.sun.star.ucb.SimpleFileAccess", m_xCtx ) );
- }
- catch ( Exception e )
- {
+ XSimpleFileAccess.class,
+ m_xCtx.getServiceManager().createInstanceWithContext(
+ "com.sun.star.ucb.SimpleFileAccess", m_xCtx));
+ } catch (Exception e) {
// TODO should throw
LogUtils.DEBUG("Error instantiating simplefile access ");
- LogUtils.DEBUG( LogUtils.getTrace( e ) );
+ LogUtils.DEBUG(LogUtils.getTrace(e));
}
}
- public String getParcelContainerDir()
- {
+ public String getParcelContainerDir() {
// If this container does not represent an uno-package
// then then it is a document, user or share
// in each case the convention is to have a Scripts/[language]
// dir where scripts reside
- if ( !isUnoPkg() )
- {
- return PathUtils.make_url( containerUrl , "Scripts/" + language.toLowerCase() );
+ if (!isUnoPkg()) {
+ return PathUtils.make_url(containerUrl , "Scripts/" + language.toLowerCase());
}
+
return containerUrl;
}
- public Object getByName( String aName ) throws com.sun.star.container.NoSuchElementException, WrappedTargetException
- {
+ public Object getByName(String aName) throws
+ com.sun.star.container.NoSuchElementException, WrappedTargetException {
Parcel parcel = null;
- try
- {
- if ( hasElements() )
- {
- for (Parcel parcelToCheck : parcels)
- {
- if ( parcelToCheck.getName().equals( aName ) )
- {
- parcel = parcelToCheck;
- break;
+
+ try {
+ if (hasElements()) {
+ for (Parcel parcelToCheck : parcels) {
+ if (parcelToCheck.getName().equals(aName)) {
+ parcel = parcelToCheck;
+ break;
}
}
}
- }
- catch ( Exception e)
- {
+ } catch (Exception e) {
throw new WrappedTargetException(e);
}
- if ( parcel == null )
- {
- throw new com.sun.star.container.NoSuchElementException( "Macro Library " + aName + " not found" );
+
+ if (parcel == null) {
+ throw new com.sun.star.container.NoSuchElementException("Macro Library " + aName
+ + " not found");
}
+
return parcel;
}
- public String[] getElementNames()
- {
- if ( hasElements() )
- {
- Parcel[] theParcels = parcels.toArray( new Parcel[parcels.size()] );
+ public String[] getElementNames() {
+ if (hasElements()) {
+ Parcel[] theParcels = parcels.toArray(new Parcel[parcels.size()]);
String[] names = new String[ theParcels.length ];
- for ( int count = 0; count < names.length; count++ )
- {
+
+ for (int count = 0; count < names.length; count++) {
names[count] = theParcels[ count ].getName();
}
+
return names;
}
return new String[0];
}
- public boolean hasByName( String aName )
- {
+ public boolean hasByName(String aName) {
boolean isFound = false;
- try
- {
- if ( getByName( aName ) != null )
- {
+
+ try {
+ if (getByName(aName) != null) {
isFound = true;
}
- }
- catch ( Exception e )
- {
+ } catch (Exception e) {
//TODO - handle trace
}
+
return isFound;
}
- public Type getElementType()
- {
+ public Type getElementType() {
return new Type();
}
- public boolean hasElements()
- {
+ public boolean hasElements() {
return !(parcels == null || parcels.isEmpty());
}
- private void loadParcels() throws com.sun.star.lang.IllegalArgumentException, com.sun.star.lang.WrappedTargetException
- {
- try
- {
- LogUtils.DEBUG("About to load parcels from " + containerUrl );
- if ( m_xSFA.isFolder( getParcelContainerDir() ) )
- {
- LogUtils.DEBUG( getParcelContainerDir() + " is a folder " );
- String[] children = m_xSFA.getFolderContents( getParcelContainerDir(), true );
+ private void loadParcels() throws com.sun.star.lang.IllegalArgumentException,
+ com.sun.star.lang.WrappedTargetException {
+ try {
+ LogUtils.DEBUG("About to load parcels from " + containerUrl);
+
+ if (m_xSFA.isFolder(getParcelContainerDir())) {
+ LogUtils.DEBUG(getParcelContainerDir() + " is a folder ");
+ String[] children = m_xSFA.getFolderContents(getParcelContainerDir(), true);
parcels = new ArrayList<Parcel>(children.length);
- for (String child : children)
- {
+
+ for (String child : children) {
LogUtils.DEBUG("Processing " + child);
- try
- {
+
+ try {
loadParcel(child);
- }
- catch (java.lang.Exception e)
- {
+ } catch (java.lang.Exception e) {
// print an error message and move on to
// the next parcel
- LogUtils.DEBUG("ParcelContainer.loadParcels caught " + e.getClass().getName() + " exception loading parcel " + child + ": " + e.getMessage());
+ LogUtils.DEBUG("ParcelContainer.loadParcels caught " + e.getClass().getName() +
+ " exception loading parcel " + child + ": " + e.getMessage());
}
}
- }
- else
- {
- LogUtils.DEBUG(" ParcelCOntainer.loadParcels " + getParcelContainerDir() + " is not a folder ");
+ } else {
+ LogUtils.DEBUG(" ParcelCOntainer.loadParcels " + getParcelContainerDir() +
+ " is not a folder ");
}
- }
- catch ( com.sun.star.ucb.CommandAbortedException e )
- {
- LogUtils.DEBUG("ParcelContainer.loadParcels caught exception processing folders for " + getParcelContainerDir() );
- LogUtils.DEBUG("TRACE: " + LogUtils.getTrace(e) );
+ } catch (com.sun.star.ucb.CommandAbortedException e) {
+ LogUtils.DEBUG("ParcelContainer.loadParcels caught exception processing folders for "
+ + getParcelContainerDir());
+ LogUtils.DEBUG("TRACE: " + LogUtils.getTrace(e));
throw new com.sun.star.lang.WrappedTargetException(e);
- }
- catch ( com.sun.star.uno.Exception e )
- {
- LogUtils.DEBUG("ParcelContainer.loadParcels caught exception processing folders for " + getParcelContainerDir() );
- LogUtils.DEBUG("TRACE: " + LogUtils.getTrace(e) );
+ } catch (com.sun.star.uno.Exception e) {
+ LogUtils.DEBUG("ParcelContainer.loadParcels caught exception processing folders for "
+ + getParcelContainerDir());
+ LogUtils.DEBUG("TRACE: " + LogUtils.getTrace(e));
throw new com.sun.star.lang.WrappedTargetException(e);
}
}
- public XNameContainer createParcel(String name) throws ElementExistException, com.sun.star.lang.WrappedTargetException
- {
+ public XNameContainer createParcel(String name) throws ElementExistException,
+ com.sun.star.lang.WrappedTargetException {
Parcel p = null;
- if ( hasByName( name ) )
- {
- throw new ElementExistException( "Parcel " + name + " already exists" );
+
+ if (hasByName(name)) {
+ throw new ElementExistException("Parcel " + name + " already exists");
}
- String pathToParcel = PathUtils.make_url( getParcelContainerDir() , name );
- try
- {
- LogUtils.DEBUG("ParcelContainer.createParcel, creating folder " + pathToParcel );
- m_xSFA.createFolder( pathToParcel );
+ String pathToParcel = PathUtils.make_url(getParcelContainerDir() , name);
+
+ try {
+ LogUtils.DEBUG("ParcelContainer.createParcel, creating folder " + pathToParcel);
+ m_xSFA.createFolder(pathToParcel);
- LogUtils.DEBUG("ParcelContainer.createParcel, folder " + pathToParcel + " created ");
+ LogUtils.DEBUG("ParcelContainer.createParcel, folder " + pathToParcel +
+ " created ");
ParcelDescriptor pd = new ParcelDescriptor();
- pd.setLanguage( language );
- String parcelDesc = PathUtils.make_url( pathToParcel, ParcelDescriptor.PARCEL_DESCRIPTOR_NAME );
- XSimpleFileAccess2 xSFA2 = UnoRuntime.queryInterface( XSimpleFileAccess2.class, m_xSFA );
- if ( xSFA2 != null )
- {
- LogUtils.DEBUG("createParcel() Using XSIMPLEFILEACCESS2 " + parcelDesc );
- ByteArrayOutputStream bos = new ByteArrayOutputStream( 1024 );
- pd.write( bos );
+ pd.setLanguage(language);
+ String parcelDesc = PathUtils.make_url(pathToParcel,
+ ParcelDescriptor.PARCEL_DESCRIPTOR_NAME);
+ XSimpleFileAccess2 xSFA2 = UnoRuntime.queryInterface(XSimpleFileAccess2.class,
+ m_xSFA);
+
+ if (xSFA2 != null) {
+ LogUtils.DEBUG("createParcel() Using XSIMPLEFILEACCESS2 " + parcelDesc);
+ ByteArrayOutputStream bos = new ByteArrayOutputStream(1024);
+ pd.write(bos);
bos.close();
- ByteArrayInputStream bis = new ByteArrayInputStream( bos.toByteArray() );
- XInputStreamImpl xis = new XInputStreamImpl( bis );
- xSFA2.writeFile( parcelDesc, xis );
+ ByteArrayInputStream bis = new ByteArrayInputStream(bos.toByteArray());
+ XInputStreamImpl xis = new XInputStreamImpl(bis);
+ xSFA2.writeFile(parcelDesc, xis);
xis.closeInput();
- p = loadParcel( pathToParcel );
+ p = loadParcel(pathToParcel);
}
- }
- catch ( Exception e )
- {
+ } catch (Exception e) {
- LogUtils.DEBUG("createParcel() Exception while attempting to create = " + name );
+ LogUtils.DEBUG("createParcel() Exception while attempting to create = " + name);
throw new com.sun.star.lang.WrappedTargetException(e);
}
+
return p;
}
- public Parcel loadParcel( String parcelUrl ) throws com.sun.star.lang.WrappedTargetException, com.sun.star.lang.IllegalArgumentException
- {
+ public Parcel loadParcel(String parcelUrl) throws
+ com.sun.star.lang.WrappedTargetException,
+ com.sun.star.lang.IllegalArgumentException {
- String parcelDescUrl = PathUtils.make_url( parcelUrl, ParcelDescriptor.PARCEL_DESCRIPTOR_NAME );
+ String parcelDescUrl = PathUtils.make_url(parcelUrl,
+ ParcelDescriptor.PARCEL_DESCRIPTOR_NAME);
Parcel parcel = null;
XInputStream xis = null;
InputStream is = null;
- try
- {
- if ( m_xSFA.exists( parcelDescUrl ) )
- {
- LogUtils.DEBUG("ParcelContainer.loadParcel opening " + parcelDescUrl );
- xis = m_xSFA.openFileRead( parcelDescUrl );
- is = new XInputStreamWrapper( xis );
+ try {
+ if (m_xSFA.exists(parcelDescUrl)) {
+ LogUtils.DEBUG("ParcelContainer.loadParcel opening " + parcelDescUrl);
+ xis = m_xSFA.openFileRead(parcelDescUrl);
+ is = new XInputStreamWrapper(xis);
ParcelDescriptor pd = new ParcelDescriptor(is) ;
- try
- {
+
+ try {
is.close();
is = null;
+ } catch (Exception e) {
+ LogUtils.DEBUG("ParcelContainer.loadParcel Exception when closing stream for "
+ + parcelDescUrl + " :" + e);
}
- catch ( Exception e )
- {
- LogUtils.DEBUG("ParcelContainer.loadParcel Exception when closing stream for " + parcelDescUrl + " :" + e );
- }
- LogUtils.DEBUG("ParcelContainer.loadParcel closed " + parcelDescUrl );
- if ( !pd.getLanguage().equals( language ) )
- {
+
+ LogUtils.DEBUG("ParcelContainer.loadParcel closed " + parcelDescUrl);
+
+ if (!pd.getLanguage().equals(language)) {
LogUtils.DEBUG("ParcelContainer.loadParcel Language of Parcel does not match this container ");
return null;
}
- LogUtils.DEBUG("Processing " + parcelDescUrl + " closed " );
+
+ LogUtils.DEBUG("Processing " + parcelDescUrl + " closed ");
int indexOfSlash = parcelUrl.lastIndexOf('/');
- String name = parcelUrl.substring( indexOfSlash + 1 );
+ String name = parcelUrl.substring(indexOfSlash + 1);
- parcel = new Parcel( m_xSFA, this, pd, name );
+ parcel = new Parcel(m_xSFA, this, pd, name);
- LogUtils.DEBUG(" ParcelContainer.loadParcel created parcel for " + parcelDescUrl + " for language " + language );
- parcels.add( parcel );
- }
- else
- {
- throw new java.io.IOException( parcelDescUrl + " does NOT exist!");
+ LogUtils.DEBUG(" ParcelContainer.loadParcel created parcel for " + parcelDescUrl
+ + " for language " + language);
+ parcels.add(parcel);
+ } else {
+ throw new java.io.IOException(parcelDescUrl + " does NOT exist!");
}
- }
- catch ( com.sun.star.ucb.CommandAbortedException e )
- {
+ } catch (com.sun.star.ucb.CommandAbortedException e) {
- LogUtils.DEBUG("loadParcel() Exception while accessing filesystem url = " + parcelDescUrl + e );
+ LogUtils.DEBUG("loadParcel() Exception while accessing filesystem url = " +
+ parcelDescUrl + e);
throw new com.sun.star.lang.WrappedTargetException(e);
- }
- catch ( java.io.IOException e )
- {
- LogUtils.DEBUG("ParcelContainer.loadParcel() caught IOException while accessing " + parcelDescUrl + ": " + e );
+ } catch (java.io.IOException e) {
+ LogUtils.DEBUG("ParcelContainer.loadParcel() caught IOException while accessing "
+ + parcelDescUrl + ": " + e);
throw new com.sun.star.lang.WrappedTargetException(e);
- }
- catch ( com.sun.star.uno.Exception e )
- {
+ } catch (com.sun.star.uno.Exception e) {
- LogUtils.DEBUG("loadParcel() Exception while accessing filesystem url = " + parcelDescUrl + e );
+ LogUtils.DEBUG("loadParcel() Exception while accessing filesystem url = " +
+ parcelDescUrl + e);
throw new com.sun.star.lang.WrappedTargetException(e);
}
- finally
- {
- if ( is != null )
- {
- try
- {
+ finally {
+ if (is != null) {
+ try {
is.close(); // is will close xis
+ } catch (Exception ignore) {
}
- catch ( Exception ignore )
- {
- }
- }
- else if ( xis != null )
- {
- try
- {
+ } else if (xis != null) {
+ try {
xis.closeInput();
- }
- catch ( Exception ignore )
- {
+ } catch (Exception ignore) {
}
}
}
+
return parcel;
}
- public void renameParcel(String oldName, String newName) throws com.sun.star.container.NoSuchElementException, com.sun.star.lang.WrappedTargetException
- {
- LogUtils.DEBUG(" ** ParcelContainer Renaming parcel " + oldName + " to " + newName );
- LogUtils.DEBUG(" ** ParcelContainer is " + this );
- Parcel p = (Parcel)getByName( oldName );
- if ( p == null )
- {
- throw new com.sun.star.container.NoSuchElementException( "No parcel named " + oldName );
- }
- String oldParcelDirUrl = PathUtils.make_url( getParcelContainerDir(),
- oldName );
- String newParcelDirUrl = PathUtils.make_url( getParcelContainerDir(),
- newName );
- try
- {
- if (!m_xSFA.isFolder( oldParcelDirUrl ) )
- {
- Exception e = new com.sun.star.io.IOException("Invalid Parcel directory: " + oldName );
+ public void renameParcel(String oldName,
+ String newName) throws com.sun.star.container.NoSuchElementException,
+ com.sun.star.lang.WrappedTargetException {
+ LogUtils.DEBUG(" ** ParcelContainer Renaming parcel " + oldName + " to " +
+ newName);
+ LogUtils.DEBUG(" ** ParcelContainer is " + this);
+ Parcel p = (Parcel)getByName(oldName);
+
+ if (p == null) {
+ throw new com.sun.star.container.NoSuchElementException("No parcel named " +
+ oldName);
+ }
+
+ String oldParcelDirUrl = PathUtils.make_url(getParcelContainerDir(),
+ oldName);
+ String newParcelDirUrl = PathUtils.make_url(getParcelContainerDir(),
+ newName);
+
+ try {
+ if (!m_xSFA.isFolder(oldParcelDirUrl)) {
+ Exception e = new com.sun.star.io.IOException("Invalid Parcel directory: " +
+ oldName);
throw new com.sun.star.lang.WrappedTargetException(e);
}
- LogUtils.DEBUG(" ** ParcelContainer Renaming folder " + oldParcelDirUrl + " to " + newParcelDirUrl );
- m_xSFA.move( oldParcelDirUrl, newParcelDirUrl );
- }
- catch ( com.sun.star.ucb.CommandAbortedException ce )
- {
- LogUtils.DEBUG(" ** ParcelContainer Renaming failed with " + ce );
+
+ LogUtils.DEBUG(" ** ParcelContainer Renaming folder " + oldParcelDirUrl + " to "
+ + newParcelDirUrl);
+ m_xSFA.move(oldParcelDirUrl, newParcelDirUrl);
+ } catch (com.sun.star.ucb.CommandAbortedException ce) {
+ LogUtils.DEBUG(" ** ParcelContainer Renaming failed with " + ce);
throw new com.sun.star.lang.WrappedTargetException(ce);
- }
- catch ( com.sun.star.uno.Exception e )
- {
- LogUtils.DEBUG(" ** ParcelContainer Renaming failed with " + e );
+ } catch (com.sun.star.uno.Exception e) {
+ LogUtils.DEBUG(" ** ParcelContainer Renaming failed with " + e);
throw new com.sun.star.lang.WrappedTargetException(e);
}
- p.rename( newName );
+ p.rename(newName);
}
// removes but doesn't physically delele parcel from container
- public boolean removeParcel(String name) throws com.sun.star.container.NoSuchElementException, com.sun.star.lang.WrappedTargetException
- {
- Parcel p = (Parcel)getByName( name );
- if ( p == null )
- {
- throw new com.sun.star.container.NoSuchElementException("No parcel named " + name );
+ public boolean removeParcel(String name) throws
+ com.sun.star.container.NoSuchElementException,
+ com.sun.star.lang.WrappedTargetException {
+ Parcel p = (Parcel)getByName(name);
+
+ if (p == null) {
+ throw new com.sun.star.container.NoSuchElementException("No parcel named " +
+ name);
}
- return parcels.remove( p );
+ return parcels.remove(p);
}
- public boolean deleteParcel(String name) throws com.sun.star.container.NoSuchElementException, com.sun.star.lang.WrappedTargetException
- {
- LogUtils.DEBUG( "deleteParcel for containerURL " + containerUrl + " name = " + name + " Langueg = " + language );
+ public boolean deleteParcel(String name) throws
+ com.sun.star.container.NoSuchElementException,
+ com.sun.star.lang.WrappedTargetException {
+ LogUtils.DEBUG("deleteParcel for containerURL " + containerUrl + " name = " +
+ name + " Langueg = " + language);
- Parcel p = (Parcel)getByName( name );
- if ( p == null )
- {
- throw new com.sun.star.container.NoSuchElementException("No parcel named " + name );
- }
+ Parcel p = (Parcel)getByName(name);
- try
- {
- String pathToParcel = PathUtils.make_url( getParcelContainerDir(), name );
- m_xSFA.kill( pathToParcel );
+ if (p == null) {
+ throw new com.sun.star.container.NoSuchElementException("No parcel named " +
+ name);
}
- catch( Exception e )
- {
- LogUtils.DEBUG("Error deleteing parcel " + name );
+
+ try {
+ String pathToParcel = PathUtils.make_url(getParcelContainerDir(), name);
+ m_xSFA.kill(pathToParcel);
+ } catch (Exception e) {
+ LogUtils.DEBUG("Error deleteing parcel " + name);
throw new com.sun.star.lang.WrappedTargetException(e);
}
- return parcels.remove( p );
+ return parcels.remove(p);
}
- public String getLanguage() { return language; }
+ public String getLanguage() {
+ return language;
+ }
- public ScriptMetaData findScript( ParsedScriptUri parsedUri ) throws com.sun.star.container.NoSuchElementException, com.sun.star.lang.WrappedTargetException
- {
- Parcel p = (Parcel)getByName( parsedUri.parcel);
- ScriptMetaData scriptData = (ScriptMetaData)p.getByName( parsedUri.function);
- LogUtils.DEBUG("** found script data for " + parsedUri.function + " script is " + scriptData );
+ public ScriptMetaData findScript(ParsedScriptUri parsedUri) throws
+ com.sun.star.container.NoSuchElementException,
+ com.sun.star.lang.WrappedTargetException {
+ Parcel p = (Parcel)getByName(parsedUri.parcel);
+ ScriptMetaData scriptData = (ScriptMetaData)p.getByName(parsedUri.function);
+ LogUtils.DEBUG("** found script data for " + parsedUri.function + " script is "
+ + scriptData);
return scriptData;
}
-public ParsedScriptUri parseScriptUri( String scriptURI ) throws com.sun.star.lang.IllegalArgumentException
-{
+ public ParsedScriptUri parseScriptUri(String scriptURI) throws
+ com.sun.star.lang.IllegalArgumentException {
XMultiComponentFactory xMcFac = null;
XUriReferenceFactory xFac = null;
- try
- {
+ try {
xMcFac = m_xCtx.getServiceManager();
- xFac = UnoRuntime.queryInterface( XUriReferenceFactory.class,
- xMcFac.createInstanceWithContext(
- "com.sun.star.uri.UriReferenceFactory", m_xCtx ) );
- }
- catch( com.sun.star.uno.Exception e )
- {
- LogUtils.DEBUG("Problems parsing URL:" + e.toString() );
+ xFac = UnoRuntime.queryInterface(XUriReferenceFactory.class,
+ xMcFac.createInstanceWithContext(
+ "com.sun.star.uri.UriReferenceFactory", m_xCtx));
+ } catch (com.sun.star.uno.Exception e) {
+ LogUtils.DEBUG("Problems parsing URL:" + e.toString());
throw new com.sun.star.lang.IllegalArgumentException(e, "Problems parsing URL");
}
- if ( xFac == null )
- {
+
+ if (xFac == null) {
LogUtils.DEBUG("Failed to create UrlReference factory");
- throw new com.sun.star.lang.IllegalArgumentException( "Failed to create UrlReference factory for url " + scriptURI );
+ throw new com.sun.star.lang.IllegalArgumentException("Failed to create UrlReference factory for url "
+ + scriptURI);
}
- XUriReference uriRef = xFac.parse( scriptURI );
- XVndSunStarScriptUrl sfUri = UnoRuntime.queryInterface( XVndSunStarScriptUrl.class, uriRef );
+ XUriReference uriRef = xFac.parse(scriptURI);
+ XVndSunStarScriptUrl sfUri = UnoRuntime.queryInterface(
+ XVndSunStarScriptUrl.class, uriRef);
- if ( sfUri == null )
- {
+ if (sfUri == null) {
LogUtils.DEBUG("Failed to parse url");
- throw new com.sun.star.lang.IllegalArgumentException( "Failed to parse url " + scriptURI );
+ throw new com.sun.star.lang.IllegalArgumentException("Failed to parse url " +
+ scriptURI);
}
ParsedScriptUri parsedUri = new ParsedScriptUri();
- parsedUri.function= sfUri.getName();
+ parsedUri.function = sfUri.getName();
parsedUri.parcel = "";
// parse parcel name;
- StringTokenizer tokenizer = new StringTokenizer( parsedUri.function, "." );
+ StringTokenizer tokenizer = new StringTokenizer(parsedUri.function, ".");
- if ( tokenizer.hasMoreElements() )
- {
+ if (tokenizer.hasMoreElements()) {
parsedUri.parcel = (String)tokenizer.nextElement();
- LogUtils.DEBUG("** parcelName = " + parsedUri.parcel );
+ LogUtils.DEBUG("** parcelName = " + parsedUri.parcel);
}
- if ( parsedUri.function != null && ( parsedUri.function.length() > 0 ) )
- {
+ if (parsedUri.function != null && (parsedUri.function.length() > 0)) {
// strip out parcel name
- parsedUri.function = parsedUri.function.substring( parsedUri.parcel.length() + 1);
+ parsedUri.function = parsedUri.function.substring(parsedUri.parcel.length() +
+ 1);
}
// parse location
@@ -685,11 +661,11 @@ public ParsedScriptUri parseScriptUri( String scriptURI ) throws com.sun.star.l
// time its got to here
LogUtils.DEBUG("** location = " + parsedUri.location +
- "\nfunction = " + parsedUri.function +
- "\nparcel = " + parsedUri.parcel +
- "\nlocation = " + parsedUri.location );
+ "\nfunction = " + parsedUri.function +
+ "\nparcel = " + parsedUri.parcel +
+ "\nlocation = " + parsedUri.location);
return parsedUri;
-}
+ }
}
diff --git a/scripting/java/com/sun/star/script/framework/container/ParcelDescriptor.java b/scripting/java/com/sun/star/script/framework/container/ParcelDescriptor.java
index 2d44ff55944e..77b2f9fb3810 100644
--- a/scripting/java/com/sun/star/script/framework/container/ParcelDescriptor.java
+++ b/scripting/java/com/sun/star/script/framework/container/ParcelDescriptor.java
@@ -38,10 +38,11 @@ public class ParcelDescriptor {
// File name to be used for parcel descriptor files
public static final String
- PARCEL_DESCRIPTOR_NAME = "parcel-descriptor.xml";
+ PARCEL_DESCRIPTOR_NAME = "parcel-descriptor.xml";
// Collection of all ParcelDescriptor created for files
- private static final Map<File,ParcelDescriptor> PARCEL_DESCRIPTOR_MAP = new HashMap<File,ParcelDescriptor>(5);
+ private static final Map<File, ParcelDescriptor> PARCEL_DESCRIPTOR_MAP = new
+ HashMap<File, ParcelDescriptor>(5);
// This is the default contents of a parcel descriptor to be used when
// creating empty descriptors
@@ -53,7 +54,7 @@ public class ParcelDescriptor {
private File file = null;
private Document document = null;
private String language = null;
- private Map<String,String> languagedepprops = new HashMap<String,String>(3);
+ private Map<String, String> languagedepprops = new HashMap<String, String>(3);
@@ -61,11 +62,11 @@ public class ParcelDescriptor {
public ParcelDescriptor() throws IOException {
ByteArrayInputStream bis = null;
+
try {
bis = new ByteArrayInputStream(EMPTY_DOCUMENT);
this.document = XMLParserFactory.getParser().parse(bis);
- }
- finally {
+ } finally {
if (bis != null)
bis.close();
}
@@ -89,27 +90,28 @@ public class ParcelDescriptor {
if (file.exists()) {
FileInputStream fis = null;
+
try {
fis = new FileInputStream(file);
this.document = XMLParserFactory.getParser().parse(fis);
- }
- finally {
+ } finally {
if (fis != null)
fis.close();
}
- }
- else {
+ } else {
ByteArrayInputStream bis = null;
+
try {
bis = new ByteArrayInputStream(EMPTY_DOCUMENT);
this.document = XMLParserFactory.getParser().parse(bis);
- }
- finally {
+ } finally {
if (bis != null)
bis.close();
}
+
setLanguage(language);
}
+
initLanguageProperties();
}
@@ -128,6 +130,7 @@ public class ParcelDescriptor {
language = e.getAttribute("language");
}
}
+
return language;
}
@@ -138,8 +141,7 @@ public class ParcelDescriptor {
try {
Element e = document.getDocumentElement();
e.setAttribute("language", language);
- }
- catch (DOMException de) {
+ } catch (DOMException de) {
}
}
}
@@ -156,7 +158,7 @@ public class ParcelDescriptor {
for (int i = 0; i < len; i++) {
String language, languagename, logicalname, description = "";
- Map<String,String> langProps = new HashMap<String,String>();
+ Map<String, String> langProps = new HashMap<String, String>();
NodeList nl;
Element tmp;
@@ -164,6 +166,7 @@ public class ParcelDescriptor {
language = scriptElement.getAttribute("language");
nl = scriptElement.getElementsByTagName("logicalname");
+
if (nl == null)
logicalname = "";
else {
@@ -173,15 +176,13 @@ public class ParcelDescriptor {
// get the text of the description element
nl = scriptElement.getElementsByTagName("locale");
- if (nl != null)
- {
+
+ if (nl != null) {
nl = nl.item(0).getChildNodes();
- if (nl != null)
- {
- for (int j = 0 ; j < nl.getLength(); j++)
- {
- if (nl.item(j).getNodeName().equals("description"))
- {
+
+ if (nl != null) {
+ for (int j = 0 ; j < nl.getLength(); j++) {
+ if (nl.item(j).getNodeName().equals("description")) {
CharacterData cd =
(CharacterData)nl.item(j).getFirstChild();
description = cd.getData().trim();
@@ -191,36 +192,41 @@ public class ParcelDescriptor {
}
nl = scriptElement.getElementsByTagName("functionname");
+
if (nl == null) {
languagename = "";
} else {
tmp = (Element)nl.item(0);
languagename = tmp.getAttribute("value");
}
+
nl = scriptElement.getElementsByTagName("languagedepprops");
- if ( nl != null && nl.getLength() > 0 )
- {
+
+ if (nl != null && nl.getLength() > 0) {
NodeList props = ((Element)nl.item(0)).getElementsByTagName("prop");
- if ( props != null )
- {
- for ( int j=0; j < props.getLength(); j++ )
- {
+
+ if (props != null) {
+ for (int j = 0; j < props.getLength(); j++) {
tmp = (Element)props.item(j);
String key = tmp.getAttribute("name");
String val = tmp.getAttribute("value");
- langProps.put( key,val );
+ langProps.put(key, val);
}
}
}
- ScriptEntry entry = new ScriptEntry(language, languagename, "", langProps,description);
+
+ ScriptEntry entry = new ScriptEntry(language, languagename, "", langProps,
+ description);
scripts.add(entry);
}
+
return scripts.toArray(new ScriptEntry[scripts.size()]);
}
public void setScriptEntries(ScriptEntry[] scripts) {
clearEntries();
+
for (ScriptEntry script : scripts) {
addScriptEntry(script);
}
@@ -228,6 +234,7 @@ public class ParcelDescriptor {
public void setScriptEntries(Iterator<ScriptEntry> scripts) {
clearEntries();
+
while (scripts.hasNext())
addScriptEntry(scripts.next());
}
@@ -271,13 +278,11 @@ public class ParcelDescriptor {
int len;
if ((scriptNodes = document.getElementsByTagName("script")) != null &&
- (len = scriptNodes.getLength()) != 0)
- {
+ (len = scriptNodes.getLength()) != 0) {
for (int i = len - 1; i >= 0; i--) {
try {
main.removeChild(scriptNodes.item(i));
- }
- catch (DOMException de) {
+ } catch (DOMException de) {
// ignore
}
}
@@ -290,8 +295,7 @@ public class ParcelDescriptor {
int len;
if ((scriptNodes = document.getElementsByTagName("script")) != null &&
- (len = scriptNodes.getLength()) != 0)
- {
+ (len = scriptNodes.getLength()) != 0) {
for (int i = len - 1; i >= 0; i--) {
try {
Element scriptElement = (Element)scriptNodes.item(i);
@@ -299,6 +303,7 @@ public class ParcelDescriptor {
NodeList nl =
scriptElement.getElementsByTagName("functionname");
+
if (nl == null) {
continue;
} else {
@@ -309,8 +314,7 @@ public class ParcelDescriptor {
if (languagename.equals(script.getLanguageName())) {
main.removeChild(scriptElement);
}
- }
- catch (DOMException de) {
+ } catch (DOMException de) {
// ignore
}
}
@@ -332,10 +336,11 @@ public class ParcelDescriptor {
tempitem = document.createElement("description");
String description = script.getDescription();
- if (description == null || description.length() == 0)
- {
+
+ if (description == null || description.length() == 0) {
description = script.getLogicalName();
}
+
tempitem.appendChild(document.createTextNode(description));
item.appendChild(tempitem);
@@ -354,6 +359,7 @@ public class ParcelDescriptor {
item = document.createElement("languagedepprops");
Iterator<String> iter = languagedepprops.keySet().iterator();
+
while (iter.hasNext()) {
tempitem = document.createElement("prop");
key = iter.next();
@@ -361,6 +367,7 @@ public class ParcelDescriptor {
tempitem.setAttribute("value", languagedepprops.get(key));
item.appendChild(tempitem);
}
+
root.appendChild(item);
}
diff --git a/scripting/java/com/sun/star/script/framework/container/ParsedScriptUri.java b/scripting/java/com/sun/star/script/framework/container/ParsedScriptUri.java
index 477604c721ac..65d6f4e68a28 100644
--- a/scripting/java/com/sun/star/script/framework/container/ParsedScriptUri.java
+++ b/scripting/java/com/sun/star/script/framework/container/ParsedScriptUri.java
@@ -17,8 +17,7 @@
*/
package com.sun.star.script.framework.container;
-public class ParsedScriptUri
-{
+public class ParsedScriptUri {
public String location;
public String function;
diff --git a/scripting/java/com/sun/star/script/framework/container/ScriptEntry.java b/scripting/java/com/sun/star/script/framework/container/ScriptEntry.java
index b4d6a70e8e22..6f0ae24e9647 100644
--- a/scripting/java/com/sun/star/script/framework/container/ScriptEntry.java
+++ b/scripting/java/com/sun/star/script/framework/container/ScriptEntry.java
@@ -27,7 +27,7 @@ public class ScriptEntry implements Cloneable {
private String logicalname = "";
private String description = "";
- private Map<String,String> languagedepprops;
+ private Map<String, String> languagedepprops;
public ScriptEntry(String language, String languagename,
String location) {
@@ -39,11 +39,10 @@ public class ScriptEntry implements Cloneable {
// as logical name also
this.logicalname = languagename;
this.location = location;
- this.languagedepprops = new HashMap<String,String>();
+ this.languagedepprops = new HashMap<String, String>();
}
- public ScriptEntry(ScriptEntry entry)
- {
+ public ScriptEntry(ScriptEntry entry) {
this.language = entry.language;
this.languagename = entry.languagename;
this.logicalname = entry.languagename;
@@ -53,15 +52,15 @@ public class ScriptEntry implements Cloneable {
}
public ScriptEntry(String language, String languagename,
- String location, Map<String,String> languagedepprops) {
- this( language, languagename, location );
+ String location, Map<String, String> languagedepprops) {
+ this(language, languagename, location);
this.languagedepprops = languagedepprops;
}
public ScriptEntry(String language, String languagename,
- String location, Map<String,String> languagedepprops,
+ String location, Map<String, String> languagedepprops,
String description) {
- this( language, languagename, location );
+ this(language, languagename, location);
this.languagedepprops = languagedepprops;
this.description = description;
}
@@ -77,14 +76,13 @@ public class ScriptEntry implements Cloneable {
public boolean equals(ScriptEntry other) {
return language.equals(other.getLanguage()) &&
- languagename.equals(other.getLanguageName()) &&
- logicalname.equals(other.getLogicalName()) &&
- languagedepprops.equals(other.getLanguageProperties()) &&
- location.equals(other.getLocation());
+ languagename.equals(other.getLanguageName()) &&
+ logicalname.equals(other.getLogicalName()) &&
+ languagedepprops.equals(other.getLanguageProperties()) &&
+ location.equals(other.getLocation());
}
- public Map<String,String> getLanguageProperties()
- {
+ public Map<String, String> getLanguageProperties() {
return languagedepprops;
}
@@ -114,6 +112,7 @@ public class ScriptEntry implements Cloneable {
@Override
public String toString() {
- return "\nLogicalName = " + logicalname + "\nLanguageName = " + languagename + "\nLocation = " + location + "\nLanguaguageProperties = " + languagedepprops;
+ return "\nLogicalName = " + logicalname + "\nLanguageName = " + languagename +
+ "\nLocation = " + location + "\nLanguaguageProperties = " + languagedepprops;
}
}
diff --git a/scripting/java/com/sun/star/script/framework/container/ScriptMetaData.java b/scripting/java/com/sun/star/script/framework/container/ScriptMetaData.java
index d55b226d83df..42d237d44ec5 100644
--- a/scripting/java/com/sun/star/script/framework/container/ScriptMetaData.java
+++ b/scripting/java/com/sun/star/script/framework/container/ScriptMetaData.java
@@ -42,49 +42,47 @@ public class ScriptMetaData extends ScriptEntry {
private Parcel parent;
- public ScriptMetaData( Parcel parent, ScriptEntry entry,
- String source )
- {
- super( entry );
+ public ScriptMetaData(Parcel parent, ScriptEntry entry,
+ String source) {
+ super(entry);
this.parent = parent;
- if ( source != null )
- {
+
+ if (source != null) {
this.hasSource = true;
this.source = source;
}
}
- public boolean hasSource()
- {
+ public boolean hasSource() {
return hasSource;
}
public String getSource() {
- return ( source !=null && hasSource ) ? source : null;
+ return (source != null && hasSource) ? source : null;
}
public byte[] getSourceBytes() {
- return ( source !=null && hasSource ) ? source.getBytes() : null;
+ return (source != null && hasSource) ? source.getBytes() : null;
}
public boolean equals(ScriptMetaData other) {
return super.equals(other) && hasSource == other.hasSource();
}
- public String getScriptFullURL()
- {
- String url = "vnd.sun.star.script:" + parent.getName() + "." + getLanguageName() +
- "?" + "language=" + getLanguage() +
- "&location=" + getParcelLocation();
- return url;
+ public String getScriptFullURL() {
+ String url = "vnd.sun.star.script:" + parent.getName() + "." + getLanguageName()
+ +
+ "?" + "language=" + getLanguage() +
+ "&location=" + getParcelLocation();
+ return url;
}
- public String getShortFormScriptURL()
- {
- String url = "vnd.sun.star.script:" + parent.getName() + "." + getLanguageName() +
- "?" + "language=" + getLanguage() +
- "&location=" + getLocationPlaceHolder();
+ public String getShortFormScriptURL() {
+ String url = "vnd.sun.star.script:" + parent.getName() + "." + getLanguageName()
+ +
+ "?" + "language=" + getLanguage() +
+ "&location=" + getLocationPlaceHolder();
return url;
}
@@ -111,78 +109,60 @@ public class ScriptMetaData extends ScriptEntry {
private static final String UNO_SHARED_PACKAGES2 =
SHARE + "/uno_packages";
- public static String getLocationPlaceHolder(String url, String pkgname)
- {
+ public static String getLocationPlaceHolder(String url, String pkgname) {
String result = "Unknown";
- if ( url.contains(UNO_USER_PACKAGES1) ||
- url.contains(UNO_USER_PACKAGES2) )
- {
- result = PathUtils.make_url( "user:uno_packages", pkgname );
- }
- else if ( url.contains(UNO_SHARED_PACKAGES1) ||
- url.contains(UNO_SHARED_PACKAGES2) )
- {
- result = PathUtils.make_url( "share:uno_packages", pkgname );
- }
- else if ( url.indexOf(SHARE) == 0 )
- {
+ if (url.contains(UNO_USER_PACKAGES1) ||
+ url.contains(UNO_USER_PACKAGES2)) {
+ result = PathUtils.make_url("user:uno_packages", pkgname);
+ } else if (url.contains(UNO_SHARED_PACKAGES1) ||
+ url.contains(UNO_SHARED_PACKAGES2)) {
+ result = PathUtils.make_url("share:uno_packages", pkgname);
+ } else if (url.indexOf(SHARE) == 0) {
result = "share";
- }
- else if ( url.indexOf(USER) == 0 )
- {
+ } else if (url.indexOf(USER) == 0) {
result = "user";
- }
- else if ( url.indexOf("vnd.sun.star.tdoc:") == 0 )
- {
+ } else if (url.indexOf("vnd.sun.star.tdoc:") == 0) {
result = "document";
}
+
return result;
}
- public String getLocationPlaceHolder()
- {
+ public String getLocationPlaceHolder() {
String placeHolder = "Unknown";
String pathToParcel = parent.getPathToParcel();
- if ( pathToParcel.contains(UNO_USER_PACKAGES1) ||
- pathToParcel.contains(UNO_USER_PACKAGES2) )
- {
+ if (pathToParcel.contains(UNO_USER_PACKAGES1) ||
+ pathToParcel.contains(UNO_USER_PACKAGES2)) {
// it's a package
placeHolder = "user:uno_packages";
String unoPkg = parent.parent.getName();
- if ( unoPkg != null )
- {
- placeHolder = PathUtils.make_url( placeHolder, unoPkg );
+
+ if (unoPkg != null) {
+ placeHolder = PathUtils.make_url(placeHolder, unoPkg);
}
- }
- else if ( pathToParcel.contains(UNO_SHARED_PACKAGES1) ||
- pathToParcel.contains(UNO_SHARED_PACKAGES2) )
- {
+ } else if (pathToParcel.contains(UNO_SHARED_PACKAGES1) ||
+ pathToParcel.contains(UNO_SHARED_PACKAGES2)) {
//its a package
placeHolder = "share:uno_packages";
String unoPkg = parent.parent.getName();
- if ( unoPkg != null )
- {
- placeHolder = PathUtils.make_url( placeHolder, unoPkg );
+
+ if (unoPkg != null) {
+ placeHolder = PathUtils.make_url(placeHolder, unoPkg);
}
- }
- else if ( pathToParcel.indexOf(SHARE) == 0 )
- {
+ } else if (pathToParcel.indexOf(SHARE) == 0) {
placeHolder = "share";
- }
- else if ( pathToParcel.indexOf(USER) == 0 )
- {
+ } else if (pathToParcel.indexOf(USER) == 0) {
placeHolder = "user";
- }
- else if ( pathToParcel.indexOf("vnd.sun.star.tdoc:") == 0 )
- {
+ } else if (pathToParcel.indexOf("vnd.sun.star.tdoc:") == 0) {
placeHolder = "document";
}
+
// TODO handling document packages ??? not really sure of package url
-/* else
- {
- } */
+ /* else
+ {
+ } */
return placeHolder;
}
@@ -193,76 +173,69 @@ public class ScriptMetaData extends ScriptEntry {
// Also if it is to remain needs to be renamed to getParcelLocationURL
// return URL string to parcel
- public String getParcelLocation()
- {
+ public String getParcelLocation() {
return parent.getPathToParcel();
}
@Override
- public String toString()
- {
- return "\nParcelLocation = " + getParcelLocation() + "\nLocationPlaceHolder = " + locationPlaceHolder + super.toString();
+ public String toString() {
+ return "\nParcelLocation = " + getParcelLocation() + "\nLocationPlaceHolder = "
+ + locationPlaceHolder + super.toString();
}
- public URL[] getClassPath()
- {
- try
- {
- String classpath = getLanguageProperties().get("classpath");
+ public URL[] getClassPath() {
+ try {
+ String classpath = getLanguageProperties().get("classpath");
- if ( classpath == null )
- {
- classpath = "";
- }
+ if (classpath == null) {
+ classpath = "";
+ }
- String parcelPath = getParcelLocation();
- // make sure path ends with /
- if ( !parcelPath.endsWith("/") )
- {
- parcelPath += "/";
- }
+ String parcelPath = getParcelLocation();
+
+ // make sure path ends with /
+ if (!parcelPath.endsWith("/")) {
+ parcelPath += "/";
+ }
- // replace \ with /
- parcelPath = parcelPath.replace( '\\', '/' );
+ // replace \ with /
+ parcelPath = parcelPath.replace('\\', '/');
+
+ ArrayList<URL> classPathVec = new ArrayList<URL>();
+ StringTokenizer stk = new StringTokenizer(classpath, ":");
+
+ while (stk.hasMoreElements()) {
+ String relativeClasspath = stk.nextToken();
+ String pathToProcess = PathUtils.make_url(parcelPath, relativeClasspath);
+ URL url = createURL(pathToProcess);
+
+ if (url != null) {
+ classPathVec.add(url);
+ }
- ArrayList<URL> classPathVec = new ArrayList<URL>();
- StringTokenizer stk = new StringTokenizer(classpath, ":");
- while ( stk.hasMoreElements() )
- {
- String relativeClasspath = stk.nextToken();
- String pathToProcess = PathUtils.make_url( parcelPath, relativeClasspath);
- URL url = createURL( pathToProcess );
- if ( url != null )
- {
- classPathVec.add ( url );
}
- }
- if ( classPathVec.size() == 0)
- {
- URL url = createURL( parcelPath );
- if ( url != null )
- {
- classPathVec.add(url);
+ if (classPathVec.size() == 0) {
+ URL url = createURL(parcelPath);
+
+ if (url != null) {
+ classPathVec.add(url);
+ }
}
- }
- return classPathVec.toArray( new URL[classPathVec.size()]);
- }
- catch ( Exception e )
- {
- LogUtils.DEBUG("Failed to build class path " + e.toString() );
- LogUtils.DEBUG( LogUtils.getTrace( e ) );
- return new URL[0];
- }
+ return classPathVec.toArray(new URL[classPathVec.size()]);
+ } catch (Exception e) {
+ LogUtils.DEBUG("Failed to build class path " + e.toString());
+ LogUtils.DEBUG(LogUtils.getTrace(e));
+ return new URL[0];
+ }
}
- private URL createURL( String path ) throws java.net.MalformedURLException
- {
+ private URL createURL(String path) throws java.net.MalformedURLException {
int indexOfColon = path.indexOf(':');
- String scheme = path.substring( 0, indexOfColon );
- UCBStreamHandler handler = new UCBStreamHandler( scheme, parent.m_xSFA);
+ String scheme = path.substring(0, indexOfColon);
+ UCBStreamHandler handler = new UCBStreamHandler(scheme, parent.m_xSFA);
path += UCBStreamHandler.separator;
return new URL(null, path, handler);
@@ -270,87 +243,81 @@ public class ScriptMetaData extends ScriptEntry {
// TODO should decide whether this should throw or not
// decide whether it should be public or protected ( final ? )
- public void loadSource()
- {
- try
- {
- URL sourceUrl = getSourceURL();
- LogUtils.DEBUG("** In load source BUT not loading yet for " + sourceUrl );
-
- if ( sourceUrl != null )
- {
- StringBuilder buf = new StringBuilder();
- InputStream in = sourceUrl.openStream();
-
- byte[] contents = new byte[1024];
- int len;
- while ((len = in.read(contents, 0, 1024)) != -1) {
- buf.append(new String(contents, 0, len));
- }
-
- try {
- in.close();
- }
- catch (java.io.IOException ignore ) {
- LogUtils.DEBUG("** Failed to read scriot from url " + ignore.toString() );
- }
-
- source = buf.toString();
- hasSource = true;
+ public void loadSource() {
+ try {
+ URL sourceUrl = getSourceURL();
+ LogUtils.DEBUG("** In load source BUT not loading yet for " + sourceUrl);
+
+ if (sourceUrl != null) {
+ StringBuilder buf = new StringBuilder();
+ InputStream in = sourceUrl.openStream();
+
+ byte[] contents = new byte[1024];
+ int len;
+
+ while ((len = in.read(contents, 0, 1024)) != -1) {
+ buf.append(new String(contents, 0, len));
+ }
+
+ try {
+ in.close();
+ } catch (java.io.IOException ignore) {
+ LogUtils.DEBUG("** Failed to read scriot from url " + ignore.toString());
}
- }
- catch (java.io.IOException e) {
- LogUtils.DEBUG("** Failed to read scriot from url " + e.toString());
- }
+ source = buf.toString();
+ hasSource = true;
+ }
+ } catch (java.io.IOException e) {
+ LogUtils.DEBUG("** Failed to read scriot from url " + e.toString());
}
- protected boolean writeSourceFile()
- {
+
+ }
+ protected boolean writeSourceFile() {
String sourceFilePath = parent.getPathToParcel() + "/" + getLanguageName();
boolean result = false;
- try
- {
- XSimpleFileAccess2 xSFA2 = UnoRuntime.queryInterface( XSimpleFileAccess2.class,
- parent.m_xSFA );
- if ( xSFA2 != null )
- {
- ByteArrayInputStream bis = new ByteArrayInputStream( getSourceBytes() );
- XInputStreamImpl xis = new XInputStreamImpl( bis );
- xSFA2.writeFile( sourceFilePath, xis );
+
+ try {
+ XSimpleFileAccess2 xSFA2 = UnoRuntime.queryInterface(XSimpleFileAccess2.class,
+ parent.m_xSFA);
+
+ if (xSFA2 != null) {
+ ByteArrayInputStream bis = new ByteArrayInputStream(getSourceBytes());
+ XInputStreamImpl xis = new XInputStreamImpl(bis);
+ xSFA2.writeFile(sourceFilePath, xis);
xis.closeInput();
result = true;
}
}
// TODO re-examine exception processing should probably throw
// exceptions back to caller
- catch ( Exception ignore )
+ catch (Exception ignore)
{
}
+
return result;
}
- protected boolean removeSourceFile()
- {
+ protected boolean removeSourceFile() {
String parcelLocation = parent.getPathToParcel();
String sourceFilePath = parcelLocation + "/" + getLanguageName();
boolean result = false;
- try
- {
- parent.m_xSFA.kill( sourceFilePath );
+
+ try {
+ parent.m_xSFA.kill(sourceFilePath);
result = true;
}
// TODO reexamine exception handling
- catch ( Exception e )
- {
+ catch (Exception e) {
}
+
return result;
}
- public URL getSourceURL() throws java.net.MalformedURLException
- {
+ public URL getSourceURL() throws java.net.MalformedURLException {
String sUrl = getParcelLocation();
- sUrl = PathUtils.make_url( sUrl, getLanguageName() );
- LogUtils.DEBUG("Creating script url for " + sUrl );
- return createURL( sUrl );
+ sUrl = PathUtils.make_url(sUrl, getLanguageName());
+ LogUtils.DEBUG("Creating script url for " + sUrl);
+ return createURL(sUrl);
}
}
diff --git a/scripting/java/com/sun/star/script/framework/container/UnoPkgContainer.java b/scripting/java/com/sun/star/script/framework/container/UnoPkgContainer.java
index be9dd42db9f1..9a338e06e35f 100644
--- a/scripting/java/com/sun/star/script/framework/container/UnoPkgContainer.java
+++ b/scripting/java/com/sun/star/script/framework/container/UnoPkgContainer.java
@@ -33,136 +33,128 @@ import com.sun.star.io.XOutputStream;
import com.sun.star.io.XTruncate;
import com.sun.star.deployment.XPackage;
-public class UnoPkgContainer extends ParcelContainer
-{
+public class UnoPkgContainer extends ParcelContainer {
- private Map<String,ParcelContainer> registeredPackages = new HashMap<String,ParcelContainer>();
+ private Map<String, ParcelContainer> registeredPackages = new
+ HashMap<String, ParcelContainer>();
private String extensionDb;
private String extensionRepository;
- public UnoPkgContainer( XComponentContext xCtx, String locationURL,
- String _extensionDb, String _extensionRepository, String language ) throws com.sun.star.lang.IllegalArgumentException, com.sun.star.lang.WrappedTargetException
- {
- super( xCtx, locationURL, language, false );
+ public UnoPkgContainer(XComponentContext xCtx, String locationURL,
+ String _extensionDb, String _extensionRepository,
+ String language) throws com.sun.star.lang.IllegalArgumentException,
+ com.sun.star.lang.WrappedTargetException {
+ super(xCtx, locationURL, language, false);
extensionDb = _extensionDb;
extensionRepository = _extensionRepository;
init();
}
// gets the ParcelContainer for persisted uno packages
- public ParcelContainer getRegisteredUnoPkgContainer( String url )
- {
- if (!url.endsWith("/"))
- {
+ public ParcelContainer getRegisteredUnoPkgContainer(String url) {
+ if (!url.endsWith("/")) {
url += "/";
}
- LogUtils.DEBUG("** getRegisterPackage ctx = " + containerUrl );
- LogUtils.DEBUG("** getRegisterPackage for uri " + url );
- LogUtils.DEBUG("** getRegisterPackage for langugage " + language );
- ParcelContainer result = registeredPackages.get( url );
- LogUtils.DEBUG("getRegisterPackage result is " + result );
+ LogUtils.DEBUG("** getRegisterPackage ctx = " + containerUrl);
+ LogUtils.DEBUG("** getRegisterPackage for uri " + url);
+ LogUtils.DEBUG("** getRegisterPackage for langugage " + language);
+ ParcelContainer result = registeredPackages.get(url);
+ LogUtils.DEBUG("getRegisterPackage result is " + result);
return result;
}
- public boolean hasRegisteredUnoPkgContainer( String url ) {
- return getRegisteredUnoPkgContainer( url ) != null;
+ public boolean hasRegisteredUnoPkgContainer(String url) {
+ return getRegisteredUnoPkgContainer(url) != null;
}
- private void registerPackageContainer( String url, ParcelContainer c )
- {
- if (!url.endsWith("/"))
- {
+ private void registerPackageContainer(String url, ParcelContainer c) {
+ if (!url.endsWith("/")) {
url += "/";
}
- LogUtils.DEBUG("RegisterPackage ctx = " + containerUrl );
- LogUtils.DEBUG("RegisterPackage language = " + language );
- LogUtils.DEBUG("RegisterPackage " + c + " for url " + url );
- registeredPackages.put( url, c );
+ LogUtils.DEBUG("RegisterPackage ctx = " + containerUrl);
+ LogUtils.DEBUG("RegisterPackage language = " + language);
+ LogUtils.DEBUG("RegisterPackage " + c + " for url " + url);
+ registeredPackages.put(url, c);
}
- public void deRegisterPackageContainer( String url )
- {
- if (!url.endsWith("/"))
- {
+ public void deRegisterPackageContainer(String url) {
+ if (!url.endsWith("/")) {
url += "/";
}
- LogUtils.DEBUG("In deRegisterPackageContainer for " + url );
- if ( hasRegisteredUnoPkgContainer( url ) )
- {
- try
- {
+ LogUtils.DEBUG("In deRegisterPackageContainer for " + url);
+
+ if (hasRegisteredUnoPkgContainer(url)) {
+ try {
DeployedUnoPackagesDB db = getUnoPackagesDB();
- if ( db != null )
- {
- if ( db.removePackage( language, url ) )
- {
- writeUnoPackageDB( db );
- ParcelContainer container = registeredPackages.get( url );
- if ( !container.hasElements() )
- {
- // When all libraries within a package bundle
- // ( for this language ) are removed also
- // remove the container from its parent
- // Otherwise, a container ( with no containees )
- // representing the uno package bundle will
- // still exist and so will get displayed
- if ( container.parent() != null )
- {
- container.parent().removeChildContainer( container );
- }
- }
- registeredPackages.remove( url );
- }
- }
- }
- catch (Exception e)
- {
- //TODO revisit exception handling and exception here
- //means something very wrong
- LogUtils.DEBUG("***** deRegisterPackageContainer() got exception " + e );
- }
+
+ if (db != null) {
+ if (db.removePackage(language, url)) {
+ writeUnoPackageDB(db);
+ ParcelContainer container = registeredPackages.get(url);
+
+ if (!container.hasElements()) {
+ // When all libraries within a package bundle
+ // ( for this language ) are removed also
+ // remove the container from its parent
+ // Otherwise, a container ( with no containees )
+ // representing the uno package bundle will
+ // still exist and so will get displayed
+ if (container.parent() != null) {
+ container.parent().removeChildContainer(container);
+ }
+ }
+
+ registeredPackages.remove(url);
+ }
+ }
+ } catch (Exception e) {
+ //TODO revisit exception handling and exception here
+ //means something very wrong
+ LogUtils.DEBUG("***** deRegisterPackageContainer() got exception " + e);
+ }
}
- LogUtils.DEBUG("Leaving deRegisterPackageContainer for " + url );
+
+ LogUtils.DEBUG("Leaving deRegisterPackageContainer for " + url);
}
- private void init() throws com.sun.star.lang.IllegalArgumentException
- {
- LogUtils.DEBUG("getting container for " + containerUrl );
- try
- {
+ private void init() throws com.sun.star.lang.IllegalArgumentException {
+ LogUtils.DEBUG("getting container for " + containerUrl);
+
+ try {
DeployedUnoPackagesDB db = getUnoPackagesDB();
- if ( db != null )
- {
- String[] packages = db.getDeployedPackages( language );
+
+ if (db != null) {
+ String[] packages = db.getDeployedPackages(language);
+
for (String thepackage : packages) {
try {
processUnoPackage(thepackage, language);
} catch (com.sun.star.lang.IllegalArgumentException ila) {
LogUtils.DEBUG("Failed to process " + thepackage + " for " + language);
- LogUtils.DEBUG(" Reason: " + ila );
+ LogUtils.DEBUG(" Reason: " + ila);
} catch (Exception e) {
// TODO proper exception or do we wish
// to ignore errors here
LogUtils.DEBUG("Something very wrong!!!!!");
LogUtils.DEBUG("Failed to process " + thepackage + " for " + language);
- LogUtils.DEBUG(" Reason: " + e );
+ LogUtils.DEBUG(" Reason: " + e);
}
}
}
- }
- catch ( com.sun.star.lang.WrappedTargetException e )
- {
+ } catch (com.sun.star.lang.WrappedTargetException e) {
// no deployed packages
- LogUtils.DEBUG("No deployed uno-packages for " + containerUrl );
+ LogUtils.DEBUG("No deployed uno-packages for " + containerUrl);
}
}
@Override
- public ScriptMetaData findScript( ParsedScriptUri psu ) throws com.sun.star.container.NoSuchElementException, com.sun.star.lang.WrappedTargetException
+ public ScriptMetaData findScript(ParsedScriptUri psu) throws
+ com.sun.star.container.NoSuchElementException,
+ com.sun.star.lang.WrappedTargetException
{
ScriptMetaData scriptData = null;
@@ -172,70 +164,59 @@ public class UnoPkgContainer extends ParcelContainer
String location = psu.location;
LogUtils.DEBUG("*** UnoPkgContainer.findScript() ***" +
- "\ncontainerUrl = " + containerUrl +
- "\nfunction = " + functionName +
- "\nlocation = " + location +
- "\nparcel = " + parcelName );
+ "\ncontainerUrl = " + containerUrl +
+ "\nfunction = " + functionName +
+ "\nlocation = " + location +
+ "\nparcel = " + parcelName);
- ParcelContainer pc = getChildContainer( location );
+ ParcelContainer pc = getChildContainer(location);
- if ( pc == null )
- {
- throw new com.sun.star.lang.WrappedTargetException( "Failed to resolve script " , null, new com.sun.star.lang.IllegalArgumentException( "Cannot resolve script location for script = " + functionName ) );
+ if (pc == null) {
+ throw new com.sun.star.lang.WrappedTargetException("Failed to resolve script " ,
+ null, new com.sun.star.lang.IllegalArgumentException("Cannot resolve script location for script = "
+ + functionName));
}
- return pc.findScript( psu );
+ return pc.findScript(psu);
}
- private DeployedUnoPackagesDB getUnoPackagesDB() throws com.sun.star.lang.WrappedTargetException
- {
+ private DeployedUnoPackagesDB getUnoPackagesDB() throws
+ com.sun.star.lang.WrappedTargetException {
InputStream is = null;
DeployedUnoPackagesDB dp = null;
- try
- {
- String packagesUrl = PathUtils.make_url( extensionDb, "/Scripts/" + extensionRepository + "-extension-desc.xml" );
- LogUtils.DEBUG("getUnoPackagesDB() looking for existing db in " + packagesUrl );
- if ( m_xSFA.exists( packagesUrl ) )
- {
- if ( packagesUrl.startsWith( "vnd.sun.star.tdoc" ) )
- {
+
+ try {
+ String packagesUrl = PathUtils.make_url(extensionDb,
+ "/Scripts/" + extensionRepository + "-extension-desc.xml");
+ LogUtils.DEBUG("getUnoPackagesDB() looking for existing db in " + packagesUrl);
+
+ if (m_xSFA.exists(packagesUrl)) {
+ if (packagesUrl.startsWith("vnd.sun.star.tdoc")) {
// handles using XStorage directly
throw new com.sun.star.lang.WrappedTargetException("Can't handle documents yet");
}
- is = new XInputStreamWrapper( m_xSFA.openFileRead( packagesUrl ) );
- dp = new DeployedUnoPackagesDB( is );
- try
- {
+ is = new XInputStreamWrapper(m_xSFA.openFileRead(packagesUrl));
+ dp = new DeployedUnoPackagesDB(is);
+
+ try {
is.close();
is = null;
+ } catch (Exception ignore) {
}
- catch ( Exception ignore )
- {
- }
- }
- else
- {
+ } else {
LogUtils.DEBUG("getUnoPackagesDB() " + packagesUrl + " does not exist");
}
- }
- catch( Exception e )
- {
- LogUtils.DEBUG("getUnoPackagesDB() caught Exception: " + e );
- LogUtils.DEBUG( LogUtils.getTrace( e ) );
+ } catch (Exception e) {
+ LogUtils.DEBUG("getUnoPackagesDB() caught Exception: " + e);
+ LogUtils.DEBUG(LogUtils.getTrace(e));
throw new com.sun.star.lang.WrappedTargetException(e);
- }
- finally
- {
- if ( is != null )
- {
- try
- {
+ } finally {
+ if (is != null) {
+ try {
is.close();
is = null;
- }
- catch ( Exception ignore )
- {
+ } catch (Exception ignore) {
}
}
}
@@ -243,160 +224,151 @@ public class UnoPkgContainer extends ParcelContainer
return dp;
}
- private void writeUnoPackageDB( DeployedUnoPackagesDB dp ) throws com.sun.star.lang.IllegalArgumentException, com.sun.star.lang.WrappedTargetException
- {
+ private void writeUnoPackageDB(DeployedUnoPackagesDB dp) throws
+ com.sun.star.lang.IllegalArgumentException,
+ com.sun.star.lang.WrappedTargetException {
LogUtils.DEBUG("In writeUnoPackageDB() ");
XOutputStream xos = null;
OutputStream os = null;
- try
- {
- String packagesUrl = PathUtils.make_url( extensionDb, "/Scripts/" + extensionRepository + "-extension-desc.xml" );
- xos = m_xSFA.openFileWrite( packagesUrl );
- XTruncate xTrc = UnoRuntime.queryInterface( XTruncate.class, xos );
- if ( xTrc != null )
- {
- LogUtils.DEBUG("In writeUnoPackageDB() Truncating...." );
+
+ try {
+ String packagesUrl = PathUtils.make_url(extensionDb,
+ "/Scripts/" + extensionRepository + "-extension-desc.xml");
+ xos = m_xSFA.openFileWrite(packagesUrl);
+ XTruncate xTrc = UnoRuntime.queryInterface(XTruncate.class, xos);
+
+ if (xTrc != null) {
+ LogUtils.DEBUG("In writeUnoPackageDB() Truncating....");
xTrc.truncate();
+ } else {
+ LogUtils.DEBUG("In writeUnoPackageDB() CAN'T Truncate....");
}
- else
- {
- LogUtils.DEBUG("In writeUnoPackageDB() CAN'T Truncate...." );
- }
- os = new XOutputStreamWrapper( xos );
- dp.write( os );
- try
- {
+
+ os = new XOutputStreamWrapper(xos);
+ dp.write(os);
+
+ try {
os.close(); // will close xos
os = null;
+ } catch (Exception ignore) {
}
- catch( Exception ignore )
- {
- }
- }
- catch( Exception e )
- {
- LogUtils.DEBUG("In writeUnoPackageDB() Exception: " + e );
+ } catch (Exception e) {
+ LogUtils.DEBUG("In writeUnoPackageDB() Exception: " + e);
throw new com.sun.star.lang.WrappedTargetException(e);
- }
- finally
- {
- if ( os != null )
- {
- try
- {
+ } finally {
+ if (os != null) {
+ try {
os.close(); // will close xos
os = null;
- }
- catch ( Exception ignore )
- {
+ } catch (Exception ignore) {
}
}
}
}
- public void processUnoPackage( XPackage dPackage, String language ) throws com.sun.star.lang.IllegalArgumentException, com.sun.star.lang.WrappedTargetException, com.sun.star.container.ElementExistException
- {
- LogUtils.DEBUG("** in processUnoPackage " );
+ public void processUnoPackage(XPackage dPackage,
+ String language) throws com.sun.star.lang.IllegalArgumentException,
+ com.sun.star.lang.WrappedTargetException,
+ com.sun.star.container.ElementExistException {
+ LogUtils.DEBUG("** in processUnoPackage ");
String uri = dPackage.getURL();
- if ( !uri.endsWith( "/" ) )
- {
+ if (!uri.endsWith("/")) {
uri += "/";
}
- LogUtils.DEBUG("** processUnoPackage getURL() -> " + uri );
- LogUtils.DEBUG("** processUnoPackage getName() -> " + dPackage.getName() );
- LogUtils.DEBUG("** processUnoPackage getMediaType() -> " + dPackage.getPackageType().getMediaType() );
- try
- {
- LogUtils.DEBUG("** processUnoPackage getDisplayName() -> " + dPackage.getDisplayName() );
- }
- catch (com.sun.star.deployment.ExtensionRemovedException e)
- {
+ LogUtils.DEBUG("** processUnoPackage getURL() -> " + uri);
+ LogUtils.DEBUG("** processUnoPackage getName() -> " + dPackage.getName());
+ LogUtils.DEBUG("** processUnoPackage getMediaType() -> " +
+ dPackage.getPackageType().getMediaType());
+
+ try {
+ LogUtils.DEBUG("** processUnoPackage getDisplayName() -> " +
+ dPackage.getDisplayName());
+ } catch (com.sun.star.deployment.ExtensionRemovedException e) {
throw new com.sun.star.lang.WrappedTargetException(e.getMessage(), this, e);
}
- processUnoPackage( uri, language );
+ processUnoPackage(uri, language);
DeployedUnoPackagesDB db = getUnoPackagesDB();
- if ( db == null )
- {
- try
- {
+
+ if (db == null) {
+ try {
db = new DeployedUnoPackagesDB();
- }
- catch ( java.io.IOException ioe )
- {
+ } catch (java.io.IOException ioe) {
throw new com.sun.star.lang.WrappedTargetException(ioe);
}
}
- db.addPackage( language, uri );
- writeUnoPackageDB( db );
+
+ db.addPackage(language, uri);
+ writeUnoPackageDB(db);
}
- private void processUnoPackage( String uri, String language ) throws com.sun.star.lang.IllegalArgumentException, com.sun.star.lang.WrappedTargetException, com.sun.star.container.ElementExistException
- {
- if ( hasRegisteredUnoPkgContainer( uri ) )
- {
- throw new com.sun.star.container.ElementExistException( "Already a registered uno package " + uri + " for language " + language );
+ private void processUnoPackage(String uri,
+ String language) throws com.sun.star.lang.IllegalArgumentException,
+ com.sun.star.lang.WrappedTargetException,
+ com.sun.star.container.ElementExistException {
+ if (hasRegisteredUnoPkgContainer(uri)) {
+ throw new com.sun.star.container.ElementExistException("Already a registered uno package "
+ + uri + " for language " + language);
}
- LogUtils.DEBUG("processUnoPackage - URL = " + uri );
+
+ LogUtils.DEBUG("processUnoPackage - URL = " + uri);
LogUtils.DEBUG("processUnoPackage - script library package");
String parentUrl = uri;
- if ( uri.contains("%2Funo_packages%2F") ||
- uri.contains("/uno_packages/") ||
- uri.contains("$UNO_USER_PACKAGES_CACHE/") ||
- uri.contains("$UNO_SHARED_PACKAGES_CACHE/") ||
- uri.contains("$BUNDLED_EXTENSIONS/") )
- {
+ if (uri.contains("%2Funo_packages%2F") ||
+ uri.contains("/uno_packages/") ||
+ uri.contains("$UNO_USER_PACKAGES_CACHE/") ||
+ uri.contains("$UNO_SHARED_PACKAGES_CACHE/") ||
+ uri.contains("$BUNDLED_EXTENSIONS/")) {
//its in a bundle need to determine the uno-package file its in
LogUtils.DEBUG("processUnoPackage - is part of a uno bundle");
int index = uri.lastIndexOf('/');
- if ( uri.endsWith("/") )
- {
- uri = uri.substring( 0, index );
+
+ if (uri.endsWith("/")) {
+ uri = uri.substring(0, index);
index = uri.lastIndexOf('/');
}
- if ( index > -1 )
- {
- parentUrl = uri.substring( 0, index );
+ if (index > -1) {
+ parentUrl = uri.substring(0, index);
LogUtils.DEBUG("processUnoPackage - composition is contained in " + parentUrl);
}
- ParcelContainer pkgContainer = getChildContainerForURL( parentUrl );
- if ( pkgContainer == null )
- {
- pkgContainer = new ParcelContainer( this, m_xCtx, parentUrl, language, false );
- if ( pkgContainer.loadParcel( uri ) == null )
- {
- throw new com.sun.star.lang.IllegalArgumentException( "Couldn't load script library from composition package " + uri + " for language " + language );
+ ParcelContainer pkgContainer = getChildContainerForURL(parentUrl);
+
+ if (pkgContainer == null) {
+ pkgContainer = new ParcelContainer(this, m_xCtx, parentUrl, language, false);
+
+ if (pkgContainer.loadParcel(uri) == null) {
+ throw new com.sun.star.lang.IllegalArgumentException("Couldn't load script library from composition package "
+ + uri + " for language " + language);
}
- addChildContainer( pkgContainer );
- }
- else
- {
- if ( pkgContainer.loadParcel( uri ) == null )
- {
- throw new com.sun.star.lang.IllegalArgumentException( "Couldn't load script library from composition package " + uri + " for language " + language );
+
+ addChildContainer(pkgContainer);
+ } else {
+ if (pkgContainer.loadParcel(uri) == null) {
+ throw new com.sun.star.lang.IllegalArgumentException("Couldn't load script library from composition package "
+ + uri + " for language " + language);
}
}
- registerPackageContainer( uri, pkgContainer );
- }
- else
- {
+
+ registerPackageContainer(uri, pkgContainer);
+ } else {
// stand-alone library package, e.g. not contained in
// an uno package
- if ( loadParcel( uri ) == null )
- {
- throw new com.sun.star.lang.IllegalArgumentException( "Couldn't load script library package " + uri + " for language " + language );
+ if (loadParcel(uri) == null) {
+ throw new com.sun.star.lang.IllegalArgumentException("Couldn't load script library package "
+ + uri + " for language " + language);
}
- registerPackageContainer( uri, this );
+
+ registerPackageContainer(uri, this);
}
}
diff --git a/scripting/java/com/sun/star/script/framework/container/XMLParserFactory.java b/scripting/java/com/sun/star/script/framework/container/XMLParserFactory.java
index 00d39a6c3332..9e17b2c68822 100644
--- a/scripting/java/com/sun/star/script/framework/container/XMLParserFactory.java
+++ b/scripting/java/com/sun/star/script/framework/container/XMLParserFactory.java
@@ -39,6 +39,7 @@ public class XMLParserFactory {
public static synchronized XMLParser getParser() {
if (parser == null)
parser = new DefaultParser();
+
return parser;
}
@@ -69,16 +70,14 @@ public class XMLParserFactory {
}
result = builder.parse(is);
- }
- catch (SAXParseException spe) {
+ } catch (SAXParseException spe) {
throw new IOException(spe.getMessage());
- }
- catch (SAXException se) {
+ } catch (SAXException se) {
throw new IOException(se.getMessage());
- }
- catch (ParserConfigurationException pce) {
+ } catch (ParserConfigurationException pce) {
throw new IOException(pce.getMessage());
}
+
return result;
}
@@ -97,10 +96,9 @@ public class XMLParserFactory {
// these DOM implementations are self writing
Method write;
write = clazz.getDeclaredMethod("write",
- new Class[] {OutputStream.class});
+ new Class[] {OutputStream.class});
write.invoke(doc, new Object[] {out});
- }
- else {
+ } else {
// try xerces serialize package using introspection
ClassLoader cl = this.getClass().getClassLoader();
@@ -109,16 +107,16 @@ public class XMLParserFactory {
try {
serializerClass = Class.forName(
- "org.apache.xml.serialize.XMLSerializer", true, cl);
+ "org.apache.xml.serialize.XMLSerializer", true, cl);
formatterClass = Class.forName(
- "org.apache.xml.serialize.OutputFormat", true, cl);
+ "org.apache.xml.serialize.OutputFormat", true, cl);
} catch (ClassNotFoundException cnfe) {
String prefix = "com.sun.org.apache.xml.internal.";
serializerClass = Class.forName(
- prefix + "serialize.XMLSerializer" , true, cl);
+ prefix + "serialize.XMLSerializer" , true, cl);
formatterClass = Class.forName(
- prefix + "serialize.OutputFormat", true, cl);
+ prefix + "serialize.OutputFormat", true, cl);
}
Object serializerObject = serializerClass.newInstance();
@@ -126,29 +124,29 @@ public class XMLParserFactory {
// improve output readability using the OutputFormat class
Method method = formatterClass.getMethod("setMethod",
- new Class[] {String.class});
+ new Class[] {String.class});
method.invoke(formatterObject, new Object[] {"xml"});
method = formatterClass.getMethod("setIndenting",
- new Class[] {Boolean.TYPE});
+ new Class[] {Boolean.TYPE});
method.invoke(formatterObject, new Object[] {Boolean.TRUE});
// now set up an instance of XMLSerializer with our
// OutputStream and serialize our Document
method = serializerClass.getMethod("setOutputByteStream",
- new Class[] {OutputStream.class});
+ new Class[] {OutputStream.class});
method.invoke(serializerObject, new Object[] {out});
method = serializerClass.getMethod("setOutputFormat",
- new Class[] {formatterClass});
+ new Class[] {formatterClass});
method.invoke(serializerObject,
- new Object[] {formatterObject});
+ new Object[] {formatterObject});
method = serializerClass.getMethod("asDOMSerializer",
- new Class[0]);
+ new Class[0]);
Object impl = method.invoke(serializerObject,
- new Object[0]);
+ new Object[0]);
method = impl.getClass().getMethod("serialize",
- new Class[] {Document.class});
+ new Class[] {Document.class});
method.invoke(impl, new Object[] {doc});
}
} catch (NoSuchMethodException ex) {
diff --git a/scripting/java/com/sun/star/script/framework/io/UCBStreamHandler.java b/scripting/java/com/sun/star/script/framework/io/UCBStreamHandler.java
index 33bb67419eea..e4a715060d73 100644
--- a/scripting/java/com/sun/star/script/framework/io/UCBStreamHandler.java
+++ b/scripting/java/com/sun/star/script/framework/io/UCBStreamHandler.java
@@ -36,28 +36,30 @@ public class UCBStreamHandler extends URLStreamHandler {
public final static String separator = "/ucb/";
private XSimpleFileAccess m_xSimpleFileAccess = null;
- private HashMap<String,InputStream> m_jarStreamMap = new HashMap<String,InputStream>(12);
+ private HashMap<String, InputStream> m_jarStreamMap = new
+ HashMap<String, InputStream>(12);
private static String m_ucbscheme;
- public UCBStreamHandler( String scheme, XSimpleFileAccess xSFA )
- {
- LogUtils.DEBUG( "UCBStreamHandler ctor, scheme = " + scheme );
+ public UCBStreamHandler(String scheme, XSimpleFileAccess xSFA) {
+ LogUtils.DEBUG("UCBStreamHandler ctor, scheme = " + scheme);
UCBStreamHandler.m_ucbscheme = scheme;
this.m_xSimpleFileAccess = xSFA;
}
@Override
public void parseURL(URL url, String spec, int start, int limit) {
- LogUtils.DEBUG("**XUCBStreamHandler, parseURL: " + url + " spec: " + spec + " start: " + start + " limit: " + limit );
+ LogUtils.DEBUG("**XUCBStreamHandler, parseURL: " + url + " spec: " + spec +
+ " start: " + start + " limit: " + limit);
String file = url.getFile();
+
if (file == null)
file = spec.substring(start, limit);
else
file += spec.substring(start, limit);
- LogUtils.DEBUG("**For scheme = " + m_ucbscheme );
- LogUtils.DEBUG("**Setting path = " + file );
+ LogUtils.DEBUG("**For scheme = " + m_ucbscheme);
+ LogUtils.DEBUG("**Setting path = " + file);
setURL(url, m_ucbscheme, null, -1, null, null, file, null, null);
}
@@ -78,73 +80,73 @@ public class UCBStreamHandler extends URLStreamHandler {
@Override
public InputStream getInputStream() throws IOException {
- LogUtils.DEBUG("UCBConnectionHandler GetInputStream on " + url );
+ LogUtils.DEBUG("UCBConnectionHandler GetInputStream on " + url);
String sUrl = url.toString();
+
if (sUrl.lastIndexOf(separator) == -1) {
- LogUtils.DEBUG("getInputStream straight file load" );
+ LogUtils.DEBUG("getInputStream straight file load");
return getFileStreamFromUCB(sUrl);
- }
- else {
- String path = sUrl.substring(0, sUrl.lastIndexOf(separator) );
+ } else {
+ String path = sUrl.substring(0, sUrl.lastIndexOf(separator));
String file = sUrl.substring(
- sUrl.lastIndexOf(separator) + separator.length());
- LogUtils.DEBUG("getInputStream, load of file from another file eg. " + file + " from " + path );
+ sUrl.lastIndexOf(separator) + separator.length());
+ LogUtils.DEBUG("getInputStream, load of file from another file eg. " + file +
+ " from " + path);
return getUCBStream(file, path);
}
}
@Override
public OutputStream getOutputStream() throws IOException {
- LogUtils.DEBUG("UCBConnectionHandler getOutputStream on " + url );
+ LogUtils.DEBUG("UCBConnectionHandler getOutputStream on " + url);
OutputStream os = null;
- try
- {
+
+ try {
String sUrl = url.toString();
- if ( !( sUrl.lastIndexOf(separator) == -1) ) {
+
+ if (!(sUrl.lastIndexOf(separator) == -1)) {
String path = sUrl.substring(0, sUrl.lastIndexOf(separator));
- if ( m_xSimpleFileAccess.isReadOnly( path ) )
- {
+ if (m_xSimpleFileAccess.isReadOnly(path)) {
throw new java.io.IOException("File is read only");
}
- LogUtils.DEBUG("getOutputStream, create o/p stream for file eg. " + path );
+ LogUtils.DEBUG("getOutputStream, create o/p stream for file eg. " + path);
// we will only deal with simple file write
- XOutputStream xos = m_xSimpleFileAccess.openFileWrite( path );
- XTruncate xtrunc = UnoRuntime.queryInterface( XTruncate.class, xos );
- if ( xtrunc != null )
- {
+ XOutputStream xos = m_xSimpleFileAccess.openFileWrite(path);
+ XTruncate xtrunc = UnoRuntime.queryInterface(XTruncate.class, xos);
+
+ if (xtrunc != null) {
xtrunc.truncate();
}
- os = new XOutputStreamWrapper( xos );
+
+ os = new XOutputStreamWrapper(xos);
}
- if ( os == null )
- {
- throw new IOException("Failed to get OutputStream for " + sUrl );
+
+ if (os == null) {
+ throw new IOException("Failed to get OutputStream for " + sUrl);
}
- }
- catch ( com.sun.star.ucb.CommandAbortedException cae )
- {
- LogUtils.DEBUG("caught exception: " + cae.toString() + " getting writable stream from " + url );
+ } catch (com.sun.star.ucb.CommandAbortedException cae) {
+ LogUtils.DEBUG("caught exception: " + cae.toString() +
+ " getting writable stream from " + url);
IOException newEx = new IOException(cae.getMessage());
newEx.initCause(cae);
throw newEx;
- }
- catch ( com.sun.star.uno.Exception e )
- {
- LogUtils.DEBUG("caught unknown exception: " + e.toString() + " getting writable stream from " + url );
+ } catch (com.sun.star.uno.Exception e) {
+ LogUtils.DEBUG("caught unknown exception: " + e.toString() +
+ " getting writable stream from " + url);
IOException newEx = new IOException(e.getMessage());
newEx.initCause(e);
throw newEx;
}
+
return os;
}
}
private InputStream getUCBStream(String file, String path)
- throws IOException
- {
+ throws IOException {
InputStream is = null;
InputStream result = null;
@@ -155,42 +157,37 @@ public class UCBStreamHandler extends URLStreamHandler {
if (is == null) {
is = getFileStreamFromUCB(path);
m_jarStreamMap.put(path, is);
- }
- else {
+ } else {
try {
is.reset();
- }
- catch (IOException e) {
+ } catch (IOException e) {
is.close();
is = getFileStreamFromUCB(path);
m_jarStreamMap.put(path, is);
}
}
+
result = getFileStreamFromJarStream(file, is);
- }
- else
- {
- String fileUrl = PathUtils.make_url(path,file);
+ } else {
+ String fileUrl = PathUtils.make_url(path, file);
result = getFileStreamFromUCB(fileUrl);
}
- }
- finally {
+ } finally {
if (is != null) {
try {
is.close();
- }
- catch (IOException ioe) {
+ } catch (IOException ioe) {
LogUtils.DEBUG("Caught exception closing stream: " +
- ioe.getMessage());
+ ioe.getMessage());
}
}
}
+
return result;
}
private InputStream getFileStreamFromJarStream(String file, InputStream is)
- throws IOException
- {
+ throws IOException {
ZipEntry entry;
ZipInputStream zis = new ZipInputStream(is);
@@ -202,33 +199,33 @@ public class UCBStreamHandler extends URLStreamHandler {
return zis;
}
}
+
return null;
}
private InputStream getFileStreamFromUCB(String path)
- throws IOException
- {
+ throws IOException {
InputStream result = null;
XInputStream xInputStream = null;
try {
- LogUtils.DEBUG("Trying to read from " + path );
+ LogUtils.DEBUG("Trying to read from " + path);
xInputStream = m_xSimpleFileAccess.openFileRead(path);
- LogUtils.DEBUG("sfa appeared to read file " );
+ LogUtils.DEBUG("sfa appeared to read file ");
byte[][] inputBytes = new byte[1][];
int sz = m_xSimpleFileAccess.getSize(path);
+
// TODO don't depend on result of available() or size()
// just read stream 'till complete
- if ( sz == 0 )
- {
- if ( xInputStream.available() > 0 )
- {
+ if (sz == 0) {
+ if (xInputStream.available() > 0) {
sz = xInputStream.available();
}
}
- LogUtils.DEBUG("size of file " + path + " is " + sz );
- LogUtils.DEBUG("available = " + xInputStream.available() );
+
+ LogUtils.DEBUG("size of file " + path + " is " + sz);
+ LogUtils.DEBUG("available = " + xInputStream.available());
inputBytes[0] = new byte[sz];
int ln = xInputStream.readBytes(inputBytes, sz);
@@ -239,27 +236,23 @@ public class UCBStreamHandler extends URLStreamHandler {
}
result = new ByteArrayInputStream(inputBytes[0]);
- }
- catch (com.sun.star.io.IOException ioe) {
- LogUtils.DEBUG("caught exception " + ioe );
+ } catch (com.sun.star.io.IOException ioe) {
+ LogUtils.DEBUG("caught exception " + ioe);
throw new IOException(ioe.getMessage());
- }
- catch (com.sun.star.uno.Exception e) {
- LogUtils.DEBUG("caught exception " + e );
+ } catch (com.sun.star.uno.Exception e) {
+ LogUtils.DEBUG("caught exception " + e);
throw new IOException(e.getMessage());
- }
- finally
- {
+ } finally {
if (xInputStream != null) {
try {
xInputStream.closeInput();
- }
- catch (Exception e2) {
+ } catch (Exception e2) {
LogUtils.DEBUG(
"Error closing XInputStream:" + e2.getMessage());
}
}
}
+
return result;
}
diff --git a/scripting/java/com/sun/star/script/framework/io/XInputStreamImpl.java b/scripting/java/com/sun/star/script/framework/io/XInputStreamImpl.java
index 801cb0d4be3a..19d9c508923e 100644
--- a/scripting/java/com/sun/star/script/framework/io/XInputStreamImpl.java
+++ b/scripting/java/com/sun/star/script/framework/io/XInputStreamImpl.java
@@ -23,86 +23,78 @@ import java.io.InputStream;
import com.sun.star.io.XInputStream;
-public class XInputStreamImpl implements XInputStream
-{
+public class XInputStreamImpl implements XInputStream {
private InputStream is;
- public XInputStreamImpl( InputStream is )
- {
+ public XInputStreamImpl(InputStream is) {
this.is = is;
}
- public int readBytes( /*OUT*/byte[][] aData, /*IN*/int nBytesToRead ) throws com.sun.star.io.NotConnectedException, com.sun.star.io.BufferSizeExceededException, com.sun.star.io.IOException
- {
+ public int readBytes(/*OUT*/byte[][] aData, /*IN*/int nBytesToRead) throws
+ com.sun.star.io.NotConnectedException,
+ com.sun.star.io.BufferSizeExceededException, com.sun.star.io.IOException {
aData[ 0 ] = new byte[ nBytesToRead ];
int totalBytesRead = 0;
- try
- {
+ try {
int bytesRead;
- while ( ( bytesRead = is.read( aData[ 0 ], totalBytesRead, nBytesToRead ) ) > 0 && ( totalBytesRead < nBytesToRead ) )
- {
+
+ while ((bytesRead = is.read(aData[ 0 ], totalBytesRead, nBytesToRead)) > 0
+ && (totalBytesRead < nBytesToRead)) {
totalBytesRead += bytesRead;
nBytesToRead -= bytesRead;
}
- }
- catch ( IOException e )
- {
+ } catch (IOException e) {
throw new com.sun.star.io.IOException(e);
- }
- catch ( IndexOutOfBoundsException aie )
- {
+ } catch (IndexOutOfBoundsException aie) {
throw new com.sun.star.io.BufferSizeExceededException(aie);
}
+
return totalBytesRead;
}
- public int readSomeBytes( /*OUT*/byte[][] aData, /*IN*/int nMaxBytesToRead ) throws com.sun.star.io.NotConnectedException, com.sun.star.io.BufferSizeExceededException, com.sun.star.io.IOException
- {
+ public int readSomeBytes(/*OUT*/byte[][] aData, /*IN*/int nMaxBytesToRead)
+ throws com.sun.star.io.NotConnectedException,
+ com.sun.star.io.BufferSizeExceededException, com.sun.star.io.IOException {
int bytesToRead = nMaxBytesToRead;
int availableBytes = available();
- if ( availableBytes < nMaxBytesToRead )
- {
+
+ if (availableBytes < nMaxBytesToRead) {
bytesToRead = availableBytes;
}
- int read = readBytes( aData, bytesToRead );
+
+ int read = readBytes(aData, bytesToRead);
return read;
}
- public void skipBytes( /*IN*/int nBytesToSkip ) throws com.sun.star.io.NotConnectedException, com.sun.star.io.BufferSizeExceededException, com.sun.star.io.IOException
- {
- try
- {
- is.skip( nBytesToSkip );
- }
- catch ( IOException e )
- {
+ public void skipBytes(/*IN*/int nBytesToSkip) throws
+ com.sun.star.io.NotConnectedException,
+ com.sun.star.io.BufferSizeExceededException, com.sun.star.io.IOException {
+ try {
+ is.skip(nBytesToSkip);
+ } catch (IOException e) {
throw new com.sun.star.io.IOException(e);
}
}
- public int available( ) throws com.sun.star.io.NotConnectedException, com.sun.star.io.IOException
- {
+ public int available() throws com.sun.star.io.NotConnectedException,
+ com.sun.star.io.IOException {
int bytesAvail = 0;
- try
- {
+
+ try {
bytesAvail = is.available();
- }
- catch ( IOException e )
- {
+ } catch (IOException e) {
throw new com.sun.star.io.IOException(e);
}
+
return bytesAvail;
}
- public void closeInput( ) throws com.sun.star.io.NotConnectedException, com.sun.star.io.IOException
- {
- try
- {
+ public void closeInput() throws com.sun.star.io.NotConnectedException,
+ com.sun.star.io.IOException {
+ try {
is.close();
- }
- catch( IOException e )
- {
+ } catch (IOException e) {
throw new com.sun.star.io.IOException(e);
}
}
diff --git a/scripting/java/com/sun/star/script/framework/io/XInputStreamWrapper.java b/scripting/java/com/sun/star/script/framework/io/XInputStreamWrapper.java
index a1e27793f4f1..8da2bb27ff1b 100644
--- a/scripting/java/com/sun/star/script/framework/io/XInputStreamWrapper.java
+++ b/scripting/java/com/sun/star/script/framework/io/XInputStreamWrapper.java
@@ -28,69 +28,59 @@ public class XInputStreamWrapper extends InputStream {
}
@Override
- public int read() throws java.io.IOException
- {
+ public int read() throws java.io.IOException {
byte[][] byteRet = new byte[1][0];
long numRead;
try {
numRead = m_xInputStream.readBytes(byteRet, 1);
- }
- catch (com.sun.star.io.IOException ioe) {
+ } catch (com.sun.star.io.IOException ioe) {
throw new java.io.IOException(ioe.getMessage());
}
if (numRead != 1) {
return -1;
}
+
return byteRet[0][0];
}
@Override
- public int read( byte[] b ) throws java.io.IOException
- {
+ public int read(byte[] b) throws java.io.IOException {
byte[][] byteRet = new byte[1][];
byteRet[0] = b;
- try
- {
- return m_xInputStream.readBytes( byteRet, b.length );
- }
- catch ( com.sun.star.io.IOException ioe)
- {
+
+ try {
+ return m_xInputStream.readBytes(byteRet, b.length);
+ } catch (com.sun.star.io.IOException ioe) {
throw new java.io.IOException(ioe.getMessage());
}
}
@Override
- public long skip(long n) throws java.io.IOException
- {
+ public long skip(long n) throws java.io.IOException {
try {
m_xInputStream.skipBytes((int)n);
return n;
- }
- catch (com.sun.star.io.IOException ioe) {
+ } catch (com.sun.star.io.IOException ioe) {
throw new java.io.IOException(ioe.getMessage());
}
}
@Override
- public int available() throws java.io.IOException
- {
+ public int available() throws java.io.IOException {
try {
return m_xInputStream.available();
- }
- catch (com.sun.star.io.IOException ioe) {
+ } catch (com.sun.star.io.IOException ioe) {
throw new java.io.IOException(ioe.getMessage());
}
}
@Override
- public void close() throws java.io.IOException
- {
+ public void close() throws java.io.IOException {
try {
m_xInputStream.closeInput();
- }
- catch (com.sun.star.io.IOException ioe) {
+ } catch (com.sun.star.io.IOException ioe) {
throw new java.io.IOException(ioe.getMessage());
}
}
diff --git a/scripting/java/com/sun/star/script/framework/io/XOutputStreamWrapper.java b/scripting/java/com/sun/star/script/framework/io/XOutputStreamWrapper.java
index b1c663c54a7c..1d54b136811f 100644
--- a/scripting/java/com/sun/star/script/framework/io/XOutputStreamWrapper.java
+++ b/scripting/java/com/sun/star/script/framework/io/XOutputStreamWrapper.java
@@ -21,101 +21,83 @@ import com.sun.star.io.XOutputStream;
public class XOutputStreamWrapper extends OutputStream {
- private XOutputStream m_xOutputStream;
- public XOutputStreamWrapper(XOutputStream xOs ) {
- this.m_xOutputStream = xOs;
+ private XOutputStream m_xOutputStream;
+ public XOutputStreamWrapper(XOutputStream xOs) {
+ this.m_xOutputStream = xOs;
+ }
+ @Override
+ public void write(int b)
+ throws java.io.IOException {
+ if (m_xOutputStream == null) {
+ throw new java.io.IOException("Stream is null");
+ }
+
+ byte[] bytes = new byte[1];
+ bytes[0] = (byte) b;
+
+ try {
+ m_xOutputStream.writeBytes(bytes);
+ } catch (com.sun.star.io.IOException ioe) {
+ throw new java.io.IOException(ioe.getMessage());
+ }
+ }
+ @Override
+ public void write(byte[] b)
+ throws java.io.IOException {
+
+ if (m_xOutputStream == null) {
+ throw new java.io.IOException("Stream is null");
+ }
+
+ try {
+ m_xOutputStream.writeBytes(b);
+ } catch (com.sun.star.io.IOException ioe) {
+ throw new java.io.IOException(ioe.getMessage());
}
- @Override
- public void write(int b)
- throws java.io.IOException
- {
- if ( m_xOutputStream == null )
- {
- throw new java.io.IOException("Stream is null");
- }
- byte[] bytes = new byte[1];
- bytes[0] = (byte) b;
- try
- {
- m_xOutputStream.writeBytes( bytes );
- }
- catch ( com.sun.star.io.IOException ioe )
- {
- throw new java.io.IOException(ioe.getMessage());
- }
+ }
+ @Override
+ public void write(byte[] b, int off, int len)
+ throws java.io.IOException {
+ if (m_xOutputStream == null) {
+ throw new java.io.IOException("Stream is null");
}
- @Override
- public void write(byte[] b)
- throws java.io.IOException
- {
- if ( m_xOutputStream == null )
- {
- throw new java.io.IOException( "Stream is null" );
- }
- try
- {
- m_xOutputStream.writeBytes( b );
- }
- catch ( com.sun.star.io.IOException ioe )
- {
- throw new java.io.IOException(ioe.getMessage());
- }
+ byte[] bytes = new byte[len];
+ System.arraycopy(b, off, bytes, 0, len);
+
+ try {
+ m_xOutputStream.writeBytes(bytes);
+ } catch (com.sun.star.io.IOException ioe) {
+ throw new java.io.IOException(ioe.getMessage());
}
- @Override
- public void write( byte[] b, int off, int len )
- throws java.io.IOException
- {
- if ( m_xOutputStream == null )
- {
- throw new java.io.IOException( "Stream is null" );
- }
- byte[] bytes = new byte[len];
- System.arraycopy(b, off, bytes, 0, len);
- try
- {
- m_xOutputStream.writeBytes(bytes);
- }
- catch ( com.sun.star.io.IOException ioe )
- {
- throw new java.io.IOException(ioe.getMessage());
- }
+ }
+
+ @Override
+ public void flush()
+ throws java.io.IOException {
+ if (m_xOutputStream == null) {
+ throw new java.io.IOException("Stream is null");
}
- @Override
- public void flush()
- throws java.io.IOException
- {
- if ( m_xOutputStream == null )
- {
- throw new java.io.IOException( "Stream is null" );
- }
- try
- {
- m_xOutputStream.flush();
- }
- catch ( com.sun.star.io.IOException ioe )
- {
- throw new java.io.IOException(ioe.getMessage());
- }
+ try {
+ m_xOutputStream.flush();
+ } catch (com.sun.star.io.IOException ioe) {
+ throw new java.io.IOException(ioe.getMessage());
}
- @Override
- public void close()
- throws java.io.IOException
- {
- if ( m_xOutputStream == null )
- {
- throw new java.io.IOException( "Stream is null" );
- }
- try
- {
- m_xOutputStream.closeOutput();
- }
- catch ( com.sun.star.io.IOException ioe )
- {
- throw new java.io.IOException(ioe.getMessage());
- }
+ }
+ @Override
+ public void close()
+ throws java.io.IOException {
+ if (m_xOutputStream == null) {
+ throw new java.io.IOException("Stream is null");
}
+ try {
+ m_xOutputStream.closeOutput();
+ } catch (com.sun.star.io.IOException ioe) {
+ throw new java.io.IOException(ioe.getMessage());
+ }
}
+}
+
diff --git a/scripting/java/com/sun/star/script/framework/io/XStorageHelper.java b/scripting/java/com/sun/star/script/framework/io/XStorageHelper.java
index c936aacfae07..aed57aee66f7 100644
--- a/scripting/java/com/sun/star/script/framework/io/XStorageHelper.java
+++ b/scripting/java/com/sun/star/script/framework/io/XStorageHelper.java
@@ -50,182 +50,158 @@ import java.util.*;
import java.io.*;
-public class XStorageHelper implements XEventListener
-{
+public class XStorageHelper implements XEventListener {
XStorage[] xStorages;
XStream xStream;
XInputStream xIs = null;
XOutputStream xOs = null;
- static Map<String,XModel> modelMap = new HashMap<String,XModel>();
+ static Map<String, XModel> modelMap = new HashMap<String, XModel>();
XModel xModel = null;
private static XStorageHelper listener = new XStorageHelper();
private XStorageHelper() {}
- public XStorageHelper( String path, int mode, boolean create ) throws IOException
- {
+ public XStorageHelper(String path, int mode,
+ boolean create) throws IOException {
String modelUrl = null;
- int indexOfScriptsDir = path.lastIndexOf( "Scripts" );
- if ( indexOfScriptsDir > -1 )
- {
- modelUrl = path.substring( 0, indexOfScriptsDir - 1 );
- path = path.substring( indexOfScriptsDir, path.length());
+ int indexOfScriptsDir = path.lastIndexOf("Scripts");
+
+ if (indexOfScriptsDir > -1) {
+ modelUrl = path.substring(0, indexOfScriptsDir - 1);
+ path = path.substring(indexOfScriptsDir, path.length());
}
LogUtils.DEBUG("XStorageHelper ctor, path: " + path);
- this.xModel = getModelForURL( modelUrl );
+ this.xModel = getModelForURL(modelUrl);
- try
- {
+ try {
StringTokenizer tokens = new StringTokenizer(path, "/");
- if (tokens.countTokens() == 0)
- {
- throw new IOException("Invalid path");
+ if (tokens.countTokens() == 0) {
+ throw new IOException("Invalid path");
}
+
XDocumentSubStorageSupplier xDocumentSubStorageSupplier =
UnoRuntime.queryInterface(
- XDocumentSubStorageSupplier.class, xModel);
+ XDocumentSubStorageSupplier.class, xModel);
xStorages = new XStorage[tokens.countTokens() ];
- LogUtils.DEBUG("XStorageHelper ctor, path chunks length: " + xStorages.length );
+ LogUtils.DEBUG("XStorageHelper ctor, path chunks length: " + xStorages.length);
- for ( int i = 0; i < xStorages.length; i++ )
- {
- LogUtils.DEBUG("XStorageHelper, processing index " + i );
+ for (int i = 0; i < xStorages.length; i++) {
+ LogUtils.DEBUG("XStorageHelper, processing index " + i);
String name = tokens.nextToken();
LogUtils.DEBUG("XStorageHelper, getting: " + name);
XStorage storage = null;
- if ( i == 0 )
- {
- storage = xDocumentSubStorageSupplier.getDocumentSubStorage( name, mode );
- if ( storage == null )
- {
- LogUtils.DEBUG("** boo hoo Storage is null " );
+
+ if (i == 0) {
+ storage = xDocumentSubStorageSupplier.getDocumentSubStorage(name, mode);
+
+ if (storage == null) {
+ LogUtils.DEBUG("** boo hoo Storage is null ");
}
- XPropertySet xProps = UnoRuntime.queryInterface(XPropertySet.class,storage );
- if ( xProps != null )
- {
- String mediaType = AnyConverter.toString( xProps.getPropertyValue( "MediaType" ) );
- LogUtils.DEBUG("***** media type is " + mediaType );
- if ( !mediaType.equals("scripts") )
- {
- xProps.setPropertyValue("MediaType","scripts");
+
+ XPropertySet xProps = UnoRuntime.queryInterface(XPropertySet.class, storage);
+
+ if (xProps != null) {
+ String mediaType = AnyConverter.toString(xProps.getPropertyValue("MediaType"));
+ LogUtils.DEBUG("***** media type is " + mediaType);
+
+ if (!mediaType.equals("scripts")) {
+ xProps.setPropertyValue("MediaType", "scripts");
}
}
- }
- else
- {
- XNameAccess xNameAccess = UnoRuntime.queryInterface(XNameAccess.class, xStorages[i-1]);
- if (xNameAccess == null )
- {
+ } else {
+ XNameAccess xNameAccess = UnoRuntime.queryInterface(XNameAccess.class,
+ xStorages[i - 1]);
+
+ if (xNameAccess == null) {
disposeObject();
throw new IOException("No name access " + name);
- }
- else if ( !xNameAccess.hasByName(name) || !xStorages[i-1].isStorageElement(name) )
- {
- if ( !create )
- {
+ } else if (!xNameAccess.hasByName(name)
+ || !xStorages[i - 1].isStorageElement(name)) {
+ if (!create) {
disposeObject();
throw new IOException("No subdir: " + name);
- }
- else
- {
+ } else {
// attempt to create new storage
- LogUtils.DEBUG("Attempt to create new storage for " + name );
+ LogUtils.DEBUG("Attempt to create new storage for " + name);
}
}
- storage = xStorages[i-1].openStorageElement(
- name, mode );
+ storage = xStorages[i - 1].openStorageElement(
+ name, mode);
}
- if ( storage == null )
- {
+
+ if (storage == null) {
disposeObject();
throw new IOException("storage not found: " + name);
}
+
xStorages[ i ] = storage;
}
- }
- catch ( com.sun.star.io.IOException ioe)
- {
+ } catch (com.sun.star.io.IOException ioe) {
disposeObject();
- }
- catch (com.sun.star.uno.Exception e)
- {
+ } catch (com.sun.star.uno.Exception e) {
disposeObject();
throw new IOException(e.getMessage());
}
}
- public synchronized static void addNewModel( XModel model )
- {
+ public synchronized static void addNewModel(XModel model) {
// TODO needs to cater for model for untitled document
- modelMap.put( PathUtils.getOidForModel( model ), model );
+ modelMap.put(PathUtils.getOidForModel(model), model);
XComponent xComp = UnoRuntime.queryInterface(XComponent.class, model);
- if ( xComp != null )
- {
- try
- {
- xComp.addEventListener( listener );
- }
- catch ( Exception e )
- {
+ if (xComp != null) {
+ try {
+ xComp.addEventListener(listener);
+ } catch (Exception e) {
// What TODO here ?
- LogUtils.DEBUG( LogUtils.getTrace( e ) );
+ LogUtils.DEBUG(LogUtils.getTrace(e));
}
}
}
- public void disposing( EventObject Source )
- {
- XModel model = UnoRuntime.queryInterface(XModel.class,Source.Source );
+ public void disposing(EventObject Source) {
+ XModel model = UnoRuntime.queryInterface(XModel.class, Source.Source);
- if ( model != null )
- {
- LogUtils.DEBUG(" Disposing doc " + model.getURL() );
- modelMap.remove( model );
+ if (model != null) {
+ LogUtils.DEBUG(" Disposing doc " + model.getURL());
+ modelMap.remove(model);
}
}
- public XStorage getStorage()
- {
+ public XStorage getStorage() {
return xStorages[ xStorages.length - 1 ];
}
- public XModel getModel()
- {
+ public XModel getModel() {
return xModel;
}
- public void disposeObject()
- {
- disposeObject( false );
+ public void disposeObject() {
+ disposeObject(false);
}
- public void disposeObject( boolean shouldCommit )
- {
+ public void disposeObject(boolean shouldCommit) {
LogUtils.DEBUG("In disposeObject");
- for ( int i = xStorages.length -1 ; i > -1; i-- )
- {
- LogUtils.DEBUG("In disposeObject disposing storage " + i );
- try
- {
+ for (int i = xStorages.length - 1 ; i > -1; i--) {
+ LogUtils.DEBUG("In disposeObject disposing storage " + i);
+
+ try {
XStorage xStorage = xStorages[i];
- if ( shouldCommit )
- {
+
+ if (shouldCommit) {
commit(xStorage);
}
+
disposeObject(xStorage);
- LogUtils.DEBUG("In disposeObject disposed storage " + i );
- }
- catch( Exception ignore )
- {
- LogUtils.DEBUG("Exception disposing storage " + i );
+ LogUtils.DEBUG("In disposeObject disposed storage " + i);
+ } catch (Exception ignore) {
+ LogUtils.DEBUG("Exception disposing storage " + i);
}
}
}
- static public void disposeObject( XInterface xInterface )
- {
+ static public void disposeObject(XInterface xInterface) {
if (xInterface == null) {
return;
}
@@ -235,28 +211,25 @@ public class XStorageHelper implements XEventListener
if (xComponent == null) {
return;
}
+
xComponent.dispose();
}
- static public void commit( XInterface xInterface )
- {
- XTransactedObject xTrans = UnoRuntime.queryInterface(XTransactedObject.class, xInterface);
- if ( xTrans != null )
- {
- try
- {
+ static public void commit(XInterface xInterface) {
+ XTransactedObject xTrans = UnoRuntime.queryInterface(XTransactedObject.class,
+ xInterface);
+
+ if (xTrans != null) {
+ try {
xTrans.commit();
- }
- catch ( Exception e )
- {
- LogUtils.DEBUG("Something went bellyup exception: " + e );
+ } catch (Exception e) {
+ LogUtils.DEBUG("Something went bellyup exception: " + e);
}
}
}
- public XModel getModelForURL( String url )
- {
- //TODO does not cater for untitled documents
- return modelMap.get( url );
+ public XModel getModelForURL(String url) {
+ //TODO does not cater for untitled documents
+ return modelMap.get(url);
}
}
diff --git a/scripting/java/com/sun/star/script/framework/log/LogUtils.java b/scripting/java/com/sun/star/script/framework/log/LogUtils.java
index 0344db864214..e6ed7ff61dbe 100644
--- a/scripting/java/com/sun/star/script/framework/log/LogUtils.java
+++ b/scripting/java/com/sun/star/script/framework/log/LogUtils.java
@@ -25,13 +25,11 @@ public class LogUtils {
private static boolean m_bDebugEnabled = false;
- static
- {
+ static {
String debugFlag =
System.getProperties().getProperty("ScriptJavaRuntimeDebug");
- if (debugFlag != null && debugFlag.length() > 0)
- {
+ if (debugFlag != null && debugFlag.length() > 0) {
m_bDebugEnabled = debugFlag.equalsIgnoreCase("true");
}
}
@@ -45,42 +43,34 @@ public class LogUtils {
*
* @param msg message to be displayed
*/
- public static void DEBUG(String msg)
- {
- if (m_bDebugEnabled)
- {
+ public static void DEBUG(String msg) {
+ if (m_bDebugEnabled) {
System.out.println(msg);
}
}
- public static String getTrace( Exception e )
- {
+ public static String getTrace(Exception e) {
ByteArrayOutputStream baos = null;
PrintStream ps = null;
String result = "";
- try
- {
- baos = new ByteArrayOutputStream( );
- ps = new PrintStream( baos );
- e.printStackTrace( ps );
- }
- finally
- {
- try
- {
- if ( baos != null )
- {
+
+ try {
+ baos = new ByteArrayOutputStream();
+ ps = new PrintStream(baos);
+ e.printStackTrace(ps);
+ } finally {
+ try {
+ if (baos != null) {
baos.close();
}
- if ( ps != null )
- {
+
+ if (ps != null) {
ps.close();
}
- }
- catch ( Exception excp )
- {
+ } catch (Exception excp) {
}
}
+
return result;
}
}
diff --git a/scripting/java/com/sun/star/script/framework/provider/ClassLoaderFactory.java b/scripting/java/com/sun/star/script/framework/provider/ClassLoaderFactory.java
index 823f2ff731e7..73f3f9c38fd9 100644
--- a/scripting/java/com/sun/star/script/framework/provider/ClassLoaderFactory.java
+++ b/scripting/java/com/sun/star/script/framework/provider/ClassLoaderFactory.java
@@ -26,24 +26,23 @@ import com.sun.star.script.framework.container.ScriptMetaData;
/**
* Class Loader Factory
*/
-public class ClassLoaderFactory
-{
+public class ClassLoaderFactory {
private ClassLoaderFactory() {}
- public static ClassLoader getURLClassLoader( ScriptMetaData scriptData )
- {
+ public static ClassLoader getURLClassLoader(ScriptMetaData scriptData) {
ClassLoader parent = scriptData.getClass().getClassLoader();
URL[] classPath = scriptData.getClassPath();
- LogUtils.DEBUG("Classpath has length " + classPath.length );
- for ( int i=0; i < classPath.length; i++ )
- {
- LogUtils.DEBUG("ClassPath " + i + "} is " + classPath[ i ].toString() );
+ LogUtils.DEBUG("Classpath has length " + classPath.length);
+
+ for (int i = 0; i < classPath.length; i++) {
+ LogUtils.DEBUG("ClassPath " + i + "} is " + classPath[ i ].toString());
}
- return getURLClassLoader( parent, classPath );
+
+ return getURLClassLoader(parent, classPath);
}
- private static ClassLoader getURLClassLoader( ClassLoader parent, URL[] classpath)
- {
- return new URLClassLoader( classpath, parent);
+ private static ClassLoader getURLClassLoader(ClassLoader parent,
+ URL[] classpath) {
+ return new URLClassLoader(classpath, parent);
}
}
diff --git a/scripting/java/com/sun/star/script/framework/provider/EditorScriptContext.java b/scripting/java/com/sun/star/script/framework/provider/EditorScriptContext.java
index 994a62700db0..5755e8cd6a28 100644
--- a/scripting/java/com/sun/star/script/framework/provider/EditorScriptContext.java
+++ b/scripting/java/com/sun/star/script/framework/provider/EditorScriptContext.java
@@ -25,13 +25,11 @@ import com.sun.star.document.XScriptInvocationContext;
import com.sun.star.script.provider.XScriptContext;
-public class EditorScriptContext implements XScriptContext
-{
+public class EditorScriptContext implements XScriptContext {
private XDesktop m_xDeskTop;
private XComponentContext m_xComponentContext;
- public EditorScriptContext( XComponentContext xmComponentContext,
- XDesktop xDesktop )
- {
+ public EditorScriptContext(XComponentContext xmComponentContext,
+ XDesktop xDesktop) {
this.m_xComponentContext = xmComponentContext;
this.m_xDeskTop = xDesktop;
}
@@ -41,18 +39,16 @@ public class EditorScriptContext implements XScriptContext
@return XModel interface
*/
- public XModel getDocument()
- {
- XModel xModel = UnoRuntime.queryInterface( XModel.class,
- m_xDeskTop.getCurrentComponent() );
+ public XModel getDocument() {
+ XModel xModel = UnoRuntime.queryInterface(XModel.class,
+ m_xDeskTop.getCurrentComponent());
return xModel;
}
- public XScriptInvocationContext getInvocationContext()
- {
+ public XScriptInvocationContext getInvocationContext() {
XScriptInvocationContext xContext = UnoRuntime.queryInterface(
- XScriptInvocationContext.class, getDocument() );
+ XScriptInvocationContext.class, getDocument());
return xContext;
}
@@ -61,8 +57,7 @@ public class EditorScriptContext implements XScriptContext
@return XDesktop interface
*/
- public XDesktop getDesktop()
- {
+ public XDesktop getDesktop() {
return m_xDeskTop;
}
@@ -71,9 +66,8 @@ public class EditorScriptContext implements XScriptContext
@return XComponentContext interface
*/
- public XComponentContext getComponentContext()
- {
- return m_xComponentContext;
+ public XComponentContext getComponentContext() {
+ return m_xComponentContext;
}
}
diff --git a/scripting/java/com/sun/star/script/framework/provider/NoSuitableClassLoaderException.java b/scripting/java/com/sun/star/script/framework/provider/NoSuitableClassLoaderException.java
index ea412fc6b678..c9c103256a39 100644
--- a/scripting/java/com/sun/star/script/framework/provider/NoSuitableClassLoaderException.java
+++ b/scripting/java/com/sun/star/script/framework/provider/NoSuitableClassLoaderException.java
@@ -18,14 +18,12 @@
package com.sun.star.script.framework.provider;
-public class NoSuitableClassLoaderException extends Exception
-{
+public class NoSuitableClassLoaderException extends Exception {
/**
* Constructs an <code>NoSuitableClassLoaderException</code> with <code>null</code>
* as its error detail message.
*/
- public NoSuitableClassLoaderException()
- {
+ public NoSuitableClassLoaderException() {
super();
}
/**
@@ -36,8 +34,7 @@ public class NoSuitableClassLoaderException extends Exception
*
* @param s the detail message.
*/
- public NoSuitableClassLoaderException(String s)
- {
+ public NoSuitableClassLoaderException(String s) {
super(s);
}
diff --git a/scripting/java/com/sun/star/script/framework/provider/PathUtils.java b/scripting/java/com/sun/star/script/framework/provider/PathUtils.java
index 1bd7bd28f657..3cb88c929d2a 100644
--- a/scripting/java/com/sun/star/script/framework/provider/PathUtils.java
+++ b/scripting/java/com/sun/star/script/framework/provider/PathUtils.java
@@ -38,46 +38,41 @@ public class PathUtils {
BOOTSTRAP_NAME = m_windows ? "bootstrap.ini" : "bootstraprc";
}
- public static String getOidForModel( XModel xModel )
- {
+ public static String getOidForModel(XModel xModel) {
String oid = "";
- if ( xModel != null )
- {
- try
- {
- Method getOid = IQueryInterface.class.getMethod("getOid", (java.lang.Class[])null);
- if ( getOid != null )
- {
- oid = (String)getOid.invoke( xModel, new Object[0] );
+
+ if (xModel != null) {
+ try {
+ Method getOid = IQueryInterface.class.getMethod("getOid",
+ (java.lang.Class[])null);
+
+ if (getOid != null) {
+ oid = (String)getOid.invoke(xModel, new Object[0]);
}
- }
- catch ( Exception ignore )
- {
+ } catch (Exception ignore) {
}
}
+
return oid;
}
- static public String make_url( String baseUrl, String url )
- {
- StringBuilder buff = new StringBuilder( baseUrl.length() + url.length() );
- buff.append( baseUrl );
- StringTokenizer t = new StringTokenizer( url, "/");
- while ( t.hasMoreElements() )
- {
- if ( buff.charAt( buff.length() - 1 ) != '/' )
- {
- buff.append('/');
- }
- try
- {
- buff.append( java.net.URLEncoder.encode( (String)t.nextElement(), "UTF-8" ) );
- }
- catch (java.io.UnsupportedEncodingException e)
- {
- e.printStackTrace();
- }
+ static public String make_url(String baseUrl, String url) {
+ StringBuilder buff = new StringBuilder(baseUrl.length() + url.length());
+ buff.append(baseUrl);
+ StringTokenizer t = new StringTokenizer(url, "/");
+
+ while (t.hasMoreElements()) {
+ if (buff.charAt(buff.length() - 1) != '/') {
+ buff.append('/');
+ }
+
+ try {
+ buff.append(java.net.URLEncoder.encode((String)t.nextElement(), "UTF-8"));
+ } catch (java.io.UnsupportedEncodingException e) {
+ e.printStackTrace();
+ }
}
+
return buff.toString();
}
diff --git a/scripting/java/com/sun/star/script/framework/provider/ScriptContext.java b/scripting/java/com/sun/star/script/framework/provider/ScriptContext.java
index 9d922cf30c5a..546755e9e93a 100644
--- a/scripting/java/com/sun/star/script/framework/provider/ScriptContext.java
+++ b/scripting/java/com/sun/star/script/framework/provider/ScriptContext.java
@@ -31,8 +31,7 @@ import com.sun.star.script.provider.XScriptContext;
import com.sun.star.script.framework.log.LogUtils;
-public class ScriptContext extends PropertySet implements XScriptContext
-{
+public class ScriptContext extends PropertySet implements XScriptContext {
private final static String HM_DOC_REF = "DocumentReference";
private final static String HM_DESKTOP = "Desktop";
private final static String HM_COMPONENT_CONTEXT = "ComponentContext";
@@ -47,51 +46,50 @@ public class ScriptContext extends PropertySet implements XScriptContext
private XComponentContext m_xComponentContext = null;
- private ScriptContext( XComponentContext xmComponentContext,
- XDesktop xDesktop, XModel xModel, XScriptInvocationContext xInvocContext)
- {
+ private ScriptContext(XComponentContext xmComponentContext,
+ XDesktop xDesktop, XModel xModel, XScriptInvocationContext xInvocContext) {
this.m_xDeskTop = xDesktop;
this.m_xComponentContext = xmComponentContext;
this.m_xModel = xModel;
this.m_xInvocationContext = xInvocContext;
- if ( m_xModel != null )
- {
- registerProperty( DOC_URI, new Type(String.class),
- (short)(PropertyAttribute.MAYBEVOID | PropertyAttribute.TRANSIENT), "m_sDocURI");
+ if (m_xModel != null) {
+ registerProperty(DOC_URI, new Type(String.class),
+ (short)(PropertyAttribute.MAYBEVOID | PropertyAttribute.TRANSIENT),
+ "m_sDocURI");
}
- registerProperty( HM_DOC_REF, new Type(XModel.class),
- (short)(PropertyAttribute.MAYBEVOID | PropertyAttribute.TRANSIENT), "m_xModel");
- registerProperty( HM_DESKTOP, new Type(XDesktop.class),
- (short)(PropertyAttribute.MAYBEVOID | PropertyAttribute.TRANSIENT), "m_xDeskTop");
- registerProperty( HM_COMPONENT_CONTEXT, new Type(XDesktop.class),
- (short)(PropertyAttribute.MAYBEVOID | PropertyAttribute.TRANSIENT), "m_xComponentContext");
+ registerProperty(HM_DOC_REF, new Type(XModel.class),
+ (short)(PropertyAttribute.MAYBEVOID | PropertyAttribute.TRANSIENT), "m_xModel");
+ registerProperty(HM_DESKTOP, new Type(XDesktop.class),
+ (short)(PropertyAttribute.MAYBEVOID | PropertyAttribute.TRANSIENT),
+ "m_xDeskTop");
+ registerProperty(HM_COMPONENT_CONTEXT, new Type(XDesktop.class),
+ (short)(PropertyAttribute.MAYBEVOID | PropertyAttribute.TRANSIENT),
+ "m_xComponentContext");
}
- public static XScriptContext createContext( XModel xModel, XScriptInvocationContext xInvocContext,
- XComponentContext xCtxt, XMultiComponentFactory xMCF)
- {
+ public static XScriptContext createContext(XModel xModel,
+ XScriptInvocationContext xInvocContext,
+ XComponentContext xCtxt, XMultiComponentFactory xMCF) {
XScriptContext sc = null;
try {
Object xInterface = xMCF.createInstanceWithContext(
- "com.sun.star.frame.Desktop", xCtxt);
+ "com.sun.star.frame.Desktop", xCtxt);
XDesktop xDesktop = UnoRuntime.queryInterface(XDesktop.class, xInterface);
- if ( xModel != null )
- {
+
+ if (xModel != null) {
sc = new ScriptContext(xCtxt, xDesktop, xModel, xInvocContext);
- }
- else
- {
- sc = new EditorScriptContext(xCtxt, xDesktop );
+ } else {
+ sc = new EditorScriptContext(xCtxt, xDesktop);
}
+ } catch (Exception e) {
+ LogUtils.DEBUG(LogUtils.getTrace(e));
}
- catch ( Exception e ) {
- LogUtils.DEBUG( LogUtils.getTrace( e ) );
- }
+
return sc;
}
@@ -101,13 +99,11 @@ public class ScriptContext extends PropertySet implements XScriptContext
@return XModel interface
*/
- public XModel getDocument()
- {
+ public XModel getDocument() {
return m_xModel;
}
- public XScriptInvocationContext getInvocationContext()
- {
+ public XScriptInvocationContext getInvocationContext() {
return m_xInvocationContext;
}
@@ -116,8 +112,7 @@ public class ScriptContext extends PropertySet implements XScriptContext
@return XDesktop interface
*/
- public XDesktop getDesktop()
- {
+ public XDesktop getDesktop() {
return m_xDeskTop;
}
@@ -126,9 +121,8 @@ public class ScriptContext extends PropertySet implements XScriptContext
@return XComponentContext interface
*/
- public XComponentContext getComponentContext()
- {
- return m_xComponentContext;
+ public XComponentContext getComponentContext() {
+ return m_xComponentContext;
}
}
diff --git a/scripting/java/com/sun/star/script/framework/provider/ScriptEditor.java b/scripting/java/com/sun/star/script/framework/provider/ScriptEditor.java
index 834108bc62ba..8ae3b510fdf2 100644
--- a/scripting/java/com/sun/star/script/framework/provider/ScriptEditor.java
+++ b/scripting/java/com/sun/star/script/framework/provider/ScriptEditor.java
@@ -21,10 +21,9 @@ package com.sun.star.script.framework.provider;
import com.sun.star.script.provider.XScriptContext;
import com.sun.star.script.framework.container.ScriptMetaData;
-public interface ScriptEditor
-{
+public interface ScriptEditor {
Object execute() throws Exception;
- void indicateErrorLine( int lineNum );
+ void indicateErrorLine(int lineNum);
void edit(XScriptContext context, ScriptMetaData entry);
String getTemplate();
String getExtension();
diff --git a/scripting/java/com/sun/star/script/framework/provider/ScriptProvider.java b/scripting/java/com/sun/star/script/framework/provider/ScriptProvider.java
index 3ee02ecb8dc5..3077ae6da3ec 100644
--- a/scripting/java/com/sun/star/script/framework/provider/ScriptProvider.java
+++ b/scripting/java/com/sun/star/script/framework/provider/ScriptProvider.java
@@ -80,8 +80,7 @@ import com.sun.star.uno.TypeClass;
public abstract class ScriptProvider
implements XScriptProvider, XBrowseNode, XPropertySet, XInvocation,
- XInitialization, XTypeProvider, XServiceInfo, XNameContainer
-{
+ XInitialization, XTypeProvider, XServiceInfo, XNameContainer {
private final String[] __serviceNames = {
"com.sun.star.script.provider.ScriptProviderFor",
"com.sun.star.script.provider.LanguageScriptProvider"
@@ -100,178 +99,165 @@ public abstract class ScriptProvider
// proxies to helper objects which implement interfaces
private XPropertySet m_xPropertySetProxy;
private XInvocation m_xInvocationProxy;
- // TODO should this be implemented in this class
+ // TODO should this be implemented in this class
private XBrowseNode m_xBrowseNodeProxy;
private XScriptContext m_xScriptContext;
- public ScriptProvider( XComponentContext ctx, String language )
- {
+ public ScriptProvider(XComponentContext ctx, String language) {
this.language = language;
__serviceNames[0] += language;
- LogUtils.DEBUG( "ScriptProvider: constructor - start. " + language );
+ LogUtils.DEBUG("ScriptProvider: constructor - start. " + language);
m_xContext = ctx;
// Initialize DialogFactory class in case dialogs are required
DialogFactory.createDialogFactory(m_xContext);
- try
- {
+ try {
m_xMultiComponentFactory = m_xContext.getServiceManager();
- if ( m_xMultiComponentFactory == null )
- {
- throw new Exception( "Error could not obtain a " +
- "multicomponent factory - rethrowing Exception." );
+ if (m_xMultiComponentFactory == null) {
+ throw new Exception("Error could not obtain a " +
+ "multicomponent factory - rethrowing Exception.");
}
Object serviceObj = m_xContext.getValueByName(
- "/singletons/com.sun.star.util.theMacroExpander");
+ "/singletons/com.sun.star.util.theMacroExpander");
XMacroExpander me = (XMacroExpander) AnyConverter.toObject(
- new Type(XMacroExpander.class), serviceObj);
+ new Type(XMacroExpander.class), serviceObj);
XMLParserFactory.setOfficeDTDURL(me.expandMacros(
- "$BRAND_BASE_DIR/$BRAND_SHARE_SUBDIR/dtd/officedocument/1_0/"));
+ "$BRAND_BASE_DIR/$BRAND_SHARE_SUBDIR/dtd/officedocument/1_0/"));
- }
- catch ( Exception e )
- {
- LogUtils.DEBUG( LogUtils.getTrace( e ) );
+ } catch (Exception e) {
+ LogUtils.DEBUG(LogUtils.getTrace(e));
com.sun.star.uno.RuntimeException e2 =
new com.sun.star.uno.RuntimeException(
- "Error constructing ScriptProvider: " + e );
- e2.initCause( e );
+ "Error constructing ScriptProvider: " + e);
+ e2.initCause(e);
throw e2;
}
- LogUtils.DEBUG( "ScriptProvider: constructor - finished." );
+ LogUtils.DEBUG("ScriptProvider: constructor - finished.");
}
- synchronized public XScriptContext getScriptingContext()
- {
- if ( m_xScriptContext == null )
- {
- m_xScriptContext = ScriptContext.createContext( m_xModel, m_xInvocContext, m_xContext, m_xMultiComponentFactory );
+ synchronized public XScriptContext getScriptingContext() {
+ if (m_xScriptContext == null) {
+ m_xScriptContext = ScriptContext.createContext(m_xModel, m_xInvocContext,
+ m_xContext, m_xMultiComponentFactory);
}
+
return m_xScriptContext;
}
- public void initialize( Object[] aArguments )
- throws com.sun.star.uno.Exception
- {
- LogUtils.DEBUG( "entering XInit for language " + language);
+
+ public void initialize(Object[] aArguments)
+ throws com.sun.star.uno.Exception {
+ LogUtils.DEBUG("entering XInit for language " + language);
boolean isPkgProvider = false;
- if( aArguments.length == 1 )
- {
+
+ if (aArguments.length == 1) {
String contextUrl = null;
- if ( AnyConverter.getType(aArguments[0]).getTypeClass().equals(TypeClass.INTERFACE) )
- {
+
+ if (AnyConverter.getType(aArguments[0]).getTypeClass().equals(
+ TypeClass.INTERFACE)) {
// try whether it denotes a XScriptInvocationContext
m_xInvocContext = UnoRuntime.queryInterface(
- XScriptInvocationContext.class, aArguments[0]);
- if ( m_xInvocContext != null )
- {
+ XScriptInvocationContext.class, aArguments[0]);
+
+ if (m_xInvocContext != null) {
// if so, obtain the document - by definition, this must be
// the ScriptContainer
- m_xModel = UnoRuntime.queryInterface( XModel.class,
- m_xInvocContext.getScriptContainer() );
- }
- else
- {
+ m_xModel = UnoRuntime.queryInterface(XModel.class,
+ m_xInvocContext.getScriptContainer());
+ } else {
// otherwise, check whether it's an XModel
- m_xModel = UnoRuntime.queryInterface( XModel.class,
- m_xInvocContext.getScriptContainer() );
+ m_xModel = UnoRuntime.queryInterface(XModel.class,
+ m_xInvocContext.getScriptContainer());
}
- if ( m_xModel == null )
- {
+
+ if (m_xModel == null) {
throw new com.sun.star.uno.Exception(
- "ScriptProvider argument must be either a string, a valid XScriptInvocationContext, " +
+ "ScriptProvider argument must be either a string, a valid XScriptInvocationContext, "
+ +
"or an XModel", this);
}
- contextUrl = getDocUrlFromModel( m_xModel );
- m_container = new ParcelContainer( m_xContext, contextUrl, language );
- }
- else if (AnyConverter.isString(aArguments[0]))
- {
+ contextUrl = getDocUrlFromModel(m_xModel);
+ m_container = new ParcelContainer(m_xContext, contextUrl, language);
+ } else if (AnyConverter.isString(aArguments[0])) {
String originalContextURL = AnyConverter.toString(aArguments[0]);
- LogUtils.DEBUG("creating Application, path: " + originalContextURL );
+ LogUtils.DEBUG("creating Application, path: " + originalContextURL);
contextUrl = originalContextURL;
+
// TODO no support for packages in documents yet
- if ( originalContextURL.startsWith( "vnd.sun.star.tdoc" ) )
- {
- m_container = new ParcelContainer( m_xContext, contextUrl, language );
- m_xModel = getModelFromDocUrl( originalContextURL );
- }
- else
- {
+ if (originalContextURL.startsWith("vnd.sun.star.tdoc")) {
+ m_container = new ParcelContainer(m_xContext, contextUrl, language);
+ m_xModel = getModelFromDocUrl(originalContextURL);
+ } else {
String extensionDb = null;
String extensionRepository = null;
- if ( originalContextURL.startsWith( "bundled" ) )
- {
+
+ if (originalContextURL.startsWith("bundled")) {
contextUrl = "vnd.sun.star.expand:$BUNDLED_EXTENSIONS";
- extensionDb = "vnd.sun.star.expand:${$BRAND_INI_DIR/" + PathUtils.BOOTSTRAP_NAME + "::UserInstallation}/user";
+ extensionDb = "vnd.sun.star.expand:${$BRAND_INI_DIR/" + PathUtils.BOOTSTRAP_NAME
+ + "::UserInstallation}/user";
extensionRepository = "bundled";
- }
- else if ( originalContextURL.startsWith( "share" ) )
- {
+ } else if (originalContextURL.startsWith("share")) {
contextUrl = "vnd.sun.star.expand:$BRAND_BASE_DIR/$BRAND_SHARE_SUBDIR";
- extensionDb = "vnd.sun.star.expand:${$BRAND_INI_DIR/" + PathUtils.BOOTSTRAP_NAME + "::UserInstallation}/user";
+ extensionDb = "vnd.sun.star.expand:${$BRAND_INI_DIR/" + PathUtils.BOOTSTRAP_NAME
+ + "::UserInstallation}/user";
extensionRepository = "shared";
- }
- else if ( originalContextURL.startsWith( "user" ) )
- {
- contextUrl = "vnd.sun.star.expand:${$BRAND_INI_DIR/" + PathUtils.BOOTSTRAP_NAME + "::UserInstallation}/user";
- extensionDb = "vnd.sun.star.expand:${$BRAND_INI_DIR/" + PathUtils.BOOTSTRAP_NAME + "::UserInstallation}/user";
+ } else if (originalContextURL.startsWith("user")) {
+ contextUrl = "vnd.sun.star.expand:${$BRAND_INI_DIR/" + PathUtils.BOOTSTRAP_NAME
+ + "::UserInstallation}/user";
+ extensionDb = "vnd.sun.star.expand:${$BRAND_INI_DIR/" + PathUtils.BOOTSTRAP_NAME
+ + "::UserInstallation}/user";
extensionRepository = "user";
}
- if ( originalContextURL.endsWith( "uno_packages") )
- {
+ if (originalContextURL.endsWith("uno_packages")) {
isPkgProvider = true;
+
if (!originalContextURL.equals(contextUrl)
- && !extensionRepository.equals("bundled"))
- {
+ && !extensionRepository.equals("bundled")) {
contextUrl = PathUtils.make_url(contextUrl, "uno_packages");
}
}
- if ( isPkgProvider )
- {
- m_container = new UnoPkgContainer( m_xContext, contextUrl, extensionDb, extensionRepository, language );
- }
- else
- {
- m_container = new ParcelContainer( m_xContext, contextUrl, language );
+ if (isPkgProvider) {
+ m_container = new UnoPkgContainer(m_xContext, contextUrl, extensionDb,
+ extensionRepository, language);
+ } else {
+ m_container = new ParcelContainer(m_xContext, contextUrl, language);
}
}
- }
- else
- {
+ } else {
throw new com.sun.star.uno.RuntimeException(
"ScriptProvider created with invalid argument");
}
- LogUtils.DEBUG("Modified Application path is: " + contextUrl );
- LogUtils.DEBUG("isPkgProvider is: " + isPkgProvider );
+ LogUtils.DEBUG("Modified Application path is: " + contextUrl);
+ LogUtils.DEBUG("isPkgProvider is: " + isPkgProvider);
// TODO should all be done in this class instead of
// deleagation????
- m_xBrowseNodeProxy = new ProviderBrowseNode( this,
- m_container, m_xContext );
-
- m_xInvocationProxy = UnoRuntime.queryInterface(XInvocation.class, m_xBrowseNodeProxy);
- m_xPropertySetProxy = UnoRuntime.queryInterface(XPropertySet.class, m_xBrowseNodeProxy);
- }
- else
- {
+ m_xBrowseNodeProxy = new ProviderBrowseNode(this,
+ m_container, m_xContext);
+
+ m_xInvocationProxy = UnoRuntime.queryInterface(XInvocation.class,
+ m_xBrowseNodeProxy);
+ m_xPropertySetProxy = UnoRuntime.queryInterface(XPropertySet.class,
+ m_xBrowseNodeProxy);
+ } else {
// this is ok, for example when executing a script from the
// command line
- LogUtils.DEBUG( "ScriptProviderFor" + language +
- " initialized without a context");
+ LogUtils.DEBUG("ScriptProviderFor" + language +
+ " initialized without a context");
}
- LogUtils.DEBUG( "leaving XInit" );
+
+ LogUtils.DEBUG("leaving XInit");
}
/**
@@ -279,17 +265,16 @@ public abstract class ScriptProvider
*
* @return The types value
*/
- public com.sun.star.uno.Type[] getTypes()
- {
+ public com.sun.star.uno.Type[] getTypes() {
Type[] retValue = new Type[ 8 ];
- retValue[ 0 ] = new Type( XScriptProvider.class );
- retValue[ 1 ] = new Type( XBrowseNode.class );
- retValue[ 2 ] = new Type( XInitialization.class );
- retValue[ 3 ] = new Type( XTypeProvider.class );
- retValue[ 4 ] = new Type( XServiceInfo.class );
- retValue[ 5 ] = new Type( XPropertySet.class );
- retValue[ 6 ] = new Type( XInvocation.class );
- retValue[ 7 ] = new Type( com.sun.star.container.XNameContainer.class );
+ retValue[ 0 ] = new Type(XScriptProvider.class);
+ retValue[ 1 ] = new Type(XBrowseNode.class);
+ retValue[ 2 ] = new Type(XInitialization.class);
+ retValue[ 3 ] = new Type(XTypeProvider.class);
+ retValue[ 4 ] = new Type(XServiceInfo.class);
+ retValue[ 5 ] = new Type(XPropertySet.class);
+ retValue[ 6 ] = new Type(XInvocation.class);
+ retValue[ 7 ] = new Type(com.sun.star.container.XNameContainer.class);
return retValue;
}
@@ -298,8 +283,7 @@ public abstract class ScriptProvider
*
* @return The implementationId value
*/
- public byte[] getImplementationId()
- {
+ public byte[] getImplementationId() {
return new byte[0];
}
@@ -308,8 +292,7 @@ public abstract class ScriptProvider
*
* @return The implementationName value
*/
- public String getImplementationName()
- {
+ public String getImplementationName() {
return getClass().getName();
}
@@ -319,15 +302,13 @@ public abstract class ScriptProvider
* @param serviceName Description of the Parameter
* @return Description of the Return Value
*/
- public boolean supportsService( String serviceName )
- {
- for ( int index = __serviceNames.length; index-- > 0; )
- {
- if ( serviceName.equals( __serviceNames[ index ] ) )
- {
+ public boolean supportsService(String serviceName) {
+ for (int index = __serviceNames.length; index-- > 0;) {
+ if (serviceName.equals(__serviceNames[ index ])) {
return true;
}
}
+
return false;
}
@@ -336,16 +317,15 @@ public abstract class ScriptProvider
*
* @return The supportedServiceNames value
*/
- public String[] getSupportedServiceNames()
- {
+ public String[] getSupportedServiceNames() {
return __serviceNames;
}
- public abstract XScript getScript( /*IN*/String scriptURI )
- throws com.sun.star.uno.RuntimeException,
- ScriptFrameworkErrorException;
+ public abstract XScript getScript(/*IN*/String scriptURI)
+ throws com.sun.star.uno.RuntimeException,
+ ScriptFrameworkErrorException;
// TODO need to encapsulate this better,
// Some factory concept for creating/accessing Editor
@@ -358,55 +338,51 @@ public abstract class ScriptProvider
// This method is used to get the ScriptEditor for this ScriptProvider
public abstract ScriptEditor getScriptEditor();
- public ScriptMetaData getScriptData( /*IN*/String scriptURI ) throws ScriptFrameworkErrorException
+ public ScriptMetaData getScriptData(/*IN*/String scriptURI) throws
+ ScriptFrameworkErrorException
{
- try
- {
- ParsedScriptUri details = m_container.parseScriptUri( scriptURI );
- try
- {
+ try {
+ ParsedScriptUri details = m_container.parseScriptUri(scriptURI);
+
+ try {
ScriptMetaData scriptData = m_container.findScript(details);
- if (scriptData == null)
- {
+
+ if (scriptData == null) {
throw new ScriptFrameworkErrorException(details.function + " does not exist",
- null, details.function, language, ScriptFrameworkErrorType.NO_SUCH_SCRIPT);
+ null, details.function, language, ScriptFrameworkErrorType.NO_SUCH_SCRIPT);
}
+
return scriptData;
- }
- catch (com.sun.star.container.NoSuchElementException nse)
- {
+ } catch (com.sun.star.container.NoSuchElementException nse) {
ScriptFrameworkErrorException e2
- = new ScriptFrameworkErrorException(
- nse.getMessage(), null, details.function, language,
- ScriptFrameworkErrorType.NO_SUCH_SCRIPT);
+ = new ScriptFrameworkErrorException(
+ nse.getMessage(), null, details.function, language,
+ ScriptFrameworkErrorType.NO_SUCH_SCRIPT);
e2.initCause(nse);
throw e2;
- }
- catch (com.sun.star.lang.WrappedTargetException wta)
- {
+ } catch (com.sun.star.lang.WrappedTargetException wta) {
// TODO specify the correct error Type
Exception wrapped = (Exception) wta.TargetException;
String message = wta.getMessage();
- if (wrapped != null)
- {
+
+ if (wrapped != null) {
message = wrapped.getMessage();
}
+
ScriptFrameworkErrorException e2
- = new ScriptFrameworkErrorException(
- message, null, details.function, language,
- ScriptFrameworkErrorType.UNKNOWN);
+ = new ScriptFrameworkErrorException(
+ message, null, details.function, language,
+ ScriptFrameworkErrorType.UNKNOWN);
e2.initCause(wta);
throw e2;
}
- }
- catch (com.sun.star.lang.IllegalArgumentException ila)
- {
+ } catch (com.sun.star.lang.IllegalArgumentException ila) {
// TODO specify the correct error Type
ScriptFrameworkErrorException e2
- = new ScriptFrameworkErrorException(
- ila.getMessage(), null, scriptURI, language,
- ScriptFrameworkErrorType.UNKNOWN);
+ = new ScriptFrameworkErrorException(
+ ila.getMessage(), null, scriptURI, language,
+ ScriptFrameworkErrorType.UNKNOWN);
e2.initCause(ila);
throw e2;
}
@@ -414,39 +390,34 @@ public abstract class ScriptProvider
// Implementation of XBrowseNode interface
- public String getName()
- {
+ public String getName() {
return language;
}
- public XBrowseNode[] getChildNodes()
- {
- if ( m_xBrowseNodeProxy == null )
- {
+ public XBrowseNode[] getChildNodes() {
+ if (m_xBrowseNodeProxy == null) {
LogUtils.DEBUG("No Nodes available ");
return new XBrowseNode[0];
}
+
return m_xBrowseNodeProxy .getChildNodes();
}
- public boolean hasChildNodes()
- {
- if ( m_xBrowseNodeProxy == null )
- {
+ public boolean hasChildNodes() {
+ if (m_xBrowseNodeProxy == null) {
LogUtils.DEBUG("No Nodes available ");
return false;
}
+
return m_xBrowseNodeProxy.hasChildNodes();
}
- public short getType()
- {
+ public short getType() {
return BrowseNodeTypes.CONTAINER;
}
@Override
- public String toString()
- {
+ public String toString() {
return getName();
}
@@ -457,25 +428,22 @@ public abstract class ScriptProvider
public Object invoke(String aFunctionName, Object[] aParams,
short[][] aOutParamIndex, Object[][] aOutParam)
- throws com.sun.star.lang.IllegalArgumentException,
- com.sun.star.script.CannotConvertException,
- com.sun.star.reflection.InvocationTargetException
- {
+ throws com.sun.star.lang.IllegalArgumentException,
+ com.sun.star.script.CannotConvertException,
+ com.sun.star.reflection.InvocationTargetException {
return m_xInvocationProxy.invoke(
- aFunctionName, aParams, aOutParamIndex, aOutParam);
+ aFunctionName, aParams, aOutParamIndex, aOutParam);
}
public void setValue(String aPropertyName, Object aValue)
- throws com.sun.star.beans.UnknownPropertyException,
- com.sun.star.script.CannotConvertException,
- com.sun.star.reflection.InvocationTargetException
- {
+ throws com.sun.star.beans.UnknownPropertyException,
+ com.sun.star.script.CannotConvertException,
+ com.sun.star.reflection.InvocationTargetException {
m_xInvocationProxy.setValue(aPropertyName, aValue);
}
public Object getValue(String aPropertyName)
- throws com.sun.star.beans.UnknownPropertyException
- {
+ throws com.sun.star.beans.UnknownPropertyException {
return m_xInvocationProxy.getValue(aPropertyName);
}
@@ -487,203 +455,195 @@ public abstract class ScriptProvider
return m_xInvocationProxy.hasProperty(aName);
}
- public XPropertySetInfo getPropertySetInfo()
- {
+ public XPropertySetInfo getPropertySetInfo() {
return m_xPropertySetProxy.getPropertySetInfo();
}
public void setPropertyValue(String aPropertyName, Object aValue)
- throws com.sun.star.beans.UnknownPropertyException,
- com.sun.star.beans.PropertyVetoException,
- com.sun.star.lang.IllegalArgumentException,
- com.sun.star.lang.WrappedTargetException
- {
+ throws com.sun.star.beans.UnknownPropertyException,
+ com.sun.star.beans.PropertyVetoException,
+ com.sun.star.lang.IllegalArgumentException,
+ com.sun.star.lang.WrappedTargetException {
m_xPropertySetProxy.setPropertyValue(aPropertyName, aValue);
}
public Object getPropertyValue(String PropertyName)
- throws com.sun.star.beans.UnknownPropertyException,
- com.sun.star.lang.WrappedTargetException
- {
+ throws com.sun.star.beans.UnknownPropertyException,
+ com.sun.star.lang.WrappedTargetException {
return m_xPropertySetProxy.getPropertyValue(PropertyName);
}
public void addPropertyChangeListener(
String aPropertyName, XPropertyChangeListener xListener)
- throws com.sun.star.beans.UnknownPropertyException,
- com.sun.star.lang.WrappedTargetException
- {
+ throws com.sun.star.beans.UnknownPropertyException,
+ com.sun.star.lang.WrappedTargetException {
m_xPropertySetProxy.addPropertyChangeListener(aPropertyName, xListener);
}
public void removePropertyChangeListener(
String aPropertyName, XPropertyChangeListener aListener)
- throws com.sun.star.beans.UnknownPropertyException,
- com.sun.star.lang.WrappedTargetException
- {
+ throws com.sun.star.beans.UnknownPropertyException,
+ com.sun.star.lang.WrappedTargetException {
m_xPropertySetProxy.removePropertyChangeListener(
aPropertyName, aListener);
}
public void addVetoableChangeListener(
String PropertyName, XVetoableChangeListener aListener)
- throws com.sun.star.beans.UnknownPropertyException,
- com.sun.star.lang.WrappedTargetException
- {
+ throws com.sun.star.beans.UnknownPropertyException,
+ com.sun.star.lang.WrappedTargetException {
m_xPropertySetProxy.addVetoableChangeListener(PropertyName, aListener);
}
public void removeVetoableChangeListener(
String PropertyName, XVetoableChangeListener aListener)
- throws com.sun.star.beans.UnknownPropertyException,
- com.sun.star.lang.WrappedTargetException
- {
+ throws com.sun.star.beans.UnknownPropertyException,
+ com.sun.star.lang.WrappedTargetException {
m_xPropertySetProxy.removeVetoableChangeListener(
PropertyName, aListener);
}
- public java.lang.Object getByName( String aName ) throws com.sun.star.container.NoSuchElementException, com.sun.star.lang.WrappedTargetException
- {
+ public java.lang.Object getByName(String aName) throws
+ com.sun.star.container.NoSuchElementException,
+ com.sun.star.lang.WrappedTargetException {
// TODO needs implementing?
throw new com.sun.star.uno.RuntimeException(
- "getByName not implemented" );
+ "getByName not implemented");
}
- public String[] getElementNames()
- {
+ public String[] getElementNames() {
// TODO needs implementing?
throw new com.sun.star.uno.RuntimeException(
- "getElementNames not implemented" );
+ "getElementNames not implemented");
}
// Performs the getRegStatus functionality for the PkgMgr
- public boolean hasByName( String aName ) {
- return ((UnoPkgContainer)m_container).hasRegisteredUnoPkgContainer( aName );
+ public boolean hasByName(String aName) {
+ return ((UnoPkgContainer)m_container).hasRegisteredUnoPkgContainer(aName);
}
- public com.sun.star.uno.Type getElementType()
- {
+ public com.sun.star.uno.Type getElementType() {
// TODO at the moment this returns void indicating
// type is unknown should indicate XPackage ? do we implement XPackage
return new Type();
}
- public boolean hasElements()
- {
+ public boolean hasElements() {
// TODO needs implementing?
throw new com.sun.star.uno.RuntimeException(
- "hasElements not implemented" );
+ "hasElements not implemented");
}
- public void replaceByName( String aName, java.lang.Object aElement ) throws com.sun.star.lang.IllegalArgumentException, com.sun.star.container.NoSuchElementException, com.sun.star.lang.WrappedTargetException
- {
+ public void replaceByName(String aName,
+ java.lang.Object aElement) throws com.sun.star.lang.IllegalArgumentException,
+ com.sun.star.container.NoSuchElementException,
+ com.sun.star.lang.WrappedTargetException {
// TODO needs implementing
- if ( true )
- {
+ if (true) {
throw new com.sun.star.uno.RuntimeException(
- "replaceByName not implemented" );
+ "replaceByName not implemented");
}
}
- public void insertByName( String aName, java.lang.Object aElement ) throws com.sun.star.lang.IllegalArgumentException, com.sun.star.container.ElementExistException, com.sun.star.lang.WrappedTargetException
- {
- LogUtils.DEBUG("Provider for " + language + " received register for package " + aName );
- XPackage newPackage = UnoRuntime.queryInterface( XPackage.class, aElement );
- if ( aName.length() == 0 )
- {
- throw new com.sun.star.lang.IllegalArgumentException( "Empty name" );
+ public void insertByName(String aName,
+ java.lang.Object aElement) throws com.sun.star.lang.IllegalArgumentException,
+ com.sun.star.container.ElementExistException,
+ com.sun.star.lang.WrappedTargetException {
+ LogUtils.DEBUG("Provider for " + language + " received register for package " +
+ aName);
+ XPackage newPackage = UnoRuntime.queryInterface(XPackage.class, aElement);
+
+ if (aName.length() == 0) {
+ throw new com.sun.star.lang.IllegalArgumentException("Empty name");
}
- if ( newPackage == null )
- {
- throw new com.sun.star.lang.IllegalArgumentException( "No package supplied" );
+
+ if (newPackage == null) {
+ throw new com.sun.star.lang.IllegalArgumentException("No package supplied");
}
- ((UnoPkgContainer)m_container).processUnoPackage( newPackage, language );
+ ((UnoPkgContainer)m_container).processUnoPackage(newPackage, language);
}
// de-register for library only !!
- public void removeByName( String Name ) throws com.sun.star.container.NoSuchElementException, com.sun.star.lang.WrappedTargetException
- {
- LogUtils.DEBUG("In ScriptProvider.removeByName() for " + Name + " this provider = " + language );
- ParcelContainer c = ((UnoPkgContainer)m_container).getRegisteredUnoPkgContainer( Name );
- if ( c != null )
- {
+ public void removeByName(String Name) throws
+ com.sun.star.container.NoSuchElementException,
+ com.sun.star.lang.WrappedTargetException {
+ LogUtils.DEBUG("In ScriptProvider.removeByName() for " + Name +
+ " this provider = " + language);
+ ParcelContainer c = ((UnoPkgContainer)m_container).getRegisteredUnoPkgContainer(
+ Name);
+
+ if (c != null) {
String libName;
- if (Name.endsWith("/"))
- {
- String tmp = Name.substring( 0, Name.lastIndexOf('/') );
- libName = tmp.substring( tmp.lastIndexOf('/') + 1 );
- }
- else
- {
- libName = Name.substring( Name.lastIndexOf('/') + 1 );
- }
- LogUtils.DEBUG("Deregistering library " + libName );
- if ( c.removeParcel( libName ) )
- {
- ((UnoPkgContainer)m_container).deRegisterPackageContainer( Name );
+
+ if (Name.endsWith("/")) {
+ String tmp = Name.substring(0, Name.lastIndexOf('/'));
+ libName = tmp.substring(tmp.lastIndexOf('/') + 1);
+ } else {
+ libName = Name.substring(Name.lastIndexOf('/') + 1);
}
- else
- {
- throw new com.sun.star.container.NoSuchElementException( libName + " cannot be removed from container." );
+
+ LogUtils.DEBUG("Deregistering library " + libName);
+
+ if (c.removeParcel(libName)) {
+ ((UnoPkgContainer)m_container).deRegisterPackageContainer(Name);
+ } else {
+ throw new com.sun.star.container.NoSuchElementException(
+ libName + " cannot be removed from container.");
}
+ } else {
+ throw new com.sun.star.container.NoSuchElementException(
+ Name + " doesn't exist for " + language);
}
- else
- {
- throw new com.sun.star.container.NoSuchElementException( Name + " doesn't exist for " + language );
- }
+
// TODO see if we want to remove the ParcelContainer is no Parcels/Libraries left
}
- private String getDocUrlFromModel( XModel document )
- {
+ private String getDocUrlFromModel(XModel document) {
XTransientDocumentsDocumentContentFactory factory = null;
- try
- {
+
+ try {
factory = UnoRuntime.queryInterface(
- XTransientDocumentsDocumentContentFactory.class,
- m_xMultiComponentFactory.createInstanceWithContext(
- "com.sun.star.frame.TransientDocumentsDocumentContentFactory",
- m_xContext
- )
- );
- }
- catch (Exception ex)
- {
+ XTransientDocumentsDocumentContentFactory.class,
+ m_xMultiComponentFactory.createInstanceWithContext(
+ "com.sun.star.frame.TransientDocumentsDocumentContentFactory",
+ m_xContext
+ )
+ );
+ } catch (Exception ex) {
}
- if ( factory == null )
- throw new com.sun.star.uno.RuntimeException( "ScriptProvider: unable to create a TDOC context factory.", this );
+ if (factory == null)
+ throw new com.sun.star.uno.RuntimeException("ScriptProvider: unable to create a TDOC context factory.",
+ this);
- try
- {
- XContent content = factory.createDocumentContent( document );
+ try {
+ XContent content = factory.createDocumentContent(document);
return content.getIdentifier().getContentIdentifier();
- }
- catch (com.sun.star.lang.IllegalArgumentException ex)
- {
+ } catch (com.sun.star.lang.IllegalArgumentException ex) {
}
LogUtils.DEBUG("unable to determine the model's TDOC URL");
return "";
}
- private XModel getModelFromDocUrl( String docUrl )
- {
- LogUtils.DEBUG("getModelFromDocUrl - searching for match for ->" + docUrl + "<-" );
+ private XModel getModelFromDocUrl(String docUrl) {
+ LogUtils.DEBUG("getModelFromDocUrl - searching for match for ->" + docUrl +
+ "<-");
XModel xModel = null;
- try
- {
- XUniversalContentBroker ucb = UniversalContentBroker.create( m_xContext );
- XContentIdentifier xCntId = ucb.createContentIdentifier( docUrl );
+ try {
+ XUniversalContentBroker ucb = UniversalContentBroker.create(m_xContext);
+
+ XContentIdentifier xCntId = ucb.createContentIdentifier(docUrl);
- XContent xCnt = ucb.queryContent( xCntId );
+ XContent xCnt = ucb.queryContent(xCntId);
- XCommandProcessor xCmd = UnoRuntime.queryInterface( XCommandProcessor.class, xCnt );
+ XCommandProcessor xCmd = UnoRuntime.queryInterface(XCommandProcessor.class,
+ xCnt);
Property[] pArgs = new Property[ ] { new Property() };
@@ -697,19 +657,18 @@ public abstract class ScriptProvider
command.Argument = pArgs;
com.sun.star.ucb.XCommandEnvironment env = null ;
- Object result = xCmd.execute( command, 0, env ) ;
+ Object result = xCmd.execute(command, 0, env) ;
- XRow values = UnoRuntime.queryInterface( XRow.class,
- result );
+ XRow values = UnoRuntime.queryInterface(XRow.class,
+ result);
- xModel = UnoRuntime.queryInterface( XModel.class,
- values.getObject( 1, null ) );
- }
- catch ( Exception ignore )
- {
- LogUtils.DEBUG("Failed to get model exception " + ignore );
+ xModel = UnoRuntime.queryInterface(XModel.class,
+ values.getObject(1, null));
+ } catch (Exception ignore) {
+ LogUtils.DEBUG("Failed to get model exception " + ignore);
}
+
return xModel;
}
diff --git a/scripting/java/com/sun/star/script/framework/provider/SwingInvocation.java b/scripting/java/com/sun/star/script/framework/provider/SwingInvocation.java
index 74e95546af35..1a0e2ff4f14d 100644
--- a/scripting/java/com/sun/star/script/framework/provider/SwingInvocation.java
+++ b/scripting/java/com/sun/star/script/framework/provider/SwingInvocation.java
@@ -28,8 +28,10 @@ public final class SwingInvocation {
public static void invoke(final Runnable doRun) {
new Thread("SwingInvocation") {
@Override
- public void run() { SwingUtilities.invokeLater(doRun); }
- }.start();
+ public void run() {
+ SwingUtilities.invokeLater(doRun);
+ }
+ } .start();
}
private SwingInvocation() {}
diff --git a/scripting/java/com/sun/star/script/framework/provider/beanshell/PlainSourceView.java b/scripting/java/com/sun/star/script/framework/provider/beanshell/PlainSourceView.java
index bd8f01c9193a..f1f8e09561cb 100644
--- a/scripting/java/com/sun/star/script/framework/provider/beanshell/PlainSourceView.java
+++ b/scripting/java/com/sun/star/script/framework/provider/beanshell/PlainSourceView.java
@@ -55,14 +55,13 @@ public class PlainSourceView extends JScrollPane
so we don't get a storm of DocumentEvents during loading */
ta.getDocument().removeDocumentListener(this);
- if (!isModified)
- {
+ if (!isModified) {
int pos = ta.getCaretPosition();
ta.setText(model.getText());
+
try {
ta.setCaretPosition(pos);
- }
- catch (IllegalArgumentException iae) {
+ } catch (IllegalArgumentException iae) {
// do nothing and allow JTextArea to set it's own position
}
}
@@ -72,8 +71,7 @@ public class PlainSourceView extends JScrollPane
int line = ta.getLineStartOffset(model.getCurrentPosition());
Rectangle rect = ta.modelToView(line);
ta.scrollRectToVisible(rect);
- }
- catch (Exception e) {
+ } catch (Exception e) {
// couldn't scroll to line, do nothing
}
@@ -164,6 +162,7 @@ class GlyphGutter extends JComponent {
int lineCount = textArea.getLineCount() + 1;
String dummy = Integer.toString(lineCount);
+
if (dummy.length() < 2) {
dummy = DUMMY_STRING;
}
@@ -195,6 +194,7 @@ class GlyphGutter extends JComponent {
int startLine = clip.y / h;
int endLine = (clip.y + clip.height) / h + 1;
int width = getWidth();
+
if (endLine > lineCount) {
endLine = lineCount;
}
@@ -221,12 +221,15 @@ class GlyphGutter extends JComponent {
int dy = y;
arrow.addPoint(dx, dy + 3);
arrow.addPoint(dx + 5, dy + 3);
+
for (x = dx + 5; x <= dx + 10; x++, y++) {
arrow.addPoint(x, y);
}
+
for (x = dx + 9; x >= dx + 5; x--, y++) {
arrow.addPoint(x, y);
}
+
arrow.addPoint(dx + 5, dy + 7);
arrow.addPoint(dx, dy + 7);
diff --git a/scripting/java/com/sun/star/script/framework/provider/beanshell/ScriptEditorForBeanShell.java b/scripting/java/com/sun/star/script/framework/provider/beanshell/ScriptEditorForBeanShell.java
index c0cfd1f6a3f0..5991d2285e42 100644
--- a/scripting/java/com/sun/star/script/framework/provider/beanshell/ScriptEditorForBeanShell.java
+++ b/scripting/java/com/sun/star/script/framework/provider/beanshell/ScriptEditorForBeanShell.java
@@ -43,8 +43,7 @@ import com.sun.star.script.framework.container.ScriptMetaData;
import com.sun.star.script.framework.provider.ClassLoaderFactory;
public class ScriptEditorForBeanShell
- implements ScriptEditor, ActionListener
-{
+ implements ScriptEditor, ActionListener {
private JFrame frame;
private String filename;
@@ -59,7 +58,8 @@ public class ScriptEditorForBeanShell
private static ScriptEditorForBeanShell theScriptEditorForBeanShell;
// global list of ScriptEditors, key is URL of file being edited
- private static Map<URL,ScriptEditorForBeanShell> BEING_EDITED = new HashMap<URL,ScriptEditorForBeanShell>();
+ private static Map<URL, ScriptEditorForBeanShell> BEING_EDITED = new
+ HashMap<URL, ScriptEditorForBeanShell>();
// template for new BeanShell scripts
private static String BSHTEMPLATE;
@@ -74,6 +74,7 @@ public class ScriptEditorForBeanShell
StringBuilder buf = new StringBuilder();
byte[] b = new byte[1024];
int len;
+
while ((len = in.read(b)) != -1) {
buf.append(new String(b, 0, len));
}
@@ -81,11 +82,9 @@ public class ScriptEditorForBeanShell
in.close();
BSHTEMPLATE = buf.toString();
- }
- catch (IOException ioe) {
+ } catch (IOException ioe) {
BSHTEMPLATE = "// BeanShell script";
- }
- catch (Exception e) {
+ } catch (Exception e) {
BSHTEMPLATE = "// BeanShell script";
}
}
@@ -93,13 +92,13 @@ public class ScriptEditorForBeanShell
/**
* Returns the global ScriptEditorForBeanShell instance.
*/
- public static synchronized ScriptEditorForBeanShell getEditor()
- {
- if (theScriptEditorForBeanShell == null)
- {
+
+ public static synchronized ScriptEditorForBeanShell getEditor() {
+ if (theScriptEditorForBeanShell == null) {
theScriptEditorForBeanShell =
new ScriptEditorForBeanShell();
}
+
return theScriptEditorForBeanShell;
}
@@ -111,8 +110,7 @@ public class ScriptEditorForBeanShell
* @return The ScriptEditorForBeanShell associated with
* the given URL if one exists, otherwise null.
*/
- public static ScriptEditorForBeanShell getEditor(URL url)
- {
+ public static ScriptEditorForBeanShell getEditor(URL url) {
synchronized (BEING_EDITED) {
return BEING_EDITED.get(url);
}
@@ -122,8 +120,7 @@ public class ScriptEditorForBeanShell
* Returns whether or not the script source being edited in this
* ScriptEditorForBeanShell has been modified
*/
- public boolean isModified()
- {
+ public boolean isModified() {
return view.isModified();
}
@@ -132,8 +129,7 @@ public class ScriptEditorForBeanShell
*
* @return The text displayed in this ScriptEditorForBeanShell
*/
- public String getText()
- {
+ public String getText() {
return view.getText();
}
@@ -160,9 +156,8 @@ public class ScriptEditorForBeanShell
* Indicates the line where error occurred
*
*/
- public void indicateErrorLine( int lineNum )
- {
- model.indicateErrorLine( lineNum );
+ public void indicateErrorLine(int lineNum) {
+ model.indicateErrorLine(lineNum);
}
/**
* Executes the script edited by the editor
@@ -170,7 +165,7 @@ public class ScriptEditorForBeanShell
*/
public Object execute() throws Exception {
frame.toFront();
- return model.execute( context, cl );
+ return model.execute(context, cl);
}
/**
* Opens an editor window for the specified ScriptMetaData.
@@ -181,41 +176,44 @@ public class ScriptEditorForBeanShell
* @param entry The metadata describing the script
*/
public void edit(final XScriptContext context, ScriptMetaData entry) {
- if (entry != null ) {
+ if (entry != null) {
try {
ClassLoader cl = null;
+
try {
- cl = ClassLoaderFactory.getURLClassLoader( entry );
- }
- catch (Exception ignore) // TODO re-examine error handling
- {
+ cl = ClassLoaderFactory.getURLClassLoader(entry);
+ } catch (Exception ignore) { // TODO re-examine error handling
}
+
final ClassLoader theCl = cl;
String sUrl = entry.getParcelLocation();
- if ( !sUrl.endsWith( "/" ) )
- {
+
+ if (!sUrl.endsWith("/")) {
sUrl += "/";
}
+
sUrl += entry.getLanguageName();
final URL url = entry.getSourceURL();
SwingInvocation.invoke(
- new Runnable() {
- public void run() {
- ScriptEditorForBeanShell editor;
- synchronized (BEING_EDITED) {
- editor = BEING_EDITED.get(url);
- if (editor == null) {
- editor = new ScriptEditorForBeanShell(
- context, theCl, url);
- BEING_EDITED.put(url, editor);
- }
+ new Runnable() {
+ public void run() {
+ ScriptEditorForBeanShell editor;
+
+ synchronized (BEING_EDITED) {
+ editor = BEING_EDITED.get(url);
+
+ if (editor == null) {
+ editor = new ScriptEditorForBeanShell(
+ context, theCl, url);
+ BEING_EDITED.put(url, editor);
}
- editor.frame.toFront();
}
- });
- }
- catch (IOException ioe) {
- showErrorMessage( "Error loading file: " + ioe.getMessage() );
+
+ editor.frame.toFront();
+ }
+ });
+ } catch (IOException ioe) {
+ showErrorMessage("Error loading file: " + ioe.getMessage());
}
}
}
@@ -224,16 +222,16 @@ public class ScriptEditorForBeanShell
}
private ScriptEditorForBeanShell(XScriptContext context, ClassLoader cl,
- URL url)
- {
+ URL url) {
this.context = context;
this.scriptURL = url;
this.model = new ScriptSourceModel(url);
this.filename = url.getFile();
this.cl = cl;
+
try {
Class<?> c = Class.forName(
- "org.openoffice.netbeans.editor.NetBeansSourceView");
+ "org.openoffice.netbeans.editor.NetBeansSourceView");
Class<?>[] types = new Class[] { ScriptSourceModel.class };
@@ -242,15 +240,12 @@ public class ScriptEditorForBeanShell
if (ctor != null) {
Object[] args = new Object[] { this.model };
this.view = (ScriptSourceView) ctor.newInstance(args);
- }
- else {
+ } else {
this.view = new PlainSourceView(model);
}
- }
- catch (java.lang.Error err) {
+ } catch (java.lang.Error err) {
this.view = new PlainSourceView(model);
- }
- catch (Exception e) {
+ } catch (Exception e) {
this.view = new PlainSourceView(model);
}
@@ -261,7 +256,7 @@ public class ScriptEditorForBeanShell
private void showErrorMessage(String message) {
JOptionPane.showMessageDialog(frame, message,
- "Error", JOptionPane.ERROR_MESSAGE);
+ "Error", JOptionPane.ERROR_MESSAGE);
}
private void initUI() {
@@ -269,13 +264,12 @@ public class ScriptEditorForBeanShell
frame.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
frame.addWindowListener(
- new WindowAdapter()
- {
- @Override
- public void windowClosing(WindowEvent e) {
- doClose();
- }
+ new WindowAdapter() {
+ @Override
+ public void windowClosing(WindowEvent e) {
+ doClose();
}
+ }
);
String[] labels = {"Run", "Clear", "Save", "Close"};
@@ -286,6 +280,7 @@ public class ScriptEditorForBeanShell
JButton b = new JButton(label);
b.addActionListener(this);
p.add(b);
+
if (label.equals("Save") && filename == null) {
b.setEnabled(false);
}
@@ -301,23 +296,21 @@ public class ScriptEditorForBeanShell
private void doClose() {
if (view.isModified()) {
int result = JOptionPane.showConfirmDialog(frame,
- "The script has been modified. " +
- "Do you want to save the changes?");
+ "The script has been modified. " +
+ "Do you want to save the changes?");
- if (result == JOptionPane.CANCEL_OPTION)
- {
+ if (result == JOptionPane.CANCEL_OPTION) {
// don't close the window, just return
return;
- }
- else if (result == JOptionPane.YES_OPTION)
- {
+ } else if (result == JOptionPane.YES_OPTION) {
boolean saveSuccess = saveTextArea();
- if (!saveSuccess)
- {
+
+ if (!saveSuccess) {
return;
}
}
}
+
frame.dispose();
shutdown();
}
@@ -330,43 +323,40 @@ public class ScriptEditorForBeanShell
}
OutputStream fos = null;
+
try {
String s = view.getText();
fos = scriptURL.openConnection().getOutputStream();
- if ( fos != null) {
+
+ if (fos != null) {
fos.write(s.getBytes());
- }
- else
- {
+ } else {
showErrorMessage(
- "Error saving script: Could not open stream for file" );
+ "Error saving script: Could not open stream for file");
result = false;
}
+
view.setModified(false);
- }
- catch (IOException ioe) {
- showErrorMessage( "Error saving script: " + ioe.getMessage() );
- result = false;
- }
- catch (Exception e) {
- showErrorMessage( "Error saving script: " + e.getMessage() );
- result = false;
- }
- finally {
+ } catch (IOException ioe) {
+ showErrorMessage("Error saving script: " + ioe.getMessage());
+ result = false;
+ } catch (Exception e) {
+ showErrorMessage("Error saving script: " + e.getMessage());
+ result = false;
+ } finally {
if (fos != null) {
try {
fos.flush();
fos.close();
- }
- catch (IOException ignore) {
+ } catch (IOException ignore) {
}
}
}
+
return result;
}
- private void shutdown()
- {
+ private void shutdown() {
synchronized (BEING_EDITED) {
BEING_EDITED.remove(scriptURL);
}
@@ -374,21 +364,16 @@ public class ScriptEditorForBeanShell
public void actionPerformed(ActionEvent e) {
if (e.getActionCommand().equals("Run")) {
- try
- {
+ try {
execute();
- }
- catch (Exception invokeException ) {
+ } catch (Exception invokeException) {
showErrorMessage(invokeException.getMessage());
}
- }
- else if (e.getActionCommand().equals("Close")) {
+ } else if (e.getActionCommand().equals("Close")) {
doClose();
- }
- else if (e.getActionCommand().equals("Save")) {
+ } else if (e.getActionCommand().equals("Save")) {
saveTextArea();
- }
- else if (e.getActionCommand().equals("Clear")) {
+ } else if (e.getActionCommand().equals("Clear")) {
view.clear();
}
}
diff --git a/scripting/java/com/sun/star/script/framework/provider/beanshell/ScriptProviderForBeanShell.java b/scripting/java/com/sun/star/script/framework/provider/beanshell/ScriptProviderForBeanShell.java
index da534d602d57..1f56cbe325d4 100644
--- a/scripting/java/com/sun/star/script/framework/provider/beanshell/ScriptProviderForBeanShell.java
+++ b/scripting/java/com/sun/star/script/framework/provider/beanshell/ScriptProviderForBeanShell.java
@@ -47,42 +47,36 @@ import com.sun.star.script.framework.provider.*;
import com.sun.star.script.framework.log.*;
import com.sun.star.script.framework.container.ScriptMetaData;
-public class ScriptProviderForBeanShell
-{
- public static class ScriptProviderForBeanShell_2 extends ScriptProvider
- {
- public ScriptProviderForBeanShell_2(XComponentContext ctx)
- {
- super (ctx, "BeanShell");
+public class ScriptProviderForBeanShell {
+ public static class ScriptProviderForBeanShell_2 extends ScriptProvider {
+ public ScriptProviderForBeanShell_2(XComponentContext ctx) {
+ super(ctx, "BeanShell");
}
@Override
- public XScript getScript( /*IN*/String scriptURI )
- throws com.sun.star.uno.RuntimeException,
- ScriptFrameworkErrorException
- {
- ScriptMetaData scriptData = getScriptData( scriptURI );
- try
- {
- ScriptImpl script = new ScriptImpl( m_xContext, scriptData, m_xModel, m_xInvocContext );
+ public XScript getScript(/*IN*/String scriptURI)
+ throws com.sun.star.uno.RuntimeException,
+ ScriptFrameworkErrorException {
+ ScriptMetaData scriptData = getScriptData(scriptURI);
+
+ try {
+ ScriptImpl script = new ScriptImpl(m_xContext, scriptData, m_xModel,
+ m_xInvocContext);
return script;
- }
- catch ( com.sun.star.uno.RuntimeException re )
- {
- throw new ScriptFrameworkErrorException( "Failed to create script object: " + re.getMessage(),
- null, scriptData.getLanguageName(), language, ScriptFrameworkErrorType.UNKNOWN );
+ } catch (com.sun.star.uno.RuntimeException re) {
+ throw new ScriptFrameworkErrorException("Failed to create script object: " +
+ re.getMessage(),
+ null, scriptData.getLanguageName(), language, ScriptFrameworkErrorType.UNKNOWN);
}
}
@Override
- public boolean hasScriptEditor()
- {
+ public boolean hasScriptEditor() {
return true;
}
@Override
- public ScriptEditor getScriptEditor()
- {
+ public ScriptEditor getScriptEditor() {
return ScriptEditorForBeanShell.getEditor();
}
}
@@ -99,263 +93,249 @@ public class ScriptProviderForBeanShell
* the component
* @see com.sun.star.comp.loader.JavaLoader
*/
- public static XSingleServiceFactory __getServiceFactory( String implName,
+ public static XSingleServiceFactory __getServiceFactory(String implName,
XMultiServiceFactory multiFactory,
- XRegistryKey regKey )
- {
+ XRegistryKey regKey) {
XSingleServiceFactory xSingleServiceFactory = null;
- if ( implName.equals( ScriptProviderForBeanShell.ScriptProviderForBeanShell_2.class.getName() ) )
- {
+ if (implName.equals(
+ ScriptProviderForBeanShell.ScriptProviderForBeanShell_2.class.getName())) {
xSingleServiceFactory = FactoryHelper.getServiceFactory(
- ScriptProviderForBeanShell.ScriptProviderForBeanShell_2.class,
- "com.sun.star.script.provider.ScriptProviderForBeanShell",
- multiFactory,
- regKey );
+ ScriptProviderForBeanShell.ScriptProviderForBeanShell_2.class,
+ "com.sun.star.script.provider.ScriptProviderForBeanShell",
+ multiFactory,
+ regKey);
}
return xSingleServiceFactory;
}
}
-class ScriptImpl implements XScript
-{
+class ScriptImpl implements XScript {
private ScriptMetaData metaData;
private XComponentContext m_xContext;
private XMultiComponentFactory m_xMultiComponentFactory;
private XModel m_xModel;
private XScriptInvocationContext m_xInvocContext;
- ScriptImpl( XComponentContext ctx, ScriptMetaData metaData, XModel xModel,
- XScriptInvocationContext xContext ) throws com.sun.star.uno.RuntimeException
- {
+ ScriptImpl(XComponentContext ctx, ScriptMetaData metaData, XModel xModel,
+ XScriptInvocationContext xContext) throws com.sun.star.uno.RuntimeException {
this.metaData = metaData;
this.m_xContext = ctx;
this.m_xModel = xModel;
this.m_xInvocContext = xContext;
- try
- {
+ try {
this.m_xMultiComponentFactory = m_xContext.getServiceManager();
- }
- catch ( Exception e )
- {
- LogUtils.DEBUG( LogUtils.getTrace( e ) );
+ } catch (Exception e) {
+ LogUtils.DEBUG(LogUtils.getTrace(e));
throw new com.sun.star.uno.RuntimeException(
"Error constructing ScriptImpl [beanshell]: "
- + e.getMessage() );
+ + e.getMessage());
}
- LogUtils.DEBUG("ScriptImpl [beanshell] script data = " + metaData );
+ LogUtils.DEBUG("ScriptImpl [beanshell] script data = " + metaData);
}
- /**
- * documentStorageID and document reference
- * for use in script name resolving
- *
- * @param aParams All parameters; pure, out params are
- * undefined in sequence, i.e., the value
- * has to be ignored by the callee
- *
- * @param aOutParamIndex Out indices
- *
- * @param aOutParam Out parameters
- *
- * @return The value returned from the function
- * being invoked
- *
- * @throws IllegalArgumentException If there is no matching script name
- *
- * @throws InvocationTargetException If the running script throws
- * an exception this information
- * is captured and rethrown as
- * this exception type.
- */
-
- public Object invoke( /*IN*/Object[] aParams,
- /*OUT*/short[][] aOutParamIndex,
- /*OUT*/Object[][] aOutParam )
- throws ScriptFrameworkErrorException,
- InvocationTargetException
- {
- // Initialise the out parameters - not used at the moment
- aOutParamIndex[0] = new short[0];
- aOutParam[0] = new Object[0];
-
-
- ClassLoader cl = null;
- URL sourceUrl = null;
- try {
- cl = ClassLoaderFactory.getURLClassLoader( metaData );
- sourceUrl = metaData.getSourceURL();
- }
- catch ( java.net.MalformedURLException mfu )
- {
- // Framework error
- throw new ScriptFrameworkErrorException(
- mfu.getMessage(), null,
- metaData.getLanguageName(), metaData.getLanguage(),
- ScriptFrameworkErrorType.MALFORMED_URL );
- }
- // Set class loader to be used for class files
- // and jar files
- Thread.currentThread().setContextClassLoader(cl);
- Interpreter interpreter = new Interpreter();
-
- interpreter.getNameSpace().clear();
- // Set class loader to be used by interpreter
- // to look for classes by source e.g. interpreter
- // will use this classloader to search classpath
- // for source file ( bla.java ) on import or reference
- interpreter.setClassLoader(cl);
- try {
- interpreter.set("XSCRIPTCONTEXT",
- ScriptContext.createContext(m_xModel, m_xInvocContext,
- m_xContext, m_xMultiComponentFactory));
-
- interpreter.set("ARGUMENTS", aParams);
- }
- catch (bsh.EvalError e) {
- // Framework error setting up context
- throw new ScriptFrameworkErrorException(
- e.getMessage(), null,
- metaData.getLanguageName(), metaData.getLanguage(),
- ScriptFrameworkErrorType.UNKNOWN );
- }
-
- try {
- Object result;
+ /**
+ * documentStorageID and document reference
+ * for use in script name resolving
+ *
+ * @param aParams All parameters; pure, out params are
+ * undefined in sequence, i.e., the value
+ * has to be ignored by the callee
+ *
+ * @param aOutParamIndex Out indices
+ *
+ * @param aOutParam Out parameters
+ *
+ * @return The value returned from the function
+ * being invoked
+ *
+ * @throws IllegalArgumentException If there is no matching script name
+ *
+ * @throws InvocationTargetException If the running script throws
+ * an exception this information
+ * is captured and rethrown as
+ * this exception type.
+ */
- ScriptEditorForBeanShell editor =
- ScriptEditorForBeanShell.getEditor(
- sourceUrl );
+ public Object invoke(/*IN*/Object[] aParams,
+ /*OUT*/short[][] aOutParamIndex,
+ /*OUT*/Object[][] aOutParam)
+ throws ScriptFrameworkErrorException,
+ InvocationTargetException {
+ // Initialise the out parameters - not used at the moment
+ aOutParamIndex[0] = new short[0];
+ aOutParam[0] = new Object[0];
+
+
+ ClassLoader cl = null;
+ URL sourceUrl = null;
+
+ try {
+ cl = ClassLoaderFactory.getURLClassLoader(metaData);
+ sourceUrl = metaData.getSourceURL();
+ } catch (java.net.MalformedURLException mfu) {
+ // Framework error
+ throw new ScriptFrameworkErrorException(
+ mfu.getMessage(), null,
+ metaData.getLanguageName(), metaData.getLanguage(),
+ ScriptFrameworkErrorType.MALFORMED_URL);
+ }
- if ( editor != null )
- {
- result = editor.execute();
+ // Set class loader to be used for class files
+ // and jar files
+ Thread.currentThread().setContextClassLoader(cl);
+ Interpreter interpreter = new Interpreter();
+
+ interpreter.getNameSpace().clear();
+ // Set class loader to be used by interpreter
+ // to look for classes by source e.g. interpreter
+ // will use this classloader to search classpath
+ // for source file ( bla.java ) on import or reference
+ interpreter.setClassLoader(cl);
+
+ try {
+ interpreter.set("XSCRIPTCONTEXT",
+ ScriptContext.createContext(m_xModel, m_xInvocContext,
+ m_xContext, m_xMultiComponentFactory));
+
+ interpreter.set("ARGUMENTS", aParams);
+ } catch (bsh.EvalError e) {
+ // Framework error setting up context
+ throw new ScriptFrameworkErrorException(
+ e.getMessage(), null,
+ metaData.getLanguageName(), metaData.getLanguage(),
+ ScriptFrameworkErrorType.UNKNOWN);
+ }
- if (result == null)
- {
- return new Any(new Type(), null);
- }
- return result;
- }
+ try {
+ Object result;
- metaData.loadSource();
- String source = metaData.getSource();
+ ScriptEditorForBeanShell editor =
+ ScriptEditorForBeanShell.getEditor(
+ sourceUrl);
- if ( source == null || source.length() == 0 )
- {
- throw new ScriptFrameworkErrorException(
- "Failed to read script", null,
- metaData.getLanguageName(), metaData.getLanguage(),
- ScriptFrameworkErrorType.NO_SUCH_SCRIPT );
- }
- result = interpreter.eval( source );
+ if (editor != null) {
+ result = editor.execute();
- if (result == null)
- {
+ if (result == null) {
return new Any(new Type(), null);
}
+
return result;
}
- catch ( bsh.ParseException pe )
- {
- throw new InvocationTargetException( "Beanshell failed to parse " + metaData.getLanguageName(), null, processBshException( pe, metaData.getLanguageName() ) );
- }
- catch ( bsh.TargetError te )
- {
- throw new InvocationTargetException( "Beanshell uncaught exception for " + metaData.getLanguageName(), null, processBshException( te, metaData.getLanguageName() ) );
- }
- catch ( bsh.EvalError ex )
- {
- throw new InvocationTargetException( "Beanshell error for " + metaData.getLanguageName(), null, processBshException( ex, metaData.getLanguageName() ) );
- }
- catch ( Exception e )
- {
+
+ metaData.loadSource();
+ String source = metaData.getSource();
+
+ if (source == null || source.length() == 0) {
throw new ScriptFrameworkErrorException(
"Failed to read script", null,
metaData.getLanguageName(), metaData.getLanguage(),
- ScriptFrameworkErrorType.UNKNOWN );
+ ScriptFrameworkErrorType.NO_SUCH_SCRIPT);
+ }
+
+ result = interpreter.eval(source);
+
+ if (result == null) {
+ return new Any(new Type(), null);
}
+
+ return result;
+ } catch (bsh.ParseException pe) {
+ throw new InvocationTargetException("Beanshell failed to parse " +
+ metaData.getLanguageName(), null, processBshException(pe,
+ metaData.getLanguageName()));
+ } catch (bsh.TargetError te) {
+ throw new InvocationTargetException("Beanshell uncaught exception for " +
+ metaData.getLanguageName(), null, processBshException(te,
+ metaData.getLanguageName()));
+ } catch (bsh.EvalError ex) {
+ throw new InvocationTargetException("Beanshell error for " +
+ metaData.getLanguageName(), null, processBshException(ex,
+ metaData.getLanguageName()));
+ } catch (Exception e) {
+ throw new ScriptFrameworkErrorException(
+ "Failed to read script", null,
+ metaData.getLanguageName(), metaData.getLanguage(),
+ ScriptFrameworkErrorType.UNKNOWN);
}
- private void raiseEditor( int lineNum )
- {
- try
- {
- URL sourceUrl = metaData.getSourceURL();
- ScriptEditorForBeanShell editor = ScriptEditorForBeanShell.getEditor( sourceUrl );
- if ( editor == null )
- {
- editor = ScriptEditorForBeanShell.getEditor();
- editor.edit(
- ScriptContext.createContext(m_xModel, m_xInvocContext,
- m_xContext, m_xMultiComponentFactory), metaData );
- editor = ScriptEditorForBeanShell.getEditor( sourceUrl );
- }
- if ( editor != null )
- {
- editor.indicateErrorLine( lineNum );
- }
+ }
+ private void raiseEditor(int lineNum) {
+ try {
+ URL sourceUrl = metaData.getSourceURL();
+ ScriptEditorForBeanShell editor = ScriptEditorForBeanShell.getEditor(sourceUrl);
+
+ if (editor == null) {
+ editor = ScriptEditorForBeanShell.getEditor();
+ editor.edit(
+ ScriptContext.createContext(m_xModel, m_xInvocContext,
+ m_xContext, m_xMultiComponentFactory), metaData);
+ editor = ScriptEditorForBeanShell.getEditor(sourceUrl);
}
- catch( Exception ignore )
- {
+
+ if (editor != null) {
+ editor.indicateErrorLine(lineNum);
}
+ } catch (Exception ignore) {
}
+ }
- private ScriptErrorRaisedException processBshException( bsh.EvalError e, String script )
- {
- LogUtils.DEBUG("Beanshell error RAW message " + e.getMessage());
- String message = e.getMessage();
- int usefulInfoIndex = message.lastIndexOf("\' :" );
- int lineNum = e.getErrorLineNumber();
+ private ScriptErrorRaisedException processBshException(bsh.EvalError e,
+ String script) {
+ LogUtils.DEBUG("Beanshell error RAW message " + e.getMessage());
+ String message = e.getMessage();
+ int usefulInfoIndex = message.lastIndexOf("\' :");
+ int lineNum = e.getErrorLineNumber();
+
+ raiseEditor(lineNum);
+
+ if (usefulInfoIndex > -1) {
+ message = message.substring(usefulInfoIndex + 2);
+ }
- raiseEditor( lineNum );
+ if (e instanceof bsh.TargetError) {
+ LogUtils.DEBUG("got instance of TargetError");
- if ( usefulInfoIndex > -1 )
- {
- message = message.substring( usefulInfoIndex + 2 );
+ if (usefulInfoIndex == -1) {
+ message = ((bsh.TargetError)e).getTarget().getMessage();
}
- if ( e instanceof bsh.TargetError )
- {
- LogUtils.DEBUG("got instance of TargetError");
- if ( usefulInfoIndex == -1 )
- {
- message = ( ( bsh.TargetError)e ).getTarget().getMessage();
- }
- String wrappedException = "";
- String full = e.toString();
- int index = full.indexOf( "Target exception:" );
- if ( index > -1 )
- {
- String toParse = full.substring( index );
- LogUtils.DEBUG("About to parse " + toParse );
- StringTokenizer tokenizer = new StringTokenizer( full.substring( index ),":" );
- if ( tokenizer.countTokens() > 2 )
- {
- LogUtils.DEBUG("First token = " + (String)tokenizer.nextElement());
- wrappedException = (String)tokenizer.nextElement();
- LogUtils.DEBUG("wrapped exception = = " + wrappedException );
- }
+
+ String wrappedException = "";
+ String full = e.toString();
+ int index = full.indexOf("Target exception:");
+
+ if (index > -1) {
+ String toParse = full.substring(index);
+ LogUtils.DEBUG("About to parse " + toParse);
+ StringTokenizer tokenizer = new StringTokenizer(full.substring(index), ":");
+
+ if (tokenizer.countTokens() > 2) {
+ LogUtils.DEBUG("First token = " + (String)tokenizer.nextElement());
+ wrappedException = (String)tokenizer.nextElement();
+ LogUtils.DEBUG("wrapped exception = = " + wrappedException);
}
- ScriptExceptionRaisedException se = new ScriptExceptionRaisedException( message);
- se.lineNum = lineNum;
- se.scriptName = script;
- se.exceptionType = wrappedException;
- se.language = "BeanShell";
- LogUtils.DEBUG("UnCaught Exception error: " );
- LogUtils.DEBUG("\tscript: " + script );
- LogUtils.DEBUG("\tline: " + lineNum );
- LogUtils.DEBUG("\twrapped exception: " + wrappedException );
- LogUtils.DEBUG("\tmessage: " + message );
- return se;
- }
- else
- {
- LogUtils.DEBUG("Error or ParseError Exception error: " );
- LogUtils.DEBUG("\tscript: " + script );
- LogUtils.DEBUG("\tline: " + lineNum );
- LogUtils.DEBUG("\tmessage: " + message );
- return new ScriptErrorRaisedException( message, null, script, "BeanShell", lineNum );
}
+
+ ScriptExceptionRaisedException se = new ScriptExceptionRaisedException(message);
+ se.lineNum = lineNum;
+ se.scriptName = script;
+ se.exceptionType = wrappedException;
+ se.language = "BeanShell";
+ LogUtils.DEBUG("UnCaught Exception error: ");
+ LogUtils.DEBUG("\tscript: " + script);
+ LogUtils.DEBUG("\tline: " + lineNum);
+ LogUtils.DEBUG("\twrapped exception: " + wrappedException);
+ LogUtils.DEBUG("\tmessage: " + message);
+ return se;
+ } else {
+ LogUtils.DEBUG("Error or ParseError Exception error: ");
+ LogUtils.DEBUG("\tscript: " + script);
+ LogUtils.DEBUG("\tline: " + lineNum);
+ LogUtils.DEBUG("\tmessage: " + message);
+ return new ScriptErrorRaisedException(message, null, script, "BeanShell",
+ lineNum);
}
+ }
}
diff --git a/scripting/java/com/sun/star/script/framework/provider/beanshell/ScriptSourceModel.java b/scripting/java/com/sun/star/script/framework/provider/beanshell/ScriptSourceModel.java
index ef4719ef1a7d..9954c6b550c9 100644
--- a/scripting/java/com/sun/star/script/framework/provider/beanshell/ScriptSourceModel.java
+++ b/scripting/java/com/sun/star/script/framework/provider/beanshell/ScriptSourceModel.java
@@ -30,7 +30,7 @@ public class ScriptSourceModel {
private URL file = null;
private ScriptSourceView view = null;
- public ScriptSourceModel(URL file ) {
+ public ScriptSourceModel(URL file) {
this.file = file;
}
@@ -40,14 +40,14 @@ public class ScriptSourceModel {
byte[] contents = new byte[1024];
int len;
+
while ((len = in.read(contents, 0, 1024)) != -1) {
buf.append(new String(contents, 0, len));
}
try {
in.close();
- }
- catch (IOException ignore) {
+ } catch (IOException ignore) {
}
return buf.toString();
@@ -58,8 +58,7 @@ public class ScriptSourceModel {
try {
result = load();
- }
- catch (IOException ioe) {
+ } catch (IOException ioe) {
// do nothing, empty string will be returned
}
@@ -74,52 +73,51 @@ public class ScriptSourceModel {
this.view = view;
}
- public Object execute(final XScriptContext context, ClassLoader cl )
- throws Exception
- {
- if ( cl != null )
- {
- // sets this threads class loader
- // hopefully any threads spawned by this
- // will inherit this cl
- // this enables any class files imported
- // from the interpreter to be loaded
- // note: setting the classloader on the
- // interpreter has a slightly different
- // meaning in that the classloader for
- // the interpreter seems only to look for
- // source files ( bla.java ) in the classpath
- Thread.currentThread().setContextClassLoader(cl);
- }
- bsh.Interpreter interpreter = new bsh.Interpreter();
- if ( cl != null )
- {
- // additionally set class loader on the interpreter
- // to allow it to load java classes defined in source
- // files e.g. bla.java
- interpreter.getNameSpace().clear();
- }
-
-
- // reset position
- currentPosition = -1;
- view.update();
-
- interpreter.set("XSCRIPTCONTEXT", context);
- interpreter.set("ARGUMENTS", new Object[0]);
-
- Object result;
- if (view.isModified()) {
- result = interpreter.eval(view.getText());
- }
- else {
- result = interpreter.eval(getText());
- }
+ public Object execute(final XScriptContext context, ClassLoader cl)
+ throws Exception {
+ if (cl != null) {
+ // sets this threads class loader
+ // hopefully any threads spawned by this
+ // will inherit this cl
+ // this enables any class files imported
+ // from the interpreter to be loaded
+ // note: setting the classloader on the
+ // interpreter has a slightly different
+ // meaning in that the classloader for
+ // the interpreter seems only to look for
+ // source files ( bla.java ) in the classpath
+ Thread.currentThread().setContextClassLoader(cl);
+ }
+
+ bsh.Interpreter interpreter = new bsh.Interpreter();
+
+ if (cl != null) {
+ // additionally set class loader on the interpreter
+ // to allow it to load java classes defined in source
+ // files e.g. bla.java
+ interpreter.getNameSpace().clear();
+ }
+
+
+ // reset position
+ currentPosition = -1;
+ view.update();
+
+ interpreter.set("XSCRIPTCONTEXT", context);
+ interpreter.set("ARGUMENTS", new Object[0]);
+
+ Object result;
+
+ if (view.isModified()) {
+ result = interpreter.eval(view.getText());
+ } else {
+ result = interpreter.eval(getText());
+ }
+
return result;
}
- public void indicateErrorLine( int lineNum )
- {
- System.out.println("Beanshell indicateErrorLine " + lineNum );
+ public void indicateErrorLine(int lineNum) {
+ System.out.println("Beanshell indicateErrorLine " + lineNum);
currentPosition = lineNum - 1;
view.update();
}
diff --git a/scripting/java/com/sun/star/script/framework/provider/java/Resolver.java b/scripting/java/com/sun/star/script/framework/provider/java/Resolver.java
index af35e3e4c233..ab5103070210 100644
--- a/scripting/java/com/sun/star/script/framework/provider/java/Resolver.java
+++ b/scripting/java/com/sun/star/script/framework/provider/java/Resolver.java
@@ -32,7 +32,7 @@ public interface Resolver {
* @param c A Class
* @return The ScriptProxy value
*/
- ScriptProxy getProxy( ScriptDescriptor sd, Class<?> c )
+ ScriptProxy getProxy(ScriptDescriptor sd, Class<?> c)
throws NoSuchMethodException;
}
diff --git a/scripting/java/com/sun/star/script/framework/provider/java/ScriptDescriptor.java b/scripting/java/com/sun/star/script/framework/provider/java/ScriptDescriptor.java
index 66d25aa6ccdd..cd2e417695b6 100644
--- a/scripting/java/com/sun/star/script/framework/provider/java/ScriptDescriptor.java
+++ b/scripting/java/com/sun/star/script/framework/provider/java/ScriptDescriptor.java
@@ -26,13 +26,12 @@ import java.util.StringTokenizer;
* The <code>ScriptDescriptor</code> object is used to store the search
* criteria that should be used for finding a particular script
*/
-public class ScriptDescriptor
-{
+public class ScriptDescriptor {
private String m_name;
private String m_methodName;
private String m_className;
private List<String> m_classpath;
- private ArrayList<Class<?>> m_argumentTypes = new ArrayList<Class<?>>( 11 );
+ private ArrayList<Class<?>> m_argumentTypes = new ArrayList<Class<?>>(11);
/**
* Constructs a ScriptDescriptor for the given name
@@ -40,19 +39,17 @@ public class ScriptDescriptor
* @param name Script Name
* @exception IllegalArgumentException if the given name does not contain a "."
*/
- public ScriptDescriptor( String name )
- throws IllegalArgumentException
- {
- int idx = name.lastIndexOf( '.' );
-
- if ( idx == -1 )
- {
- throw new IllegalArgumentException( "Invalid method name" );
+ public ScriptDescriptor(String name)
+ throws IllegalArgumentException {
+ int idx = name.lastIndexOf('.');
+
+ if (idx == -1) {
+ throw new IllegalArgumentException("Invalid method name");
}
this.m_name = name;
- this.m_methodName = name.substring( idx + 1 );
- this.m_className = name.substring( 0, idx );
+ this.m_methodName = name.substring(idx + 1);
+ this.m_className = name.substring(0, idx);
}
/**
@@ -60,8 +57,7 @@ public class ScriptDescriptor
*
* @return The Script Name value
*/
- public String getName()
- {
+ public String getName() {
return m_name;
}
@@ -70,8 +66,7 @@ public class ScriptDescriptor
*
* @return The Script Name value
*/
- public String getClassName()
- {
+ public String getClassName() {
return m_className;
}
@@ -81,8 +76,7 @@ public class ScriptDescriptor
*
* @return The methodName value
*/
- public String getMethodName()
- {
+ public String getMethodName() {
return m_methodName;
}
@@ -92,12 +86,11 @@ public class ScriptDescriptor
*
* @param classpath The new classpath value
*/
- public void setClasspath( String classpath )
- {
- StringTokenizer stk = new StringTokenizer( classpath, ":" );
- while( stk.hasMoreElements() )
- {
- this.m_classpath.add( (String) stk.nextElement() );
+ public void setClasspath(String classpath) {
+ StringTokenizer stk = new StringTokenizer(classpath, ":");
+
+ while (stk.hasMoreElements()) {
+ this.m_classpath.add((String) stk.nextElement());
}
}
@@ -106,8 +99,7 @@ public class ScriptDescriptor
*
* @param classpath The new classpath value
*/
- public void setClasspath( List<String> classpath )
- {
+ public void setClasspath(List<String> classpath) {
this.m_classpath = classpath;
}
@@ -117,8 +109,7 @@ public class ScriptDescriptor
*
* @return The classpath value
*/
- public List<String> getClasspath()
- {
+ public List<String> getClasspath() {
return m_classpath;
}
@@ -129,9 +120,9 @@ public class ScriptDescriptor
*
* @param clazz The feature to be added to the ArgumentType attribute
*/
- public synchronized void addArgumentType( Class<?> clazz )
- {
- m_argumentTypes.add( clazz );
+
+ public synchronized void addArgumentType(Class<?> clazz) {
+ m_argumentTypes.add(clazz);
}
@@ -146,11 +137,11 @@ public class ScriptDescriptor
*
* @return The argumentTypes value
*/
+
public synchronized Class<?>[]
- getArgumentTypes()
- {
- if ( m_argumentTypes.size() > 0 )
- return m_argumentTypes.toArray( new Class[ m_argumentTypes.size() ] );
+ getArgumentTypes() {
+ if (m_argumentTypes.size() > 0)
+ return m_argumentTypes.toArray(new Class[ m_argumentTypes.size() ]);
else
return null;
}
@@ -163,24 +154,22 @@ public class ScriptDescriptor
* @return The scriptName including the parameters.
*/
@Override
- public String toString()
- {
- StringBuilder description = new StringBuilder( m_name );
+ public String toString() {
+ StringBuilder description = new StringBuilder(m_name);
Class<?>[] types = getArgumentTypes();
- description.append( " (" );
+ description.append(" (");
- if ( types != null )
- {
- for ( int i = 0; i < types.length - 1; i++ )
- {
- description.append( types[ i ].getName() );
- description.append( ", " );
+ if (types != null) {
+ for (int i = 0; i < types.length - 1; i++) {
+ description.append(types[ i ].getName());
+ description.append(", ");
}
- description.append( types[ types.length - 1 ].getName() );
+ description.append(types[ types.length - 1 ].getName());
}
- description.append( ")" );
+
+ description.append(")");
return description.toString();
}
diff --git a/scripting/java/com/sun/star/script/framework/provider/java/ScriptProviderForJava.java b/scripting/java/com/sun/star/script/framework/provider/java/ScriptProviderForJava.java
index 9bac3b7e0e40..b09c530b570d 100644
--- a/scripting/java/com/sun/star/script/framework/provider/java/ScriptProviderForJava.java
+++ b/scripting/java/com/sun/star/script/framework/provider/java/ScriptProviderForJava.java
@@ -41,50 +41,43 @@ import com.sun.star.script.framework.container.ScriptMetaData;
import com.sun.star.script.framework.provider.*;
import com.sun.star.script.framework.log.LogUtils;
-public class ScriptProviderForJava
-{
- public static class _ScriptProviderForJava extends ScriptProvider
- {
+public class ScriptProviderForJava {
+ public static class _ScriptProviderForJava extends ScriptProvider {
private Resolver m_resolutionPolicy = new StrictResolver();
- public _ScriptProviderForJava( XComponentContext ctx )
- {
- super (ctx, "Java");
+ public _ScriptProviderForJava(XComponentContext ctx) {
+ super(ctx, "Java");
}
@Override
- public XScript getScript( /*IN*/String scriptURI )
- throws com.sun.star.uno.RuntimeException,
- ScriptFrameworkErrorException
- {
- ScriptMetaData scriptData = getScriptData( scriptURI );
- try
- {
- ScriptImpl script = new ScriptImpl( m_xContext, m_resolutionPolicy, scriptData, m_xModel, m_xInvocContext );
+ public XScript getScript(/*IN*/String scriptURI)
+ throws com.sun.star.uno.RuntimeException,
+ ScriptFrameworkErrorException {
+ ScriptMetaData scriptData = getScriptData(scriptURI);
+
+ try {
+ ScriptImpl script = new ScriptImpl(m_xContext, m_resolutionPolicy, scriptData,
+ m_xModel, m_xInvocContext);
return script;
- }
- catch ( com.sun.star.uno.RuntimeException re )
- {
+ } catch (com.sun.star.uno.RuntimeException re) {
ScriptFrameworkErrorException e2 =
new ScriptFrameworkErrorException(
- "Failed to create script object: " + re,
- null, scriptData.getLanguageName(), language,
- ScriptFrameworkErrorType.UNKNOWN );
- e2.initCause( re );
+ "Failed to create script object: " + re,
+ null, scriptData.getLanguageName(), language,
+ ScriptFrameworkErrorType.UNKNOWN);
+ e2.initCause(re);
throw e2;
}
}
@Override
- public boolean hasScriptEditor()
- {
+ public boolean hasScriptEditor() {
return false;
}
@Override
- public ScriptEditor getScriptEditor()
- {
+ public ScriptEditor getScriptEditor() {
return null;
}
}
@@ -101,245 +94,223 @@ public class ScriptProviderForJava
* the component
* @see com.sun.star.comp.loader.JavaLoader
*/
- public static XSingleServiceFactory __getServiceFactory( String implName,
+ public static XSingleServiceFactory __getServiceFactory(String implName,
XMultiServiceFactory multiFactory,
- XRegistryKey regKey )
- {
+ XRegistryKey regKey) {
XSingleServiceFactory xSingleServiceFactory = null;
- if ( implName.equals( ScriptProviderForJava._ScriptProviderForJava.class.getName() ) )
- {
- xSingleServiceFactory = FactoryHelper.getServiceFactory(
- ScriptProviderForJava._ScriptProviderForJava.class,
- "com.sun.star.script.provider.ScriptProviderForJava",
- multiFactory,
- regKey );
+ if (implName.equals(
+ ScriptProviderForJava._ScriptProviderForJava.class.getName())) {
+ xSingleServiceFactory = FactoryHelper.getServiceFactory(
+ ScriptProviderForJava._ScriptProviderForJava.class,
+ "com.sun.star.script.provider.ScriptProviderForJava",
+ multiFactory,
+ regKey);
}
return xSingleServiceFactory;
}
}
-class ScriptImpl implements XScript
-{
+class ScriptImpl implements XScript {
private ScriptMetaData metaData;
private XComponentContext m_xContext;
private XModel m_xModel;
private XScriptInvocationContext m_xInvocContext;
private XMultiComponentFactory m_xMultiComponentFactory;
private Resolver m_resolutionPolicy;
- ScriptImpl( XComponentContext ctx, Resolver resolver, ScriptMetaData metaData, XModel xModel, XScriptInvocationContext xInvocContext ) throws com.sun.star.uno.RuntimeException
- {
+ ScriptImpl(XComponentContext ctx, Resolver resolver, ScriptMetaData metaData,
+ XModel xModel, XScriptInvocationContext xInvocContext) throws
+ com.sun.star.uno.RuntimeException {
this.metaData = metaData;
this.m_xContext = ctx;
this.m_xModel = xModel;
this.m_xInvocContext = xInvocContext;
this.m_resolutionPolicy = resolver;
- try
- {
+
+ try {
this.m_xMultiComponentFactory = m_xContext.getServiceManager();
- }
- catch ( Exception e )
- {
- LogUtils.DEBUG( LogUtils.getTrace( e ) );
+ } catch (Exception e) {
+ LogUtils.DEBUG(LogUtils.getTrace(e));
com.sun.star.uno.RuntimeException e2 =
new com.sun.star.uno.RuntimeException(
- "Error constructing ScriptProvider: " + e );
- e2.initCause( e );
+ "Error constructing ScriptProvider: " + e);
+ e2.initCause(e);
throw e2;
}
- LogUtils.DEBUG("ScriptImpl [java] script data = " + metaData );
+ LogUtils.DEBUG("ScriptImpl [java] script data = " + metaData);
}
- /**
- * Invoke
- *
- *
- * @param params All parameters; pure, out params are undefined in
- * sequence, i.e., the value has to be ignored by the callee
- * @param aOutParamIndex Out indices
- * @param aOutParam Out parameters
- * @return The value returned from the function being invoked
- * @throws IllegalArgumentException If there is no matching script name
- * @throws com.sun.star.reflection.InvocationTargetException If the running script throws an exception
- * this information is captured and rethrown as this exception type.
- */
-
- public Object invoke(
- /*IN*/Object[] params,
- /*OUT*/short[][] aOutParamIndex,
- /*OUT*/Object[][] aOutParam )
-
- throws ScriptFrameworkErrorException, com.sun.star.reflection.InvocationTargetException
- {
- LogUtils.DEBUG( "** ScriptProviderForJava::invoke: Starting..." );
-
- // Initialise the out parameters - not used at the moment
- aOutParamIndex[0] = new short[0];
- aOutParam[0] = new Object[0];
-
- Map<String,String> languageProps = metaData.getLanguageProperties();
-
- ScriptDescriptor scriptDesc =
- new ScriptDescriptor( metaData.getLanguageName() );
-
- ClassLoader scriptLoader = null;
+ /**
+ * Invoke
+ *
+ *
+ * @param params All parameters; pure, out params are undefined in
+ * sequence, i.e., the value has to be ignored by the callee
+ * @param aOutParamIndex Out indices
+ * @param aOutParam Out parameters
+ * @return The value returned from the function being invoked
+ * @throws IllegalArgumentException If there is no matching script name
+ * @throws com.sun.star.reflection.InvocationTargetException If the running script throws an exception
+ * this information is captured and rethrown as this exception type.
+ */
- try {
- LogUtils.DEBUG( "Classloader starting..." );
- scriptLoader = ClassLoaderFactory.getURLClassLoader(
- metaData );
- LogUtils.DEBUG( "Classloader finished..." );
- }
- catch (ArrayStoreException e )
- {
- // Framework error
- ScriptFrameworkErrorException e2 =
- new ScriptFrameworkErrorException(
- e.toString(), null,
- metaData.getLanguageName(), metaData.getLanguage(),
- ScriptFrameworkErrorType.UNKNOWN );
- e2.initCause( e );
- throw e2;
- }
+ public Object invoke(
+ /*IN*/Object[] params,
+ /*OUT*/short[][] aOutParamIndex,
+ /*OUT*/Object[][] aOutParam)
+
+ throws ScriptFrameworkErrorException,
+ com.sun.star.reflection.InvocationTargetException {
+ LogUtils.DEBUG("** ScriptProviderForJava::invoke: Starting...");
+
+ // Initialise the out parameters - not used at the moment
+ aOutParamIndex[0] = new short[0];
+ aOutParam[0] = new Object[0];
+
+ Map<String, String> languageProps = metaData.getLanguageProperties();
+
+ ScriptDescriptor scriptDesc =
+ new ScriptDescriptor(metaData.getLanguageName());
+
+ ClassLoader scriptLoader = null;
+
+ try {
+ LogUtils.DEBUG("Classloader starting...");
+ scriptLoader = ClassLoaderFactory.getURLClassLoader(
+ metaData);
+ LogUtils.DEBUG("Classloader finished...");
+ } catch (ArrayStoreException e) {
+ // Framework error
+ ScriptFrameworkErrorException e2 =
+ new ScriptFrameworkErrorException(
+ e.toString(), null,
+ metaData.getLanguageName(), metaData.getLanguage(),
+ ScriptFrameworkErrorType.UNKNOWN);
+ e2.initCause(e);
+ throw e2;
+ }
- ArrayList<Object> invocationArgList = new ArrayList<Object>();
- Object[] invocationArgs = null;
+ ArrayList<Object> invocationArgList = new ArrayList<Object>();
+ Object[] invocationArgs = null;
- LogUtils.DEBUG( "Parameter Mapping..." );
+ LogUtils.DEBUG("Parameter Mapping...");
- // Setup Context Object
- XScriptContext xSc = ScriptContext.createContext(m_xModel, m_xInvocContext,
- m_xContext, m_xMultiComponentFactory);
- scriptDesc.addArgumentType( XScriptContext.class );
- invocationArgList.add( xSc );
+ // Setup Context Object
+ XScriptContext xSc = ScriptContext.createContext(m_xModel, m_xInvocContext,
+ m_xContext, m_xMultiComponentFactory);
+ scriptDesc.addArgumentType(XScriptContext.class);
+ invocationArgList.add(xSc);
- for ( int i = 0; i < params.length; i++ )
- {
- scriptDesc.addArgumentType( params[ i ].getClass() );
- invocationArgList.add( params[ i ] );
- }
+ for (int i = 0; i < params.length; i++) {
+ scriptDesc.addArgumentType(params[ i ].getClass());
+ invocationArgList.add(params[ i ]);
+ }
- if ( !invocationArgList.isEmpty() )
- {
- invocationArgs = invocationArgList.toArray();
- }
+ if (!invocationArgList.isEmpty()) {
+ invocationArgs = invocationArgList.toArray();
+ }
- LogUtils.DEBUG( "ScriptProxy starting... " );
- ScriptProxy script = null;
- try
- {
- String className = metaData.getLanguageName().substring( 0,
- metaData.getLanguageName().lastIndexOf( '.' ) );
- LogUtils.DEBUG( "About to load Class " + className + " starting... " );
-
- long start = new java.util.Date().getTime();
- Class<?> c = scriptLoader.loadClass( className );
- long end = new java.util.Date().getTime();
-
- LogUtils.DEBUG("loadClass took: " + String.valueOf(end - start) +
- "milliseconds");
-
- try
- {
- LogUtils.DEBUG( "class loaded ... " );
- script = m_resolutionPolicy.getProxy( scriptDesc, c );
- LogUtils.DEBUG( "script resolved ... " );
- }
- catch( NoSuchMethodException e )
- {
- // Framework error
- ScriptFrameworkErrorException e2 =
- new ScriptFrameworkErrorException(
- e.toString(), null,
- metaData.getLanguageName(), metaData.getLanguage(),
- ScriptFrameworkErrorType.NO_SUCH_SCRIPT );
- e2.initCause( e );
- throw e2;
- }
- }
- catch ( ClassNotFoundException e )
- {
- // Framework error
- ScriptFrameworkErrorException e2 =
- new ScriptFrameworkErrorException(
- e.toString(), null,
- metaData.getLanguageName(), metaData.getLanguage(),
- ScriptFrameworkErrorType.NO_SUCH_SCRIPT );
- e2.initCause( e );
- throw e2;
- }
+ LogUtils.DEBUG("ScriptProxy starting... ");
+ ScriptProxy script = null;
- LogUtils.DEBUG( "Starting Invoke on Proxy ..." );
- Object result = null;
+ try {
+ String className = metaData.getLanguageName().substring(0,
+ metaData.getLanguageName().lastIndexOf('.'));
+ LogUtils.DEBUG("About to load Class " + className + " starting... ");
- try
- {
- long start = new java.util.Date().getTime();
- result = script.invoke( invocationArgs );
- long end = new java.util.Date().getTime();
+ long start = new java.util.Date().getTime();
+ Class<?> c = scriptLoader.loadClass(className);
+ long end = new java.util.Date().getTime();
- LogUtils.DEBUG("invoke took: " +
- String.valueOf(end - start) + "milliseconds");
- }
- catch ( java.lang.IllegalArgumentException iae )
- {
- ScriptFrameworkErrorException e2 =
- new ScriptFrameworkErrorException(
- iae.getMessage(), null,
- metaData.getLanguageName(), metaData.getLanguage(),
- ScriptFrameworkErrorType.UNKNOWN );
- e2.initCause( iae );
- throw e2;
- }
- catch ( java.lang.IllegalAccessException ia )
- {
+ LogUtils.DEBUG("loadClass took: " + String.valueOf(end - start) +
+ "milliseconds");
+
+ try {
+ LogUtils.DEBUG("class loaded ... ");
+ script = m_resolutionPolicy.getProxy(scriptDesc, c);
+ LogUtils.DEBUG("script resolved ... ");
+ } catch (NoSuchMethodException e) {
+ // Framework error
ScriptFrameworkErrorException e2 =
new ScriptFrameworkErrorException(
- ia.toString(), null,
- metaData.getLanguageName(), metaData.getLanguage(),
- ScriptFrameworkErrorType.UNKNOWN );
- e2.initCause( ia );
+ e.toString(), null,
+ metaData.getLanguageName(), metaData.getLanguage(),
+ ScriptFrameworkErrorType.NO_SUCH_SCRIPT);
+ e2.initCause(e);
throw e2;
}
- catch ( java.lang.reflect.InvocationTargetException ite )
- {
- Throwable targetException = ite.getTargetException();
- ScriptExceptionRaisedException se =
- new ScriptExceptionRaisedException(
- targetException.toString() );
- se.lineNum = -1;
- se.scriptName = metaData.getLanguageName();
- se.language = "Java";
- se.exceptionType = targetException.getClass().getName();
- throw new com.sun.star.reflection.InvocationTargetException(
- "Scripting Framework error executing script ", null, se );
- }
- catch ( Exception unknown )
- {
- ScriptExceptionRaisedException se =
- new ScriptExceptionRaisedException(
- unknown.toString() );
- se.lineNum = -1;
- se.scriptName = metaData.getLanguageName();
- se.language = "Java";
- se.exceptionType = unknown.getClass().getName();
- throw new com.sun.star.reflection.InvocationTargetException(
- "Scripting Framework error executing script ", null, se );
- }
- if ( result == null )
- {
- LogUtils.DEBUG( "Got Nothing Back" );
- // in the case where there is no return type
- Any voidAny = new Any(new Type(), null);
- result = voidAny;
- }
- else
- {
- LogUtils.DEBUG( "Got object " + result );
- }
- return result;
+ } catch (ClassNotFoundException e) {
+ // Framework error
+ ScriptFrameworkErrorException e2 =
+ new ScriptFrameworkErrorException(
+ e.toString(), null,
+ metaData.getLanguageName(), metaData.getLanguage(),
+ ScriptFrameworkErrorType.NO_SUCH_SCRIPT);
+ e2.initCause(e);
+ throw e2;
+ }
+
+ LogUtils.DEBUG("Starting Invoke on Proxy ...");
+ Object result = null;
+
+ try {
+ long start = new java.util.Date().getTime();
+ result = script.invoke(invocationArgs);
+ long end = new java.util.Date().getTime();
+
+ LogUtils.DEBUG("invoke took: " +
+ String.valueOf(end - start) + "milliseconds");
+ } catch (java.lang.IllegalArgumentException iae) {
+ ScriptFrameworkErrorException e2 =
+ new ScriptFrameworkErrorException(
+ iae.getMessage(), null,
+ metaData.getLanguageName(), metaData.getLanguage(),
+ ScriptFrameworkErrorType.UNKNOWN);
+ e2.initCause(iae);
+ throw e2;
+ } catch (java.lang.IllegalAccessException ia) {
+ ScriptFrameworkErrorException e2 =
+ new ScriptFrameworkErrorException(
+ ia.toString(), null,
+ metaData.getLanguageName(), metaData.getLanguage(),
+ ScriptFrameworkErrorType.UNKNOWN);
+ e2.initCause(ia);
+ throw e2;
+ } catch (java.lang.reflect.InvocationTargetException ite) {
+ Throwable targetException = ite.getTargetException();
+ ScriptExceptionRaisedException se =
+ new ScriptExceptionRaisedException(
+ targetException.toString());
+ se.lineNum = -1;
+ se.scriptName = metaData.getLanguageName();
+ se.language = "Java";
+ se.exceptionType = targetException.getClass().getName();
+ throw new com.sun.star.reflection.InvocationTargetException(
+ "Scripting Framework error executing script ", null, se);
+ } catch (Exception unknown) {
+ ScriptExceptionRaisedException se =
+ new ScriptExceptionRaisedException(
+ unknown.toString());
+ se.lineNum = -1;
+ se.scriptName = metaData.getLanguageName();
+ se.language = "Java";
+ se.exceptionType = unknown.getClass().getName();
+ throw new com.sun.star.reflection.InvocationTargetException(
+ "Scripting Framework error executing script ", null, se);
+ }
+
+ if (result == null) {
+ LogUtils.DEBUG("Got Nothing Back");
+ // in the case where there is no return type
+ Any voidAny = new Any(new Type(), null);
+ result = voidAny;
+ } else {
+ LogUtils.DEBUG("Got object " + result);
}
+
+ return result;
+ }
}
diff --git a/scripting/java/com/sun/star/script/framework/provider/java/ScriptProxy.java b/scripting/java/com/sun/star/script/framework/provider/java/ScriptProxy.java
index 010f160ade94..a9bd27293f54 100644
--- a/scripting/java/com/sun/star/script/framework/provider/java/ScriptProxy.java
+++ b/scripting/java/com/sun/star/script/framework/provider/java/ScriptProxy.java
@@ -26,8 +26,7 @@ import java.lang.reflect.InvocationTargetException;
*
* @see java.lang.reflect.Method
*/
-public class ScriptProxy
-{
+public class ScriptProxy {
private Object m_targetObject;
private Method m_method;
@@ -38,8 +37,7 @@ public class ScriptProxy
*
* @param method Description of the Parameter
*/
- public ScriptProxy( Method method )
- {
+ public ScriptProxy(Method method) {
this.m_method = method;
}
@@ -50,8 +48,7 @@ public class ScriptProxy
*
* @param obj The new targetObject value
*/
- public void setTargetObject( Object obj )
- {
+ public void setTargetObject(Object obj) {
m_targetObject = obj;
}
@@ -67,11 +64,10 @@ public class ScriptProxy
* @see java.lang.reflect.Method for the exceptions
* that may be thrown
*/
- public Object invoke( Object[] args )
+ public Object invoke(Object[] args)
throws IllegalAccessException, InvocationTargetException,
- IllegalArgumentException
- {
- return m_method.invoke( m_targetObject, args );
+ IllegalArgumentException {
+ return m_method.invoke(m_targetObject, args);
}
}
diff --git a/scripting/java/com/sun/star/script/framework/provider/java/StrictResolver.java b/scripting/java/com/sun/star/script/framework/provider/java/StrictResolver.java
index 6f1898b43387..4ad0f4d52fa7 100644
--- a/scripting/java/com/sun/star/script/framework/provider/java/StrictResolver.java
+++ b/scripting/java/com/sun/star/script/framework/provider/java/StrictResolver.java
@@ -28,14 +28,12 @@ import com.sun.star.script.framework.log.LogUtils;
* method accepting all of the arguments specified in the ScriptDescriptor
* can be found in the Class.
*/
-public class StrictResolver implements Resolver
-{
+public class StrictResolver implements Resolver {
/**
*Constructor for the StrictResolver object
*/
- public StrictResolver()
- {
- LogUtils.DEBUG( this.getClass().getName() + " created" );
+ public StrictResolver() {
+ LogUtils.DEBUG(this.getClass().getName() + " created");
}
/**
@@ -47,49 +45,40 @@ public class StrictResolver implements Resolver
* @param c the Class file in which to search for the method
* @return the ScriptProxy matching the criteria, or null if no match is found
*/
- public ScriptProxy getProxy( ScriptDescriptor sd, Class<?> c )
- throws NoSuchMethodException
- {
+ public ScriptProxy getProxy(ScriptDescriptor sd, Class<?> c)
+ throws NoSuchMethodException {
Method m = null;
- LogUtils.DEBUG( "StrictResolver.getProxy() for: " + sd.toString() );
+ LogUtils.DEBUG("StrictResolver.getProxy() for: " + sd.toString());
- try
- {
- m = resolveArguments( sd, c );
- }
- catch ( ClassNotFoundException e )
- {
- throw new NoSuchMethodException( "StrictResolver.getProxy: Can't find method: "
- + sd.getMethodName() + ":" + e.getMessage() );
- }
- catch ( NoSuchMethodException e )
- {
- throw new NoSuchMethodException( "StrictResolver.getProxy: Can't find method: "
- + sd.getMethodName() + ":" + e.getMessage() );
+ try {
+ m = resolveArguments(sd, c);
+ } catch (ClassNotFoundException e) {
+ throw new NoSuchMethodException("StrictResolver.getProxy: Can't find method: "
+ + sd.getMethodName() + ":" + e.getMessage());
+ } catch (NoSuchMethodException e) {
+ throw new NoSuchMethodException("StrictResolver.getProxy: Can't find method: "
+ + sd.getMethodName() + ":" + e.getMessage());
}
- ScriptProxy sp = new ScriptProxy( m );
+ ScriptProxy sp = new ScriptProxy(m);
int modifiers = m.getModifiers();
- if ( !Modifier.isStatic( modifiers ) )
- {
+
+ if (!Modifier.isStatic(modifiers)) {
Object o;
- try
- {
+
+ try {
o = c.newInstance();
+ } catch (InstantiationException ie) {
+ throw new NoSuchMethodException("getScriptProxy: Can't instantiate: " +
+ c.getName());
+ } catch (IllegalAccessException iae) {
+ throw new NoSuchMethodException("getScriptProxy: Can't access: "
+ + c.getName());
}
- catch ( InstantiationException ie )
- {
- throw new NoSuchMethodException( "getScriptProxy: Can't instantiate: " +
- c.getName() );
- }
- catch ( IllegalAccessException iae )
- {
- throw new NoSuchMethodException( "getScriptProxy: Can't access: "
- + c.getName() );
- }
- sp.setTargetObject( o );
+
+ sp.setTargetObject(o);
}
return sp;
@@ -105,10 +94,9 @@ public class StrictResolver implements Resolver
* @exception ClassNotFoundException
* @exception NoSuchMethodException
*/
- private Method resolveArguments( ScriptDescriptor sd, Class<?> c )
- throws ClassNotFoundException, NoSuchMethodException
- {
- return c.getMethod( sd.getMethodName(), sd.getArgumentTypes() );
+ private Method resolveArguments(ScriptDescriptor sd, Class<?> c)
+ throws ClassNotFoundException, NoSuchMethodException {
+ return c.getMethod(sd.getMethodName(), sd.getArgumentTypes());
}
}
diff --git a/scripting/java/com/sun/star/script/framework/provider/javascript/ScriptEditorForJavaScript.java b/scripting/java/com/sun/star/script/framework/provider/javascript/ScriptEditorForJavaScript.java
index cc4c7b3c787f..89ebabd62b82 100644
--- a/scripting/java/com/sun/star/script/framework/provider/javascript/ScriptEditorForJavaScript.java
+++ b/scripting/java/com/sun/star/script/framework/provider/javascript/ScriptEditorForJavaScript.java
@@ -40,8 +40,7 @@ import java.util.HashMap;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
-public class ScriptEditorForJavaScript implements ScriptEditor
-{
+public class ScriptEditorForJavaScript implements ScriptEditor {
// global ScriptEditorForJavaScript instance
private static ScriptEditorForJavaScript theScriptEditorForJavaScript;
@@ -51,7 +50,8 @@ public class ScriptEditorForJavaScript implements ScriptEditor
private Main rhinoWindow;
private URL scriptURL;
// global list of ScriptEditors, key is URL of file being edited
- private static Map<URL,ScriptEditorForJavaScript> BEING_EDITED = new HashMap<URL,ScriptEditorForJavaScript>();
+ private static Map<URL, ScriptEditorForJavaScript> BEING_EDITED = new
+ HashMap<URL, ScriptEditorForJavaScript>();
static {
try {
@@ -62,6 +62,7 @@ public class ScriptEditorForJavaScript implements ScriptEditor
StringBuilder buf = new StringBuilder();
byte[] b = new byte[1024];
int len;
+
while ((len = in.read(b)) != -1) {
buf.append(new String(b, 0, len));
}
@@ -69,11 +70,9 @@ public class ScriptEditorForJavaScript implements ScriptEditor
in.close();
JSTEMPLATE = buf.toString();
- }
- catch (IOException ioe) {
+ } catch (IOException ioe) {
JSTEMPLATE = "// JavaScript script";
- }
- catch (Exception e) {
+ } catch (Exception e) {
JSTEMPLATE = "// JavaScript script";
}
}
@@ -81,13 +80,13 @@ public class ScriptEditorForJavaScript implements ScriptEditor
/**
* Returns the global ScriptEditorForJavaScript instance.
*/
- public static synchronized ScriptEditorForJavaScript getEditor()
- {
- if (theScriptEditorForJavaScript == null)
- {
+
+ public static synchronized ScriptEditorForJavaScript getEditor() {
+ if (theScriptEditorForJavaScript == null) {
theScriptEditorForJavaScript =
new ScriptEditorForJavaScript();
}
+
return theScriptEditorForJavaScript;
}
@@ -99,8 +98,7 @@ public class ScriptEditorForJavaScript implements ScriptEditor
* @return The ScriptEditorForJavaScript associated with
* the given URL if one exists, otherwise null.
*/
- public static ScriptEditorForJavaScript getEditor(URL url)
- {
+ public static ScriptEditorForJavaScript getEditor(URL url) {
synchronized (BEING_EDITED) {
return BEING_EDITED.get(url);
}
@@ -110,9 +108,8 @@ public class ScriptEditorForJavaScript implements ScriptEditor
* Returns whether or not the script source being edited in this
* ScriptEditorForJavaScript has been modified
*/
- public boolean isModified()
- {
- return rhinoWindow.isModified( scriptURL );
+ public boolean isModified() {
+ return rhinoWindow.isModified(scriptURL);
}
/**
@@ -120,9 +117,8 @@ public class ScriptEditorForJavaScript implements ScriptEditor
*
* @return The text displayed in this ScriptEditorForJavaScript
*/
- public String getText()
- {
- return rhinoWindow.getText( scriptURL );
+ public String getText() {
+ return rhinoWindow.getText(scriptURL);
}
/**
@@ -130,8 +126,7 @@ public class ScriptEditorForJavaScript implements ScriptEditor
*
* @return The url of this ScriptEditorForJavaScript
*/
- public String getURL()
- {
+ public String getURL() {
return scriptURL.toString();
}
@@ -140,8 +135,7 @@ public class ScriptEditorForJavaScript implements ScriptEditor
*
* @return The template text for JavaScript scripts
*/
- public String getTemplate()
- {
+ public String getTemplate() {
return JSTEMPLATE;
}
@@ -150,8 +144,7 @@ public class ScriptEditorForJavaScript implements ScriptEditor
*
* @return The default extension for JavaScript scripts
*/
- public String getExtension()
- {
+ public String getExtension() {
return "js";
}
@@ -163,36 +156,36 @@ public class ScriptEditorForJavaScript implements ScriptEditor
* @param context The context in which to execute the script
* @param entry The metadata describing the script
*/
- public void edit(final XScriptContext context, ScriptMetaData entry)
- {
+ public void edit(final XScriptContext context, ScriptMetaData entry) {
try {
String sUrl = entry.getParcelLocation();
- if ( !sUrl.endsWith( "/" ) )
- {
+
+ if (!sUrl.endsWith("/")) {
sUrl += "/";
}
+
sUrl += entry.getLanguageName();
final URL url = entry.getSourceURL();
SwingInvocation.invoke(
- new Runnable() {
- public void run() {
- synchronized (BEING_EDITED) {
- ScriptEditorForJavaScript editor =
- BEING_EDITED.get(url);
- if (editor == null) {
- editor = new ScriptEditorForJavaScript(
- context, url);
- BEING_EDITED.put(url, editor);
- }
+ new Runnable() {
+ public void run() {
+ synchronized (BEING_EDITED) {
+ ScriptEditorForJavaScript editor =
+ BEING_EDITED.get(url);
+
+ if (editor == null) {
+ editor = new ScriptEditorForJavaScript(
+ context, url);
+ BEING_EDITED.put(url, editor);
}
- assert rhinoWindow != null;
- rhinoWindow.showScriptWindow(url);
- rhinoWindow.toFront();
}
- });
- }
- catch ( IOException e )
- {
+
+ assert rhinoWindow != null;
+ rhinoWindow.showScriptWindow(url);
+ rhinoWindow.toFront();
+ }
+ });
+ } catch (IOException e) {
LogUtils.DEBUG("Caught exception: " + e);
LogUtils.DEBUG(LogUtils.getTrace(e));
}
@@ -200,15 +193,13 @@ public class ScriptEditorForJavaScript implements ScriptEditor
// Ensures that new instances of this class can only be created using
// the factory methods
- private ScriptEditorForJavaScript()
- {
+ private ScriptEditorForJavaScript() {
}
- private ScriptEditorForJavaScript(XScriptContext context, URL url)
- {
+ private ScriptEditorForJavaScript(XScriptContext context, URL url) {
initUI();
- Scriptable scope = getScope( context );
- this.rhinoWindow.openFile(url, scope, new closeHandler( url ) );
+ Scriptable scope = getScope(context);
+ this.rhinoWindow.openFile(url, scope, new closeHandler(url));
this.scriptURL = url;
@@ -219,30 +210,26 @@ public class ScriptEditorForJavaScript implements ScriptEditor
*
*/
- public Object execute() throws Exception
- {
+ public Object execute() throws Exception {
rhinoWindow.toFront();
- return this.rhinoWindow.runScriptWindow( scriptURL );
+ return this.rhinoWindow.runScriptWindow(scriptURL);
}
/**
* Indicates the line where error occurred
*
*/
- public void indicateErrorLine( int lineNum )
- {
+ public void indicateErrorLine(int lineNum) {
this.rhinoWindow.toFront();
- this.rhinoWindow.highlighLineInScriptWindow( scriptURL, lineNum );
+ this.rhinoWindow.highlighLineInScriptWindow(scriptURL, lineNum);
}
// This code is based on the main method of the Rhino Debugger Main class
// We pass in the XScriptContext in the global scope for script execution
private void initUI() {
try {
- synchronized ( ScriptEditorForJavaScript.class )
- {
- if ( this.rhinoWindow != null )
- {
+ synchronized (ScriptEditorForJavaScript.class) {
+ if (this.rhinoWindow != null) {
return;
}
@@ -263,7 +250,7 @@ public class ScriptEditorForJavaScript implements ScriptEditor
return org.mozilla.javascript.tools.shell.Main.getScope();
}
});
- sdb.addWindowListener( new WindowAdapter() {
+ sdb.addWindowListener(new WindowAdapter() {
@Override
public void windowClosing(WindowEvent e) {
shutdown();
@@ -272,35 +259,34 @@ public class ScriptEditorForJavaScript implements ScriptEditor
this.rhinoWindow = sdb;
}
} catch (Exception exc) {
- LogUtils.DEBUG( LogUtils.getTrace( exc ) );
+ LogUtils.DEBUG(LogUtils.getTrace(exc));
}
}
- private void shutdown()
- {
+ private void shutdown() {
// dereference Rhino Debugger window
this.rhinoWindow = null;
this.scriptURL = null;
+
// remove all scripts from BEING_EDITED
- synchronized( BEING_EDITED )
- {
+ synchronized (BEING_EDITED) {
java.util.Iterator<URL> iter = BEING_EDITED.keySet().iterator();
java.util.ArrayList<URL> keysToRemove = new java.util.ArrayList<URL>();
- while ( iter.hasNext() )
- {
+
+ while (iter.hasNext()) {
URL key = iter.next();
- keysToRemove.add( key );
+ keysToRemove.add(key);
}
- for ( int i=0; i<keysToRemove.size(); i++ )
- {
- BEING_EDITED.remove( keysToRemove.get( i ) );
+
+ for (int i = 0; i < keysToRemove.size(); i++) {
+ BEING_EDITED.remove(keysToRemove.get(i));
}
+
keysToRemove = null;
}
}
- private Scriptable getScope(XScriptContext xsctxt )
- {
+ private Scriptable getScope(XScriptContext xsctxt) {
Context ctxt = Context.enter();
ImporterTopLevel scope = new ImporterTopLevel(ctxt);
@@ -308,25 +294,21 @@ public class ScriptEditorForJavaScript implements ScriptEditor
scope.put("XSCRIPTCONTEXT", scope, jsCtxt);
Scriptable jsArgs = Context.toObject(
- new Object[0], scope);
+ new Object[0], scope);
scope.put("ARGUMENTS", scope, jsArgs);
Context.exit();
return scope;
}
- private class closeHandler implements Runnable
- {
+ private class closeHandler implements Runnable {
private URL url;
- private closeHandler( URL url )
- {
+ private closeHandler(URL url) {
this.url = url;
}
- public void run()
- {
- synchronized( BEING_EDITED )
- {
- BEING_EDITED.remove( this.url );
+ public void run() {
+ synchronized (BEING_EDITED) {
+ BEING_EDITED.remove(this.url);
}
}
}
diff --git a/scripting/java/com/sun/star/script/framework/provider/javascript/ScriptProviderForJavaScript.java b/scripting/java/com/sun/star/script/framework/provider/javascript/ScriptProviderForJavaScript.java
index 1ef1ad7a0c81..e5b7a95cf46e 100644
--- a/scripting/java/com/sun/star/script/framework/provider/javascript/ScriptProviderForJavaScript.java
+++ b/scripting/java/com/sun/star/script/framework/provider/javascript/ScriptProviderForJavaScript.java
@@ -48,43 +48,37 @@ import org.mozilla.javascript.ImporterTopLevel;
import org.mozilla.javascript.Scriptable;
import org.mozilla.javascript.JavaScriptException;
-public class ScriptProviderForJavaScript
-{
- public static class ScriptProviderForJavaScript_2 extends ScriptProvider
- {
- public ScriptProviderForJavaScript_2(XComponentContext ctx)
- {
+public class ScriptProviderForJavaScript {
+ public static class ScriptProviderForJavaScript_2 extends ScriptProvider {
+ public ScriptProviderForJavaScript_2(XComponentContext ctx) {
super(ctx, "JavaScript");
}
@Override
- public XScript getScript( /*IN*/String scriptURI )
- throws com.sun.star.uno.RuntimeException,
- ScriptFrameworkErrorException
- {
+ public XScript getScript(/*IN*/String scriptURI)
+ throws com.sun.star.uno.RuntimeException,
+ ScriptFrameworkErrorException {
ScriptMetaData scriptData = null;
- try
- {
- scriptData = getScriptData( scriptURI );
- ScriptImpl script = new ScriptImpl( m_xContext, scriptData, m_xModel, m_xInvocContext );
+
+ try {
+ scriptData = getScriptData(scriptURI);
+ ScriptImpl script = new ScriptImpl(m_xContext, scriptData, m_xModel,
+ m_xInvocContext);
return script;
- }
- catch ( com.sun.star.uno.RuntimeException re )
- {
- throw new ScriptFrameworkErrorException( "Failed to create script object: " + re.getMessage(),
- null, scriptData.getLanguageName(), language, ScriptFrameworkErrorType.UNKNOWN );
+ } catch (com.sun.star.uno.RuntimeException re) {
+ throw new ScriptFrameworkErrorException("Failed to create script object: " +
+ re.getMessage(),
+ null, scriptData.getLanguageName(), language, ScriptFrameworkErrorType.UNKNOWN);
}
}
@Override
- public boolean hasScriptEditor()
- {
+ public boolean hasScriptEditor() {
return true;
}
@Override
- public ScriptEditor getScriptEditor()
- {
+ public ScriptEditor getScriptEditor() {
return ScriptEditorForJavaScript.getEditor();
}
}
@@ -101,242 +95,231 @@ public class ScriptProviderForJavaScript
* the component
* @see com.sun.star.comp.loader.JavaLoader
*/
- public static XSingleServiceFactory __getServiceFactory( String implName,
+ public static XSingleServiceFactory __getServiceFactory(String implName,
XMultiServiceFactory multiFactory,
- XRegistryKey regKey )
- {
+ XRegistryKey regKey) {
XSingleServiceFactory xSingleServiceFactory = null;
- if ( implName.equals( ScriptProviderForJavaScript.ScriptProviderForJavaScript_2.class.getName() ) )
- {
+ if (implName.equals(
+ ScriptProviderForJavaScript.ScriptProviderForJavaScript_2.class.getName())) {
xSingleServiceFactory = FactoryHelper.getServiceFactory(
- ScriptProviderForJavaScript.ScriptProviderForJavaScript_2.class,
- "com.sun.star.script.provider.ScriptProviderForJavaScript",
- multiFactory,
- regKey );
+ ScriptProviderForJavaScript.ScriptProviderForJavaScript_2.class,
+ "com.sun.star.script.provider.ScriptProviderForJavaScript",
+ multiFactory,
+ regKey);
}
return xSingleServiceFactory;
}
}
-class ScriptImpl implements XScript
-{
+class ScriptImpl implements XScript {
private ScriptMetaData metaData;
private XComponentContext m_xContext;
private XMultiComponentFactory m_xMultiComponentFactory;
private XModel m_xModel;
private XScriptInvocationContext m_xInvocContext;
- ScriptImpl( XComponentContext ctx, ScriptMetaData metaData, XModel xModel, XScriptInvocationContext xInvocContext ) throws com.sun.star.uno.RuntimeException
- {
+ ScriptImpl(XComponentContext ctx, ScriptMetaData metaData, XModel xModel,
+ XScriptInvocationContext xInvocContext) throws
+ com.sun.star.uno.RuntimeException {
this.metaData = metaData;
this.m_xContext = ctx;
this.m_xModel = xModel;
this.m_xInvocContext = xInvocContext;
- try
- {
+
+ try {
this.m_xMultiComponentFactory = m_xContext.getServiceManager();
- }
- catch ( Exception e )
- {
- LogUtils.DEBUG( LogUtils.getTrace( e ) );
+ } catch (Exception e) {
+ LogUtils.DEBUG(LogUtils.getTrace(e));
throw new com.sun.star.uno.RuntimeException(
"Error constructing ScriptImpl: [javascript]");
}
- LogUtils.DEBUG("ScriptImpl [javascript] script data = " + metaData );
+
+ LogUtils.DEBUG("ScriptImpl [javascript] script data = " + metaData);
}
- /**
- * The invoke method of the ScriptProviderForJavaScript runs the
- * JavaScript script specified in the URI
- *
- *
- *
- * @param params All parameters; pure, out params are
- * undefined in sequence, i.e., the value
- * has to be ignored by the callee
- *
- * @param aOutParamIndex Out indices
- *
- * @param aOutParam Out parameters
- *
- * @return The value returned from the function
- * being invoked
- *
- * @throws ScriptFrameworkErrorException If there is no matching script name
- *
- *
- * @throws InvocationTargetException If the running script throws
- * an exception this information
- * is captured and rethrown as
- * ScriptErrorRaisedException or
- * ScriptExceptionRaisedException
- */
-
- public Object invoke(
- /*IN*/Object[] params,
- /*OUT*/short[][] aOutParamIndex,
- /*OUT*/Object[][] aOutParam )
-
- throws ScriptFrameworkErrorException, InvocationTargetException
- {
- // Initialise the out parameters - not used at the moment
- aOutParamIndex[0] = new short[0];
- aOutParam[0] = new Object[0];
-
-
-
- ClassLoader cl = null;
- URL sourceUrl = null;
- try {
- cl = ClassLoaderFactory.getURLClassLoader( metaData );
- sourceUrl = metaData.getSourceURL();
- }
- catch ( java.net.MalformedURLException mfu )
- {
- throw new ScriptFrameworkErrorException(
- mfu.getMessage(), null,
- metaData.getLanguageName(), metaData.getLanguage(),
- ScriptFrameworkErrorType.MALFORMED_URL );
- }
- Context ctxt = null;
-
- try
- {
- String editorURL = sourceUrl.toString();
- Object result = null;
- ScriptEditorForJavaScript editor =
- ScriptEditorForJavaScript.getEditor(
- metaData.getSourceURL() );
-
- if (editor != null)
- {
- editorURL = editor.getURL();
- result = editor.execute();
- if ( result != null &&
- result.getClass().getName().equals( "org.mozilla.javascript.Undefined" ) )
- {
- // Always return a string
- // TODO revisit
- return Context.toString( result );
- }
+ /**
+ * The invoke method of the ScriptProviderForJavaScript runs the
+ * JavaScript script specified in the URI
+ *
+ *
+ *
+ * @param params All parameters; pure, out params are
+ * undefined in sequence, i.e., the value
+ * has to be ignored by the callee
+ *
+ * @param aOutParamIndex Out indices
+ *
+ * @param aOutParam Out parameters
+ *
+ * @return The value returned from the function
+ * being invoked
+ *
+ * @throws ScriptFrameworkErrorException If there is no matching script name
+ *
+ *
+ * @throws InvocationTargetException If the running script throws
+ * an exception this information
+ * is captured and rethrown as
+ * ScriptErrorRaisedException or
+ * ScriptExceptionRaisedException
+ */
- }
+ public Object invoke(
+ /*IN*/Object[] params,
+ /*OUT*/short[][] aOutParamIndex,
+ /*OUT*/Object[][] aOutParam)
- String source;
- if (editor != null && editor.isModified())
- {
- LogUtils.DEBUG("GOT A MODIFIED SOURCE");
- source = editor.getText();
- }
- else
- {
- metaData.loadSource();
- source = metaData.getSource();
+ throws ScriptFrameworkErrorException, InvocationTargetException {
+ // Initialise the out parameters - not used at the moment
+ aOutParamIndex[0] = new short[0];
+ aOutParam[0] = new Object[0];
- }
- if ( source == null || source.length() == 0 ) {
- throw new ScriptFrameworkErrorException(
- "Failed to read source data for script", null,
- metaData.getLanguageName(), metaData.getLanguage(),
- ScriptFrameworkErrorType.UNKNOWN );
- }
- /* Set the context ClassLoader on the current thread to
- be our custom ClassLoader. This is the suggested method
- for setting up a ClassLoader to be used by the Rhino
- interpreter
- */
- if (cl != null) {
- Thread.currentThread().setContextClassLoader(cl);
+ ClassLoader cl = null;
+ URL sourceUrl = null;
+
+ try {
+ cl = ClassLoaderFactory.getURLClassLoader(metaData);
+ sourceUrl = metaData.getSourceURL();
+ } catch (java.net.MalformedURLException mfu) {
+ throw new ScriptFrameworkErrorException(
+ mfu.getMessage(), null,
+ metaData.getLanguageName(), metaData.getLanguage(),
+ ScriptFrameworkErrorType.MALFORMED_URL);
+ }
+
+ Context ctxt = null;
+
+ try {
+ String editorURL = sourceUrl.toString();
+ Object result = null;
+ ScriptEditorForJavaScript editor =
+ ScriptEditorForJavaScript.getEditor(
+ metaData.getSourceURL());
+
+ if (editor != null) {
+ editorURL = editor.getURL();
+ result = editor.execute();
+
+ if (result != null &&
+ result.getClass().getName().equals("org.mozilla.javascript.Undefined")) {
+ // Always return a string
+ // TODO revisit
+ return Context.toString(result);
}
- // Initialize a Rhino Context object
- ctxt = Context.enter();
-
- /* The ImporterTopLevel ensures that importClass and
- importPackage statements work in Javascript scripts
- Make the XScriptContext available as a global variable
- to the script
- */
- ImporterTopLevel scope = new ImporterTopLevel(ctxt);
-
- Scriptable jsCtxt = Context.toObject(
- ScriptContext.createContext(
- m_xModel, m_xInvocContext, m_xContext,
- m_xMultiComponentFactory), scope);
- scope.put("XSCRIPTCONTEXT", scope, jsCtxt);
-
- Scriptable jsArgs = Context.toObject(params, scope);
- scope.put("ARGUMENTS", scope, jsArgs);
-
- result = ctxt.evaluateString(scope,
- source, "<stdin>", 1, null);
- result = Context.toString(result);
- return result;
}
- catch (JavaScriptException jse) {
- LogUtils.DEBUG( "Caught JavaScriptException exception for JavaScript type = " + jse.getClass() );
- String message = jse.getMessage();
- Object wrap = jse.getValue();
- LogUtils.DEBUG( "\t message " + message );
- LogUtils.DEBUG( "\t wrapped type " + wrap.getClass() );
- LogUtils.DEBUG( "\t wrapped toString " + wrap.toString() );
- ScriptExceptionRaisedException se = new
- ScriptExceptionRaisedException( message );
- se.lineNum = -1;
- se.language = "JavaScript";
- se.scriptName = metaData.getLanguageName();
- se.exceptionType = wrap.getClass().getName();
- se.language = metaData.getLanguage();
- LogUtils.DEBUG( "ExceptionRaised exception " );
- LogUtils.DEBUG( "\t message " + se.getMessage() );
- LogUtils.DEBUG( "\t lineNum " + se.lineNum );
- LogUtils.DEBUG( "\t language " + se.language );
- LogUtils.DEBUG( "\t scriptName " + se.scriptName );
- raiseEditor( se.lineNum );
- throw new InvocationTargetException( "JavaScript uncaught exception" + metaData.getLanguageName(), null, se );
+
+ String source;
+
+ if (editor != null && editor.isModified()) {
+ LogUtils.DEBUG("GOT A MODIFIED SOURCE");
+ source = editor.getText();
+ } else {
+ metaData.loadSource();
+ source = metaData.getSource();
+
}
- catch (Exception ex) {
- LogUtils.DEBUG("Caught Exception " + ex );
- LogUtils.DEBUG("rethrowing as ScriptFramework error" );
+
+ if (source == null || source.length() == 0) {
throw new ScriptFrameworkErrorException(
- ex.getMessage(), null,
+ "Failed to read source data for script", null,
metaData.getLanguageName(), metaData.getLanguage(),
- ScriptFrameworkErrorType.UNKNOWN );
+ ScriptFrameworkErrorType.UNKNOWN);
}
- finally {
- if ( ctxt != null )
- {
- Context.exit();
- }
+
+ /* Set the context ClassLoader on the current thread to
+ be our custom ClassLoader. This is the suggested method
+ for setting up a ClassLoader to be used by the Rhino
+ interpreter
+ */
+ if (cl != null) {
+ Thread.currentThread().setContextClassLoader(cl);
+ }
+
+ // Initialize a Rhino Context object
+ ctxt = Context.enter();
+
+ /* The ImporterTopLevel ensures that importClass and
+ importPackage statements work in Javascript scripts
+ Make the XScriptContext available as a global variable
+ to the script
+ */
+ ImporterTopLevel scope = new ImporterTopLevel(ctxt);
+
+ Scriptable jsCtxt = Context.toObject(
+ ScriptContext.createContext(
+ m_xModel, m_xInvocContext, m_xContext,
+ m_xMultiComponentFactory), scope);
+ scope.put("XSCRIPTCONTEXT", scope, jsCtxt);
+
+ Scriptable jsArgs = Context.toObject(params, scope);
+ scope.put("ARGUMENTS", scope, jsArgs);
+
+ result = ctxt.evaluateString(scope,
+ source, "<stdin>", 1, null);
+ result = Context.toString(result);
+ return result;
+ } catch (JavaScriptException jse) {
+ LogUtils.DEBUG("Caught JavaScriptException exception for JavaScript type = " +
+ jse.getClass());
+ String message = jse.getMessage();
+ Object wrap = jse.getValue();
+ LogUtils.DEBUG("\t message " + message);
+ LogUtils.DEBUG("\t wrapped type " + wrap.getClass());
+ LogUtils.DEBUG("\t wrapped toString " + wrap.toString());
+ ScriptExceptionRaisedException se = new
+ ScriptExceptionRaisedException(message);
+ se.lineNum = -1;
+ se.language = "JavaScript";
+ se.scriptName = metaData.getLanguageName();
+ se.exceptionType = wrap.getClass().getName();
+ se.language = metaData.getLanguage();
+ LogUtils.DEBUG("ExceptionRaised exception ");
+ LogUtils.DEBUG("\t message " + se.getMessage());
+ LogUtils.DEBUG("\t lineNum " + se.lineNum);
+ LogUtils.DEBUG("\t language " + se.language);
+ LogUtils.DEBUG("\t scriptName " + se.scriptName);
+ raiseEditor(se.lineNum);
+ throw new InvocationTargetException("JavaScript uncaught exception" +
+ metaData.getLanguageName(), null, se);
+ } catch (Exception ex) {
+ LogUtils.DEBUG("Caught Exception " + ex);
+ LogUtils.DEBUG("rethrowing as ScriptFramework error");
+ throw new ScriptFrameworkErrorException(
+ ex.getMessage(), null,
+ metaData.getLanguageName(), metaData.getLanguage(),
+ ScriptFrameworkErrorType.UNKNOWN);
+ } finally {
+ if (ctxt != null) {
+ Context.exit();
}
}
+ }
- private void raiseEditor( int lineNum )
- {
- try
- {
- URL sourceUrl = metaData.getSourceURL();
- ScriptEditorForJavaScript editor = ScriptEditorForJavaScript.getEditor( sourceUrl );
- if ( editor == null )
- {
- editor = ScriptEditorForJavaScript.getEditor();
- editor.edit(
- ScriptContext.createContext(m_xModel, m_xInvocContext,
- m_xContext, m_xMultiComponentFactory), metaData );
- editor = ScriptEditorForJavaScript.getEditor( sourceUrl );
- }
- if ( editor != null )
- {
- System.out.println("** Have raised IDE for JavaScript, calling indicateErrorLine for line " + lineNum );
- editor.indicateErrorLine( lineNum );
- }
+ private void raiseEditor(int lineNum) {
+ try {
+ URL sourceUrl = metaData.getSourceURL();
+ ScriptEditorForJavaScript editor = ScriptEditorForJavaScript.getEditor(
+ sourceUrl);
+
+ if (editor == null) {
+ editor = ScriptEditorForJavaScript.getEditor();
+ editor.edit(
+ ScriptContext.createContext(m_xModel, m_xInvocContext,
+ m_xContext, m_xMultiComponentFactory), metaData);
+ editor = ScriptEditorForJavaScript.getEditor(sourceUrl);
}
- catch( Exception ignore )
- {
+
+ if (editor != null) {
+ System.out.println("** Have raised IDE for JavaScript, calling indicateErrorLine for line "
+ + lineNum);
+ editor.indicateErrorLine(lineNum);
}
+ } catch (Exception ignore) {
}
+ }
}
diff --git a/scripting/java/org/openoffice/idesupport/CommandLineTools.java b/scripting/java/org/openoffice/idesupport/CommandLineTools.java
index c47e2457c121..8fa9269ca361 100644
--- a/scripting/java/org/openoffice/idesupport/CommandLineTools.java
+++ b/scripting/java/org/openoffice/idesupport/CommandLineTools.java
@@ -43,28 +43,25 @@ public class CommandLineTools {
// Get the URL for the Office DTD directory and pass it to the
// XMLParserFactory so that Office xml files can be parsed
- if (officePath == null)
- {
+ if (officePath == null) {
try {
SVersionRCFile sv = SVersionRCFile.createInstance();
- if (sv.getDefaultVersion() != null)
- {
+
+ if (sv.getDefaultVersion() != null) {
officePath = sv.getDefaultVersion().getPath();
}
- }
- catch (IOException ioe) {
+ } catch (IOException ioe) {
System.err.println("Error getting Office directory");
}
}
- if (officePath == null)
- {
+ if (officePath == null) {
driver.fatalUsage("Error: Office Installation path not set");
}
File officeDir = new File(officePath);
- if (!officeDir.exists() || !officeDir.isDirectory())
- {
+
+ if (!officeDir.exists() || !officeDir.isDirectory()) {
driver.fatalUsage(
"Error: Office Installation path not valid: " + officePath);
}
@@ -78,8 +75,7 @@ public class CommandLineTools {
else {
try {
command.execute();
- }
- catch (Exception e) {
+ } catch (Exception e) {
driver.fatal("Error: " + e.getMessage());
}
}
@@ -91,17 +87,17 @@ public class CommandLineTools {
private void printUsage() {
System.out.println("java " + getClass().getName() + " -h " +
- "prints this message");
+ "prints this message");
System.out.println("java " + getClass().getName() +
- " [-o Path to Office Installation] " +
- "-d <script parcel zip file> " +
- "<destination document or directory>");
+ " [-o Path to Office Installation] " +
+ "-d <script parcel zip file> " +
+ "<destination document or directory>");
System.out.println("java " + getClass().getName() +
- " [-o Path to Office Installation] " +
- "-g [parcel root directory] [options] [script names]");
+ " [-o Path to Office Installation] " +
+ "-g [parcel root directory] [options] [script names]");
System.out.println("options:");
System.out.println("\t[-l language[=supported extension 1[" +
- File.pathSeparator + "supported extension 2]]]");
+ File.pathSeparator + "supported extension 2]]]");
System.out.println("\t[-p name=value]");
System.out.println("\t[-v]");
}
@@ -121,8 +117,7 @@ public class CommandLineTools {
if (args.length < 1) {
return null;
- }
- else if (args[0].equals("-h")) {
+ } else if (args[0].equals("-h")) {
return new Command() {
public void execute() {
printUsage();
@@ -132,24 +127,24 @@ public class CommandLineTools {
int i = 0;
- if(args[0].equals("-o")) {
- officePath = args[i+1];
+ if (args[0].equals("-o")) {
+ officePath = args[i + 1];
i += 2;
}
- if(args[i].equals("-d")) {
+ if (args[i].equals("-d")) {
if ((args.length - i) != 3)
return null;
else
- return new DeployCommand(args[i+1], args[i+2]);
- }
- else if(args[i].equals("-g")) {
+ return new DeployCommand(args[i + 1], args[i + 2]);
+ } else if (args[i].equals("-g")) {
if ((args.length - i) == 1)
return new GenerateCommand(System.getProperty("user.dir"));
GenerateCommand command;
i++;
+
if (!args[i].startsWith("-"))
command = new GenerateCommand(args[i++]);
else
@@ -158,19 +153,18 @@ public class CommandLineTools {
for (; i < args.length; i++) {
if (args[i].equals("-l")) {
command.setLanguage(args[++i]);
- }
- else if (args[i].equals("-p")) {
+ } else if (args[i].equals("-p")) {
command.addProperty(args[++i]);
- }
- else if (args[i].equals("-v")) {
+ } else if (args[i].equals("-v")) {
command.setVerbose();
- }
- else {
+ } else {
command.addScript(args[i]);
}
}
+
return command;
}
+
return null;
}
@@ -207,13 +201,13 @@ public class CommandLineTools {
extensions = new String[tokenizer.countTokens()];
int i = 0;
- while(tokenizer.hasMoreTokens())
+ while (tokenizer.hasMoreTokens())
extensions[i++] = (String)tokenizer.nextToken();
- }
- else {
+ } else {
extensions = new String[1];
extensions[0] = ext;
}
+
this.finder = new ExtensionFinder(this.language, extensions);
}
}
@@ -244,6 +238,7 @@ public class CommandLineTools {
public void addScript(ScriptEntry entry) {
if (scripts == null)
scripts = new ArrayList(3);
+
scripts.add(entry);
}
@@ -251,15 +246,14 @@ public class CommandLineTools {
if (!basedir.isDirectory()) {
throw new Exception(basedir.getName() + " is not a directory");
- }
- else if (!contents.exists()) {
+ } else if (!contents.exists()) {
throw new Exception(basedir.getName() +
- " does not contain a Contents directory");
+ " does not contain a Contents directory");
}
if (language == null && !parcelxml.exists()) {
throw new Exception(parcelxml.getName() + " not found and language " +
- "not specified");
+ "not specified");
}
if (language != null && parcelxml.exists()) {
@@ -271,8 +265,8 @@ public class CommandLineTools {
if (!desclang.equals(language.toLowerCase()))
throw new Exception(parcelxml.getName() + " already exists, " +
- "and has a different language attribute: " +
- desc.getLanguage());
+ "and has a different language attribute: " +
+ desc.getLanguage());
}
if (language != null && scripts == null) {
@@ -282,6 +276,7 @@ public class CommandLineTools {
log("Searching for " + language + " scripts");
ScriptEntry[] entries = finder.findMethods(contents);
+
for (int i = 0; i < entries.length; i++) {
addScript(entries[i]);
log("Found: " + entries[i].getLogicalName());
@@ -293,7 +288,9 @@ public class CommandLineTools {
throw new Exception("No valid scripts found");
ParcelDescriptor desc = new ParcelDescriptor(parcelxml, language);
- desc.setScriptEntries((ScriptEntry[])scripts.toArray(new ScriptEntry[scripts.size()]));
+ desc.setScriptEntries((ScriptEntry[])scripts.toArray(new
+ ScriptEntry[scripts.size()]));
+
if (properties.size() != 0) {
Enumeration enumer = properties.keys();
@@ -305,15 +302,16 @@ public class CommandLineTools {
desc.setLanguageProperty(name, value);
}
}
+
desc.write();
- }
- else {
+ } else {
if (!parcelxml.exists())
throw new Exception("No valid scripts found");
}
contents = new File(contents.getAbsolutePath());
- String name = ParcelZipper.getParcelZipper().zipParcel(contents, AllFilesFilter.getInstance());
+ String name = ParcelZipper.getParcelZipper().zipParcel(contents,
+ AllFilesFilter.getInstance());
System.out.println(name + " generated");
}
@@ -335,7 +333,7 @@ public class CommandLineTools {
public void execute() throws Exception {
ParcelZipper.getParcelZipper().deployParcel(source, target);
System.out.println(source.getName() +
- " successfully deployed to " + target.getAbsolutePath());
+ " successfully deployed to " + target.getAbsolutePath());
}
}
}
diff --git a/scripting/java/org/openoffice/idesupport/ExtensionFinder.java b/scripting/java/org/openoffice/idesupport/ExtensionFinder.java
index 0fa051c5af67..48b80fd77eec 100644
--- a/scripting/java/org/openoffice/idesupport/ExtensionFinder.java
+++ b/scripting/java/org/openoffice/idesupport/ExtensionFinder.java
@@ -44,6 +44,7 @@ public class ExtensionFinder implements MethodFinder {
return empty;
parcelName = basedir.getName();
+
if (parcelName.equals(ParcelZipper.CONTENTS_DIRNAME))
parcelName = basedir.getParentFile().getName();
@@ -51,10 +52,12 @@ public class ExtensionFinder implements MethodFinder {
if (files.size() != 0)
return files.toArray(empty);
+
return empty;
}
- private void findFiles(ArrayList<ScriptEntry> list, File basedir, String parcelName) {
+ private void findFiles(ArrayList<ScriptEntry> list, File basedir,
+ String parcelName) {
File[] children = basedir.listFiles();
File f;
@@ -67,7 +70,7 @@ public class ExtensionFinder implements MethodFinder {
for (int j = 0; j < extensions.length; j++) {
if (f.getName().endsWith(extensions[j])) {
ScriptEntry entry = new ScriptEntry(language,
- f.getName(), parcelName);
+ f.getName(), parcelName);
list.add(entry);
break;
}
diff --git a/scripting/java/org/openoffice/idesupport/JavaFinder.java b/scripting/java/org/openoffice/idesupport/JavaFinder.java
index 98043d2198e8..e9385fd3c57e 100644
--- a/scripting/java/org/openoffice/idesupport/JavaFinder.java
+++ b/scripting/java/org/openoffice/idesupport/JavaFinder.java
@@ -65,10 +65,12 @@ public class JavaFinder implements MethodFinder {
return empty;
parcelName = basedir.getName();
+
if (parcelName.equals(ParcelZipper.CONTENTS_DIRNAME))
parcelName = basedir.getParentFile().getName();
String[] classNames = findClassNames(basedir);
+
if (classNames != null && classNames.length != 0) {
ClassLoader classloader;
@@ -78,40 +80,32 @@ public class JavaFinder implements MethodFinder {
else
classloader = getClassLoader();
- for (int i = 0; i < classNames.length; i++)
- {
- try
- {
+ for (int i = 0; i < classNames.length; i++) {
+ try {
Class clazz = classloader.loadClass(classNames[i]);
Method[] methods = clazz.getDeclaredMethods();
- for (int k = 0; k < methods.length; k++)
- {
- if (Modifier.isPublic(methods[k].getModifiers()))
- {
+
+ for (int k = 0; k < methods.length; k++) {
+ if (Modifier.isPublic(methods[k].getModifiers())) {
Class[] params = methods[k].getParameterTypes();
- if(params.length > 0)
- {
- if(params[0].getName().equals(FIRST_PARAM))
- {
+
+ if (params.length > 0) {
+ if (params[0].getName().equals(FIRST_PARAM)) {
ScriptEntry entry =
new ScriptEntry(classNames[i] + "." +
- methods[k].getName(), parcelName);
+ methods[k].getName(), parcelName);
result.add(entry);
}
}
}
}
- }
- catch (ClassNotFoundException e)
- {
+ } catch (ClassNotFoundException e) {
System.err.println("Caught ClassNotFoundException loading: "
- + classNames[i]);
+ + classNames[i]);
continue;
- }
- catch (NoClassDefFoundError nc)
- {
+ } catch (NoClassDefFoundError nc) {
System.err.println("Caught NoClassDefFoundErr loading: " +
- classNames[i]);
+ classNames[i]);
continue;
}
}
@@ -119,6 +113,7 @@ public class JavaFinder implements MethodFinder {
if (result.size() != 0)
return result.toArray(empty);
+
return empty;
}
@@ -133,8 +128,7 @@ public class JavaFinder implements MethodFinder {
if (s != null)
urls.add(new URL(s));
- }
- catch (MalformedURLException mue) {
+ } catch (MalformedURLException mue) {
}
}
@@ -146,7 +140,8 @@ public class JavaFinder implements MethodFinder {
files.add(basedir);
try {
- Iterator<OfficeInstallation> offices = SVersionRCFile.createInstance().getVersions();
+ Iterator<OfficeInstallation> offices =
+ SVersionRCFile.createInstance().getVersions();
while (offices.hasNext()) {
OfficeInstallation oi = offices.next();
@@ -157,14 +152,14 @@ public class JavaFinder implements MethodFinder {
break;
}
}
- }
- catch (IOException ioe) {
+ } catch (IOException ioe) {
return null;
}
URL[] urls = new URL[files.size()];
String urlpath;
File f;
+
for (int i = 0; i < urls.length; i++) {
try {
f = files.get(i);
@@ -172,8 +167,7 @@ public class JavaFinder implements MethodFinder {
if (urlpath != null)
urls[i] = new URL(urlpath);
- }
- catch (MalformedURLException mue) {
+ } catch (MalformedURLException mue) {
// do nothing, go on to next file
}
}
@@ -191,36 +185,36 @@ public class JavaFinder implements MethodFinder {
else if (children[i].getName().endsWith(suffix))
result.add(children[i]);
}
+
return result;
}
- private String[] findClassNames(File basedir)
- {
+ private String[] findClassNames(File basedir) {
ArrayList<File> classFiles = findFiles(basedir, CLASS_SUFFIX);
- if(classFiles == null || classFiles.size() == 0)
+
+ if (classFiles == null || classFiles.size() == 0)
return null;
ArrayList<File> javaFiles = findFiles(basedir, JAVA_SUFFIX);
- if(javaFiles == null || javaFiles.size() == 0)
+
+ if (javaFiles == null || javaFiles.size() == 0)
return null;
ArrayList<String> result = new ArrayList<String>();
- for (int i = 0; i < classFiles.size(); i++)
- {
+
+ for (int i = 0; i < classFiles.size(); i++) {
File classFile = classFiles.get(i);
String className = classFile.getName();
className = className.substring(0, className.lastIndexOf(CLASS_SUFFIX));
boolean finished = false;
- for (int j = 0; j < javaFiles.size() && !finished; j++)
- {
+ for (int j = 0; j < javaFiles.size() && !finished; j++) {
File javaFile = javaFiles.get(j);
String javaName = javaFile.getName();
javaName = javaName.substring(0, javaName.lastIndexOf(JAVA_SUFFIX));
- if (javaName.equals(className))
- {
+ if (javaName.equals(className)) {
String path = classFile.getAbsolutePath();
path = path.substring(basedir.getAbsolutePath().length() + 1);
path = path.replace(File.separatorChar, '.');
@@ -232,6 +226,7 @@ public class JavaFinder implements MethodFinder {
}
}
}
+
return result.toArray(new String[result.size()]);
}
}
diff --git a/scripting/java/org/openoffice/idesupport/LocalOffice.java b/scripting/java/org/openoffice/idesupport/LocalOffice.java
index ad6e4ad8302b..f6d0814e0199 100644
--- a/scripting/java/org/openoffice/idesupport/LocalOffice.java
+++ b/scripting/java/org/openoffice/idesupport/LocalOffice.java
@@ -28,8 +28,7 @@ import java.net.ConnectException;
* office has to be started with options appropriate for establishing
* local connection.
*/
-public class LocalOffice
-{
+public class LocalOffice {
/**
@@ -40,15 +39,13 @@ public class LocalOffice
* @param port is a communication port.
*/
protected void connect(String officePath, int port)
- throws ConnectException
- {
+ throws ConnectException {
}
/**
* Closes the connection to the running office.
*/
- public void disconnect()
- {
+ public void disconnect() {
}
/**
@@ -56,7 +53,6 @@ public class LocalOffice
*
* @param uri is an identifier of storage has to be refreshed.
*/
- public void refreshStorage(String uri)
- {
+ public void refreshStorage(String uri) {
}
}
diff --git a/scripting/java/org/openoffice/idesupport/OfficeDocument.java b/scripting/java/org/openoffice/idesupport/OfficeDocument.java
index 764501f01695..abad0ebbdd77 100644
--- a/scripting/java/org/openoffice/idesupport/OfficeDocument.java
+++ b/scripting/java/org/openoffice/idesupport/OfficeDocument.java
@@ -29,23 +29,22 @@ import java.util.zip.ZipFile;
import org.openoffice.idesupport.zip.ParcelZipper;
-public class OfficeDocument
-{
+public class OfficeDocument {
public static final String PARCEL_PREFIX_DIR =
ParcelZipper.PARCEL_PREFIX_DIR;
public static final String[] OFFICE_EXTENSIONS =
- {".sxc" , ".sxw", ".sxi", ".sxd"};
+ {".sxc" , ".sxw", ".sxi", ".sxd"};
public static final String OFFICE_PRODUCT_NAME = "OpenOffice.org";
private File file = null;
- public OfficeDocument(File file) throws IllegalArgumentException
- {
+ public OfficeDocument(File file) throws IllegalArgumentException {
if (!file.exists() || file.isDirectory() || !isOfficeFile(file)) {
throw new IllegalArgumentException("This is not a valid " +
- OFFICE_PRODUCT_NAME + " document.");
+ OFFICE_PRODUCT_NAME + " document.");
}
+
this.file = file;
}
@@ -53,6 +52,7 @@ public class OfficeDocument
for (int i = 0; i < OFFICE_EXTENSIONS.length; i++)
if (file.getName().endsWith(OFFICE_EXTENSIONS[i]))
return true;
+
return false;
}
@@ -61,15 +61,13 @@ public class OfficeDocument
ArrayList<String> parcels = new ArrayList<String>();
ZipFile zp = null;
- try
- {
+ try {
zp = new ZipFile(this.file);
- for (Enumeration enumer = zp.entries(); enumer.hasMoreElements(); )
- {
+ for (Enumeration enumer = zp.entries(); enumer.hasMoreElements();) {
ZipEntry ze = (ZipEntry)enumer.nextElement();
- if (ze.getName().endsWith(ParcelZipper.PARCEL_DESCRIPTOR_XML))
- {
+
+ if (ze.getName().endsWith(ParcelZipper.PARCEL_DESCRIPTOR_XML)) {
String tmp = ze.getName();
int end = tmp.lastIndexOf('/');
tmp = tmp.substring(0, end);
@@ -78,19 +76,15 @@ public class OfficeDocument
parcels.add(parcelName);
}
}
- }
- catch(ZipException ze) {
+ } catch (ZipException ze) {
ze.printStackTrace();
- }
- catch(IOException ioe) {
+ } catch (IOException ioe) {
ioe.printStackTrace();
- }
- finally {
+ } finally {
if (zp != null) {
try {
zp.close();
- }
- catch (IOException asdf) {
+ } catch (IOException asdf) {
}
}
}
@@ -102,11 +96,11 @@ public class OfficeDocument
try {
ParcelZipper.getParcelZipper().removeParcel(file, parcelName);
- }
- catch (IOException ioe) {
+ } catch (IOException ioe) {
ioe.printStackTrace();
return false;
}
+
return true;
}
}
diff --git a/scripting/java/org/openoffice/idesupport/OfficeInstallation.java b/scripting/java/org/openoffice/idesupport/OfficeInstallation.java
index 586d3a2d47ef..fdc89c9d12a1 100644
--- a/scripting/java/org/openoffice/idesupport/OfficeInstallation.java
+++ b/scripting/java/org/openoffice/idesupport/OfficeInstallation.java
@@ -46,8 +46,7 @@ public class OfficeInstallation implements java.io.Serializable {
path = path.replace('/', File.separatorChar);
this.path = path;
- }
- else {
+ } else {
this.path = path;
if (System.getProperty("os.name").startsWith("Windows"))
diff --git a/scripting/java/org/openoffice/idesupport/SVersionRCFile.java b/scripting/java/org/openoffice/idesupport/SVersionRCFile.java
index a258983da7dd..4e754e347c75 100644
--- a/scripting/java/org/openoffice/idesupport/SVersionRCFile.java
+++ b/scripting/java/org/openoffice/idesupport/SVersionRCFile.java
@@ -32,14 +32,14 @@ public class SVersionRCFile {
private static final String DEFAULT_NAME =
System.getProperty("os.name").startsWith("Windows") ?
- System.getProperty("user.home") + File.separator +
- "Application Data" + File.separator + "sversion.ini" :
- System.getProperty("user.home") + File.separator +
- ".sversionrc";
+ System.getProperty("user.home") + File.separator +
+ "Application Data" + File.separator + "sversion.ini" :
+ System.getProperty("user.home") + File.separator +
+ ".sversionrc";
public static final String FILE_URL_PREFIX =
System.getProperty("os.name").startsWith("Windows") ?
- "file:///" : "file://";
+ "file:///" : "file://";
@@ -55,7 +55,8 @@ public class SVersionRCFile {
/* Make sure this is in LowerCase !!!!! */
private static final String SCRIPTF = "scriptf";
- private static final HashMap<String, SVersionRCFile> files = new HashMap<String, SVersionRCFile>(3);
+ private static final HashMap<String, SVersionRCFile> files = new
+ HashMap<String, SVersionRCFile>(3);
private File sversionrc = null;
private OfficeInstallation defaultversion = null;
@@ -72,13 +73,13 @@ public class SVersionRCFile {
}
public static SVersionRCFile createInstance() {
- return(createInstance(DEFAULT_NAME));
+ return (createInstance(DEFAULT_NAME));
}
private static SVersionRCFile createInstance(String name) {
SVersionRCFile result = null;
- synchronized(SVersionRCFile.class) {
+ synchronized (SVersionRCFile.class) {
result = files.get(name);
if (result == null) {
@@ -86,6 +87,7 @@ public class SVersionRCFile {
files.put(name, result);
}
}
+
return result;
}
@@ -108,15 +110,14 @@ public class SVersionRCFile {
br = new BufferedReader(new FileReader(sversionrc));
load(br);
lastModified = l;
- }
- catch (FileNotFoundException fnfe) {
+ } catch (FileNotFoundException fnfe) {
throw new IOException(fnfe.getMessage());
- }
- finally {
+ } finally {
if (br != null)
br.close();
}
}
+
return versions.iterator();
}
@@ -124,10 +125,10 @@ public class SVersionRCFile {
String s;
while ((s = br.readLine()) != null &&
- !(s.equals(VERSIONS_LINE))) {}
+ !(s.equals(VERSIONS_LINE))) {}
while ((s = br.readLine()) != null &&
- s.length() != 0) {
+ s.length() != 0) {
StringTokenizer tokens = new StringTokenizer(s, "=");
int count = tokens.countTokens();
@@ -137,6 +138,7 @@ public class SVersionRCFile {
String name = tokens.nextToken();
String path = tokens.nextToken();
OfficeInstallation oi = new OfficeInstallation(name, path);
+
if (oi.supportsFramework()) {
versions.add(oi);
defaultversion = oi;
@@ -152,8 +154,7 @@ public class SVersionRCFile {
try {
path = f.getCanonicalPath();
- }
- catch (IOException ioe) {
+ } catch (IOException ioe) {
return null;
}
@@ -169,33 +170,33 @@ public class SVersionRCFile {
return buf.toString();
}
- public static String getPathForUnoil(String officeInstall)
- {
+ public static String getPathForUnoil(String officeInstall) {
File unopkgdir = new File(officeInstall, UNOPACKAGEDIR);
- if(!unopkgdir.exists())
- {
+
+ if (!unopkgdir.exists()) {
return null;
}
+
File scriptf = null;
String[] listunopkg = unopkgdir.list();
int size = listunopkg.length;
- for(int i=0; i<size; i++)
- {
- if (listunopkg[i].toLowerCase().indexOf(SCRIPTF)>-1)
- {
+
+ for (int i = 0; i < size; i++) {
+ if (listunopkg[i].toLowerCase().indexOf(SCRIPTF) > -1) {
scriptf = new File(unopkgdir, listunopkg[i]);
}
}
- if(scriptf != null)
- {
+
+ if (scriptf != null) {
File unoil = new File(scriptf, UNOILJAR);
- if(unoil.exists())
- {
+
+ if (unoil.exists()) {
String path = unoil.getParent();
path = path.substring(path.indexOf(UNOPACKAGEDIR));
return officeInstall + path;
}
}
+
return null;
}
@@ -208,10 +209,10 @@ public class SVersionRCFile {
ov = new SVersionRCFile(args[0]);
Iterator<OfficeInstallation> enumer;
+
try {
enumer = ov.getVersions();
- }
- catch (IOException ioe) {
+ } catch (IOException ioe) {
System.err.println("Error getting versions: " + ioe.getMessage());
return;
}
@@ -219,7 +220,7 @@ public class SVersionRCFile {
while (enumer.hasNext()) {
OfficeInstallation oi = enumer.next();
System.out.println("Name: " + oi.getName() + ", Path: " + oi.getPath() +
- ", URL: " + oi.getURL());
+ ", URL: " + oi.getURL());
}
}
}
diff --git a/scripting/java/org/openoffice/idesupport/filter/BinaryOnlyFilter.java b/scripting/java/org/openoffice/idesupport/filter/BinaryOnlyFilter.java
index a78ef0e11191..95436158bc6f 100644
--- a/scripting/java/org/openoffice/idesupport/filter/BinaryOnlyFilter.java
+++ b/scripting/java/org/openoffice/idesupport/filter/BinaryOnlyFilter.java
@@ -33,6 +33,7 @@ public class BinaryOnlyFilter implements FileFilter {
for (int i = 0; i < EXTENSIONS.length; i++)
if (name.endsWith(EXTENSIONS[i]))
return true;
+
return false;
}
diff --git a/scripting/java/org/openoffice/idesupport/filter/ExceptParcelFilter.java b/scripting/java/org/openoffice/idesupport/filter/ExceptParcelFilter.java
index 792c9d42a26d..178d449fd8ee 100644
--- a/scripting/java/org/openoffice/idesupport/filter/ExceptParcelFilter.java
+++ b/scripting/java/org/openoffice/idesupport/filter/ExceptParcelFilter.java
@@ -26,8 +26,7 @@ public class ExceptParcelFilter implements FileFilter {
private ExceptParcelFilter() {
}
- public void setParcelToRemove(String parcelName)
- {
+ public void setParcelToRemove(String parcelName) {
ExceptParcelFilter.parcelName = parcelName;
}
@@ -37,6 +36,7 @@ public class ExceptParcelFilter implements FileFilter {
public boolean validate(String name) {
if (name.startsWith(ExceptParcelFilter.parcelName))
return true;
+
return false;
}
diff --git a/scripting/java/org/openoffice/idesupport/localoffice/LocalOfficeImpl.java b/scripting/java/org/openoffice/idesupport/localoffice/LocalOfficeImpl.java
index 35a995819b83..3051b72bbfdd 100644
--- a/scripting/java/org/openoffice/idesupport/localoffice/LocalOfficeImpl.java
+++ b/scripting/java/org/openoffice/idesupport/localoffice/LocalOfficeImpl.java
@@ -40,8 +40,7 @@ import org.openoffice.idesupport.LocalOffice;
* with options appropriate for establishing local connection.
*/
public final class LocalOfficeImpl
- extends LocalOffice
-{
+ extends LocalOffice {
private final static String STORAGE_MRG_SINGLETON =
"/singletons/drafts.com.sun.star.script.framework.storage.theScriptStorageManager";
@@ -57,8 +56,7 @@ public final class LocalOfficeImpl
*/
@Override
protected void connect(String officePath, int port)
- throws ConnectException
- {
+ throws ConnectException {
try {
bootstrap(port);
} catch (java.lang.Exception ex) {
@@ -72,35 +70,36 @@ public final class LocalOfficeImpl
* @param uri is an identifier of storage has to be refreshed.
*/
@Override
- public void refreshStorage(String uri)
- {
+ public void refreshStorage(String uri) {
try {
Object object = null;
object = mComponentContext.getValueByName(STORAGE_MRG_SINGLETON);
XScriptStorageManager storageMgr;
storageMgr = UnoRuntime.queryInterface(
- XScriptStorageManager.class, object);
+ XScriptStorageManager.class, object);
storageMgr.refreshScriptStorage(uri);
} catch (java.lang.Exception ex) {
-System.out.println("*** LocalOfficeImpl.refreshStorage: FAILED " + ex.getMessage());
-System.out.println("*** LocalOfficeImpl.refreshStorage: FAILED " + ex.getClass().getName());
+ System.out.println("*** LocalOfficeImpl.refreshStorage: FAILED " +
+ ex.getMessage());
+ System.out.println("*** LocalOfficeImpl.refreshStorage: FAILED " +
+ ex.getClass().getName());
}
-System.out.println("*** LocalOfficeImpl.refreshStorage: DONE");
+
+ System.out.println("*** LocalOfficeImpl.refreshStorage: DONE");
}
/**
* Closes the connection to the running office.
*/
@Override
- public void disconnect()
- {
-/*
- if(mComponentFactory != null) {
- XComponent comp = (XComponent)UnoRuntime.queryInterface(
- XComponent.class, mComponentFactory);
- comp.dispose();
- }
-*/
+ public void disconnect() {
+ /*
+ if(mComponentFactory != null) {
+ XComponent comp = (XComponent)UnoRuntime.queryInterface(
+ XComponent.class, mComponentFactory);
+ comp.dispose();
+ }
+ */
}
/**
@@ -112,22 +111,21 @@ System.out.println("*** LocalOfficeImpl.refreshStorage: DONE");
* @param port is a communication port.
*/
private void bootstrap(int port)
- throws java.lang.Exception
- {
+ throws java.lang.Exception {
Object object;
mComponentContext = Bootstrap.createInitialComponentContext(null);
XUnoUrlResolver urlresolver = UnoUrlResolver.create(mComponentContext);
object = urlresolver.resolve(
- "uno:socket,host=localhost,port=" +
- port +
- ";urp;StarOffice.ServiceManager");
+ "uno:socket,host=localhost,port=" +
+ port +
+ ";urp;StarOffice.ServiceManager");
mComponentFactory = UnoRuntime.queryInterface(
- XMultiComponentFactory.class, object);
+ XMultiComponentFactory.class, object);
XPropertySet factoryProps;
factoryProps = UnoRuntime.queryInterface(
- XPropertySet.class, mComponentFactory);
+ XPropertySet.class, mComponentFactory);
object = factoryProps.getPropertyValue("DefaultContext");
mComponentContext = UnoRuntime.queryInterface(
- XComponentContext.class, object);
+ XComponentContext.class, object);
}
}
diff --git a/scripting/java/org/openoffice/idesupport/ui/ConfigurePanel.java b/scripting/java/org/openoffice/idesupport/ui/ConfigurePanel.java
index 72d98823864b..4098dca61f0e 100644
--- a/scripting/java/org/openoffice/idesupport/ui/ConfigurePanel.java
+++ b/scripting/java/org/openoffice/idesupport/ui/ConfigurePanel.java
@@ -53,7 +53,7 @@ public class ConfigurePanel extends JPanel {
"Choose What to Export as Scripts";
public ConfigurePanel(String basedir, ArrayList<String> classpath,
- ParcelDescriptor descriptor) {
+ ParcelDescriptor descriptor) {
this.basedir = new File(basedir);
this.classpath = classpath;
@@ -62,17 +62,17 @@ public class ConfigurePanel extends JPanel {
}
public ConfigurePanel(String basedir, ArrayList<String> classpath)
- throws IOException {
+ throws IOException {
this.basedir = new File(basedir);
this.classpath = classpath;
this.descriptor = new ParcelDescriptor(new File(this.basedir,
- ParcelZipper.PARCEL_DESCRIPTOR_XML));
+ ParcelZipper.PARCEL_DESCRIPTOR_XML));
initUI();
}
public void reload(String basedir, ArrayList<String> classpath,
- ParcelDescriptor descriptor) {
+ ParcelDescriptor descriptor) {
if (basedir != null)
this.basedir = new File(basedir);
@@ -85,12 +85,12 @@ public class ConfigurePanel extends JPanel {
}
methodPanel.reload(this.basedir, this.classpath,
- descriptor.getLanguage());
+ descriptor.getLanguage());
scriptPanel.reload(descriptor.getScriptEntries());
}
public void reload(String basedir, ArrayList<String> classpath)
- throws IOException {
+ throws IOException {
if (basedir != null)
this.basedir = new File(basedir);
@@ -99,10 +99,10 @@ public class ConfigurePanel extends JPanel {
this.classpath = classpath;
this.descriptor = new ParcelDescriptor(new File(this.basedir,
- ParcelZipper.PARCEL_DESCRIPTOR_XML));
+ ParcelZipper.PARCEL_DESCRIPTOR_XML));
methodPanel.reload(this.basedir, this.classpath,
- descriptor.getLanguage());
+ descriptor.getLanguage());
scriptPanel.reload(descriptor.getScriptEntries());
}
@@ -163,16 +163,17 @@ public class ConfigurePanel extends JPanel {
private JPanel initMethodButtons() {
JPanel panel = new JPanel();
panel.setLayout(new GridBagLayout());
- ImageIcon icon = new ImageIcon(getClass().getResource("/org/openoffice/idesupport/ui/add.gif"));
+ ImageIcon icon = new ImageIcon(
+ getClass().getResource("/org/openoffice/idesupport/ui/add.gif"));
JButton addButton = new JButton("Add", icon);
addButton.setHorizontalTextPosition(AbstractButton.LEFT);
addButton.addActionListener(
- new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- scriptPanel.addScriptEntries(methodPanel.getSelectedEntries());
- }
+ new ActionListener() {
+ public void actionPerformed(ActionEvent e) {
+ scriptPanel.addScriptEntries(methodPanel.getSelectedEntries());
}
+ }
);
GridBagConstraints gbc = new java.awt.GridBagConstraints();
@@ -199,19 +200,19 @@ public class ConfigurePanel extends JPanel {
JButton removeAllButton = new JButton("Remove All");
removeButton.addActionListener(
- new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- scriptPanel.removeSelectedRows();
- }
+ new ActionListener() {
+ public void actionPerformed(ActionEvent e) {
+ scriptPanel.removeSelectedRows();
}
+ }
);
removeAllButton.addActionListener(
- new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- scriptPanel.removeAllRows();
- }
+ new ActionListener() {
+ public void actionPerformed(ActionEvent e) {
+ scriptPanel.removeAllRows();
}
+ }
);
panel.add(removeButton);
diff --git a/scripting/java/org/openoffice/idesupport/ui/ScriptPanel.java b/scripting/java/org/openoffice/idesupport/ui/ScriptPanel.java
index a6969cdd89ef..c25b5fb04660 100644
--- a/scripting/java/org/openoffice/idesupport/ui/ScriptPanel.java
+++ b/scripting/java/org/openoffice/idesupport/ui/ScriptPanel.java
@@ -56,8 +56,7 @@ public class ScriptPanel extends JPanel {
try {
entry = (ScriptEntry) entries[i].clone();
- }
- catch (CloneNotSupportedException cnse) {
+ } catch (CloneNotSupportedException cnse) {
entry = new ScriptEntry(entries[i].getLanguage(),
entries[i].getLanguageName(),
entries[i].getLocation());
@@ -108,8 +107,10 @@ public class ScriptPanel extends JPanel {
private void tableFocusLost() {
TableCellEditor editor = table.getCellEditor();
+
if (editor != null) {
Object value = editor.getCellEditorValue();
+
if (value != null)
model.setValueAt(value,
table.getEditingRow(), table.getEditingColumn());
@@ -118,16 +119,19 @@ public class ScriptPanel extends JPanel {
private class ScriptTableModel extends AbstractTableModel {
final String[] columnNames = {"Exported Method",
- "Script Name"};
+ "Script Name"
+ };
private ArrayList<ScriptEntry> scripts;
private int nextRow;
public ScriptTableModel(ScriptEntry[] entries) {
scripts = new ArrayList<ScriptEntry>(entries.length + 11);
+
for (int i = 0; i < entries.length; i++) {
scripts.add(entries[i]);
}
+
nextRow = entries.length;
}
diff --git a/scripting/java/org/openoffice/idesupport/xml/Manifest.java b/scripting/java/org/openoffice/idesupport/xml/Manifest.java
index 263de3d97b29..492df63b75ea 100644
--- a/scripting/java/org/openoffice/idesupport/xml/Manifest.java
+++ b/scripting/java/org/openoffice/idesupport/xml/Manifest.java
@@ -53,14 +53,13 @@ public class Manifest {
try {
root = (Element)
- document.getElementsByTagName("manifest:manifest").item(0);
+ document.getElementsByTagName("manifest:manifest").item(0);
el = document.createElement("manifest:file-entry");
el.setAttribute("manifest:media-type", type);
el.setAttribute("manifest:full-path", entry);
root.appendChild(el);
- }
- catch (Exception e) {
+ } catch (Exception e) {
System.err.println("Error adding entry: " + e.getMessage());
}
}
@@ -78,25 +77,28 @@ public class Manifest {
try {
root = (Element)
- document.getElementsByTagName("manifest:manifest").item(0);
+ document.getElementsByTagName("manifest:manifest").item(0);
NodeList nl = root.getElementsByTagName("manifest:file-entry");
+
if (nl == null || (len = nl.getLength()) == 0)
return;
ArrayList<Element> list = new ArrayList<Element>();
+
for (int i = 0; i < len; i++) {
el = (Element)nl.item(i);
+
if (el.getAttribute("manifest:full-path").startsWith(entry)) {
list.add(el);
}
}
Iterator iter = list.iterator();
+
while (iter.hasNext())
root.removeChild((Element)iter.next());
- }
- catch (Exception e) {
+ } catch (Exception e) {
System.err.println("Error removing entry: " + e.getMessage());
}
}
@@ -109,8 +111,7 @@ public class Manifest {
out = new ByteArrayOutputStream();
write(out);
result = new ByteArrayInputStream(out.toByteArray());
- }
- finally {
+ } finally {
if (out != null)
out.close();
}
diff --git a/scripting/java/org/openoffice/idesupport/zip/ParcelZipper.java b/scripting/java/org/openoffice/idesupport/zip/ParcelZipper.java
index 9fd7f5da00fd..3c8d797f220c 100644
--- a/scripting/java/org/openoffice/idesupport/zip/ParcelZipper.java
+++ b/scripting/java/org/openoffice/idesupport/zip/ParcelZipper.java
@@ -24,8 +24,7 @@ import org.openoffice.idesupport.filter.FileFilter;
import org.openoffice.idesupport.filter.BinaryOnlyFilter;
import org.openoffice.idesupport.xml.Manifest;
-public class ParcelZipper
-{
+public class ParcelZipper {
public static final String PARCEL_PREFIX_DIR = "Scripts/";
private static final String PARCEL_EXTENSION = "sxp";
public static final String CONTENTS_DIRNAME = "Contents";
@@ -42,6 +41,7 @@ public class ParcelZipper
public static synchronized ParcelZipper getParcelZipper() {
if (zipper == null)
zipper = new ParcelZipper();
+
return zipper;
}
@@ -52,7 +52,7 @@ public class ParcelZipper
public String removeParcel(File document, String parcelName)
- throws IOException {
+ throws IOException {
ZipInputStream documentStream = null;
ZipOutputStream outStream = null;
@@ -60,6 +60,7 @@ public class ParcelZipper
if (!parcelName.startsWith(PARCEL_PREFIX_DIR))
parcelName = PARCEL_PREFIX_DIR + parcelName;
+
manifest = removeParcelFromManifest(document, parcelName);
// first write contents of document to tmpfile
@@ -76,38 +77,36 @@ public class ParcelZipper
while ((inEntry = documentStream.getNextEntry()) != null) {
- if(inEntry.getName().startsWith(parcelName))
+ if (inEntry.getName().startsWith(parcelName))
continue;
outEntry = new ZipEntry(inEntry);
outStream.putNextEntry(outEntry);
- if(inEntry.getName().equals("META-INF/manifest.xml") &&
- manifest != null) {
+ if (inEntry.getName().equals("META-INF/manifest.xml") &&
+ manifest != null) {
InputStream manifestStream = null;
+
try {
manifestStream = manifest.getInputStream();
+
while ((len = manifestStream.read(bytes)) != -1)
outStream.write(bytes, 0, len);
- }
- finally {
+ } finally {
if (manifestStream != null)
manifestStream.close();
}
- }
- else if (!inEntry.isDirectory()) {
+ } else if (!inEntry.isDirectory()) {
while ((len = documentStream.read(bytes)) != -1)
outStream.write(bytes, 0, len);
}
outStream.closeEntry();
}
- }
- catch (IOException ioe) {
+ } catch (IOException ioe) {
tmpfile.delete();
throw ioe;
- }
- finally {
+ } finally {
if (documentStream != null)
documentStream.close();
@@ -118,8 +117,7 @@ public class ParcelZipper
if (!document.delete()) {
tmpfile.delete();
throw new IOException("Could not overwrite " + document);
- }
- else
+ } else
tmpfile.renameTo(document);
return document.getAbsolutePath();
@@ -132,18 +130,16 @@ public class ParcelZipper
try {
documentZip = new ZipFile(document);
ZipEntry original = documentZip.getEntry("META-INF/manifest.xml");
+
if (original != null) {
result = new Manifest(documentZip.getInputStream(original));
}
- }
- catch (IOException ioe) {
- }
- finally {
+ } catch (IOException ioe) {
+ } finally {
try {
if (documentZip != null)
documentZip.close();
- }
- catch (IOException ioe) {}
+ } catch (IOException ioe) {}
}
return result;
@@ -153,6 +149,7 @@ public class ParcelZipper
Manifest result = null;
result = getManifestFromDocument(document);
+
if (result == null)
return null;
diff --git a/scripting/java/org/openoffice/netbeans/editor/JavaKit.java b/scripting/java/org/openoffice/netbeans/editor/JavaKit.java
index 3f622927ed83..1a3b6abddd17 100644
--- a/scripting/java/org/openoffice/netbeans/editor/JavaKit.java
+++ b/scripting/java/org/openoffice/netbeans/editor/JavaKit.java
@@ -57,10 +57,10 @@ public class JavaKit extends ExtKit {
public static final String JAVA_MIME_TYPE = "text/x-java"; // NOI18N
- static final long serialVersionUID =-5445829962533684922L;
+ static final long serialVersionUID = -5445829962533684922L;
static {
- Settings.addInitializer( new JavaSettingsInitializer( JavaKit.class ) );
+ Settings.addInitializer(new JavaSettingsInitializer(JavaKit.class));
Settings.reset();
URL skeleton = null, body = null;
@@ -73,8 +73,8 @@ public class JavaKit extends ExtKit {
new URLAccessor(body));
JCBaseFinder finder = new JCBaseFinder();
- finder.append( provider );
- JavaCompletion.setFinder( finder );
+ finder.append(provider);
+ JavaCompletion.setFinder(finder);
}
}
@@ -110,7 +110,7 @@ public class JavaKit extends ExtKit {
protected void initDocument(BaseDocument doc) {
doc.addLayer(new JavaDrawLayerFactory.JavaLayer(),
- JavaDrawLayerFactory.JAVA_LAYER_VISIBILITY);
+ JavaDrawLayerFactory.JAVA_LAYER_VISIBILITY);
doc.addDocumentListener(new JavaDrawLayerFactory.LParenWatcher());
}
@@ -131,8 +131,7 @@ public class JavaKit extends ExtKit {
/** Not implemented
*/
public void append(byte[] buffer, int off, int len)
- throws IOException
- {
+ throws IOException {
throw new IllegalArgumentException("read only!");
}
@@ -150,6 +149,7 @@ public class JavaKit extends ExtKit {
*/
public void read(byte[] buffer, int off, int len) throws IOException {
InputStream str = getStream(actOff);
+
while (len > 0) {
int count = str.read(buffer, off, len);
streamOff += count;
@@ -162,7 +162,7 @@ public class JavaKit extends ExtKit {
* @param requestWrite if true, file is opened for read/write
*/
public void open(boolean requestWrite) throws IOException {
- if(requestWrite)
+ if (requestWrite)
throw new IllegalArgumentException("read only!");
}
@@ -181,7 +181,7 @@ public class JavaKit extends ExtKit {
* at which the next read or write occurs.
*/
public long getFilePointer() throws IOException {
- return actOff;
+ return actOff;
}
/** Clears the file and sets the offset to 0 */
@@ -206,7 +206,7 @@ public class JavaKit extends ExtKit {
stream = null;
}
- if(stream == null) {
+ if (stream == null) {
stream = url.openStream();
streamOff = 0;
}
@@ -214,6 +214,7 @@ public class JavaKit extends ExtKit {
while (streamOff < off) {
long len = stream.skip(off - streamOff);
streamOff += (int)len;
+
if (len == 0) throw new IOException("EOF");
}
diff --git a/scripting/java/org/openoffice/netbeans/editor/NetBeansSourceView.java b/scripting/java/org/openoffice/netbeans/editor/NetBeansSourceView.java
index b4b2bd8d4fa3..19388fd8f82f 100644
--- a/scripting/java/org/openoffice/netbeans/editor/NetBeansSourceView.java
+++ b/scripting/java/org/openoffice/netbeans/editor/NetBeansSourceView.java
@@ -49,25 +49,24 @@ public class NetBeansSourceView extends JPanel
try {
Class kitClass = Class.forName(
- NetBeansSourceView.class.getPackage().getName() + ".JavaKit");
+ NetBeansSourceView.class.getPackage().getName() + ".JavaKit");
JEditorPane.registerEditorKitForContentType(
"text/x-java", kitClass.getName(), kitClass.getClassLoader());
- }
- catch( ClassNotFoundException exc ) {
+ } catch (ClassNotFoundException exc) {
}
}
private class MyLocalizer implements LocaleSupport.Localizer {
private ResourceBundle bundle;
- public MyLocalizer( String bundleName ) {
- bundle = ResourceBundle.getBundle( bundleName );
+ public MyLocalizer(String bundleName) {
+ bundle = ResourceBundle.getBundle(bundleName);
}
// Localizer
- public String getString( String key ) {
- return bundle.getString( key );
+ public String getString(String key) {
+ return bundle.getString(key);
}
}
@@ -102,10 +101,10 @@ public class NetBeansSourceView extends JPanel
}
java.net.URL url = null;
+
try {
url = f.toURL();
- }
- catch (java.net.MalformedURLException mue) {
+ } catch (java.net.MalformedURLException mue) {
System.err.println("Invalid file");
System.exit(-1);
}
@@ -120,11 +119,11 @@ public class NetBeansSourceView extends JPanel
}
// Code grabbed from NetBeans editor module
- public void scrollToLine(int line)
- {
+ public void scrollToLine(int line) {
BaseDocument doc = Utilities.getDocument(pane);
int pos = -1;
+
if (doc != null) {
// Obtain the offset where to jump
pos = Utilities.getRowStartFromLineOffset(doc, line);
@@ -132,11 +131,11 @@ public class NetBeansSourceView extends JPanel
if (pos != -1) {
Caret caret = pane.getCaret();
+
if (caret instanceof BaseCaret) { // support extended scroll mode
BaseCaret bCaret = (BaseCaret)caret;
bCaret.setDot(pos, bCaret, EditorUI.SCROLL_FIND);
- }
- else {
+ } else {
caret.setDot(pos);
}
}
@@ -151,16 +150,14 @@ public class NetBeansSourceView extends JPanel
so we don't get a storm of DocumentEvents during loading */
pane.getDocument().removeDocumentListener(this);
- if (!isModified)
- {
+ if (!isModified) {
pane.setText(model.getText());
}
// scroll to current position of the model
try {
scrollToLine(model.getCurrentPosition());
- }
- catch (Exception e) {
+ } catch (Exception e) {
// couldn't scroll to line, do nothing
}
diff --git a/scripting/java/org/openoffice/netbeans/modules/office/actions/BuildParcelAction.java b/scripting/java/org/openoffice/netbeans/modules/office/actions/BuildParcelAction.java
index db68ba7f874a..9aa998cfe77a 100644
--- a/scripting/java/org/openoffice/netbeans/modules/office/actions/BuildParcelAction.java
+++ b/scripting/java/org/openoffice/netbeans/modules/office/actions/BuildParcelAction.java
@@ -50,7 +50,7 @@ public class BuildParcelAction extends BuildAllAction {
if (task.isSuccessful()) {
ParcelFolderCookie cookie = (ParcelFolderCookie)
- activatedNodes[i].getCookie(ParcelFolderCookie.class);
+ activatedNodes[i].getCookie(ParcelFolderCookie.class);
if (cookie != null)
cookie.generate();
diff --git a/scripting/java/org/openoffice/netbeans/modules/office/actions/ConfigureParcelAction.java b/scripting/java/org/openoffice/netbeans/modules/office/actions/ConfigureParcelAction.java
index 0e4005828c9c..fa64996ced70 100644
--- a/scripting/java/org/openoffice/netbeans/modules/office/actions/ConfigureParcelAction.java
+++ b/scripting/java/org/openoffice/netbeans/modules/office/actions/ConfigureParcelAction.java
@@ -43,15 +43,15 @@ public class ConfigureParcelAction extends CookieAction {
return HelpCtx.DEFAULT_HELP;
}
- protected void performAction(final Node[] activatedNodes)
- {
+ protected void performAction(final Node[] activatedNodes) {
FrameworkJarChecker.mountDependencies();
RequestProcessor.getDefault().post(new Runnable() {
public void run() {
for (int i = 0; i < activatedNodes.length; i++) {
ParcelFolderCookie pfc = (ParcelFolderCookie)
- activatedNodes[i].getCookie(ParcelFolderCookie.class);
+ activatedNodes[i].getCookie(ParcelFolderCookie.class);
+
if (pfc != null)
pfc.configure();
}
diff --git a/scripting/java/org/openoffice/netbeans/modules/office/actions/DeployParcelAction.java b/scripting/java/org/openoffice/netbeans/modules/office/actions/DeployParcelAction.java
index 015c15cfb54b..6f9f48b02489 100644
--- a/scripting/java/org/openoffice/netbeans/modules/office/actions/DeployParcelAction.java
+++ b/scripting/java/org/openoffice/netbeans/modules/office/actions/DeployParcelAction.java
@@ -51,16 +51,17 @@ import org.openoffice.idesupport.LocalOffice;
import org.openoffice.netbeans.modules.office.utils.NagDialog;
import org.openoffice.netbeans.modules.office.options.OfficeSettings;
-public class DeployParcelAction extends CookieAction implements Presenter.Popup {
+public class DeployParcelAction extends CookieAction implements
+ Presenter.Popup {
private static final String BROWSE_LABEL = "Office Document...";
private static final String DEPLOY_LABEL = "Deploy To";
- public String getName () {
+ public String getName() {
return DEPLOY_LABEL;
}
- public HelpCtx getHelpCtx () {
+ public HelpCtx getHelpCtx() {
return HelpCtx.DEFAULT_HELP;
}
@@ -79,12 +80,13 @@ public class DeployParcelAction extends CookieAction implements Presenter.Popup
(ParcelCookie)nodes[0].getCookie(ParcelCookie.class);
File target = new File(oi.getPath(File.separator + label +
- File.separator + "Scripts"));
+ File.separator + "Scripts"));
File langdir = new File(target, parcelCookie.getLanguage());
if (!langdir.exists()) {
boolean response = askIfCreateDirectory(langdir);
+
if (!response) {
return;
}
@@ -110,8 +112,10 @@ public class DeployParcelAction extends CookieAction implements Presenter.Popup
item.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
File target = getTargetFile();
+
if (target == null)
return;
+
deploy(target);
}
});
@@ -120,15 +124,15 @@ public class DeployParcelAction extends CookieAction implements Presenter.Popup
return menu;
}
- protected int mode () {
+ protected int mode() {
return MODE_ONE;
}
- protected Class[] cookieClasses () {
+ protected Class[] cookieClasses() {
return new Class[] { ParcelCookie.class };
}
- protected void performAction (Node[] activatedNodes) {
+ protected void performAction(Node[] activatedNodes) {
// do nothing, should not happen
}
@@ -150,7 +154,7 @@ public class DeployParcelAction extends CookieAction implements Presenter.Popup
private boolean askIfCreateDirectory(File directory) {
String message = directory.getAbsolutePath() + " does not exist. " +
- "Do you want to create it now?";
+ "Do you want to create it now?";
NotifyDescriptor d = new NotifyDescriptor.Confirmation(
message, NotifyDescriptor.OK_CANCEL_OPTION);
@@ -160,10 +164,10 @@ public class DeployParcelAction extends CookieAction implements Presenter.Popup
return false;
boolean result;
+
try {
result = directory.mkdirs();
- }
- catch (SecurityException se) {
+ } catch (SecurityException se) {
result = false;
}
@@ -173,6 +177,7 @@ public class DeployParcelAction extends CookieAction implements Presenter.Popup
tmp, NotifyDescriptor.ERROR_MESSAGE);
TopManager.getDefault().notify(d2);
}
+
return result;
}
@@ -185,14 +190,14 @@ public class DeployParcelAction extends CookieAction implements Presenter.Popup
private void showNagDialog() {
String message = "If you currently have Office running you will " +
- "need to click on the Tools/Scripting Add-on's/Refresh All Scripts " +
- " menu item in Office so that the scripts in this parcel can be detected.";
+ "need to click on the Tools/Scripting Add-on's/Refresh All Scripts " +
+ " menu item in Office so that the scripts in this parcel can be detected.";
OfficeSettings settings = OfficeSettings.getDefault();
if (settings.getWarnAfterDirDeploy()) {
NagDialog warning = NagDialog.createInformationDialog(
- message, "Show this message in future", true);
+ message, "Show this message in future", true);
warning.show();
@@ -216,6 +221,7 @@ public class DeployParcelAction extends CookieAction implements Presenter.Popup
file.getName().endsWith(".sxd") ||
file.getName().endsWith(".sxi"))
return true;
+
return false;
}
@@ -229,6 +235,7 @@ public class DeployParcelAction extends CookieAction implements Presenter.Popup
if (result == JFileChooser.APPROVE_OPTION) {
target = chooser.getSelectedFile();
}
+
return target;
}
}
diff --git a/scripting/java/org/openoffice/netbeans/modules/office/actions/MountDocumentAction.java b/scripting/java/org/openoffice/netbeans/modules/office/actions/MountDocumentAction.java
index 7fa5fa7e0292..8b22e93ef9c4 100644
--- a/scripting/java/org/openoffice/netbeans/modules/office/actions/MountDocumentAction.java
+++ b/scripting/java/org/openoffice/netbeans/modules/office/actions/MountDocumentAction.java
@@ -26,41 +26,33 @@ import org.openide.util.actions.CookieAction;
/**
* @version 1.0
*/
-public class MountDocumentAction extends CookieAction
-{
- public String getName()
- {
+public class MountDocumentAction extends CookieAction {
+ public String getName() {
return "Mount Document"; //NOI18N
}
- public HelpCtx getHelpCtx()
- {
+ public HelpCtx getHelpCtx() {
return HelpCtx.DEFAULT_HELP;
}
- protected int mode()
- {
+ protected int mode() {
// enable duplication for as many qualifying nodes as are selected:
return CookieAction.MODE_ALL;
}
- protected java.lang.Class[] cookieClasses()
- {
+ protected java.lang.Class[] cookieClasses() {
// just the DuplicateCookie:
return new Class[] {OfficeDocumentCookie.class};
}
- protected void performAction(final Node[] activatedNodes)
- {
- RequestProcessor.getDefault().post(new Runnable()
- {
- public void run()
- {
- for (int i=0; i<activatedNodes.length; i++)
- {
- OfficeDocumentCookie cookie = (OfficeDocumentCookie)activatedNodes[i].getCookie(OfficeDocumentCookie.class);
- if (cookie != null)
- {
+ protected void performAction(final Node[] activatedNodes) {
+ RequestProcessor.getDefault().post(new Runnable() {
+ public void run() {
+ for (int i = 0; i < activatedNodes.length; i++) {
+ OfficeDocumentCookie cookie = (OfficeDocumentCookie)activatedNodes[i].getCookie(
+ OfficeDocumentCookie.class);
+
+ if (cookie != null) {
cookie.mount();
}
}
diff --git a/scripting/java/org/openoffice/netbeans/modules/office/actions/MountParcelAction.java b/scripting/java/org/openoffice/netbeans/modules/office/actions/MountParcelAction.java
index c579dacc2e53..01395dc3fb7d 100644
--- a/scripting/java/org/openoffice/netbeans/modules/office/actions/MountParcelAction.java
+++ b/scripting/java/org/openoffice/netbeans/modules/office/actions/MountParcelAction.java
@@ -26,40 +26,32 @@ import org.openide.util.actions.CookieAction;
/**
* @version 1.0
*/
-public class MountParcelAction extends CookieAction
-{
- public String getName()
- {
+public class MountParcelAction extends CookieAction {
+ public String getName() {
return "Mount Parcel"; //NOI18N
}
- public HelpCtx getHelpCtx()
- {
+ public HelpCtx getHelpCtx() {
return HelpCtx.DEFAULT_HELP;
}
- protected int mode()
- {
+ protected int mode() {
// enable duplication for as many qualifying nodes as are selected:
return CookieAction.MODE_ALL;
}
- protected java.lang.Class[] cookieClasses()
- {
+ protected java.lang.Class[] cookieClasses() {
return new Class[] {ParcelCookie.class};
}
- protected void performAction(final Node[] activatedNodes)
- {
- RequestProcessor.getDefault().post(new Runnable()
- {
- public void run()
- {
- for (int i=0; i<activatedNodes.length; i++)
- {
- ParcelCookie mpc = (ParcelCookie)activatedNodes[i].getCookie(ParcelCookie.class);
- if (mpc != null)
- {
+ protected void performAction(final Node[] activatedNodes) {
+ RequestProcessor.getDefault().post(new Runnable() {
+ public void run() {
+ for (int i = 0; i < activatedNodes.length; i++) {
+ ParcelCookie mpc = (ParcelCookie)activatedNodes[i].getCookie(
+ ParcelCookie.class);
+
+ if (mpc != null) {
mpc.mount();
}
}
diff --git a/scripting/java/org/openoffice/netbeans/modules/office/actions/OfficeDocumentCookie.java b/scripting/java/org/openoffice/netbeans/modules/office/actions/OfficeDocumentCookie.java
index 04ac91f3e741..df57575020f4 100644
--- a/scripting/java/org/openoffice/netbeans/modules/office/actions/OfficeDocumentCookie.java
+++ b/scripting/java/org/openoffice/netbeans/modules/office/actions/OfficeDocumentCookie.java
@@ -22,8 +22,7 @@ import java.util.Enumeration;
import javax.swing.event.ChangeListener;
import org.openide.nodes.Node;
-public interface OfficeDocumentCookie extends Node.Cookie
-{
+public interface OfficeDocumentCookie extends Node.Cookie {
void mount();
Enumeration getParcels();
void removeParcel(String name);
diff --git a/scripting/java/org/openoffice/netbeans/modules/office/actions/OfficeDocumentSupport.java b/scripting/java/org/openoffice/netbeans/modules/office/actions/OfficeDocumentSupport.java
index 0237872185bf..c77fc63a7cbc 100644
--- a/scripting/java/org/openoffice/netbeans/modules/office/actions/OfficeDocumentSupport.java
+++ b/scripting/java/org/openoffice/netbeans/modules/office/actions/OfficeDocumentSupport.java
@@ -44,8 +44,8 @@ import org.openoffice.netbeans.modules.office.loader.OfficeDocumentDataObject;
import org.openoffice.netbeans.modules.office.utils.ZipMounter;
import org.openoffice.netbeans.modules.office.utils.ManifestParser;
-public class OfficeDocumentSupport implements OfficeDocumentCookie, OpenCookie, FileChangeListener
-{
+public class OfficeDocumentSupport implements OfficeDocumentCookie, OpenCookie,
+ FileChangeListener {
protected OfficeDocumentDataObject dataObj;
private boolean isMounted = false;
private OfficeDocument document;
@@ -54,12 +54,13 @@ public class OfficeDocumentSupport implements OfficeDocumentCookie, OpenCookie,
public OfficeDocumentSupport(OfficeDocumentDataObject dataObj) {
this.dataObj = dataObj;
FileObject fo = dataObj.getPrimaryFile();
+
try {
this.document = new OfficeDocument(FileUtil.toFile(fo));
- }
- catch (Exception e) {
+ } catch (Exception e) {
e.printStackTrace();
}
+
fo.addFileChangeListener(this);
}
@@ -69,26 +70,24 @@ public class OfficeDocumentSupport implements OfficeDocumentCookie, OpenCookie,
try {
ZipMounter.getZipMounter().mountZipFile(file);
isMounted = true;
- }
- catch (IOException ioe) {
+ } catch (IOException ioe) {
ErrorManager.getDefault().notify(ioe);
- }
- catch (PropertyVetoException pve) {
+ } catch (PropertyVetoException pve) {
ErrorManager.getDefault().notify(pve);
}
}
- public void open () {
+ public void open() {
File file = FileUtil.toFile(dataObj.getPrimaryFile());
OfficeSettings settings = OfficeSettings.getDefault();
File soffice = new File(settings.getOfficeDirectory().getPath(
- File.separator + "soffice"));
+ File.separator + "soffice"));
try {
- Process p = Runtime.getRuntime ().exec (new String[] {
- soffice.getAbsolutePath(), file.getAbsolutePath ()
- });
+ Process p = Runtime.getRuntime().exec(new String[] {
+ soffice.getAbsolutePath(), file.getAbsolutePath()
+ });
} catch (IOException ioe) {
ErrorManager.getDefault().notify(ioe);
}
diff --git a/scripting/java/org/openoffice/netbeans/modules/office/actions/ParcelCookie.java b/scripting/java/org/openoffice/netbeans/modules/office/actions/ParcelCookie.java
index 1e4f701234bd..1c782ae6bf22 100644
--- a/scripting/java/org/openoffice/netbeans/modules/office/actions/ParcelCookie.java
+++ b/scripting/java/org/openoffice/netbeans/modules/office/actions/ParcelCookie.java
@@ -21,8 +21,7 @@ package org.openoffice.netbeans.modules.office.actions;
import java.io.File;
import org.openide.nodes.Node;
-public interface ParcelCookie extends Node.Cookie
-{
+public interface ParcelCookie extends Node.Cookie {
File getFile();
String getLanguage();
diff --git a/scripting/java/org/openoffice/netbeans/modules/office/actions/ParcelDescriptorEditorSupport.java b/scripting/java/org/openoffice/netbeans/modules/office/actions/ParcelDescriptorEditorSupport.java
index 00402b93409d..c4378ceff24d 100644
--- a/scripting/java/org/openoffice/netbeans/modules/office/actions/ParcelDescriptorEditorSupport.java
+++ b/scripting/java/org/openoffice/netbeans/modules/office/actions/ParcelDescriptorEditorSupport.java
@@ -32,7 +32,8 @@ import org.openoffice.netbeans.modules.office.loader.ParcelDescriptorDataObject;
/** Support for editing a data object as text.
*/
// Replace OpenCookie with EditCookie or maybe ViewCookie as desired:
-public class ParcelDescriptorEditorSupport extends DataEditorSupport implements EditorCookie, OpenCookie, CloseCookie, PrintCookie {
+public class ParcelDescriptorEditorSupport extends DataEditorSupport implements
+ EditorCookie, OpenCookie, CloseCookie, PrintCookie {
/** Create a new editor support.
* @param obj the data object whose primary file will be edited as text
@@ -51,12 +52,15 @@ public class ParcelDescriptorEditorSupport extends DataEditorSupport implements
if (!super.notifyModified()) {
return false;
}
+
ParcelDescriptorDataObject obj = (ParcelDescriptorDataObject)getDataObject();
+
if (obj.getCookie(SaveCookie.class) == null) {
obj.setModified(true);
// You must implement this method on the object:
obj.addSaveCookie(new Save());
}
+
return true;
}
@@ -66,11 +70,13 @@ public class ParcelDescriptorEditorSupport extends DataEditorSupport implements
protected void notifyUnmodified() {
ParcelDescriptorDataObject obj = (ParcelDescriptorDataObject)getDataObject();
SaveCookie save = (SaveCookie)obj.getCookie(SaveCookie.class);
+
if (save != null) {
// You must implement this method on the object:
obj.removeSaveCookie(save);
obj.setModified(false);
}
+
super.notifyUnmodified();
}
@@ -111,7 +117,8 @@ public class ParcelDescriptorEditorSupport extends DataEditorSupport implements
* @throws IOException if the lock could not be taken
*/
protected FileLock takeLock() throws IOException {
- return ((ParcelDescriptorDataObject)getDataObject()).getPrimaryEntry().takeLock();
+ return ((ParcelDescriptorDataObject)
+ getDataObject()).getPrimaryEntry().takeLock();
}
/** Find the editor support this environment represents.
@@ -120,7 +127,8 @@ public class ParcelDescriptorEditorSupport extends DataEditorSupport implements
* @return the editor support
*/
public CloneableOpenSupport findCloneableOpenSupport() {
- return (ParcelDescriptorEditorSupport)getDataObject().getCookie(ParcelDescriptorEditorSupport.class);
+ return (ParcelDescriptorEditorSupport)getDataObject().getCookie(
+ ParcelDescriptorEditorSupport.class);
}
}
diff --git a/scripting/java/org/openoffice/netbeans/modules/office/actions/ParcelDescriptorParserCookie.java b/scripting/java/org/openoffice/netbeans/modules/office/actions/ParcelDescriptorParserCookie.java
index 21091196b0e8..0e7e4226d657 100644
--- a/scripting/java/org/openoffice/netbeans/modules/office/actions/ParcelDescriptorParserCookie.java
+++ b/scripting/java/org/openoffice/netbeans/modules/office/actions/ParcelDescriptorParserCookie.java
@@ -22,8 +22,7 @@ import org.w3c.dom.NodeList;
import javax.swing.event.ChangeListener;
import org.openide.nodes.Node;
-public interface ParcelDescriptorParserCookie extends Node.Cookie
-{
+public interface ParcelDescriptorParserCookie extends Node.Cookie {
// should return a NodeList of org.w3c.dom.Element
NodeList getScriptElements();
diff --git a/scripting/java/org/openoffice/netbeans/modules/office/actions/ParcelDescriptorParserSupport.java b/scripting/java/org/openoffice/netbeans/modules/office/actions/ParcelDescriptorParserSupport.java
index 7d71560bce59..f3f105679677 100644
--- a/scripting/java/org/openoffice/netbeans/modules/office/actions/ParcelDescriptorParserSupport.java
+++ b/scripting/java/org/openoffice/netbeans/modules/office/actions/ParcelDescriptorParserSupport.java
@@ -32,50 +32,45 @@ import org.openide.filesystems.*;
import org.openide.xml.XMLUtil;
public class ParcelDescriptorParserSupport
- implements ParcelDescriptorParserCookie, FileChangeListener
-{
+ implements ParcelDescriptorParserCookie, FileChangeListener {
private FileObject fo;
private Document document;
private Set listeners;
- public ParcelDescriptorParserSupport(FileObject fo)
- {
+ public ParcelDescriptorParserSupport(FileObject fo) {
this.fo = fo;
fo.addFileChangeListener(this);
}
- private synchronized void parseFile()
- {
+ private synchronized void parseFile() {
File file = FileUtil.toFile(fo);
InputSource is;
try {
is = new InputSource(new FileInputStream(file));
- }
- catch (FileNotFoundException fnfe) {
+ } catch (FileNotFoundException fnfe) {
System.out.println("Couldn't find file: " + file.getName());
return;
}
document = null;
+
try {
document = XMLUtil.parse(is, false, false, null, null);
- }
- catch (IOException ioe) {
+ } catch (IOException ioe) {
System.out.println("IO Error parsing file: " + file.getName());
- }
- catch (SAXException se) {
+ } catch (SAXException se) {
System.out.println("Sax Error parsing file: " + file.getName());
}
}
- public synchronized NodeList getScriptElements()
- {
+ public synchronized NodeList getScriptElements() {
if (document == null)
parseFile();
if (document != null)
return document.getElementsByTagName("script");
+
return null;
}
diff --git a/scripting/java/org/openoffice/netbeans/modules/office/actions/ParcelFolderCookie.java b/scripting/java/org/openoffice/netbeans/modules/office/actions/ParcelFolderCookie.java
index 778bd208b570..6a17ee13ab31 100644
--- a/scripting/java/org/openoffice/netbeans/modules/office/actions/ParcelFolderCookie.java
+++ b/scripting/java/org/openoffice/netbeans/modules/office/actions/ParcelFolderCookie.java
@@ -20,8 +20,7 @@ package org.openoffice.netbeans.modules.office.actions;
import org.openide.nodes.Node;
-public interface ParcelFolderCookie extends Node.Cookie
-{
+public interface ParcelFolderCookie extends Node.Cookie {
void generate();
boolean configure();
diff --git a/scripting/java/org/openoffice/netbeans/modules/office/actions/ParcelFolderSupport.java b/scripting/java/org/openoffice/netbeans/modules/office/actions/ParcelFolderSupport.java
index bf310bc8b2c0..ce0ac563b0a5 100644
--- a/scripting/java/org/openoffice/netbeans/modules/office/actions/ParcelFolderSupport.java
+++ b/scripting/java/org/openoffice/netbeans/modules/office/actions/ParcelFolderSupport.java
@@ -58,8 +58,7 @@ import org.openoffice.idesupport.zip.ParcelZipper;
import org.openoffice.idesupport.filter.FileFilter;
import org.openoffice.idesupport.ui.ConfigurePanel;
-public class ParcelFolderSupport implements ParcelFolderCookie
-{
+public class ParcelFolderSupport implements ParcelFolderCookie {
protected ParcelFolder parcelFolder;
private ConfigurePanel configuror = null;
@@ -72,8 +71,7 @@ public class ParcelFolderSupport implements ParcelFolderCookie
if (descriptor == null) {
return "";
- }
- else {
+ } else {
return descriptor.getLanguage();
}
}
@@ -83,8 +81,7 @@ public class ParcelFolderSupport implements ParcelFolderCookie
if (descriptor == null) {
return "";
- }
- else {
+ } else {
return descriptor.getLanguageProperty("classpath");
}
}
@@ -97,8 +94,7 @@ public class ParcelFolderSupport implements ParcelFolderCookie
try {
descriptor.write();
- }
- catch (IOException ioe) {
+ } catch (IOException ioe) {
ErrorManager.getDefault().notify(ioe);
}
}
@@ -108,7 +104,7 @@ public class ParcelFolderSupport implements ParcelFolderCookie
FileObject primary = parcelFolder.getPrimaryFile();
File contents = FileUtil.toFile(
- primary.getFileObject(ParcelZipper.CONTENTS_DIRNAME));
+ primary.getFileObject(ParcelZipper.CONTENTS_DIRNAME));
return ParcelDescriptor.getParcelDescriptor(contents);
}
@@ -128,32 +124,32 @@ public class ParcelFolderSupport implements ParcelFolderCookie
// use the Parcel Recipe directory as the target directory
File targetDir = FileUtil.toFile(parcelFolder.getPrimaryFile());
File targetfile = new File(targetDir, File.separator +
- parcelBase.getName() + "." + ParcelZipper.PARCEL_EXTENSION);
+ parcelBase.getName() + "." + ParcelZipper.PARCEL_EXTENSION);
boolean proceed = configure();
+
if (!proceed) {
return;
}
final OutputWriter out =
ParcelSupport.getOutputWindowWriter(parcelDir.getName() + " (generating)");
+
try {
out.println("Generating: " + parcelDir.getName(), null);
- ParcelZipper.getParcelZipper().zipParcel(contentsDir, targetfile, node.getFileFilter());
+ ParcelZipper.getParcelZipper().zipParcel(contentsDir, targetfile,
+ node.getFileFilter());
out.println("\nGENERATION SUCCESSFUL.");
out.println("\nRight click on the generated parcel to deploy it");
if (targetDir.equals(parcelDir)) {
parcelBase.refresh(true);
}
- }
- catch (IOException ioe) {
- out.println("GENERATION FAILED: reason: " + ioe.getClass().getName() + ": "+ ioe.getMessage());
- }
- finally
- {
- if( out != null)
- {
+ } catch (IOException ioe) {
+ out.println("GENERATION FAILED: reason: " + ioe.getClass().getName() + ": " +
+ ioe.getMessage());
+ } finally {
+ if (out != null) {
out.close();
}
}
@@ -164,33 +160,32 @@ public class ParcelFolderSupport implements ParcelFolderCookie
FileObject primary = parcelFolder.getPrimaryFile();
File contents = FileUtil.toFile(
- primary.getFileObject(ParcelZipper.CONTENTS_DIRNAME));
+ primary.getFileObject(ParcelZipper.CONTENTS_DIRNAME));
ArrayList<String> classpath = getConfigureClasspath();
classpath.add(contents.getAbsolutePath());
try {
ParcelDescriptor descriptor = getParcelDescriptor();
+
if (descriptor == null) {
descriptor = ParcelDescriptor.createParcelDescriptor(contents);
}
if (configuror == null) {
configuror = new ConfigurePanel(contents.getAbsolutePath(),
- classpath, descriptor);
- }
- else {
+ classpath, descriptor);
+ } else {
configuror.reload(contents.getAbsolutePath(), classpath,
- descriptor);
+ descriptor);
}
- }
- catch (IOException ioe) {
+ } catch (IOException ioe) {
ErrorManager.getDefault().notify(ioe);
return false;
}
DialogDescriptor dd = new DialogDescriptor(configuror,
- ConfigurePanel.DIALOG_TITLE);
+ ConfigurePanel.DIALOG_TITLE);
Dialog dialog = TopManager.getDefault().createDialog(dd);
dialog.show();
@@ -199,14 +194,13 @@ public class ParcelFolderSupport implements ParcelFolderCookie
try {
ParcelDescriptor descriptor = configuror.getConfiguration();
descriptor.write();
- }
- catch (Exception e) {
+ } catch (Exception e) {
ErrorManager.getDefault().notify(e);
}
- }
- else {
+ } else {
return false;
}
+
return true;
}
@@ -214,30 +208,30 @@ public class ParcelFolderSupport implements ParcelFolderCookie
ArrayList<String> result = new ArrayList<String>();
String classpath = NbClassPath.createRepositoryPath().getClassPath();
- if ( System.getProperty( "os.name" ).startsWith( "Windows" ) )
- {
+
+ if (System.getProperty("os.name").startsWith("Windows")) {
// under windows path is enclosed by quotes
// e.g. C:\path1;d:\path2 would appear as
// "C:\path1;d:\path2" therefore for us
// we need to remove 1 character at either end of the
// classpath returned from "createRepositoryPath().getClassPath()"
- if ( classpath.startsWith("\"") && classpath.endsWith("\"") )
- {
- StringBuffer buff = new StringBuffer(classpath);
- buff.delete(0,1);
- buff.delete( buff.length() - 1, buff.length() );
- classpath = buff.toString();
+ if (classpath.startsWith("\"") && classpath.endsWith("\"")) {
+ StringBuffer buff = new StringBuffer(classpath);
+ buff.delete(0, 1);
+ buff.delete(buff.length() - 1, buff.length());
+ classpath = buff.toString();
}
}
+
StringTokenizer tokens = new StringTokenizer(classpath, File.pathSeparator);
- while(tokens.hasMoreTokens())
+ while (tokens.hasMoreTokens())
result.addElement(tokens.nextToken());
OfficeSettings settings = OfficeSettings.getDefault();
File classesDir = new File(settings.getOfficeDirectory().getPath(
- File.separator + "program" + File.separator + "classes"));
+ File.separator + "program" + File.separator + "classes"));
File[] jarfiles = classesDir.listFiles();
for (int i = 0; i < jarfiles.length; i++)
diff --git a/scripting/java/org/openoffice/netbeans/modules/office/actions/ParcelSupport.java b/scripting/java/org/openoffice/netbeans/modules/office/actions/ParcelSupport.java
index ab05d89d687d..381be44ccadb 100644
--- a/scripting/java/org/openoffice/netbeans/modules/office/actions/ParcelSupport.java
+++ b/scripting/java/org/openoffice/netbeans/modules/office/actions/ParcelSupport.java
@@ -44,8 +44,7 @@ import org.openoffice.netbeans.modules.office.utils.NagDialog;
import org.openoffice.netbeans.modules.office.utils.ZipMounter;
import org.openoffice.netbeans.modules.office.utils.ManifestParser;
-public class ParcelSupport implements ParcelCookie
-{
+public class ParcelSupport implements ParcelCookie {
private FileObject fo;
private ParcelZipper zipper = ParcelZipper.getParcelZipper();
private String language = null;
@@ -62,26 +61,23 @@ public class ParcelSupport implements ParcelCookie
if (language == null) {
try {
language = zipper.getParcelLanguage(getFile());
- }
- catch (IOException ioe) {
+ } catch (IOException ioe) {
return null;
}
}
+
return language;
}
- public void mount()
- {
+ public void mount() {
File parcel = FileUtil.toFile(fo);
if (parcel != null) {
try {
ZipMounter.getZipMounter().mountZipFile(parcel);
- }
- catch (IOException ioe) {
+ } catch (IOException ioe) {
ErrorManager.getDefault().notify(ioe);
- }
- catch (PropertyVetoException pve) {
+ } catch (PropertyVetoException pve) {
ErrorManager.getDefault().notify(pve);
}
}
@@ -93,12 +89,12 @@ public class ParcelSupport implements ParcelCookie
if (!target.isDirectory()) {
OfficeSettings settings = OfficeSettings.getDefault();
String message = "If you already have this document open in " +
- "Office, please close it before continuing. Click OK to " +
- "continue deployment.";
+ "Office, please close it before continuing. Click OK to " +
+ "continue deployment.";
if (settings.getWarnBeforeDocDeploy()) {
NagDialog warning = NagDialog.createConfirmationDialog(
- message, "Show this message in future", true);
+ message, "Show this message in future", true);
boolean result = warning.show();
@@ -117,36 +113,35 @@ public class ParcelSupport implements ParcelCookie
if (!zipper.isOverwriteNeeded(source, target))
if (!promptForOverwrite(source, target))
return false;
- }
- catch (IOException ioe) {
- out.println("DEPLOYMENT FAILED: reason: " +
- ioe.getClass().getName() + ": "+ ioe.getMessage());
- return false;
+ } catch (IOException ioe) {
+ out.println("DEPLOYMENT FAILED: reason: " +
+ ioe.getClass().getName() + ": " + ioe.getMessage());
+ return false;
}
try {
out.println("Deploying: " + fo.getName() +
- "\nTo: " + target.getAbsolutePath(), null);
+ "\nTo: " + target.getAbsolutePath(), null);
zipper.deployParcel(source, target);
out.println("\nDEPLOYMENT SUCCESSFUL.");
FileObject[] fileobjs = FileUtil.fromFile(target);
+
if (fileobjs != null) {
for (int i = 0; i < fileobjs.length; i++)
fileobjs[i].refresh(true);
}
- }
- catch (IOException ioe) {
- out.println("DEPLOYMENT FAILED: reason: " +
- ioe.getClass().getName() + ": "+ ioe.getMessage());
- return false;
- }
- finally {
- if( out != null)
+ } catch (IOException ioe) {
+ out.println("DEPLOYMENT FAILED: reason: " +
+ ioe.getClass().getName() + ": " + ioe.getMessage());
+ return false;
+ } finally {
+ if (out != null)
out.close();
}
+
return true;
}
@@ -156,19 +151,20 @@ public class ParcelSupport implements ParcelCookie
io.setOutputVisible(true);
OutputWriter out = io.getOut();
+
try {
out.reset();
- }
- catch( IOException e) {
+ } catch (IOException e) {
e.printStackTrace(System.err);
}
+
out.println(Calendar.getInstance().getTime() + ":\n");
return out;
}
private boolean promptForOverwrite(File source, File target) {
String message = source.getName() + " has already been deployed " +
- "to this target. Do you wish to overwrite it?";
+ "to this target. Do you wish to overwrite it?";
NotifyDescriptor d = new NotifyDescriptor.Confirmation(
message, NotifyDescriptor.OK_CANCEL_OPTION);
diff --git a/scripting/java/org/openoffice/netbeans/modules/office/filesystem/OpenOfficeDocFileSystem.java b/scripting/java/org/openoffice/netbeans/modules/office/filesystem/OpenOfficeDocFileSystem.java
index e86f5e03ae3c..6081445d258a 100644
--- a/scripting/java/org/openoffice/netbeans/modules/office/filesystem/OpenOfficeDocFileSystem.java
+++ b/scripting/java/org/openoffice/netbeans/modules/office/filesystem/OpenOfficeDocFileSystem.java
@@ -42,8 +42,7 @@ import org.openide.util.NbBundle;
* OpenOffice.org Document filesystem.
*/
public class OpenOfficeDocFileSystem
- extends AbstractFileSystem
-{
+ extends AbstractFileSystem {
public static final String SCRIPTS_ROOT = "Scripts"; // must be a folder
public static final String SEPARATOR = "/"; // zip file separator
@@ -74,6 +73,7 @@ public class OpenOfficeDocFileSystem
static {
// Identify the type of OS
String osname = System.getProperty("os.name");
+
if (osname.startsWith("Mac OS"))
osType = OS_MACOS;
else if (osname.startsWith("Windows"))
@@ -85,8 +85,7 @@ public class OpenOfficeDocFileSystem
/**
* Default constructor. Initializes new OpenOffice filesystem.
*/
- public OpenOfficeDocFileSystem()
- {
+ public OpenOfficeDocFileSystem() {
// Create the filesystem cache
cache = new HashMap();
@@ -116,8 +115,7 @@ public class OpenOfficeDocFileSystem
/**
* Constructor. Initializes new OpenOffice filesystem with FS capability.
*/
- public OpenOfficeDocFileSystem(FileSystemCapability cap)
- {
+ public OpenOfficeDocFileSystem(FileSystemCapability cap) {
this();
setCapability(cap);
}
@@ -127,8 +125,7 @@ public class OpenOfficeDocFileSystem
* NOTE: The scope is not a part of the signature so it is impossible
* to mount the same archive more than once.
*/
- public static String computeSystemName(File file)
- {
+ public static String computeSystemName(File file) {
return OpenOfficeDocFileSystem.class.getName() + "[" + file + "]";
}
@@ -137,21 +134,19 @@ public class OpenOfficeDocFileSystem
/**
* Provides the 'human readable' name of the instance of the filesystem.
*/
- public String getDisplayName()
- {
+ public String getDisplayName() {
if (!isValid())
return NbBundle.getMessage(OpenOfficeDocFileSystem.class,
- "LAB_invalid_file_system", ((docFile != null)? docFile.toString(): ""));
+ "LAB_invalid_file_system", ((docFile != null) ? docFile.toString() : ""));
else
return NbBundle.getMessage(OpenOfficeDocFileSystem.class,
- "LAB_valid_file_system", docFile.toString());
+ "LAB_valid_file_system", docFile.toString());
}
/**
* Retrieves the 'document' property.
*/
- public File getDocument()
- {
+ public File getDocument() {
return docFile;
}
@@ -162,39 +157,45 @@ public class OpenOfficeDocFileSystem
// of the root file object) should cause everything using this filesystem
// to refresh. The system name must change and refreshRoot should be used
// to ensure that everything is correctly updated.
+
public synchronized void setDocument(File file)
- throws java.beans.PropertyVetoException, java.io.IOException
- {
-System.out.println("OpenOfficeDocFileSystem.setDocument: file=\"" + file.toString() + "\"");
- if(!file.exists() || !file.isFile()) {
+ throws java.beans.PropertyVetoException, java.io.IOException {
+ System.out.println("OpenOfficeDocFileSystem.setDocument: file=\"" +
+ file.toString() + "\"");
+
+ if (!file.exists() || !file.isFile()) {
IOException ioe = new IOException(
file.toString() + " does not exist");
ErrorManager.getDefault().annotate(ioe, NbBundle.getMessage(
- OpenOfficeDocFileSystem.class, "EXC_root_dir_does_not_exist",
- file.toString()));
+ OpenOfficeDocFileSystem.class, "EXC_root_dir_does_not_exist",
+ file.toString()));
throw ioe;
}
+
// update the document
try {
- updateDocument();
- } catch(IOException ioe) {
+ updateDocument();
+ } catch (IOException ioe) {
// cannot save all!!!
-System.out.println("*** OpenOfficeDocFileSystem.setDocument:");
-System.out.println(" file: " + ((docFile != null)? docFile.toString(): ""));
-System.out.println(" exception: " + ioe.getMessage());
+ System.out.println("*** OpenOfficeDocFileSystem.setDocument:");
+ System.out.println(" file: " + ((docFile != null) ? docFile.toString() :
+ ""));
+ System.out.println(" exception: " + ioe.getMessage());
}
+
// new document type verification!!!
closeDocument();
+
// open a new document
try {
openDocument(file);
firePropertyChange(PROP_ROOT, null, refreshRoot());
setRefreshTime(REFRESH_TIME);
- } catch(IOException ioe) {
+ } catch (IOException ioe) {
// cannot open a new document!!!
-System.out.println("*** OpenOfficeDocFileSystem.setDocument:");
-System.out.println(" file: " + ((file != null)? file.toString(): ""));
-System.out.println(" exception: " + ioe.getMessage());
+ System.out.println("*** OpenOfficeDocFileSystem.setDocument:");
+ System.out.println(" file: " + ((file != null) ? file.toString() : ""));
+ System.out.println(" exception: " + ioe.getMessage());
}
}
@@ -203,8 +204,7 @@ System.out.println(" exception: " + ioe.getMessage());
* NOTE: The portion of the mounted document available to the user is
* always editable.
*/
- public boolean isReadOnly()
- {
+ public boolean isReadOnly() {
return false;
}
@@ -213,8 +213,7 @@ System.out.println(" exception: " + ioe.getMessage());
* NOTE: The portion of the mounted document available to the user is
* always editable.
*/
- public void setReadOnly(boolean flag)
- {
+ public void setReadOnly(boolean flag) {
// sorry! it is not supported.
}
@@ -224,8 +223,7 @@ System.out.println(" exception: " + ioe.getMessage());
* Participates in the environment configuration.
* This is how you can affect the classpath for execution, compilation, etc.
*/
- public void prepareEnvironment(FileSystem.Environment environment)
- {
+ public void prepareEnvironment(FileSystem.Environment environment) {
// BUG: the compiller cannot access files within the OpenOffice document.
//environment.addClassPath(docFile.toString());
}
@@ -266,7 +264,7 @@ System.out.println(" exception: " + ioe.getMessage());
// The actions should typically be CookieActions looking for DataObject
// cookies, where the object's primary file is on this type of filesystem.
public SystemAction[] getActions() {
-// ------>>>> UPDATE OPENOFFICE DOCUMENT <<<<------
+ // ------>>>> UPDATE OPENOFFICE DOCUMENT <<<<------
return new SystemAction[] {
SystemAction.get(SomeAction.class),
null, // separator
@@ -283,17 +281,18 @@ System.out.println(" exception: " + ioe.getMessage());
* to avoid retaining resources for too long etc. Filesystems should maintain correct
* semantics regardless of whether and when this method is called.
*/
- public void removeNotify()
- {
+ public void removeNotify() {
setRefreshTime(REFRESH_OFF); // disable refresh
+
// update the document
try {
- updateDocument();
- } catch(IOException ioe) {
+ updateDocument();
+ } catch (IOException ioe) {
// cannot save all!!!
-System.out.println("*** OpenOfficeDocFileSystem.removeNotify:");
-System.out.println(" exception: " + ioe.getMessage());
+ System.out.println("*** OpenOfficeDocFileSystem.removeNotify:");
+ System.out.println(" exception: " + ioe.getMessage());
}
+
closeDocument();
super.removeNotify();
}
@@ -302,9 +301,8 @@ System.out.println(" exception: " + ioe.getMessage());
* Opens (mounts) an OpenOffice document.
*/
private void openDocument(File file)
- throws IOException, PropertyVetoException
- {
- synchronized(cache) {
+ throws IOException, PropertyVetoException {
+ synchronized (cache) {
setSystemName(computeSystemName(file));
docFile = file;
zipFile = new ZipFile(docFile);
@@ -316,19 +314,19 @@ System.out.println(" exception: " + ioe.getMessage());
/*
* Closes the document and cleans up the cache.
*/
- private void closeDocument()
- {
- synchronized(cache) {
+ private void closeDocument() {
+ synchronized (cache) {
// if a document mounted - close it
- if(docFile != null) {
+ if (docFile != null) {
// close the document archive
- if(zipFile != null) {
+ if (zipFile != null) {
try {
zipFile.close();
- } catch(IOException ioe) {
+ } catch (IOException ioe) {
// sorry! we can do nothing about it.
}
}
+
zipFile = null;
// clean up cache
scanDocument(new CleanStrategy());
@@ -341,21 +339,24 @@ System.out.println(" exception: " + ioe.getMessage());
/*
* Creates a document cache.
*/
- private void cacheDocument(Enumeration entries, Strategy editables)
- {
+ private void cacheDocument(Enumeration entries, Strategy editables) {
Entry cacheEntry;
ZipEntry archEntry;
- synchronized(cache) {
+
+ synchronized (cache) {
cache.clear();
// root folder
cacheEntry = new ReadWriteEntry(null);
cache.put(cacheEntry.getName(), cacheEntry);
+
// the rest of items
- while(entries.hasMoreElements()) {
+ while (entries.hasMoreElements()) {
archEntry = (ZipEntry)entries.nextElement();
cacheEntry = new Entry(archEntry);
- if(editables.evaluate(cacheEntry))
+
+ if (editables.evaluate(cacheEntry))
cacheEntry = new ReadWriteEntry(archEntry);
+
cache.put(cacheEntry.getName(), cacheEntry);
}
} // synchronized
@@ -365,44 +366,51 @@ System.out.println(" exception: " + ioe.getMessage());
* Updates the document.
*/
private void updateDocument()
- throws IOException
- {
- if(docFile == null)
+ throws IOException {
+ if (docFile == null)
return;
- synchronized(cache) {
+
+ synchronized (cache) {
ModifiedStrategy modifiedStrategy = new ModifiedStrategy();
scanDocument(modifiedStrategy);
- if(isModified || modifiedStrategy.isModified())
- {
+
+ if (isModified || modifiedStrategy.isModified()) {
File tmpFile = null;
+
try {
// create updated document
tmpFile = File.createTempFile(
- TMP_FILE_PREF, TMP_FILE_SUFX, docFile.getParentFile());
+ TMP_FILE_PREF, TMP_FILE_SUFX, docFile.getParentFile());
saveDocument(tmpFile);
- } catch(IOException ioe) {
- if(tmpFile != null)
+ } catch (IOException ioe) {
+ if (tmpFile != null)
tmpFile.delete();
+
throw ioe;
}
+
// close the document archive
- if(zipFile != null) {
+ if (zipFile != null) {
try {
zipFile.close();
- } catch(IOException ioe) {
+ } catch (IOException ioe) {
}
}
+
zipFile = null;
// create the document and backup
File newFile = new File(docFile.getParentFile() + File.separator +
- "~" + docFile.getName());
- if(newFile.exists())
+ "~" + docFile.getName());
+
+ if (newFile.exists())
newFile.delete(); // delete old backup
+
docFile.renameTo(newFile);
tmpFile.renameTo(docFile);
// open the document archive
zipFile = new ZipFile(docFile);
}
+
isModified = false;
} // synchronized
}
@@ -411,9 +419,8 @@ System.out.println(" exception: " + ioe.getMessage());
* Saves the document in a new archive.
*/
private void saveDocument(File file)
- throws IOException
- {
- synchronized(cache) {
+ throws IOException {
+ synchronized (cache) {
SaveStrategy saver = new SaveStrategy(file);
scanDocument(saver);
saver.close();
@@ -423,11 +430,11 @@ System.out.println(" exception: " + ioe.getMessage());
/*
* Provides each individual entry in the cached document to an apraiser.
*/
- private void scanDocument(Strategy strategy)
- {
- synchronized(cache) {
+ private void scanDocument(Strategy strategy) {
+ synchronized (cache) {
Iterator itr = cache.values().iterator();
- while(itr.hasNext()) {
+
+ while (itr.hasNext()) {
strategy.evaluate((Entry)itr.next());
}
} // synchronized
@@ -437,25 +444,29 @@ System.out.println(" exception: " + ioe.getMessage());
* Retrieves or creates a file.
*/
private Entry getFileEntry(String name)
- throws IOException
- {
+ throws IOException {
Entry cEntry = null;
- synchronized(cache) {
+
+ synchronized (cache) {
cEntry = (Entry)cache.get(name);
- if(cEntry == null) {
+
+ if (cEntry == null) {
// create a new file
ZipEntry zEntry = new ZipEntry(name);
zEntry.setTime(new Date().getTime());
cEntry = new Entry(zEntry);
- if(!editableStrategy.evaluate(cEntry)) {
+
+ if (!editableStrategy.evaluate(cEntry)) {
throw new IOException(
"cannot create/edit readonly file"); // I18N
}
+
cEntry = new ReadWriteEntry(zEntry);
cache.put(cEntry.getName(), cEntry);
isModified = true;
}
} // synchronized
+
return cEntry;
}
@@ -463,12 +474,13 @@ System.out.println(" exception: " + ioe.getMessage());
* Retrieves or creates a folder.
*/
private Entry getFolderEntry(String name)
- throws IOException
- {
+ throws IOException {
Entry cEntry = null;
- synchronized(cache) {
+
+ synchronized (cache) {
cEntry = (Entry)cache.get(name);
- if(cEntry == null) {
+
+ if (cEntry == null) {
// create a new folder
ZipEntry zEntry = new ZipEntry(name + SEPARATOR);
zEntry.setMethod(ZipEntry.STORED);
@@ -477,19 +489,22 @@ System.out.println(" exception: " + ioe.getMessage());
zEntry.setCrc(crc.getValue());
zEntry.setTime(new Date().getTime());
cEntry = new Entry(zEntry);
- if(!editableStrategy.evaluate(cEntry)) {
+
+ if (!editableStrategy.evaluate(cEntry)) {
throw new IOException(
"cannot create folder"); // I18N
}
+
cEntry = new ReadWriteEntry(zEntry);
cEntry.getOutputStream(); // sets up modified flag
cache.put(cEntry.getName(), cEntry);
isModified = true;
} else {
- if(!cEntry.isFolder())
+ if (!cEntry.isFolder())
cEntry = null;
}
} // synchronized
+
return cEntry;
}
@@ -502,20 +517,23 @@ System.out.println(" exception: " + ioe.getMessage());
* the rest of the code.
* WORKAROUND: we have to strip leading '/' if it is in the name.
*/
- private static String zipName(String name)
- {
- String zname = ((name.startsWith(File.separator))?
- name.substring(File.separator.length()): name);
- switch(osType) {
+ private static String zipName(String name) {
+ String zname = ((name.startsWith(File.separator)) ?
+ name.substring(File.separator.length()) : name);
+
+ switch (osType) {
case OS_MACOS:
zname = zname.replace(':', '/'); // ':' by '/'
break;
+
case OS_WINDOWS:
zname = zname.replace((char)0x5c, '/'); // '\' by '/'
break;
+
default:
break;
}
+
return zname;
}
@@ -526,14 +544,15 @@ System.out.println(" exception: " + ioe.getMessage());
* not affect the file's presence or name.
*/
private class InfoImpl
- implements Info
- {
+ implements Info {
public boolean folder(String name) {
- synchronized(cache) {
+ synchronized (cache) {
String zname = zipName(name);
Entry entry = (Entry)cache.get(zname);
- if(entry != null)
+
+ if (entry != null)
return entry.isFolder();
+
// logical zip file entry
childrenStrategy.setParent(zname);
scanDocument(childrenStrategy);
@@ -542,14 +561,14 @@ System.out.println(" exception: " + ioe.getMessage());
}
public Date lastModified(String name) {
- synchronized(cache) {
+ synchronized (cache) {
Entry entry = (Entry)cache.get(zipName(name));
- return new Date((entry != null)? entry.getTime(): 0L);
+ return new Date((entry != null) ? entry.getTime() : 0L);
}
}
public boolean readOnly(String name) {
- synchronized(cache) {
+ synchronized (cache) {
Entry entry = (Entry)cache.get(zipName(name));
return entry && entry.isReadOnly();
}
@@ -564,24 +583,22 @@ System.out.println(" exception: " + ioe.getMessage());
}
public long size(String name) {
- synchronized(cache) {
+ synchronized (cache) {
Entry entry = (Entry)cache.get(zipName(name));
- return (entry != null)? entry.getSize(): 0;
+ return (entry != null) ? entry.getSize() : 0;
} // synchronized
}
public InputStream inputStream(String name)
- throws FileNotFoundException
- {
- synchronized(cache) {
+ throws FileNotFoundException {
+ synchronized (cache) {
Entry entry = (Entry)cache.get(zipName(name));
- return (entry != null)? entry.getInputStream(): null;
+ return (entry != null) ? entry.getInputStream() : null;
} // synchronized
}
public OutputStream outputStream(String name)
- throws IOException
- {
+ throws IOException {
return getFileEntry(zipName(name)).getOutputStream();
}
@@ -589,19 +606,18 @@ System.out.println(" exception: " + ioe.getMessage());
// This only means that you should define how the file should be locked
// to the outside world--perhaps it does not need to be.
public void lock(String name)
- throws IOException
- {
-/*
- File file = getFile(name);
- if (file.exists() == true && file.canWrite() == false) {
- IOException ioe = new IOException("file " + file +
- " could not be locked");
- ErrorManager.getDefault().annotate(ioe, NbBundle.getMessage(
- OpenOfficeDocFileSystem.class, "EXC_file_could_not_be_locked",
- file.getName(), getDisplayName(), file.getPath()));
- throw ioe;
- }
-*/
+ throws IOException {
+ /*
+ File file = getFile(name);
+ if (file.exists() == true && file.canWrite() == false) {
+ IOException ioe = new IOException("file " + file +
+ " could not be locked");
+ ErrorManager.getDefault().annotate(ioe, NbBundle.getMessage(
+ OpenOfficeDocFileSystem.class, "EXC_file_could_not_be_locked",
+ file.getName(), getDisplayName(), file.getPath()));
+ throw ioe;
+ }
+ */
}
public void unlock(String name) {
@@ -620,80 +636,90 @@ System.out.println(" exception: " + ioe.getMessage());
* Operations that change the available files.
*/
private class ChangeImpl
- implements Change
- {
+ implements Change {
public void createFolder(String name)
- throws IOException
- {
- synchronized(cache) {
+ throws IOException {
+ synchronized (cache) {
String zname = zipName(name);
- if(cache.get(zname) != null) {
+
+ if (cache.get(zname) != null) {
throw new IOException(
"cannot create new folder: " + name); // I18N
}
+
getFolderEntry(zname);
} // synchronized
}
public void createData(String name)
- throws IOException
- {
- synchronized(cache) {
+ throws IOException {
+ synchronized (cache) {
String zname = zipName(name);
- if(cache.get(zname) != null) {
+
+ if (cache.get(zname) != null) {
throw new IOException(
"cannot create new data: " + name); // I18N
}
+
OutputStream os = getFileEntry(zname).getOutputStream();
os.close();
} // synchronized
}
public void rename(String oldName, String newName)
- throws IOException
- {
+ throws IOException {
String oname = zipName(oldName);
String nname = zipName(newName);
- if((oname.length() == 0) || (nname.length() == 0)) {
+
+ if ((oname.length() == 0) || (nname.length() == 0)) {
throw new IOException(
"cannot move or rename the root folder"); // I18N
}
- synchronized(cache) {
- if(cache.get(nname) != null) {
+
+ synchronized (cache) {
+ if (cache.get(nname) != null) {
throw new IOException(
"target file/folder " + newName + " exists"); // I18N
}
+
Entry entry = (Entry)cache.get(oname);
- if(entry == null) {
+
+ if (entry == null) {
throw new IOException(
"there is no such a file/folder " + oldName); // I18N
}
- if(entry.isReadOnly()) {
+
+ if (entry.isReadOnly()) {
throw new IOException(
"file/folder " + oldName + " is readonly"); // I18N
}
+
entry.rename(nname);
- if(!editableStrategy.evaluate(entry)) {
+
+ if (!editableStrategy.evaluate(entry)) {
entry.rename(oname);
throw new IOException(
"cannot create file/folder"); // I18N
}
+
cache.remove(oname);
cache.put(entry.getName(), entry);
} // synchronized
}
public void delete(String name)
- throws IOException
- {
+ throws IOException {
String zname = zipName(name);
- if(zname.length() == 0) {
+
+ if (zname.length() == 0) {
throw new IOException(
"cannot delete the root folder"); // I18N
}
- synchronized(cache) {
+
+ synchronized (cache) {
Entry entry = (Entry)cache.remove(zname);
- if(entry != null) {
+
+ if (entry != null) {
// BUG: this is the design bug. Cache has to
// remember that the entry was removed.
isModified = true;
@@ -707,17 +733,17 @@ System.out.println(" exception: " + ioe.getMessage());
* Operation which provides the directory structure.
*/
private class ListImpl
- implements List
- {
- public String[] children(String name)
- {
+ implements List {
+ public String[] children(String name) {
String[] children = null;
- synchronized(cache) {
+
+ synchronized (cache) {
String zname = zipName(name);
Entry entry = (Entry)cache.get(zname);
- if(entry != null) {
+
+ if (entry != null) {
// real zip file entry
- if(entry.isFolder()) {
+ if (entry.isFolder()) {
childrenStrategy.setParent(entry.getName());
}
} else {
@@ -725,9 +751,11 @@ System.out.println(" exception: " + ioe.getMessage());
// (portion of the path of a real zip file entry)
childrenStrategy.setParent(zname);
}
+
scanDocument(childrenStrategy);
children = childrenStrategy.getChildren();
} // synchronize
+
return children;
}
@@ -781,8 +809,7 @@ System.out.println(" exception: " + ioe.getMessage());
/* -----------------------------------------------------------
* This interface hides an action will be performed on an entry.
*/
- private interface Strategy
- {
+ private interface Strategy {
boolean evaluate(Entry entry);
}
@@ -790,17 +817,14 @@ System.out.println(" exception: " + ioe.getMessage());
* Recognizes editable (read-write) entires
*/
private class EditableStrategy
- implements Strategy
- {
+ implements Strategy {
private String scope;
- public EditableStrategy(String scope)
- {
+ public EditableStrategy(String scope) {
this.scope = scope;
}
- public boolean evaluate(Entry entry)
- {
+ public boolean evaluate(Entry entry) {
// recognizes all entries in a subtree of the
// 'scope' as editable entries
return entry && entry.getName().startsWith(scope);
@@ -811,55 +835,58 @@ System.out.println(" exception: " + ioe.getMessage());
* Recognizes and accumulates immediate children of the parent.
*/
private class ChildrenStrategy
- implements Strategy
- {
+ implements Strategy {
private String parent;
private Collection children = new HashSet();
- public void setParent(String name)
- {
- parent = (name.length() > 0)? (name + SEPARATOR): "";
- if(children == null)
+ public void setParent(String name) {
+ parent = (name.length() > 0) ? (name + SEPARATOR) : "";
+
+ if (children == null)
children = (java.util.List)new LinkedList();
+
children.clear();
}
- public boolean evaluate(Entry entry)
- {
+ public boolean evaluate(Entry entry) {
// do not accept "children" of a file
// ignore "read only" part of the filesystem
- if(!entry.isReadOnly()) {
+ if (!entry.isReadOnly()) {
// identify a child
- if( (entry.getName().length() > 0) &&
- (entry.getName().startsWith(parent)))
- {
+ if ((entry.getName().length() > 0) &&
+ (entry.getName().startsWith(parent))) {
// identify an immediate child
String child = entry.getName();
- if(parent.length() > 0) {
+
+ if (parent.length() > 0) {
child = entry.getName().substring(parent.length());
}
+
int idx = child.indexOf(SEPARATOR);
- if(idx > 0) // more path elements ahead
+
+ if (idx > 0) // more path elements ahead
child = child.substring(0, idx);
+
return children.add(child);
}
}
+
return false;
}
- public int countChildren()
- {
+ public int countChildren() {
return children.size();
}
- public String[] getChildren()
- {
+ public String[] getChildren() {
String[] chn = new String[children.size()];
Iterator itr = children.iterator();
int idx = 0;
- while(itr.hasNext()) {
+
+ while (itr.hasNext()) {
chn[idx++] = (String)itr.next();
}
+
return chn;
}
}
@@ -868,18 +895,15 @@ System.out.println(" exception: " + ioe.getMessage());
* Recognizes cache entries which have to be save into new archive.
*/
private class ModifiedStrategy
- implements Strategy
- {
+ implements Strategy {
private boolean modified;
- public boolean evaluate(Entry entry)
- {
+ public boolean evaluate(Entry entry) {
modified |= entry.isModified();
return entry.isModified();
}
- public boolean isModified()
- {
+ public boolean isModified() {
return modified;
}
}
@@ -888,35 +912,33 @@ System.out.println(" exception: " + ioe.getMessage());
* Saves each entry in the filesystem cache.
*/
private class SaveStrategy
- implements Strategy
- {
+ implements Strategy {
ZipOutputStream docos;
IOException ioexp;
public SaveStrategy(File newdoc)
- throws IOException
- {
+ throws IOException {
docos = new ZipOutputStream(new FileOutputStream(newdoc));
ioexp = null; // success by default
}
- public boolean evaluate(Entry entry)
- {
- if(entry.getName().length() == 0)
+ public boolean evaluate(Entry entry) {
+ if (entry.getName().length() == 0)
return false;
+
try {
entry.save(docos);
- } catch(IOException ioe) {
- if(ioexp == null)
+ } catch (IOException ioe) {
+ if (ioexp == null)
ioexp = ioe;
}
+
return true;
}
public void close()
- throws IOException
- {
- if(docos != null) {
+ throws IOException {
+ if (docos != null) {
try {
docos.close();
} catch (IOException ioe) {
@@ -924,7 +946,8 @@ System.out.println(" exception: " + ioe.getMessage());
} finally {
docos = null;
}
- if(ioexp != null) {
+
+ if (ioexp != null) {
throw ioexp;
}
}
@@ -935,15 +958,14 @@ System.out.println(" exception: " + ioe.getMessage());
* Cleans each entiry in the filesystem cache.
*/
private class CleanStrategy
- implements Strategy
- {
- public boolean evaluate(Entry entry)
- {
+ implements Strategy {
+ public boolean evaluate(Entry entry) {
try {
entry.clean();
- } catch(java.lang.Exception exp) {
+ } catch (java.lang.Exception exp) {
// sorry! can do nothing about it.
}
+
return true;
}
}
@@ -951,25 +973,24 @@ System.out.println(" exception: " + ioe.getMessage());
/* -----------------------------------------------------------
* ReadOnly cache entry
*/
- private class Entry
- {
+ private class Entry {
private String name;
private boolean folder;
private long size;
private long time;
private File node; // data files only
- public Entry(ZipEntry entry)
- {
- if(entry != null) {
+ public Entry(ZipEntry entry) {
+ if (entry != null) {
name = entry.getName();
folder = entry.isDirectory();
size = entry.getSize();
time = entry.getTime();
+
// removes tail file separator from a folder name
- if(folder && name.endsWith(SEPARATOR)) {
+ if (folder && name.endsWith(SEPARATOR)) {
name = name.substring(
- 0, name.length() - SEPARATOR.length());
+ 0, name.length() - SEPARATOR.length());
}
} else {
// 'null' is special cace of root folder
@@ -980,65 +1001,56 @@ System.out.println(" exception: " + ioe.getMessage());
}
}
- public boolean isReadOnly()
- {
+ public boolean isReadOnly() {
return true;
}
- public boolean isFolder()
- {
+ public boolean isFolder() {
return folder;
}
- public boolean isModified()
- {
+ public boolean isModified() {
return false;
}
- public String getName()
- {
+ public String getName() {
return name;
}
- public long getSize()
- {
+ public long getSize() {
return size;
}
- public long getTime()
- {
+ public long getTime() {
// adjust last modified time to the java.io.File
- return (time >= 0)? time: 0;
+ return (time >= 0) ? time : 0;
}
public InputStream getInputStream()
- throws FileNotFoundException
- {
+ throws FileNotFoundException {
return !isFolder() ? new FileInputStream(getFile()) : null;
}
public OutputStream getOutputStream()
- throws IOException
- {
+ throws IOException {
return null;
}
public void rename(String name)
- throws IOException
- {
+ throws IOException {
// BUG: this is the design bug. Cache has to manage such kind
// of operation in order to keep the data integrity.
this.name = name;
}
public void save(ZipOutputStream arch)
- throws IOException
- {
+ throws IOException {
InputStream is = null;
ZipEntry entry = new ZipEntry(
- getName() + ((isFolder())? SEPARATOR: ""));
+ getName() + ((isFolder()) ? SEPARATOR : ""));
+
try {
- if(isFolder()) {
+ if (isFolder()) {
// folder
entry.setMethod(ZipEntry.STORED);
entry.setSize(0);
@@ -1048,55 +1060,56 @@ System.out.println(" exception: " + ioe.getMessage());
arch.putNextEntry(entry);
} else {
// file
- if(!isModified())
+ if (!isModified())
entry.setTime(getTime());
else
entry.setTime(node.lastModified());
+
arch.putNextEntry(entry);
is = getInputStream();
FileUtil.copy(is, arch);
}
} finally {
// close streams
- if(is != null) {
+ if (is != null) {
try {
is.close();
- } catch(java.io.IOException ioe) {
+ } catch (java.io.IOException ioe) {
// sorry! can do nothing about it.
}
}
- if(arch != null)
+
+ if (arch != null)
arch.closeEntry();
}
}
public void clean()
- throws IOException
- {
- if(node != null)
+ throws IOException {
+ if (node != null)
node.delete();
}
- public String toString()
- {
+ public String toString() {
return (
- ((isReadOnly())? "RO ": "RW ") +
- ((isFolder())? "D": "F") +
- " \"" + getName() + "\"");
+ ((isReadOnly()) ? "RO " : "RW ") +
+ ((isFolder()) ? "D" : "F") +
+ " \"" + getName() + "\"");
}
/* package */ File getFile()
- throws FileNotFoundException
- {
- if(node == null) {
+ throws FileNotFoundException {
+ if (node == null) {
try {
node = File.createTempFile(TMP_FILE_PREF, TMP_FILE_SUFX);
- // copy the file from archive to the cache
- OutputStream nos = null;
- InputStream zis = null;
+ // copy the file from archive to the cache
+ OutputStream nos = null;
+ InputStream zis = null;
+
try {
ZipEntry entry = zipFile.getEntry(getName());
- if(entry != null) {
+
+ if (entry != null) {
// copy existing file to the cache
zis = zipFile.getInputStream(entry);
nos = new FileOutputStream(node);
@@ -1104,28 +1117,31 @@ System.out.println(" exception: " + ioe.getMessage());
}
} finally {
// close streams
- if(nos != null) {
+ if (nos != null) {
try {
nos.close();
- } catch(java.io.IOException ioe) {
+ } catch (java.io.IOException ioe) {
}
}
- if(zis != null) {
+
+ if (zis != null) {
try {
zis.close();
- } catch(java.io.IOException ioe) {
+ } catch (java.io.IOException ioe) {
}
}
}
- } catch(java.lang.Exception exp) {
+ } catch (java.lang.Exception exp) {
// delete cache file
- if(node != null)
+ if (node != null)
node.delete();
+
node = null;
throw new FileNotFoundException(
"cannot access file: " + getName()); // I18N
}
}
+
return node;
}
@@ -1135,36 +1151,30 @@ System.out.println(" exception: " + ioe.getMessage());
* ReadWrite cache entry
*/
private class ReadWriteEntry
- extends Entry
- {
+ extends Entry {
private boolean modified;
// 'null' is special cace of root folder
- public ReadWriteEntry(ZipEntry entry)
- {
+ public ReadWriteEntry(ZipEntry entry) {
super(entry);
}
- public boolean isReadOnly()
- {
+ public boolean isReadOnly() {
return false;
}
- public boolean isModified()
- {
+ public boolean isModified() {
return modified;
}
public void rename(String name)
- throws IOException
- {
+ throws IOException {
modified = true;
super.rename(name);
}
public OutputStream getOutputStream()
- throws IOException
- {
+ throws IOException {
modified = true;
return !isFolder() ? new FileOutputStream(getFile()) : null;
}
diff --git a/scripting/java/org/openoffice/netbeans/modules/office/filesystem/OpenOfficeDocFileSystemBeanInfo.java b/scripting/java/org/openoffice/netbeans/modules/office/filesystem/OpenOfficeDocFileSystemBeanInfo.java
index 4e4b8fb54404..ad3d18e154db 100644
--- a/scripting/java/org/openoffice/netbeans/modules/office/filesystem/OpenOfficeDocFileSystemBeanInfo.java
+++ b/scripting/java/org/openoffice/netbeans/modules/office/filesystem/OpenOfficeDocFileSystemBeanInfo.java
@@ -31,8 +31,7 @@ import org.openide.util.Utilities;
* Description of the OpenOffice.org Document filesystem.
*/
public class OpenOfficeDocFileSystemBeanInfo
- extends SimpleBeanInfo
-{
+ extends SimpleBeanInfo {
private static String ICONLOCATION =
"org/openoffice/netbeans/modules/office/resources";
private static String COLORICON16NAME =
@@ -43,49 +42,47 @@ public class OpenOfficeDocFileSystemBeanInfo
/**
* Retrieves an additional bean information.
*/
- public BeanInfo[] getAdditionalBeanInfo()
- {
+ public BeanInfo[] getAdditionalBeanInfo() {
try {
return new BeanInfo[] {
- Introspector.getBeanInfo(FileSystem.class)
- };
+ Introspector.getBeanInfo(FileSystem.class)
+ };
} catch (IntrospectionException ie) {
ErrorManager.getDefault().notify(ie);
return null;
}
}
-/*
- // If you have a visual dialog to customize configuration of the
- // filesystem:
- public BeanDescriptor getBeanDescriptor()
- {
- return new BeanDescriptor(OpenOfficeDocFileSystem.class,
- OpenOfficeDocFileSystemCustomizer.class);
- }
-*/
+ /*
+ // If you have a visual dialog to customize configuration of the
+ // filesystem:
+ public BeanDescriptor getBeanDescriptor()
+ {
+ return new BeanDescriptor(OpenOfficeDocFileSystem.class,
+ OpenOfficeDocFileSystemCustomizer.class);
+ }
+ */
/**
* Retrieves bean property descriptors.
*/
- public PropertyDescriptor[] getPropertyDescriptors()
- {
+ public PropertyDescriptor[] getPropertyDescriptors() {
try {
// Included only to make it a writable property (it is read-only
// in FileSystem):
PropertyDescriptor readOnly = new PropertyDescriptor(
"readOnly", OpenOfficeDocFileSystem.class);
readOnly.setDisplayName(NbBundle.getMessage(
- OpenOfficeDocFileSystemBeanInfo.class, "PROP_readOnly"));
+ OpenOfficeDocFileSystemBeanInfo.class, "PROP_readOnly"));
readOnly.setShortDescription(NbBundle.getMessage(
- OpenOfficeDocFileSystemBeanInfo.class, "HINT_readOnly"));
+ OpenOfficeDocFileSystemBeanInfo.class, "HINT_readOnly"));
// This could be whatever properties you use to configure the
// filesystem:
PropertyDescriptor document = new PropertyDescriptor(
"Document", OpenOfficeDocFileSystem.class);
document.setDisplayName(NbBundle.getMessage(
- OpenOfficeDocFileSystemBeanInfo.class, "PROP_document"));
+ OpenOfficeDocFileSystemBeanInfo.class, "PROP_document"));
document.setShortDescription(NbBundle.getMessage(
- OpenOfficeDocFileSystemBeanInfo.class, "HINT_document"));
+ OpenOfficeDocFileSystemBeanInfo.class, "HINT_document"));
// Request to the property editor that it be permitted only to
// choose directories:
document.setValue("directories", Boolean.FALSE); // NOI18N
@@ -101,9 +98,8 @@ public class OpenOfficeDocFileSystemBeanInfo
/**
* Retrieves an icon by the icon type.
*/
- public Image getIcon(int type)
- {
- if((type == BeanInfo.ICON_COLOR_16x16) ||
+ public Image getIcon(int type) {
+ if ((type == BeanInfo.ICON_COLOR_16x16) ||
(type == BeanInfo.ICON_MONO_16x16)) {
return Utilities.loadImage(COLORICON16NAME);
} else {
diff --git a/scripting/java/org/openoffice/netbeans/modules/office/loader/OfficeDocumentDataLoader.java b/scripting/java/org/openoffice/netbeans/modules/office/loader/OfficeDocumentDataLoader.java
index d47481ec39d5..268c6054b2bb 100644
--- a/scripting/java/org/openoffice/netbeans/modules/office/loader/OfficeDocumentDataLoader.java
+++ b/scripting/java/org/openoffice/netbeans/modules/office/loader/OfficeDocumentDataLoader.java
@@ -59,6 +59,7 @@ public class OfficeDocumentDataLoader extends UniFileLoader {
protected FileObject findPrimaryFile(FileObject fo) {
ExtensionList extensions = getExtensions();
+
if (!extensions.isRegistered(fo))
return null;
@@ -67,32 +68,32 @@ public class OfficeDocumentDataLoader extends UniFileLoader {
try {
jarFs.setJarFile(document);
- }
- catch (IOException e) {
+ } catch (IOException e) {
return null;
- }
- catch (Exception e) {
+ } catch (Exception e) {
return null;
}
+
return fo;
}
protected SystemAction[] defaultActions() {
return new SystemAction[] {
- SystemAction.get(OpenAction.class),
- null,
- SystemAction.get(CutAction.class),
- SystemAction.get(CopyAction.class),
- SystemAction.get(PasteAction.class),
- null,
- SystemAction.get(DeleteAction.class),
- SystemAction.get(RenameAction.class),
- null,
- SystemAction.get(PropertiesAction.class),
- };
+ SystemAction.get(OpenAction.class),
+ null,
+ SystemAction.get(CutAction.class),
+ SystemAction.get(CopyAction.class),
+ SystemAction.get(PasteAction.class),
+ null,
+ SystemAction.get(DeleteAction.class),
+ SystemAction.get(RenameAction.class),
+ null,
+ SystemAction.get(PropertiesAction.class),
+ };
}
- protected MultiDataObject createMultiObject(FileObject primaryFile) throws DataObjectExistsException, IOException {
+ protected MultiDataObject createMultiObject(FileObject primaryFile) throws
+ DataObjectExistsException, IOException {
return new OfficeDocumentDataObject(primaryFile, this);
}
}
diff --git a/scripting/java/org/openoffice/netbeans/modules/office/loader/OfficeDocumentDataNode.java b/scripting/java/org/openoffice/netbeans/modules/office/loader/OfficeDocumentDataNode.java
index 91f393e5d176..32d438f1f3c2 100644
--- a/scripting/java/org/openoffice/netbeans/modules/office/loader/OfficeDocumentDataNode.java
+++ b/scripting/java/org/openoffice/netbeans/modules/office/loader/OfficeDocumentDataNode.java
@@ -36,7 +36,7 @@ public class OfficeDocumentDataNode extends DataNode {
public OfficeDocumentDataNode(OfficeDocumentDataObject obj) {
this(obj, new OfficeDocumentChildren((OfficeDocumentCookie)
- obj.getCookie(OfficeDocumentCookie.class)));
+ obj.getCookie(OfficeDocumentCookie.class)));
}
public OfficeDocumentDataNode(OfficeDocumentDataObject obj, Children ch) {
@@ -55,27 +55,32 @@ public class OfficeDocumentDataNode extends DataNode {
if (copies != null) {
for (int i = 0; i < copies.length; i++) {
if (copies[i] instanceof ParcelDataNode) {
- File source = FileUtil.toFile(((ParcelDataNode)copies[i]).getDataObject().getPrimaryFile());
+ File source = FileUtil.toFile(((ParcelDataNode)
+ copies[i]).getDataObject().getPrimaryFile());
File target = FileUtil.toFile(getDataObject().getPrimaryFile());
if (source.exists() && source.canRead() &&
target.exists() && target.canWrite()) {
- ls.add(new ParcelDataNode.ParcelPasteType((ParcelDataNode)copies[i], target, false));
+ ls.add(new ParcelDataNode.ParcelPasteType((ParcelDataNode)copies[i], target,
+ false));
}
}
}
}
Node[] moves = NodeTransfer.nodes(t, NodeTransfer.MOVE);
+
if (moves != null) {
for (int i = 0; i < moves.length; i++) {
if (moves[i] instanceof ParcelDataNode) {
- File source = FileUtil.toFile(((ParcelDataNode)moves[i]).getDataObject().getPrimaryFile());
+ File source = FileUtil.toFile(((ParcelDataNode)
+ moves[i]).getDataObject().getPrimaryFile());
File target = FileUtil.toFile(getDataObject().getPrimaryFile());
if (source.exists() && source.canRead() &&
target.exists() && target.canWrite()) {
- ls.add(new ParcelDataNode.ParcelPasteType((ParcelDataNode)moves[i], target, true));
+ ls.add(new ParcelDataNode.ParcelPasteType((ParcelDataNode)moves[i], target,
+ true));
}
}
}
diff --git a/scripting/java/org/openoffice/netbeans/modules/office/loader/OfficeDocumentDataObject.java b/scripting/java/org/openoffice/netbeans/modules/office/loader/OfficeDocumentDataObject.java
index 23f5fd6e22ea..742b7d882968 100644
--- a/scripting/java/org/openoffice/netbeans/modules/office/loader/OfficeDocumentDataObject.java
+++ b/scripting/java/org/openoffice/netbeans/modules/office/loader/OfficeDocumentDataObject.java
@@ -29,7 +29,8 @@ import org.openoffice.netbeans.modules.office.actions.*;
public class OfficeDocumentDataObject extends MultiDataObject {
- public OfficeDocumentDataObject(FileObject pf, OfficeDocumentDataLoader loader) throws DataObjectExistsException {
+ public OfficeDocumentDataObject(FileObject pf,
+ OfficeDocumentDataLoader loader) throws DataObjectExistsException {
super(pf, loader);
init();
}
diff --git a/scripting/java/org/openoffice/netbeans/modules/office/loader/ParcelContentsFolder.java b/scripting/java/org/openoffice/netbeans/modules/office/loader/ParcelContentsFolder.java
index 53fa63199517..9243df8c7341 100644
--- a/scripting/java/org/openoffice/netbeans/modules/office/loader/ParcelContentsFolder.java
+++ b/scripting/java/org/openoffice/netbeans/modules/office/loader/ParcelContentsFolder.java
@@ -41,8 +41,9 @@ import org.openoffice.netbeans.modules.office.actions.ParcelFolderCookie;
import org.openoffice.netbeans.modules.office.utils.PackageRemover;
public class ParcelContentsFolder extends DataFolder {
- public ParcelContentsFolder(FileObject pf, ParcelContentsFolderDataLoader loader)
- throws DataObjectExistsException {
+ public ParcelContentsFolder(FileObject pf,
+ ParcelContentsFolderDataLoader loader)
+ throws DataObjectExistsException {
super(pf, loader);
}
@@ -59,11 +60,11 @@ public class ParcelContentsFolder extends DataFolder {
DataFolder contents = (DataFolder)getDataObject();
ParcelFolderCookie cookie =
(ParcelFolderCookie)contents.getFolder().
- getCookie(ParcelFolderCookie.class);
+ getCookie(ParcelFolderCookie.class);
String language = cookie.getLanguage();
ParcelContentsFolder.createEmptyScript(contents,
- language);
+ language);
}
};
return newtypes;
@@ -76,11 +77,9 @@ public class ParcelContentsFolder extends DataFolder {
if (language.toLowerCase().equals("java")) {
sourceFile += ".java";
- }
- else if (language.toLowerCase().equals("beanshell")) {
+ } else if (language.toLowerCase().equals("beanshell")) {
sourceFile += ".bsh";
- }
- else {
+ } else {
NotifyDescriptor d = new NotifyDescriptor.Message(
"Language not defined for this Parcel Folder");
TopManager.getDefault().notify(d);
@@ -89,36 +88,37 @@ public class ParcelContentsFolder extends DataFolder {
FileSystem fs = Repository.getDefault().getDefaultFileSystem();
DataObject result = null;
+
try {
DataObject dObj = DataObject.find(fs.findResource(sourceFile));
result = dObj.createFromTemplate(parent);
- }
- catch (IOException ioe) {
+ } catch (IOException ioe) {
ErrorManager.getDefault().notify(ioe);
}
FileObject fo = result.getPrimaryFile();
+
if (fo.getExt().equals("java")) {
FileLock lock = null;
+
try {
PackageRemover.removeDeclaration(FileUtil.toFile(fo));
// IssueZilla 11986 - rename the FileObject
// so the JavaNode is resynchronized
lock = fo.lock();
+
if (lock != null) {
fo.rename(lock, fo.getName(), fo.getExt());
}
- }
- catch (IOException ioe) {
+ } catch (IOException ioe) {
NotifyDescriptor d = new NotifyDescriptor.Message(
- "Error removing package declaration from file: " +
- fo.getNameExt() +
- ". You should manually remove this declaration " +
- "before building the Parcel Recipe");
+ "Error removing package declaration from file: " +
+ fo.getNameExt() +
+ ". You should manually remove this declaration " +
+ "before building the Parcel Recipe");
TopManager.getDefault().notify(d);
- }
- finally {
+ } finally {
if (lock != null) {
lock.releaseLock();
}
diff --git a/scripting/java/org/openoffice/netbeans/modules/office/loader/ParcelContentsFolderDataLoader.java b/scripting/java/org/openoffice/netbeans/modules/office/loader/ParcelContentsFolderDataLoader.java
index 4406f3f903c8..4943a4f5d75e 100644
--- a/scripting/java/org/openoffice/netbeans/modules/office/loader/ParcelContentsFolderDataLoader.java
+++ b/scripting/java/org/openoffice/netbeans/modules/office/loader/ParcelContentsFolderDataLoader.java
@@ -55,19 +55,20 @@ public class ParcelContentsFolderDataLoader extends UniFileLoader {
protected SystemAction[] defaultActions() {
return new SystemAction[] {
- SystemAction.get(PasteAction.class),
- SystemAction.get(NewAction.class),
- // null,
- // SystemAction.get(PropertiesAction.class),
- };
+ SystemAction.get(PasteAction.class),
+ SystemAction.get(NewAction.class),
+ // null,
+ // SystemAction.get(PropertiesAction.class),
+ };
}
protected MultiDataObject createMultiObject(FileObject primaryFile)
- throws DataObjectExistsException {
+ throws DataObjectExistsException {
return new ParcelContentsFolder(primaryFile, this);
}
- protected MultiDataObject.Entry createPrimaryEntry(MultiDataObject obj, FileObject primaryFile) {
+ protected MultiDataObject.Entry createPrimaryEntry(MultiDataObject obj,
+ FileObject primaryFile) {
return new FileEntry.Folder(obj, primaryFile);
}
}
diff --git a/scripting/java/org/openoffice/netbeans/modules/office/loader/ParcelDataLoader.java b/scripting/java/org/openoffice/netbeans/modules/office/loader/ParcelDataLoader.java
index 14e968668f71..86e86742c43e 100644
--- a/scripting/java/org/openoffice/netbeans/modules/office/loader/ParcelDataLoader.java
+++ b/scripting/java/org/openoffice/netbeans/modules/office/loader/ParcelDataLoader.java
@@ -57,19 +57,20 @@ public class ParcelDataLoader extends UniFileLoader {
protected SystemAction[] defaultActions() {
return new SystemAction[] {
- SystemAction.get(DeployParcelAction.class),
- null,
- SystemAction.get(CutAction.class),
- SystemAction.get(CopyAction.class),
- null,
- SystemAction.get(DeleteAction.class),
- SystemAction.get(RenameAction.class),
- null,
- SystemAction.get(PropertiesAction.class),
- };
+ SystemAction.get(DeployParcelAction.class),
+ null,
+ SystemAction.get(CutAction.class),
+ SystemAction.get(CopyAction.class),
+ null,
+ SystemAction.get(DeleteAction.class),
+ SystemAction.get(RenameAction.class),
+ null,
+ SystemAction.get(PropertiesAction.class),
+ };
}
- protected MultiDataObject createMultiObject(FileObject primaryFile) throws DataObjectExistsException, IOException {
+ protected MultiDataObject createMultiObject(FileObject primaryFile) throws
+ DataObjectExistsException, IOException {
return new ParcelDataObject(primaryFile, this);
}
}
diff --git a/scripting/java/org/openoffice/netbeans/modules/office/loader/ParcelDataNode.java b/scripting/java/org/openoffice/netbeans/modules/office/loader/ParcelDataNode.java
index 5865f32c2803..cb51b982e7c4 100644
--- a/scripting/java/org/openoffice/netbeans/modules/office/loader/ParcelDataNode.java
+++ b/scripting/java/org/openoffice/netbeans/modules/office/loader/ParcelDataNode.java
@@ -55,7 +55,7 @@ public class ParcelDataNode extends DataNode {
boolean isCut = false;
public ParcelPasteType(ParcelDataNode sourceParcel,
- File targetDocument, boolean isCut) {
+ File targetDocument, boolean isCut) {
this.sourceParcel = sourceParcel;
this.targetDocument = targetDocument;
this.isCut = isCut;
@@ -68,13 +68,13 @@ public class ParcelDataNode extends DataNode {
if (isCut) {
FileObject fo = sourceParcel.getDataObject().getPrimaryFile();
+
try {
fo.delete();
- }
- catch (IOException ioe) {}
+ } catch (IOException ioe) {}
+
return ExTransferable.EMPTY;
- }
- else {
+ } else {
return null;
}
}
diff --git a/scripting/java/org/openoffice/netbeans/modules/office/loader/ParcelDataObject.java b/scripting/java/org/openoffice/netbeans/modules/office/loader/ParcelDataObject.java
index 83833d06b480..0c9cf1720ca3 100644
--- a/scripting/java/org/openoffice/netbeans/modules/office/loader/ParcelDataObject.java
+++ b/scripting/java/org/openoffice/netbeans/modules/office/loader/ParcelDataObject.java
@@ -31,7 +31,8 @@ import org.openoffice.netbeans.modules.office.actions.*;
*/
public class ParcelDataObject extends MultiDataObject {
- public ParcelDataObject(FileObject pf, ParcelDataLoader loader) throws DataObjectExistsException {
+ public ParcelDataObject(FileObject pf,
+ ParcelDataLoader loader) throws DataObjectExistsException {
super(pf, loader);
init();
}
diff --git a/scripting/java/org/openoffice/netbeans/modules/office/loader/ParcelDescriptorDataLoader.java b/scripting/java/org/openoffice/netbeans/modules/office/loader/ParcelDescriptorDataLoader.java
index 8f6083ae00d8..58b94c91031c 100644
--- a/scripting/java/org/openoffice/netbeans/modules/office/loader/ParcelDescriptorDataLoader.java
+++ b/scripting/java/org/openoffice/netbeans/modules/office/loader/ParcelDescriptorDataLoader.java
@@ -53,20 +53,21 @@ public class ParcelDescriptorDataLoader extends UniFileLoader {
protected SystemAction[] defaultActions() {
return new SystemAction[] {
- SystemAction.get(OpenAction.class),
- null,
- SystemAction.get(CutAction.class),
- SystemAction.get(CopyAction.class),
- SystemAction.get(PasteAction.class),
- null,
- SystemAction.get(DeleteAction.class),
- SystemAction.get(RenameAction.class),
- null,
- SystemAction.get(PropertiesAction.class),
- };
+ SystemAction.get(OpenAction.class),
+ null,
+ SystemAction.get(CutAction.class),
+ SystemAction.get(CopyAction.class),
+ SystemAction.get(PasteAction.class),
+ null,
+ SystemAction.get(DeleteAction.class),
+ SystemAction.get(RenameAction.class),
+ null,
+ SystemAction.get(PropertiesAction.class),
+ };
}
- protected MultiDataObject createMultiObject(FileObject primaryFile) throws DataObjectExistsException, IOException {
+ protected MultiDataObject createMultiObject(FileObject primaryFile) throws
+ DataObjectExistsException, IOException {
return new ParcelDescriptorDataObject(primaryFile, this);
}
}
diff --git a/scripting/java/org/openoffice/netbeans/modules/office/loader/ParcelDescriptorDataObject.java b/scripting/java/org/openoffice/netbeans/modules/office/loader/ParcelDescriptorDataObject.java
index c344830b1c27..f72735cfc2ad 100644
--- a/scripting/java/org/openoffice/netbeans/modules/office/loader/ParcelDescriptorDataObject.java
+++ b/scripting/java/org/openoffice/netbeans/modules/office/loader/ParcelDescriptorDataObject.java
@@ -34,18 +34,21 @@ public class ParcelDescriptorDataObject extends MultiDataObject {
private boolean canParse = false;
- public ParcelDescriptorDataObject(FileObject pf, ParcelDescriptorDataLoader loader) throws DataObjectExistsException {
+ public ParcelDescriptorDataObject(FileObject pf,
+ ParcelDescriptorDataLoader loader) throws DataObjectExistsException {
super(pf, loader);
init();
}
private void init() {
FileObject fo = getPrimaryFile();
+
if (FileUtil.toFile(fo) != null)
canParse = true;
CookieSet cookies = getCookieSet();
cookies.add(new ParcelDescriptorEditorSupport(this));
+
if (canParse)
cookies.add(new ParcelDescriptorParserSupport(getPrimaryFile()));
}
diff --git a/scripting/java/org/openoffice/netbeans/modules/office/loader/ParcelFolder.java b/scripting/java/org/openoffice/netbeans/modules/office/loader/ParcelFolder.java
index cb03c0c8f35d..a9f04564794f 100644
--- a/scripting/java/org/openoffice/netbeans/modules/office/loader/ParcelFolder.java
+++ b/scripting/java/org/openoffice/netbeans/modules/office/loader/ParcelFolder.java
@@ -47,7 +47,7 @@ public class ParcelFolder extends DataFolder {
public static final String LANGUAGE_ATTRIBUTE = "language";
public ParcelFolder(FileObject pf, ParcelFolderDataLoader loader)
- throws DataObjectExistsException {
+ throws DataObjectExistsException {
super(pf, loader);
CookieSet cookies = getCookieSet();
cookies.add(new ParcelFolderSupport(this));
@@ -74,10 +74,12 @@ public class ParcelFolder extends DataFolder {
super(pf.createNodeChildren(dataFilter));
location = (File)pf.getPrimaryFile().getAttribute(LOCATION);
+
if (location == null)
location = FileUtil.toFile(pf.getPrimaryFile());
String name = (String)pf.getPrimaryFile().getAttribute(FILTER);
+
if (name == null)
filter = DEFAULT_FILTER;
else {
@@ -91,10 +93,10 @@ public class ParcelFolder extends DataFolder {
ParcelFolderCookie cookie =
(ParcelFolderCookie)pf.getCookie(ParcelFolderCookie.class);
String s = cookie.getClasspath();
+
if (s != null) {
classpath = s;
- }
- else {
+ } else {
classpath = ".";
cookie.setClasspath(classpath);
}
@@ -111,6 +113,7 @@ public class ParcelFolder extends DataFolder {
public String getLanguage() {
if (language == null)
language = (String)getPrimaryFile().getAttribute(LANGUAGE);
+
return language;
}
@@ -121,6 +124,7 @@ public class ParcelFolder extends DataFolder {
sheet = super.createSheet();
props = sheet.get(Sheet.PROPERTIES);
+
if (props == null) {
props = Sheet.createPropertiesSet();
sheet.put(props);
@@ -139,24 +143,24 @@ public class ParcelFolder extends DataFolder {
}
private Node.Property createLocationProperty() {
- Node.Property prop =
- new PropertySupport.ReadWrite(LOCATION, File.class,
- "Location", "Output location of Parcel Zip File") {
- public void setValue(Object obj) {
- if (obj instanceof File) {
- location = (File)obj;
- try {
- getPrimaryFile().setAttribute(LOCATION, location);
- }
- catch (IOException ioe) {
- }
+ Node.Property prop =
+ new PropertySupport.ReadWrite(LOCATION, File.class,
+ "Location", "Output location of Parcel Zip File") {
+ public void setValue(Object obj) {
+ if (obj instanceof File) {
+ location = (File)obj;
+
+ try {
+ getPrimaryFile().setAttribute(LOCATION, location);
+ } catch (IOException ioe) {
}
}
+ }
- public Object getValue() {
- return location;
- }
- };
+ public Object getValue() {
+ return location;
+ }
+ };
prop.setValue("files", Boolean.FALSE);
return prop;
}
@@ -165,114 +169,114 @@ public class ParcelFolder extends DataFolder {
private Node.Property createLanguageProperty() {
Node.Property prop =
- new PropertySupport.ReadWrite(LANGUAGE, String.class,
- "Parcel Language", "Language of scripts in this Parcel") {
- public void setValue(Object obj) {
- if (obj instanceof String) {
- language = (String)obj;
-
- try {
- getPrimaryFile().setAttribute(LANGUAGE, language);
- }
- catch (IOException ioe) {
- }
+ new PropertySupport.ReadWrite(LANGUAGE, String.class,
+ "Parcel Language", "Language of scripts in this Parcel") {
+ public void setValue(Object obj) {
+ if (obj instanceof String) {
+ language = (String)obj;
+
+ try {
+ getPrimaryFile().setAttribute(LANGUAGE, language);
+ } catch (IOException ioe) {
}
}
+ }
- public Object getValue() {
- if (language == null)
- language = (String)getPrimaryFile().getAttribute(LANGUAGE);
- return language;
- }
+ public Object getValue() {
+ if (language == null)
+ language = (String)getPrimaryFile().getAttribute(LANGUAGE);
- public PropertyEditor getPropertyEditor() {
- return new PropertyEditorSupport() {
- public String[] getTags() {
- return languages;
- }
-
- public void setAsText(String text) {
- for (int i = 0; i < languages.length; i++)
- if (text.equals(languages[i]))
- this.setValue(languages[i]);
- }
-
- public String getAsText() {
- return (String)this.getValue();
- }
- };
- }
- };
+ return language;
+ }
+
+ public PropertyEditor getPropertyEditor() {
+ return new PropertyEditorSupport() {
+ public String[] getTags() {
+ return languages;
+ }
+
+ public void setAsText(String text) {
+ for (int i = 0; i < languages.length; i++)
+ if (text.equals(languages[i]))
+ this.setValue(languages[i]);
+ }
+
+ public String getAsText() {
+ return (String)this.getValue();
+ }
+ };
+ }
+ };
return prop;
}
private FileFilter[] availableFilters = new FileFilter[] {
- BinaryOnlyFilter.getInstance(), AllFilesFilter.getInstance()};
+ BinaryOnlyFilter.getInstance(), AllFilesFilter.getInstance()
+ };
private Node.Property createFilterProperty() {
Node.Property prop =
- new PropertySupport.ReadWrite(FILTER, String.class,
- "File Filter", "Files to be included in Parcel") {
- public void setValue(Object obj) {
- if (obj instanceof FileFilter) {
- filter = (FileFilter)obj;
-
- try {
- getPrimaryFile().setAttribute(FILTER, filter.toString());
- }
- catch (IOException ioe) {
- }
+ new PropertySupport.ReadWrite(FILTER, String.class,
+ "File Filter", "Files to be included in Parcel") {
+ public void setValue(Object obj) {
+ if (obj instanceof FileFilter) {
+ filter = (FileFilter)obj;
+
+ try {
+ getPrimaryFile().setAttribute(FILTER, filter.toString());
+ } catch (IOException ioe) {
}
}
+ }
- public Object getValue() {
- return filter;
- }
+ public Object getValue() {
+ return filter;
+ }
- public PropertyEditor getPropertyEditor() {
- return new PropertyEditorSupport() {
- public String[] getTags() {
- String[] tags = new String[availableFilters.length];
+ public PropertyEditor getPropertyEditor() {
+ return new PropertyEditorSupport() {
+ public String[] getTags() {
+ String[] tags = new String[availableFilters.length];
- for (int i = 0; i < availableFilters.length; i++)
- tags[i] = availableFilters[i].toString();
+ for (int i = 0; i < availableFilters.length; i++)
+ tags[i] = availableFilters[i].toString();
- return tags;
- }
+ return tags;
+ }
- public void setAsText(String text) {
- for (int i = 0; i < availableFilters.length; i++)
- if (text.equals(availableFilters[i].toString()))
- this.setValue(availableFilters[i]);
- }
+ public void setAsText(String text) {
+ for (int i = 0; i < availableFilters.length; i++)
+ if (text.equals(availableFilters[i].toString()))
+ this.setValue(availableFilters[i]);
+ }
- public String getAsText() {
- return this.getValue().toString();
- }
- };
- }
- };
+ public String getAsText() {
+ return this.getValue().toString();
+ }
+ };
+ }
+ };
return prop;
}
private Node.Property createClasspathProperty() {
- Node.Property prop =
- new PropertySupport.ReadWrite(CLASSPATH, String.class,
- "Classpath", "Classpath property for scripts in this parcel") {
- public void setValue(Object obj) {
- if (obj instanceof String) {
- classpath = (String)obj;
-
- ParcelFolderCookie cookie = (ParcelFolderCookie)
- getDataObject().getCookie(ParcelFolderCookie.class);
- cookie.setClasspath(classpath);
- }
+ Node.Property prop =
+ new PropertySupport.ReadWrite(CLASSPATH, String.class,
+ "Classpath", "Classpath property for scripts in this parcel") {
+ public void setValue(Object obj) {
+ if (obj instanceof String) {
+ classpath = (String)obj;
+
+ ParcelFolderCookie cookie = (ParcelFolderCookie)
+ getDataObject().getCookie(ParcelFolderCookie.class);
+ cookie.setClasspath(classpath);
}
+ }
- public Object getValue() {
- return classpath;
- }
- };
+ public Object getValue() {
+ return classpath;
+ }
+ };
return prop;
}
}
@@ -280,8 +284,10 @@ public class ParcelFolder extends DataFolder {
private class ParcelFolderFilter implements DataFilter {
public boolean acceptDataObject(DataObject dobj) {
String name = dobj.getPrimaryFile().getNameExt();
+
if (name.equals(ParcelZipper.PARCEL_DESCRIPTOR_XML))
return false;
+
return true;
}
}
diff --git a/scripting/java/org/openoffice/netbeans/modules/office/loader/ParcelFolderDataLoader.java b/scripting/java/org/openoffice/netbeans/modules/office/loader/ParcelFolderDataLoader.java
index df60b27561c1..965d11b18ce7 100644
--- a/scripting/java/org/openoffice/netbeans/modules/office/loader/ParcelFolderDataLoader.java
+++ b/scripting/java/org/openoffice/netbeans/modules/office/loader/ParcelFolderDataLoader.java
@@ -56,10 +56,13 @@ public class ParcelFolderDataLoader extends UniFileLoader {
return null;
FileObject contents = fo.getFileObject(ParcelZipper.CONTENTS_DIRNAME);
+
if (contents == null)
return null;
- FileObject descriptor = contents.getFileObject(ParcelZipper.PARCEL_DESCRIPTOR_XML);
+ FileObject descriptor = contents.getFileObject(
+ ParcelZipper.PARCEL_DESCRIPTOR_XML);
+
if (descriptor == null)
return null;
@@ -68,25 +71,27 @@ public class ParcelFolderDataLoader extends UniFileLoader {
protected SystemAction[] defaultActions() {
return new SystemAction[] {
- SystemAction.get(CompileParcelAction.class),
- SystemAction.get(BuildParcelAction.class),
- SystemAction.get(ConfigureParcelAction.class),
- null,
- SystemAction.get(CutAction.class),
- SystemAction.get(CopyAction.class),
- null,
- SystemAction.get(DeleteAction.class),
- SystemAction.get(RenameAction.class),
- null,
- SystemAction.get(PropertiesAction.class),
- };
+ SystemAction.get(CompileParcelAction.class),
+ SystemAction.get(BuildParcelAction.class),
+ SystemAction.get(ConfigureParcelAction.class),
+ null,
+ SystemAction.get(CutAction.class),
+ SystemAction.get(CopyAction.class),
+ null,
+ SystemAction.get(DeleteAction.class),
+ SystemAction.get(RenameAction.class),
+ null,
+ SystemAction.get(PropertiesAction.class),
+ };
}
- protected MultiDataObject createMultiObject(FileObject primaryFile) throws DataObjectExistsException, IOException {
+ protected MultiDataObject createMultiObject(FileObject primaryFile) throws
+ DataObjectExistsException, IOException {
return new ParcelFolder(primaryFile, this);
}
- protected MultiDataObject.Entry createPrimaryEntry(MultiDataObject obj, FileObject primaryFile) {
+ protected MultiDataObject.Entry createPrimaryEntry(MultiDataObject obj,
+ FileObject primaryFile) {
return new FileEntry.Folder(obj, primaryFile);
}
}
diff --git a/scripting/java/org/openoffice/netbeans/modules/office/nodes/OfficeDocumentChildren.java b/scripting/java/org/openoffice/netbeans/modules/office/nodes/OfficeDocumentChildren.java
index 01710f9bcaac..b5e939bc2811 100644
--- a/scripting/java/org/openoffice/netbeans/modules/office/nodes/OfficeDocumentChildren.java
+++ b/scripting/java/org/openoffice/netbeans/modules/office/nodes/OfficeDocumentChildren.java
@@ -48,16 +48,19 @@ public class OfficeDocumentChildren extends Children.Keys
}
Enumeration parcels = document.getParcels();
+
if (!parcels.hasMoreElements()) {
setKeys(Collections.EMPTY_SET);
return;
}
ArrayList keys = new ArrayList();
+
while (parcels.hasMoreElements()) {
String parcel = (String)parcels.nextElement();
keys.add(parcel);
}
+
setKeys(keys);
}
@@ -101,8 +104,8 @@ public class OfficeDocumentChildren extends Children.Keys
protected SystemAction[] createActions() {
return new SystemAction[] {
- SystemAction.get(DeleteAction.class),
- };
+ SystemAction.get(DeleteAction.class),
+ };
}
public HelpCtx getHelpCtx() {
@@ -116,12 +119,12 @@ public class OfficeDocumentChildren extends Children.Keys
public void destroy() throws IOException {
OfficeSettings settings = OfficeSettings.getDefault();
String message = "If you already have this document open in " +
- "Office, please close it before continuing. Click OK to " +
- "delete this parcel.";
+ "Office, please close it before continuing. Click OK to " +
+ "delete this parcel.";
if (settings.getWarnBeforeParcelDelete()) {
NagDialog warning = NagDialog.createConfirmationDialog(
- message, "Show this message in future", true);
+ message, "Show this message in future", true);
boolean result = warning.show();
@@ -131,6 +134,7 @@ public class OfficeDocumentChildren extends Children.Keys
if (!result)
return;
}
+
super.destroy();
document.removeParcel(name);
}
diff --git a/scripting/java/org/openoffice/netbeans/modules/office/nodes/ParcelDescriptorChildren.java b/scripting/java/org/openoffice/netbeans/modules/office/nodes/ParcelDescriptorChildren.java
index e8f6ef9003a7..52312ea03574 100644
--- a/scripting/java/org/openoffice/netbeans/modules/office/nodes/ParcelDescriptorChildren.java
+++ b/scripting/java/org/openoffice/netbeans/modules/office/nodes/ParcelDescriptorChildren.java
@@ -31,7 +31,8 @@ import org.openoffice.netbeans.modules.office.actions.ParcelDescriptorParserCook
/** List of children of a containing node.
* Remember to document what your permitted keys are!
*/
-public class ParcelDescriptorChildren extends Children.Keys implements ChangeListener {
+public class ParcelDescriptorChildren extends Children.Keys implements
+ ChangeListener {
private ParcelDescriptorParserCookie parserCookie = null;
@@ -51,8 +52,10 @@ public class ParcelDescriptorChildren extends Children.Keys implements ChangeLis
}
ArrayList keys = new ArrayList(len);
+
for (int i = 0; i < len; i++)
keys.add(nl.item(i));
+
setKeys(keys);
}
diff --git a/scripting/java/org/openoffice/netbeans/modules/office/nodes/ScriptNode.java b/scripting/java/org/openoffice/netbeans/modules/office/nodes/ScriptNode.java
index 91b4d97cb68f..861a4a4f1909 100644
--- a/scripting/java/org/openoffice/netbeans/modules/office/nodes/ScriptNode.java
+++ b/scripting/java/org/openoffice/netbeans/modules/office/nodes/ScriptNode.java
@@ -54,10 +54,10 @@ public class ScriptNode extends AbstractNode {
protected SystemAction[] createActions() {
return new SystemAction[] {
- SystemAction.get(ToolsAction.class),
- null,
- SystemAction.get(PropertiesAction.class),
- };
+ SystemAction.get(ToolsAction.class),
+ null,
+ SystemAction.get(PropertiesAction.class),
+ };
}
public HelpCtx getHelpCtx() {
@@ -75,12 +75,14 @@ public class ScriptNode extends AbstractNode {
protected Sheet createSheet() {
Sheet sheet = super.createSheet();
Sheet.Set props = sheet.get(Sheet.PROPERTIES);
+
if (props == null) {
props = Sheet.createPropertiesSet();
sheet.put(props);
}
org.openide.nodes.Node.Property prop = null;
+
if ((prop = getStringProperty(LOGICAL_NAME)) != null)
props.put(prop);
@@ -92,7 +94,8 @@ public class ScriptNode extends AbstractNode {
private org.openide.nodes.Node.Property getStringProperty(String name) {
NodeList nl = element.getElementsByTagName(name);
- if(nl.getLength() != 1)
+
+ if (nl.getLength() != 1)
return null;
Element nameElement = (Element)nl.item(0);
@@ -107,7 +110,7 @@ public class ScriptNode extends AbstractNode {
public StringProperty(ScriptNode sn, String name, String value) {
super(value, String.class, name,
- "The name of the java language method for this script");
+ "The name of the java language method for this script");
this.sn = sn;
this.name = name;
this.value = value;
diff --git a/scripting/java/org/openoffice/netbeans/modules/office/options/OfficeSettings.java b/scripting/java/org/openoffice/netbeans/modules/office/options/OfficeSettings.java
index a56cdfa97779..1caa8835b4f8 100644
--- a/scripting/java/org/openoffice/netbeans/modules/office/options/OfficeSettings.java
+++ b/scripting/java/org/openoffice/netbeans/modules/office/options/OfficeSettings.java
@@ -60,8 +60,7 @@ public class OfficeSettings extends SystemOption {
setOfficeDirectory(oi);
return;
}
- }
- catch (IOException ioe) {
+ } catch (IOException ioe) {
}
}
}
diff --git a/scripting/java/org/openoffice/netbeans/modules/office/options/OfficeSettingsBeanInfo.java b/scripting/java/org/openoffice/netbeans/modules/office/options/OfficeSettingsBeanInfo.java
index 63a386986896..a811ab855fd5 100644
--- a/scripting/java/org/openoffice/netbeans/modules/office/options/OfficeSettingsBeanInfo.java
+++ b/scripting/java/org/openoffice/netbeans/modules/office/options/OfficeSettingsBeanInfo.java
@@ -39,54 +39,53 @@ public class OfficeSettingsBeanInfo extends SimpleBeanInfo {
try {
PropertyDescriptor[] props = new PropertyDescriptor[] {
new PropertyDescriptor(OfficeSettings.OFFICE_DIRECTORY,
- OfficeSettings.class,
- "get" + OfficeSettings.OFFICE_DIRECTORY,
- "set" + OfficeSettings.OFFICE_DIRECTORY),
+ OfficeSettings.class,
+ "get" + OfficeSettings.OFFICE_DIRECTORY,
+ "set" + OfficeSettings.OFFICE_DIRECTORY),
new PropertyDescriptor(OfficeSettings.WARN_BEFORE_DOC_DEPLOY,
- OfficeSettings.class,
- "get" + OfficeSettings.WARN_BEFORE_DOC_DEPLOY,
- "set" + OfficeSettings.WARN_BEFORE_DOC_DEPLOY),
+ OfficeSettings.class,
+ "get" + OfficeSettings.WARN_BEFORE_DOC_DEPLOY,
+ "set" + OfficeSettings.WARN_BEFORE_DOC_DEPLOY),
new PropertyDescriptor(OfficeSettings.WARN_BEFORE_PARCEL_DELETE,
- OfficeSettings.class,
- "get" + OfficeSettings.WARN_BEFORE_PARCEL_DELETE,
- "set" + OfficeSettings.WARN_BEFORE_PARCEL_DELETE),
+ OfficeSettings.class,
+ "get" + OfficeSettings.WARN_BEFORE_PARCEL_DELETE,
+ "set" + OfficeSettings.WARN_BEFORE_PARCEL_DELETE),
new PropertyDescriptor(OfficeSettings.WARN_AFTER_DIR_DEPLOY,
- OfficeSettings.class,
- "get" + OfficeSettings.WARN_AFTER_DIR_DEPLOY,
- "set" + OfficeSettings.WARN_AFTER_DIR_DEPLOY),
+ OfficeSettings.class,
+ "get" + OfficeSettings.WARN_AFTER_DIR_DEPLOY,
+ "set" + OfficeSettings.WARN_AFTER_DIR_DEPLOY),
new PropertyDescriptor(OfficeSettings.WARN_BEFORE_MOUNT,
- OfficeSettings.class,
- "get" + OfficeSettings.WARN_BEFORE_MOUNT,
- "set" + OfficeSettings.WARN_BEFORE_MOUNT)
+ OfficeSettings.class,
+ "get" + OfficeSettings.WARN_BEFORE_MOUNT,
+ "set" + OfficeSettings.WARN_BEFORE_MOUNT)
};
props[0].setDisplayName(NbBundle.getMessage(
- OfficeSettingsBeanInfo.class, "PROP_OfficeDirectory"));
+ OfficeSettingsBeanInfo.class, "PROP_OfficeDirectory"));
props[0].setShortDescription(NbBundle.getMessage(
- OfficeSettingsBeanInfo.class, "HINT_OfficeDirectory"));
+ OfficeSettingsBeanInfo.class, "HINT_OfficeDirectory"));
props[0].setPropertyEditorClass(OfficeDirectoryEditor.class);
props[1].setDisplayName(NbBundle.getMessage(
- OfficeSettingsBeanInfo.class, "PROP_WarnBeforeDocDeploy"));
+ OfficeSettingsBeanInfo.class, "PROP_WarnBeforeDocDeploy"));
props[1].setShortDescription(NbBundle.getMessage(
- OfficeSettingsBeanInfo.class, "HINT_WarnBeforeDocDeploy"));
+ OfficeSettingsBeanInfo.class, "HINT_WarnBeforeDocDeploy"));
props[1].setHidden(true);
props[2].setDisplayName(NbBundle.getMessage(
- OfficeSettingsBeanInfo.class, "PROP_WarnAfterDirDeploy"));
+ OfficeSettingsBeanInfo.class, "PROP_WarnAfterDirDeploy"));
props[2].setShortDescription(NbBundle.getMessage(
- OfficeSettingsBeanInfo.class, "HINT_WarnAfterDirDeploy"));
+ OfficeSettingsBeanInfo.class, "HINT_WarnAfterDirDeploy"));
props[2].setHidden(true);
props[3].setDisplayName(NbBundle.getMessage(
- OfficeSettingsBeanInfo.class, "PROP_WarnBeforeMount"));
+ OfficeSettingsBeanInfo.class, "PROP_WarnBeforeMount"));
props[3].setShortDescription(NbBundle.getMessage(
- OfficeSettingsBeanInfo.class, "HINT_WarnBeforeMount"));
+ OfficeSettingsBeanInfo.class, "HINT_WarnBeforeMount"));
props[3].setHidden(true);
return props;
- }
- catch (IntrospectionException ie) {
+ } catch (IntrospectionException ie) {
ErrorManager.getDefault().notify(ie);
return null;
}
@@ -105,18 +104,18 @@ public class OfficeSettingsBeanInfo extends SimpleBeanInfo {
private SelectPathPanel panel;
- public String getAsText () {
+ public String getAsText() {
return ((OfficeInstallation)getValue()).getPath();
}
- public void setAsText (String path) {
+ public void setAsText(String path) {
OfficeInstallation oi = new OfficeInstallation(path);
if (!oi.supportsFramework())
throw new IllegalArgumentException(path +
- " is not a valid Office install");
+ " is not a valid Office install");
else
- setValue (oi);
+ setValue(oi);
}
public Component getCustomEditor() {
diff --git a/scripting/java/org/openoffice/netbeans/modules/office/utils/FrameworkJarChecker.java b/scripting/java/org/openoffice/netbeans/modules/office/utils/FrameworkJarChecker.java
index b26b729455bf..9c6c33900383 100644
--- a/scripting/java/org/openoffice/netbeans/modules/office/utils/FrameworkJarChecker.java
+++ b/scripting/java/org/openoffice/netbeans/modules/office/utils/FrameworkJarChecker.java
@@ -33,46 +33,44 @@ public class FrameworkJarChecker {
public static void mountDependencies() {
String unoilPath = SVersionRCFile.getPathForUnoil(
- OfficeSettings.getDefault().getOfficeDirectory().getPath());
+ OfficeSettings.getDefault().getOfficeDirectory().getPath());
if (unoilPath == null)
return;
File unoilFile = new File(unoilPath + File.separator + "unoil.jar");
JarFileSystem jfs = new JarFileSystem();
+
try {
jfs.setJarFile(unoilFile);
- }
- catch (IOException ioe) {
+ } catch (IOException ioe) {
return;
- }
- catch (PropertyVetoException pve) {
+ } catch (PropertyVetoException pve) {
return;
}
FileSystem result;
+
try {
result =
Repository.getDefault().findFileSystem(jfs.getSystemName());
- }
- catch(Exception exp) {
+ } catch (Exception exp) {
result = null;
- }
- finally {
+ } finally {
jfs.removeNotify();
}
- if(result == null) {
+ if (result == null) {
JarFileSystem newjfs = new JarFileSystem();
+
try {
newjfs.setJarFile(unoilFile);
- }
- catch (IOException ioe) {
+ } catch (IOException ioe) {
return;
- }
- catch (PropertyVetoException pve) {
+ } catch (PropertyVetoException pve) {
return;
}
+
Repository.getDefault().addFileSystem(newjfs);
newjfs.setHidden(true);
}
@@ -80,31 +78,31 @@ public class FrameworkJarChecker {
public static void unmountDependencies() {
String unoilPath = SVersionRCFile.getPathForUnoil(
- OfficeSettings.getDefault().getOfficeDirectory().getPath());
+ OfficeSettings.getDefault().getOfficeDirectory().getPath());
if (unoilPath == null)
return;
File unoilFile = new File(unoilPath + File.separator + "unoil.jar");
JarFileSystem jfs = new JarFileSystem();
+
try {
jfs.setJarFile(unoilFile);
- }
- catch (IOException ioe) {
+ } catch (IOException ioe) {
return;
- }
- catch (PropertyVetoException pve) {
+ } catch (PropertyVetoException pve) {
return;
}
FileSystem result;
+
try {
result =
Repository.getDefault().findFileSystem(jfs.getSystemName());
- if(result != null)
+
+ if (result != null)
Repository.getDefault().removeFileSystem(result);
- }
- catch(Exception exp) {
+ } catch (Exception exp) {
}
}
@@ -115,13 +113,13 @@ public class FrameworkJarChecker {
return;
String message = "The Office Scripting Framework support jar file " +
- "is not mounted, so Office scripts will not compile. NetBeans " +
- "is going to mount this jar file automatically.";
+ "is not mounted, so Office scripts will not compile. NetBeans " +
+ "is going to mount this jar file automatically.";
String prompt = "Show this message in future.";
NagDialog warning = NagDialog.createInformationDialog(
- message, prompt, true);
+ message, prompt, true);
if (!warning.getState()) {
settings.setWarnBeforeMount(false);
diff --git a/scripting/java/org/openoffice/netbeans/modules/office/utils/ManifestParser.java b/scripting/java/org/openoffice/netbeans/modules/office/utils/ManifestParser.java
index 1859ec60865e..67e6202c7789 100644
--- a/scripting/java/org/openoffice/netbeans/modules/office/utils/ManifestParser.java
+++ b/scripting/java/org/openoffice/netbeans/modules/office/utils/ManifestParser.java
@@ -45,6 +45,7 @@ public class ManifestParser implements XMLParser {
if (parser == null) {
parser = new ManifestParser();
}
+
return parser;
}
@@ -60,18 +61,15 @@ public class ManifestParser implements XMLParser {
is.setSystemId(id);
result = XMLUtil.parse(is, false, false, null, null);
- }
- catch (IOException ioe) {
+ } catch (IOException ioe) {
System.out.println("IO Error parsing stream.");
return null;
- }
- catch (SAXParseException spe) {
+ } catch (SAXParseException spe) {
System.out.println("Sax Error parsing stream: " + spe.getMessage());
System.out.println("\tPublicId: " + spe.getPublicId());
System.out.println("\tSystemId: " + spe.getSystemId());
return null;
- }
- catch (SAXException se) {
+ } catch (SAXException se) {
System.out.println("Sax Error parsing stream: " + se.getMessage());
return null;
}
diff --git a/scripting/java/org/openoffice/netbeans/modules/office/utils/NagDialog.java b/scripting/java/org/openoffice/netbeans/modules/office/utils/NagDialog.java
index c54833ba02bb..f6f9ee148e0e 100644
--- a/scripting/java/org/openoffice/netbeans/modules/office/utils/NagDialog.java
+++ b/scripting/java/org/openoffice/netbeans/modules/office/utils/NagDialog.java
@@ -36,7 +36,7 @@ public class NagDialog {
private JCheckBox checkbox;
private NagDialog(String message, String prompt, boolean initialState,
- int type) {
+ int type) {
initUI(message, prompt, initialState, type);
}
@@ -46,7 +46,7 @@ public class NagDialog {
message, prompt, initialState, JOptionPane.INFORMATION_MESSAGE);
result.setDescriptor(new NotifyDescriptor.Message(result.getPanel(),
- NotifyDescriptor.PLAIN_MESSAGE));
+ NotifyDescriptor.PLAIN_MESSAGE));
return result;
}
@@ -57,8 +57,8 @@ public class NagDialog {
message, prompt, initialState, JOptionPane.QUESTION_MESSAGE);
result.setDescriptor(new NotifyDescriptor.Confirmation(
- result.getPanel(), NotifyDescriptor.OK_CANCEL_OPTION,
- NotifyDescriptor.PLAIN_MESSAGE));
+ result.getPanel(), NotifyDescriptor.OK_CANCEL_OPTION,
+ NotifyDescriptor.PLAIN_MESSAGE));
return result;
}
@@ -82,21 +82,21 @@ public class NagDialog {
}
private void initUI(String message, String prompt, boolean initialState,
- int type) {
+ int type) {
this.panel = new JPanel();
JOptionPane optionPane = new JOptionPane(message, type, 0, null,
- new Object[0], null)
- {
- public int getMaxCharactersPerLineCount() {
- return 100;
- }
- };
+ new Object[0], null) {
+ public int getMaxCharactersPerLineCount() {
+ return 100;
+ }
+ };
optionPane.setUI(new javax.swing.plaf.basic.BasicOptionPaneUI() {
public Dimension getMinimumOptionPaneSize() {
if (minimumSize == null) {
return new Dimension(MinimumWidth, 50);
}
+
return new Dimension(minimumSize.width, 50);
}
});
diff --git a/scripting/java/org/openoffice/netbeans/modules/office/utils/OfficeModule.java b/scripting/java/org/openoffice/netbeans/modules/office/utils/OfficeModule.java
index 305735cd4b86..a4d917e2552b 100644
--- a/scripting/java/org/openoffice/netbeans/modules/office/utils/OfficeModule.java
+++ b/scripting/java/org/openoffice/netbeans/modules/office/utils/OfficeModule.java
@@ -32,27 +32,28 @@ public class OfficeModule extends ModuleInstall {
private static final long serialVersionUID = -8499324854301243852L;
- public void installed () {
+ public void installed() {
WizardDescriptor wiz = new InstallationPathDescriptor();
TopManager.getDefault().createDialog(wiz).show();
- if(wiz.getValue() == NotifyDescriptor.OK_OPTION) {
+ if (wiz.getValue() == NotifyDescriptor.OK_OPTION) {
OfficeInstallation oi = (OfficeInstallation)
- wiz.getProperty(InstallationPathDescriptor.PROP_INSTALLPATH);
+ wiz.getProperty(InstallationPathDescriptor.PROP_INSTALLPATH);
OfficeSettings settings = OfficeSettings.getDefault();
settings.setOfficeDirectory(oi);
}
+
FrameworkJarChecker.mountDependencies();
XMLParserFactory.setParser(ManifestParser.getManifestParser());
}
- public void restored () {
+ public void restored() {
FrameworkJarChecker.mountDependencies();
XMLParserFactory.setParser(ManifestParser.getManifestParser());
}
- public boolean closing () {
+ public boolean closing() {
FrameworkJarChecker.unmountDependencies();
return true;
}
diff --git a/scripting/java/org/openoffice/netbeans/modules/office/utils/PackageRemover.java b/scripting/java/org/openoffice/netbeans/modules/office/utils/PackageRemover.java
index 270b30fde9d9..f79368f6f495 100644
--- a/scripting/java/org/openoffice/netbeans/modules/office/utils/PackageRemover.java
+++ b/scripting/java/org/openoffice/netbeans/modules/office/utils/PackageRemover.java
@@ -39,24 +39,25 @@ public class PackageRemover {
try {
String line;
+
while ((line = in.readLine()) != null) {
if (line.startsWith("package")) {
String newDeclaration = evaluate(line);
+
if (newDeclaration != null) {
out.write(newDeclaration, 0, newDeclaration.length());
out.newLine();
}
- }
- else {
+ } else {
out.write(line, 0, line.length());
out.newLine();
}
}
- }
- finally {
+ } finally {
if (in != null) {
in.close();
}
+
if (out != null) {
out.close();
}
@@ -65,8 +66,7 @@ public class PackageRemover {
if (!source.delete()) {
tmp.delete();
throw new IOException("Could not overwrite " + source);
- }
- else {
+ } else {
tmp.renameTo(source);
}
}
@@ -74,10 +74,12 @@ public class PackageRemover {
public static String evaluate(String line) {
int idx = line.indexOf(ParcelZipper.CONTENTS_DIRNAME);
+
if (idx == -1)
return line;
idx = idx + ParcelZipper.CONTENTS_DIRNAME.length();
+
if (line.charAt(idx) == '.')
return "package " + line.substring(idx + 1);;
@@ -89,8 +91,7 @@ public class PackageRemover {
try {
removeDeclaration(source);
- }
- catch (IOException ioe) {
+ } catch (IOException ioe) {
ioe.printStackTrace();
}
}
diff --git a/scripting/java/org/openoffice/netbeans/modules/office/utils/ZipMounter.java b/scripting/java/org/openoffice/netbeans/modules/office/utils/ZipMounter.java
index 7150ef81e541..4163ea1ea99f 100644
--- a/scripting/java/org/openoffice/netbeans/modules/office/utils/ZipMounter.java
+++ b/scripting/java/org/openoffice/netbeans/modules/office/utils/ZipMounter.java
@@ -27,8 +27,7 @@ import org.openide.filesystems.Repository;
import org.openoffice.netbeans.modules.office.filesystem.OpenOfficeDocFileSystem;
-public class ZipMounter
-{
+public class ZipMounter {
private static ZipMounter mounter = null;
private ZipMounter() {
@@ -37,25 +36,26 @@ public class ZipMounter
public static synchronized ZipMounter getZipMounter() {
if (mounter == null)
mounter = new ZipMounter();
+
return mounter;
}
public void mountZipFile(File zipfile)
- throws IOException, PropertyVetoException
- {
+ throws IOException, PropertyVetoException {
if (zipfile != null) {
addDocumentToRepository(zipfile, true);
}
}
private FileSystem addDocumentToRepository(File rootFile, boolean writeable)
- throws IOException, PropertyVetoException
- {
+ throws IOException, PropertyVetoException {
Repository repo = Repository.getDefault();
OpenOfficeDocFileSystem oofs;
oofs = (OpenOfficeDocFileSystem)getMountedDocument(rootFile);
- if(oofs != null)
+
+ if (oofs != null)
repo.removeFileSystem(oofs);
+
oofs = new OpenOfficeDocFileSystem();
oofs.setDocument(rootFile);
repo.addFileSystem(oofs);
@@ -64,16 +64,18 @@ public class ZipMounter
/** @return FileSystem which has given jar file as its root or
* null if no such file system could be found in repository */
- private FileSystem getMountedDocument(File rootFile)
- {
+ private FileSystem getMountedDocument(File rootFile) {
if (rootFile == null)
return null;
+
FileSystem oofs = null;
+
try {
oofs = Repository.getDefault().findFileSystem(
- OpenOfficeDocFileSystem.computeSystemName(rootFile));
- } catch(Exception exp) {
+ OpenOfficeDocFileSystem.computeSystemName(rootFile));
+ } catch (Exception exp) {
}
+
return oofs;
}
}
diff --git a/scripting/java/org/openoffice/netbeans/modules/office/wizard/InstallationPathDescriptor.java b/scripting/java/org/openoffice/netbeans/modules/office/wizard/InstallationPathDescriptor.java
index 46147272eb83..f75873dade3f 100644
--- a/scripting/java/org/openoffice/netbeans/modules/office/wizard/InstallationPathDescriptor.java
+++ b/scripting/java/org/openoffice/netbeans/modules/office/wizard/InstallationPathDescriptor.java
@@ -56,7 +56,8 @@ public class InstallationPathDescriptor extends WizardDescriptor {
protected void updateState() {
super.updateState();
putProperty("WizardPanel_contentData", iterator.getSteps()); // NOI18N
- putProperty("WizardPanel_contentSelectedIndex", Integer.valueOf(iterator.getIndex())); // NOI18N
+ putProperty("WizardPanel_contentSelectedIndex",
+ Integer.valueOf(iterator.getIndex())); // NOI18N
}
}
diff --git a/scripting/java/org/openoffice/netbeans/modules/office/wizard/InstallationPathIterator.java b/scripting/java/org/openoffice/netbeans/modules/office/wizard/InstallationPathIterator.java
index 918bcbdf0b49..fafd40165978 100644
--- a/scripting/java/org/openoffice/netbeans/modules/office/wizard/InstallationPathIterator.java
+++ b/scripting/java/org/openoffice/netbeans/modules/office/wizard/InstallationPathIterator.java
@@ -40,16 +40,16 @@ public class InstallationPathIterator implements WizardDescriptor.Iterator {
protected WizardDescriptor.Panel[] createPanels() {
return new WizardDescriptor.Panel[] {
- new SelectPathPanel()
- };
+ new SelectPathPanel()
+ };
}
// And the list of step names:
protected String[] createSteps() {
return new String[] {
- "Select OpenOffice.org Installation"
- };
+ "Select OpenOffice.org Installation"
+ };
}
// --- The rest probably does not need to be touched. ---
@@ -66,6 +66,7 @@ public class InstallationPathIterator implements WizardDescriptor.Iterator {
if (panels == null) {
panels = createPanels();
}
+
return panels;
}
@@ -77,6 +78,7 @@ public class InstallationPathIterator implements WizardDescriptor.Iterator {
if (steps == null) {
steps = createSteps();
}
+
return steps;
}
@@ -87,7 +89,7 @@ public class InstallationPathIterator implements WizardDescriptor.Iterator {
public String name() {
return NbBundle.getMessage(InstallationPathIterator.class, "TITLE_x_of_y",
- Integer.valueOf(index + 1), Integer.valueOf(getPanels().length));
+ Integer.valueOf(index + 1), Integer.valueOf(getPanels().length));
}
public boolean hasNext() {
@@ -98,10 +100,12 @@ public class InstallationPathIterator implements WizardDescriptor.Iterator {
}
public void nextPanel() {
if (!hasNext()) throw new NoSuchElementException();
+
index++;
}
public void previousPanel() {
if (!hasPrevious()) throw new NoSuchElementException();
+
index--;
}
public WizardDescriptor.Panel current() {
diff --git a/scripting/java/org/openoffice/netbeans/modules/office/wizard/JavaScriptIterator.java b/scripting/java/org/openoffice/netbeans/modules/office/wizard/JavaScriptIterator.java
index 8a326201301b..dd602ce1131d 100644
--- a/scripting/java/org/openoffice/netbeans/modules/office/wizard/JavaScriptIterator.java
+++ b/scripting/java/org/openoffice/netbeans/modules/office/wizard/JavaScriptIterator.java
@@ -58,17 +58,17 @@ public class JavaScriptIterator implements TemplateWizard.Iterator {
protected WizardDescriptor.Panel[] createPanels() {
return new WizardDescriptor.Panel[] {
- // keep the default 2nd panel:
- wiz.targetChooser(),
- };
+ // keep the default 2nd panel:
+ wiz.targetChooser(),
+ };
}
// And the list of step names:
protected String[] createSteps() {
return new String[] {
- null,
- };
+ null,
+ };
}
private DataFolder checkTarget(DataFolder folder) {
@@ -80,21 +80,23 @@ public class JavaScriptIterator implements TemplateWizard.Iterator {
if (fs instanceof OpenOfficeDocFileSystem && fo.isRoot()) {
FileObject scripts =
fo.getFileObject(OpenOfficeDocFileSystem.SCRIPTS_ROOT);
+
if (scripts == null)
scripts =
fo.createFolder(OpenOfficeDocFileSystem.SCRIPTS_ROOT);
FileObject javafolder = scripts.getFileObject("java");
+
if (javafolder == null)
javafolder = scripts.createFolder("java");
DataFolder subfolder = new DataFolder(javafolder);
return subfolder;
}
- }
- catch (IOException ioe) {
+ } catch (IOException ioe) {
/* do nothing, we will just return the folder we were passed in */
}
+
return folder;
}
@@ -105,6 +107,7 @@ public class JavaScriptIterator implements TemplateWizard.Iterator {
DataObject template = wiz.getTemplate();
DataObject result;
+
if (name == null) {
// Default name.
result = template.createFromTemplate(targetFolder);
@@ -113,6 +116,7 @@ public class JavaScriptIterator implements TemplateWizard.Iterator {
}
FileObject tmp = result.getPrimaryFile();
+
if (tmp.getExt().equals("java")) {
try {
PackageRemover.removeDeclaration(FileUtil.toFile(tmp));
@@ -120,13 +124,12 @@ public class JavaScriptIterator implements TemplateWizard.Iterator {
// IssueZilla 11986 - rename the FileObject
// so the JavaNode is resynchronized
tmp.rename(tmp.lock(), tmp.getName(), tmp.getExt());
- }
- catch (IOException ioe) {
+ } catch (IOException ioe) {
NotifyDescriptor d = new NotifyDescriptor.Message(
- "Error removing package declaration from file: " +
- tmp.getNameExt() +
- ". You should manually remove this declaration " +
- "before building the Parcel Recipe");
+ "Error removing package declaration from file: " +
+ tmp.getNameExt() +
+ ". You should manually remove this declaration " +
+ "before building the Parcel Recipe");
TopManager.getDefault().notify(d);
}
}
@@ -150,18 +153,22 @@ public class JavaScriptIterator implements TemplateWizard.Iterator {
panels = createPanels();
// Make sure list of steps is accurate.
String[] steps = createSteps();
+
for (int i = 0; i < panels.length; i++) {
Component c = panels[i].getComponent();
+
if (steps[i] == null) {
// Default step name to component name of panel.
// Mainly useful for getting the name of the target
// chooser to appear in the list of steps.
steps[i] = c.getName();
}
+
if (c instanceof JComponent) { // assume Swing components
JComponent jc = (JComponent)c;
// Step #.
- jc.putClientProperty("WizardPanel_contentSelectedIndex", Integer.valueOf(i)); // NOI18N
+ jc.putClientProperty("WizardPanel_contentSelectedIndex",
+ Integer.valueOf(i)); // NOI18N
// Step name (actually the whole list for reference).
jc.putClientProperty("WizardPanel_contentData", steps); // NOI18N
}
@@ -189,10 +196,12 @@ public class JavaScriptIterator implements TemplateWizard.Iterator {
}
public void nextPanel() {
if (!hasNext()) throw new NoSuchElementException();
+
index++;
}
public void previousPanel() {
if (!hasPrevious()) throw new NoSuchElementException();
+
index--;
}
public WizardDescriptor.Panel current() {
diff --git a/scripting/java/org/openoffice/netbeans/modules/office/wizard/ParcelContentsIterator.java b/scripting/java/org/openoffice/netbeans/modules/office/wizard/ParcelContentsIterator.java
index 510a9adb638c..4135724d2010 100644
--- a/scripting/java/org/openoffice/netbeans/modules/office/wizard/ParcelContentsIterator.java
+++ b/scripting/java/org/openoffice/netbeans/modules/office/wizard/ParcelContentsIterator.java
@@ -62,17 +62,17 @@ public class ParcelContentsIterator implements TemplateWizard.Iterator {
protected WizardDescriptor.Panel[] createPanels() {
return new WizardDescriptor.Panel[] {
- new ParcelPropertiesPanel(),
- };
+ new ParcelPropertiesPanel(),
+ };
}
// And the list of step names:
protected String[] createSteps() {
return new String[] {
- // null,
- "Parcel Properties",
- };
+ // null,
+ "Parcel Properties",
+ };
}
private DataFolder checkTarget(DataFolder folder) {
@@ -84,21 +84,23 @@ public class ParcelContentsIterator implements TemplateWizard.Iterator {
if (fs instanceof OpenOfficeDocFileSystem && fo.isRoot()) {
FileObject scripts =
fo.getFileObject(OpenOfficeDocFileSystem.SCRIPTS_ROOT);
+
if (scripts == null)
scripts =
fo.createFolder(OpenOfficeDocFileSystem.SCRIPTS_ROOT);
FileObject javafolder = scripts.getFileObject("java");
+
if (javafolder == null)
javafolder = scripts.createFolder("java");
DataFolder subfolder = new DataFolder(javafolder);
return subfolder;
}
- }
- catch (IOException ioe) {
+ } catch (IOException ioe) {
/* do nothing, we will just return the folder we were passed in */
}
+
return folder;
}
@@ -111,6 +113,7 @@ public class ParcelContentsIterator implements TemplateWizard.Iterator {
DataObject template = wiz.getTemplate();
DataObject result;
+
if (name == null) {
// Default name.
result = template.createFromTemplate(targetFolder);
@@ -152,18 +155,22 @@ public class ParcelContentsIterator implements TemplateWizard.Iterator {
panels = createPanels();
// Make sure list of steps is accurate.
String[] steps = createSteps();
+
for (int i = 0; i < panels.length; i++) {
Component c = panels[i].getComponent();
+
if (steps[i] == null) {
// Default step name to component name of panel.
// Mainly useful for getting the name of the target
// chooser to appear in the list of steps.
steps[i] = c.getName();
}
+
if (c instanceof JComponent) { // assume Swing components
JComponent jc = (JComponent)c;
// Step #.
- jc.putClientProperty("WizardPanel_contentSelectedIndex", Integer.valueOf(i)); // NOI18N
+ jc.putClientProperty("WizardPanel_contentSelectedIndex",
+ Integer.valueOf(i)); // NOI18N
// Step name (actually the whole list for reference).
jc.putClientProperty("WizardPanel_contentData", steps); // NOI18N
}
@@ -191,10 +198,12 @@ public class ParcelContentsIterator implements TemplateWizard.Iterator {
}
public void nextPanel() {
if (!hasNext()) throw new NoSuchElementException();
+
index++;
}
public void previousPanel() {
if (!hasPrevious()) throw new NoSuchElementException();
+
index--;
}
public WizardDescriptor.Panel current() {
diff --git a/scripting/java/org/openoffice/netbeans/modules/office/wizard/ParcelPropertiesPanel.java b/scripting/java/org/openoffice/netbeans/modules/office/wizard/ParcelPropertiesPanel.java
index e0355ed391c6..aaf3abd5a186 100644
--- a/scripting/java/org/openoffice/netbeans/modules/office/wizard/ParcelPropertiesPanel.java
+++ b/scripting/java/org/openoffice/netbeans/modules/office/wizard/ParcelPropertiesPanel.java
@@ -51,6 +51,7 @@ public class ParcelPropertiesPanel implements WizardDescriptor.FinishPanel {
if (component == null) {
component = new ParcelPropertiesVisualPanel(this);
}
+
return component;
}
diff --git a/scripting/java/org/openoffice/netbeans/modules/office/wizard/ParcelPropertiesVisualPanel.java b/scripting/java/org/openoffice/netbeans/modules/office/wizard/ParcelPropertiesVisualPanel.java
index bdb25bd02fb3..bf10d713e4c7 100644
--- a/scripting/java/org/openoffice/netbeans/modules/office/wizard/ParcelPropertiesVisualPanel.java
+++ b/scripting/java/org/openoffice/netbeans/modules/office/wizard/ParcelPropertiesVisualPanel.java
@@ -39,7 +39,8 @@ public class ParcelPropertiesVisualPanel extends javax.swing.JPanel {
languagesComboBox.addItem("BeanShell");
// Provide a name in the title bar.
- setName(NbBundle.getMessage(ParcelPropertiesVisualPanel.class, "TITLE_ParcelPropertiesVisualPanel"));
+ setName(NbBundle.getMessage(ParcelPropertiesVisualPanel.class,
+ "TITLE_ParcelPropertiesVisualPanel"));
}
/** This method is called from within the constructor to
@@ -121,27 +122,33 @@ public class ParcelPropertiesVisualPanel extends javax.swing.JPanel {
}//GEN-END:initComponents
- private void recipeNameFocusGained(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_recipeNameFocusGained
+ private void recipeNameFocusGained(java.awt.event.FocusEvent
+ evt) {//GEN-FIRST:event_recipeNameFocusGained
recipeName.selectAll();
}//GEN-LAST:event_recipeNameFocusGained
- private void recipeNameFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_recipeNameFocusLost
+ private void recipeNameFocusLost(java.awt.event.FocusEvent
+ evt) {//GEN-FIRST:event_recipeNameFocusLost
changeName();
}//GEN-LAST:event_recipeNameFocusLost
- private void languagesComboBoxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_languagesComboBoxActionPerformed
+ private void languagesComboBoxActionPerformed(java.awt.event.ActionEvent
+ evt) {//GEN-FIRST:event_languagesComboBoxActionPerformed
String language = (String)languagesComboBox.getSelectedItem();
panel.setLanguage(language);
}//GEN-LAST:event_languagesComboBoxActionPerformed
- private void recipeNameActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_recipeNameActionPerformed
+ private void recipeNameActionPerformed(java.awt.event.ActionEvent
+ evt) {//GEN-FIRST:event_recipeNameActionPerformed
changeName();
}//GEN-LAST:event_recipeNameActionPerformed
private void changeName() {
String name = recipeName.getText().trim();
+
if (name.length() == 0)
name = null;
+
panel.setName(name);
}
diff --git a/scripting/java/org/openoffice/netbeans/modules/office/wizard/SelectPathPanel.java b/scripting/java/org/openoffice/netbeans/modules/office/wizard/SelectPathPanel.java
index 66fb0a29821a..dfa434d75a35 100644
--- a/scripting/java/org/openoffice/netbeans/modules/office/wizard/SelectPathPanel.java
+++ b/scripting/java/org/openoffice/netbeans/modules/office/wizard/SelectPathPanel.java
@@ -36,7 +36,8 @@ import org.openoffice.idesupport.SVersionRCFile;
/** A single panel descriptor for a wizard.
* You probably want to make a wizard iterator to hold it.
*/
-public class SelectPathPanel implements WizardDescriptor.Panel /* .FinishPanel */ {
+public class SelectPathPanel implements
+ WizardDescriptor.Panel { /* .FinishPanel */
/** The visual component that displays this panel.
* If you need to access the component from this class,
@@ -52,8 +53,7 @@ public class SelectPathPanel implements WizardDescriptor.Panel /* .FinishPanel *
if (office == null) {
try {
office = SVersionRCFile.createInstance().getDefaultVersion();
- }
- catch (java.io.IOException ioe) {}
+ } catch (java.io.IOException ioe) {}
}
}
@@ -65,6 +65,7 @@ public class SelectPathPanel implements WizardDescriptor.Panel /* .FinishPanel *
if (component == null) {
component = new SelectPathVisualPanel(this);
}
+
return component;
}
@@ -98,10 +99,13 @@ public class SelectPathPanel implements WizardDescriptor.Panel /* .FinishPanel *
}
protected final void fireChangeEvent() {
Iterator it;
+
synchronized (listeners) {
it = new HashSet(listeners).iterator();
}
+
ChangeEvent ev = new ChangeEvent(this);
+
while (it.hasNext()) {
((ChangeListener)it.next()).stateChanged(ev);
}
diff --git a/scripting/java/org/openoffice/netbeans/modules/office/wizard/SelectPathVisualPanel.java b/scripting/java/org/openoffice/netbeans/modules/office/wizard/SelectPathVisualPanel.java
index 3853944e72fe..ca26a25bc150 100644
--- a/scripting/java/org/openoffice/netbeans/modules/office/wizard/SelectPathVisualPanel.java
+++ b/scripting/java/org/openoffice/netbeans/modules/office/wizard/SelectPathVisualPanel.java
@@ -52,8 +52,7 @@ public class SelectPathVisualPanel extends javax.swing.JPanel {
OfficeInstallation oi = (OfficeInstallation)enumer.nextElement();
installationsComboBox.addItem(oi);
}
- }
- catch (IOException ioe) {
+ } catch (IOException ioe) {
installationsComboBox.addItem("<empty>");
}
@@ -63,15 +62,16 @@ public class SelectPathVisualPanel extends javax.swing.JPanel {
}
installationsComboBox.addActionListener(
- new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- installationsComboBoxActionPerformed(evt);
- }
+ new java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ installationsComboBoxActionPerformed(evt);
}
+ }
);
// Provide a name in the title bar.
- setName(NbBundle.getMessage(SelectPathVisualPanel.class, "TITLE_SelectPathVisualPanel"));
+ setName(NbBundle.getMessage(SelectPathVisualPanel.class,
+ "TITLE_SelectPathVisualPanel"));
}
private void installationsComboBoxActionPerformed(
@@ -155,7 +155,8 @@ public class SelectPathVisualPanel extends javax.swing.JPanel {
}//GEN-END:initComponents
- private void browseButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_browseButtonActionPerformed
+ private void browseButtonActionPerformed(java.awt.event.ActionEvent
+ evt) {//GEN-FIRST:event_browseButtonActionPerformed
// Add your handling code here:
File target = null;
@@ -167,10 +168,10 @@ public class SelectPathVisualPanel extends javax.swing.JPanel {
target = chooser.getSelectedFile();
String path;
+
try {
path = target.getCanonicalPath();
- }
- catch (IOException ioe) {
+ } catch (IOException ioe) {
path = target.getAbsolutePath();
}
diff --git a/scripting/workben/ifc/scripting/ScriptingUtils.java b/scripting/workben/ifc/scripting/ScriptingUtils.java
index eb317036e2ab..03ef3f5ca680 100644
--- a/scripting/workben/ifc/scripting/ScriptingUtils.java
+++ b/scripting/workben/ifc/scripting/ScriptingUtils.java
@@ -37,6 +37,7 @@ public class ScriptingUtils {
public static synchronized ScriptingUtils getDefault() {
if (utils == null)
utils = new ScriptingUtils();
+
return utils;
}
@@ -63,23 +64,23 @@ public class ScriptingUtils {
if (storageManager == null) {
try {
XPropertySet xProp = UnoRuntime.queryInterface(
- XPropertySet.class, xMSF);
+ XPropertySet.class, xMSF);
XComponentContext xContext = UnoRuntime.queryInterface(XComponentContext.class,
- xProp.getPropertyValue("DefaultContext"));
+ xProp.getPropertyValue("DefaultContext"));
XInterface ifc = (XInterface)
- xContext.getValueByName("/singletons/drafts.com.sun.star." +
- "script.framework.storage.theScriptStorageManager");
+ xContext.getValueByName("/singletons/drafts.com.sun.star." +
+ "script.framework.storage.theScriptStorageManager");
storageManager = UnoRuntime.queryInterface(XScriptStorageManager.class, ifc);
- }
- catch( Exception e ) {
+ } catch (Exception e) {
return -1;
}
}
access = getXSimpleFileAccess(xMSF);
+
if (access == null)
return -1;
@@ -96,10 +97,10 @@ public class ScriptingUtils {
xMSF.createInstance("com.sun.star.ucb.SimpleFileAccess");
access = UnoRuntime.queryInterface(XSimpleFileAccess.class, fa);
- }
- catch (com.sun.star.uno.Exception e) {
+ } catch (com.sun.star.uno.Exception e) {
return null;
}
+
return access;
}
}
diff --git a/scripting/workben/ifc/scripting/SecurityDialogUtil.java b/scripting/workben/ifc/scripting/SecurityDialogUtil.java
index fbcee55b5431..349b70bfa24f 100644
--- a/scripting/workben/ifc/scripting/SecurityDialogUtil.java
+++ b/scripting/workben/ifc/scripting/SecurityDialogUtil.java
@@ -33,116 +33,112 @@ import util.AccessibilityTools;
*/
public class SecurityDialogUtil extends Thread {
-private XMultiServiceFactory xMSF = null;
-private String errorMsg;
-private String btnName;
-private boolean checkBox;
+ private XMultiServiceFactory xMSF = null;
+ private String errorMsg;
+ private String btnName;
+ private boolean checkBox;
+
+ /**
+ * Constructor.
+ */
+ public SecurityDialogUtil(XMultiServiceFactory xMSF, String btnName,
+ boolean checkBox) {
+ this.xMSF = xMSF;
+ this.btnName = btnName;
+ this.checkBox = checkBox;
+ this.errorMsg = "";
+ }
-/**
- * Constructor.
- */
-public SecurityDialogUtil(XMultiServiceFactory xMSF, String btnName, boolean checkBox )
-{
- this.xMSF = xMSF;
- this.btnName = btnName;
- this.checkBox = checkBox;
- this.errorMsg = "";
-}
+ /**
+ * Returns the error message that occurred while
+ * accessing and pressing the button.
+ * @return Error message.
+ */
+ public String getErrorMessage() {
+ return errorMsg;
+ }
-/**
- * Returns the error message that occurred while
- * accessing and pressing the button.
- * @return Error message.
- */
-public String getErrorMessage()
-{
- return errorMsg;
-}
+ /**
+ * Press the named button in the currently visible dialog box.
+ */
+ @Override
+ public void run() {
+ // wait for the message box to appear
+ try {
+ Thread.sleep(4000) ;
+ } catch (InterruptedException e) {
+ System.err.println("While waiting :" + e.getMessage()) ;
+ }
-/**
- * Press the named button in the currently visible dialog box.
- */
-@Override
-public void run()
-{
- // wait for the message box to appear
- try
- {
- Thread.sleep(4000) ;
- }
- catch (InterruptedException e)
- {
- System.err.println("While waiting :" + e.getMessage()) ;
- }
+ // access the message box
- // access the message box
+ XAccessibleContext xCon = null;
- XAccessibleContext xCon = null;
- try
- {
- XInterface x = (XInterface) xMSF.createInstance(
- "com.sun.star.awt.Toolkit") ;
- XExtendedToolkit tk =
+ try {
+ XInterface x = (XInterface) xMSF.createInstance(
+ "com.sun.star.awt.Toolkit") ;
+ XExtendedToolkit tk =
UnoRuntime.queryInterface(
- XExtendedToolkit.class,x);
- new AccessibilityTools();
- XWindow xWindow = UnoRuntime.queryInterface(
- XWindow.class,tk.getActiveTopWindow());
- XAccessible xRoot = AccessibilityTools.getAccessibleObject(xWindow);
- xCon = xRoot.getAccessibleContext();
- }
- catch (Exception e)
- {
- errorMsg="Exception while using Accessibility\n"+
- e.getMessage();
- return;
- }
- // get the button
- XInterface oObj = null;
- try
- {
- int count = xCon.getAccessibleChildCount();
- for (int i=0; i<count; i++) {
- XAccessible xAcc = xCon.getAccessibleChild(i);
- String name =
+ XExtendedToolkit.class, x);
+ new AccessibilityTools();
+ XWindow xWindow = UnoRuntime.queryInterface(
+ XWindow.class, tk.getActiveTopWindow());
+ XAccessible xRoot = AccessibilityTools.getAccessibleObject(xWindow);
+ xCon = xRoot.getAccessibleContext();
+ } catch (Exception e) {
+ errorMsg = "Exception while using Accessibility\n" +
+ e.getMessage();
+ return;
+ }
+
+ // get the button
+ XInterface oObj = null;
+
+ try {
+ int count = xCon.getAccessibleChildCount();
+
+ for (int i = 0; i < count; i++) {
+ XAccessible xAcc = xCon.getAccessibleChild(i);
+ String name =
xAcc.getAccessibleContext().getAccessibleName();
- // check for button
- if ( name.equals( btnName ) && ( UnoRuntime.queryInterface(
- XButton.class, xAcc ) != null ) )
- {
- oObj = xAcc.getAccessibleContext();
- }
- // check for checkbox
- if ( checkBox && ( UnoRuntime.queryInterface( XCheckBox.class, xAcc ) != null ) )
- {
- // want to do this action now
- // probably equates to toggle cb
- XAccessibleAction xAction =
+
+ // check for button
+ if (name.equals(btnName) && (UnoRuntime.queryInterface(
+ XButton.class, xAcc) != null)) {
+ oObj = xAcc.getAccessibleContext();
+ }
+
+ // check for checkbox
+ if (checkBox && (UnoRuntime.queryInterface(XCheckBox.class, xAcc) != null)) {
+ // want to do this action now
+ // probably equates to toggle cb
+ XAccessibleAction xAction =
UnoRuntime.queryInterface(
- XAccessibleAction.class, xAcc.getAccessibleContext());
- xAction.doAccessibleAction(0);
+ XAccessibleAction.class, xAcc.getAccessibleContext());
+ xAction.doAccessibleAction(0);
- // might be worth using oObj2 to double check the new state??
+ // might be worth using oObj2 to double check the new state??
+ }
}
- }
- if (oObj == null) {
- errorMsg="No button has been found:\n"+
- "No action is triggered.";
- return;
- }
- // press button
- XAccessibleAction xAction =
+
+ if (oObj == null) {
+ errorMsg = "No button has been found:\n" +
+ "No action is triggered.";
+ return;
+ }
+
+ // press button
+ XAccessibleAction xAction =
UnoRuntime.queryInterface(
- XAccessibleAction.class, oObj);
- xAction.doAccessibleAction(0);
- }
- catch(com.sun.star.lang.IndexOutOfBoundsException e) {
- errorMsg="Exception\n"+
- e.getMessage();
+ XAccessibleAction.class, oObj);
+ xAction.doAccessibleAction(0);
+ } catch (com.sun.star.lang.IndexOutOfBoundsException e) {
+ errorMsg = "Exception\n" +
+ e.getMessage();
+ }
}
-}
}
diff --git a/scripting/workben/ifc/scripting/_XFunction.java b/scripting/workben/ifc/scripting/_XFunction.java
index e4c04b257c0d..31c1742b2d8b 100644
--- a/scripting/workben/ifc/scripting/_XFunction.java
+++ b/scripting/workben/ifc/scripting/_XFunction.java
@@ -40,6 +40,7 @@ public class _XFunction extends MultiMethodTest {
public void before() throws StatusException {
log.println("getting provider");
oProvider = (XFunctionProvider) tEnv.getObjRelation("provider");
+
if (oProvider == null)
log.println("it's null");
else
@@ -60,8 +61,7 @@ public class _XFunction extends MultiMethodTest {
while (tests.hasNext()) {
result &= runInvokeTest((Parameters)tests.next());
}
- }
- else {
+ } else {
result = false;
}
@@ -85,7 +85,7 @@ public class _XFunction extends MultiMethodTest {
log.println(testdata.get("description"));
- try{
+ try {
Object[] aParams = new Object[0];
short[][] aOutParamIndex = new short[1][];
aOutParamIndex[0] = new short[0];
@@ -93,12 +93,13 @@ public class _XFunction extends MultiMethodTest {
aOutParam[0] = new Object[0];
XFunction func = oProvider.getFunction(logicalname);
+
if (func == null) {
log.println("Couldn't get XFunction for:" + logicalname);
return false;
}
- Object ret = func.invoke( aParams, aOutParamIndex, aOutParam );
+ Object ret = func.invoke(aParams, aOutParamIndex, aOutParam);
if (ret != null) {
gotreturntype = ret.getClass().getName();
@@ -106,31 +107,26 @@ public class _XFunction extends MultiMethodTest {
}
output = "success";
- }
- catch (com.sun.star.lang.IllegalArgumentException iae) {
+ } catch (com.sun.star.lang.IllegalArgumentException iae) {
log.println("Couldn't invoke script:" + iae);
output = "com.sun.star.lang.IllegalArgumentException";
- }
- catch (com.sun.star.script.CannotConvertException cce) {
+ } catch (com.sun.star.script.CannotConvertException cce) {
log.println("Couldn't invoke script:" + cce);
output = "com.sun.star.script.CannotConvertException";
- }
- catch (com.sun.star.reflection.InvocationTargetException ite) {
+ } catch (com.sun.star.reflection.InvocationTargetException ite) {
log.println("Couldn't invoke script:" + ite);
output = "com.sun.star.reflection.InvocationTargetException";
- }
- catch (com.sun.star.uno.RuntimeException re) {
+ } catch (com.sun.star.uno.RuntimeException re) {
log.println("Couldn't invoke script:" + re);
output = "com.sun.star.uno.RuntimeException";
- }
- catch(java.lang.Exception e){
+ } catch (java.lang.Exception e) {
log.println("Couldn't invoke script:" + e);
output = "java.lang.Exception";
}
if (expreturntype != null) {
log.println("expected return type: " + expreturntype +
- ", got return type: " + gotreturntype);
+ ", got return type: " + gotreturntype);
if (!gotreturntype.equals(expreturntype))
result = false;
@@ -138,13 +134,14 @@ public class _XFunction extends MultiMethodTest {
if (expreturnvalue != null) {
log.println("expected return value: " + expreturnvalue +
- ", got return value: " + gotreturnvalue);
+ ", got return value: " + gotreturnvalue);
if (!gotreturnvalue.equals(expreturnvalue))
result = false;
}
log.println("expected: " + expected + ", output: " + output);
+
if (!output.equals(expected))
result = false;
diff --git a/scripting/workben/ifc/scripting/_XFunctionProvider.java b/scripting/workben/ifc/scripting/_XFunctionProvider.java
index 7a51288885e8..a8bfbca6b687 100644
--- a/scripting/workben/ifc/scripting/_XFunctionProvider.java
+++ b/scripting/workben/ifc/scripting/_XFunctionProvider.java
@@ -53,8 +53,7 @@ public class _XFunctionProvider extends MultiMethodTest {
while (tests.hasNext()) {
result &= runGetFunctionTest((Parameters)tests.next());
}
- }
- else {
+ } else {
result = false;
}
diff --git a/scripting/workben/ifc/scripting/_XScriptInfo.java b/scripting/workben/ifc/scripting/_XScriptInfo.java
index cd78ad7b1817..8e1cff6bf5ea 100644
--- a/scripting/workben/ifc/scripting/_XScriptInfo.java
+++ b/scripting/workben/ifc/scripting/_XScriptInfo.java
@@ -63,8 +63,7 @@ public class _XScriptInfo extends MultiMethodTest {
log.println("expected: " + expected + ", output: " + output);
result &= output.equals(expected);
}
- }
- else {
+ } else {
result = false;
}
@@ -94,10 +93,10 @@ public class _XScriptInfo extends MultiMethodTest {
log.println("expected: " + expected + ", output: " + output);
result &= output.endsWith(expected);
}
- }
- else {
+ } else {
result = false;
}
+
tRes.tested("getParcelURI()", result);
}
@@ -124,10 +123,10 @@ public class _XScriptInfo extends MultiMethodTest {
log.println("expected: " + expected + ", output: " + output);
result &= output.equals(expected);
}
- }
- else {
+ } else {
result = false;
}
+
tRes.tested("getLanguage()", result);
}
@@ -154,10 +153,10 @@ public class _XScriptInfo extends MultiMethodTest {
log.println("expected: " + expected + ", output: " + output);
result &= output.equals(expected);
}
- }
- else {
+ } else {
result = false;
}
+
tRes.tested("getFunctionName()", result);
}
@@ -184,8 +183,7 @@ public class _XScriptInfo extends MultiMethodTest {
if (output == null)
output = "null";
- }
- catch( com.sun.star.uno.Exception e) {
+ } catch (com.sun.star.uno.Exception e) {
log.println("caught UNO Exception:" + e);
output = "com.sun.star.uno.Exception";
}
@@ -193,6 +191,7 @@ public class _XScriptInfo extends MultiMethodTest {
log.println("expected: " + expected + ", output: " + output);
}
}
+
tRes.tested("getLanguageProperties()", true);
}
@@ -226,10 +225,10 @@ public class _XScriptInfo extends MultiMethodTest {
log.println("expected: " + expected + ", output: " + output);
result &= output.equals(expected);
}
- }
- else {
+ } else {
result = false;
}
+
tRes.tested("getFileSetNames()", result);
}
@@ -264,10 +263,10 @@ public class _XScriptInfo extends MultiMethodTest {
log.println("expected: " + expected + ", output: " + output);
result &= output.equals(expected);
}
- }
- else {
+ } else {
result = false;
}
+
tRes.tested("getFilesInFileSet()", result);
}
@@ -297,11 +296,10 @@ public class _XScriptInfo extends MultiMethodTest {
output = "empty";
log.println("expected: [" + expected + "], output: [" +
- output + "]");
+ output + "]");
result &= output.equals(expected);
}
- }
- else {
+ } else {
result = false;
}
diff --git a/scripting/workben/ifc/scripting/_XScriptInfoAccess.java b/scripting/workben/ifc/scripting/_XScriptInfoAccess.java
index 18b8a41d4d0e..bf2095635fdb 100644
--- a/scripting/workben/ifc/scripting/_XScriptInfoAccess.java
+++ b/scripting/workben/ifc/scripting/_XScriptInfoAccess.java
@@ -54,8 +54,7 @@ public class _XScriptInfoAccess extends MultiMethodTest {
while (tests.hasNext()) {
result &= runGetScriptLogicalNamesTest((Parameters)tests.next());
}
- }
- else {
+ } else {
result = false;
}
@@ -69,21 +68,21 @@ public class _XScriptInfoAccess extends MultiMethodTest {
log.println(testdata.get("description"));
- log.println("In _XScriptInfoAccess.getScriptLogicalNames()");
- String[] logicalNames = oObj.getScriptLogicalNames();
+ log.println("In _XScriptInfoAccess.getScriptLogicalNames()");
+ String[] logicalNames = oObj.getScriptLogicalNames();
- if (logicalNames == null)
- output = "null";
- else if (logicalNames.length == 0)
- output = "empty";
- else {
- for (int i = 0; i < logicalNames.length; i++) {
- if (logicalNames[i].equals(expected)) {
- output = logicalNames[i];
- break;
- }
+ if (logicalNames == null)
+ output = "null";
+ else if (logicalNames.length == 0)
+ output = "empty";
+ else {
+ for (int i = 0; i < logicalNames.length; i++) {
+ if (logicalNames[i].equals(expected)) {
+ output = logicalNames[i];
+ break;
}
}
+ }
log.println("expected: " + expected + ", output: " + output);
return (output.equals(expected));
@@ -103,8 +102,7 @@ public class _XScriptInfoAccess extends MultiMethodTest {
while (tests.hasNext()) {
result &= runGetImplementationsTest((Parameters)tests.next());
}
- }
- else {
+ } else {
result = false;
}
@@ -119,9 +117,9 @@ public class _XScriptInfoAccess extends MultiMethodTest {
log.println(testdata.get("description"));
- // performs a basic check to see if 1 match (XScriptInfo) is returned
- // the XScriptInfo object is tested more completely in _XScriptInfo
- // which is drive from ScriptInfo
+ // performs a basic check to see if 1 match (XScriptInfo) is returned
+ // the XScriptInfo object is tested more completely in _XScriptInfo
+ // which is drive from ScriptInfo
try {
XScriptInfo[] impls = oObj.getImplementations(logicalname);
@@ -133,8 +131,7 @@ public class _XScriptInfoAccess extends MultiMethodTest {
output = "empty";
else
output = impls[0].getLogicalName();
- }
- catch (com.sun.star.uno.Exception e) {
+ } catch (com.sun.star.uno.Exception e) {
log.println("Caught UNO Exception:" + e);
output = "com.sun.star.uno.Exception";
}
@@ -157,8 +154,7 @@ public class _XScriptInfoAccess extends MultiMethodTest {
while (tests.hasNext()) {
result &= runGetAllImplementationsTest((Parameters)tests.next());
}
- }
- else {
+ } else {
result = false;
}
@@ -174,18 +170,19 @@ public class _XScriptInfoAccess extends MultiMethodTest {
log.println(testdata.get("description"));
Object obj = ScriptingUtils.getDefault().getScriptStorage(
- tParam.getMSF(), location);
+ tParam.getMSF(), location);
- XScriptInfoAccess access = UnoRuntime.queryInterface(XScriptInfoAccess.class, obj);
+ XScriptInfoAccess access = UnoRuntime.queryInterface(XScriptInfoAccess.class,
+ obj);
XScriptInfo[] impls = access.getAllImplementations();
if (impls == null || impls.length == 0) {
output = "empty";
- }
- else {
+ } else {
for (int i = 0; i < impls.length - 1; i++)
output += impls[i].getLogicalName() + ",";
+
output += impls[impls.length - 1].getLogicalName();
}
diff --git a/scripting/workben/ifc/scripting/_XScriptInvocation.java b/scripting/workben/ifc/scripting/_XScriptInvocation.java
index a829fb553c67..06c76e75ba06 100644
--- a/scripting/workben/ifc/scripting/_XScriptInvocation.java
+++ b/scripting/workben/ifc/scripting/_XScriptInvocation.java
@@ -67,8 +67,7 @@ public class _XScriptInvocation extends MultiMethodTest {
while (tests.hasNext()) {
result &= runInvokeTest((Parameters)tests.next());
}
- }
- else {
+ } else {
result = false;
}
@@ -86,12 +85,14 @@ public class _XScriptInvocation extends MultiMethodTest {
int storageId = getStorageId(location);
XModel ctx = null;
+
if (!context.equals("null"))
ctx = loadDocument(context);
- HashMap<String,Object> map = new HashMap<String,Object>();
+ HashMap<String, Object> map = new HashMap<String, Object>();
map.put("SCRIPTING_DOC_STORAGE_ID", Integer.valueOf(storageId));
map.put("SCRIPTING_DOC_URI", "hahaha");
+
if (ctx != null)
map.put("SCRIPTING_DOC_REF", ctx);
@@ -109,22 +110,18 @@ public class _XScriptInvocation extends MultiMethodTest {
try {
Object ret = oObj.invoke(logicalname, params, args, num, result);
log.println("return type is: " + ret.getClass().getName() +
- ", value is: " + ret.toString());
+ ", value is: " + ret.toString());
output = "success";
- }
- catch (com.sun.star.lang.IllegalArgumentException iae) {
+ } catch (com.sun.star.lang.IllegalArgumentException iae) {
log.println("Couldn't invoke script:" + iae);
output = "com.sun.star.lang.IllegalArgumentException";
- }
- catch (com.sun.star.script.CannotConvertException cce) {
+ } catch (com.sun.star.script.CannotConvertException cce) {
log.println("Couldn't invoke script:" + cce);
output = "com.sun.star.script.CannotConvertException";
- }
- catch (com.sun.star.reflection.InvocationTargetException ite) {
+ } catch (com.sun.star.reflection.InvocationTargetException ite) {
log.println("Couldn't invoke script:" + ite);
output = "com.sun.star.reflection.InvocationTargetException";
- }
- catch (com.sun.star.uno.RuntimeException re) {
+ } catch (com.sun.star.uno.RuntimeException re) {
log.println("Couldn't invoke script:" + re);
output = "com.sun.star.uno.RuntimeException";
}
@@ -150,23 +147,23 @@ public class _XScriptInvocation extends MultiMethodTest {
if (storageManager == null) {
try {
XPropertySet xProp = UnoRuntime.queryInterface(
- XPropertySet.class, tParam.getMSF());
+ XPropertySet.class, tParam.getMSF());
XComponentContext xContext = UnoRuntime.queryInterface(XComponentContext.class,
- xProp.getPropertyValue("DefaultContext"));
+ xProp.getPropertyValue("DefaultContext"));
XInterface ifc = (XInterface)
- xContext.getValueByName("/singletons/drafts.com.sun.star." +
- "script.framework.storage.theScriptStorageManager");
+ xContext.getValueByName("/singletons/drafts.com.sun.star." +
+ "script.framework.storage.theScriptStorageManager");
storageManager = UnoRuntime.queryInterface(XScriptStorageManager.class, ifc);
- }
- catch( Exception e ) {
+ } catch (Exception e) {
return -1;
}
}
access = getXSimpleFileAccess();
+
if (access == null)
return -1;
@@ -180,13 +177,13 @@ public class _XScriptInvocation extends MultiMethodTest {
try {
Object fa = tParam.getMSF().createInstance(
- "com.sun.star.ucb.SimpleFileAccess");
+ "com.sun.star.ucb.SimpleFileAccess");
access = UnoRuntime.queryInterface(XSimpleFileAccess.class, fa);
- }
- catch (com.sun.star.uno.Exception e) {
+ } catch (com.sun.star.uno.Exception e) {
return null;
}
+
return access;
}
@@ -199,18 +196,15 @@ public class _XScriptInvocation extends MultiMethodTest {
try {
Object obj = factory.loadDocument(fullname);
model = UnoRuntime.queryInterface(XModel.class, obj);
- }
- catch (com.sun.star.lang.IllegalArgumentException iae) {
+ } catch (com.sun.star.lang.IllegalArgumentException iae) {
return null;
- }
- catch (Exception e) {
+ } catch (Exception e) {
return null;
}
try {
Thread.sleep(5000);
- }
- catch (InterruptedException ie) {
+ } catch (InterruptedException ie) {
}
return model;
diff --git a/scripting/workben/ifc/scripting/_XScriptNameResolver.java b/scripting/workben/ifc/scripting/_XScriptNameResolver.java
index b2f264d1e4b1..851ed9c936e5 100644
--- a/scripting/workben/ifc/scripting/_XScriptNameResolver.java
+++ b/scripting/workben/ifc/scripting/_XScriptNameResolver.java
@@ -62,8 +62,7 @@ public class _XScriptNameResolver extends MultiMethodTest {
while (tests.hasNext()) {
result &= runResolveTest((Parameters)tests.next());
}
- }
- else {
+ } else {
result = false;
}
@@ -81,7 +80,7 @@ public class _XScriptNameResolver extends MultiMethodTest {
log.println(description + ": " + logicalname);
- HashMap<String,Object> map = new HashMap<String,Object>();
+ HashMap<String, Object> map = new HashMap<String, Object>();
map.put("SCRIPTING_DOC_STORAGE_ID", Integer.valueOf(storageId));
map.put("SCRIPTING_DOC_URI", util.utils.getFullTestURL(location));
@@ -97,16 +96,13 @@ public class _XScriptNameResolver extends MultiMethodTest {
output = "null";
else
output = "XScriptInfo.class";
- }
- catch (com.sun.star.lang.IllegalArgumentException iae) {
+ } catch (com.sun.star.lang.IllegalArgumentException iae) {
log.println("caught IllegalArgumentException: " + iae);
output = "com.sun.star.lang.IllegalArgumentException";
- }
- catch (com.sun.star.script.CannotConvertException cce) {
+ } catch (com.sun.star.script.CannotConvertException cce) {
log.println("caught CannotConvertException: " + cce);
output = "com.sun.star.script.CannotConvertException";
- }
- catch (com.sun.star.uno.RuntimeException re) {
+ } catch (com.sun.star.uno.RuntimeException re) {
log.println("caught RuntimeException: " + re);
output = "com.sun.star.uno.RuntimeException";
}
@@ -129,23 +125,23 @@ public class _XScriptNameResolver extends MultiMethodTest {
if (storageManager == null) {
try {
XPropertySet xProp = UnoRuntime.queryInterface(
- XPropertySet.class, tParam.getMSF());
+ XPropertySet.class, tParam.getMSF());
XComponentContext xContext = UnoRuntime.queryInterface(XComponentContext.class,
- xProp.getPropertyValue("DefaultContext"));
+ xProp.getPropertyValue("DefaultContext"));
XInterface ifc = (XInterface)
- xContext.getValueByName("/singletons/drafts.com.sun.star." +
- "script.framework.storage.theScriptStorageManager");
+ xContext.getValueByName("/singletons/drafts.com.sun.star." +
+ "script.framework.storage.theScriptStorageManager");
storageManager = UnoRuntime.queryInterface(XScriptStorageManager.class, ifc);
- }
- catch( Exception e ) {
+ } catch (Exception e) {
return -1;
}
}
access = getXSimpleFileAccess();
+
if (access == null)
return -1;
@@ -159,13 +155,13 @@ public class _XScriptNameResolver extends MultiMethodTest {
try {
Object fa = tParam.getMSF().createInstance(
- "com.sun.star.ucb.SimpleFileAccess");
+ "com.sun.star.ucb.SimpleFileAccess");
access = UnoRuntime.queryInterface(XSimpleFileAccess.class, fa);
- }
- catch (com.sun.star.uno.Exception e) {
+ } catch (com.sun.star.uno.Exception e) {
return null;
}
+
return access;
}
}
diff --git a/scripting/workben/ifc/scripting/_XScriptSecurity.java b/scripting/workben/ifc/scripting/_XScriptSecurity.java
index cd3b65668f7f..f06d4288a6c4 100644
--- a/scripting/workben/ifc/scripting/_XScriptSecurity.java
+++ b/scripting/workben/ifc/scripting/_XScriptSecurity.java
@@ -67,8 +67,7 @@ public class _XScriptSecurity extends MultiMethodTest {
while (tests.hasNext()) {
result &= runCheckPermissionTest((Parameters)tests.next());
}
- }
- else {
+ } else {
result = false;
}
@@ -110,200 +109,196 @@ public class _XScriptSecurity extends MultiMethodTest {
// get the officeBasic setting
int officeBasic = 0;
- if( runmacro.equals("never") )
- {
+
+ if (runmacro.equals("never")) {
officeBasic = 0;
- }
- else if ( runmacro.equals("pathlist") )
- {
+ } else if (runmacro.equals("pathlist")) {
officeBasic = 1;
- }
- else if ( runmacro.equals("always") )
- {
+ } else if (runmacro.equals("always")) {
officeBasic = 2;
}
// should pathlist include doc?
String secureURLs = null;
- if( pathlist.equals("true") )
- {
+
+ if (pathlist.equals("true")) {
String uri = util.utils.getFullTestURL(location);
secureURLs = uri.substring(0, uri.lastIndexOf('/'));
}
- if ( !setSecurity( officeBasic, confirm, warning, secureURLs ) )
- {
- log.println( "failed to set security" );
+ if (!setSecurity(officeBasic, confirm, warning, secureURLs)) {
+ log.println("failed to set security");
return false;
}
- if( dialog.equals( "true" ) )
- {
+ if (dialog.equals("true")) {
// is the checkbox to be ticked?
boolean checkBox = false;
- if( checkBoxStr.equals( "true" ) )
- {
+
+ if (checkBoxStr.equals("true")) {
checkBox = true;
}
- new SecurityDialogUtil( tParam.getMSF(), buttonName, checkBox ).start();
+
+ new SecurityDialogUtil(tParam.getMSF(), buttonName, checkBox).start();
}
+
// need to set up dialog utils thread first
int storageId = getStorageId(location);
try {
String uri = util.utils.getFullTestURL(location);
- oObj.checkPermission(uri, "execute" );
+ oObj.checkPermission(uri, "execute");
output = "true";
- }
- catch (com.sun.star.security.AccessControlException ace) {
+ } catch (com.sun.star.security.AccessControlException ace) {
log.println("Couldn't invoke script:" + ace);
output = "com.sun.star.security.AccessControlException";
- }
- catch (com.sun.star.lang.IllegalArgumentException iae) {
+ } catch (com.sun.star.lang.IllegalArgumentException iae) {
log.println("Couldn't invoke script:" + iae);
output = "com.sun.star.lang.IllegalArgumentException";
- }
- catch (com.sun.star.uno.RuntimeException re) {
+ } catch (com.sun.star.uno.RuntimeException re) {
log.println("Couldn't invoke script:" + re);
output = "com.sun.star.uno.RuntimeException";
}
log.println("expected: " + expected + ", output: " + output);
- if (output.equals(expected))
- {
- if( checkpath.equals("true") )
- {
+
+ if (output.equals(expected)) {
+ if (checkpath.equals("true")) {
String setPath = getPathList();
String expectedPath = "empty";
- if( checkBoxStr.equals( "true" ) )
- {
+
+ if (checkBoxStr.equals("true")) {
String uri = util.utils.getFullTestURL(location);
expectedPath = uri.substring(0, uri.lastIndexOf('/'));
}
+
log.println("pathlist: expected: " + expectedPath + ", output: " + setPath);
- return setPath.equals( expectedPath );
+ return setPath.equals(expectedPath);
}
+
return true;
- }
- else
+ } else
return false;
}
- private String getPathList()
- {
+ private String getPathList() {
String result = "";
+
try {
- Object oProv = tParam.getMSF().createInstance(
- "com.sun.star.configuration.ConfigurationProvider" );
-
- XMultiServiceFactory xProv = UnoRuntime.queryInterface(XMultiServiceFactory.class, oProv);
-
- //the path to the security settings in the registry
- PropertyValue aPathArg = new PropertyValue();
- aPathArg.Name="nodepath";
- aPathArg.Value="org.openoffice.Office.Common/Security/Scripting";
- // we don't want to cache the write
- PropertyValue aModeArg = new PropertyValue();
- aModeArg.Name="lazywrite";
- aModeArg.Value=Boolean.FALSE;
-
- Object[] aArgs = new Object[2];
- aArgs[0]=aPathArg;
- aArgs[1]=aModeArg;
- Object oConfigUpdate = xProv.createInstanceWithArguments(
- "com.sun.star.configuration.ConfigurationAccess",
- aArgs );
- XPropertySet xPropertySet = UnoRuntime.queryInterface(
- XPropertySet.class, oConfigUpdate );
-
- String[] paths = (String[])xPropertySet.getPropertyValue("SecureURL");
- if (paths == null || paths.length == 0)
- result = "empty";
- else
- result = paths[0];
-
- } catch (Exception e)
- {
+ Object oProv = tParam.getMSF().createInstance(
+ "com.sun.star.configuration.ConfigurationProvider");
+
+ XMultiServiceFactory xProv = UnoRuntime.queryInterface(
+ XMultiServiceFactory.class, oProv);
+
+ //the path to the security settings in the registry
+ PropertyValue aPathArg = new PropertyValue();
+ aPathArg.Name = "nodepath";
+ aPathArg.Value = "org.openoffice.Office.Common/Security/Scripting";
+ // we don't want to cache the write
+ PropertyValue aModeArg = new PropertyValue();
+ aModeArg.Name = "lazywrite";
+ aModeArg.Value = Boolean.FALSE;
+
+ Object[] aArgs = new Object[2];
+ aArgs[0] = aPathArg;
+ aArgs[1] = aModeArg;
+ Object oConfigUpdate = xProv.createInstanceWithArguments(
+ "com.sun.star.configuration.ConfigurationAccess",
+ aArgs);
+ XPropertySet xPropertySet = UnoRuntime.queryInterface(
+ XPropertySet.class, oConfigUpdate);
+
+ String[] paths = (String[])xPropertySet.getPropertyValue("SecureURL");
+
+ if (paths == null || paths.length == 0)
+ result = "empty";
+ else
+ result = paths[0];
+
+ } catch (Exception e) {
result = e.getClass().getName() + " getting list of secure URLs";
}
+
return result;
}
- private boolean setSecurity( int officeBasic, String confirm,
- String warning, String secureURLs )
- {
- boolean success=false;
+ private boolean setSecurity(int officeBasic, String confirm,
+ String warning, String secureURLs) {
+ boolean success = false;
+
try {
- Object oProv = tParam.getMSF().createInstance(
- "com.sun.star.configuration.ConfigurationProvider" );
-
- XMultiServiceFactory xProv = UnoRuntime.queryInterface(XMultiServiceFactory.class, oProv);
-
- //the path to the security settings in the registry
- PropertyValue aPathArg = new PropertyValue();
- aPathArg.Name="nodepath";
- aPathArg.Value="org.openoffice.Office.Common/Security/Scripting";
- // we don't want to cache the write
- PropertyValue aModeArg = new PropertyValue();
- aModeArg.Name="lazywrite";
- aModeArg.Value=Boolean.FALSE;
-
- Object[] aArgs = new Object[2];
- aArgs[0]=aPathArg;
- aArgs[1]=aModeArg;
- Object oConfigUpdate = xProv.createInstanceWithArguments(
- "com.sun.star.configuration.ConfigurationUpdateAccess",
- aArgs );
- XNameReplace xNameReplace = UnoRuntime.queryInterface(
- XNameReplace.class, oConfigUpdate );
- XChangesBatch xChangesBatch = UnoRuntime.queryInterface(
- XChangesBatch.class, oConfigUpdate );
-
- Object[] aSecureURLs;
- if (secureURLs == null) {
- aSecureURLs = new Object[0];
- }
- else {
- aSecureURLs = new Object[1];
- aSecureURLs[0] = secureURLs;
- }
- log.println("setting SecureURL");
- xNameReplace.replaceByName( "SecureURL", aSecureURLs );
+ Object oProv = tParam.getMSF().createInstance(
+ "com.sun.star.configuration.ConfigurationProvider");
+
+ XMultiServiceFactory xProv = UnoRuntime.queryInterface(
+ XMultiServiceFactory.class, oProv);
+
+ //the path to the security settings in the registry
+ PropertyValue aPathArg = new PropertyValue();
+ aPathArg.Name = "nodepath";
+ aPathArg.Value = "org.openoffice.Office.Common/Security/Scripting";
+ // we don't want to cache the write
+ PropertyValue aModeArg = new PropertyValue();
+ aModeArg.Name = "lazywrite";
+ aModeArg.Value = Boolean.FALSE;
+
+ Object[] aArgs = new Object[2];
+ aArgs[0] = aPathArg;
+ aArgs[1] = aModeArg;
+ Object oConfigUpdate = xProv.createInstanceWithArguments(
+ "com.sun.star.configuration.ConfigurationUpdateAccess",
+ aArgs);
+ XNameReplace xNameReplace = UnoRuntime.queryInterface(
+ XNameReplace.class, oConfigUpdate);
+ XChangesBatch xChangesBatch = UnoRuntime.queryInterface(
+ XChangesBatch.class, oConfigUpdate);
+
+ Object[] aSecureURLs;
+
+ if (secureURLs == null) {
+ aSecureURLs = new Object[0];
+ } else {
+ aSecureURLs = new Object[1];
+ aSecureURLs[0] = secureURLs;
+ }
- log.println("setting OfficeBasic");
- xNameReplace.replaceByName( "OfficeBasic", Integer.valueOf(officeBasic) );
+ log.println("setting SecureURL");
+ xNameReplace.replaceByName("SecureURL", aSecureURLs);
- Boolean bConfirm = null;
- if( ( confirm != null ) && ( confirm.equals("true") ) )
- {
- bConfirm = Boolean.TRUE;
- }
- else
- {
- bConfirm = Boolean.FALSE;
- }
- log.println("setting Confirmation");
- xNameReplace.replaceByName( "Confirmation", bConfirm );
+ log.println("setting OfficeBasic");
+ xNameReplace.replaceByName("OfficeBasic", Integer.valueOf(officeBasic));
- Boolean bWarning = null;
- if( ( warning != null ) && ( warning.equals("true") ) )
- {
- bWarning = Boolean.TRUE;
- }
- else
- {
- bWarning = Boolean.FALSE;
- }
- log.println("setting Warning");
- xNameReplace.replaceByName( "Warning", bWarning );
+ Boolean bConfirm = null;
+
+ if ((confirm != null) && (confirm.equals("true"))) {
+ bConfirm = Boolean.TRUE;
+ } else {
+ bConfirm = Boolean.FALSE;
+ }
- // and now commit the changes
- xChangesBatch.commitChanges();
- success=true;
+ log.println("setting Confirmation");
+ xNameReplace.replaceByName("Confirmation", bConfirm);
+
+ Boolean bWarning = null;
+
+ if ((warning != null) && (warning.equals("true"))) {
+ bWarning = Boolean.TRUE;
+ } else {
+ bWarning = Boolean.FALSE;
+ }
+
+ log.println("setting Warning");
+ xNameReplace.replaceByName("Warning", bWarning);
+
+ // and now commit the changes
+ xChangesBatch.commitChanges();
+ success = true;
} catch (Exception e) {
log.println("Error updating security settings: " +
- e.getMessage() );
+ e.getMessage());
}
+
return success;
}
@@ -315,23 +310,23 @@ public class _XScriptSecurity extends MultiMethodTest {
if (storageManager == null) {
try {
XPropertySet xProp = UnoRuntime.queryInterface(
- XPropertySet.class, tParam.getMSF());
+ XPropertySet.class, tParam.getMSF());
XComponentContext xContext = UnoRuntime.queryInterface(XComponentContext.class,
- xProp.getPropertyValue("DefaultContext"));
+ xProp.getPropertyValue("DefaultContext"));
XInterface ifc = (XInterface)
- xContext.getValueByName("/singletons/drafts.com.sun.star." +
- "script.framework.storage.theScriptStorageManager");
+ xContext.getValueByName("/singletons/drafts.com.sun.star." +
+ "script.framework.storage.theScriptStorageManager");
storageManager = UnoRuntime.queryInterface(XScriptStorageManager.class, ifc);
- }
- catch( Exception e ) {
+ } catch (Exception e) {
return -1;
}
}
access = getXSimpleFileAccess();
+
if (access == null)
return -1;
@@ -345,13 +340,13 @@ public class _XScriptSecurity extends MultiMethodTest {
try {
Object fa = tParam.getMSF().createInstance(
- "com.sun.star.ucb.SimpleFileAccess");
+ "com.sun.star.ucb.SimpleFileAccess");
access = UnoRuntime.queryInterface(XSimpleFileAccess.class, fa);
- }
- catch (com.sun.star.uno.Exception e) {
+ } catch (com.sun.star.uno.Exception e) {
return null;
}
+
return access;
}
diff --git a/scripting/workben/ifc/scripting/_XScriptStorageManager.java b/scripting/workben/ifc/scripting/_XScriptStorageManager.java
index f8eab044c772..0e300317cb60 100644
--- a/scripting/workben/ifc/scripting/_XScriptStorageManager.java
+++ b/scripting/workben/ifc/scripting/_XScriptStorageManager.java
@@ -66,20 +66,20 @@ public class _XScriptStorageManager extends MultiMethodTest {
if (access == null) {
output = "Couldn't create XSimpleFileAccess";
- }
- else {
+ } else {
try {
int id = oObj.createScriptStorage(access);
output = "success";
- }
- catch (com.sun.star.uno.RuntimeException re) {
+ } catch (com.sun.star.uno.RuntimeException re) {
log.println("Exception from createScriptStorage: " + re);
output = "com.sun.star.uno.RuntimeException";
}
}
+
log.println("expected: " + expected + ", output: " + output);
result &= output.equals(expected);
}
+
tRes.tested("createScriptStorage()", result);
}
@@ -116,18 +116,18 @@ public class _XScriptStorageManager extends MultiMethodTest {
output = "null";
else {
Object info = UnoRuntime.queryInterface(
- XScriptInfoAccess.class, ifc);
+ XScriptInfoAccess.class, ifc);
if (info == null)
output = "null";
else
output = "XScriptInfoAccess.class";
}
- }
- catch (com.sun.star.uno.RuntimeException re) {
+ } catch (com.sun.star.uno.RuntimeException re) {
log.println("Caught RuntimeException: " + re);
output = "com.sun.star.uno.RuntimeException";
}
+
log.println("expected: " + expected + ", output: " + output);
result &= output.equals(expected);
}
@@ -165,21 +165,22 @@ public class _XScriptStorageManager extends MultiMethodTest {
output = "null";
else {
Object info = UnoRuntime.queryInterface(
- XScriptInfoAccess.class, ifc);
+ XScriptInfoAccess.class, ifc);
if (info == null)
output = "null";
else
output = "XScriptInfoAccess.class";
}
- }
- catch (com.sun.star.uno.RuntimeException re) {
+ } catch (com.sun.star.uno.RuntimeException re) {
log.println("Caught RuntimeException: " + re);
output = "com.sun.star.uno.RuntimeException";
}
+
log.println("expected: " + expected + ", output: " + output);
result &= output.equals(expected);
}
+
tRes.tested("getScriptStorage()", result);
}
@@ -209,14 +210,15 @@ public class _XScriptStorageManager extends MultiMethodTest {
log.println("calling refreshScriptStorage with URI: " + uri);
oObj.refreshScriptStorage(uri);
output = "success";
- }
- catch (com.sun.star.uno.RuntimeException re) {
+ } catch (com.sun.star.uno.RuntimeException re) {
log.println("Caught RuntimeException: " + re);
output = "com.sun.star.uno.RuntimeException";
}
+
log.println("expected: " + expected + ", output: " + output);
result &= output.equals(expected);
}
+
tRes.tested("refreshScriptStorage()", result);
}
@@ -231,6 +233,7 @@ public class _XScriptStorageManager extends MultiMethodTest {
String uri = util.utils.getFullTestURL(location);
XSimpleFileAccess access = getXSimpleFileAccess();
+
if (access == null)
return -1;
@@ -242,13 +245,13 @@ public class _XScriptStorageManager extends MultiMethodTest {
try {
Object fa = tParam.getMSF().createInstance(
- "com.sun.star.ucb.SimpleFileAccess");
+ "com.sun.star.ucb.SimpleFileAccess");
access = UnoRuntime.queryInterface(XSimpleFileAccess.class, fa);
- }
- catch (com.sun.star.uno.Exception e) {
+ } catch (com.sun.star.uno.Exception e) {
return null;
}
+
return access;
}
}
diff --git a/scripting/workben/ifc/scripting/_XScriptStorageRefresh.java b/scripting/workben/ifc/scripting/_XScriptStorageRefresh.java
index bae6a3e5a20d..fb4bd7c0a316 100644
--- a/scripting/workben/ifc/scripting/_XScriptStorageRefresh.java
+++ b/scripting/workben/ifc/scripting/_XScriptStorageRefresh.java
@@ -61,14 +61,15 @@ public class _XScriptStorageRefresh extends MultiMethodTest {
try {
oObj.refresh();
output = "success";
- }
- catch (com.sun.star.uno.RuntimeException re) {
+ } catch (com.sun.star.uno.RuntimeException re) {
log.println("Caught RuntimeException: " + re);
output = "com.sun.star.uno.RuntimeException";
}
+
log.println("expected: " + expected + ", output: " + output);
result &= output.equals(expected);
}
+
tRes.tested("refresh()", result);
}
}
diff --git a/scripting/workben/installer/Banner.java b/scripting/workben/installer/Banner.java
index aea91a2caebd..d9945acd7331 100644
--- a/scripting/workben/installer/Banner.java
+++ b/scripting/workben/installer/Banner.java
@@ -20,31 +20,26 @@ package installer;
import java.awt.*;
-public class Banner extends Canvas
-{
+public class Banner extends Canvas {
Image img;
- Banner()
- {
+ Banner() {
setBackground(Color.white);
img = Toolkit.getDefaultToolkit().createImage("sidebar.jpg");
}
@Override
- public void paint(Graphics g)
- {
+ public void paint(Graphics g) {
g.drawImage(img, 0, 0, Color.white, null);
g.dispose();
}
@Override
- public void update(Graphics g)
- {
+ public void update(Graphics g) {
super.update(g);
}
@Override
- public Dimension getPreferredSize()
- {
+ public Dimension getPreferredSize() {
return new Dimension(137, 358);
}
diff --git a/scripting/workben/installer/ExceptionTraceHelper.java b/scripting/workben/installer/ExceptionTraceHelper.java
index e0e5c92558da..ecde5e448072 100644
--- a/scripting/workben/installer/ExceptionTraceHelper.java
+++ b/scripting/workben/installer/ExceptionTraceHelper.java
@@ -21,36 +21,29 @@ import java.io.ByteArrayOutputStream;
import java.io.PrintStream;
// class for propagating the exception stack traces across the Java/UNO bridge
-public class ExceptionTraceHelper
-{
- public static String getTrace( Exception e )
- {
+public class ExceptionTraceHelper {
+ public static String getTrace(Exception e) {
ByteArrayOutputStream baos = null;
PrintStream ps = null;
String result = "";
- try
- {
- baos = new ByteArrayOutputStream( 128 );
- ps = new PrintStream( baos );
- e.printStackTrace( ps );
- }
- finally
- {
- try
- {
- if ( baos != null )
- {
+
+ try {
+ baos = new ByteArrayOutputStream(128);
+ ps = new PrintStream(baos);
+ e.printStackTrace(ps);
+ } finally {
+ try {
+ if (baos != null) {
baos.close();
}
- if ( ps != null )
- {
+
+ if (ps != null) {
ps.close();
}
- }
- catch ( Exception excp )
- {
+ } catch (Exception excp) {
}
}
+
return result;
}
}
diff --git a/scripting/workben/installer/ExecCmd.java b/scripting/workben/installer/ExecCmd.java
index c812ae6229b7..e52a63aefac0 100644
--- a/scripting/workben/installer/ExecCmd.java
+++ b/scripting/workben/installer/ExecCmd.java
@@ -18,99 +18,88 @@
package installer;
import java.io.*;
-public class ExecCmd
-{
+public class ExecCmd {
- public boolean exec( String cmd, String[] env )
- {
- System.out.println("About to exectute " + cmd);
- final Process p;
- boolean result = false;
- try
- {
- Runtime rt = Runtime.getRuntime();
- p=rt.exec( cmd, env );
- new Thread(new Runnable() {
- public void run()
- {
- BufferedReader br_in = null;
- try
- {
- br_in = new BufferedReader(new InputStreamReader(p.getInputStream()));
- String buff = null;
- while ((buff = br_in.readLine()) != null)
- {
- System.out.println("Process out :" + buff);
- /*try
- {
- Thread.sleep(100);
- }
- catch(Exception e) {}*/
- }
- System.out.println("finished reading out");
- }
- catch (IOException ioe)
- {
+ public boolean exec(String cmd, String[] env) {
+ System.out.println("About to exectute " + cmd);
+ final Process p;
+ boolean result = false;
+
+ try {
+ Runtime rt = Runtime.getRuntime();
+ p = rt.exec(cmd, env);
+ new Thread(new Runnable() {
+ public void run() {
+ BufferedReader br_in = null;
+
+ try {
+ br_in = new BufferedReader(new InputStreamReader(p.getInputStream()));
+ String buff = null;
+
+ while ((buff = br_in.readLine()) != null) {
+ System.out.println("Process out :" + buff);
+ /*try
+ {
+ Thread.sleep(100);
+ }
+ catch(Exception e) {}*/
+ }
+
+ System.out.println("finished reading out");
+ } catch (IOException ioe) {
System.out.println("Exception caught printing javac result");
ioe.printStackTrace();
+ } finally {
+ if (br_in != null) {
+ try {
+ br_in.close();
+ } catch (Exception e) {} // nothing can be done
+ }
}
- finally
- {
- if ( br_in != null )
- {
- try
- {
- br_in.close();
- }
- catch( Exception e ) {} // nothing can be done
- }
- }
- } } ).start();
+ }
+ }).start();
new Thread(new Runnable() {
public void run() {
- BufferedReader br_err = null;
- try {
- br_err = new BufferedReader(new InputStreamReader(p.getErrorStream()));
- String buff = null;
- while ((buff = br_err.readLine()) != null) {
- System.out.println("Process err :" + buff);
- }
- System.out.println("finished reading err");
- } catch (IOException ioe) {
- System.out.println("Exception caught printing javac result");
- ioe.printStackTrace();
- }
- finally
- {
- if ( br_err != null )
- {
- try
- {
- br_err.close();
+ BufferedReader br_err = null;
+
+ try {
+ br_err = new BufferedReader(new InputStreamReader(p.getErrorStream()));
+ String buff = null;
+
+ while ((buff = br_err.readLine()) != null) {
+ System.out.println("Process err :" + buff);
+ }
+
+ System.out.println("finished reading err");
+ } catch (IOException ioe) {
+ System.out.println("Exception caught printing javac result");
+ ioe.printStackTrace();
+ } finally {
+ if (br_err != null) {
+ try {
+ br_err.close();
+ } catch (Exception e) {} // nothing can be done
}
- catch( Exception e ) {} // nothing can be done
}
- }
- } }).start();
+ }
+ }).start();
int exitcode = p.waitFor();
- if ( exitcode != 0 )
- {
- System.out.println("cmd [" + cmd + "] failed" );
- result= false;
- }
- else
- {
+
+ if (exitcode != 0) {
+ System.out.println("cmd [" + cmd + "] failed");
+ result = false;
+ } else {
System.out.println("cmd [" + cmd + "] completed successfully");
- result= true;
+ result = true;
}
+ } catch (Exception e) {
+ System.out.println("Exception");
+ e.printStackTrace();
}
- catch (Exception e) {
- System.out.println("Exception");
- e.printStackTrace();
- }
- System.out.println("command complete");
- return result;
+
+ System.out.println("command complete");
+ return result;
}
}
diff --git a/scripting/workben/installer/FileUpdater.java b/scripting/workben/installer/FileUpdater.java
index 5c628dbd89c4..6ba73692ca99 100644
--- a/scripting/workben/installer/FileUpdater.java
+++ b/scripting/workben/installer/FileUpdater.java
@@ -26,141 +26,158 @@ public class FileUpdater {
- public static boolean updateScriptXLC( String installPath, JLabel statusLabel ) {
+ public static boolean updateScriptXLC(String installPath, JLabel statusLabel) {
- File in_file = null;
- File out_file = null;
- FileWriter out = null;
- int count = 0;
+ File in_file = null;
+ File out_file = null;
+ FileWriter out = null;
+ int count = 0;
+
+ try {
+ in_file = new File(installPath + File.separator + "user" + File.separator +
+ "basic" + File.separator + "script.xlc");
+
+ String[] xmlArray = new String[50];
try {
- in_file = new File( installPath+File.separator+"user"+File.separator+"basic"+File.separator+"script.xlc" );
+ BufferedReader reader = new BufferedReader(new FileReader(in_file));
+ count = -1;
- String[] xmlArray = new String[50];
- try {
- BufferedReader reader = new BufferedReader(new FileReader(in_file));
- count = -1;
- for (String s = reader.readLine(); s != null; s = reader.readLine()) { //</oor:node>
- count = count + 1;
- xmlArray[count] = s;
+ for (String s = reader.readLine(); s != null;
+ s = reader.readLine()) { //</oor:node>
+ count = count + 1;
+ xmlArray[count] = s;
+ }
+
+ reader.close();
+ } catch (IOException ioe) {
+ String message = "Error reading script.xlc, please view SFrameworkInstall.log.";
+ System.out.println(message);
+ ioe.printStackTrace();
+ statusLabel.setText(message);
+ return false;
}
- reader.close();
- }
- catch( IOException ioe ) {
- String message = "Error reading script.xlc, please view SFrameworkInstall.log.";
- System.out.println(message);
- ioe.printStackTrace();
- statusLabel.setText(message);
- return false;
- }
- in_file.delete();
+ in_file.delete();
- out_file = new File( installPath+File.separator+"user"+File.separator+"basic"+File.separator+"script.xlc" );
- out_file.createNewFile();
- out = new FileWriter( out_file );
+ out_file = new File(installPath + File.separator + "user" + File.separator +
+ "basic" + File.separator + "script.xlc");
+ out_file.createNewFile();
+ out = new FileWriter(out_file);
- //split the string into a string array with one line of xml in each element
- for(int i=0; i<count + 1; i++) {
- out.write(xmlArray[i]+"\n");
- if( ( xmlArray[i].indexOf( "<library:libraries xmlns:library" ) != -1 ) && ( xmlArray[i+1].indexOf( "ScriptBindingLibrary" ) == -1 ) ) {
- String opSys = System.getProperty("os.name");
- if (opSys.indexOf("Windows") != -1) {
- out.write(" <library:library library:name=\"ScriptBindingLibrary\" library:link=\"true\"/>\n" );
- }
- else {
- out.write(" <library:library library:name=\"ScriptBindingLibrary\" xlink:href=\"file://"+installPath+"/share/basic/ScriptBindingLibrary/script.xlb/\" xlink:type=\"simple\" library:link=\"true\"/>\n" );
- }
- }
+ //split the string into a string array with one line of xml in each element
+ for (int i = 0; i < count + 1; i++) {
+ out.write(xmlArray[i] + "\n");
+
+ if ((xmlArray[i].indexOf("<library:libraries xmlns:library") != -1)
+ && (xmlArray[i + 1].indexOf("ScriptBindingLibrary") == -1)) {
+ String opSys = System.getProperty("os.name");
+
+ if (opSys.indexOf("Windows") != -1) {
+ out.write(" <library:library library:name=\"ScriptBindingLibrary\" library:link=\"true\"/>\n");
+ } else {
+ out.write(" <library:library library:name=\"ScriptBindingLibrary\" xlink:href=\"file://"
+ + installPath +
+ "/share/basic/ScriptBindingLibrary/script.xlb/\" xlink:type=\"simple\" library:link=\"true\"/>\n");
+ }
}
}
- catch( Exception e ) {
- String message = "\nError updating script.xlc, please view SFrameworkInstall.log.";
+ } catch (Exception e) {
+ String message =
+ "\nError updating script.xlc, please view SFrameworkInstall.log.";
System.out.println(message);
e.printStackTrace();
statusLabel.setText(message);
return false;
+ } finally {
+ try {
+ out.close();
+ } catch (Exception e) {
+ System.out.println("Update Script.xlc Failed, please view SFrameworkInstall.log.");
+ e.printStackTrace();
+ System.err.println(e);
}
- finally {
- try {
- out.close();
- }
- catch(Exception e) {
- System.out.println("Update Script.xlc Failed, please view SFrameworkInstall.log.");
- e.printStackTrace();
- System.err.println(e);
- }
- }
+ }
+
return true;
- }// updateScriptXLC
+ }// updateScriptXLC
- public static boolean updateDialogXLC( String installPath, JLabel statusLabel ) {
- File in_file = null;
- File out_file = null;
- FileWriter out = null;
- int count = 0;
+ public static boolean updateDialogXLC(String installPath, JLabel statusLabel) {
+ File in_file = null;
+ File out_file = null;
+ FileWriter out = null;
+ int count = 0;
+
+ try {
+ in_file = new File(installPath + File.separator + "user" + File.separator +
+ "basic" + File.separator + "dialog.xlc");
+
+ String[] xmlArray = new String[50];
try {
- in_file = new File( installPath+File.separator+"user"+File.separator+"basic"+File.separator+"dialog.xlc" );
+ BufferedReader reader = new BufferedReader(new FileReader(in_file));
+ count = -1;
- String[] xmlArray = new String[50];
- try {
- BufferedReader reader = new BufferedReader(new FileReader(in_file));
- count = -1;
- for (String s = reader.readLine(); s != null; s = reader.readLine()) {
- count = count + 1;
- xmlArray[count] = s;
+ for (String s = reader.readLine(); s != null; s = reader.readLine()) {
+ count = count + 1;
+ xmlArray[count] = s;
+ }
+
+ reader.close();
+ } catch (IOException ioe) {
+
+ String message =
+ "\nError reading dialog.xlc, please view SFrameworkInstall.log.";
+ System.out.println(message);
+ statusLabel.setText(message);
+ return false;
}
- reader.close();
- }
- catch( IOException ioe ) {
- String message = "\nError reading dialog.xlc, please view SFrameworkInstall.log.";
- System.out.println(message);
- statusLabel.setText(message);
- return false;
- }
- in_file.delete();
+ in_file.delete();
- out_file = new File( installPath+File.separator+"user"+File.separator+"basic"+File.separator+"dialog.xlc" );
- out_file.createNewFile();
+ out_file = new File(installPath + File.separator + "user" + File.separator +
+ "basic" + File.separator + "dialog.xlc");
+ out_file.createNewFile();
- out = new FileWriter( out_file );
+ out = new FileWriter(out_file);
- //split the string into a string array with one line of xml in each element
- for(int i=0; i<count + 1; i++) {
- out.write(xmlArray[i]+"\n");
- if( ( xmlArray[i].indexOf( "<library:libraries xmlns:library" ) != -1 ) && ( xmlArray[i+1].indexOf( "ScriptBindingLibrary" ) == -1 ) ) {
- String opSys = System.getProperty("os.name");
- if (opSys.indexOf("Windows") != -1) {
- out.write(" <library:library library:name=\"ScriptBindingLibrary\" library:link=\"true\"/>\n" );
- }
- else {
- out.write(" <library:library library:name=\"ScriptBindingLibrary\" xlink:href=\"file://"+installPath+"/share/basic/ScriptBindingLibrary/dialog.xlb/\" xlink:type=\"simple\" library:link=\"true\"/>\n" );
- }
- }
+ //split the string into a string array with one line of xml in each element
+ for (int i = 0; i < count + 1; i++) {
+ out.write(xmlArray[i] + "\n");
+
+ if ((xmlArray[i].indexOf("<library:libraries xmlns:library") != -1)
+ && (xmlArray[i + 1].indexOf("ScriptBindingLibrary") == -1)) {
+ String opSys = System.getProperty("os.name");
+
+ if (opSys.indexOf("Windows") != -1) {
+ out.write(" <library:library library:name=\"ScriptBindingLibrary\" library:link=\"true\"/>\n");
+ } else {
+ out.write(" <library:library library:name=\"ScriptBindingLibrary\" xlink:href=\"file://"
+ + installPath +
+ "/share/basic/ScriptBindingLibrary/dialog.xlb/\" xlink:type=\"simple\" library:link=\"true\"/>\n");
+ }
}
}
- catch( Exception e ) {
- String message = "\nError updating dialog.xlc, please view SFrameworkInstall.log.";
+ } catch (Exception e) {
+ String message =
+ "\nError updating dialog.xlc, please view SFrameworkInstall.log.";
System.out.println(message);
e.printStackTrace();
statusLabel.setText(message);
return false;
+ } finally {
+ try {
+ out.close();
+ } catch (Exception e) {
+ System.out.println("Update dialog.xlc Failed, please view SFrameworkInstall.log.");
+ e.printStackTrace();
+ System.err.println(e);
}
- finally {
- try {
- out.close();
- }
- catch(Exception e) {
- System.out.println("Update dialog.xlc Failed, please view SFrameworkInstall.log.");
- e.printStackTrace();
- System.err.println(e);
- }
- }
+ }
+
return true;
- }// updateScriptXLC
+ }// updateScriptXLC
}
diff --git a/scripting/workben/installer/Final.java b/scripting/workben/installer/Final.java
index 640bd93d0054..b951537e8e0c 100644
--- a/scripting/workben/installer/Final.java
+++ b/scripting/workben/installer/Final.java
@@ -22,7 +22,8 @@ import java.awt.event.*;
import java.util.*;
import javax.swing.*;
-public class Final extends javax.swing.JPanel implements ActionListener, InstallListener {
+public class Final extends javax.swing.JPanel implements ActionListener,
+ InstallListener {
/** Creates new form Welcome */
public Final(InstallWizard wizard) {
@@ -67,10 +68,9 @@ public class Final extends javax.swing.JPanel implements ActionListener, Install
}
public void actionPerformed(ActionEvent e) {
- // navNext is "Install"
- if (e.getSource() == nav.navNext)
- {
- JProgressBar progressBar=new JProgressBar();
+ // navNext is "Install"
+ if (e.getSource() == nav.navNext) {
+ JProgressBar progressBar = new JProgressBar();
progressBar.setMaximum(10);
progressBar.setValue(0);
statusPanel.add(progressBar, java.awt.BorderLayout.SOUTH);
@@ -79,50 +79,50 @@ public class Final extends javax.swing.JPanel implements ActionListener, Install
nav.enableCancel(false);
ArrayList<?> locations = InstallWizard.getLocations();
// Returned 1
- String path=null;
- for (int i =0;i<locations.size();i++){
- path= (String)locations.get(i);
- xud = new XmlUpdater(path, statusLine,progressBar,InstallWizard.bNetworkInstall,InstallWizard.bBindingsInstall);
- xud.addInstallListener(this);
- InstallWizard.setInstallStarted(true);
- InstallWizard.setPatchedTypes(false);
- InstallWizard.setPatchedJava(false);
- InstallWizard.setPatchedRDB(false);
- xud.start();
+ String path = null;
+
+ for (int i = 0; i < locations.size(); i++) {
+ path = (String)locations.get(i);
+ xud = new XmlUpdater(path, statusLine, progressBar,
+ InstallWizard.bNetworkInstall, InstallWizard.bBindingsInstall);
+ xud.addInstallListener(this);
+ InstallWizard.setInstallStarted(true);
+ InstallWizard.setPatchedTypes(false);
+ InstallWizard.setPatchedJava(false);
+ InstallWizard.setPatchedRDB(false);
+ xud.start();
}
}
- // set to "Exit" at end of installation process
- if (e.getSource() == nav.navCancel) {
- int answer = JOptionPane.showConfirmDialog(wizard, "Are you sure you want to exit?");
- if (answer == JOptionPane.YES_OPTION)
- {
- wizard.exitForm();
- }
- else
- {
- return;
+ // set to "Exit" at end of installation process
+ if (e.getSource() == nav.navCancel) {
+ int answer = JOptionPane.showConfirmDialog(wizard,
+ "Are you sure you want to exit?");
+
+ if (answer == JOptionPane.YES_OPTION) {
+ wizard.exitForm();
+ } else {
+ return;
+ }
}
- }
}// actionPerformed
public void installationComplete(InstallationEvent ev) {
- if( InstUtil.hasNetbeansInstallation() ) {
- nav.removeCancelListener(this);
- nav.setCancelListener(nav);
- nav.navCancel.setText("Finish");
- nav.enableIDE(true);
- nav.enableCancel(true);
- xud = null;
- }
- else {
- nav.removeCancelListener(this);
- nav.setCancelListener(nav);
- nav.navCancel.setText("Finish");
- nav.enableCancel(true);
- xud = null;
- }
+ if (InstUtil.hasNetbeansInstallation()) {
+ nav.removeCancelListener(this);
+ nav.setCancelListener(nav);
+ nav.navCancel.setText("Finish");
+ nav.enableIDE(true);
+ nav.enableCancel(true);
+ xud = null;
+ } else {
+ nav.removeCancelListener(this);
+ nav.setCancelListener(nav);
+ nav.navCancel.setText("Finish");
+ nav.enableCancel(true);
+ xud = null;
+ }
}
// Variables declaration - do not modify//GEN-BEGIN:variables
diff --git a/scripting/workben/installer/IdeFinal.java b/scripting/workben/installer/IdeFinal.java
index 33612f1907ef..93159b7b4e2b 100644
--- a/scripting/workben/installer/IdeFinal.java
+++ b/scripting/workben/installer/IdeFinal.java
@@ -22,13 +22,14 @@ import java.awt.event.*;
import java.util.*;
import javax.swing.*;
-public class IdeFinal extends javax.swing.JPanel implements ActionListener, InstallListener {
+public class IdeFinal extends javax.swing.JPanel implements ActionListener,
+ InstallListener {
/** Creates new form Welcome */
public IdeFinal(InstallWizard wizard) {
this.wizard = wizard;
setBackground(java.awt.Color.white);
- ideupdater = null;
+ ideupdater = null;
initComponents();
}
@@ -39,7 +40,7 @@ public class IdeFinal extends javax.swing.JPanel implements ActionListener, Inst
*/
private void initComponents() {//GEN-BEGIN:initComponents
statusPanel = new javax.swing.JPanel();
- statusPanel.setBackground(java.awt.Color.white);
+ statusPanel.setBackground(java.awt.Color.white);
statusLine = new javax.swing.JLabel("Ready", javax.swing.JLabel.CENTER);
setLayout(new java.awt.BorderLayout());
@@ -50,12 +51,12 @@ public class IdeFinal extends javax.swing.JPanel implements ActionListener, Inst
statusPanel.add(statusLine, java.awt.BorderLayout.CENTER);
add(statusPanel, java.awt.BorderLayout.CENTER);
- nav = new NavPanel(wizard, true, true, true, InstallWizard.IDEVERSIONS, "");
- nav.setNextListener(this);
- nav.removeCancelListener(nav);
- nav.setCancelListener(this);
- nav.navNext.setText("Install");
- add(nav, java.awt.BorderLayout.SOUTH);
+ nav = new NavPanel(wizard, true, true, true, InstallWizard.IDEVERSIONS, "");
+ nav.setNextListener(this);
+ nav.removeCancelListener(nav);
+ nav.setCancelListener(this);
+ nav.navNext.setText("Install");
+ add(nav, java.awt.BorderLayout.SOUTH);
}//GEN-END:initComponents
@Override
@@ -64,10 +65,9 @@ public class IdeFinal extends javax.swing.JPanel implements ActionListener, Inst
}
public void actionPerformed(ActionEvent e) {
- // navNext is "Install"
- if (e.getSource() == nav.navNext)
- {
- JProgressBar progressBar=new JProgressBar();
+ // navNext is "Install"
+ if (e.getSource() == nav.navNext) {
+ JProgressBar progressBar = new JProgressBar();
progressBar.setMaximum(10);
progressBar.setValue(0);
statusPanel.add(progressBar, java.awt.BorderLayout.SOUTH);
@@ -76,29 +76,29 @@ public class IdeFinal extends javax.swing.JPanel implements ActionListener, Inst
nav.enableCancel(false);
ArrayList<?> locations = InstallWizard.getLocations();
// Returned 1
- String path=null;
- for (int i =0;i<locations.size();i++){
- path= (String)locations.get(i);
-
- ideupdater = new IdeUpdater( path, statusLine, progressBar );
- ideupdater.addInstallListener(this);
- InstallWizard.setInstallStarted(true);
- ideupdater.start();
+ String path = null;
+
+ for (int i = 0; i < locations.size(); i++) {
+ path = (String)locations.get(i);
+
+ ideupdater = new IdeUpdater(path, statusLine, progressBar);
+ ideupdater.addInstallListener(this);
+ InstallWizard.setInstallStarted(true);
+ ideupdater.start();
}
}
- // set to "Exit" at end of installation process
- if (e.getSource() == nav.navCancel) {
- int answer = JOptionPane.showConfirmDialog(wizard, "Are you sure you want to exit?");
- if (answer == JOptionPane.YES_OPTION)
- {
- wizard.exitForm();
- }
- else
- {
- return;
+ // set to "Exit" at end of installation process
+ if (e.getSource() == nav.navCancel) {
+ int answer = JOptionPane.showConfirmDialog(wizard,
+ "Are you sure you want to exit?");
+
+ if (answer == JOptionPane.YES_OPTION) {
+ wizard.exitForm();
+ } else {
+ return;
+ }
}
- }
}// actionPerformed
diff --git a/scripting/workben/installer/IdeUpdater.java b/scripting/workben/installer/IdeUpdater.java
index b35b519abbe3..b0ec0cd35cbf 100644
--- a/scripting/workben/installer/IdeUpdater.java
+++ b/scripting/workben/installer/IdeUpdater.java
@@ -47,70 +47,65 @@ public class IdeUpdater extends Thread {
if (!installPath.endsWith(File.separator))
installPath += File.separator;
- File netbeansLauncher = new File( installPath + "bin" );
+ File netbeansLauncher = new File(installPath + "bin");
- if( netbeansLauncher.isDirectory() ) {
- isNetbeansPath = true;
- installPath = installPath +"modules" + File.separator;
- }
+ if (netbeansLauncher.isDirectory()) {
+ isNetbeansPath = true;
+ installPath = installPath + "modules" + File.separator;
+ }
- System.out.println( "IdeUpdater installPath is " + installPath + " isNetbeansPath is " + isNetbeansPath );
+ System.out.println("IdeUpdater installPath is " + installPath +
+ " isNetbeansPath is " + isNetbeansPath);
this.installPath = installPath;
this.statusLabel = statusLabel;
- listeners = new ArrayList<InstallListener>();
- threadSuspended = false;
- progressBar=pBar;
- progressBar.setStringPainted(true);
+ listeners = new ArrayList<InstallListener>();
+ threadSuspended = false;
+ progressBar = pBar;
+ progressBar.setStringPainted(true);
}// XmlUpdater
@Override
public void run() {
- internalThread = Thread.currentThread();
+ internalThread = Thread.currentThread();
- progressBar.setString("Unzipping Required Files");
+ progressBar.setString("Unzipping Required Files");
ZipData zd = new ZipData();
- // Adding IDE support
- if( isNetbeansPath ) {
- if (!zd.extractEntry("ide/office.jar",installPath, statusLabel))
- {
- onInstallComplete();
- return;
- }
- }
- else {
- if (!zd.extractEntry("ide/idesupport.jar",installPath, statusLabel))
- {
- onInstallComplete();
- return;
- }
- if (!zd.extractEntry("ide/OfficeScripting.jar",installPath, statusLabel))
- {
- onInstallComplete();
- return;
+ // Adding IDE support
+ if (isNetbeansPath) {
+ if (!zd.extractEntry("ide/office.jar", installPath, statusLabel)) {
+ onInstallComplete();
+ return;
+ }
+ } else {
+ if (!zd.extractEntry("ide/idesupport.jar", installPath, statusLabel)) {
+ onInstallComplete();
+ return;
+ }
+
+ if (!zd.extractEntry("ide/OfficeScripting.jar", installPath, statusLabel)) {
+ onInstallComplete();
+ return;
+ }
}
- }
- statusLabel.setText("Installation Complete");
- progressBar.setString("Installation Complete");
- progressBar.setValue(10);
- onInstallComplete();
+ statusLabel.setText("Installation Complete");
+ progressBar.setString("Installation Complete");
+ progressBar.setValue(10);
+ onInstallComplete();
}// run
- public void addInstallListener(InstallListener listener)
- {
+ public void addInstallListener(InstallListener listener) {
listeners.add(listener);
}// addInstallListener
- private void onInstallComplete()
- {
- for( InstallListener l : listeners)
- {
+ private void onInstallComplete() {
+ for (InstallListener l : listeners) {
l.installationComplete(null);
}
}// onInstallComplete
diff --git a/scripting/workben/installer/IdeVersion.java b/scripting/workben/installer/IdeVersion.java
index ab50752e2cd4..3a7cc5a485a4 100644
--- a/scripting/workben/installer/IdeVersion.java
+++ b/scripting/workben/installer/IdeVersion.java
@@ -26,12 +26,13 @@ import javax.swing.*;
import javax.swing.event.*;
import javax.swing.table.*;
-public class IdeVersion extends javax.swing.JPanel implements ActionListener, TableModelListener {
+public class IdeVersion extends javax.swing.JPanel implements ActionListener,
+ TableModelListener {
/** Creates new form Welcome */
public IdeVersion(InstallWizard wizard) {
- this.wizard=wizard;
- setBackground(Color.white);
+ this.wizard = wizard;
+ setBackground(Color.white);
initComponents();
}
@@ -46,47 +47,49 @@ public class IdeVersion extends javax.swing.JPanel implements ActionListener, Ta
setLayout(new BorderLayout());
- try {
- Properties netbeansProps = InstUtil.getNetbeansLocation();
- Properties ideProps = new Properties();
- if(netbeansProps!=null )
- {
+ try {
+ Properties netbeansProps = InstUtil.getNetbeansLocation();
+ Properties ideProps = new Properties();
+
+ if (netbeansProps != null) {
System.out.println("**** Found netbeans install");
- for( int n = 0; n < netbeansProps.size(); n++ ) {
- for( int v = 0; v < InstUtil.versions.length; v++ ) {
- System.out.println("n: " +n+" v: " +v);
- String key = InstUtil.versions[v];
- System.out.println("It got here1");
- String path = null;
- if ( (path = netbeansProps.getProperty(key) ) != null ) {
- ideProps.put(key, path);
+
+ for (int n = 0; n < netbeansProps.size(); n++) {
+ for (int v = 0; v < InstUtil.versions.length; v++) {
+ System.out.println("n: " + n + " v: " + v);
+ String key = InstUtil.versions[v];
+ System.out.println("It got here1");
+ String path = null;
+
+ if ((path = netbeansProps.getProperty(key)) != null) {
+ ideProps.put(key, path);
+ }
+ }
}
}
- }
- }
- props = ideProps;
- }
- catch (Exception e) {
+
+ props = ideProps;
+ } catch (Exception e) {
System.err.println("Exception thrown in initComponents");
}
- tableModel = new MyTableModelIDE (props, InstUtil.versions);
+ tableModel = new MyTableModelIDE(props, InstUtil.versions);
- if (tableModel.getRowCount() == 0)
- {
- JOptionPane.showMessageDialog(this, "No compatible IDEs were found.", "Invalid versions", JOptionPane.ERROR_MESSAGE);
- }
+ if (tableModel.getRowCount() == 0) {
+ JOptionPane.showMessageDialog(this, "No compatible IDEs were found.",
+ "Invalid versions", JOptionPane.ERROR_MESSAGE);
+ }
tableModel.addTableModelListener(this);
JTable tableVersions = new JTable(tableModel) {
@Override
- public String getToolTipText(MouseEvent event)
- {
- int col = columnAtPoint( event.getPoint() );
+ public String getToolTipText(MouseEvent event) {
+ int col = columnAtPoint(event.getPoint());
+
if (col != 2)
return null;
- int row = rowAtPoint( event.getPoint() );
+ int row = rowAtPoint(event.getPoint());
Object o = getValueAt(row, col);
if (o == null)
@@ -99,14 +102,14 @@ public class IdeVersion extends javax.swing.JPanel implements ActionListener, Ta
}
@Override
- public Point getToolTipLocation(MouseEvent event)
- {
- int col = columnAtPoint( event.getPoint() );
+ public Point getToolTipLocation(MouseEvent event) {
+ int col = columnAtPoint(event.getPoint());
+
if (col != 2)
return null;
- int row = rowAtPoint( event.getPoint() );
- Object o = getValueAt(row,col);
+ int row = rowAtPoint(event.getPoint());
+ Object o = getValueAt(row, col);
if (o == null)
return null;
@@ -115,7 +118,7 @@ public class IdeVersion extends javax.swing.JPanel implements ActionListener, Ta
return null;
Point pt = getCellRect(row, col, true).getLocation();
- pt.translate(-1,-2);
+ pt.translate(-1, -2);
return pt;
}
};
@@ -123,7 +126,7 @@ public class IdeVersion extends javax.swing.JPanel implements ActionListener, Ta
JScrollPane scroll = new JScrollPane(tableVersions);
tableVersions.setPreferredSize(
- new Dimension(InstallWizard.DEFWIDTH,InstallWizard.DEFHEIGHT));
+ new Dimension(InstallWizard.DEFWIDTH, InstallWizard.DEFHEIGHT));
tableVersions.setRowSelectionAllowed(false);
tableVersions.setColumnSelectionAllowed(false);
@@ -132,12 +135,14 @@ public class IdeVersion extends javax.swing.JPanel implements ActionListener, Ta
initColumnSizes(tableVersions, tableModel);
versionPanel.add(scroll);
- JTextArea area = new JTextArea("Please select IDEs below that you wish to add Scripting support to");
+ JTextArea area = new
+ JTextArea("Please select IDEs below that you wish to add Scripting support to");
area.setLineWrap(true);
area.setEditable(false);
add(area, BorderLayout.NORTH);
add(versionPanel, BorderLayout.CENTER);
- nav = new NavPanel(wizard, true, false, true, InstallWizard.IDEWELCOME, InstallWizard.IDEFINAL);
+ nav = new NavPanel(wizard, true, false, true, InstallWizard.IDEWELCOME,
+ InstallWizard.IDEFINAL);
nav.setNextListener(this);
add(nav, BorderLayout.SOUTH);
@@ -153,8 +158,10 @@ public class IdeVersion extends javax.swing.JPanel implements ActionListener, Ta
public void actionPerformed(ActionEvent ev) {
InstallWizard.clearLocations();
int len = tableModel.data.size();
+
for (int i = 0; i < len; i++) {
ArrayList<?> list = tableModel.data.get(i);
+
if (((Boolean)list.get(0)).booleanValue())
InstallWizard.storeLocation((String)list.get(2));
}
@@ -164,8 +171,7 @@ public class IdeVersion extends javax.swing.JPanel implements ActionListener, Ta
public void tableChanged(TableModelEvent e) {
if (tableModel.isAnySelected()) {
nav.enableNext(true);
- }
- else {
+ } else {
nav.enableNext(false);
}
}
@@ -184,9 +190,9 @@ public class IdeVersion extends javax.swing.JPanel implements ActionListener, Ta
try {
comp = column.getHeaderRenderer().
- getTableCellRendererComponent(
- null, column.getHeaderValue(),
- false, false, 0, 0);
+ getTableCellRendererComponent(
+ null, column.getHeaderValue(),
+ false, false, 0, 0);
headerWidth = comp.getPreferredSize().width;
} catch (NullPointerException e) {
// System.err.println("Null pointer exception!");
@@ -201,19 +207,19 @@ public class IdeVersion extends javax.swing.JPanel implements ActionListener, Ta
System.out.println("longValues: " + longValues[i]);
comp = table.getDefaultRenderer(model.getColumnClass(i)).
- getTableCellRendererComponent(
- table, longValues[i],
- false, false, 0, i);
+ getTableCellRendererComponent(
+ table, longValues[i],
+ false, false, 0, i);
cellWidth = comp.getPreferredSize().width;
preferredWidth = Math.max(headerWidth, cellWidth);
if (false) {
System.out.println("Initializing width of column "
- + i + ". "
- + "preferredWidth = " + preferredWidth
- + "; totalWidth = " + totalWidth
- + "; leftWidth = " + (InstallWizard.DEFWIDTH - totalWidth));
+ + i + ". "
+ + "preferredWidth = " + preferredWidth
+ + "; totalWidth = " + totalWidth
+ + "; leftWidth = " + (InstallWizard.DEFWIDTH - totalWidth));
}
//XXX: Before Swing 1.1 Beta 2, use setMinWidth instead.
@@ -222,8 +228,7 @@ public class IdeVersion extends javax.swing.JPanel implements ActionListener, Ta
column.setPreferredWidth(InstallWizard.DEFWIDTH - totalWidth);
else
column.setPreferredWidth(preferredWidth);
- }
- else {
+ } else {
column.setMinWidth(preferredWidth);
totalWidth += preferredWidth;
}
@@ -236,17 +241,18 @@ public class IdeVersion extends javax.swing.JPanel implements ActionListener, Ta
private NavPanel nav;
// End of variables declaration//GEN-END:variables
- }
+}
class MyTableModelIDE extends AbstractTableModel {
ArrayList<ArrayList<Object>> data;
private String colNames[] = {"", "IDE Name", "IDE Location"};
Object[] longValues = new Object[] {Boolean.TRUE, "Name", "Location"};
- MyTableModelIDE (Properties properties, String [] validVersions) {
+ MyTableModelIDE(Properties properties, String [] validVersions) {
data = new ArrayList<ArrayList<Object>>();
int len = validVersions.length;
+
for (int i = 0; i < len; i++) {
String key = validVersions[i];
String path = null;
@@ -256,11 +262,13 @@ class MyTableModelIDE extends AbstractTableModel {
row.add(0, Boolean.FALSE);
row.add(1, key);
+
if (key.length() > ((String)longValues[1]).length()) {
longValues[1] = key;
}
row.add(2, path);
+
if (path.length() > ((String)longValues[2]).length()) {
longValues[2] = path;
}
@@ -292,35 +300,38 @@ class MyTableModelIDE extends AbstractTableModel {
return aRow.get(col);
}
- @Override
- public Class getColumnClass(int c) {
+ @Override
+ public Class getColumnClass(int c) {
return getValueAt(0, c).getClass();
- }
+ }
- @Override
- public boolean isCellEditable(int row, int col) {
- return (col == 0);
- }
+ @Override
+ public boolean isCellEditable(int row, int col) {
+ return (col == 0);
+ }
- @Override
- public void setValueAt(Object value, int row, int col) {
+ @Override
+ public void setValueAt(Object value, int row, int col) {
ArrayList<Object> aRow = data.get(row);
aRow.set(col, value);
fireTableCellUpdated(row, col);
- }
+ }
- public boolean isAnySelected() {
+ public boolean isAnySelected() {
Iterator iter = data.iterator();
+
while (iter.hasNext()) {
ArrayList<?> row = (ArrayList<?>)iter.next();
+
if (((Boolean)row.get(0)).booleanValue()) {
- return true;
+ return true;
}
}
+
return false;
- }
+ }
}
diff --git a/scripting/workben/installer/IdeWelcome.java b/scripting/workben/installer/IdeWelcome.java
index a0d3a5145ee0..c6852bbd639c 100644
--- a/scripting/workben/installer/IdeWelcome.java
+++ b/scripting/workben/installer/IdeWelcome.java
@@ -25,7 +25,8 @@ public class IdeWelcome extends javax.swing.JPanel implements ActionListener {
/** Creates new form Welcome */
public IdeWelcome(InstallWizard wizard) {
this.wizard = wizard;
- setBorder(new javax.swing.border.EtchedBorder(javax.swing.border.EtchedBorder.RAISED));
+ setBorder(new javax.swing.border.EtchedBorder(
+ javax.swing.border.EtchedBorder.RAISED));
initComponents();
}
@@ -45,13 +46,15 @@ public class IdeWelcome extends javax.swing.JPanel implements ActionListener {
area.setLineWrap(true);
area.setText("\n Click Next to include Scripting Framework support for IDEs.");
area.append("\n Click Cancel exit the Installation process. \n");
- if( InstUtil.hasNetbeansInstallation() ) {
- area.append("\n \tA version of Netbeans has been detected. \n");
- }
+
+ if (InstUtil.hasNetbeansInstallation()) {
+ area.append("\n \tA version of Netbeans has been detected. \n");
+ }
welcomePanel.add(area, java.awt.BorderLayout.CENTER);
add(welcomePanel, java.awt.BorderLayout.CENTER);
- NavPanel nav = new NavPanel(wizard, false, true, true, "", InstallWizard.IDEVERSIONS);
+ NavPanel nav = new NavPanel(wizard, false, true, true, "",
+ InstallWizard.IDEVERSIONS);
nav.setNextListener(this);
add(nav, java.awt.BorderLayout.SOUTH);
@@ -62,8 +65,7 @@ public class IdeWelcome extends javax.swing.JPanel implements ActionListener {
return new java.awt.Dimension(InstallWizard.DEFWIDTH, InstallWizard.DEFHEIGHT);
}
- public void actionPerformed(ActionEvent ev)
- {
+ public void actionPerformed(ActionEvent ev) {
//Perform next actions here...
}
diff --git a/scripting/workben/installer/InstUtil.java b/scripting/workben/installer/InstUtil.java
index d9bab179344f..262ce6c01e6b 100644
--- a/scripting/workben/installer/InstUtil.java
+++ b/scripting/workben/installer/InstUtil.java
@@ -35,12 +35,14 @@ public class InstUtil {
String os = System.getProperty("os.name");
if (os.indexOf("Windows") != -1) {
- boolean bSVersionInHomeDir = new File(thePath.toString() + "sversion.ini").exists();
+ boolean bSVersionInHomeDir = new File(thePath.toString() +
+ "sversion.ini").exists();
if (!bSVersionInHomeDir) {
thePath.append("Application Data");
thePath.append(File.separator);
}
+
theFile = findVersionFile(new File(thePath.toString()));
} else if (os.indexOf("SunOS") != -1) {
thePath.append(".sversionrc");
@@ -50,14 +52,14 @@ public class InstUtil {
theFile = new File(thePath.toString());
}
- if (theFile == null)
- {
+ if (theFile == null) {
throw new IOException("Could not locate the OpenOffice settings file.\nAre you sure StarOffice is installed on your system?");
}
- if (!theFile.exists())
- {
+
+ if (!theFile.exists()) {
throw new IOException("Could not locate the OpenOffice settings file.\nAre you sure StarOffice is installed on your system?");
}
+
return theFile;
}
@@ -65,28 +67,28 @@ public class InstUtil {
public static boolean hasNetbeansInstallation() {
boolean result = false;
- result = checkForSupportedVersion( getNetbeansLocation(), versions );
+ result = checkForSupportedVersion(getNetbeansLocation(), versions);
if (!result)
System.out.println("No supported version of NetBeans found.");
+
return result;
}
- private static boolean checkForSupportedVersion( Properties installs, String[] supportedVersions )
- {
- if ( installs != null )
- {
- for ( int index = 0; index < supportedVersions.length; index++ )
- {
+ private static boolean checkForSupportedVersion(Properties installs,
+ String[] supportedVersions) {
+ if (installs != null) {
+ for (int index = 0; index < supportedVersions.length; index++) {
String key = supportedVersions[ index ];
- if ( installs.getProperty(key) != null )
- {
+
+ if (installs.getProperty(key) != null) {
// at least one supported version for netbeans present, so return;
return true;
}
}
}
+
return false;
}
@@ -96,95 +98,93 @@ public class InstUtil {
public static Properties getNetbeansLocation() {
- Properties results = new Properties();
+ Properties results = new Properties();
- StringBuffer str = new StringBuffer();
+ StringBuffer str = new StringBuffer();
str.append(System.getProperty("user.home"));
str.append(File.separator);
- StringBuffer thePath = new StringBuffer(str.toString());
+ StringBuffer thePath = new StringBuffer(str.toString());
String os = System.getProperty("os.name");
- if (os.indexOf("Windows") != -1) {
- thePath.append(".netbeans");
+ if (os.indexOf("Windows") != -1) {
+ thePath.append(".netbeans");
} else if (os.indexOf("SunOS") != -1) {
- thePath.append(".netbeans");
+ thePath.append(".netbeans");
} else if (os.indexOf("Linux") != -1) {
- thePath.append(".netbeans");
- }
-
- if ( thePath.toString().indexOf( ".netbeans" ) == -1 )
- return null;
- else if ( new File( thePath.append( File.separator+"3.4"+File.separator ).toString() ).isDirectory() ) {
-
- System.out.println( "Found NetBeans 3.4 user directory: " + thePath );
- File netbeansLogFile = new File( thePath.toString() + File.separator + "system" + File.separator + "ide.log" );
- if( netbeansLogFile.exists() ) {
- String installPath = getNetbeansInstallation( netbeansLogFile );
- File f = new File(installPath);
- results.put("NetBeans 3.4", f.getPath()+File.separator);
- System.out.println( "NetBeans Installation directory: " + f.getPath());
- }
- else {
- System.out.println( "No NetBeans log file found" );
- return null;
+ thePath.append(".netbeans");
}
- }
- else
- {
- System.out.println( "No NetBeans user directory found" );
- return null;
+
+ if (thePath.toString().indexOf(".netbeans") == -1)
+ return null;
+ else if (new File(thePath.append(File.separator + "3.4" +
+ File.separator).toString()).isDirectory()) {
+
+ System.out.println("Found NetBeans 3.4 user directory: " + thePath);
+ File netbeansLogFile = new File(thePath.toString() + File.separator + "system" +
+ File.separator + "ide.log");
+
+ if (netbeansLogFile.exists()) {
+ String installPath = getNetbeansInstallation(netbeansLogFile);
+ File f = new File(installPath);
+ results.put("NetBeans 3.4", f.getPath() + File.separator);
+ System.out.println("NetBeans Installation directory: " + f.getPath());
+ } else {
+ System.out.println("No NetBeans log file found");
+ return null;
+ }
+ } else {
+ System.out.println("No NetBeans user directory found");
+ return null;
}
- return results;
+ return results;
}
- private static String getNetbeansInstallation( File logFile ) {
+ private static String getNetbeansInstallation(File logFile) {
String installPath = "";
+
try {
- BufferedReader reader = new BufferedReader(new FileReader(logFile));
+ BufferedReader reader = new BufferedReader(new FileReader(logFile));
+
+ for (String s = reader.readLine(); s != null; s = reader.readLine()) {
+ if (s.indexOf("IDE Install") != -1) {
+ int pathStart = s.indexOf("=") + 2;
+ installPath = s.substring(pathStart, s.length());
+ int pathEnd = installPath.indexOf(";");
+ installPath = installPath.substring(0, pathEnd) + File.separator;
+ break;
+ }
+ }
- for (String s = reader.readLine(); s != null; s = reader.readLine()) {
- if( s.indexOf( "IDE Install" ) != -1 ) {
- int pathStart = s.indexOf( "=" ) + 2;
- installPath = s.substring( pathStart, s.length() );
- int pathEnd = installPath.indexOf( ";");
- installPath = installPath.substring( 0, pathEnd ) +File.separator;
- break;
- }
- }
- reader.close();
+ reader.close();
+ } catch (IOException ioe) {
+ System.out.println("Error reading Netbeans location information");
}
- catch( IOException ioe ) {
- System.out.println( "Error reading Netbeans location information" );
- }
return installPath;
}
- private static File findVersionFile(File start)
- {
+ private static File findVersionFile(File start) {
File versionFile = null;
File files[] = start.listFiles(new VersionFilter());
- if (files.length == 0)
- {
+
+ if (files.length == 0) {
File dirs[] = start.listFiles(new DirFilter());
- for (int i=0; i< dirs.length; i++)
- {
+
+ for (int i = 0; i < dirs.length; i++) {
versionFile = findVersionFile(dirs[i]);
- if (versionFile != null)
- {
+
+ if (versionFile != null) {
break;
}
}
- }
- else
- {
+ } else {
versionFile = files[0];
}
@@ -194,10 +194,12 @@ public class InstUtil {
private static boolean verifySversionExists(File sversionFile) {
if (!sversionFile.exists())
return false;
+
return true;
}
- public static Properties getOfficeVersions(File sversionFile) throws IOException {
+ public static Properties getOfficeVersions(File sversionFile) throws
+ IOException {
BufferedReader reader = new BufferedReader(new FileReader(sversionFile));
String sectionName = null;
Properties results = new Properties();
@@ -205,56 +207,60 @@ public class InstUtil {
for (String s = reader.readLine(); s != null; s = reader.readLine()) {
if (s.length() == 0)
continue;
+
if (s.charAt(0) == '[') {
sectionName = s.substring(1, s.length() - 1);
continue;
}
+
if ((sectionName != null) && sectionName.equalsIgnoreCase("Versions")) {
- int equals = s.indexOf( "=" );
- String officeName = s.substring(0, equals );
+ int equals = s.indexOf("=");
+ String officeName = s.substring(0, equals);
- String instPath = s.substring(equals + 8, s.length());
- String [] parts = new String[2];
- parts[0] = officeName;
- parts[1] = instPath + File.separator;
+ String instPath = s.substring(equals + 8, s.length());
+ String [] parts = new String[2];
+ parts[0] = officeName;
+ parts[1] = instPath + File.separator;
if (parts.length == 2) {
- try {
+ try {
URL url = new URL("file://" + parts[1].trim());
- String opSys =System.getProperty("os.name");
- if (opSys.indexOf("Windows")!=-1){
- String windowsPath = URLDecoder.decode( url.getPath() );
- boolean firstSlash = true;
- while( windowsPath.indexOf("/") != -1 ) {
- int forwardSlashPos = windowsPath.indexOf("/");
- String firstPart = windowsPath.substring( 0, forwardSlashPos );
- String lastPart = windowsPath.substring( forwardSlashPos + 1, windowsPath.length() );
- if( firstSlash ) {
- windowsPath = lastPart;
- firstSlash = false;
- }
- else {
- windowsPath = firstPart + "\\" + lastPart;
- }
- }
- int lastSlash = windowsPath.lastIndexOf("\\");
- windowsPath = windowsPath.substring( 0, lastSlash );
- results.put( parts[0].trim(), windowsPath );
- }
- else {
- results.put(parts[0].trim(), URLDecoder.decode(url.getPath()));
- }
+ String opSys = System.getProperty("os.name");
+
+ if (opSys.indexOf("Windows") != -1) {
+ String windowsPath = URLDecoder.decode(url.getPath());
+ boolean firstSlash = true;
+
+ while (windowsPath.indexOf("/") != -1) {
+ int forwardSlashPos = windowsPath.indexOf("/");
+ String firstPart = windowsPath.substring(0, forwardSlashPos);
+ String lastPart = windowsPath.substring(forwardSlashPos + 1,
+ windowsPath.length());
+
+ if (firstSlash) {
+ windowsPath = lastPart;
+ firstSlash = false;
+ } else {
+ windowsPath = firstPart + "\\" + lastPart;
+ }
+ }
+
+ int lastSlash = windowsPath.lastIndexOf("\\");
+ windowsPath = windowsPath.substring(0, lastSlash);
+ results.put(parts[0].trim(), windowsPath);
+ } else {
+ results.put(parts[0].trim(), URLDecoder.decode(url.getPath()));
+ }
+ } catch (MalformedURLException eSyntax) {
+ results.put(parts[0].trim(), parts[1].trim());
+ System.err.println("GotHereException");
}
- catch (MalformedURLException eSyntax) {
- results.put(parts[0].trim(), parts[1].trim());
- System.err.println("GotHereException");
- }
- }
- else {
+ } else {
System.out.println("not splitting on equals");
}
}
}
+
reader.close();
return results;
}
@@ -266,31 +272,34 @@ public class InstUtil {
private static boolean isCorrectJavaVersion() {
if (System.getProperty("java.version").startsWith("1.4"))
return true;
+
return false;
}
public static void main(String args[]) {
InstUtil inst = new InstUtil();
File f = null;
- try
- {
+
+ try {
f = InstUtil.buildSversionLocation();
- }
- catch (IOException e)
- {
+ } catch (IOException e) {
e.printStackTrace();
System.out.println(e.getMessage());
}
+
if (!InstUtil.verifySversionExists(f)) {
System.err.println("Problem with sversion.ini");
}
+
try {
InstUtil.getOfficeVersions(f);
} catch (IOException e) {
e.printStackTrace();
System.err.println(e);
}
+
System.out.println(InstUtil.getJavaVersion());
+
if (!InstUtil.isCorrectJavaVersion()) {
System.err.println("Not correct Java Version");
}
@@ -301,19 +310,14 @@ public class InstUtil {
-class DirFilter implements java.io.FileFilter
-{
- public boolean accept(File aFile)
- {
+class DirFilter implements java.io.FileFilter {
+ public boolean accept(File aFile) {
return aFile.isDirectory();
}
}
-class VersionFilter implements java.io.FileFilter
-{
- public boolean accept(File aFile)
- {
- if (aFile.getName().compareToIgnoreCase("sversion.ini") == 0)
- {
+class VersionFilter implements java.io.FileFilter {
+ public boolean accept(File aFile) {
+ if (aFile.getName().compareToIgnoreCase("sversion.ini") == 0) {
return true;
}
diff --git a/scripting/workben/installer/InstallListener.java b/scripting/workben/installer/InstallListener.java
index 6dd111559902..81a005668369 100644
--- a/scripting/workben/installer/InstallListener.java
+++ b/scripting/workben/installer/InstallListener.java
@@ -18,7 +18,6 @@
package installer;
-public interface InstallListener
-{
+public interface InstallListener {
void installationComplete(InstallationEvent e);
}
diff --git a/scripting/workben/installer/InstallWizard.java b/scripting/workben/installer/InstallWizard.java
index c02f5f13b904..fc9d3bdf19da 100644
--- a/scripting/workben/installer/InstallWizard.java
+++ b/scripting/workben/installer/InstallWizard.java
@@ -25,77 +25,78 @@ import java.util.*;
import java.net.*;
import java.io.*;
-public class InstallWizard extends javax.swing.JFrame implements ActionListener {
-/*
- private static class ShutdownHook extends Thread {
- public void run()
- {
- if (InstallWizard.isInstallStarted())
- {
- // Check for and backup any config.xml files
- // Check for and backup any StarBasic macro files
- // Check for and backup ProtocolHandler
-
- if (!InstallWizard.isPatchedTypes())
+public class InstallWizard extends javax.swing.JFrame implements
+ ActionListener {
+ /*
+ private static class ShutdownHook extends Thread {
+ public void run()
{
- File backup = new File(InstUtil.getTmpDir(), "TypeDetection.xml");
- File destination = new File(InstallWizard.getTypesPath());
- InstUtil.copy(backup, destination); //Restore typedetection.xml
- }
- if (!InstallWizard.isPatchedJava())
- {
- File backup = new File(InstUtil.getTmpDir(), "Java.xml");
- File destination = new File(InstallWizard.getJavaPath());
- InstUtil.copy(backup, destination); //Restore typedetection.xml
- }
- if (!InstallWizard.isPatchedRDB())
- {
- File backup = new File(InstUtil.getTmpDir(), "applicat.rdb");
- File destination = new File(InstallWizard.getJavaPath());
- //InstUtil.copy(backup, destination); //Restore typedetection.xml
- }
+ if (InstallWizard.isInstallStarted())
+ {
+ // Check for and backup any config.xml files
+ // Check for and backup any StarBasic macro files
+ // Check for and backup ProtocolHandler
- System.out.println( "ShutdownHook" );
+ if (!InstallWizard.isPatchedTypes())
+ {
+ File backup = new File(InstUtil.getTmpDir(), "TypeDetection.xml");
+ File destination = new File(InstallWizard.getTypesPath());
+ InstUtil.copy(backup, destination); //Restore typedetection.xml
+ }
+ if (!InstallWizard.isPatchedJava())
+ {
+ File backup = new File(InstUtil.getTmpDir(), "Java.xml");
+ File destination = new File(InstallWizard.getJavaPath());
+ InstUtil.copy(backup, destination); //Restore typedetection.xml
+ }
+ if (!InstallWizard.isPatchedRDB())
+ {
+ File backup = new File(InstUtil.getTmpDir(), "applicat.rdb");
+ File destination = new File(InstallWizard.getJavaPath());
+ //InstUtil.copy(backup, destination); //Restore typedetection.xml
}
- InstUtil.removeTmpDir();
- }
- }// class ShutdownHook
+ System.out.println( "ShutdownHook" );
+ }
- static {
- Runtime rt=Runtime.getRuntime();
- rt.addShutdownHook(new ShutdownHook());
- }
-*/
+ InstUtil.removeTmpDir();
+ }
+ }// class ShutdownHook
+
+ static {
+ Runtime rt=Runtime.getRuntime();
+ rt.addShutdownHook(new ShutdownHook());
+ }
+ */
/** Creates new form InstallWizard */
public InstallWizard() {
super("Office Scripting Framework Installer - Early Developer Release");
- try {
- System.out.print("All diagnostic output is being redirected to SFrameworkInstall.log\n");
- System.out.print("Location: "+ System.getProperty( "user.dir" ) +
- File.separator + "SFrameworkInstall.log\n");
-
- LogStream log = new LogStream( "SFrameworkInstall.log" );
- System.setErr(log);
-
- System.setOut(log);
- }
- catch( FileNotFoundException fnfe ) {
- System.err.println("Office Scripting Framework Installer - Error: ");
- System.err.println("Unable to create log file for installation.");
- exitForm();
- }
-
- setBackground(new Color(0,0,0));
- locations = new ArrayList<String>();
- Point center = new Point( 400, 400 );
- int windowWidth=200;
- int windowHeight=300;
- setSize(windowWidth,windowHeight);
- setBounds((center.x-windowWidth/2)-115,(center.y-windowWidth/2)-100, windowWidth,windowHeight);
- initComponents();
- setResizable(false);
+ try {
+ System.out.print("All diagnostic output is being redirected to SFrameworkInstall.log\n");
+ System.out.print("Location: " + System.getProperty("user.dir") +
+ File.separator + "SFrameworkInstall.log\n");
+
+ LogStream log = new LogStream("SFrameworkInstall.log");
+ System.setErr(log);
+
+ System.setOut(log);
+ } catch (FileNotFoundException fnfe) {
+ System.err.println("Office Scripting Framework Installer - Error: ");
+ System.err.println("Unable to create log file for installation.");
+ exitForm();
+ }
+
+ setBackground(new Color(0, 0, 0));
+ locations = new ArrayList<String>();
+ Point center = new Point(400, 400);
+ int windowWidth = 200;
+ int windowHeight = 300;
+ setSize(windowWidth, windowHeight);
+ setBounds((center.x - windowWidth / 2) - 115,
+ (center.y - windowWidth / 2) - 100, windowWidth, windowHeight);
+ initComponents();
+ setResizable(false);
}
/** This method is called from within the constructor to
@@ -137,40 +138,39 @@ public class InstallWizard extends javax.swing.JFrame implements ActionListener
screens.add(WELCOME, new Welcome(this));
version = new Version(this);
screens.add(VERSIONS, version);
- _final = new Final(this);
+ _final = new Final(this);
screens.add(FINAL, _final);
- boolean hasIDEInstallation = ( InstUtil.hasNetbeansInstallation() ) ;
+ boolean hasIDEInstallation = (InstUtil.hasNetbeansInstallation()) ;
+
+ if (hasIDEInstallation) {
+ idewelcome = new IdeWelcome(this);
+ screens.add(IDEWELCOME, idewelcome);
+ ideversion = new IdeVersion(this);
+ screens.add(IDEVERSIONS, ideversion);
+ idefinal = new IdeFinal(this);
+ screens.add(IDEFINAL, idefinal);
+ }
- if( hasIDEInstallation )
- {
- idewelcome = new IdeWelcome(this);
- screens.add(IDEWELCOME, idewelcome);
- ideversion = new IdeVersion(this);
- screens.add(IDEVERSIONS, ideversion);
- idefinal = new IdeFinal(this);
- screens.add(IDEFINAL, idefinal);
- }
getContentPane().add(screens, java.awt.BorderLayout.CENTER);
- navNext.addActionListener(this);
- navNext.addActionListener(version);
- navNext.addActionListener(_final);
+ navNext.addActionListener(this);
+ navNext.addActionListener(version);
+ navNext.addActionListener(_final);
- if( hasIDEInstallation )
- {
- navNext.addActionListener(ideversion);
- navNext.addActionListener(idefinal);
- }
+ if (hasIDEInstallation) {
+ navNext.addActionListener(ideversion);
+ navNext.addActionListener(idefinal);
+ }
- navCancel.addActionListener(this);
- navBack.addActionListener(this);
+ navCancel.addActionListener(this);
+ navBack.addActionListener(this);
- URL url = this.getClass().getResource("sidebar.jpg");
- JLabel sideBar = new JLabel();
- sideBar.setIcon(new ImageIcon(url));
- getContentPane().add (sideBar, java.awt.BorderLayout.WEST);
+ URL url = this.getClass().getResource("sidebar.jpg");
+ JLabel sideBar = new JLabel();
+ sideBar.setIcon(new ImageIcon(url));
+ getContentPane().add(sideBar, java.awt.BorderLayout.WEST);
pack();
}// initComponents
@@ -180,41 +180,33 @@ public class InstallWizard extends javax.swing.JFrame implements ActionListener
}
- public void actionPerformed(ActionEvent e)
- {
- if (e.getSource() == navNext)
- {
+ public void actionPerformed(ActionEvent e) {
+ if (e.getSource() == navNext) {
((CardLayout)screens.getLayout()).next(screens);
- }
+ }
- if (e.getSource() == navCancel)
- {
+ if (e.getSource() == navCancel) {
exitForm();
- }
+ }
- if (e.getSource() == navBack)
- {
+ if (e.getSource() == navBack) {
((CardLayout)screens.getLayout()).previous(screens);
- }
+ }
}// actionPerformed
- public static void storeLocation(String path)
- {
+ public static void storeLocation(String path) {
locations.add(path);
}
- public static ArrayList<String> getLocations()
- {
+ public static ArrayList<String> getLocations() {
return locations;
}
- public static void clearLocations()
- {
+ public static void clearLocations() {
locations.clear();
}
- public void show(String cardName)
- {
+ public void show(String cardName) {
((CardLayout)screens.getLayout()).show(screens, cardName);
}
@@ -231,14 +223,19 @@ public class InstallWizard extends javax.swing.JFrame implements ActionListener
printUsage();
System.exit(0);
}
+
if (args[i].equals("-office"))
officePath = args[++i];
+
if (args[i].equals("-netbeans"))
netbeansPath = args[++i];
+
if (args[i].equals("-net"))
bNetworkInstall = true;
+
if (args[i].equals("-bindings"))
bBindingsInstall = true;
+
i++;
}
@@ -250,21 +247,21 @@ public class InstallWizard extends javax.swing.JFrame implements ActionListener
try {
System.out.println("Log file is: " +
- System.getProperty("user.dir") +
- File.separator + "SFrameworkInstall.log");
+ System.getProperty("user.dir") +
+ File.separator + "SFrameworkInstall.log");
- LogStream log = new LogStream( "SFrameworkInstall.log" );
+ LogStream log = new LogStream("SFrameworkInstall.log");
System.setErr(log);
System.setOut(log);
- }
- catch( FileNotFoundException fnfe ) {
+ } catch (FileNotFoundException fnfe) {
System.err.println("Error: Unable to create log file: "
- + fnfe.getMessage());
+ + fnfe.getMessage());
System.exit(-1);
}
if (officePath != null) {
- XmlUpdater xud = new XmlUpdater(officePath, label, progressbar, bNetworkInstall, bBindingsInstall );
+ XmlUpdater xud = new XmlUpdater(officePath, label, progressbar, bNetworkInstall,
+ bBindingsInstall);
xud.run();
}
@@ -292,23 +289,19 @@ public class InstallWizard extends javax.swing.JFrame implements ActionListener
- public static synchronized void setPatchedTypes(boolean value)
- {
+ public static synchronized void setPatchedTypes(boolean value) {
bPatchedTypes = value;
}
- public static synchronized void setPatchedJava(boolean value)
- {
+ public static synchronized void setPatchedJava(boolean value) {
bPatchedJava = value;
}
- public static synchronized void setPatchedRDB(boolean value)
- {
+ public static synchronized void setPatchedRDB(boolean value) {
bPatchedRDB = value;
}
- public static synchronized void setInstallStarted(boolean value)
- {
+ public static synchronized void setInstallStarted(boolean value) {
bInstallStarted = value;
}
diff --git a/scripting/workben/installer/InstallationEvent.java b/scripting/workben/installer/InstallationEvent.java
index cdac2dc2cda7..9d91f9bf4505 100644
--- a/scripting/workben/installer/InstallationEvent.java
+++ b/scripting/workben/installer/InstallationEvent.java
@@ -18,23 +18,19 @@
package installer;
-public class InstallationEvent
-{
+public class InstallationEvent {
private Object source;
private String message;
- InstallationEvent(Object source, String message)
- {
+ InstallationEvent(Object source, String message) {
this.source = source;
this.message = message;
}
- public Object getSource()
- {
+ public Object getSource() {
return source;
}
- public String getMessage()
- {
+ public String getMessage() {
return message;
}
}
diff --git a/scripting/workben/installer/LogStream.java b/scripting/workben/installer/LogStream.java
index 3fde653709f3..27f33860d9d2 100644
--- a/scripting/workben/installer/LogStream.java
+++ b/scripting/workben/installer/LogStream.java
@@ -25,46 +25,36 @@ import java.text.DateFormat;
import java.text.SimpleDateFormat;
-public class LogStream extends PrintStream
-{
- static final private DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss z: ");
+public class LogStream extends PrintStream {
+ static final private DateFormat formatter = new
+ SimpleDateFormat("yyyy-MM-dd HH:mm:ss z: ");
- private String getTimeStamp()
- {
- String timeStamp = formatter.format( new Date() );
- return timeStamp;
+ private String getTimeStamp() {
+ String timeStamp = formatter.format(new Date());
+ return timeStamp;
}
- public LogStream( String logFileName ) throws java.io.FileNotFoundException
- {
- super( new FileOutputStream( logFileName ) );
+ public LogStream(String logFileName) throws java.io.FileNotFoundException {
+ super(new FileOutputStream(logFileName));
}
@Override
- public void println(String x)
- {
- super.println( getTimeStamp() + x );
+ public void println(String x) {
+ super.println(getTimeStamp() + x);
}
- public static void main(String[] args)
- {
- if ( args.length > 0 )
- {
- try
- {
- LogStream log = new LogStream( args[0] );
+ public static void main(String[] args) {
+ if (args.length > 0) {
+ try {
+ LogStream log = new LogStream(args[0]);
System.setErr(log);
System.setOut(log);
System.out.println("Test from logger from out");
System.err.println("Test from logger from err");
System.out.println("finised test from out");
System.err.println("finised test from err");
- }
- catch( java.io.FileNotFoundException fe )
- {
- System.err.println("Error creating logStream: " + fe );
+ } catch (java.io.FileNotFoundException fe) {
+ System.err.println("Error creating logStream: " + fe);
fe.printStackTrace();
}
- }
- else
- {
+ } else {
System.err.println("specify log file java LogStream [logfile]");
System.exit(1);
}
diff --git a/scripting/workben/installer/NavPanel.java b/scripting/workben/installer/NavPanel.java
index d8718e1257d1..89cfed25b1de 100644
--- a/scripting/workben/installer/NavPanel.java
+++ b/scripting/workben/installer/NavPanel.java
@@ -23,9 +23,11 @@ import java.awt.*;
import java.awt.event.*;
public class NavPanel extends JPanel implements ActionListener {
- NavPanel(InstallWizard wizard, boolean bBack, boolean bNext, boolean bCancel, String prev, String next) {
+ NavPanel(InstallWizard wizard, boolean bBack, boolean bNext, boolean bCancel,
+ String prev, String next) {
setBackground(Color.white);
- setBorder(new javax.swing.border.EtchedBorder(javax.swing.border.EtchedBorder.LOWERED));
+ setBorder(new javax.swing.border.EtchedBorder(
+ javax.swing.border.EtchedBorder.LOWERED));
this.wizard = wizard;
this.next = next;
this.prev = prev;
@@ -36,7 +38,7 @@ public class NavPanel extends JPanel implements ActionListener {
gridBagConstraints1 = new java.awt.GridBagConstraints();
gridBagConstraints1.insets = new java.awt.Insets(1, 1, 1, 1);
- gridBagConstraints1.anchor = GridBagConstraints.WEST;
+ gridBagConstraints1.anchor = GridBagConstraints.WEST;
gridBagConstraints2 = new java.awt.GridBagConstraints();
gridBagConstraints2.gridx = 2;
@@ -70,24 +72,26 @@ public class NavPanel extends JPanel implements ActionListener {
}
public void enableIDE(boolean bEnable) {
- ideDetected = bEnable;
+ ideDetected = bEnable;
}
public void actionPerformed(ActionEvent ev) {
if ((ev.getSource() == navNext) && (next.length() != 0)) {
wizard.show(next);
}
+
if ((ev.getSource() == navBack) && (prev.length() != 0)) {
wizard.show(prev);
}
+
if (ev.getSource() == navCancel) {
- if( ideDetected ) {
- wizard.show(InstallWizard.IDEWELCOME);
- }
- else {
- wizard.exitForm();
- }
- enableIDE(false);
+ if (ideDetected) {
+ wizard.show(InstallWizard.IDEWELCOME);
+ } else {
+ wizard.exitForm();
+ }
+
+ enableIDE(false);
}
}
@@ -107,8 +111,7 @@ public class NavPanel extends JPanel implements ActionListener {
- public void removeCancelListener(ActionListener listener)
- {
+ public void removeCancelListener(ActionListener listener) {
navCancel.removeActionListener(listener);
}
diff --git a/scripting/workben/installer/Register.java b/scripting/workben/installer/Register.java
index a3634143bd2e..afe95f5d1de6 100644
--- a/scripting/workben/installer/Register.java
+++ b/scripting/workben/installer/Register.java
@@ -20,85 +20,88 @@ package installer;
import java.io.*;
import javax.swing.*;
-public class Register{
+public class Register {
public static boolean register(String path, JLabel statusLabel) {
String[] packages = {"ooscriptframe.zip", "bshruntime.zip", "jsruntime.zip"};
- try {
- boolean goodResult = false;
- String env[] = new String[1];
+ try {
+ boolean goodResult = false;
+ String env[] = new String[1];
ExecCmd command = new ExecCmd();
- boolean isWindows =
+ boolean isWindows =
(System.getProperty("os.name").indexOf("Windows") != -1);
- String progpath = path.concat("program" + File.separator);
+ String progpath = path.concat("program" + File.separator);
statusLabel.setText("Registering Scripting Framework...");
// pkgchk Scripting Framework Components
statusLabel.setText("Registering Scripting Framework Components...");
- System.out.println("Registering Scripting Framework Components...");
+ System.out.println("Registering Scripting Framework Components...");
for (int i = 0; i < packages.length; i++) {
String cmd = "";
- if (!isWindows) {
- env[0]="LD_LIBRARY_PATH=" + progpath;
+ if (!isWindows) {
+ env[0] = "LD_LIBRARY_PATH=" + progpath;
- goodResult = command.exec("chmod a+x " + progpath + "pkgchk", null );
+ goodResult = command.exec("chmod a+x " + progpath + "pkgchk", null);
- if ( goodResult ){
+ if (goodResult) {
cmd = progpath + "pkgchk -s -f " + progpath + packages[i];
- System.err.println(cmd);
+ System.err.println(cmd);
goodResult = command.exec(cmd, env);
}
- }
- else {
+ } else {
cmd = "\"" + progpath + "pkgchk.exe\" -s -f \"" + progpath +
- packages[i] + "\"";
+ packages[i] + "\"";
- System.err.println(cmd);
- goodResult =command.exec(cmd,null);
+ System.err.println(cmd);
+ goodResult = command.exec(cmd, null);
+
+ }
- }
if (!goodResult) {
System.err.println("\nPkgChk Failed");
- if(!isWindows)
- System.err.println("Command: " + cmd + "\n" + env[0]);
- else
- System.err.println("Command: \"" + cmd + "\"");
+ if (!isWindows)
+ System.err.println("Command: " + cmd + "\n" + env[0]);
+ else
+ System.err.println("Command: \"" + cmd + "\"");
- statusLabel.setText(
+ statusLabel.setText(
"PkgChk Failed, please view SFrameworkInstall.log");
- return false;
+ return false;
}
- }
+ }
// updating StarBasic libraries
statusLabel.setText("Updating StarBasic libraries...");
- if(!FileUpdater.updateScriptXLC(path, statusLabel)) {
- statusLabel.setText("Updating user/basic/script.xlc failed, please view SFrameworkInstall.log");
- return false;
- }
- if(!FileUpdater.updateDialogXLC(path, statusLabel)) {
- statusLabel.setText("Updating user/basic/dialog.xlc failed, please view SFrameworkInstall.log");
+
+ if (!FileUpdater.updateScriptXLC(path, statusLabel)) {
+ statusLabel.setText("Updating user/basic/script.xlc failed, please view SFrameworkInstall.log");
+ return false;
+ }
+
+ if (!FileUpdater.updateDialogXLC(path, statusLabel)) {
+ statusLabel.setText("Updating user/basic/dialog.xlc failed, please view SFrameworkInstall.log");
+ return false;
+ }
+
+ } catch (Exception e) {
+ String message =
+ "\nError installing scripting package, please view SFrameworkInstall.log.";
+ System.out.println(message);
+ e.printStackTrace();
+ statusLabel.setText(message);
return false;
}
- }
- catch(Exception e){
- String message = "\nError installing scripting package, please view SFrameworkInstall.log.";
- System.out.println(message);
- e.printStackTrace();
- statusLabel.setText(message);
- return false;
- }
- return true;
+ return true;
}// register
}//Register
diff --git a/scripting/workben/installer/Version.java b/scripting/workben/installer/Version.java
index 2540f62f3dd6..8ede6c54527e 100644
--- a/scripting/workben/installer/Version.java
+++ b/scripting/workben/installer/Version.java
@@ -27,12 +27,13 @@ import javax.swing.*;
import javax.swing.event.*;
import javax.swing.table.*;
-public class Version extends javax.swing.JPanel implements ActionListener, TableModelListener {
+public class Version extends javax.swing.JPanel implements ActionListener,
+ TableModelListener {
/** Creates new form Welcome */
public Version(InstallWizard wizard) {
- this.wizard=wizard;
- setBackground(Color.white);
+ this.wizard = wizard;
+ setBackground(Color.white);
initComponents();
}
@@ -49,44 +50,46 @@ public class Version extends javax.swing.JPanel implements ActionListener, Table
System.out.println("Initialising versions");
File fileVersions = null;
- try
- {
+
+ try {
fileVersions = InstUtil.buildSversionLocation();
- }
- catch(IOException eFnF)
- {
+ } catch (IOException eFnF) {
System.err.println("Cannot find sversion.ini/.sversionrc");
- JOptionPane.showMessageDialog(this, eFnF.getMessage(), "File not Found", JOptionPane.ERROR_MESSAGE);
+ JOptionPane.showMessageDialog(this, eFnF.getMessage(), "File not Found",
+ JOptionPane.ERROR_MESSAGE);
wizard.exitForm();
- }
+ }
try {
props = InstUtil.getOfficeVersions(fileVersions);
- }
- catch (IOException eIO) {
+ } catch (IOException eIO) {
//Message about no installed versions found
System.err.println("Failed to parse SVERSION");
- JOptionPane.showMessageDialog(this, "There was a problem reading from the Office settings file.", "Parse Error", JOptionPane.ERROR_MESSAGE);
+ JOptionPane.showMessageDialog(this,
+ "There was a problem reading from the Office settings file.", "Parse Error",
+ JOptionPane.ERROR_MESSAGE);
wizard.exitForm();
}
tableModel = new MyTableModel(props);
- if (tableModel.getRowCount() == 0)
- {
- JOptionPane.showMessageDialog(this, "No compatible versions of Office were found.", "Invalid versions", JOptionPane.ERROR_MESSAGE);
+
+ if (tableModel.getRowCount() == 0) {
+ JOptionPane.showMessageDialog(this,
+ "No compatible versions of Office were found.", "Invalid versions",
+ JOptionPane.ERROR_MESSAGE);
wizard.exitForm();
- }
+ }
tableModel.addTableModelListener(this);
JTable tableVersions = new JTable(tableModel) {
@Override
- public String getToolTipText(MouseEvent event)
- {
- int col = columnAtPoint( event.getPoint() );
+ public String getToolTipText(MouseEvent event) {
+ int col = columnAtPoint(event.getPoint());
+
if (col != 2)
return null;
- int row = rowAtPoint( event.getPoint() );
+ int row = rowAtPoint(event.getPoint());
Object o = getValueAt(row, col);
if (o == null)
@@ -99,14 +102,14 @@ public class Version extends javax.swing.JPanel implements ActionListener, Table
}
@Override
- public Point getToolTipLocation(MouseEvent event)
- {
- int col = columnAtPoint( event.getPoint() );
+ public Point getToolTipLocation(MouseEvent event) {
+ int col = columnAtPoint(event.getPoint());
+
if (col != 2)
return null;
- int row = rowAtPoint( event.getPoint() );
- Object o = getValueAt(row,col);
+ int row = rowAtPoint(event.getPoint());
+ Object o = getValueAt(row, col);
if (o == null)
return null;
@@ -115,7 +118,7 @@ public class Version extends javax.swing.JPanel implements ActionListener, Table
return null;
Point pt = getCellRect(row, col, true).getLocation();
- pt.translate(-1,-2);
+ pt.translate(-1, -2);
return pt;
}
};
@@ -123,7 +126,7 @@ public class Version extends javax.swing.JPanel implements ActionListener, Table
JScrollPane scroll = new JScrollPane(tableVersions);
tableVersions.setPreferredSize(
- new Dimension(InstallWizard.DEFWIDTH,InstallWizard.DEFHEIGHT));
+ new Dimension(InstallWizard.DEFWIDTH, InstallWizard.DEFHEIGHT));
tableVersions.setRowSelectionAllowed(false);
tableVersions.setColumnSelectionAllowed(false);
@@ -132,13 +135,15 @@ public class Version extends javax.swing.JPanel implements ActionListener, Table
initColumnSizes(tableVersions, tableModel);
versionPanel.add(scroll);
- JTextArea area = new JTextArea("Please select the Office version you wish to Update");
+ JTextArea area = new
+ JTextArea("Please select the Office version you wish to Update");
area.setLineWrap(true);
area.setEditable(false);
add(area, BorderLayout.NORTH);
add(versionPanel, BorderLayout.CENTER);
//nav = new NavPanel(wizard, true, false, true, InstallWizard.WELCOME, InstallWizard.FINAL);
- nav = new NavPanel(wizard, true, false, true, InstallWizard.WELCOME, InstallWizard.FINAL);
+ nav = new NavPanel(wizard, true, false, true, InstallWizard.WELCOME,
+ InstallWizard.FINAL);
nav.setNextListener(this);
add(nav, BorderLayout.SOUTH);
@@ -158,9 +163,9 @@ public class Version extends javax.swing.JPanel implements ActionListener, Table
try {
comp = column.getHeaderRenderer().
- getTableCellRendererComponent(
- null, column.getHeaderValue(),
- false, false, 0, 0);
+ getTableCellRendererComponent(
+ null, column.getHeaderValue(),
+ false, false, 0, 0);
headerWidth = comp.getPreferredSize().width;
} catch (NullPointerException e) {
// System.err.println("Null pointer exception!");
@@ -175,19 +180,19 @@ public class Version extends javax.swing.JPanel implements ActionListener, Table
System.out.println("longValues: " + longValues[i]);
comp = table.getDefaultRenderer(model.getColumnClass(i)).
- getTableCellRendererComponent(
- table, longValues[i],
- false, false, 0, i);
+ getTableCellRendererComponent(
+ table, longValues[i],
+ false, false, 0, i);
cellWidth = comp.getPreferredSize().width;
preferredWidth = Math.max(headerWidth, cellWidth);
if (false) {
System.out.println("Initializing width of column "
- + i + ". "
- + "preferredWidth = " + preferredWidth
- + "; totalWidth = " + totalWidth
- + "; leftWidth = " + (InstallWizard.DEFWIDTH - totalWidth));
+ + i + ". "
+ + "preferredWidth = " + preferredWidth
+ + "; totalWidth = " + totalWidth
+ + "; leftWidth = " + (InstallWizard.DEFWIDTH - totalWidth));
}
//XXX: Before Swing 1.1 Beta 2, use setMinWidth instead.
@@ -196,8 +201,7 @@ public class Version extends javax.swing.JPanel implements ActionListener, Table
column.setPreferredWidth(InstallWizard.DEFWIDTH - totalWidth);
else
column.setPreferredWidth(preferredWidth);
- }
- else {
+ } else {
column.setMinWidth(preferredWidth);
totalWidth += preferredWidth;
}
@@ -213,8 +217,10 @@ public class Version extends javax.swing.JPanel implements ActionListener, Table
public void actionPerformed(ActionEvent ev) {
InstallWizard.clearLocations();
int len = tableModel.data.size();
+
for (int i = 0; i < len; i++) {
ArrayList<?> list = tableModel.data.get(i);
+
if (((Boolean)list.get(0)).booleanValue())
InstallWizard.storeLocation((String)list.get(2));
}
@@ -224,8 +230,7 @@ public class Version extends javax.swing.JPanel implements ActionListener, Table
public void tableChanged(TableModelEvent e) {
if (tableModel.isAnySelected()) {
nav.enableNext(true);
- }
- else {
+ } else {
nav.enableNext(false);
}
}
@@ -244,42 +249,44 @@ class MyTableModel extends AbstractTableModel {
private String colNames[] = {"", "Name", "Location"};
Object[] longValues = new Object[] {Boolean.TRUE, "Name", "Location"};
- MyTableModel (Properties properties) {
+ MyTableModel(Properties properties) {
data = new ArrayList<ArrayList<Object>>();
boolean isWindows =
(System.getProperty("os.name").indexOf("Windows") != -1);
+
for (Enumeration e = properties.propertyNames(); e.hasMoreElements() ;) {
String key = (String)e.nextElement();
String path = null;
- if ( !( key.startsWith("#") ) &&
- ( path = properties.getProperty(key)) != null) {
+ if (!(key.startsWith("#")) &&
+ (path = properties.getProperty(key)) != null) {
String pkgChkPath = path + File.separator + "program" + File.separator;
- if ( isWindows )
- {
+
+ if (isWindows) {
pkgChkPath += "pkgchk.exe";
- }
- else
- {
+ } else {
pkgChkPath += "pkgchk";
}
- File pkgChk = new File( pkgChkPath );
- if ( pkgChk.exists() )
- {
+
+ File pkgChk = new File(pkgChkPath);
+
+ if (pkgChk.exists()) {
ArrayList<Object> row = new ArrayList<Object>();
row.add(0, Boolean.FALSE);
row.add(1, key);
+
if (key.length() > ((String)longValues[1]).length()) {
longValues[1] = key;
}
row.add(2, path);
+
if (path.length() > ((String)longValues[2]).length()) {
longValues[2] = path;
}
- data.add(row);
+ data.add(row);
}
}
}
@@ -328,12 +335,15 @@ class MyTableModel extends AbstractTableModel {
public boolean isAnySelected() {
Iterator iter = data.iterator();
+
while (iter.hasNext()) {
ArrayList<?> row = (ArrayList<?>)iter.next();
+
if (((Boolean)row.get(0)).booleanValue()) {
return true;
}
}
+
return false;
}
diff --git a/scripting/workben/installer/Welcome.java b/scripting/workben/installer/Welcome.java
index a2c5f0f7ed37..c71a7af6b4fb 100644
--- a/scripting/workben/installer/Welcome.java
+++ b/scripting/workben/installer/Welcome.java
@@ -24,8 +24,9 @@ public class Welcome extends javax.swing.JPanel implements ActionListener {
/** Creates new form Welcome */
public Welcome(InstallWizard wizard) {
- this.wizard = wizard;
- setBorder(new javax.swing.border.EtchedBorder(javax.swing.border.EtchedBorder.RAISED));
+ this.wizard = wizard;
+ setBorder(new javax.swing.border.EtchedBorder(
+ javax.swing.border.EtchedBorder.RAISED));
initComponents();
}
@@ -37,7 +38,7 @@ public class Welcome extends javax.swing.JPanel implements ActionListener {
private void initComponents() {//GEN-BEGIN:initComponents
welcomePanel = new javax.swing.JPanel();
area = new javax.swing.JTextArea();
- nextButtonEnable = true;
+ nextButtonEnable = true;
setLayout(new java.awt.BorderLayout());
@@ -46,19 +47,20 @@ public class Welcome extends javax.swing.JPanel implements ActionListener {
area.setLineWrap(true);
String message = "\n\tOffice Scripting Framework Version 0.3" +
- "\n\n\n\tPlease ensure that you have exited from Office";
+ "\n\n\n\tPlease ensure that you have exited from Office";
- setUpWelcomePanel(message);
+ setUpWelcomePanel(message);
}//GEN-END:initComponents
- private void setUpWelcomePanel(String message){
- area.setText( message );
+ private void setUpWelcomePanel(String message) {
+ area.setText(message);
welcomePanel.add(area, java.awt.BorderLayout.CENTER);
add(welcomePanel, java.awt.BorderLayout.CENTER);
- NavPanel nav = new NavPanel(wizard, false, nextButtonEnable, true, "", InstallWizard.VERSIONS);
- nav.setNextListener(this);
- add(nav, java.awt.BorderLayout.SOUTH);
+ NavPanel nav = new NavPanel(wizard, false, nextButtonEnable, true, "",
+ InstallWizard.VERSIONS);
+ nav.setNextListener(this);
+ add(nav, java.awt.BorderLayout.SOUTH);
}
@@ -67,8 +69,7 @@ public class Welcome extends javax.swing.JPanel implements ActionListener {
return new java.awt.Dimension(InstallWizard.DEFWIDTH, InstallWizard.DEFHEIGHT);
}
- public void actionPerformed(ActionEvent ev)
- {
+ public void actionPerformed(ActionEvent ev) {
//Perform next actions here...
}
diff --git a/scripting/workben/installer/XmlUpdater.java b/scripting/workben/installer/XmlUpdater.java
index 3424cd57d110..c7bd2ff6ac3a 100644
--- a/scripting/workben/installer/XmlUpdater.java
+++ b/scripting/workben/installer/XmlUpdater.java
@@ -35,8 +35,7 @@ public class XmlUpdater extends Thread {
private boolean threadSuspended;
private JProgressBar progressBar;
- private final String[] bakFiles =
- {
+ private final String[] bakFiles = {
"writermenubar.xml",
"writerkeybinding.xml",
"calcmenubar.xml",
@@ -49,8 +48,7 @@ public class XmlUpdater extends Thread {
"META-INF" + File.separator + "manifest.xml"
};
- private final String[] dirs =
- {
+ private final String[] dirs = {
"java" + File.separator + "Highlight",
"java" + File.separator + "MemoryUsage",
"java" + File.separator + "ScriptFrmwrkHelper",
@@ -62,8 +60,7 @@ public class XmlUpdater extends Thread {
"javascript" + File.separator + "ExportSheetsToHTML"
};
- private final String[] names =
- {
+ private final String[] names = {
"java/Highlight/HighlightUtil.java",
"java/Highlight/HighlightText.java",
"java/Highlight/Highlight.jar",
@@ -94,14 +91,15 @@ public class XmlUpdater extends Thread {
};
- public XmlUpdater(String installPath, JLabel statusLabel,JProgressBar pBar, boolean netInstall, boolean bindingsInstall) {
+ public XmlUpdater(String installPath, JLabel statusLabel, JProgressBar pBar,
+ boolean netInstall, boolean bindingsInstall) {
this.installPath = installPath;
this.statusLabel = statusLabel;
this.netInstall = netInstall;
this.bindingsInstall = bindingsInstall;
listeners = new ArrayList<InstallListener>();
threadSuspended = false;
- progressBar=pBar;
+ progressBar = pBar;
progressBar.setStringPainted(true);
}// XmlUpdater
@@ -109,8 +107,7 @@ public class XmlUpdater extends Thread {
- public void setResume()
- {
+ public void setResume() {
threadSuspended = false;
notify();
}// setResume
@@ -121,156 +118,163 @@ public class XmlUpdater extends Thread {
internalThread = Thread.currentThread();
- String progpath=installPath;
- progpath= progpath.concat(File.separator+"program"+File.separator);
+ String progpath = installPath;
+ progpath = progpath.concat(File.separator + "program" + File.separator);
- String starBasicPath=installPath;
- starBasicPath= starBasicPath.concat(File.separator+"share"+File.separator+"basic"+File.separator+"ScriptBindingLibrary"+File.separator);
+ String starBasicPath = installPath;
+ starBasicPath = starBasicPath.concat(File.separator + "share" + File.separator +
+ "basic" + File.separator + "ScriptBindingLibrary" + File.separator);
- String regSchemaOfficePath=installPath;
- regSchemaOfficePath= regSchemaOfficePath.concat(File.separator+"share"+File.separator+"registry"+File.separator+"schema"+File.separator+"org"+File.separator+"openoffice"+File.separator+"Office"+File.separator);
+ String regSchemaOfficePath = installPath;
+ regSchemaOfficePath = regSchemaOfficePath.concat(File.separator + "share" +
+ File.separator + "registry" + File.separator + "schema" + File.separator + "org"
+ + File.separator + "openoffice" + File.separator + "Office" + File.separator);
progressBar.setString("Unzipping Required Files");
ZipData zd = new ZipData();
- if( (!netInstall) || bindingsInstall) {
- String configPath=installPath;
- configPath= configPath.concat(File.separator+"user"+File.separator+"config"+File.separator+"soffice.cfg"+File.separator);
- String manifestPath=configPath + "META-INF" + File.separator;
+ if ((!netInstall) || bindingsInstall) {
+ String configPath = installPath;
+ configPath = configPath.concat(File.separator + "user" + File.separator +
+ "config" + File.separator + "soffice.cfg" + File.separator);
+ String manifestPath = configPath + "META-INF" + File.separator;
//Adding <Office>/user/config/soffice.cfg/
- File configDir = new File( configPath );
- if( !configDir.isDirectory() ) {
- if( !configDir.mkdir() ) {
- System.out.println( "creating " + configDir + "directory failed");
- }
- else {
- System.out.println( configDir + "directory created");
- }
- }
- else
- System.out.println( "soffice.cfg exists" );
+ File configDir = new File(configPath);
- File manifestDir = new File( manifestPath );
- if( !manifestDir.isDirectory() ) {
- if( !manifestDir.mkdir() ) {
- System.out.println( "creating " + manifestPath + "directory failed");
+ if (!configDir.isDirectory()) {
+ if (!configDir.mkdir()) {
+ System.out.println("creating " + configDir + "directory failed");
+ } else {
+ System.out.println(configDir + "directory created");
}
- else {
- System.out.println( manifestPath + " directory created");
+ } else
+ System.out.println("soffice.cfg exists");
+
+ File manifestDir = new File(manifestPath);
+
+ if (!manifestDir.isDirectory()) {
+ if (!manifestDir.mkdir()) {
+ System.out.println("creating " + manifestPath + "directory failed");
+ } else {
+ System.out.println(manifestPath + " directory created");
}
- }
- else
- System.out.println( manifestPath + " exists" );
+ } else
+ System.out.println(manifestPath + " exists");
// Backup the confguration files in
// <office>/user/config/soffice.cfg/
// If they already exist.
- for( int i=0; i < bakFiles.length; i++ )
- {
+ for (int i = 0; i < bakFiles.length; i++) {
String pathNameBak = configPath + bakFiles[i];
- File origFile = new File( pathNameBak );
- if( origFile.exists() )
- {
- System.out.println( "Attempting to backup " + pathNameBak + " to " + pathNameBak + ".bak" );
- if(! origFile.renameTo( new File( pathNameBak + ".bak" ) ) )
- {
- System.out.println( "Failed to backup " + pathNameBak + " to " + pathNameBak + ".bak" );
+ File origFile = new File(pathNameBak);
+
+ if (origFile.exists()) {
+ System.out.println("Attempting to backup " + pathNameBak + " to " + pathNameBak
+ + ".bak");
+
+ if (! origFile.renameTo(new File(pathNameBak + ".bak"))) {
+ System.out.println("Failed to backup " + pathNameBak + " to " + pathNameBak +
+ ".bak");
}
}
}
// Adding Office configuration files
- if (!zd.extractEntry("bindingdialog/writermenubar.xml",configPath, statusLabel))
- {
+ if (!zd.extractEntry("bindingdialog/writermenubar.xml", configPath,
+ statusLabel)) {
onInstallComplete();
return;
}
- if (!zd.extractEntry("bindingdialog/writerkeybinding.xml",configPath, statusLabel))
- {
+
+ if (!zd.extractEntry("bindingdialog/writerkeybinding.xml", configPath,
+ statusLabel)) {
onInstallComplete();
return;
}
- if (!zd.extractEntry("bindingdialog/calcmenubar.xml",configPath, statusLabel))
- {
+
+ if (!zd.extractEntry("bindingdialog/calcmenubar.xml", configPath,
+ statusLabel)) {
onInstallComplete();
return;
}
- if (!zd.extractEntry("bindingdialog/calckeybinding.xml",configPath, statusLabel))
- {
+
+ if (!zd.extractEntry("bindingdialog/calckeybinding.xml", configPath,
+ statusLabel)) {
onInstallComplete();
return;
}
- if (!zd.extractEntry("bindingdialog/impressmenubar.xml",configPath, statusLabel))
- {
+
+ if (!zd.extractEntry("bindingdialog/impressmenubar.xml", configPath,
+ statusLabel)) {
onInstallComplete();
return;
}
- if (!zd.extractEntry("bindingdialog/impresskeybinding.xml",configPath, statusLabel))
- {
+
+ if (!zd.extractEntry("bindingdialog/impresskeybinding.xml", configPath,
+ statusLabel)) {
onInstallComplete();
return;
}
- if (!zd.extractEntry("bindingdialog/drawmenubar.xml",configPath, statusLabel))
- {
+
+ if (!zd.extractEntry("bindingdialog/drawmenubar.xml", configPath,
+ statusLabel)) {
onInstallComplete();
return;
}
- if (!zd.extractEntry("bindingdialog/drawkeybinding.xml",configPath, statusLabel))
- {
+
+ if (!zd.extractEntry("bindingdialog/drawkeybinding.xml", configPath,
+ statusLabel)) {
onInstallComplete();
return;
}
- if (!zd.extractEntry("bindingdialog/eventbindings.xml",configPath, statusLabel))
- {
+
+ if (!zd.extractEntry("bindingdialog/eventbindings.xml", configPath,
+ statusLabel)) {
onInstallComplete();
return;
}
- if (!zd.extractEntry("bindingdialog/manifest.xml",manifestPath, statusLabel))
- {
+
+ if (!zd.extractEntry("bindingdialog/manifest.xml", manifestPath, statusLabel)) {
onInstallComplete();
return;
}
}
- if(!bindingsInstall) {
+ if (!bindingsInstall) {
// Adding new directories to Office
// Adding <Office>/user/basic/ScriptBindingLibrary/
- File scriptBindingLib = new File( starBasicPath );
- if( !scriptBindingLib.isDirectory() ) {
- if( !scriptBindingLib.mkdir() ) {
- System.out.println( "ScriptBindingLibrary failed");
- }
- else {
- System.out.println( "ScriptBindingLibrary directory created");
+ File scriptBindingLib = new File(starBasicPath);
+
+ if (!scriptBindingLib.isDirectory()) {
+ if (!scriptBindingLib.mkdir()) {
+ System.out.println("ScriptBindingLibrary failed");
+ } else {
+ System.out.println("ScriptBindingLibrary directory created");
}
- }
- else
- System.out.println( "ScriptBindingLibrary exists" );
+ } else
+ System.out.println("ScriptBindingLibrary exists");
// Adding Scripting Framework and tools
- if (!zd.extractEntry("sframework/ooscriptframe.zip",progpath, statusLabel))
- {
+ if (!zd.extractEntry("sframework/ooscriptframe.zip", progpath, statusLabel)) {
onInstallComplete();
return;
}
- if (!zd.extractEntry("sframework/bshruntime.zip",progpath, statusLabel))
- {
+ if (!zd.extractEntry("sframework/bshruntime.zip", progpath, statusLabel)) {
onInstallComplete();
return;
}
- if (!zd.extractEntry("sframework/jsruntime.zip",progpath, statusLabel))
- {
+ if (!zd.extractEntry("sframework/jsruntime.zip", progpath, statusLabel)) {
onInstallComplete();
return;
}
- if (!zd.extractEntry("schema/Scripting.xcs",regSchemaOfficePath, statusLabel))
- {
+ if (!zd.extractEntry("schema/Scripting.xcs", regSchemaOfficePath,
+ statusLabel)) {
onInstallComplete();
return;
}
@@ -279,14 +283,16 @@ public class XmlUpdater extends Thread {
progressBar.setString("Registering Scripting Framework");
progressBar.setValue(3);
- if(!Register.register(installPath+File.separator, statusLabel) ) {
- onInstallComplete();
- return;
+
+ if (!Register.register(installPath + File.separator, statusLabel)) {
+ onInstallComplete();
+ return;
}
+
progressBar.setValue(5);
String path = installPath + File.separator +
- "share" + File.separator + "Scripts" + File.separator;
+ "share" + File.separator + "Scripts" + File.separator;
for (int i = 0; i < dirs.length; i++) {
File dir = new File(path + dirs[i]);
@@ -294,7 +300,7 @@ public class XmlUpdater extends Thread {
if (!dir.exists()) {
if (!dir.mkdirs()) {
System.err.println("Error making dir: " +
- dir.getAbsolutePath());
+ dir.getAbsolutePath());
onInstallComplete();
return;
}
@@ -313,43 +319,48 @@ public class XmlUpdater extends Thread {
// Adding binding dialog
- if (!zd.extractEntry("bindingdialog/ScriptBinding.xba",starBasicPath, statusLabel))
- {
+ if (!zd.extractEntry("bindingdialog/ScriptBinding.xba", starBasicPath,
+ statusLabel)) {
onInstallComplete();
return;
}
- if (!zd.extractEntry("bindingdialog/MenuBinding.xdl",starBasicPath, statusLabel))
- {
+
+ if (!zd.extractEntry("bindingdialog/MenuBinding.xdl", starBasicPath,
+ statusLabel)) {
onInstallComplete();
return;
}
- if (!zd.extractEntry("bindingdialog/KeyBinding.xdl",starBasicPath, statusLabel))
- {
+
+ if (!zd.extractEntry("bindingdialog/KeyBinding.xdl", starBasicPath,
+ statusLabel)) {
onInstallComplete();
return;
}
- if (!zd.extractEntry("bindingdialog/EventsBinding.xdl",starBasicPath, statusLabel))
- {
+
+ if (!zd.extractEntry("bindingdialog/EventsBinding.xdl", starBasicPath,
+ statusLabel)) {
onInstallComplete();
return;
}
- if (!zd.extractEntry("bindingdialog/HelpBinding.xdl",starBasicPath, statusLabel))
- {
+
+ if (!zd.extractEntry("bindingdialog/HelpBinding.xdl", starBasicPath,
+ statusLabel)) {
onInstallComplete();
return;
}
- if (!zd.extractEntry("bindingdialog/EditDebug.xdl",starBasicPath, statusLabel))
- {
+
+ if (!zd.extractEntry("bindingdialog/EditDebug.xdl", starBasicPath,
+ statusLabel)) {
onInstallComplete();
return;
}
- if (!zd.extractEntry("bindingdialog/dialog.xlb",starBasicPath, statusLabel))
- {
+
+ if (!zd.extractEntry("bindingdialog/dialog.xlb", starBasicPath, statusLabel)) {
onInstallComplete();
return;
}
- if (!zd.extractEntry("bindingdialog/script.xlb",starBasicPath, statusLabel))
- {
+
+ if (!zd.extractEntry("bindingdialog/script.xlb", starBasicPath, statusLabel)) {
onInstallComplete();
return;
}
@@ -364,16 +375,13 @@ public class XmlUpdater extends Thread {
}// run
- public void addInstallListener(InstallListener listener)
- {
+ public void addInstallListener(InstallListener listener) {
listeners.add(listener);
}// addInstallListener
- private void onInstallComplete()
- {
- for (InstallListener l : listeners)
- {
+ private void onInstallComplete() {
+ for (InstallListener l : listeners) {
l.installationComplete(null);
}
}// onInstallComplete
diff --git a/scripting/workben/installer/ZipData.java b/scripting/workben/installer/ZipData.java
index 466f87a6e863..6e5d513a16be 100644
--- a/scripting/workben/installer/ZipData.java
+++ b/scripting/workben/installer/ZipData.java
@@ -24,7 +24,7 @@ import javax.swing.*;
public class ZipData {
public boolean extractEntry(String entry, String destination,
- JLabel statusLabel) {
+ JLabel statusLabel) {
OutputStream out = null;
InputStream in = null;
@@ -37,6 +37,7 @@ public class ZipData {
}
String entryName;
+
if (entry.lastIndexOf("/") != -1) {
entryName = entry.substring(entry.lastIndexOf("/") + 1);
} else {
@@ -44,9 +45,10 @@ public class ZipData {
}
String destName;
+
if (destination.lastIndexOf(File.separator) != -1) {
destName = destination.substring(destination
- .lastIndexOf(File.separator) + 1);
+ .lastIndexOf(File.separator) + 1);
} else {
destName = destination;
}
@@ -60,12 +62,13 @@ public class ZipData {
entry = "/" + entry;
in = this.getClass().getResourceAsStream(entry);
+
if (in == null) {
System.err.println("File " + entry + " not found in jar file");
if (statusLabel != null)
statusLabel.setText("Failed extracting " + entry
- + "see SFramework.log for more information");
+ + "see SFramework.log for more information");
return false;
}
@@ -74,11 +77,11 @@ public class ZipData {
out = new FileOutputStream(destination);
} catch (IOException ioe) {
System.err.println("Error opening " + destination + ": "
- + ioe.getMessage());
+ + ioe.getMessage());
if (statusLabel != null)
statusLabel.setText("Error opening" + destination
- + "see SFramework.log for more information");
+ + "see SFramework.log for more information");
return false;
}
@@ -91,11 +94,12 @@ public class ZipData {
out.write(bytes, 0, len);
} catch (IOException ioe) {
System.err.println("Error writing " + destination + ": "
- + ioe.getMessage());
+ + ioe.getMessage());
if (statusLabel != null)
statusLabel.setText("Failed writing " + destination
- + "see SFramework.log for more information");
+ + "see SFramework.log for more information");
+
return false;
} finally {
try {
@@ -104,6 +108,7 @@ public class ZipData {
} catch (IOException ioe) {
}
}
+
return true;
}
}
diff --git a/scripting/workben/mod/_scripting/Dispatch.java b/scripting/workben/mod/_scripting/Dispatch.java
index 00b4ee5900bf..20542cf02d10 100644
--- a/scripting/workben/mod/_scripting/Dispatch.java
+++ b/scripting/workben/mod/_scripting/Dispatch.java
@@ -43,30 +43,34 @@ import com.sun.star.util.XURLTransformer;
public class Dispatch extends TestCase {
private String scriptURL = "script://HighlightText.showForm";
@Override
- public void initialize( TestParameters tParam, PrintWriter log ) {
+ public void initialize(TestParameters tParam, PrintWriter log) {
}
@Override
+
public synchronized TestEnvironment createTestEnvironment(
- TestParameters tParam, PrintWriter log ) throws StatusException {
- log.println("creating test environment");
+ TestParameters tParam, PrintWriter log) throws StatusException {
+ log.println("creating test environment");
XInterface oObj = null;
URL dispatchURL = null;
+
try {
XMultiServiceFactory xMSF = tParam.getMSF();
SOfficeFactory SOF = null;
- SOF = SOfficeFactory.getFactory( xMSF );
- String docPath = util.utils.getFullTestURL( "ExampleSpreadSheetLatest.sxc" );
- XComponent doc = SOF.loadDocument( docPath );
- XModel model = UnoRuntime.queryInterface( XModel.class,
- doc );
+ SOF = SOfficeFactory.getFactory(xMSF);
+ String docPath = util.utils.getFullTestURL("ExampleSpreadSheetLatest.sxc");
+ XComponent doc = SOF.loadDocument(docPath);
+ XModel model = UnoRuntime.queryInterface(XModel.class,
+ doc);
XFrame frame = model.getCurrentController().getFrame();
- oObj = ( XInterface )xMSF.createInstanceWithArguments( "com.sun.star.comp.ScriptProtocolHandler", new Object[] { frame } );
+ oObj = (XInterface)
+ xMSF.createInstanceWithArguments("com.sun.star.comp.ScriptProtocolHandler",
+ new Object[] { frame });
- XURLTransformer xParser=UnoRuntime.queryInterface(XURLTransformer.class,
- tParam.getMSF().createInstance
- ("com.sun.star.util.URLTransformer"));
+ XURLTransformer xParser = UnoRuntime.queryInterface(XURLTransformer.class,
+ tParam.getMSF().createInstance
+ ("com.sun.star.util.URLTransformer"));
// Because it's an in/out parameter we must use an array of
// URL objects.
URL[] aParseURL = new URL[1];
@@ -81,13 +85,14 @@ public class Dispatch extends TestCase {
}
TestEnvironment tEnv = new TestEnvironment(oObj) ;
- tEnv.addObjRelation( "XDispatchProvider.URL", scriptURL );
- tEnv.addObjRelation( "XDispatch.URL", dispatchURL );
+ tEnv.addObjRelation("XDispatchProvider.URL", scriptURL);
+ tEnv.addObjRelation("XDispatch.URL", dispatchURL);
return tEnv ;
}
@Override
- public synchronized void disposeTestEnvironment( TestEnvironment tEnv,
+
+ public synchronized void disposeTestEnvironment(TestEnvironment tEnv,
TestParameters tParam) {
}
}
diff --git a/scripting/workben/mod/_scripting/Function.java b/scripting/workben/mod/_scripting/Function.java
index 97c90771a25e..9a2d8b273144 100644
--- a/scripting/workben/mod/_scripting/Function.java
+++ b/scripting/workben/mod/_scripting/Function.java
@@ -38,29 +38,33 @@ public class Function extends TestCase {
private String doc = "doc_with_beanshell_scripts.sxw";
@Override
- public void initialize( TestParameters tParam, PrintWriter log ) {
+ public void initialize(TestParameters tParam, PrintWriter log) {
}
@Override
+
public synchronized TestEnvironment createTestEnvironment(
- TestParameters tParam, PrintWriter log ) throws StatusException {
+ TestParameters tParam, PrintWriter log) throws StatusException {
XInterface oObj = null;
- XFunctionProvider provider = null;
+ XFunctionProvider provider = null;
log.println("creating test environment");
+
try {
XMultiServiceFactory xMSF = tParam.getMSF();
SOfficeFactory SOF = null;
- SOF = SOfficeFactory.getFactory( xMSF );
+ SOF = SOfficeFactory.getFactory(xMSF);
String docPath = util.utils.getFullTestURL(doc);
- XComponent doc = SOF.loadDocument( docPath );
- XModel model = UnoRuntime.queryInterface( XModel.class,
- doc );
+ XComponent doc = SOF.loadDocument(docPath);
+ XModel model = UnoRuntime.queryInterface(XModel.class,
+ doc);
oObj =
- (XInterface)xMSF.createInstanceWithArguments( "drafts.com.sun.star.script.framework.provider.FunctionProvider", new Object[]{ model } );
- provider = UnoRuntime.queryInterface( XFunctionProvider.class, oObj );
- oObj = provider.getFunction( script );
+ (XInterface)
+ xMSF.createInstanceWithArguments("drafts.com.sun.star.script.framework.provider.FunctionProvider",
+ new Object[] { model });
+ provider = UnoRuntime.queryInterface(XFunctionProvider.class, oObj);
+ oObj = provider.getFunction(script);
} catch (com.sun.star.uno.Exception e) {
e.printStackTrace();
@@ -75,7 +79,8 @@ public class Function extends TestCase {
}
@Override
- public synchronized void disposeTestEnvironment( TestEnvironment tEnv,
+
+ public synchronized void disposeTestEnvironment(TestEnvironment tEnv,
TestParameters tParam) {
}
}
diff --git a/scripting/workben/mod/_scripting/FunctionProvider.java b/scripting/workben/mod/_scripting/FunctionProvider.java
index beb5d6c9f714..8cbedee9935e 100644
--- a/scripting/workben/mod/_scripting/FunctionProvider.java
+++ b/scripting/workben/mod/_scripting/FunctionProvider.java
@@ -34,25 +34,29 @@ public class FunctionProvider extends TestCase {
String docPath = null;
@Override
- public void initialize( TestParameters tParam, PrintWriter log ) {
+ public void initialize(TestParameters tParam, PrintWriter log) {
}
@Override
+
public synchronized TestEnvironment createTestEnvironment(
- TestParameters tParam, PrintWriter log ) throws StatusException {
+ TestParameters tParam, PrintWriter log) throws StatusException {
XInterface oObj = null;
- log.println("creating test environment");
+ log.println("creating test environment");
+
try {
XMultiServiceFactory xMSF = tParam.getMSF();
- Object xInterface = xMSF.createInstance( "com.sun.star.frame.Desktop" );
- XDesktop dtop = UnoRuntime.queryInterface( XDesktop.class,
- xInterface );
+ Object xInterface = xMSF.createInstance("com.sun.star.frame.Desktop");
+ XDesktop dtop = UnoRuntime.queryInterface(XDesktop.class,
+ xInterface);
XModel model = dtop.getCurrentFrame().getController().getModel();
oObj =
- (XInterface)xMSF.createInstanceWithArguments( "drafts.com.sun.star.script.framework.provider.FunctionProvider", new Object[]{ model } );
+ (XInterface)
+ xMSF.createInstanceWithArguments("drafts.com.sun.star.script.framework.provider.FunctionProvider",
+ new Object[] { model });
} catch (com.sun.star.uno.Exception e) {
@@ -66,7 +70,8 @@ public class FunctionProvider extends TestCase {
}
@Override
- public synchronized void disposeTestEnvironment( TestEnvironment tEnv,
+
+ public synchronized void disposeTestEnvironment(TestEnvironment tEnv,
TestParameters tParam) {
}
}
diff --git a/scripting/workben/mod/_scripting/ScriptInfo.java b/scripting/workben/mod/_scripting/ScriptInfo.java
index 8001ca99d5c7..05b7b3d0c80e 100644
--- a/scripting/workben/mod/_scripting/ScriptInfo.java
+++ b/scripting/workben/mod/_scripting/ScriptInfo.java
@@ -36,51 +36,58 @@ public class ScriptInfo extends TestCase {
String docPath = null;
@Override
- public void initialize( TestParameters tParam, PrintWriter log ) {
+ public void initialize(TestParameters tParam, PrintWriter log) {
// Get path to test documents
- String rootDocPath = ( String )tParam.get( "TEST_DOCUMENT_PATH" );
- System.out.println( "TEST_DOCUMENT_PATH is " + rootDocPath );
- rootDocPath = util.utils.getFullTestURL( "ExampleSpreadSheetLatest.sxc" );
- if ( rootDocPath != null && rootDocPath.length() > 1 ){
+ String rootDocPath = (String)tParam.get("TEST_DOCUMENT_PATH");
+ System.out.println("TEST_DOCUMENT_PATH is " + rootDocPath);
+ rootDocPath = util.utils.getFullTestURL("ExampleSpreadSheetLatest.sxc");
+
+ if (rootDocPath != null && rootDocPath.length() > 1) {
// convert all "\\" to "/", necessary for UCB
- if ( rootDocPath.indexOf( "\\" ) > 0 ){
- rootDocPath = rootDocPath.replace( '\\','/' );
- }
+ if (rootDocPath.indexOf("\\") > 0) {
+ rootDocPath = rootDocPath.replace('\\', '/');
+ }
+
System.out.println("After processing the path is " + rootDocPath);
- // encode the ulr (for UCB)
- String encodedPath = URLEncoder.encode( rootDocPath );
- System.out.println("The encoded path is " + encodedPath );
+ // encode the ulr (for UCB)
+ String encodedPath = URLEncoder.encode(rootDocPath);
+ System.out.println("The encoded path is " + encodedPath);
docPath = "vnd.sun.star.pkg://" + encodedPath;
- System.out.println( "docPath path is " + docPath );
+ System.out.println("docPath path is " + docPath);
}
}
@Override
+
public synchronized TestEnvironment createTestEnvironment(
- TestParameters tParam, PrintWriter log ) throws StatusException {
+ TestParameters tParam, PrintWriter log) throws StatusException {
- log.println("creating test environment");
- if ( docPath == null ){
+ log.println("creating test environment");
+
+ if (docPath == null) {
log.println("Testdata not set up, docPath is null");
throw new StatusException(
"Can't create object environment, no test document available",
- new Exception() ) ;
+ new Exception()) ;
}
XInterface oObj = null;
XSimpleFileAccess access = null;
+
try {
XMultiServiceFactory xMSF = tParam.getMSF();
Object xInterface =
- xMSF.createInstance( "com.sun.star.ucb.SimpleFileAccess" );
- access = UnoRuntime.queryInterface( XSimpleFileAccess.class, xInterface );
+ xMSF.createInstance("com.sun.star.ucb.SimpleFileAccess");
+ access = UnoRuntime.queryInterface(XSimpleFileAccess.class, xInterface);
Object storageObj = xMSF.createInstanceWithArguments(
- "drafts.com.sun.star.script.framework.storage.ScriptStorage",
- new Object[]{ access, Integer.valueOf(99), docPath } );
- XScriptInfoAccess infoAccess = UnoRuntime.queryInterface(XScriptInfoAccess.class, storageObj);
- XScriptInfo[] infos = infoAccess.getImplementations("script://MemoryUtils.MemUsage?location=document");
- oObj = infos[0];
+ "drafts.com.sun.star.script.framework.storage.ScriptStorage",
+ new Object[] { access, Integer.valueOf(99), docPath });
+ XScriptInfoAccess infoAccess = UnoRuntime.queryInterface(
+ XScriptInfoAccess.class, storageObj);
+ XScriptInfo[] infos =
+ infoAccess.getImplementations("script://MemoryUtils.MemUsage?location=document");
+ oObj = infos[0];
} catch (com.sun.star.uno.Exception e) {
throw new StatusException("Can't create object environment", e) ;
}
@@ -92,7 +99,8 @@ public class ScriptInfo extends TestCase {
}
@Override
- public synchronized void disposeTestEnvironment( TestEnvironment tEnv,
+
+ public synchronized void disposeTestEnvironment(TestEnvironment tEnv,
TestParameters tParam) {
}
}
diff --git a/scripting/workben/mod/_scripting/ScriptRuntimeManager.java b/scripting/workben/mod/_scripting/ScriptRuntimeManager.java
index 79f84ac109ec..6051adb1ae70 100644
--- a/scripting/workben/mod/_scripting/ScriptRuntimeManager.java
+++ b/scripting/workben/mod/_scripting/ScriptRuntimeManager.java
@@ -28,20 +28,21 @@ import lib.TestParameters;
public class ScriptRuntimeManager extends TestCase {
@Override
- public void initialize( TestParameters tParam, PrintWriter log ) {
+ public void initialize(TestParameters tParam, PrintWriter log) {
}
@Override
+
public synchronized TestEnvironment createTestEnvironment(
- TestParameters Param, PrintWriter log ) throws StatusException {
+ TestParameters Param, PrintWriter log) throws StatusException {
- log.println("creating test environment");
+ log.println("creating test environment");
XInterface oObj = null;
try {
oObj = (XInterface) Param.getMSF().createInstance
- ("drafts.com.sun.star.script.framework.runtime.ScriptRuntimeManager");
+ ("drafts.com.sun.star.script.framework.runtime.ScriptRuntimeManager");
} catch (com.sun.star.uno.Exception e) {
throw new StatusException("Can't create object environment", e) ;
}
@@ -53,7 +54,8 @@ public class ScriptRuntimeManager extends TestCase {
}
@Override
- public synchronized void disposeTestEnvironment( TestEnvironment tEnv,
+
+ public synchronized void disposeTestEnvironment(TestEnvironment tEnv,
TestParameters tParam) {
}
}
diff --git a/scripting/workben/mod/_scripting/ScriptStorage.java b/scripting/workben/mod/_scripting/ScriptStorage.java
index dc8749bf103f..c09f24c083fd 100644
--- a/scripting/workben/mod/_scripting/ScriptStorage.java
+++ b/scripting/workben/mod/_scripting/ScriptStorage.java
@@ -33,48 +33,53 @@ public class ScriptStorage extends TestCase {
String docPath = null;
@Override
- public void initialize( TestParameters tParam, PrintWriter log ) {
+ public void initialize(TestParameters tParam, PrintWriter log) {
// Get path to test documents
- String rootDocPath = ( String )tParam.get( "TEST_DOCUMENT_PATH" );
- System.out.println( "TEST_DOCUMENT_PATH is " + rootDocPath );
- rootDocPath = util.utils.getFullTestURL( "ExampleSpreadSheetLatest.sxc" );
- if ( rootDocPath != null && rootDocPath.length() > 1 ){
+ String rootDocPath = (String)tParam.get("TEST_DOCUMENT_PATH");
+ System.out.println("TEST_DOCUMENT_PATH is " + rootDocPath);
+ rootDocPath = util.utils.getFullTestURL("ExampleSpreadSheetLatest.sxc");
+
+ if (rootDocPath != null && rootDocPath.length() > 1) {
// convert all "\\" to "/", necessary for UCB
- if ( rootDocPath.indexOf( "\\" ) > 0 ){
- rootDocPath = rootDocPath.replace( '\\','/' );
- }
+ if (rootDocPath.indexOf("\\") > 0) {
+ rootDocPath = rootDocPath.replace('\\', '/');
+ }
+
System.out.println("After processing the path is " + rootDocPath);
- // encode the ulr (for UCB)
- String encodedPath = URLEncoder.encode( rootDocPath );
- System.out.println("The encoded path is " + encodedPath );
+ // encode the ulr (for UCB)
+ String encodedPath = URLEncoder.encode(rootDocPath);
+ System.out.println("The encoded path is " + encodedPath);
docPath = "vnd.sun.star.pkg://" + encodedPath;
- System.out.println( "docPath path is " + docPath );
+ System.out.println("docPath path is " + docPath);
}
}
@Override
+
public synchronized TestEnvironment createTestEnvironment(
- TestParameters tParam, PrintWriter log ) throws StatusException {
+ TestParameters tParam, PrintWriter log) throws StatusException {
- log.println("creating test environment");
- if ( docPath == null ){
+ log.println("creating test environment");
+
+ if (docPath == null) {
log.println("Testdata not set up, docPath is null");
throw new StatusException(
"Can't create object environment, no test document available",
- new Exception() ) ;
+ new Exception()) ;
}
XInterface oObj = null;
XSimpleFileAccess access = null;
+
try {
XMultiServiceFactory xMSF = tParam.getMSF();
Object xInterface =
- xMSF.createInstance( "com.sun.star.ucb.SimpleFileAccess" );
- access = UnoRuntime.queryInterface( XSimpleFileAccess.class, xInterface );
- oObj = ( XInterface )xMSF.createInstanceWithArguments(
- "drafts.com.sun.star.script.framework.storage.ScriptStorage",
- new Object[]{ access, Integer.valueOf(99), docPath } );
+ xMSF.createInstance("com.sun.star.ucb.SimpleFileAccess");
+ access = UnoRuntime.queryInterface(XSimpleFileAccess.class, xInterface);
+ oObj = (XInterface)xMSF.createInstanceWithArguments(
+ "drafts.com.sun.star.script.framework.storage.ScriptStorage",
+ new Object[] { access, Integer.valueOf(99), docPath });
} catch (com.sun.star.uno.Exception e) {
throw new StatusException("Can't create object environment", e) ;
@@ -87,7 +92,8 @@ public class ScriptStorage extends TestCase {
}
@Override
- public synchronized void disposeTestEnvironment( TestEnvironment tEnv,
+
+ public synchronized void disposeTestEnvironment(TestEnvironment tEnv,
TestParameters tParam) {
}
}
diff --git a/scripting/workben/mod/_scripting/ScriptStorageManager.java b/scripting/workben/mod/_scripting/ScriptStorageManager.java
index 64d993edfdc4..b18c613f59e8 100644
--- a/scripting/workben/mod/_scripting/ScriptStorageManager.java
+++ b/scripting/workben/mod/_scripting/ScriptStorageManager.java
@@ -32,31 +32,32 @@ import lib.TestParameters;
public class ScriptStorageManager extends TestCase {
@Override
- public void initialize( TestParameters tParam, PrintWriter log ) {
+ public void initialize(TestParameters tParam, PrintWriter log) {
}
@Override
+
public synchronized TestEnvironment createTestEnvironment(
- TestParameters Param, PrintWriter log ) throws StatusException {
+ TestParameters Param, PrintWriter log) throws StatusException {
XInterface oObj = null;
- Object oInterface = null;
+ Object oInterface = null;
- try {
+ try {
XMultiServiceFactory xMSF = Param.getMSF();
XPropertySet xProp = UnoRuntime.queryInterface(
- XPropertySet.class, xMSF);
+ XPropertySet.class, xMSF);
// get context
XComponentContext xContext = UnoRuntime.queryInterface(XComponentContext.class,
- xProp.getPropertyValue("DefaultContext"));
+ xProp.getPropertyValue("DefaultContext"));
// get the script storage manager from context
oInterface = xContext.getValueByName("/singletons/" +
- "drafts.com.sun.star.script.framework.storage.theScriptStorageManager");
- }
- catch( Exception e ) {
- log.println("ScriptStorageManager singleton service not available" );
- e.printStackTrace();
+ "drafts.com.sun.star.script.framework.storage.theScriptStorageManager");
+ } catch (Exception e) {
+ log.println("ScriptStorageManager singleton service not available");
+ e.printStackTrace();
}
+
oObj = (XInterface) oInterface;
TestEnvironment tEnv = new TestEnvironment(oObj) ;
@@ -66,7 +67,8 @@ public class ScriptStorageManager extends TestCase {
}
@Override
- public synchronized void disposeTestEnvironment( TestEnvironment tEnv,
+
+ public synchronized void disposeTestEnvironment(TestEnvironment tEnv,
TestParameters tParam) {
}
}
diff --git a/scripting/workben/mod/_scripting/TestDataLoader.java b/scripting/workben/mod/_scripting/TestDataLoader.java
index 63d360e6a678..6f8078656058 100644
--- a/scripting/workben/mod/_scripting/TestDataLoader.java
+++ b/scripting/workben/mod/_scripting/TestDataLoader.java
@@ -56,8 +56,7 @@ public class TestDataLoader {
current = previous = st.nextToken();
list.add(getParameters(st));
- }
- else {
+ } else {
in.close();
return;
}
@@ -78,14 +77,13 @@ public class TestDataLoader {
tEnv.addObjRelation(previous, list);
in.close();
- }
- catch (IOException ioe) {
+ } catch (IOException ioe) {
}
}
private static Parameters getParameters(StringTokenizer st) {
String separator = "=";
- HashMap<String,Object> map = new HashMap<String,Object>(5);
+ HashMap<String, Object> map = new HashMap<String, Object>(5);
while (st.hasMoreTokens()) {
String pair = st.nextToken();
@@ -98,12 +96,15 @@ public class TestDataLoader {
continue;
name = tokens.nextToken();
+
if (tokens.countTokens() == 1)
value = tokens.nextToken();
else {
StringBuffer buf = new StringBuffer(tokens.nextToken());
+
while (tokens.hasMoreTokens())
buf.append(separator).append(tokens.nextToken());
+
value = buf.toString();
}