1 19 20 package org.netbeans.modules.versioning.system.cvss.ui.actions.annotate; 21 22 import org.netbeans.editor.SideBarFactory; 23 24 import javax.swing.*; 25 import javax.swing.text.JTextComponent ; 26 27 35 public final class AnnotationBarManager implements SideBarFactory { 36 37 private static final Object BAR_KEY = new Object (); 38 39 43 public JComponent createSideBar(JTextComponent target) { 44 final AnnotationBar ab = new AnnotationBar(target); 45 target.putClientProperty(BAR_KEY, ab); 46 return ab; 47 } 48 49 52 public static AnnotationBar showAnnotationBar(JTextComponent target) { 53 AnnotationBar ab = (AnnotationBar) target.getClientProperty(BAR_KEY); 54 assert ab != null: "#58828 reappeared!"; ab.annotate(); 56 return ab; 57 } 58 59 62 public static void hideAnnotationBar(JTextComponent target) { 63 if (target == null) return; 64 AnnotationBar ab = (AnnotationBar) target.getClientProperty(BAR_KEY); 65 assert ab != null: "#58828 reappeared!"; ab.hideBar(); 67 } 68 69 72 public static boolean annotationBarVisible(JTextComponent target) { 73 if (target == null) return false; 74 AnnotationBar ab = (AnnotationBar) target.getClientProperty(BAR_KEY); 75 if (ab == null) { 76 return false; 77 } 78 return ab.getPreferredSize().width > 0; 79 } 80 } 81 | Popular Tags |