private void saveUntaggedContents(File file) { try { String contents; if (editorPane.getContentType().equals("text/html")) { contents = editorPane.getText(); } else { Document doc = editorPane.getDocument(); contents = doc.getText(0, doc.getLength()); } saveFile(file, contents); saveUntagged.setEnabled(true); loadedFile = file; } catch (Exception e) { throw new RuntimeException(e); } }
public void saveUntaggedContents(File file) { try { String contents; if (editorPane.getContentType().equals("text/html")) { contents = editorPane.getText(); } else { Document doc = editorPane.getDocument(); contents = doc.getText(0, doc.getLength()); } saveFile(file, contents); saveUntagged.setEnabled(true); loadedFile = file; } catch (Exception e) { throw new RuntimeException(e); } }
public void redraw() { String text = editorPane.getText(); taggedContents = null; untaggedContents = null; if (!editorPane.getContentType().equals("text/html")) { editorPane.setContentType("text/rtf"); Document doc = editorPane.getDocument(); try { doc.insertString(0, text, defaultAttrSet); } catch (Exception e) { throw new RuntimeException(e); } editorPane.revalidate(); editorPane.repaint(); editorPane.setEditable(true); htmlContents = null; } else { editorPane.setEditable(false); htmlContents = editorPane.getText(); } saveUntagged.setEnabled(false); saveTaggedAs.setEnabled(false); }
private void removeTags() { if (editorPane.getContentType().equals("text/html")) { editorPane.setText(htmlContents); editorPane.revalidate(); editorPane.repaint(); } else { DefaultStyledDocument doc = (DefaultStyledDocument)editorPane.getDocument(); SimpleAttributeSet attr = new SimpleAttributeSet(); StyleConstants.setForeground(attr, Color.BLACK); StyleConstants.setBackground(attr, Color.WHITE); doc.setCharacterAttributes(0, doc.getLength(), attr, false); } saveTaggedAs.setEnabled(false); }
private void extract() { log.info("content type: "+editorPane.getContentType()); if (!editorPane.getContentType().equals("text/html")) {
private void removeTags() { if (editorPane.getContentType().equals("text/html")) { if (htmlContents != null) { editorPane.setText(htmlContents); } editorPane.revalidate(); editorPane.repaint(); } else { DefaultStyledDocument doc = (DefaultStyledDocument)editorPane.getDocument(); SimpleAttributeSet attr = new SimpleAttributeSet(); StyleConstants.setForeground(attr, Color.BLACK); StyleConstants.setBackground(attr, Color.WHITE); doc.setCharacterAttributes(0, doc.getLength(), attr, false); } saveTaggedAs.setEnabled(false); }
private void extract() { log.info("content type: "+editorPane.getContentType()); if (!editorPane.getContentType().equals("text/html")) {
String text = editorPane.getText(); taggedContents = null; if (!editorPane.getContentType().equals("text/html")) { editorPane.setContentType("text/rtf"); Document doc = editorPane.getDocument();
/** * Method to set the Document to print as the one contained in a JEditorPane. * This method is useful when Java does not provide direct access to a * particular Document type, such as a Rich Text Format document. With this * method such a document can be sent to the DocumentRenderer class enclosed * in a JEditorPane. * * @param jedPane the JEditorPane document container. */ public void setDocument(JEditorPane jedPane) { JEditorPane = new JEditorPane(); setDocument(jedPane.getContentType(), jedPane.getDocument()); }
TextTransferable(JTextComponent c, int start, int end) { this.c = c; Document doc = c.getDocument(); try { p0 = doc.createPosition(start); p1 = doc.createPosition(end); plainData = c.getSelectedText(); if (c instanceof JEditorPane) { JEditorPane ep = (JEditorPane)c; mimeType = ep.getContentType(); if (mimeType.startsWith("text/plain")) { return; } StringWriter sw = new StringWriter(p1.getOffset() - p0.getOffset()); ep.getEditorKit().write(sw, doc, p0.getOffset(), p1.getOffset() - p0.getOffset()); if (mimeType.startsWith("text/html")) { htmlData = sw.toString(); } else { richText = sw.toString(); } } } catch (BadLocationException ble) { } catch (IOException ioe) { } }
if (!contentType.equals(editorPane.getContentType())) { editorPane.setContentType(contentType);
dummy.setContentType(errorMessage.getContentType()); dummy.setEditorKit(errorMessage.getEditorKit()); dummy.setText(errorMessage.getText());
dummy.setContentType(errorMessage.getContentType()); dummy.setEditorKit(errorMessage.getEditorKit()); dummy.setText(errorMessage.getText());
dummy.setContentType(errorMessage.getContentType()); dummy.setEditorKit(errorMessage.getEditorKit()); dummy.setText(errorMessage.getText());
dummy.setContentType(errorMessage.getContentType()); dummy.setEditorKit(errorMessage.getEditorKit()); dummy.setText(errorMessage.getText());
dummy.setContentType(errorMessage.getContentType()); dummy.setEditorKit(errorMessage.getEditorKit()); dummy.setText(errorMessage.getText());
dummy.setContentType(errorMessage.getContentType()); dummy.setText(errorMessage.getText()); dummy.setSize(parent.getWidth() - leftEdge - insets.right, 20);
dummy.setContentType(errorMessage.getContentType()); dummy.setText(errorMessage.getText()); dummy.setSize(parent.getWidth() - leftEdge - insets.right, 20);
public EditorPanePrinter(JEditorPane pane, PageFormat pageFormat, Insets margins) { JEditorPane tmpPane = new JEditorPane(); tmpPane.setUI(new BasicEditorPaneUI()); tmpPane.setContentType(pane.getContentType()); HTMLEditorKit kit = new HTMLEditorKit(); StyleSheet ss = kit.getStyleSheet(); ss.addRule( "body {font-family:sans-serif;font-size:12pt;background-color:white;color:black;margin:3;font-weight:normal;}"); //$NON-NLS-1$ tmpPane.setEditorKit(kit); tmpPane.setBorder(null); tmpPane.setText(pane.getText()); this.sourcePane = tmpPane; this.pageFormat = pageFormat; Paper paper = pageFormat.getPaper(); this.margins = margins; this.pageWidth = (int) paper.getWidth(); this.pageHeight = (int) paper.getHeight(); paper.setImageableArea(0, 0, paper.getWidth(), paper.getHeight()); pageFormat.setPaper(paper); doPagesLayout(); }
debug("html current ContentType is: "+html.getContentType()); } catch (Exception e3) {