Link Here
|
43 |
|
43 |
|
44 |
import java.io.IOException; |
44 |
import java.io.IOException; |
45 |
import java.util.List; |
45 |
import java.util.List; |
|
|
46 |
import javax.swing.JPanel; |
47 |
import javax.swing.SwingUtilities; |
46 |
import junit.framework.*; |
48 |
import junit.framework.*; |
47 |
import org.netbeans.api.editor.mimelookup.MimeLookup; |
49 |
import org.netbeans.api.editor.mimelookup.MimeLookup; |
48 |
import org.netbeans.api.editor.mimelookup.MimePath; |
50 |
import org.netbeans.api.editor.mimelookup.MimePath; |
49 |
import org.netbeans.junit.NbTestCase; |
51 |
import org.netbeans.junit.NbTestCase; |
|
|
52 |
import org.openide.actions.CopyAction; |
50 |
import org.openide.actions.CutAction; |
53 |
import org.openide.actions.CutAction; |
51 |
import org.openide.actions.FindAction; |
54 |
import org.openide.actions.FindAction; |
|
|
55 |
import org.openide.actions.PasteAction; |
52 |
import org.openide.actions.RenameAction; |
56 |
import org.openide.actions.RenameAction; |
53 |
import org.openide.actions.ReplaceAction; |
57 |
import org.openide.actions.ReplaceAction; |
54 |
import org.openide.util.Lookup; |
58 |
import org.openide.util.Lookup; |
Link Here
|
85 |
getClass().getClassLoader()); |
89 |
getClass().getClassLoader()); |
86 |
|
90 |
|
87 |
} |
91 |
} |
88 |
|
92 |
|
|
|
93 |
/** This method is here to simulate that it is possible to get |
94 |
* instance of the lookup without querying any of registered InstanceProvider. |
95 |
* They could acquire AWT lock and that can cause deadlocks. |
96 |
*/ |
97 |
private Lookup getLookup(final MimePath path) throws Exception { |
98 |
|
99 |
class BlockAWTLock implements Runnable { |
100 |
Lookup l; |
101 |
|
102 |
public void run() { |
103 |
l = MimeLookup.getLookup(path); |
104 |
} |
105 |
} |
106 |
BlockAWTLock b = new BlockAWTLock(); |
107 |
|
108 |
synchronized (PopupActions.LOCK) { |
109 |
SwingUtilities.invokeAndWait(b); |
110 |
} |
111 |
|
112 |
return b.l; |
113 |
} |
114 |
|
89 |
/** Testing Base level popup items lookup and sorting */ |
115 |
/** Testing Base level popup items lookup and sorting */ |
90 |
public void testDynamicChangeInPopupFolders() throws IOException{ |
116 |
public void testDynamicChangeInPopupFolders() throws Exception { |
91 |
final int resultChangedCount[] = new int[1]; |
117 |
final int resultChangedCount[] = new int[1]; |
92 |
resultChangedCount[0] = 0; |
118 |
resultChangedCount[0] = 0; |
93 |
|
119 |
|
94 |
MimePath mp = MimePath.parse("text/x-java/text/xml/text/html"); |
120 |
MimePath mp = MimePath.parse("text/x-java/text/xml/text/html"); |
95 |
Lookup lookup = MimeLookup.getLookup(mp); |
121 |
Lookup lookup = getLookup(mp); |
96 |
Lookup.Result result = lookup.lookup(new Template(PopupActions.class)); |
122 |
Lookup.Result result = lookup.lookup(new Template(PopupActions.class)); |
97 |
result.allInstances(); // remove this line if issue #60010 is fixed |
123 |
result.allInstances(); // remove this line if issue #60010 is fixed |
98 |
LookupListener listener = new LookupListener(){ |
124 |
LookupListener listener = new LookupListener(){ |
Link Here
|
145 |
//ReplaceAction was created in the uppermost folder |
171 |
//ReplaceAction was created in the uppermost folder |
146 |
// let's try it is missing in the lower lookup |
172 |
// let's try it is missing in the lower lookup |
147 |
mp = MimePath.get(MimePath.get("text/x-java"), "text/xml"); |
173 |
mp = MimePath.get(MimePath.get("text/x-java"), "text/xml"); |
148 |
lookup = MimeLookup.getLookup(mp); |
174 |
lookup = getLookup(mp); |
149 |
checkPopupItemPresence(lookup, ReplaceAction.class, false); |
175 |
checkPopupItemPresence(lookup, ReplaceAction.class, false); |
150 |
checkPopupItemPresence(lookup, FindAction.class, true); |
176 |
checkPopupItemPresence(lookup, FindAction.class, true); |
151 |
|
177 |
|