Lines 53-58
Link Here
|
53 |
import javax.swing.AbstractAction; |
53 |
import javax.swing.AbstractAction; |
54 |
import javax.swing.Action; |
54 |
import javax.swing.Action; |
55 |
import javax.swing.ActionMap; |
55 |
import javax.swing.ActionMap; |
|
|
56 |
import javax.swing.JSeparator; |
56 |
import org.netbeans.junit.NbTestCase; |
57 |
import org.netbeans.junit.NbTestCase; |
57 |
import org.openide.awt.ActionReference; |
58 |
import org.openide.awt.ActionReference; |
58 |
import org.openide.awt.ActionReferences; |
59 |
import org.openide.awt.ActionReferences; |
Lines 143-150
Link Here
|
143 |
@ActionRegistration(displayName="#AlwaysOn") |
144 |
@ActionRegistration(displayName="#AlwaysOn") |
144 |
@ActionID(id="my.test.AlwaysByMethod", category="Tools") |
145 |
@ActionID(id="my.test.AlwaysByMethod", category="Tools") |
145 |
@ActionReferences({ |
146 |
@ActionReferences({ |
146 |
@ActionReference(path="Kuk/buk", position=1), |
147 |
@ActionReference(path="Kuk/buk", position=1, separatorAfter=2), |
147 |
@ActionReference(path="Muk/luk", position=11) |
148 |
@ActionReference(path="Muk/luk", position=11, separatorBefore=10) |
148 |
}) |
149 |
}) |
149 |
public static ActionListener factory() { |
150 |
public static ActionListener factory() { |
150 |
created++; |
151 |
created++; |
Lines 178-183
Link Here
|
178 |
assertNotNull("Shadow created", shad); |
179 |
assertNotNull("Shadow created", shad); |
179 |
assertEquals("Right position", 1, shad.getAttribute("position")); |
180 |
assertEquals("Right position", 1, shad.getAttribute("position")); |
180 |
assertEquals("Proper link", fo.getPath(), shad.getAttribute("originalFile")); |
181 |
assertEquals("Proper link", fo.getPath(), shad.getAttribute("originalFile")); |
|
|
182 |
FileObject sep = FileUtil.getConfigFile( |
183 |
"Kuk/buk/my-test-AlwaysByMethod-separatorAfter.instance" |
184 |
); |
185 |
assertNotNull("Separator generated", sep); |
186 |
assertEquals("Position 2", 2, sep.getAttribute("position")); |
187 |
Object instSep = sep.getAttribute("instanceCreate"); |
188 |
assertTrue("Right instance " + instSep, instSep instanceof JSeparator); |
181 |
} |
189 |
} |
182 |
{ |
190 |
{ |
183 |
FileObject shad = FileUtil.getConfigFile( |
191 |
FileObject shad = FileUtil.getConfigFile( |
Lines 186-191
Link Here
|
186 |
assertNotNull("Shadow created", shad); |
194 |
assertNotNull("Shadow created", shad); |
187 |
assertEquals("Right position", 11, shad.getAttribute("position")); |
195 |
assertEquals("Right position", 11, shad.getAttribute("position")); |
188 |
assertEquals("Proper link", fo.getPath(), shad.getAttribute("originalFile")); |
196 |
assertEquals("Proper link", fo.getPath(), shad.getAttribute("originalFile")); |
|
|
197 |
FileObject sep = FileUtil.getConfigFile( |
198 |
"Muk/luk/my-test-AlwaysByMethod-separatorBefore.instance" |
199 |
); |
200 |
assertNotNull("Separator generated", sep); |
201 |
assertEquals("Position ten", 10, sep.getAttribute("position")); |
202 |
Object instSep = sep.getAttribute("instanceCreate"); |
203 |
assertTrue("Right instance " + instSep, instSep instanceof JSeparator); |
189 |
} |
204 |
} |
190 |
|
205 |
|
191 |
} |
206 |
} |
Lines 714-717
Link Here
|
714 |
assertEquals(null, fo.getAttribute("position")); |
729 |
assertEquals(null, fo.getAttribute("position")); |
715 |
} |
730 |
} |
716 |
|
731 |
|
|
|
732 |
public void testSeparatorBeforeIsBefore() throws IOException { |
733 |
clearWorkDir(); |
734 |
AnnotationProcessorTestUtils.makeSource(getWorkDir(), "test.A", |
735 |
"import org.openide.awt.ActionRegistration;\n" + |
736 |
"import org.openide.awt.ActionReference;\n" + |
737 |
"import org.openide.awt.ActionID;\n" + |
738 |
"import org.openide.util.actions.Presenter;\n" + |
739 |
"import java.awt.event.*;\n" + |
740 |
"import java.util.List;\n" + |
741 |
"import javax.swing.*;\n" + |
742 |
"@ActionID(category=\"Tools\",id=\"my.action\")" + |
743 |
"@ActionRegistration(displayName=\"AAA\", key=\"K\") " + |
744 |
"@ActionReference(path=\"manka\", position=11, separatorBefore=13)" + |
745 |
"public class A implements ActionListener {\n" + |
746 |
" public void actionPerformed(ActionEvent e) {}" + |
747 |
"}\n" |
748 |
); |
749 |
ByteArrayOutputStream os = new ByteArrayOutputStream(); |
750 |
boolean r = AnnotationProcessorTestUtils.runJavac(getWorkDir(), null, getWorkDir(), null, os); |
751 |
assertFalse("Compilation has to fail:\n" + os, r); |
752 |
} |
753 |
|
754 |
public void testSeparatorAfterIsAfter() throws IOException { |
755 |
clearWorkDir(); |
756 |
AnnotationProcessorTestUtils.makeSource(getWorkDir(), "test.A", |
757 |
"import org.openide.awt.ActionRegistration;\n" + |
758 |
"import org.openide.awt.ActionReference;\n" + |
759 |
"import org.openide.awt.ActionID;\n" + |
760 |
"import org.openide.util.actions.Presenter;\n" + |
761 |
"import java.awt.event.*;\n" + |
762 |
"import java.util.List;\n" + |
763 |
"import javax.swing.*;\n" + |
764 |
"@ActionID(category=\"Tools\",id=\"my.action\")" + |
765 |
"@ActionRegistration(displayName=\"AAA\", key=\"K\") " + |
766 |
"@ActionReference(path=\"manka\", position=11, separatorAfter=7)" + |
767 |
"public class A implements ActionListener {\n" + |
768 |
" public void actionPerformed(ActionEvent e) {}" + |
769 |
"}\n" |
770 |
); |
771 |
ByteArrayOutputStream os = new ByteArrayOutputStream(); |
772 |
boolean r = AnnotationProcessorTestUtils.runJavac(getWorkDir(), null, getWorkDir(), null, os); |
773 |
assertFalse("Compilation has to fail:\n" + os, r); |
774 |
} |
775 |
|
717 |
} |
776 |
} |