summaryrefslogtreecommitdiff
path: root/odk
diff options
context:
space:
mode:
authorNoel Grandin <noel@peralex.com>2012-09-07 09:51:41 +0200
committerMichael Stahl <mstahl@redhat.com>2012-09-10 23:43:37 +0200
commit43cd64dd61f24ac6ce1a2b4b7a04604734bfef2b (patch)
tree50c46a6a935a9ab746fde84d1c0885f792459aa7 /odk
parenta5ff5aad59bbe70cfaa0b18ec9df6f787a7160ca (diff)
Java cleanup, simplify and generify
Convert this code to use generics and remove needless complexity Change-Id: Icc87face21de963f433d2422b3e9d62042de24a8
Diffstat (limited to 'odk')
-rw-r--r--odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/Interceptor.java24
-rw-r--r--odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/OnewayExecutor.java17
-rw-r--r--odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/StatusListener.java28
3 files changed, 18 insertions, 51 deletions
diff --git a/odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/Interceptor.java b/odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/Interceptor.java
index 42d01cf1e679..4c8626a7d2ef 100644
--- a/odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/Interceptor.java
+++ b/odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/Interceptor.java
@@ -34,10 +34,11 @@
// __________ Imports __________
-import com.sun.star.uno.UnoRuntime;
-
import java.util.Vector;
+import com.sun.star.frame.FrameActionEvent;
+import com.sun.star.uno.UnoRuntime;
+
// __________ Implementation __________
/**
@@ -172,14 +173,7 @@ public class Interceptor implements com.sun.star.frame.XFrameActionListener,
// was it frameAction()?
if (nRequest==OnewayExecutor.REQUEST_FRAMEACTION)
{
- com.sun.star.frame.FrameActionEvent[] lOutAction = new com.sun.star.frame.FrameActionEvent[1];
- Vector[] lInParams = new Vector[1];
- lInParams[0] = lParams;
-
- OnewayExecutor.codeFrameAction( OnewayExecutor.DECODE_PARAMS ,
- lInParams ,
- lOutAction );
- impl_frameAction(lOutAction[0]);
+ impl_frameAction((FrameActionEvent) lParams.get(0));
}
else
// was it dispatch()?
@@ -244,16 +238,12 @@ public class Interceptor implements com.sun.star.frame.XFrameActionListener,
return;
// pack the event and start thread - which call us back later
- Vector[] lOutParams = new Vector[1];
- com.sun.star.frame.FrameActionEvent[] lInAction = new com.sun.star.frame.FrameActionEvent[1];
- lInAction[0] = aEvent;
+ Vector<FrameActionEvent> lOutParams = new Vector<FrameActionEvent>();
+ lOutParams.add(aEvent);
- OnewayExecutor.codeFrameAction( OnewayExecutor.ENCODE_PARAMS ,
- lOutParams ,
- lInAction );
OnewayExecutor aExecutor = new OnewayExecutor( (IOnewayLink)this ,
OnewayExecutor.REQUEST_FRAMEACTION ,
- lOutParams[0] );
+ lOutParams );
aExecutor.start();
}
diff --git a/odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/OnewayExecutor.java b/odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/OnewayExecutor.java
index c549c4883a73..53e547410105 100644
--- a/odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/OnewayExecutor.java
+++ b/odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/OnewayExecutor.java
@@ -34,6 +34,8 @@
import java.util.Vector;
+import com.sun.star.frame.FrameActionEvent;
+
// __________ Implementation __________
/**
@@ -142,21 +144,6 @@ class OnewayExecutor extends Thread
* one easier - you can use this helper methods. They know how suchlist
* must be coded. It's not a must to use it - but you can ...
*/
- public static void codeFrameAction(
- boolean bEncode, Vector[] lParams,
- com.sun.star.frame.FrameActionEvent[] aAction)
- {
- if (bEncode)
- {
- lParams[0] = new Vector<Object>(1);
- lParams[0].add( (Object)(aAction[0]) );
- }
- else
- {
- aAction[0] = (com.sun.star.frame.FrameActionEvent)
- (lParams[0].elementAt(0));
- }
- }
// _______________________________
diff --git a/odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/StatusListener.java b/odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/StatusListener.java
index ac5d429ba08a..753249d4ab09 100644
--- a/odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/StatusListener.java
+++ b/odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/StatusListener.java
@@ -34,13 +34,14 @@
// __________ Imports __________
-import com.sun.star.uno.UnoRuntime;
-
-import java.lang.String;
import java.awt.Component;
+import java.util.Vector;
+
import javax.swing.JCheckBox;
import javax.swing.JLabel;
-import java.util.Vector;
+
+import com.sun.star.frame.FrameActionEvent;
+import com.sun.star.uno.UnoRuntime;
// __________ Implementation __________
@@ -176,14 +177,7 @@ class StatusListener implements com.sun.star.frame.XStatusListener,
// was it frameAction()?
if (nRequest==OnewayExecutor.REQUEST_FRAMEACTION)
{
- com.sun.star.frame.FrameActionEvent[] lOutAction = new com.sun.star.frame.FrameActionEvent[1];
- Vector[] lInParams = new Vector[1];
- lInParams[0] = lParams;
-
- OnewayExecutor.codeFrameAction( OnewayExecutor.DECODE_PARAMS ,
- lInParams ,
- lOutAction );
- impl_frameAction(lOutAction[0]);
+ impl_frameAction((FrameActionEvent) lParams.get(0));
}
}
@@ -220,16 +214,12 @@ class StatusListener implements com.sun.star.frame.XStatusListener,
if (! bHandle)
return;
- Vector[] lOutParams = new Vector[1];
- com.sun.star.frame.FrameActionEvent[] lInAction = new com.sun.star.frame.FrameActionEvent[1];
- lInAction[0] = aEvent;
+ Vector<FrameActionEvent> lOutParams = new Vector<FrameActionEvent>();
+ lOutParams.add(aEvent);
- OnewayExecutor.codeFrameAction( OnewayExecutor.ENCODE_PARAMS ,
- lOutParams ,
- lInAction );
OnewayExecutor aExecutor = new OnewayExecutor( (IOnewayLink)this ,
OnewayExecutor.REQUEST_FRAMEACTION ,
- lOutParams[0] );
+ lOutParams );
aExecutor.start();
}