Ejemplo n.º 1
0
 public void insertBreak(JTextComponent text) {
   indentationLogic = ((EditorPane) text).getIndentationLogic();
   boolean noSelection = text.getSelectionStart() == text.getSelectionEnd();
   if (noSelection) {
     insertNewlineWithAutoIndent(text);
   } else {
     text.replaceSelection("\n");
     // TODO insertNewlineWithAutoIndent
   }
 }
Ejemplo n.º 2
0
 /**
  * Determines whether the image is selected, and if it's the only thing selected.
  *
  * @return 0 if not selected, 1 if selected, 2 if exclusively selected. "Exclusive" selection is
  *     only returned when editable.
  */
 protected int getSelectionState() {
   int p0 = fElement.getStartOffset();
   int p1 = fElement.getEndOffset();
   if (fContainer instanceof JTextComponent) {
     JTextComponent textComp = (JTextComponent) fContainer;
     int start = textComp.getSelectionStart();
     int end = textComp.getSelectionEnd();
     if (start <= p0 && end >= p1) {
       if (start == p0 && end == p1 && isEditable()) return 2;
       else return 1;
     }
   }
   return 0;
 }