KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > editor > java > JavaKit


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19
20 package org.netbeans.modules.editor.java;
21
22 import java.awt.event.ActionEvent JavaDoc;
23 import java.util.ArrayList JavaDoc;
24 import java.util.List JavaDoc;
25 import javax.swing.*;
26 import javax.swing.text.*;
27 import javax.swing.text.BadLocationException JavaDoc;
28 import org.netbeans.editor.*;
29 import org.netbeans.editor.Utilities;
30 import org.netbeans.editor.ext.*;
31 import org.netbeans.editor.ext.java.*;
32 import org.netbeans.api.editor.fold.FoldHierarchy;
33 import org.netbeans.api.editor.fold.FoldUtilities;
34 import org.netbeans.api.java.queries.SourceLevelQuery;
35 import org.netbeans.editor.ext.ExtKit.CommentAction;
36 import org.netbeans.editor.ext.ExtKit.PrefixMakerAction;
37 import org.netbeans.editor.ext.ExtKit.UncommentAction;
38 import org.netbeans.lib.editor.codetemplates.api.CodeTemplateManager;
39 import org.netbeans.modules.editor.NbEditorKit;
40 import org.netbeans.modules.editor.NbEditorUtilities;
41 import org.netbeans.modules.java.editor.codegen.GenerateCodeAction;
42 import org.netbeans.modules.java.editor.imports.FastImportAction;
43 import org.netbeans.modules.java.editor.imports.JavaFixAllImports;
44 import org.netbeans.modules.java.editor.overridden.GoToSuperTypeAction;
45 import org.netbeans.modules.java.editor.rename.InstantRenameAction;
46 import org.openide.filesystems.FileObject;
47 import org.openide.loaders.DataObject;
48 import org.openide.awt.Mnemonics;
49 import org.openide.util.*;
50
51 /**
52 * Java editor kit with appropriate document
53 *
54 * @author Miloslav Metelka
55 * @version 1.00
56 */

57
58 public class JavaKit extends NbEditorKit {
59
60     public static final String JavaDoc JAVA_MIME_TYPE = "text/x-java"; // NOI18N
61

62     private static final String JavaDoc[] getSetIsPrefixes = new String JavaDoc[] {
63                 "get", "set", "is" // NOI18N
64
};
65
66     /** Switch first letter of word to capital and insert 'get'
67     * at word begining.
68     */

69     public static final String JavaDoc makeGetterAction = "make-getter"; // NOI18N
70

71     /** Switch first letter of word to capital and insert 'set'
72     * at word begining.
73     */

74     public static final String JavaDoc makeSetterAction = "make-setter"; // NOI18N
75

76     /** Switch first letter of word to capital and insert 'is'
77     * at word begining.
78     */

79     public static final String JavaDoc makeIsAction = "make-is"; // NOI18N
80

81     /** Add the watch depending on the context under the caret */
82     public static final String JavaDoc addWatchAction = "add-watch"; // NOI18N
83

84     /** Toggle the breakpoint of the current line */
85     public static final String JavaDoc toggleBreakpointAction = "toggle-breakpoint"; // NOI18N
86

87     /** Debug source and line number */
88     public static final String JavaDoc abbrevDebugLineAction = "abbrev-debug-line"; // NOI18N
89

90     /** Menu item for adding all necessary imports in a file */
91     public static final String JavaDoc fixImportsAction = "fix-imports"; // NOI18N
92

93     /** Open dialog for choosing the import statement to be added */
94     public static final String JavaDoc fastImportAction = "fast-import"; // NOI18N
95

96     /** Opens Go To Class dialog */
97     //public static final String gotoClassAction = "goto-class"; //NOI18N
98

99     public static final String JavaDoc tryCatchAction = "try-catch"; // NOI18N
100

101     public static final String JavaDoc javaDocShowAction = "javadoc-show-action"; // NOI18N
102

103     public static final String JavaDoc expandAllJavadocFolds = "expand-all-javadoc-folds"; //NOI18N
104

105     public static final String JavaDoc collapseAllJavadocFolds = "collapse-all-javadoc-folds"; //NOI18N
106

107     public static final String JavaDoc expandAllCodeBlockFolds = "expand-all-code-block-folds"; //NOI18N
108

109     public static final String JavaDoc collapseAllCodeBlockFolds = "collapse-all-code-block-folds"; //NOI18N
110

111     public static final String JavaDoc selectNextElementAction = "select-element-next"; //NOI18N
112

113     public static final String JavaDoc selectPreviousElementAction = "select-element-previous"; //NOI18N
114

115     static final long serialVersionUID =-5445829962533684922L;
116     
117
118     public JavaKit(){
119         org.netbeans.modules.java.editor.JavaEditorModule.init();
120     }
121     
122     public String JavaDoc getContentType() {
123         return JAVA_MIME_TYPE;
124     }
125
126     /** Create new instance of syntax coloring scanner
127     * @param doc document to operate on. It can be null in the cases the syntax
128     * creation is not related to the particular document
129     */

130     public Syntax createSyntax(Document doc) {
131         return new JavaSyntax(getSourceLevel((BaseDocument)doc));
132     }
133
134     public Completion createCompletion(ExtEditorUI extEditorUI) {
135         return null;
136     }
137
138     public CompletionJavaDoc createCompletionJavaDoc(ExtEditorUI extEditorUI) {
139         return null;
140     }
141
142     @Override JavaDoc
143     public Document createDefaultDocument() {
144         Document doc = new JavaDocument(this.getClass());
145         Object JavaDoc mimeType = doc.getProperty("mimeType"); //NOI18N
146
if (mimeType == null){
147             doc.putProperty("mimeType", getContentType()); //NOI18N
148
}
149         return doc;
150     }
151     
152     public String JavaDoc getSourceLevel(BaseDocument doc) {
153         DataObject dob = NbEditorUtilities.getDataObject(doc);
154         return dob != null ? SourceLevelQuery.getSourceLevel(dob.getPrimaryFile()) : null;
155     }
156
157     /** Create the formatter appropriate for this kit */
158     public Formatter createFormatter() {
159         return new JavaFormatter(this.getClass());
160     }
161
162     protected void initDocument(BaseDocument doc) {
163 // doc.addLayer(new JavaDrawLayerFactory.JavaLayer(),
164
// JavaDrawLayerFactory.JAVA_LAYER_VISIBILITY);
165
doc.addDocumentListener(new JavaDrawLayerFactory.LParenWatcher());
166         doc.putProperty(SyntaxUpdateTokens.class,
167               new SyntaxUpdateTokens() {
168                   
169                   private List JavaDoc tokenList = new ArrayList JavaDoc();
170                   
171                   public void syntaxUpdateStart() {
172                       tokenList.clear();
173                   }
174       
175                   public List JavaDoc syntaxUpdateEnd() {
176                       return tokenList;
177                   }
178       
179                   public void syntaxUpdateToken(TokenID id, TokenContextPath contextPath, int offset, int length) {
180                       if (JavaTokenContext.LINE_COMMENT == id) {
181                           tokenList.add(new TokenInfo(id, contextPath, offset, length));
182                       }
183                   }
184               }
185           );
186       
187       //do not ask why, fire bug in the IZ:
188
CodeTemplateManager.get(doc);
189       }
190
191     protected Action[] createActions() {
192         Action[] javaActions = new Action[] {
193                                    new JavaDefaultKeyTypedAction(),
194                                    new PrefixMakerAction(makeGetterAction, "get", getSetIsPrefixes), // NOI18N
195
new PrefixMakerAction(makeSetterAction, "set", getSetIsPrefixes), // NOI18N
196
new PrefixMakerAction(makeIsAction, "is", getSetIsPrefixes), // NOI18N
197
new AbbrevDebugLineAction(),
198                                    new CommentAction("//"), // NOI18N
199
new UncommentAction("//"), // NOI18N
200
new JavaGenerateGoToPopupAction(),
201                    new JavaInsertBreakAction(),
202                    new JavaDeleteCharAction(deletePrevCharAction, false),
203                                    new ExpandAllJavadocFolds(),
204                                    new CollapseAllJavadocFolds(),
205                                    new ExpandAllCodeBlockFolds(),
206                                    new CollapseAllCodeBlockFolds(),
207                                    new JavaGenerateFoldPopupAction(),
208                                    new JavaGoToDeclarationAction(),
209                                    new JavaGoToSourceAction(),
210                    new InstantRenameAction(),
211                                    new JavaFixImports(),
212                                    new GenerateCodeAction(),
213                                    new SelectCodeElementAction(selectNextElementAction, true),
214                                    new SelectCodeElementAction(selectPreviousElementAction, false),
215                                    new FastImportAction(),
216                                    new GoToSuperTypeAction(),
217                                };
218                                
219         return TextAction.augmentList(super.createActions(), javaActions);
220     }
221
222     public static class JavaDefaultKeyTypedAction extends ExtDefaultKeyTypedAction {
223
224         protected void insertString(BaseDocument doc, int dotPos,
225                                     Caret caret, String JavaDoc str,
226                                     boolean overwrite) throws BadLocationException JavaDoc {
227             char insertedChar = str.charAt(0);
228             if (insertedChar == '\"' || insertedChar == '\''){
229                 boolean inserted = BracketCompletion.completeQuote(doc, dotPos, caret, insertedChar);
230                 if (inserted){
231                     caret.setDot(dotPos+1);
232                 }else{
233                     super.insertString(doc, dotPos, caret, str, overwrite);
234                     
235                 }
236             } else {
237                 super.insertString(doc, dotPos, caret, str, overwrite);
238                 BracketCompletion.charInserted(doc, dotPos, caret, insertedChar);
239             }
240         }
241         
242         protected void replaceSelection(JTextComponent target,
243                 int dotPos,
244                 Caret caret,
245                 String JavaDoc str,
246                 boolean overwrite)
247                 throws BadLocationException JavaDoc {
248             char insertedChar = str.charAt(0);
249             Document doc = target.getDocument();
250             if (insertedChar == '\"' || insertedChar == '\''){
251                 if (doc != null) {
252                     try {
253                         boolean inserted = false;
254                         int p0 = Math.min(caret.getDot(), caret.getMark());
255                         int p1 = Math.max(caret.getDot(), caret.getMark());
256                         if (p0 != p1) {
257                             doc.remove(p0, p1 - p0);
258                         }
259                         int caretPosition = caret.getDot();
260                         if (doc instanceof BaseDocument){
261                             inserted = BracketCompletion.completeQuote(
262                                     (BaseDocument)doc,
263                                     caretPosition,
264                                     caret, insertedChar);
265                         }
266                         if (inserted){
267                             caret.setDot(caretPosition+1);
268                         } else {
269                             if (str != null && str.length() > 0) {
270                                 doc.insertString(p0, str, null);
271                             }
272                         }
273                     } catch (BadLocationException JavaDoc e) {
274                         e.printStackTrace();
275                     }
276                 }
277             } else {
278                 super.replaceSelection(target, dotPos, caret, str, overwrite);
279                 if (doc instanceof BaseDocument){
280                     BracketCompletion.charInserted((BaseDocument)doc, caret.getDot()-1, caret, insertedChar);
281                 }
282             }
283         }
284     }
285
286
287     public static class JavaGenerateGoToPopupAction extends NbGenerateGoToPopupAction {
288
289         public void actionPerformed(ActionEvent JavaDoc evt, JTextComponent target) {
290         }
291
292         private void addAcceleretors(Action a, JMenuItem item, JTextComponent target){
293             // Try to get the accelerator
294
Keymap km = target.getKeymap();
295             if (km != null) {
296                 
297                 KeyStroke[] keys = km.getKeyStrokesForAction(a);
298                 if (keys != null && keys.length > 0) {
299                     item.setAccelerator(keys[0]);
300                 }else if (a!=null){
301                     KeyStroke ks = (KeyStroke)a.getValue(Action.ACCELERATOR_KEY);
302                     if (ks!=null) {
303                         item.setAccelerator(ks);
304                     }
305                 }
306             }
307         }
308         
309         private void addAction(JTextComponent target, JMenu menu, Action a){
310             if (a != null) {
311                 String JavaDoc actionName = (String JavaDoc) a.getValue(Action.NAME);
312                 JMenuItem item = null;
313                 if (a instanceof BaseAction) {
314                     item = ((BaseAction)a).getPopupMenuItem(target);
315                 }
316                 if (item == null) {
317                     // gets trimmed text that doesn' contain "go to"
318
String JavaDoc itemText = (String JavaDoc)a.getValue(ExtKit.TRIMMED_TEXT);
319                     if (itemText == null){
320                         itemText = getItemText(target, actionName, a);
321                     }
322                     if (itemText != null) {
323                         item = new JMenuItem(itemText);
324                         Mnemonics.setLocalizedText(item, itemText);
325                         item.addActionListener(a);
326                         addAcceleretors(a, item, target);
327                         item.setEnabled(a.isEnabled());
328                         Object JavaDoc helpID = a.getValue ("helpID"); // NOI18N
329
if (helpID != null && (helpID instanceof String JavaDoc))
330                             item.putClientProperty ("HelpID", helpID); // NOI18N
331
}else{
332                         if (ExtKit.gotoSourceAction.equals(actionName)){
333                             item = new JMenuItem(NbBundle.getBundle(JavaKit.class).getString("goto_source_open_source_not_formatted")); //NOI18N
334
addAcceleretors(a, item, target);
335                             item.setEnabled(false);
336                         }
337                     }
338                 }
339
340                 if (item != null) {
341                     menu.add(item);
342                 }
343
344             }
345         }
346         
347         protected void addAction(JTextComponent target, JMenu menu,
348         String JavaDoc actionName) {
349             BaseKit kit = Utilities.getKit(target);
350             if (kit == null) return;
351             Action a = kit.getActionByName(actionName);
352             if (a!=null){
353                 addAction(target, menu, a);
354             } else { // action-name is null, add the separator
355
menu.addSeparator();
356             }
357         }
358         
359         protected String JavaDoc getItemText(JTextComponent target, String JavaDoc actionName, Action a) {
360             String JavaDoc itemText;
361             if (a instanceof BaseAction) {
362                 itemText = ((BaseAction)a).getPopupMenuText(target);
363             } else {
364                 itemText = actionName;
365             }
366             return itemText;
367         }
368         
369         public JMenuItem getPopupMenuItem(final JTextComponent target) {
370             String JavaDoc menuText = NbBundle.getBundle(JavaKit.class).getString("generate-goto-popup"); //NOI18N
371
JMenu jm = new JMenu(menuText);
372             addAction(target, jm, ExtKit.gotoSourceAction);
373             addAction(target, jm, ExtKit.gotoDeclarationAction);
374             addAction(target, jm, gotoSuperImplementationAction);
375             addAction(target, jm, ExtKit.gotoAction);
376             return jm;
377         }
378     
379     }
380     
381     
382     public static class AbbrevDebugLineAction extends BaseAction {
383
384         public AbbrevDebugLineAction() {
385             super(abbrevDebugLineAction);
386         }
387
388         public void actionPerformed(ActionEvent JavaDoc evt, JTextComponent target) {
389             if (target != null) {
390                 if (!target.isEditable() || !target.isEnabled()) {
391                     target.getToolkit().beep();
392                     return;
393                 }
394                 BaseDocument doc = (BaseDocument)target.getDocument();
395                 StringBuffer JavaDoc sb = new StringBuffer JavaDoc("System.out.println(\""); // NOI18N
396
String JavaDoc title = (String JavaDoc)doc.getProperty(Document.TitleProperty);
397                 if (title != null) {
398                     sb.append(title);
399                     sb.append(':');
400                 }
401                 try {
402                     sb.append(Utilities.getLineOffset(doc, target.getCaret().getDot()) + 1);
403                 } catch (BadLocationException JavaDoc e) {
404                 }
405                 sb.append(' ');
406
407                 BaseKit kit = Utilities.getKit(target);
408                 if (kit == null) return;
409                 Action a = kit.getActionByName(BaseKit.insertContentAction);
410                 if (a != null) {
411                     Utilities.performAction(
412                         a,
413                         new ActionEvent JavaDoc(target, ActionEvent.ACTION_PERFORMED, sb.toString()),
414                         target
415                     );
416                 }
417             }
418         }
419
420     }
421     
422
423     public static class JavaInsertBreakAction extends InsertBreakAction {
424         
425         static final long serialVersionUID = -1506173310438326380L;
426         
427         protected Object JavaDoc beforeBreak(JTextComponent target, BaseDocument doc, Caret caret) {
428             int dotPos = caret.getDot();
429             if (BracketCompletion.posWithinString(doc, dotPos)) {
430                 try {
431                     doc.insertString(dotPos, "\" + \"", null); //NOI18N
432
dotPos += 3;
433                     caret.setDot(dotPos);
434                     return new Integer JavaDoc(dotPos);
435                 } catch (BadLocationException JavaDoc ex) {
436                 }
437             } else {
438                 try {
439                     if (BracketCompletion.isAddRightBrace(doc, dotPos)) {
440                         int end = BracketCompletion.getRowOrBlockEnd(doc, dotPos);
441                         doc.insertString(end, "}", null); // NOI18N
442
doc.getFormatter().indentNewLine(doc, end);
443                         caret.setDot(dotPos);
444                         return Boolean.TRUE;
445                     }
446                 } catch (BadLocationException JavaDoc ex) {
447                 }
448             }
449             return null;
450         }
451         
452         protected void afterBreak(JTextComponent target, BaseDocument doc, Caret caret, Object JavaDoc cookie) {
453             if (cookie != null) {
454                 if (cookie instanceof Integer JavaDoc) {
455                     // integer
456
int nowDotPos = caret.getDot();
457                     caret.setDot(nowDotPos+1);
458                 }
459             }
460         }
461
462   }
463
464
465     public static class JavaDeleteCharAction extends ExtDeleteCharAction {
466         
467         public JavaDeleteCharAction(String JavaDoc nm, boolean nextChar) {
468             super(nm, nextChar);
469         }
470
471         protected void charBackspaced(BaseDocument doc, int dotPos, Caret caret, char ch)
472         throws BadLocationException JavaDoc {
473             BracketCompletion.charBackspaced(doc, dotPos, caret, ch);
474         }
475     }
476     
477     public static class ExpandAllJavadocFolds extends BaseAction{
478         public ExpandAllJavadocFolds(){
479             super(expandAllJavadocFolds);
480             putValue(SHORT_DESCRIPTION, NbBundle.getBundle(JavaKit.class).getString("expand-all-javadoc-folds"));
481             putValue(BaseAction.POPUP_MENU_TEXT, NbBundle.getBundle(JavaKit.class).getString("popup-expand-all-javadoc-folds"));
482         }
483
484         public void actionPerformed(ActionEvent JavaDoc evt, JTextComponent target) {
485             FoldHierarchy hierarchy = FoldHierarchy.get(target);
486             // Hierarchy locking done in the utility method
487
FoldUtilities.expand(hierarchy, JavaFoldManager.JAVADOC_FOLD_TYPE);
488         }
489     }
490     
491     public static class CollapseAllJavadocFolds extends BaseAction{
492         public CollapseAllJavadocFolds(){
493             super(collapseAllJavadocFolds);
494             putValue(SHORT_DESCRIPTION, NbBundle.getBundle(JavaKit.class).getString("collapse-all-javadoc-folds"));
495             putValue(BaseAction.POPUP_MENU_TEXT, NbBundle.getBundle(JavaKit.class).getString("popup-collapse-all-javadoc-folds"));
496         }
497
498         public void actionPerformed(ActionEvent JavaDoc evt, JTextComponent target) {
499             FoldHierarchy hierarchy = FoldHierarchy.get(target);
500             // Hierarchy locking done in the utility method
501
FoldUtilities.collapse(hierarchy, JavaFoldManager.JAVADOC_FOLD_TYPE);
502         }
503     }
504     
505     public static class ExpandAllCodeBlockFolds extends BaseAction{
506         public ExpandAllCodeBlockFolds(){
507             super(expandAllCodeBlockFolds);
508             putValue(SHORT_DESCRIPTION, NbBundle.getBundle(JavaKit.class).getString("expand-all-code-block-folds"));
509             putValue(BaseAction.POPUP_MENU_TEXT, NbBundle.getBundle(JavaKit.class).getString("popup-expand-all-code-block-folds"));
510         }
511
512         public void actionPerformed(ActionEvent JavaDoc evt, JTextComponent target) {
513             FoldHierarchy hierarchy = FoldHierarchy.get(target);
514             // Hierarchy locking done in the utility method
515
List JavaDoc types = new ArrayList JavaDoc();
516             types.add(JavaFoldManager.CODE_BLOCK_FOLD_TYPE);
517             types.add(JavaFoldManager.IMPORTS_FOLD_TYPE);
518             FoldUtilities.expand(hierarchy, types);
519         }
520     }
521     
522     public static class CollapseAllCodeBlockFolds extends BaseAction{
523         public CollapseAllCodeBlockFolds(){
524             super(collapseAllCodeBlockFolds);
525             putValue(SHORT_DESCRIPTION, NbBundle.getBundle(JavaKit.class).getString("collapse-all-code-block-folds"));
526             putValue(BaseAction.POPUP_MENU_TEXT, NbBundle.getBundle(JavaKit.class).getString("popup-collapse-all-code-block-folds"));
527         }
528         
529         public void actionPerformed(ActionEvent JavaDoc evt, JTextComponent target) {
530             FoldHierarchy hierarchy = FoldHierarchy.get(target);
531             // Hierarchy locking done in the utility method
532
List JavaDoc types = new ArrayList JavaDoc();
533             types.add(JavaFoldManager.CODE_BLOCK_FOLD_TYPE);
534             types.add(JavaFoldManager.IMPORTS_FOLD_TYPE);
535             FoldUtilities.collapse(hierarchy, types);
536         }
537     }
538     
539     public static class JavaGenerateFoldPopupAction extends GenerateFoldPopupAction{
540         
541         protected void addAdditionalItems(JTextComponent target, JMenu menu){
542             addAction(target, menu, collapseAllJavadocFolds);
543             addAction(target, menu, expandAllJavadocFolds);
544             setAddSeparatorBeforeNextAction(true);
545             addAction(target, menu, collapseAllCodeBlockFolds);
546             addAction(target, menu, expandAllCodeBlockFolds);
547         }
548         
549     }
550     
551     private static class JavaGoToDeclarationAction extends GotoDeclarationAction {
552         public @Override JavaDoc boolean gotoDeclaration(JTextComponent target) {
553             GoToSupport.goTo((BaseDocument) target.getDocument(), target.getCaretPosition(), false);
554             return true;
555         }
556     }
557     
558     private static class JavaGoToSourceAction extends BaseAction {
559
560         static final long serialVersionUID =-6440495023918097760L;
561
562         public JavaGoToSourceAction() {
563             super(gotoSourceAction,
564                   ABBREV_RESET | MAGIC_POSITION_RESET | UNDO_MERGE_RESET
565                   | SAVE_POSITION
566                  );
567             putValue(TRIMMED_TEXT, LocaleSupport.getString("goto-source-trimmed")); //NOI18N
568
}
569
570         public void actionPerformed(ActionEvent JavaDoc evt, JTextComponent target) {
571             if (target != null) {
572                 GoToSupport.goTo((BaseDocument) target.getDocument(), target.getCaretPosition(), true);
573             }
574         }
575         
576         public String JavaDoc getPopupMenuText(JTextComponent target) {
577             return NbBundle.getBundle(JavaKit.class).getString("goto_source_open_source_not_formatted"); //NOI18N
578
}
579         
580         protected Class JavaDoc getShortDescriptionBundleClass() {
581             return BaseKit.class;
582         }
583     }
584     
585     private static class JavaFixImports extends BaseAction {
586
587         public JavaFixImports() {
588             super(fixImportsAction,
589                   ABBREV_RESET | MAGIC_POSITION_RESET | UNDO_MERGE_RESET
590                   | SAVE_POSITION
591                  );
592             putValue(TRIMMED_TEXT, NbBundle.getBundle(JavaKit.class).getString("fix-imports-trimmed"));
593             putValue(SHORT_DESCRIPTION, NbBundle.getBundle(JavaKit.class).getString("desc-fix-imports")); // NOI18N
594
putValue(POPUP_MENU_TEXT, NbBundle.getBundle(JavaKit.class).getString("popup-fix-imports")); // NOI18N
595
}
596
597         public void actionPerformed(ActionEvent JavaDoc evt, JTextComponent target) {
598             if (target != null) {
599                 Document doc = target.getDocument();
600                 FileObject fo = ((DataObject) doc.getProperty(Document.StreamDescriptionProperty)).getPrimaryFile();
601                 
602                 JavaFixAllImports.getDefault().fixAllImports(fo);
603             }
604         }
605     }
606     
607 }
608
Popular Tags