List of usage examples for javax.swing JEditorPane setContentType
@BeanProperty(bound = false, description = "the type of content") public final void setContentType(String type)
From source file:org.isatools.isacreator.ontologyselectiontool.ViewTermDefinitionUI.java
private JEditorPane createOntologyInformationDisplay(OntologyBranch term) { JEditorPane ontologyInfo = new JEditorPane(); ontologyInfo.setContentType("text/html"); ontologyInfo.setEditable(false);/* w w w. j a v a2 s.c o m*/ ontologyInfo.setBackground(UIHelper.BG_COLOR); String labelContent = "<html>" + "<head>" + "<style type=\"text/css\">" + "<!--" + ".bodyFont {" + " font-family: Verdana;" + " font-size: 8.5px;" + " color: #006838;" + "}" + "-->" + "</style>" + "</head>" + "<body class=\"bodyFont\">"; labelContent += "<b>Term name: </b>" + term.getBranchName() + "</p>"; // special handling for ChEBI to get the structural image System.out.println("Showing CHEBI image for " + term.getBranchIdentifier()); if (term.getBranchIdentifier().toLowerCase().contains("chebi")) { String chebiTermId = term.getBranchIdentifier() .substring(term.getBranchIdentifier().lastIndexOf("_") + 1); System.out.println("Showing CHEBI image for " + chebiTermId); String chebiImageURL = "http://www.ebi.ac.uk/chebi/displayImage.do?defaultImage=true&imageIndex=0&chebiId=" + chebiTermId; labelContent += "<p><b>Chemical structure:</b>" + "<p/>" + "<img src=\"" + chebiImageURL + "\" alt=\"chemical structure for " + term.getBranchName() + "\" width=\"150\" height=\"150\"/>"; } properties = sortMap(properties); if (properties != null && properties.size() > 0) { for (String propertyType : properties.keySet()) { if (propertyType != null) { labelContent += ("<p><b>" + propertyType + ": </b>"); labelContent += (properties.get(propertyType) == null ? "no definition available" : properties.get(propertyType) + "</font></p>"); } } } else { labelContent += "<p>No definition found for this term! This can be due to 2 reasons: " + "1) Unfortunately, not all terms have their definitions supplied; and 2) the " + "ability to view the definitions for a term in this tool is not yet fully supported.</p>"; } labelContent += "</body></html>"; ontologyInfo.setText(labelContent); return ontologyInfo; }
From source file:org.isatools.isacreator.visualization.AssayInfoPanel.java
private JPanel prepareAssayInformation() { assayInformation.removeAll();/* ww w .j a v a 2s . c om*/ JEditorPane currentlyShowingInfo = new JEditorPane(); currentlyShowingInfo.setContentType("text/html"); currentlyShowingInfo.setEditable(false); currentlyShowingInfo.setBackground(UIHelper.BG_COLOR); currentlyShowingInfo.setPreferredSize(new Dimension(width - 10, height - 30)); Map<String, String> data = getAssayDetails(); String labelContent = "<html>" + "<head>" + "<style type=\"text/css\">" + "<!--" + ".bodyFont {" + " font-family: Verdana;" + " font-size: 9px;" + " color: #006838;" + "}" + "-->" + "</style>" + "</head>" + "<body class=\"bodyFont\">"; for (Object key : data.keySet()) { labelContent += ("<p><b>" + ((String) key).trim() + ": </b>"); labelContent += (data.get(key) + "</font></p>"); } labelContent += "</body></html>"; currentlyShowingInfo.setText(labelContent); assayInformation.add(currentlyShowingInfo); return assayInformation; }
From source file:org.isatools.isacreator.visualization.InvestigationInfoPanel.java
private JPanel prepareInvestigationInformation() { investigationInformation.removeAll(); JEditorPane currentlyShowingInfo = new JEditorPane(); currentlyShowingInfo.setContentType("text/html"); currentlyShowingInfo.setEditable(false); currentlyShowingInfo.setBackground(UIHelper.BG_COLOR); JScrollPane infoScroller = new JScrollPane(currentlyShowingInfo, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); infoScroller.setBackground(UIHelper.BG_COLOR); infoScroller.getViewport().setBackground(UIHelper.BG_COLOR); infoScroller.setPreferredSize(new Dimension(width - 10, height - 50)); infoScroller.setBorder(null);/*from w w w .j a v a 2 s.c o m*/ IAppWidgetFactory.makeIAppScrollPane(infoScroller); Map<String, String> data = getInvestigationDetails(); String labelContent = "<html>" + "<head>" + "<style type=\"text/css\">" + "<!--" + ".bodyFont {" + " font-family: Verdana;" + " font-size: 9px;" + " color: #006838;" + "}" + "-->" + "</style>" + "</head>" + "<body class=\"bodyFont\">"; for (Object key : data.keySet()) { labelContent += ("<p><b>" + ((String) key).trim() + ": </b>"); labelContent += (data.get(key) + "</font></p>"); } labelContent += "</body></html>"; currentlyShowingInfo.setText(labelContent); investigationInformation.add(infoScroller); return investigationInformation; }
From source file:org.isatools.isacreator.visualization.StudyInfoPanel.java
private JPanel prepareStudyInformation() { studyInformation.removeAll();/*from w ww .j a va2 s.c o m*/ JEditorPane currentlyShowingInfo = new JEditorPane(); currentlyShowingInfo.setContentType("text/html"); currentlyShowingInfo.setEditable(false); currentlyShowingInfo.setBackground(UIHelper.BG_COLOR); currentlyShowingInfo.setPreferredSize(new Dimension(width - 10, height - 30)); JScrollPane infoScroller = new JScrollPane(currentlyShowingInfo, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); infoScroller.setBackground(UIHelper.BG_COLOR); infoScroller.getViewport().setBackground(UIHelper.BG_COLOR); infoScroller.setPreferredSize(new Dimension(width - 10, height - 50)); infoScroller.setBorder(null); IAppWidgetFactory.makeIAppScrollPane(infoScroller); Map<String, String> data = getStudyDetails(); String labelContent = "<html>" + "<head>" + "<style type=\"text/css\">" + "<!--" + ".bodyFont {" + " font-family: Verdana;" + " font-size: 9px;" + " color: #006838;" + "}" + "-->" + "</style>" + "</head>" + "<body class=\"bodyFont\">"; for (Object key : data.keySet()) { labelContent += ("<p><b>" + ((String) key).trim() + ": </b>"); labelContent += (data.get(key) + "</font></p>"); } labelContent += "</body></html>"; currentlyShowingInfo.setText(labelContent); studyInformation.add(infoScroller); return studyInformation; }
From source file:org.mindswap.swoop.renderer.BaseEntityRenderer.java
/** * Create a JEditorPane given the contentType (text/plain or text/html) * and make other default settings (add hyperlink listener, editable false) * @param contentType//from ww w. j a v a2 s . co m * @return */ public static JEditorPane getEditorPane(String contentType, TermsDisplay TD) { JEditorPane editorPane = null; if (contentType.equals("text/plain")) editorPane = new JEditorPane(); else if (contentType.equals("text/html")) { editorPane = new JEditorPane(); editorPane.addHyperlinkListener(TD); } else if (contentType.equals("text/xml")) editorPane = new JEditorPane(); else throw new RuntimeException("Cannot create an editor pane for content type " + contentType); editorPane.setEditable(false); editorPane.setContentType(contentType); // adding to UI listeners of TermsDisplay //editorPane.getDocument().addDocumentListener(TD); editorPane.addMouseListener(TD); editorPane.addKeyListener(TD); return editorPane; }
From source file:org.nuclos.client.dbtransfer.DBTransferImport.java
private PanelWizardStep newStep1(final MainFrameTab ifrm) { final SpringLocaleDelegate localeDelegate = getSpringLocaleDelegate(); final PanelWizardStep step = new PanelWizardStep( localeDelegate.getMessage("dbtransfer.import.step1.1", "Konfigurationsdatei"), localeDelegate.getMessage("dbtransfer.import.step1.2", "Bitte w\u00e4hlen Sie eine Konfigurationsdatei aus.")); final JLabel lbFile = new JLabel(localeDelegate.getMessage("dbtransfer.import.step1.3", "Datei")); utils.initJPanel(step,/*w w w . ja v a 2 s.c om*/ new double[] { TableLayout.PREFERRED, TableLayout.PREFERRED, TableLayout.PREFERRED, TableLayout.FILL }, new double[] { 20, TableLayout.PREFERRED, lbFile.getPreferredSize().height, TableLayout.FILL }); final JButton btnBrowse = new JButton("..."); //final JProgressBar progressBar = new JProgressBar(0, 230); final JCheckBox chbxImportAsNuclon = new JCheckBox( localeDelegate.getMessage("configuration.transfer.import.as.nuclon", "Import als Nuclon")); chbxImportAsNuclon.setEnabled(false); final JEditorPane editWarnings = new JEditorPane(); editWarnings.setContentType("text/html"); editWarnings.setEditable(false); editWarnings.setBackground(Color.WHITE); final JScrollPane scrollWarn = new JScrollPane(editWarnings); scrollWarn.setPreferredSize(new Dimension(680, 250)); scrollWarn.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); scrollWarn.getVerticalScrollBar().setUnitIncrement(20); scrollWarn.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED); scrollWarn.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED); final JScrollPane scrollPrev = new JScrollPane(jpnPreviewContent); scrollPrev.setPreferredSize(new Dimension(680, 250)); scrollPrev.setBorder(new LineBorder(Color.LIGHT_GRAY, 1)); scrollPrev.getVerticalScrollBar().setUnitIncrement(20); scrollPrev.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED); scrollPrev.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED); final JPanel jpnPreview = new JPanel(new BorderLayout()); jpnPreview.add(jpnPreviewHeader, BorderLayout.NORTH); jpnPreview.add(scrollPrev, BorderLayout.CENTER); jpnPreview.add(jpnPreviewFooter, BorderLayout.SOUTH); jpnPreview.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); jpnPreview.setBackground(Color.WHITE); jpnPreviewHeader.setBackground(Color.WHITE); jpnPreviewContent.setBackground(Color.WHITE); jpnPreviewFooter.setBackground(Color.WHITE); final JTabbedPane tabbedPane = new JTabbedPane(); tabbedPane.addTab(localeDelegate.getMessage("configuration.transfer.prepare.warnings.tab", "Warnungen"), scrollWarn); final String sDefaultPreparePreviewTabText = localeDelegate .getMessage("configuration.transfer.prepare.preview.tab", "Vorschau der Schema Aenderungen"); tabbedPane.addTab(sDefaultPreparePreviewTabText, jpnPreview); final JLabel lbNewUser = new JLabel(); step.add(lbFile, "0,0"); step.add(tfTransferFile, "1,0"); step.add(btnBrowse, "2,0"); step.add(chbxImportAsNuclon, "1,1");//step.add(progressBar, "1,1"); step.add(lbNewUser, "0,2,3,2"); step.add(tabbedPane, "0,3,3,3"); tfTransferFile.setEditable(false); final ActionListener prepareImportAction = new ActionListener() { @Override public void actionPerformed(ActionEvent ev) { ifrm.lockLayerWithProgress(Transfer.TOPIC_CORRELATIONID_PREPARE); Thread t = new Thread() { @Override public void run() { step.setComplete(false); boolean blnTransferWithWarnings = false; //progressBar.setValue(0); //progressBar.setVisible(true); try { String fileName = tfTransferFile.getText(); if (StringUtils.isNullOrEmpty(fileName)) { return; } File f = new File(fileName); long size = f.length(); final InputStream fin = new BufferedInputStream(new FileInputStream(f)); final byte[] transferFile; try { transferFile = utils.getBytes(fin, (int) size); } finally { fin.close(); } resetStep2(); importTransferObject = getTransferFacadeRemote().prepareTransfer(isNuclon, transferFile); chbxImportAsNuclon.setEnabled(importTransferObject.getTransferOptions() .containsKey(TransferOption.IS_NUCLON_IMPORT_ALLOWED)); step.setComplete(!importTransferObject.result.hasCriticals()); if (!importTransferObject.result.hasCriticals() && !importTransferObject.result.hasWarnings()) { editWarnings.setText(localeDelegate.getMessage( "configuration.transfer.prepare.no.warnings", "Keine Warnungen")); } else { editWarnings.setText("<html><body><font color=\"#800000\">" + importTransferObject.result.getCriticals() + "</font>" + (importTransferObject.result.hasCriticals() ? "<br />" : "") + importTransferObject.result.getWarnings() + "</body></html>"); } int iPreviewSize = importTransferObject.getPreviewParts().size(); blnTransferWithWarnings = setupPreviewPanel(importTransferObject.getPreviewParts()); tabbedPane.setTitleAt(1, sDefaultPreparePreviewTabText + (iPreviewSize == 0 ? "" : " (" + iPreviewSize + ")")); lbNewUser.setText( "Neue Benutzer" + ": " + (importTransferObject.getNewUserCount() == 0 ? "keine" : importTransferObject.getNewUserCount())); } catch (Exception e) { // progressBar.setVisible(false); Errors.getInstance().showExceptionDialog(ifrm, e); } finally { btnBrowse.setEnabled(true); // progressBar.setVisible(false); ifrm.unlockLayer(); } if (blnTransferWithWarnings) { JOptionPane.showMessageDialog(jpnPreviewContent, localeDelegate.getMessage( "dbtransfer.import.step1.19", "Nicht alle Statements knnen durchgefhrt werden!\nBitte kontrollieren Sie die mit rot markierten Eintrge!", "Warning", JOptionPane.WARNING_MESSAGE)); } } }; t.start(); } }; final ActionListener browseAction = new ActionListener() { @Override public void actionPerformed(ActionEvent ev) { final JFileChooser filechooser = utils.getFileChooser( localeDelegate.getMessage("configuration.transfer.file.nuclet", "Nuclet-Dateien"), ".nuclet"); final int iBtn = filechooser.showOpenDialog(ifrm); if (iBtn == JFileChooser.APPROVE_OPTION) { final File file = filechooser.getSelectedFile(); if (file != null) { tfTransferFile.setText(""); btnBrowse.setEnabled(false); //progressBar.setVisible(true); String fileName = file.getPath(); if (StringUtils.isNullOrEmpty(fileName)) { return; } tfTransferFile.setText(fileName); prepareImportAction.actionPerformed(new ActionEvent(this, 0, "prepare")); } } } }; final ActionListener importAsNuclonAction = new ActionListener() { @Override public void actionPerformed(ActionEvent e) { isNuclon = chbxImportAsNuclon.isSelected(); prepareImportAction.actionPerformed(new ActionEvent(this, 0, "prepare")); } }; btnBrowse.addActionListener(browseAction); chbxImportAsNuclon.addActionListener(importAsNuclonAction); // progressBar.setVisible(false); return step; }
From source file:org.nuclos.client.dbtransfer.DBTransferImport.java
private PanelWizardStep newStep5(final MainFrameTab ifrm) { final SpringLocaleDelegate localeDelegate = getSpringLocaleDelegate(); final JLabel lbResult = new JLabel(); final JEditorPane editLog = new JEditorPane(); final JScrollPane scrollLog = new JScrollPane(editLog); final JLabel lbStructureChangeResult = new JLabel( localeDelegate.getMessage("dbtransfer.import.step5.1", "\u00c4nderungen am Datenbankschema")); final JButton btnSaveStructureChangeScript = new JButton( localeDelegate.getMessage("dbtransfer.import.step5.2", "Script speichern") + "..."); final JButton btnSaveStructureChangeLog = new JButton( localeDelegate.getMessage("dbtransfer.import.step5.3", "Log speichern") + "..."); editLog.setContentType("text/html"); editLog.setEditable(false);/*ww w . j a v a 2 s.c om*/ final PanelWizardStep step = new PanelWizardStep( localeDelegate.getMessage("dbtransfer.import.step5.4", "Ergebnis"), localeDelegate.getMessage( "dbtransfer.import.step5.5", "Hier wird Ihnen das Ergebnis des Imports angezeigt.")) { @Override public void prepare() { if (!importTransferResult.hasWarnings() && !importTransferResult.hasCriticals()) { lbResult.setText(localeDelegate.getMessage("dbtransfer.import.step5.6", "Import erfolgreich!")); this.setComplete(true); } else { lbResult.setText( localeDelegate.getMessage("dbtransfer.import.step5.7", "Ein Problem ist aufgetreten!")); blnSaveOfLogRecommend = true; } StringBuffer sbLog = new StringBuffer(); sbLog.append("<html><body>"); if (!importTransferResult.foundReferences.isEmpty()) { sbLog.append(localeDelegate.getMessage("dbtransfer.import.step5.8", "Folgende Konfigurationsobjekte sollten entfernt werden, werden aber noch verwendet") + ":<br />"); for (Pair<String, String> reference : importTransferResult.foundReferences) { sbLog.append( "- " + reference.y + " (" + localeDelegate.getLabelFromMetaDataVO( MetaDataClientProvider.getInstance().getEntity(reference.x)) + ")<br />"); } sbLog.append("<br />" + localeDelegate.getMessage("dbtransfer.import.step5.9", "Passen Sie Ihre Konfiguration dahingehend an oder bearbeiten Sie die Daten,\nwelche noch auf die Konfigurationsobjekte verweisen.")); sbLog.append("<br />"); } sbLog.append("<font color=\"#800000\">" + importTransferObject.result.getCriticals() + "</font>" + (importTransferObject.result.hasCriticals() ? "<br />" : "")); sbLog.append(importTransferResult.getWarnings()); sbLog.append("</body></html>"); editLog.setText(sbLog.toString()); } }; utils.initJPanel(step, new double[] { TableLayout.PREFERRED, TableLayout.PREFERRED, TableLayout.PREFERRED, TableLayout.FILL }, new double[] { 20, TableLayout.FILL, TableLayout.PREFERRED }); step.add(lbResult, "0,0,3,0"); step.add(scrollLog, "0,1,3,1"); step.add(lbStructureChangeResult, "0,2"); step.add(btnSaveStructureChangeScript, "1,2"); step.add(btnSaveStructureChangeLog, "2,2"); btnSaveStructureChangeScript.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent ae) { try { UIUtils.showWaitCursorForFrame(ifrm, true); final StringBuffer sbSql = new StringBuffer(); org.apache.commons.collections.CollectionUtils.forAllDo(importTransferResult.script, new Closure() { @Override public void execute(Object element) { sbSql.append("<DDL>" + element + "</DDL>\n\n"); } }); final JFileChooser filechooser = utils.getFileChooser( localeDelegate.getMessage("configuration.transfer.file.sql", "SQL-Dateien"), ".import-sql.txt"); filechooser.setSelectedFile(new File(tfTransferFile.getText() + ".import-sql.txt")); final int iBtn = filechooser.showSaveDialog(step); if (iBtn == JFileChooser.APPROVE_OPTION) { final File file = filechooser.getSelectedFile(); if (file != null) { String fileName = file.getPath(); if (!fileName.toLowerCase().endsWith(".import-sql.txt")) { fileName += ".import-sql.txt"; } File outFile = new File(fileName); final Writer out = new BufferedWriter(new FileWriter(outFile)); try { out.write(sbSql.toString()); } finally { out.close(); } if (blnSaveOfScriptRecommend) { step.setComplete(true); } } } } catch (Exception e) { Errors.getInstance().showExceptionDialog(ifrm, e); } finally { UIUtils.showWaitCursorForFrame(ifrm, false); } } }); btnSaveStructureChangeLog.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent ae) { try { UIUtils.showWaitCursorForFrame(ifrm, true); final JFileChooser filechooser = utils.getFileChooser( localeDelegate.getMessage("configuration.transfer.file.log", "Log-Dateien"), ".import-log.html"); filechooser.setSelectedFile(new File(tfTransferFile.getText() + ".import-log.html")); final int iBtn = filechooser.showSaveDialog(step); if (iBtn == JFileChooser.APPROVE_OPTION) { final File file = filechooser.getSelectedFile(); if (file != null) { String fileName = file.getPath(); if (!fileName.toLowerCase().endsWith(".import-log.html")) { fileName += ".import-log.html"; } File outFile = new File(fileName); final Writer out = new BufferedWriter(new FileWriter(outFile)); try { out.write(editLog.getText()); } finally { out.close(); } if (blnSaveOfLogRecommend) { step.setComplete(true); } } } } catch (Exception e) { Errors.getInstance().showExceptionDialog(ifrm, e); } finally { UIUtils.showWaitCursorForFrame(ifrm, false); } } }); return step; }
From source file:org.openmicroscopy.shoola.util.ui.UIUtilities.java
/** * Formats the text and displays it in a {@link JEditorPane}. * //from w w w.j a v a 2 s . c o m * @param text The text to display. * @return See above. */ public static JEditorPane buildTextEditorPane(String text) { if (text == null) text = ""; JEditorPane textPane = new JEditorPane(); textPane.setContentType("text/html"); textPane.setText(text); textPane.setOpaque(false); textPane.setEditable(false); textPane.setFocusable(false); return textPane; }
From source file:org.sonarlint.intellij.ui.SonarLintRulePanel.java
private JEditorPane createEditor() { JEditorPane newEditor = new JEditorPane(); newEditor.setEditorKit(kit);/*from w w w .java2s . co m*/ newEditor.setBorder(new EmptyBorder(10, 10, 10, 10)); newEditor.setEditable(false); newEditor.setContentType("text/html"); newEditor.addHyperlinkListener(e -> { if (HyperlinkEvent.EventType.ACTIVATED.equals(e.getEventType())) { Desktop desktop = Desktop.getDesktop(); try { desktop.browse(e.getURL().toURI()); } catch (Exception ex) { SonarLintConsole.get(project).error("Error opening browser: " + e.getURL(), ex); } } }); return newEditor; }
From source file:storybook.toolkit.swing.SwingUtil.java
public static JTextComponent createTextComponent(MainFrame mainFrame) { JTextComponent tc;// ww w .j a v a 2 s .com if (BookUtil.isUseHtmlScenes(mainFrame)) { tc = new JEditorPane(); JEditorPane ep = (JEditorPane) tc; ep.setEditorKitForContentType("text/html", new WysiwygHTMLEditorKit()); ep.setContentType("text/html"); } else { tc = new UndoableTextArea(); UndoableTextArea ta = (UndoableTextArea) tc; ta.setLineWrap(true); ta.setWrapStyleWord(true); ta.getUndoManager().discardAllEdits(); } return tc; }