示例#1
0
    private static int getNSVisualPosition(EditorPane txt, int pos, int direction) {
      Element root = txt.getDocument().getDefaultRootElement();
      int numLines = root.getElementIndex(txt.getDocument().getLength() - 1) + 1;
      int line = root.getElementIndex(pos) + 1;
      int tarLine = direction == SwingConstants.NORTH ? line - 1 : line + 1;
      try {
        if (tarLine <= 0) {
          return 0;
        }
        if (tarLine > numLines) {
          return txt.getDocument().getLength();
        }

        Rectangle curRect = txt.modelToView(pos);
        Rectangle tarEndRect;
        if (tarLine < numLines) {
          tarEndRect = txt.modelToView(txt.getLineStartOffset(tarLine) - 1);
        } else {
          tarEndRect = txt.modelToView(txt.getDocument().getLength() - 1);
        }
        Debug.log(9, "curRect: " + curRect + ", tarEnd: " + tarEndRect);

        if (curRect.x > tarEndRect.x) {
          pos = txt.viewToModel(new Point(tarEndRect.x, tarEndRect.y));
        } else {
          pos = txt.viewToModel(new Point(curRect.x, tarEndRect.y));
        }
      } catch (BadLocationException e) {
        Debug.error(me + "Problem getting next visual position\n%s", e.getMessage());
      }

      return pos;
    }
示例#2
0
 @Override
 public boolean importData(JComponent comp, Transferable t) {
   DataFlavor htmlFlavor = DataFlavor.stringFlavor;
   if (canImport(comp, t.getTransferDataFlavors())) {
     try {
       String transferString = (String) t.getTransferData(htmlFlavor);
       EditorPane targetTextPane = (EditorPane) comp;
       for (Map.Entry<String, String> entry : _copiedImgs.entrySet()) {
         String imgName = entry.getKey();
         String imgPath = entry.getValue();
         File destFile = targetTextPane.copyFileToBundle(imgPath);
         String newName = destFile.getName();
         if (!newName.equals(imgName)) {
           String ptnImgName = "\"" + imgName + "\"";
           newName = "\"" + newName + "\"";
           transferString = transferString.replaceAll(ptnImgName, newName);
           Debug.info(ptnImgName + " exists. Rename it to " + newName);
         }
       }
       targetTextPane.insertString(transferString);
     } catch (Exception e) {
       Debug.error(me + "importData: Problem pasting text\n%s", e.getMessage());
     }
     return true;
   }
   return false;
 }
示例#3
0
 public void setPage(URL url) throws IOException {
   // If we haven't created a peer yet, force us to use a browser, since
   // setPage is really aimed at HTML.
   if (!SwingWTUtils.isSWTControlAvailable(editorPaneImpl.getSWTPeer())) {
     loadBrowserEditorPane();
   }
   editorPaneImpl.setPage(url);
 }
示例#4
0
 public void setSelectionColor(Color color) {
   editorPaneImpl.setSelectionColor(color);
 }
示例#5
0
 public void setEditorKit(EditorKit k) {
   editorPaneImpl.setEditorKit(k);
 }
示例#6
0
 public EditorKit getEditorKit() {
   return editorPaneImpl.getEditorKit();
 }
示例#7
0
 public boolean isEditable() {
   return editorPaneImpl.isEditable();
 }
示例#8
0
 public void setText(String text) {
   editorPaneImpl.setText(text);
 }
示例#9
0
 /**
  * Once a parent component receives an "add" call for a child, this being the child, this should
  * be called to tell us to instantiate the peer and load in any cached properties.
  */
 public void setSwingWTParent(swingwt.awt.Container parent) throws Exception {
   descendantHasPeer = true;
   editorPaneImpl.setSwingWTParent(parent);
   peer = editorPaneImpl.getSWTPeer();
 }
示例#10
0
 public void removeHyperlinkListener(swingwtx.swing.event.HyperlinkListener l) {
   editorPaneImpl.removeHyperlinkListener(l);
 }
示例#11
0
 public void addHyperlinkListener(swingwtx.swing.event.HyperlinkListener l) {
   editorPaneImpl.addHyperlinkListener(l);
 }
示例#12
0
 public Document getDocument() {
   return editorPaneImpl.getDocument();
 }
示例#13
0
 public void setDocument(Document newdoc) {
   editorPaneImpl.setDocument(newdoc);
 }
示例#14
0
 public void setEditable(boolean b) {
   editorPaneImpl.setEditable(b);
 }
示例#15
0
 public Color getSelectionColor() {
   return editorPaneImpl.getSelectionColor();
 }
示例#16
0
 public void scrollToReference(String reference) {
   editorPaneImpl.scrollToReference(reference);
 }
示例#17
0
 public void setCaretPosition(int pos) {
   editorPaneImpl.setCaretPosition(pos);
 }
示例#18
0
 public String getText() {
   return editorPaneImpl.getText();
 }
示例#19
0
 public int getCaretPosition() {
   return editorPaneImpl.getCaretPosition();
 }
示例#20
0
 public String getContentType() {
   return editorPaneImpl.getContentType();
 }
示例#21
0
 public int getSelectionStart() {
   return editorPaneImpl.getSelectionStart();
 }
示例#22
0
 public int getSelectionEnd() {
   return editorPaneImpl.getSelectionEnd();
 }
示例#23
0
 public void setContentType(String contentType) {
   editorPaneImpl.setContentType(contentType);
 }