1
2
3
4
5
6 package de.funfried.netbeans.plugins.editor.closeleftright.options;
7
8 import java.beans.PropertyChangeListener;
9 import java.beans.PropertyChangeSupport;
10
11 import javax.swing.JComponent;
12 import javax.swing.SwingUtilities;
13 import javax.swing.event.ChangeEvent;
14 import javax.swing.event.ChangeListener;
15
16 import org.netbeans.spi.options.OptionsPanelController;
17 import org.openide.util.HelpCtx;
18 import org.openide.util.Lookup;
19 import org.openide.util.WeakListeners;
20
21 @OptionsPanelController.SubRegistration(location = "Appearance", displayName = "#AdvancedOption_DisplayName_AdditionalCloseActions", keywords = "#AdvancedOption_Keywords_AdditionalCloseActions", keywordsCategory = "Appearance/AdditionalCloseActions", position = 100)
22 @org.openide.util.NbBundle.Messages({ "AdvancedOption_DisplayName_AdditionalCloseActions=Additional Close Actions",
23 "AdvancedOption_Keywords_AdditionalCloseActions=action,actions,close,editor,project,left,right,git,subversion,mercurial,vcs,version,control,system,diff,search,history" })
24 public final class AdditionalCloseActionsOptionsPanelController extends OptionsPanelController implements ChangeListener {
25 private final PropertyChangeSupport pcs = new PropertyChangeSupport(this);
26
27 private AdditionalCloseActionsPanel panel;
28
29 private boolean changed;
30
31 @Override
32 public void update() {
33 getOrCreatePanel().load();
34 changed = false;
35 }
36
37
38
39
40 @Override
41 public void applyChanges() {
42 SwingUtilities.invokeLater(() -> {
43 getOrCreatePanel().store();
44 changed = false;
45 });
46 }
47
48
49
50
51 @Override
52 public void cancel() {
53
54 }
55
56
57
58
59 @Override
60 public boolean isValid() {
61 return getOrCreatePanel().valid();
62 }
63
64
65
66
67 @Override
68 public boolean isChanged() {
69 return changed;
70 }
71
72
73
74
75 @Override
76 public HelpCtx getHelpCtx() {
77 return null;
78 }
79
80
81
82
83 @Override
84 public JComponent getComponent(Lookup masterLookup) {
85 return getOrCreatePanel();
86 }
87
88
89
90
91 @Override
92 public void addPropertyChangeListener(PropertyChangeListener l) {
93 pcs.addPropertyChangeListener(l);
94 }
95
96
97
98
99 @Override
100 public void removePropertyChangeListener(PropertyChangeListener l) {
101 pcs.removePropertyChangeListener(l);
102 }
103
104 private AdditionalCloseActionsPanel getOrCreatePanel() {
105 if (panel == null) {
106 panel = new AdditionalCloseActionsPanel();
107 panel.addChangeListener(WeakListeners.change(this, panel));
108 }
109
110 return panel;
111 }
112
113
114
115
116 @Override
117 public void stateChanged(ChangeEvent e) {
118 if (!changed) {
119 changed = true;
120 pcs.firePropertyChange(OptionsPanelController.PROP_CHANGED, false, true);
121 }
122
123 pcs.firePropertyChange(OptionsPanelController.PROP_VALID, null, null);
124 }
125
126 }