Skip to content

Commit 1c0033a

Browse files
convert RunnerTextArea to Java, removing Xtend dependencies
1 parent 3450897 commit 1c0033a

File tree

1 file changed

+49
-36
lines changed

1 file changed

+49
-36
lines changed
Lines changed: 49 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +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.JTextArea;
723
import javax.swing.UIManager;
8-
import javax.swing.text.Caret;
924

10-
@SuppressWarnings("all")
1125
public class RunnerTextArea extends JTextArea implements FocusListener {
12-
public RunnerTextArea() {
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 = -1536393556223117580L;
27+
28+
public RunnerTextArea() {
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(3, 3, getWidth() - 6, getHeight() - 6);
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-
int _width = this.getWidth();
27-
int _minus = (_width - 6);
28-
int _height = this.getHeight();
29-
int _minus_1 = (_height - 6);
30-
g.fillRect(3, 3, _minus, _minus_1);
31-
this.setOpaque(false);
32-
super.paintComponent(g);
33-
this.setOpaque(true);
34-
}
35-
36-
@Override
37-
public void focusGained(final FocusEvent e) {
38-
Caret _caret = this.getCaret();
39-
_caret.setVisible(true);
40-
}
41-
42-
@Override
43-
public void focusLost(final FocusEvent e) {
44-
Caret _caret = this.getCaret();
45-
_caret.setVisible(false);
46-
}
4760
}

0 commit comments

Comments
 (0)