Exemple #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;
    }
Exemple #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;
 }
Exemple #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);
 }
Exemple #4
0
 public void setSelectionColor(Color color) {
   editorPaneImpl.setSelectionColor(color);
 }
Exemple #5
0
 public void setEditorKit(EditorKit k) {
   editorPaneImpl.setEditorKit(k);
 }
Exemple #6
0
 public EditorKit getEditorKit() {
   return editorPaneImpl.getEditorKit();
 }
Exemple #7
0
 public boolean isEditable() {
   return editorPaneImpl.isEditable();
 }
Exemple #8
0
 public void setText(String text) {
   editorPaneImpl.setText(text);
 }
Exemple #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();
 }
Exemple #10
0
 public void removeHyperlinkListener(swingwtx.swing.event.HyperlinkListener l) {
   editorPaneImpl.removeHyperlinkListener(l);
 }
Exemple #11
0
 public void addHyperlinkListener(swingwtx.swing.event.HyperlinkListener l) {
   editorPaneImpl.addHyperlinkListener(l);
 }
Exemple #12
0
 public Document getDocument() {
   return editorPaneImpl.getDocument();
 }
Exemple #13
0
 public void setDocument(Document newdoc) {
   editorPaneImpl.setDocument(newdoc);
 }
Exemple #14
0
 public void setEditable(boolean b) {
   editorPaneImpl.setEditable(b);
 }
Exemple #15
0
 public Color getSelectionColor() {
   return editorPaneImpl.getSelectionColor();
 }
Exemple #16
0
 public void scrollToReference(String reference) {
   editorPaneImpl.scrollToReference(reference);
 }
Exemple #17
0
 public void setCaretPosition(int pos) {
   editorPaneImpl.setCaretPosition(pos);
 }
Exemple #18
0
 public String getText() {
   return editorPaneImpl.getText();
 }
Exemple #19
0
 public int getCaretPosition() {
   return editorPaneImpl.getCaretPosition();
 }
Exemple #20
0
 public String getContentType() {
   return editorPaneImpl.getContentType();
 }
Exemple #21
0
 public int getSelectionStart() {
   return editorPaneImpl.getSelectionStart();
 }
Exemple #22
0
 public int getSelectionEnd() {
   return editorPaneImpl.getSelectionEnd();
 }
Exemple #23
0
 public void setContentType(String contentType) {
   editorPaneImpl.setContentType(contentType);
 }