Skip to content

Commit 3d51f9f

Browse files
add RunnerTextPane.java generated by Xtend 2.20.0
1 parent 6aa0411 commit 3d51f9f

File tree

1 file changed

+47
-45
lines changed

1 file changed

+47
-45
lines changed
Lines changed: 47 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/*
1+
/**
22
* Copyright 2019 Philipp Salvisberg <philipp.salvisberg@trivadis.com>
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -13,50 +13,52 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16+
package org.utplsql.sqldev.ui.runner;
1617

17-
package org.utplsql.sqldev.ui.runner
18+
import java.awt.Graphics;
19+
import java.awt.event.FocusEvent;
20+
import java.awt.event.FocusListener;
21+
import javax.swing.JTextPane;
22+
import javax.swing.UIManager;
23+
import javax.swing.text.Caret;
1824

19-
import java.awt.Graphics
20-
import java.awt.event.FocusEvent
21-
import java.awt.event.FocusListener
22-
import javax.swing.JTextPane
23-
import javax.swing.UIManager
24-
25-
class RunnerTextPane extends JTextPane implements FocusListener{
26-
27-
new() {
28-
super()
29-
this.addFocusListener = this
30-
}
31-
32-
override paintComponent(Graphics g) {
33-
// default for non-opaque components
34-
if (!opaque) {
35-
super.paintComponent(g)
36-
return
37-
}
38-
39-
// use value of JTextField for consistency
40-
g.color = UIManager.getColor("TextField.inactiveBackground")
41-
g.fillRect(0, 0, width, height)
42-
43-
// do rest, changing opaque to ensure background is not overwritten
44-
setOpaque(false)
45-
super.paintComponent(g)
46-
setOpaque(true)
47-
}
48-
49-
override void focusGained(FocusEvent e) {
50-
this.caret.visible = true
51-
}
52-
53-
override focusLost(FocusEvent e) {
54-
this.caret.visible = false
55-
}
56-
57-
override setText(String t) {
58-
super.setText(t)
59-
// ensure left parts of long lines are always visible
60-
caretPosition = 0
61-
}
25+
@SuppressWarnings("all")
26+
public class RunnerTextPane extends JTextPane implements FocusListener {
27+
public RunnerTextPane() {
28+
super();
29+
this.addFocusListener(this);
30+
}
31+
32+
@Override
33+
public void paintComponent(final Graphics g) {
34+
boolean _isOpaque = this.isOpaque();
35+
boolean _not = (!_isOpaque);
36+
if (_not) {
37+
super.paintComponent(g);
38+
return;
39+
}
40+
g.setColor(UIManager.getColor("TextField.inactiveBackground"));
41+
g.fillRect(0, 0, this.getWidth(), this.getHeight());
42+
this.setOpaque(false);
43+
super.paintComponent(g);
44+
this.setOpaque(true);
45+
}
46+
47+
@Override
48+
public void focusGained(final FocusEvent e) {
49+
Caret _caret = this.getCaret();
50+
_caret.setVisible(true);
51+
}
52+
53+
@Override
54+
public void focusLost(final FocusEvent e) {
55+
Caret _caret = this.getCaret();
56+
_caret.setVisible(false);
57+
}
58+
59+
@Override
60+
public void setText(final String t) {
61+
super.setText(t);
62+
this.setCaretPosition(0);
63+
}
6264
}

0 commit comments

Comments
 (0)