Skip to content

Commit 345a65b

Browse files
convert RunnerTextField to Java, removing Xtend dependencies
1 parent dd3f071 commit 345a65b

File tree

1 file changed

+49
-32
lines changed

1 file changed

+49
-32
lines changed
Lines changed: 49 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,60 @@
1+
/*
2+
* Copyright 2019 Philipp Salvisberg <philipp.salvisberg@trivadis.com>
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+
*/
116
package org.utplsql.sqldev.ui.runner;
217

318
import java.awt.Graphics;
419
import java.awt.event.FocusEvent;
520
import java.awt.event.FocusListener;
21+
622
import javax.swing.JTextField;
723
import javax.swing.UIManager;
8-
import javax.swing.text.Caret;
924

10-
@SuppressWarnings("all")
1125
public class RunnerTextField extends JTextField implements FocusListener {
12-
public RunnerTextField() {
13-
super();
14-
this.addFocusListener(this);
15-
}
16-
17-
@Override
18-
public void paintComponent(final Graphics g) {
19-
boolean _isOpaque = this.isOpaque();
20-
boolean _not = (!_isOpaque);
21-
if (_not) {
22-
super.paintComponent(g);
23-
return;
26+
private static final long serialVersionUID = 4527406698634871523L;
27+
28+
public RunnerTextField() {
29+
super();
30+
addFocusListener(this);
31+
}
32+
33+
@Override
34+
public void paintComponent(final Graphics g) {
35+
// default for non-opaque components
36+
if (!isOpaque()) {
37+
super.paintComponent(g);
38+
return;
39+
}
40+
41+
// use value of JTextField for consistency
42+
g.setColor(UIManager.getColor("TextField.inactiveBackground"));
43+
g.fillRect(0, 0, getWidth(), getHeight());
44+
45+
// do rest, changing opaque to ensure background is not overwritten
46+
setOpaque(false);
47+
super.paintComponent(g);
48+
setOpaque(true);
49+
}
50+
51+
@Override
52+
public void focusGained(final FocusEvent e) {
53+
getCaret().setVisible(true);
54+
}
55+
56+
@Override
57+
public void focusLost(final FocusEvent e) {
58+
getCaret().setVisible(false);
2459
}
25-
g.setColor(UIManager.getColor("TextField.inactiveBackground"));
26-
g.fillRect(0, 0, this.getWidth(), this.getHeight());
27-
this.setOpaque(false);
28-
super.paintComponent(g);
29-
this.setOpaque(true);
30-
}
31-
32-
@Override
33-
public void focusGained(final FocusEvent e) {
34-
Caret _caret = this.getCaret();
35-
_caret.setVisible(true);
36-
}
37-
38-
@Override
39-
public void focusLost(final FocusEvent e) {
40-
Caret _caret = this.getCaret();
41-
_caret.setVisible(false);
42-
}
4360
}

0 commit comments

Comments
 (0)