Skip to content

Commit 0bec7e5

Browse files
committed
Debugging and increase dialog height.
1 parent 07f7dcc commit 0bec7e5

File tree

2 files changed

+104
-102
lines changed

2 files changed

+104
-102
lines changed

src/main/java/org/chrisle/netbeans/plugins/nbscratchfile/NbScratchFileViewModel.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ public NbScratchFileViewModel(JDialog dialog) {
4242
}
4343

4444
public void setExt(String ext, String languageName) {
45+
System.out.println(languageName);
46+
4547
try {
4648
Path path = Paths.get(String.format("%s/.netbeans/scratches/%s/scratch%d.%s", System.getProperty("user.home"), languageName, this.counter++, ext));
4749
Files.createDirectories(path.getParent());
Lines changed: 102 additions & 102 deletions
Original file line numberDiff line numberDiff line change
@@ -1,102 +1,102 @@
1-
/*
2-
* Copyright 2017 Chris2011.
3-
*
4-
* Licensed under the Apache License, Version 2.0 (the "License");
5-
* you may not use this file except in compliance with the License.
6-
* You may obtain a copy of the License at
7-
*
8-
* http://www.apache.org/licenses/LICENSE-2.0
9-
*
10-
* Unless required by applicable law or agreed to in writing, software
11-
* distributed under the License is distributed on an "AS IS" BASIS,
12-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13-
* See the License for the specific language governing permissions and
14-
* limitations under the License.
15-
*/
16-
package org.chrisle.netbeans.plugins.utils;
17-
18-
import java.awt.Color;
19-
import java.awt.Component;
20-
import java.awt.KeyboardFocusManager;
21-
import java.awt.event.ActionEvent;
22-
import java.awt.event.KeyEvent;
23-
import java.awt.event.WindowEvent;
24-
import java.awt.event.WindowFocusListener;
25-
import javax.swing.JComponent;
26-
import javax.swing.JDialog;
27-
import javax.swing.KeyStroke;
28-
import net.java.html.js.JavaScriptBody;
29-
import org.w3c.dom.Element;
30-
import org.w3c.dom.NodeList;
31-
import org.w3c.dom.events.Event;
32-
import org.w3c.dom.events.EventTarget;
33-
34-
/**
35-
*
36-
* @author Chris2011
37-
*/
38-
public class WebViewDialog extends JDialog {
39-
private static final long serialVersionUID = 5885621373197292877L;
40-
41-
public void init(JComponent jfxPanel) {
42-
super.add(jfxPanel);
43-
super.setSize(550, 436);
44-
super.setResizable(false);
45-
super.setAlwaysOnTop(true);
46-
super.setUndecorated(true);
47-
super.getRootPane().setOpaque(false);
48-
super.getContentPane().setBackground(new Color(0, 0, 0, 0));
49-
super.setBackground(new Color(0, 0, 0, 0));
50-
51-
super.addWindowFocusListener(new WindowFocusListener() {
52-
@Override
53-
public void windowGainedFocus(WindowEvent e) {
54-
}
55-
56-
@Override
57-
public void windowLostFocus(WindowEvent e) {
58-
WebViewDialog.this.setVisible(false);
59-
}
60-
});
61-
62-
super.getRootPane().registerKeyboardAction((ActionEvent e1) -> {
63-
super.setVisible(false);
64-
}, KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), JComponent.WHEN_IN_FOCUSED_WINDOW);
65-
}
66-
67-
@JavaScriptBody(args = { "id", "tag", "css" }, body = ""
68-
+ "var sourceElem = id ? document.getElementById(id) : document.getElementsByTagName(tag)[0];"
69-
+ "sourceElem.setAttribute('style', css);")
70-
public native void colorizeElement(String id, String tag, String css);
71-
72-
private void addHoverEffectToElement(Element sourceElem, String newCss, String oldCss) {
73-
((EventTarget) sourceElem).addEventListener("mouseover", (Event elem) -> {
74-
sourceElem.setAttribute("style", newCss);
75-
}, false);
76-
77-
((EventTarget) sourceElem).addEventListener("mouseout", (Event elem) -> {
78-
sourceElem.setAttribute("style", oldCss);
79-
}, false);
80-
}
81-
82-
public void addHoverEffectToElements(NodeList sourceElements, String newCss, String oldCss) {
83-
for (int i = 0; i < sourceElements.getLength(); i++) {
84-
addHoverEffectToElement((Element) sourceElements.item(i), newCss, oldCss);
85-
}
86-
}
87-
88-
public void showDialog() {
89-
// try to use monitor, where the input focus is
90-
// therefor get the topmost component based on the input focus
91-
Component focusOwner = KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner();
92-
93-
if (null != focusOwner) {
94-
while (focusOwner.getParent() != null) {
95-
focusOwner = focusOwner.getParent();
96-
}
97-
}
98-
99-
super.setLocationRelativeTo(focusOwner);
100-
super.setVisible(true);
101-
}
102-
}
1+
/*
2+
* Copyright 2017 Chris2011.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package org.chrisle.netbeans.plugins.utils;
17+
18+
import java.awt.Color;
19+
import java.awt.Component;
20+
import java.awt.KeyboardFocusManager;
21+
import java.awt.event.ActionEvent;
22+
import java.awt.event.KeyEvent;
23+
import java.awt.event.WindowEvent;
24+
import java.awt.event.WindowFocusListener;
25+
import javax.swing.JComponent;
26+
import javax.swing.JDialog;
27+
import javax.swing.KeyStroke;
28+
import net.java.html.js.JavaScriptBody;
29+
import org.w3c.dom.Element;
30+
import org.w3c.dom.NodeList;
31+
import org.w3c.dom.events.Event;
32+
import org.w3c.dom.events.EventTarget;
33+
34+
/**
35+
*
36+
* @author Chris2011
37+
*/
38+
public class WebViewDialog extends JDialog {
39+
private static final long serialVersionUID = 5885621373197292877L;
40+
41+
public void init(JComponent jfxPanel) {
42+
super.add(jfxPanel);
43+
super.setSize(550, 438);
44+
super.setResizable(false);
45+
super.setAlwaysOnTop(true);
46+
super.setUndecorated(true);
47+
super.getRootPane().setOpaque(false);
48+
super.getContentPane().setBackground(new Color(0, 0, 0, 0));
49+
super.setBackground(new Color(0, 0, 0, 0));
50+
51+
super.addWindowFocusListener(new WindowFocusListener() {
52+
@Override
53+
public void windowGainedFocus(WindowEvent e) {
54+
}
55+
56+
@Override
57+
public void windowLostFocus(WindowEvent e) {
58+
WebViewDialog.this.setVisible(false);
59+
}
60+
});
61+
62+
super.getRootPane().registerKeyboardAction((ActionEvent e1) -> {
63+
super.setVisible(false);
64+
}, KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), JComponent.WHEN_IN_FOCUSED_WINDOW);
65+
}
66+
67+
@JavaScriptBody(args = { "id", "tag", "css" }, body = ""
68+
+ "var sourceElem = id ? document.getElementById(id) : document.getElementsByTagName(tag)[0];"
69+
+ "sourceElem.setAttribute('style', css);")
70+
public native void colorizeElement(String id, String tag, String css);
71+
72+
private void addHoverEffectToElement(Element sourceElem, String newCss, String oldCss) {
73+
((EventTarget) sourceElem).addEventListener("mouseover", (Event elem) -> {
74+
sourceElem.setAttribute("style", newCss);
75+
}, false);
76+
77+
((EventTarget) sourceElem).addEventListener("mouseout", (Event elem) -> {
78+
sourceElem.setAttribute("style", oldCss);
79+
}, false);
80+
}
81+
82+
public void addHoverEffectToElements(NodeList sourceElements, String newCss, String oldCss) {
83+
for (int i = 0; i < sourceElements.getLength(); i++) {
84+
addHoverEffectToElement((Element) sourceElements.item(i), newCss, oldCss);
85+
}
86+
}
87+
88+
public void showDialog() {
89+
// try to use monitor, where the input focus is
90+
// therefor get the topmost component based on the input focus
91+
Component focusOwner = KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner();
92+
93+
if (null != focusOwner) {
94+
while (focusOwner.getParent() != null) {
95+
focusOwner = focusOwner.getParent();
96+
}
97+
}
98+
99+
super.setLocationRelativeTo(focusOwner);
100+
super.setVisible(true);
101+
}
102+
}

0 commit comments

Comments
 (0)