Skip to content

Commit feda0b8

Browse files
committed
JTable work; JSUtil.jQuery object; drag-drop; reflect.Constructor
fixes drag-drop for first call in Firefox/win fixes java.lang.reflect.Constructor for Integer
1 parent d4351a6 commit feda0b8

21 files changed

+6127
-6021
lines changed
55 Bytes
Binary file not shown.

sources/net.sf.j2s.java.core/src/java/awt/Container.java

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@
3333
import java.util.EventListener;
3434
import java.util.Set;
3535

36+
import javax.swing.table.TableCellRenderer;
37+
3638
import javajs.util.Lst;
3739

3840

@@ -51,6 +53,9 @@
5153
import java.beans.PropertyChangeListener;
5254
import sun.awt.AppContext;
5355
import sun.awt.SunGraphicsCallback;
56+
import swingjs.plaf.JSButtonUI;
57+
import swingjs.plaf.JSComponentUI;
58+
import swingjs.plaf.JSTableUI;
5459

5560

5661
/**
@@ -4700,15 +4705,20 @@ void retargetMouseEvent(Component target, int id, MouseEvent e) {
47004705
}
47014706

47024707
int x = e.getX(), y = e.getY();
4703-
Component component;
4704-
4705-
for(component = target;
4708+
Component component = target;
4709+
if (target.parent == null) {
4710+
component = ((JSComponentUI) ((JSComponent) target).getUI()).getTargetParent();
4711+
if (component != null)
4712+
target = component;
4713+
}
4714+
// SwingJS - TableCellRenderers do not have parents
4715+
for(;
47064716
component != null && component != nativeContainer;
47074717
component = component.getParent()) {
4708-
x -= component.x;
4709-
y -= component.y;
4710-
if (((JSComponent) component).uiClassID == "PopupMenuUI")
4711-
break; // SwingJS not to worry
4718+
x -= component.x;
4719+
y -= component.y;
4720+
if (((JSComponent) component).uiClassID == "PopupMenuUI")
4721+
break; // SwingJS not to worry
47124722
}
47134723
MouseEvent retargeted;
47144724
if (component != null) {

sources/net.sf.j2s.java.core/src/javax/swing/JTable.java

Lines changed: 5799 additions & 5776 deletions
Large diffs are not rendered by default.

sources/net.sf.j2s.java.core/src/javax/swing/table/TableColumn.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -820,6 +820,7 @@ public Component getTableCellRendererComponent(JTable table, Object value,
820820
}
821821
};
822822
label.setHorizontalAlignment(JLabel.CENTER);
823+
label.setOpaque(false);
823824
return label;
824825
}
825826

sources/net.sf.j2s.java.core/src/sun/swing/SwingLazyValue.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ public Object createValue(final UIDefaults table) {
8686
return constructor.newInstance(args);
8787
}
8888
} catch (Exception e) {
89+
System.out.println("Error in sun.swing.SwingLazyValue.createValue for " + className);
8990
// Ideally we would throw an exception, unfortunately
9091
// often times there are errors as an initial look and
9192
// feel is loaded before one can be switched. Perhaps a

sources/net.sf.j2s.java.core/src/swingjs/JSGraphicsConfiguration.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ public Rectangle getBounds() {
8989
* doc = document;
9090
*/
9191
{}
92-
JQueryObject d = JSUtil.getJQuery().$(doc);
92+
JQueryObject d = JSUtil.jQuery.$(doc);
9393
return new Rectangle(d.width(), d.height());
9494
}
9595
}

sources/net.sf.j2s.java.core/src/swingjs/JSSAXParser.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ public void parseXMLString(String data) throws SAXException, IOException {
110110
}
111111

112112
private DOMNode parseXML(String data) {
113-
return JSUtil.getJQuery().parseXML(removeProcessing(data));
113+
return JSUtil.jQuery.parseXML(removeProcessing(data));
114114
}
115115

116116
/**

sources/net.sf.j2s.java.core/src/swingjs/JSToolkit.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ public static void exit() {
120120
@Override
121121
protected int getScreenWidth() {
122122
@SuppressWarnings("unused")
123-
JQuery jq = JSUtil.getJQuery();
123+
JQuery jq = JSUtil.jQuery;
124124
int w = 0;
125125
/**
126126
* @j2sNative
@@ -136,7 +136,7 @@ protected int getScreenWidth() {
136136
@Override
137137
protected int getScreenHeight() {
138138
@SuppressWarnings("unused")
139-
JQuery jq = JSUtil.getJQuery();
139+
JQuery jq = JSUtil.jQuery;
140140
int h = 0;
141141
/**
142142
* @j2sNative

sources/net.sf.j2s.java.core/src/swingjs/JSUtil.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -227,8 +227,7 @@ static String processCSS(String css, String path) {
227227
path = path.substring(0, path.lastIndexOf("/") + 1) + "images/";
228228
css = PT.rep(css, "images/", path);
229229
}
230-
JQuery jq = JSUtil.getJQuery();
231-
jq.$("head").append(jq.$("<style type='text/css'>" + css + "</style>"));
230+
JSUtil.jQuery.$("head").append(JSUtil.jQuery.$("<style type='text/css'>" + css + "</style>"));
232231
return css;
233232
}
234233

@@ -266,6 +265,8 @@ static String ensureString(Object data) {
266265
* @return an object with $ as a method
267266
*/
268267
public static JQuery getJQuery() {
268+
if (jQuery != null)
269+
return jQuery;
269270
/**
270271
* @j2sNative
271272
*
@@ -277,6 +278,8 @@ public static JQuery getJQuery() {
277278
return null;
278279
}
279280
}
281+
282+
public static JQuery jQuery = getJQuery();
280283

281284
public static String getStackTrace(int n) {
282285
/**

sources/net.sf.j2s.java.core/src/swingjs/api/js/DOMNode.java

Lines changed: 36 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,13 @@
99

1010
public abstract class DOMNode {
1111

12+
1213
public abstract void appendChild(DOMNode node);
1314

1415
public abstract boolean hasFocus();
1516

1617
public abstract boolean play();
1718

18-
public abstract DOMNode removeChild(DOMNode nocde);
19-
2019
public abstract DOMNode removeAttribute(String attr);
2120

2221
public abstract void setSelectionRange(int pt0, int pt1);
@@ -63,29 +62,36 @@ public static DOMNode getParent(DOMNode node) {
6362
return null;
6463
}
6564
}
66-
65+
6766
/**
68-
* remove this node and return its parent
67+
*
6968
* @param node
70-
* @return parent or null
69+
* @param container
70+
* @return parent if container is null, or container if it is not null
7171
*/
72-
public static DOMNode remove(DOMNode node) {
72+
public static DOMNode transferTo(DOMNode node, DOMNode container) {
7373
if (node == null)
7474
return null;
75-
/**
76-
* @j2sNative
77-
*
78-
* try {
79-
* var p = node.parentElement;
80-
* p.removeChild(node);
81-
* $(body).remove(node);
82-
* } catch(e) {
83-
* };
84-
* return p;
85-
*/
86-
{
87-
return null;
75+
DOMNode p = getParent(node);
76+
try {
77+
JSUtil.jQuery.$(node).detach();
78+
} catch (Throwable e) {
79+
// ignore
8880
}
81+
if (container == null)
82+
return p;
83+
JSUtil.jQuery.$(container).append(node);
84+
return container;
85+
}
86+
87+
/**
88+
* remove this node and return its parent
89+
* @param node
90+
* @return parent or null
91+
*/
92+
public static void remove(DOMNode node) {
93+
if (node != null)
94+
JSUtil.jQuery.$(node).remove();
8995
}
9096

9197
/**
@@ -225,7 +231,7 @@ public static void addJqueryHandledEvent(Object me, DOMNode node, String event)
225231
* f = function(ev) {me.handleJSEvent$O$I$O(node, -1, ev)};
226232
*/
227233
{}
228-
JSUtil.getJQuery().$(node).on(event, f);
234+
JSUtil.jQuery.$(node).on(event, f);
229235
}
230236

231237
public static DOMNode setZ(DOMNode node, int z) {
@@ -270,16 +276,6 @@ public static void addHorizontalGap(DOMNode domNode, int gap) {
270276
domNode.appendChild(label);
271277
}
272278

273-
public static void removeAllChildren(DOMNode node) {
274-
/**
275-
* @j2sNative
276-
*
277-
* while (node.hasChildNodes()) {
278-
* node.removeChild(node.lastChild); }
279-
*/
280-
{}
281-
}
282-
283279
public static void seTabIndex(DOMNode node, int i) {
284280
/**
285281
* @j2sNative
@@ -293,4 +289,14 @@ public static void setVisible(DOMNode node, boolean visible) {
293289
setStyles(node, "display", visible ? "block" : "none");
294290
}
295291

292+
public static int getHeight(DOMNode node) {
293+
// TODO Auto-generated method stub
294+
return JSUtil.jQuery.$(node).height();
295+
}
296+
297+
public static int getWidth(DOMNode node) {
298+
// TODO Auto-generated method stub
299+
return JSUtil.jQuery.$(node).width();
300+
}
301+
296302
}

0 commit comments

Comments
 (0)