Skip to content

Commit 1bc6d52

Browse files
committed
WA-1484 Left the oXygen built-in CGM Image Handler to make it compatible with the WebAuthor.
1 parent 7ddf773 commit 1bc6d52

File tree

2 files changed

+22
-13
lines changed

2 files changed

+22
-13
lines changed

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
.project
2+
.settings/

wsAccess.js

+20-13
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
function applicationStarted(pluginWorkspaceAccess) {
2-
imageHandler = {
2+
var imageHandler = {
33
editImage: function(editContext){return null;},
44
editImage: function(url){return false;},
55
canHandleFileType: function(type){return type.equals("cgm")},
@@ -12,37 +12,44 @@ function applicationStarted(pluginWorkspaceAccess) {
1212
return getCGMImage(pluginWorkspaceAccess, cp, rc);
1313
}
1414
}
15-
pluginWorkspaceAccess.getImageUtilities().addImageHandler(new JavaAdapter(Packages.ro.sync.exml.workspace.api.images.handlers.EditImageHandler, imageHandler));
15+
16+
17+
/**
18+
* This line overrides the oXygen default CGM image handler.
19+
*
20+
* Uncomment to activate this feature.
21+
*/
22+
//pluginWorkspaceAccess.getImageUtilities().addImageHandler(new JavaAdapter(Packages.ro.sync.exml.workspace.api.images.handlers.EditImageHandler, imageHandler));
1623
}
1724

1825
function getCGMImage(pluginWorkspaceAccess, cp, rc){
19-
cgmPanel = new Packages.net.sf.jcgm.core.CGMPanel();
26+
var cgmPanel = new Packages.net.sf.jcgm.core.CGMPanel();
2027
cgmPanel.setSize(800, 600);
2128
cgmPanel.open(cp.getUrl());
2229
// Create a new bufferedImage with imagePanel size
23-
image = new Packages.java.awt.image.BufferedImage(800, 600, Packages.java.awt.image.BufferedImage.TYPE_INT_RGB);
30+
var image = new Packages.java.awt.image.BufferedImage(800, 600, Packages.java.awt.image.BufferedImage.TYPE_INT_RGB);
2431
// Create a graphics context from the new image
25-
graphics = image.createGraphics();
32+
var graphics = image.createGraphics();
2633
graphics.setColor(Packages.java.awt.Color.WHITE);
2734
graphics.fillRect(0, 0, 800, 600);
28-
29-
paintComponentMethod = getPaintMethod(cgmPanel.getClass());
35+
36+
var paintComponentMethod = getPaintMethod(cgmPanel.getClass());
3037
paintComponentMethod.setAccessible(true);
3138
paintComponentMethod.invoke(cgmPanel, graphics);
3239
return image;
3340
}
3441

3542
/**
3643
* Looks inside the provided class to find the "paint" method.
37-
*
38-
* @param clazz The class with public "paint" method.
44+
*
45+
* @param clazz The class with public "paint" method.
3946
* @return The "paint" method.
4047
*/
4148
function getPaintMethod(clazz) {
42-
paint = null;
49+
var paint = null;
4350
while (paint == null && clazz != null) {
4451
try {
45-
declMethods = clazz.getDeclaredMethods();
52+
var declMethods = clazz.getDeclaredMethods();
4653
for(i=0;i<declMethods.length;i++){
4754
if(declMethods[i].getName().equals("paint")){
4855
paint = declMethods[i];
@@ -51,10 +58,10 @@ function getCGMImage(pluginWorkspaceAccess, cp, rc){
5158
} catch (e) {
5259
// No such method.
5360
}
54-
61+
5562
clazz = clazz.getSuperclass();
5663
}
57-
64+
5865
return paint;
5966
}
6067

0 commit comments

Comments
 (0)