Lines 41-51
Link Here
|
41 |
|
41 |
|
42 |
import java.awt.event.ActionEvent; |
42 |
import java.awt.event.ActionEvent; |
43 |
import java.awt.event.ActionListener; |
43 |
import java.awt.event.ActionListener; |
|
|
44 |
import java.lang.annotation.ElementType; |
45 |
import java.lang.annotation.Retention; |
46 |
import java.lang.annotation.RetentionPolicy; |
47 |
import java.lang.annotation.Target; |
44 |
import java.util.Collection; |
48 |
import java.util.Collection; |
45 |
import javax.swing.AbstractAction; |
49 |
import javax.swing.AbstractAction; |
46 |
import javax.swing.Action; |
50 |
import javax.swing.Action; |
47 |
import javax.swing.ActionMap; |
51 |
import javax.swing.ActionMap; |
48 |
import org.netbeans.junit.NbTestCase; |
52 |
import org.netbeans.junit.NbTestCase; |
|
|
53 |
import org.openide.awt.ActionReference; |
49 |
import org.openide.awt.ActionRegistration; |
54 |
import org.openide.awt.ActionRegistration; |
50 |
import org.openide.filesystems.FileObject; |
55 |
import org.openide.filesystems.FileObject; |
51 |
import org.openide.filesystems.FileUtil; |
56 |
import org.openide.filesystems.FileUtil; |
Lines 102-107
Link Here
|
102 |
id="my-action", |
107 |
id="my-action", |
103 |
key="klic" |
108 |
key="klic" |
104 |
) |
109 |
) |
|
|
110 |
@ActionReference( |
111 |
path="Loaders/text/x-test/Actions" |
112 |
) |
105 |
public static final class Callback implements ActionListener { |
113 |
public static final class Callback implements ActionListener { |
106 |
static int cnt; |
114 |
static int cnt; |
107 |
public void actionPerformed(ActionEvent e) { |
115 |
public void actionPerformed(ActionEvent e) { |
Lines 111-118
Link Here
|
111 |
|
119 |
|
112 |
public void testCallbackAction() throws Exception { |
120 |
public void testCallbackAction() throws Exception { |
113 |
FileObject fo = FileUtil.getConfigFile( |
121 |
FileObject fo = FileUtil.getConfigFile( |
114 |
"Actions/Tools/my-action.instance" |
122 |
"Loaders/text/x-test/Actions/my-action.shadow" |
115 |
); |
123 |
); |
|
|
124 |
assertNotNull("Shadow found", fo); |
125 |
String orig = (String) fo.getAttribute("originalFile"); |
126 |
assertNotNull("reference defined", orig); |
127 |
|
128 |
fo = FileUtil.getConfigFile(orig); |
116 |
assertNotNull("File found", fo); |
129 |
assertNotNull("File found", fo); |
117 |
Object obj = fo.getAttribute("instanceCreate"); |
130 |
Object obj = fo.getAttribute("instanceCreate"); |
118 |
assertNotNull("Attribute present", obj); |
131 |
assertNotNull("Attribute present", obj); |
Lines 145-155
Link Here
|
145 |
assertEquals("Global Action called", 200, Callback.cnt); |
158 |
assertEquals("Global Action called", 200, Callback.cnt); |
146 |
} |
159 |
} |
147 |
|
160 |
|
|
|
161 |
@ActionReference.Meta(path="Loaders/mimeType()/Actions") |
162 |
@Retention(RetentionPolicy.SOURCE) |
163 |
@Target(ElementType.TYPE) |
164 |
public @interface MimeAction { |
165 |
String mimeType(); |
166 |
} |
167 |
|
148 |
@ActionRegistration( |
168 |
@ActionRegistration( |
149 |
category="Tools", |
169 |
category="Tools", |
150 |
displayName="#OnInt", |
170 |
displayName="#OnInt", |
151 |
id="on-int" |
171 |
id="on-int" |
152 |
) |
172 |
) |
|
|
173 |
@MimeAction(mimeType="text/mime") |
153 |
public static final class Context implements ActionListener { |
174 |
public static final class Context implements ActionListener { |
154 |
private final int context; |
175 |
private final int context; |
155 |
|
176 |
|
Lines 167-174
Link Here
|
167 |
|
188 |
|
168 |
public void testContextAction() throws Exception { |
189 |
public void testContextAction() throws Exception { |
169 |
FileObject fo = FileUtil.getConfigFile( |
190 |
FileObject fo = FileUtil.getConfigFile( |
170 |
"Actions/Tools/on-int.instance" |
191 |
"Loaders/text/mime/Actions/on-int.shadow" |
171 |
); |
192 |
); |
|
|
193 |
assertNotNull("Shadow found", fo); |
194 |
String orig = (String) fo.getAttribute("originalFile"); |
195 |
assertNotNull("reference defined", orig); |
196 |
|
197 |
fo = FileUtil.getConfigFile(orig); |
172 |
assertNotNull("File found", fo); |
198 |
assertNotNull("File found", fo); |
173 |
Object obj = fo.getAttribute("instanceCreate"); |
199 |
Object obj = fo.getAttribute("instanceCreate"); |
174 |
assertNotNull("Attribute present", obj); |
200 |
assertNotNull("Attribute present", obj); |