List of usage examples for javax.swing JEditorPane setEditable
@BeanProperty(description = "specifies if the text can be edited") public void setEditable(boolean b)
TextComponent
should be editable. From source file:org.formic.wizard.step.gui.TemplateStep.java
/** * {@inheritDoc}/*w ww.ja v a 2 s. com*/ * @see org.formic.wizard.step.GuiStep#init() */ public Component init() { JPanel panel = new JPanel(); panel.setLayout(new BorderLayout()); if (html != null) { JEditorPane editor = new JEditorPane("text/html", StringUtils.EMPTY); editor.setEditable(false); editor.setOpaque(false); editor.addHyperlinkListener(new HyperlinkListener()); editor.setBorder(null); editor.setFocusable(false); content = editor; } else { JTextArea area = new JTextArea(); area.setEditable(false); content = area; } JScrollPane scroll = new JScrollPane(content); scroll.setBorder(null); panel.add(scroll, BorderLayout.CENTER); return panel; }
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); 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;//from ww w.j a v a 2 s. c o m 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();//from w w w . ja v a2 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)); 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);//w ww . j a va 2s .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 av a 2 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.jajuk.ui.views.SuggestionView.java
/** * Gets the nothing found panel./*from w ww. java2 s . c om*/ * * @return a panel with text explaining why no item has been found */ JPanel getNothingFoundPanel() { JPanel out = new JPanel(new MigLayout("ins 5", "grow")); JEditorPane jteNothing = new JEditorPane("text/html", Messages.getString("SuggestionView.7")); jteNothing.setBorder(null); jteNothing.setEditable(false); jteNothing.setOpaque(false); jteNothing.setToolTipText(Messages.getString("SuggestionView.7")); out.add(jteNothing, "center,grow"); return out; }
From source file:org.jivesoftware.sparkimpl.updater.CheckUpdates.java
public void downloadUpdate(final File downloadedFile, final SparkVersion version) { final java.util.Timer timer = new java.util.Timer(); // Prepare HTTP post final GetMethod post = new GetMethod(version.getDownloadURL()); // Get HTTP client Protocol.registerProtocol("https", new Protocol("https", new EasySSLProtocolSocketFactory(), 443)); final HttpClient httpclient = new HttpClient(); String proxyHost = System.getProperty("http.proxyHost"); String proxyPort = System.getProperty("http.proxyPort"); if (ModelUtil.hasLength(proxyHost) && ModelUtil.hasLength(proxyPort)) { try {/*from w w w. j ava2 s. c o m*/ httpclient.getHostConfiguration().setProxy(proxyHost, Integer.parseInt(proxyPort)); } catch (NumberFormatException e) { Log.error(e); } } // Execute request try { int result = httpclient.executeMethod(post); if (result != 200) { return; } long length = post.getResponseContentLength(); int contentLength = (int) length; bar = new JProgressBar(0, contentLength); } catch (IOException e) { Log.error(e); } final JFrame frame = new JFrame(Res.getString("title.downloading.im.client")); frame.setIconImage(SparkRes.getImageIcon(SparkRes.SMALL_MESSAGE_IMAGE).getImage()); titlePanel = new TitlePanel(Res.getString("title.upgrading.client"), Res.getString("message.version", version.getVersion()), SparkRes.getImageIcon(SparkRes.SEND_FILE_24x24), true); final Thread thread = new Thread(new Runnable() { public void run() { try { InputStream stream = post.getResponseBodyAsStream(); long size = post.getResponseContentLength(); ByteFormat formater = new ByteFormat(); sizeText = formater.format(size); titlePanel.setDescription(Res.getString("message.version", version.getVersion()) + " \n" + Res.getString("message.file.size", sizeText)); downloadedFile.getParentFile().mkdirs(); FileOutputStream out = new FileOutputStream(downloadedFile); copy(stream, out); out.close(); if (!cancel) { downloadComplete = true; promptForInstallation(downloadedFile, Res.getString("title.download.complete"), Res.getString("message.restart.spark")); } else { out.close(); downloadedFile.delete(); } UPDATING = false; frame.dispose(); } catch (Exception ex) { // Nothing to do } finally { timer.cancel(); // Release current connection to the connection pool once you are done post.releaseConnection(); } } }); frame.getContentPane().setLayout(new GridBagLayout()); frame.getContentPane().add(titlePanel, new GridBagConstraints(0, 0, 1, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5), 0, 0)); frame.getContentPane().add(bar, new GridBagConstraints(0, 1, 1, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5), 0, 0)); JEditorPane pane = new JEditorPane(); boolean displayContentPane = version.getChangeLogURL() != null || version.getDisplayMessage() != null; try { pane.setEditable(false); if (version.getChangeLogURL() != null) { pane.setEditorKit(new HTMLEditorKit()); pane.setPage(version.getChangeLogURL()); } else if (version.getDisplayMessage() != null) { pane.setText(version.getDisplayMessage()); } if (displayContentPane) { frame.getContentPane().add(new JScrollPane(pane), new GridBagConstraints(0, 2, 1, 1, 1.0, 1.0, GridBagConstraints.WEST, GridBagConstraints.BOTH, new Insets(5, 5, 5, 5), 0, 0)); } } catch (IOException e) { Log.error(e); } frame.getContentPane().setBackground(Color.WHITE); frame.pack(); if (displayContentPane) { frame.setSize(600, 400); } else { frame.setSize(400, 100); } frame.setLocationRelativeTo(SparkManager.getMainWindow()); GraphicUtils.centerWindowOnScreen(frame); frame.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent windowEvent) { thread.interrupt(); cancel = true; UPDATING = false; if (!downloadComplete) { JOptionPane.showMessageDialog(SparkManager.getMainWindow(), Res.getString("message.updating.cancelled"), Res.getString("title.cancelled"), JOptionPane.ERROR_MESSAGE); } } }); frame.setVisible(true); thread.start(); timer.scheduleAtFixedRate(new TimerTask() { int seconds = 1; public void run() { ByteFormat formatter = new ByteFormat(); long value = bar.getValue(); long average = value / seconds; String text = formatter.format(average) + "/Sec"; String total = formatter.format(value); titlePanel.setDescription(Res.getString("message.version", version.getVersion()) + " \n" + Res.getString("message.file.size", sizeText) + "\n" + Res.getString("message.transfer.rate") + ": " + text + "\n" + Res.getString("message.total.downloaded") + ": " + total); seconds++; } }, 1000, 1000); }
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/*w w w . j a v a2 s . c o 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.mindswap.swoop.renderer.entity.TurtleEntityRenderer.java
public Component getDisplayComponent(SwoopDisplayPanel panel) { if (!(panel instanceof TermsDisplay)) throw new IllegalArgumentException(); JEditorPane editorPane = BaseEntityRenderer.getEditorPane(this.getContentType(), (TermsDisplay) panel); if (!editorEnabled) { return editorPane; } else {/* w w w .jav a 2 s. com*/ editorPane.setEditable(true); // adding to UI listeners of TermsDisplay //editorPane.getDocument().addDocumentListener((TermsDisplay)panel); editorPane.addMouseListener((TermsDisplay) panel); editorPane.addKeyListener((TermsDisplay) panel); } 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,/*from w w w . java2s .c o m*/ 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; }