Lines 42-49
Link Here
|
42 |
|
42 |
|
43 |
package org.netbeans.spi.project.ui.support; |
43 |
package org.netbeans.spi.project.ui.support; |
44 |
|
44 |
|
|
|
45 |
import java.lang.ref.Reference; |
46 |
import java.lang.ref.WeakReference; |
47 |
import javax.swing.event.ChangeEvent; |
48 |
import javax.swing.event.ChangeListener; |
49 |
import org.netbeans.modules.project.uiapi.BuildExecutionSupportImplementation; |
45 |
import org.netbeans.modules.project.uiapi.Utilities; |
50 |
import org.netbeans.modules.project.uiapi.Utilities; |
46 |
import org.openide.filesystems.FileObject; |
51 |
import org.openide.filesystems.FileObject; |
|
|
52 |
import org.openide.util.ChangeSupport; |
53 |
import org.openide.util.WeakListeners; |
47 |
|
54 |
|
48 |
/** |
55 |
/** |
49 |
* Register running and finished build/run/debug tasks for use |
56 |
* Register running and finished build/run/debug tasks for use |
Lines 77-82
Link Here
|
77 |
public static void registerFinishedItem(BuildExecutionSupport.Item item) { |
84 |
public static void registerFinishedItem(BuildExecutionSupport.Item item) { |
78 |
Utilities.getBuildExecutionSupportImplementation().registerFinishedItem(item); |
85 |
Utilities.getBuildExecutionSupportImplementation().registerFinishedItem(item); |
79 |
} |
86 |
} |
|
|
87 |
|
88 |
public static BuildExecutionSupport.Item getLastItem() { |
89 |
return Utilities.getBuildExecutionSupportImplementation().getLastItem(); |
90 |
} |
91 |
|
92 |
public static ChangeListenerSupport getChangeSupport() { |
93 |
return ChangeListenerSupportImpl.getInstance(); |
94 |
} |
80 |
|
95 |
|
81 |
/** |
96 |
/** |
82 |
* Wrapper for the build job used by <code>BuildExecutionSupport</code> |
97 |
* Wrapper for the build job used by <code>BuildExecutionSupport</code> |
Lines 123-126
Link Here
|
123 |
*/ |
138 |
*/ |
124 |
FileObject getProjectDirectory(); |
139 |
FileObject getProjectDirectory(); |
125 |
} |
140 |
} |
|
|
141 |
|
142 |
public static interface ChangeListenerSupport { |
143 |
|
144 |
void addChangeListener(ChangeListener listener); |
145 |
|
146 |
void removeChangeListener(ChangeListener listener); |
147 |
|
148 |
} |
149 |
|
150 |
private static class ChangeListenerSupportImpl implements ChangeListenerSupport, ChangeListener { |
151 |
|
152 |
private static volatile Reference<ChangeListenerSupportImpl> chsiRef = new WeakReference<ChangeListenerSupportImpl>(null); |
153 |
private final ChangeSupport chs = new ChangeSupport(this); |
154 |
|
155 |
private ChangeListenerSupportImpl() { |
156 |
BuildExecutionSupportImplementation besi = Utilities.getBuildExecutionSupportImplementation(); |
157 |
besi.addChangeListener(WeakListeners.change(this, besi)); |
158 |
} |
159 |
|
160 |
static ChangeListenerSupportImpl getInstance() { |
161 |
ChangeListenerSupportImpl chsi = chsiRef.get(); |
162 |
if (chsi == null) { |
163 |
chsi = new ChangeListenerSupportImpl(); |
164 |
chsiRef = new WeakReference<ChangeListenerSupportImpl>(chsi); |
165 |
} |
166 |
return chsi; |
167 |
} |
168 |
|
169 |
@Override |
170 |
public void addChangeListener(ChangeListener listener) { |
171 |
chs.addChangeListener(listener); |
172 |
} |
173 |
|
174 |
@Override |
175 |
public void removeChangeListener(ChangeListener listener) { |
176 |
chs.removeChangeListener(listener); |
177 |
} |
178 |
|
179 |
@Override |
180 |
public void stateChanged(ChangeEvent e) { |
181 |
chs.fireChange(); |
182 |
} |
183 |
|
184 |
} |
126 |
} |
185 |
} |