Lines 1-561
Link Here
|
1 |
/* |
|
|
2 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. |
3 |
* |
4 |
* Copyright 1997-2009 Sun Microsystems, Inc. All rights reserved. |
5 |
* |
6 |
* The contents of this file are subject to the terms of either the GNU |
7 |
* General Public License Version 2 only ("GPL") or the Common |
8 |
* Development and Distribution License("CDDL") (collectively, the |
9 |
* "License"). You may not use this file except in compliance with the |
10 |
* License. You can obtain a copy of the License at |
11 |
* http://www.netbeans.org/cddl-gplv2.html |
12 |
* or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the |
13 |
* specific language governing permissions and limitations under the |
14 |
* License. When distributing the software, include this License Header |
15 |
* Notice in each file and include the License file at |
16 |
* nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this |
17 |
* particular file as subject to the "Classpath" exception as provided |
18 |
* by Sun in the GPL Version 2 section of the License file that |
19 |
* accompanied this code. If applicable, add the following below the |
20 |
* License Header, with the fields enclosed by brackets [] replaced by |
21 |
* your own identifying information: |
22 |
* "Portions Copyrighted [year] [name of copyright owner]" |
23 |
* |
24 |
* Contributor(s): |
25 |
* |
26 |
* The Original Software is NetBeans. The Initial Developer of the Original |
27 |
* Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun |
28 |
* Microsystems, Inc. All Rights Reserved. |
29 |
* |
30 |
* If you wish your version of this file to be governed by only the CDDL |
31 |
* or only the GPL Version 2, indicate your decision by adding |
32 |
* "[Contributor] elects to include this software in this distribution |
33 |
* under the [CDDL or GPL Version 2] license." If you do not indicate a |
34 |
* single choice of license, a recipient has the option to distribute |
35 |
* your version of this file under either the CDDL, the GPL Version 2 or |
36 |
* to extend the choice of license to its licensees as provided above. |
37 |
* However, if you add GPL Version 2 code and therefore, elected the GPL |
38 |
* Version 2 license, then the option applies only if the new code is |
39 |
* made subject to such option by the copyright holder. |
40 |
*/ |
41 |
package org.netbeans.modules.csl.core; |
42 |
|
43 |
import java.awt.event.ActionEvent; |
44 |
import java.util.ArrayList; |
45 |
import java.util.List; |
46 |
import javax.swing.Action; |
47 |
import javax.swing.JMenu; |
48 |
import javax.swing.JMenuItem; |
49 |
import javax.swing.KeyStroke; |
50 |
import javax.swing.text.BadLocationException; |
51 |
import javax.swing.text.Caret; |
52 |
import javax.swing.text.Document; |
53 |
import javax.swing.text.JTextComponent; |
54 |
import javax.swing.text.Keymap; |
55 |
import javax.swing.text.TextAction; |
56 |
import org.netbeans.api.editor.fold.FoldHierarchy; |
57 |
import org.netbeans.api.editor.fold.FoldUtilities; |
58 |
import org.netbeans.modules.csl.api.KeystrokeHandler; |
59 |
import org.netbeans.modules.csl.api.GsfLanguage; |
60 |
import org.netbeans.modules.csl.api.OffsetRange; |
61 |
import org.netbeans.editor.BaseAction; |
62 |
import org.netbeans.editor.BaseDocument; |
63 |
import org.netbeans.editor.BaseKit; |
64 |
import org.netbeans.editor.BaseKit.InsertBreakAction; |
65 |
import org.netbeans.editor.SyntaxSupport; |
66 |
import org.netbeans.editor.Utilities; |
67 |
import org.netbeans.editor.ext.ExtKit; |
68 |
import org.netbeans.editor.ext.ExtKit.ToggleCommentAction; |
69 |
import org.netbeans.editor.ext.ExtSyntaxSupport; |
70 |
import org.netbeans.lib.editor.codetemplates.api.CodeTemplateManager; |
71 |
import org.netbeans.modules.csl.spi.CommentHandler; |
72 |
import org.netbeans.modules.editor.NbEditorKit; |
73 |
import org.netbeans.modules.csl.editor.InstantRenameAction; |
74 |
import org.netbeans.modules.csl.editor.ToggleBlockCommentAction; |
75 |
import org.netbeans.modules.csl.editor.fold.GsfFoldManager; |
76 |
import org.netbeans.modules.csl.editor.hyperlink.GoToSupport; |
77 |
import org.netbeans.modules.csl.editor.semantic.GoToMarkOccurrencesAction; |
78 |
import org.netbeans.modules.csl.spi.DefaultLanguageConfig; |
79 |
import org.openide.awt.Mnemonics; |
80 |
import org.openide.util.Exceptions; |
81 |
import org.openide.util.NbBundle; |
82 |
|
83 |
|
84 |
/** |
85 |
* This class represents a generic Editor Kit which is shared by a number of different |
86 |
* languages. The EditorKit is an innerclass, because its superclass (BaseKit) calls |
87 |
* getContentType() as part of its constructor. Our getContentType implementation |
88 |
* relies on accessing one of the fields passed in to our constructor; but when the |
89 |
* super constructor is calling getContentType(), our own constructor has not yet been |
90 |
* called. This is worked around by having an outer class which holds the field |
91 |
* we need at constructor time (langauge). |
92 |
* |
93 |
* @author Tor Norbye |
94 |
* @author Jan Jancura |
95 |
*/ |
96 |
public class GsfEditorKitFactory { |
97 |
public static final String expandAllCodeBlockFolds = "expand-all-code-block-folds"; //NOI18N |
98 |
public static final String collapseAllCodeBlockFolds = "collapse-all-code-block-folds"; //NOI18N |
99 |
|
100 |
Language language; |
101 |
String mimeType; |
102 |
|
103 |
public GsfEditorKitFactory(Language language) { |
104 |
assert language != null; |
105 |
this.language = language; |
106 |
this.mimeType = language.getMimeType(); |
107 |
} |
108 |
|
109 |
/** |
110 |
* Return the actual kit. This is necessary because NbEditorKit's constructor |
111 |
* winds up calling getContentType(), before we've actually had a chance to |
112 |
* construct our own editor kit (where getContentType() depends on construction |
113 |
* of the object. The trick is to use an outer class, construct that first, and |
114 |
* |
115 |
*/ |
116 |
public GsfEditorKit kit() { |
117 |
return new GsfEditorKit(); |
118 |
} |
119 |
|
120 |
public static Action findAction(Action [] actions, String name) { |
121 |
for(Action a : actions) { |
122 |
Object nameObj = a.getValue(Action.NAME); |
123 |
if (nameObj instanceof String && name.equals(nameObj)) { |
124 |
return a; |
125 |
} |
126 |
} |
127 |
return null; |
128 |
} |
129 |
|
130 |
static KeystrokeHandler getBracketCompletion(Document doc, int offset) { |
131 |
BaseDocument baseDoc = (BaseDocument)doc; |
132 |
List<Language> list = LanguageRegistry.getInstance().getEmbeddedLanguages(baseDoc, offset); |
133 |
for (Language l : list) { |
134 |
if (l.getBracketCompletion() != null) { |
135 |
return l.getBracketCompletion(); |
136 |
} |
137 |
} |
138 |
|
139 |
return null; |
140 |
} |
141 |
|
142 |
/** |
143 |
* Returns true if bracket completion is enabled in options. |
144 |
*/ |
145 |
private static boolean completionSettingEnabled() { |
146 |
//return ((Boolean)Settings.getValue(GsfEditorKit.class, JavaSettingsNames.PAIR_CHARACTERS_COMPLETION)).booleanValue(); |
147 |
return true; |
148 |
} |
149 |
|
150 |
public class GsfEditorKit extends NbEditorKit { |
151 |
|
152 |
public GsfEditorKit() { |
153 |
} |
154 |
|
155 |
@Override |
156 |
public String getContentType() { |
157 |
return language.getMimeType(); |
158 |
} |
159 |
|
160 |
@Override |
161 |
public Document createDefaultDocument() { |
162 |
Document doc = new GsfDocument(language); |
163 |
doc.putProperty("mimeType", getContentType()); //NOI18N |
164 |
return doc; |
165 |
} |
166 |
|
167 |
@Override |
168 |
public SyntaxSupport createSyntaxSupport(final BaseDocument doc) { |
169 |
return new ExtSyntaxSupport(doc) { |
170 |
@Override |
171 |
public int[] findMatchingBlock(int offset, boolean simpleSearch) |
172 |
throws BadLocationException { |
173 |
// Do parenthesis matching, if applicable |
174 |
KeystrokeHandler bracketCompletion = getBracketCompletion(doc, offset); |
175 |
if (bracketCompletion != null) { |
176 |
OffsetRange range = bracketCompletion.findMatching(getDocument(), offset/*, simpleSearch*/); |
177 |
if (range == OffsetRange.NONE) { |
178 |
return null; |
179 |
} else { |
180 |
return new int[] { range.getStart(), range.getEnd() }; |
181 |
} |
182 |
} |
183 |
|
184 |
return null; |
185 |
} |
186 |
}; |
187 |
} |
188 |
|
189 |
@Override |
190 |
protected void initDocument(BaseDocument doc) { |
191 |
// XXX This appears in JavaKit, not sure why, but doing it just in case. |
192 |
//do not ask why, fire bug in the IZ: |
193 |
CodeTemplateManager.get(doc); |
194 |
} |
195 |
|
196 |
@Override |
197 |
public Object clone() { |
198 |
return new GsfEditorKit(); |
199 |
} |
200 |
|
201 |
@Override |
202 |
protected Action[] createActions() { |
203 |
Action[] superActions = super.createActions(); |
204 |
GsfLanguage gsfLanguage = language.getGsfLanguage(); |
205 |
|
206 |
ArrayList<Action> actions = new ArrayList<Action>(30); |
207 |
|
208 |
actions.add(new GsfDefaultKeyTypedAction()); |
209 |
actions.add(new GsfInsertBreakAction()); |
210 |
actions.add(new GsfDeleteCharAction(deletePrevCharAction, false)); |
211 |
|
212 |
String lineCommentPrefix = (gsfLanguage != null) ? gsfLanguage.getLineCommentPrefix() : null; |
213 |
if (lineCommentPrefix != null) { |
214 |
actions.add(new CommentAction(lineCommentPrefix)); |
215 |
actions.add(new UncommentAction(lineCommentPrefix)); |
216 |
actions.add(new ToggleCommentAction(lineCommentPrefix)); |
217 |
} |
218 |
|
219 |
if(gsfLanguage instanceof DefaultLanguageConfig) { |
220 |
CommentHandler ch = ((DefaultLanguageConfig)gsfLanguage).getCommentHandler(); |
221 |
if(ch != null) { |
222 |
actions.add(new ToggleBlockCommentAction(ch)); |
223 |
} |
224 |
|
225 |
} |
226 |
|
227 |
actions.add(new InstantRenameAction()); |
228 |
actions.add(new GenericGoToDeclarationAction()); |
229 |
actions.add(new GenericGenerateGoToPopupAction()); |
230 |
actions.add(new SelectCodeElementAction(SelectCodeElementAction.selectNextElementAction, true)); |
231 |
actions.add(new SelectCodeElementAction(SelectCodeElementAction.selectPreviousElementAction, false)); |
232 |
//actions.add(new ExpandAllCodeBlockFolds()); |
233 |
//actions.add(new CollapseAllCodeBlockFolds()); |
234 |
actions.add(new NextCamelCasePosition(findAction(superActions, nextWordAction))); |
235 |
actions.add(new PreviousCamelCasePosition(findAction(superActions, previousWordAction))); |
236 |
actions.add(new SelectNextCamelCasePosition(findAction(superActions, selectionNextWordAction))); |
237 |
actions.add(new SelectPreviousCamelCasePosition(findAction(superActions, selectionPreviousWordAction))); |
238 |
actions.add(new DeleteToNextCamelCasePosition(findAction(superActions, removeNextWordAction))); |
239 |
actions.add(new DeleteToPreviousCamelCasePosition(findAction(superActions, removePreviousWordAction))); |
240 |
|
241 |
if (language.hasOccurrencesFinder()) { |
242 |
actions.add(new GoToMarkOccurrencesAction(false)); |
243 |
actions.add(new GoToMarkOccurrencesAction(true)); |
244 |
} |
245 |
|
246 |
return TextAction.augmentList(superActions, |
247 |
actions.toArray(new Action[actions.size()])); |
248 |
} |
249 |
|
250 |
public class GsfDefaultKeyTypedAction extends ExtDefaultKeyTypedAction { |
251 |
private JTextComponent currentTarget; |
252 |
|
253 |
@Override |
254 |
public void actionPerformed(ActionEvent evt, JTextComponent target) { |
255 |
currentTarget = target; |
256 |
super.actionPerformed(evt, target); |
257 |
currentTarget = null; |
258 |
} |
259 |
|
260 |
@Override |
261 |
protected void insertString(BaseDocument doc, int dotPos, Caret caret, String str, |
262 |
boolean overwrite) throws BadLocationException { |
263 |
if (completionSettingEnabled()) { |
264 |
KeystrokeHandler bracketCompletion = getBracketCompletion(doc, dotPos); |
265 |
|
266 |
if (bracketCompletion != null) { |
267 |
// TODO - check if we're in a comment etc. and if so, do nothing |
268 |
boolean handled = |
269 |
bracketCompletion.beforeCharInserted(doc, dotPos, currentTarget, |
270 |
str.charAt(0)); |
271 |
|
272 |
if (!handled) { |
273 |
super.insertString(doc, dotPos, caret, str, overwrite); |
274 |
handled = bracketCompletion.afterCharInserted(doc, dotPos, currentTarget, |
275 |
str.charAt(0)); |
276 |
} |
277 |
|
278 |
return; |
279 |
} |
280 |
} |
281 |
|
282 |
super.insertString(doc, dotPos, caret, str, overwrite); |
283 |
} |
284 |
|
285 |
@Override |
286 |
protected void replaceSelection(JTextComponent target, int dotPos, Caret caret, |
287 |
String str, boolean overwrite) throws BadLocationException { |
288 |
char insertedChar = str.charAt(0); |
289 |
Document document = target.getDocument(); |
290 |
|
291 |
if (document instanceof BaseDocument) { |
292 |
BaseDocument doc = (BaseDocument)document; |
293 |
|
294 |
if (completionSettingEnabled()) { |
295 |
KeystrokeHandler bracketCompletion = getBracketCompletion(doc, dotPos); |
296 |
|
297 |
if (bracketCompletion != null) { |
298 |
try { |
299 |
int caretPosition = caret.getDot(); |
300 |
|
301 |
boolean handled = |
302 |
bracketCompletion.beforeCharInserted(doc, caretPosition, |
303 |
target, insertedChar); |
304 |
|
305 |
int p0 = Math.min(caret.getDot(), caret.getMark()); |
306 |
int p1 = Math.max(caret.getDot(), caret.getMark()); |
307 |
|
308 |
if (p0 != p1) { |
309 |
doc.remove(p0, p1 - p0); |
310 |
} |
311 |
|
312 |
if (!handled) { |
313 |
if ((str != null) && (str.length() > 0)) { |
314 |
doc.insertString(p0, str, null); |
315 |
} |
316 |
|
317 |
bracketCompletion.afterCharInserted(doc, caret.getDot() - 1, |
318 |
target, insertedChar); |
319 |
} |
320 |
} catch (BadLocationException e) { |
321 |
e.printStackTrace(); |
322 |
} |
323 |
|
324 |
return; |
325 |
} |
326 |
} |
327 |
} |
328 |
|
329 |
super.replaceSelection(target, dotPos, caret, str, overwrite); |
330 |
} |
331 |
} |
332 |
|
333 |
public class GsfInsertBreakAction extends InsertBreakAction { |
334 |
static final long serialVersionUID = -1506173310438326380L; |
335 |
|
336 |
@Override |
337 |
protected Object beforeBreak(JTextComponent target, BaseDocument doc, Caret caret) { |
338 |
if (completionSettingEnabled()) { |
339 |
KeystrokeHandler bracketCompletion = getBracketCompletion(doc, caret.getDot()); |
340 |
|
341 |
if (bracketCompletion != null) { |
342 |
try { |
343 |
int newOffset = bracketCompletion.beforeBreak(doc, caret.getDot(), target); |
344 |
|
345 |
if (newOffset >= 0) { |
346 |
return new Integer(newOffset); |
347 |
} |
348 |
} catch (BadLocationException ble) { |
349 |
Exceptions.printStackTrace(ble); |
350 |
} |
351 |
} |
352 |
} |
353 |
|
354 |
// return Boolean.TRUE; |
355 |
return null; |
356 |
} |
357 |
|
358 |
@Override |
359 |
protected void afterBreak(JTextComponent target, BaseDocument doc, Caret caret, |
360 |
Object cookie) { |
361 |
if (completionSettingEnabled()) { |
362 |
if (cookie != null) { |
363 |
if (cookie instanceof Integer) { |
364 |
// integer |
365 |
int dotPos = ((Integer)cookie).intValue(); |
366 |
if (dotPos != -1) { |
367 |
caret.setDot(dotPos); |
368 |
} else { |
369 |
int nowDotPos = caret.getDot(); |
370 |
caret.setDot(nowDotPos + 1); |
371 |
} |
372 |
} |
373 |
} |
374 |
} |
375 |
} |
376 |
} |
377 |
|
378 |
public class GsfDeleteCharAction extends ExtDeleteCharAction { |
379 |
private JTextComponent currentTarget; |
380 |
|
381 |
public GsfDeleteCharAction(String nm, boolean nextChar) { |
382 |
super(nm, nextChar); |
383 |
} |
384 |
|
385 |
@Override |
386 |
public void actionPerformed(ActionEvent evt, JTextComponent target) { |
387 |
currentTarget = target; |
388 |
super.actionPerformed(evt, target); |
389 |
currentTarget = null; |
390 |
} |
391 |
|
392 |
@Override |
393 |
protected void charBackspaced(BaseDocument doc, int dotPos, Caret caret, char ch) |
394 |
throws BadLocationException { |
395 |
if (completionSettingEnabled()) { |
396 |
KeystrokeHandler bracketCompletion = getBracketCompletion(doc, dotPos); |
397 |
|
398 |
if (bracketCompletion != null) { |
399 |
boolean success = bracketCompletion.charBackspaced(doc, dotPos, currentTarget, ch); |
400 |
return; |
401 |
} |
402 |
} |
403 |
super.charBackspaced(doc, dotPos, caret, ch); |
404 |
} |
405 |
} |
406 |
|
407 |
private class GenericGoToDeclarationAction extends GotoDeclarationAction { |
408 |
@Override |
409 |
public boolean gotoDeclaration(JTextComponent target) { |
410 |
GoToSupport.performGoTo((BaseDocument)target.getDocument(), |
411 |
target.getCaretPosition()); |
412 |
|
413 |
return true; |
414 |
} |
415 |
} |
416 |
|
417 |
private class GenericGenerateGoToPopupAction extends NbGenerateGoToPopupAction { |
418 |
@Override |
419 |
public void actionPerformed(ActionEvent evt, JTextComponent target) { |
420 |
} |
421 |
|
422 |
private void addAcceleretors(Action a, JMenuItem item, JTextComponent target) { |
423 |
// Try to get the accelerator |
424 |
Keymap km = target.getKeymap(); |
425 |
|
426 |
if (km != null) { |
427 |
KeyStroke[] keys = km.getKeyStrokesForAction(a); |
428 |
|
429 |
if ((keys != null) && (keys.length > 0)) { |
430 |
item.setAccelerator(keys[0]); |
431 |
} else if (a != null) { |
432 |
KeyStroke ks = (KeyStroke)a.getValue(Action.ACCELERATOR_KEY); |
433 |
|
434 |
if (ks != null) { |
435 |
item.setAccelerator(ks); |
436 |
} |
437 |
} |
438 |
} |
439 |
} |
440 |
|
441 |
private void addAction(JTextComponent target, JMenu menu, Action a) { |
442 |
if (a != null) { |
443 |
String actionName = (String)a.getValue(Action.NAME); |
444 |
JMenuItem item = null; |
445 |
|
446 |
if (a instanceof BaseAction) { |
447 |
item = ((BaseAction)a).getPopupMenuItem(target); |
448 |
} |
449 |
|
450 |
if (item == null) { |
451 |
// gets trimmed text that doesn' contain "go to" |
452 |
String itemText = (String)a.getValue(ExtKit.TRIMMED_TEXT); |
453 |
|
454 |
if (itemText == null) { |
455 |
itemText = getItemText(target, actionName, a); |
456 |
} |
457 |
|
458 |
if (itemText != null) { |
459 |
item = new JMenuItem(itemText); |
460 |
Mnemonics.setLocalizedText(item, itemText); |
461 |
item.addActionListener(a); |
462 |
addAcceleretors(a, item, target); |
463 |
item.setEnabled(a.isEnabled()); |
464 |
|
465 |
Object helpID = a.getValue("helpID"); // NOI18N |
466 |
|
467 |
if ((helpID != null) && (helpID instanceof String)) { |
468 |
item.putClientProperty("HelpID", helpID); // NOI18N |
469 |
} |
470 |
} else { |
471 |
if (ExtKit.gotoSourceAction.equals(actionName)) { |
472 |
item = new JMenuItem(NbBundle.getBundle(GsfEditorKit.class) |
473 |
.getString("goto_source_open_source_not_formatted")); //NOI18N |
474 |
addAcceleretors(a, item, target); |
475 |
item.setEnabled(false); |
476 |
} |
477 |
} |
478 |
} |
479 |
|
480 |
if (item != null) { |
481 |
menu.add(item); |
482 |
} |
483 |
} |
484 |
} |
485 |
|
486 |
private void addAction(JTextComponent target, JMenu menu, String actionName) { |
487 |
BaseKit kit = Utilities.getKit(target); |
488 |
|
489 |
if (kit == null) { |
490 |
return; |
491 |
} |
492 |
|
493 |
Action a = kit.getActionByName(actionName); |
494 |
|
495 |
if (a != null) { |
496 |
addAction(target, menu, a); |
497 |
} else { // action-name is null, add the separator |
498 |
menu.addSeparator(); |
499 |
} |
500 |
} |
501 |
|
502 |
private String getItemText(JTextComponent target, String actionName, Action a) { |
503 |
String itemText; |
504 |
|
505 |
if (a instanceof BaseAction) { |
506 |
itemText = ((BaseAction)a).getPopupMenuText(target); |
507 |
} else { |
508 |
itemText = actionName; |
509 |
} |
510 |
|
511 |
return itemText; |
512 |
} |
513 |
|
514 |
@Override |
515 |
public JMenuItem getPopupMenuItem(final JTextComponent target) { |
516 |
String menuText = |
517 |
NbBundle.getBundle(GsfEditorKit.class).getString("generate-goto-popup"); //NOI18N |
518 |
JMenu jm = new JMenu(menuText); |
519 |
//addAction(target, jm, ExtKit.gotoSourceAction); |
520 |
addAction(target, jm, ExtKit.gotoDeclarationAction); |
521 |
//addAction(target, jm, gotoSuperImplementationAction); |
522 |
//addAction(target, jm, ExtKit.gotoAction); |
523 |
return jm; |
524 |
} |
525 |
} |
526 |
} |
527 |
|
528 |
public static class ExpandAllCodeBlockFolds extends BaseAction{ |
529 |
public ExpandAllCodeBlockFolds(){ |
530 |
super(expandAllCodeBlockFolds); |
531 |
putValue(SHORT_DESCRIPTION, NbBundle.getBundle(GsfEditorKitFactory.class).getString("expand-all-code-block-folds")); |
532 |
putValue(BaseAction.POPUP_MENU_TEXT, NbBundle.getBundle(GsfEditorKitFactory.class).getString("popup-expand-all-code-block-folds")); |
533 |
} |
534 |
|
535 |
public void actionPerformed(ActionEvent evt, JTextComponent target) { |
536 |
FoldHierarchy hierarchy = FoldHierarchy.get(target); |
537 |
// Hierarchy locking done in the utility method |
538 |
List types = new ArrayList(); |
539 |
types.add(GsfFoldManager.CODE_BLOCK_FOLD_TYPE); |
540 |
//types.add(GsfFoldManager.IMPORTS_FOLD_TYPE); |
541 |
FoldUtilities.expand(hierarchy, types); |
542 |
} |
543 |
} |
544 |
|
545 |
public static class CollapseAllCodeBlockFolds extends BaseAction{ |
546 |
public CollapseAllCodeBlockFolds(){ |
547 |
super(collapseAllCodeBlockFolds); |
548 |
putValue(SHORT_DESCRIPTION, NbBundle.getBundle(GsfEditorKitFactory.class).getString("collapse-all-code-block-folds")); |
549 |
putValue(BaseAction.POPUP_MENU_TEXT, NbBundle.getBundle(GsfEditorKitFactory.class).getString("popup-collapse-all-code-block-folds")); |
550 |
} |
551 |
|
552 |
public void actionPerformed(ActionEvent evt, JTextComponent target) { |
553 |
FoldHierarchy hierarchy = FoldHierarchy.get(target); |
554 |
// Hierarchy locking done in the utility method |
555 |
List types = new ArrayList(); |
556 |
types.add(GsfFoldManager.CODE_BLOCK_FOLD_TYPE); |
557 |
///types.add(GsfFoldManager.IMPORTS_FOLD_TYPE); |
558 |
FoldUtilities.collapse(hierarchy, types); |
559 |
} |
560 |
} |
561 |
} |