0
Extending the Java Editor
1. Project templates
2. File templates
3. Editor actions
4. File actions
5. Code generators
6. E...
Module Development Tools
Project Templates
Project Templates
@TemplateRegistration(
folder = "Project/Samples/Standard",
displayName = "#MyApp_displayName",
descript...
File Templates
File Templates

@TemplateRegistration(
folder = "Other",
content = "AbcTemplate.abc")
package org.nb.alpha.deps;
import or...
Editor Actions
Editor Actions
@ActionID(
category = "Tools",
id = "org.nb.alpha.deps.SomeAction"
)
@ActionRegistration(
displayName = "#C...
File Actions
File Actions
@ActionID(
category = "Tools",
id = "org.nb.alpha.deps.AnotherAction"
)
@ActionRegistration(
iconBase = "org/...
Code Generators
Code Generators
public class ActionPerformedGenerator implements CodeGenerator {
JTextComponent textComp;
private ActionPe...
Error Annotations
Error Annotations
<folder name="Editors">
<folder name="AnnotationTypes">
<file name="org-netbeans-modules-yourfirstannota...
Upcoming SlideShare
Loading in...5
×

Ext java-editor

568

Published on

Published in: Technology, Education
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
568
On Slideshare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
9
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Transcript of "Ext java-editor"

  1. 1. Extending the Java Editor 1. Project templates 2. File templates 3. Editor actions 4. File actions 5. Code generators 6. Error annotations
  2. 2. Module Development Tools
  3. 3. Project Templates
  4. 4. Project Templates @TemplateRegistration( folder = "Project/Samples/Standard", displayName = "#MyApp_displayName", description = "MyAppDescription.html", iconBase = "org/nb/alpha/deps/MyApp.png", content = "MyAppProject.zip") 1. public class MyAppWizardIterator implements WizardDescriptor.InstantiatingIterator {
  5. 5. File Templates
  6. 6. File Templates @TemplateRegistration( folder = "Other", content = "AbcTemplate.abc") package org.nb.alpha.deps; import org.netbeans.api.templates.TemplateRegistration;
  7. 7. Editor Actions
  8. 8. Editor Actions @ActionID( category = "Tools", id = "org.nb.alpha.deps.SomeAction" ) @ActionRegistration( displayName = "#CTL_SomeAction" ) @ActionReferences({ @ActionReference(path = "Menu/File", position = 0), @ActionReference(path = "Editors/text/x-java/Popup", position = 400) }) @Messages("CTL_SomeAction=Some") public final class SomeAction implements ActionListener { private final DataObject context; public SomeAction(DataObject context) { this.context = context; } @Override public void actionPerformed(ActionEvent ev) { // TODO use context } }
  9. 9. File Actions
  10. 10. File Actions @ActionID( category = "Tools", id = "org.nb.alpha.deps.AnotherAction" ) @ActionRegistration( iconBase = "org/nb/alpha/deps/icon.png", displayName = "#CTL_AnotherAction" ) @ActionReferences({ @ActionReference(path = "Menu/File", position = 0), @ActionReference(path = "Loaders/text/x-java/Actions", position = 0) }) @Messages("CTL_AnotherAction=Another") public final class AnotherAction implements ActionListener { private final DataObject context; public AnotherAction(DataObject context) { this.context = context; } @Override public void actionPerformed(ActionEvent ev) { // TODO use context } }
  11. 11. Code Generators
  12. 12. Code Generators public class ActionPerformedGenerator implements CodeGenerator { JTextComponent textComp; private ActionPerformedGenerator(Lookup context) { textComp = context.lookup(JTextComponent.class); } @MimeRegistration(mimeType = "text/x-java", service = CodeGenerator.Factory.class) public static class Factory implements CodeGenerator.Factory { public List<? extends CodeGenerator> create(Lookup context) { return Collections.singletonList(new ActionPerformedGenerator(context)); } } public String getDisplayName() { return "Action Performed Generator"; } public void invoke() { //do something with the text component... } }
  13. 13. Error Annotations
  14. 14. Error Annotations <folder name="Editors"> <folder name="AnnotationTypes"> <file name="org-netbeans-modules-yourfirstannotation.xml" url="HTMLAnnotation.xml"> </file> </folder> </folder> <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE type PUBLIC "-//NetBeans//DTD annotation type 1.1//EN" "http://www.netbeans.org/dtds/annotation-type-1_1.dtd"> <type name="org-netbeans-modules-yourfirstannotation" description_key="yourfirstannotation" localizing_bundle="org.netbeans.modules.yourfirstannotation.Bundle" visible="true" glyph="nbresloc:/org/netbeans/modules/java/resources/error-glyph.gif" highlight="#66CC33" type="line" browseable="false" severity="ok" />
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×