1 package com.nilhcem.fakesmtp.gui.info;
2
3 import com.nilhcem.fakesmtp.core.ArgsHandler;
4 import com.nilhcem.fakesmtp.core.I18n;
5 import com.nilhcem.fakesmtp.gui.DirChooser;
6 import com.nilhcem.fakesmtp.model.UIModel;
7
8 import javax.swing.JTextField;
9 import java.awt.Color;
10 import java.awt.event.MouseEvent;
11 import java.awt.event.MouseListener;
12 import java.util.Observable;
13 import java.util.Observer;
14
15
16
17
18
19
20
21 public final class SaveMsgField extends Observable implements Observer {
22
23 private final JTextField saveMsgField = new JTextField(UIModel.INSTANCE.getSavePath());
24
25
26
27
28
29
30
31
32 public SaveMsgField() {
33 saveMsgField.setToolTipText(I18n.INSTANCE.get("savemsgfield.tooltip"));
34
35
36 Color bg = saveMsgField.getBackground();
37 saveMsgField.setEditable(false);
38 saveMsgField.setBackground(bg);
39
40 if (!ArgsHandler.INSTANCE.memoryModeEnabled()) {
41
42 saveMsgField.addMouseListener(new MouseListener() {
43 @Override
44 public void mouseClicked(MouseEvent e) {
45 }
46
47 @Override
48 public void mousePressed(MouseEvent e) {
49 openFolderSelection();
50 }
51
52 @Override
53 public void mouseReleased(MouseEvent e) {
54 }
55
56 @Override
57 public void mouseEntered(MouseEvent e) {
58 }
59
60 @Override
61 public void mouseExited(MouseEvent e) {
62 }
63
64 private void openFolderSelection() {
65 setChanged();
66 notifyObservers();
67 }
68 });
69 }
70 }
71
72
73
74
75
76
77 public JTextField get() {
78 return saveMsgField;
79 }
80
81
82
83
84
85
86
87
88
89
90
91 @Override
92 public void update(Observable o, Object arg) {
93 if (o instanceof DirChooser) {
94 saveMsgField.setText(UIModel.INSTANCE.getSavePath());
95 }
96 }
97 }