-
Notifications
You must be signed in to change notification settings - Fork 89
Expand file tree
/
Copy pathDataControl.java
More file actions
58 lines (48 loc) · 2.11 KB
/
DataControl.java
File metadata and controls
58 lines (48 loc) · 2.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
package nodebox.client.parameter;
import nodebox.client.NodeBoxDocument;
import nodebox.client.TextWindow;
import nodebox.client.Theme;
import nodebox.node.Parameter;
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
public class DataControl extends AbstractParameterControl implements ActionListener {
private JButton showDataButton;
private JButton clearDataButton;
public DataControl(Parameter parameter) {
super(parameter);
setLayout(new BoxLayout(this, BoxLayout.LINE_AXIS));
clearDataButton = new JButton("Clear");
clearDataButton.setMargin(new Insets(1, 0, 0, 0));
clearDataButton.putClientProperty("JButton.buttonType", "textured");
clearDataButton.putClientProperty("JComponent.sizeVariant", "small");
clearDataButton.setFont(Theme.SMALL_BOLD_FONT);
clearDataButton.setForeground(Theme.TEXT_NORMAL_COLOR);
clearDataButton.addActionListener(this);
add(clearDataButton);
showDataButton = new JButton("Show Data...");
showDataButton.setMargin(new Insets(1, 0, 0, 0));
showDataButton.putClientProperty("JButton.buttonType", "textured");
showDataButton.putClientProperty("JComponent.sizeVariant", "small");
showDataButton.setFont(Theme.SMALL_BOLD_FONT);
showDataButton.setForeground(Theme.TEXT_NORMAL_COLOR);
showDataButton.addActionListener(this);
add(showDataButton);
add(Box.createHorizontalGlue());
}
public void setValueForControl(Object v) {
}
public void actionPerformed(ActionEvent e) {
if (e.getSource() == clearDataButton) {
setParameterValue("");
} else if (e.getSource() == showDataButton) {
NodeBoxDocument doc = NodeBoxDocument.getCurrentDocument();
if (doc == null) throw new RuntimeException("No current active document.");
TextWindow window = new TextWindow(parameter);
window.setLocationRelativeTo(this);
window.setVisible(true);
doc.addParameterEditor(window);
}
}
}