public static HyperlinkListener createHyperlinkListener() { return new HyperlinkListener() { public void hyperlinkUpdate(HyperlinkEvent hlevt) { if (HyperlinkEvent.EventType.ACTIVATED == hlevt.getEventType()) { final URL url = hlevt.getURL(); if (url != null) { try { openBrowser(url.toURI()); } catch (URISyntaxException e) { LogManager.log(e); } } } } }; }
public void setupPane(JTextPane pane, final File[] files, String fileNames, final File projectDir, final String url, final String revision) { String msg = revision == null ? NbBundle.getMessage(NotificationsManager.class, "MSG_NotificationBubble_DeleteDescription", fileNames, CMD_DIFF) //NOI18N : NbBundle.getMessage(NotificationsManager.class, "MSG_NotificationBubble_Description", fileNames, url, CMD_DIFF); //NOI18N pane.setText(msg); pane.addHyperlinkListener(new HyperlinkListener() { @Override public void hyperlinkUpdate(HyperlinkEvent e) { if (e.getEventType().equals(HyperlinkEvent.EventType.ACTIVATED)) { if(CMD_DIFF.equals(e.getDescription())) { Context ctx = new Context(files); DiffAction.diff(ctx, Setup.DIFFTYPE_REMOTE, NbBundle.getMessage(NotificationsManager.class, "LBL_Remote_Changes", projectDir.getName()), false); //NOI18N } else if (revision != null) { try { SearchHistoryAction.openSearch(new SVNUrl(url), projectDir, Long.parseLong(revision)); } catch (MalformedURLException ex) { LOG.log(Level.WARNING, null, ex); } } } } }); }
private static JTextPane createInfoPanel(String notification) { JTextPane balloon = new JTextPane(); balloon.setContentType("text/html"); String text = getDetails(notification).replaceAll("(\r\n|\n|\r)", "<br>"); balloon.setText(text); balloon.setOpaque(false); balloon.setEditable(false); balloon.setBorder(new EmptyBorder(0, 0, 0, 0)); if (UIManager.getLookAndFeel().getID().equals("Nimbus")) { //#134837 //http://forums.java.net/jive/thread.jspa?messageID=283882 balloon.setBackground(new Color(0, 0, 0, 0)); } balloon.addHyperlinkListener(new HyperlinkListener() { public void hyperlinkUpdate(HyperlinkEvent e) { if (e.getEventType().equals(HyperlinkEvent.EventType.ACTIVATED)) { URLDisplayer.getDefault().showURL(e.getURL()); } } }); return balloon; }
/** * Creates a pane with the given rootlessHTML as text with the given width. * * @param width * the desired width * @param rootlessHTML * the text, can contain hyperlinks that will be clickable */ public FixedWidthEditorPane(int width, String rootlessHTML) { super("text/html", ""); this.width = width; this.rootlessHTML = rootlessHTML; updateLabel(); setEditable(false); setFocusable(false); installDefaultStylesheet(); addHyperlinkListener(new HyperlinkListener() { @Override public void hyperlinkUpdate(HyperlinkEvent e) { if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) { RMUrlHandler.handleUrl(e.getDescription()); } } }); }
/** * Initialize this component */ private void init() { antiAliasing = false; // By default disable editing setEditable(false); setContentType("text/html"); // Adds hyperlink listener this.addHyperlinkListener(new HyperlinkListener() { public void hyperlinkUpdate(HyperlinkEvent e) { if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) { // An hyperlink is activated if (getPage() != null && e.getURL().getPath() != null && e.getURL().getPath().equals(getPage().getPath())) { setURL(e.getURL()); } else { // Open external links in default browser BrowserLauncher.openURL(e.getURL().toString()); } } } }); }
/** * Initialize this component */ private void init() { antiAliasing = false; // By default disable editing setEditable(false); setContentType("text/html"); // Adds hyperlink listener this.addHyperlinkListener(new HyperlinkListener() { public void hyperlinkUpdate(HyperlinkEvent e) { if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) { // An hyperlink is activated if (getPage() != null && e.getURL().getPath() != null && e.getURL().getPath().equals(getPage().getPath())) { setURL(e.getURL()); } else { // Open external links in default browser BareBonesBrowserLaunch.openURL(e.getURL().toString()); } } } }); }
public JTextPaneTableCellRenderer() { textPane.setContentType("text/html"); textPane.setEditable(false); textPane.setOpaque(true); textPane.setBorder(null); textPane.setForeground(UIManager.getColor("Table.selectionForeground")); textPane.setBackground(UIManager.getColor("Table.selectionBackground")); Font font = UIManager.getFont("Label.font"); String bodyRule = "body { font-family: " + font.getFamily() + "; " + "font-size: " + font.getSize() + "pt; " + (font.isBold() ? "font-weight: bold;" : "") + "}"; ((HTMLDocument)textPane.getDocument()).getStyleSheet().addRule(bodyRule); textPane.addHyperlinkListener(new HyperlinkListener() { @Override public void hyperlinkUpdate(HyperlinkEvent e) { if (e.getEventType().equals(HyperlinkEvent.EventType.ACTIVATED)) MainFrame.getInstance().showHelpFrame(e.getURL().toString(), "CREOLE Plugin Manager"); } }); }
@Override public JComponent createComponent() { pane.addHyperlinkListener(new HyperlinkListener() { @Override public void hyperlinkUpdate(HyperlinkEvent e) { if (e.getEventType() == EventType.ACTIVATED) { location = e.getURL().toExternalForm(); openLocation(); } } }); pane.setEditable(false); scrollPane = new JScrollPane(); scrollPane.setViewportView(this.pane); return scrollPane; }
public SwingTextComponent(final Document document) { //super("text/html"); this.document = document; configureEditor(this); addHyperlinkListener(new HyperlinkListener() { @Override public void hyperlinkUpdate(HyperlinkEvent event) { if (event.getEventType() == HyperlinkEvent.EventType.ACTIVATED) { RequestHandler requestHandler = document.getRequestHandler(); if (requestHandler != null) { try { requestHandler.openLink(event.getURL().toURI()); } catch (URISyntaxException e) { e.printStackTrace(); } } } } }); }
/** * This method initializes jTextPane * * @return javax.swing.JTextPane */ private JTextPane getJTextPane() { if (jTextPane == null) { jTextPane = new JTextPane(); jTextPane.setContentType("text/html"); jTextPane.setText(helpText); jTextPane.addHyperlinkListener(new HyperlinkListener() { public void hyperlinkUpdate(HyperlinkEvent e) { if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) { try{ FileOpener opener = new MultiOSFileOpener(); opener.open(e.getURL().toString()); }catch (Exception ex) { logger.error("", ex); } } } }); jTextPane.setEditable(false); } return jTextPane; }
private void createErrorPage() { myErrorLabel.setOpaque(false); myErrorLabel.addHyperlinkListener(new HyperlinkListener() { @Override public void hyperlinkUpdate(HyperlinkEvent e) { initSceneBuilder(true); } }); myErrorStack = new JTextArea(50, 20); myErrorStack.setEditable(false); myErrorPanel.add(myErrorLabel, BorderLayout.NORTH); myErrorPanel.add(ScrollPaneFactory.createScrollPane(myErrorStack), BorderLayout.CENTER); myPanel.add(myErrorPanel); }
@Override public void showErrorDialog(String name, String url) { JEditorPane ep = new JEditorPane("text/html", "<html>" + owner + " was unable to download required library " + name + "<br>Check your internet connection and try restarting or download it manually from" + "<br><a href=\"" + url + "\">" + url + "</a> and put it in your mods folder" + "</html>"); ep.setEditable(false); ep.setOpaque(false); ep.addHyperlinkListener(new HyperlinkListener() { @Override public void hyperlinkUpdate(HyperlinkEvent event) { try { if (event.getEventType().equals(HyperlinkEvent.EventType.ACTIVATED)) Desktop.getDesktop().browse(event.getURL().toURI()); } catch (Exception e) { } } }); JOptionPane.showMessageDialog(null, ep, "A download error has occured", JOptionPane.ERROR_MESSAGE); }
@Override public void displayYellingData() { StringBuilder builder = new StringBuilder(); builder.append("<html>"); for (String data : yellingData) { builder.append("<br>"); builder.append(data); } builder.append("</html>"); JEditorPane ep = new JEditorPane("text/html", builder.toString()); ep.setAutoscrolls(true); ep.setEditable(false); ep.setOpaque(false); ep.addHyperlinkListener(new HyperlinkListener() { @Override public void hyperlinkUpdate(HyperlinkEvent event) { try { if (event.getEventType().equals(HyperlinkEvent.EventType.ACTIVATED)) { Desktop.getDesktop().browse(event.getURL().toURI()); } } catch (Exception ignored) { } } }); JOptionPane.showMessageDialog(null, ep, "DepLoader is Deprecated!", -1); }
@Override public void showErrorDialog(String name, String url) { JEditorPane ep = new JEditorPane("text/html", "<html>" + owner + " was unable to download required library " + name + "<br>Check your internet connection and try restarting or download it manually from" + "<br><a href=\"" + url + "\">" + url + "</a> and put it in your mods folder" + "</html>"); ep.setEditable(false); ep.setOpaque(false); ep.addHyperlinkListener(new HyperlinkListener() { @Override public void hyperlinkUpdate(HyperlinkEvent event) { try { if (event.getEventType().equals(HyperlinkEvent.EventType.ACTIVATED)) { Desktop.getDesktop().browse(event.getURL().toURI()); } } catch (Exception e) { } } }); JOptionPane.showMessageDialog(null, ep, "A download error has occured", JOptionPane.ERROR_MESSAGE); }
public MessagePane( final JDialog owner, final SessionMessage sessionMessage ) { super( "" ); // insert our own hyperlink descriptions into the message, so translators can't mess them up Object[] args = { LINK_SHOW_STATISTICS_DETAILS, LINK_SHOW_SOFTWARE_AGREEMENT }; String htmlFragment = MessageFormat.format( MESSAGE_PATTERN, args ); setText( HTMLUtils.createStyledHTMLFromFragment( htmlFragment ) ); addHyperlinkListener( new HyperlinkListener() { public void hyperlinkUpdate( HyperlinkEvent e ) { if ( e.getEventType() == HyperlinkEvent.EventType.ACTIVATED ) { if ( e.getDescription().equals( LINK_SHOW_STATISTICS_DETAILS ) ) { showStatisticsDetails( owner, sessionMessage ); } else if ( e.getDescription().equals( LINK_SHOW_SOFTWARE_AGREEMENT ) ) { showSoftwareAgreement( owner ); } else { System.err.println( "SoftwareAgreementManager.MessagePane.hyperlinkUpdate: unsupported hyperlink, description=" + e.getDescription() ); } } } } ); setBackground( new JPanel().getBackground() );//see #1275 }
public DescriptionPane( final SessionMessage sessionMessage ) { super( "" ); // insert our own hyperlink descriptions into the message, so translators can't mess them up Object[] args = { LINK_SHOW_STATISTICS_DETAILS }; String htmlFragment = MessageFormat.format( DESCRIPTION_PATTERN, args ); setText( HTMLUtils.createStyledHTMLFromFragment( htmlFragment ) ); addHyperlinkListener( new HyperlinkListener() { public void hyperlinkUpdate( HyperlinkEvent e ) { if ( e.getEventType() == HyperlinkEvent.EventType.ACTIVATED ) { if ( e.getDescription().equals( LINK_SHOW_STATISTICS_DETAILS ) ) { showStatisticsDetails( SwingUtilities.getWindowAncestor( DescriptionPane.this ), sessionMessage ); } else { System.err.println( "PrivacyPreferencesPanel.DescriptionPane.hyperlinkUpdate: unsupported hyperlink, description=" + e.getDescription() ); } } } } ); setBackground( new JPanel().getBackground() ); }
private void showHelp( String helpText ) { JEditorPane editorPane = new JEditorPane(); editorPane.setEditorKit( new HTMLEditorKit() ); editorPane.setText( helpText ); editorPane.setEditable( false ); editorPane.setBackground( new JLabel().getBackground() ); editorPane.setFont( new JLabel().getFont() ); editorPane.addHyperlinkListener( new HyperlinkListener() { public void hyperlinkUpdate( HyperlinkEvent e ) { if ( e.getEventType() == HyperlinkEvent.EventType.ACTIVATED ) { PhetServiceManager.showWebPage( e.getURL() ); } } } ); JOptionPane.showMessageDialog( this, editorPane, TUStrings.HELP_TITLE, JOptionPane.INFORMATION_MESSAGE ); }
/** * Creates a new {@link Browser}. */ public Browser() { setEditable( false ); setContentType( "text/html" ); addHyperlinkListener( new HyperlinkListener() { @Override public void hyperlinkUpdate( final HyperlinkEvent event ) { if ( event.getEventType() == HyperlinkEvent.EventType.ACTIVATED ) { if ( event.getURL() != null ) LEnv.UTILS_IMPL.get().showURLInBrowser( event.getURL() ); } else if ( event.getEventType() == HyperlinkEvent.EventType.ENTERED ) { if ( event.getURL() != null ) setToolTipText( LUtils.urlToolTip( event.getURL() ) ); } else if ( event.getEventType() == HyperlinkEvent.EventType.EXITED ) setToolTipText( null ); } } ); }
/** * */ public HyperlinkListener createHyperLinkListener() { return e -> { if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) { if (e instanceof HTMLFrameHyperlinkEvent) { ((HTMLDocument) htmlEditorPane.getDocument()).processHTMLFrameHyperlinkEvent( (HTMLFrameHyperlinkEvent) e); } else { try { htmlEditorPane.setPage(e.getURL()); } catch (IOException ioe) { System.out.println("IOE: " + ioe); } } } }; }
public static JEditorPane createLinkEnabledEditorPane(final Component parent, String text) { JEditorPane pane = createEditorPane(text); HyperlinkListener linkListener = new HyperlinkListener() { public void hyperlinkUpdate(HyperlinkEvent e) { if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) { URL url = e.getURL(); if (!openBrowser(e.getURL())) { JOptionPane.showMessageDialog(parent, "An error occurred while opening the URL: " + url.toString(), "Error", JOptionPane.ERROR_MESSAGE); } } } }; pane.addHyperlinkListener(linkListener); return pane; }
private HyperlinkListener createHyperLinkListener() { return new HyperlinkListener() { public void hyperlinkUpdate(HyperlinkEvent e) { if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) { if (e instanceof HTMLFrameHyperlinkEvent) { ((HTMLDocument) html.getDocument()).processHTMLFrameHyperlinkEvent( (HTMLFrameHyperlinkEvent) e); } else { try { html.setPage(e.getURL()); } catch (IOException ioe) { System.out.println("IOE: " + ioe); } } } } }; }
/** * Returns a component able to display message with active links. */ private JComponent createEditorPane(String message) { // Use an uneditable editor pane to let user select text in dialog JEditorPane messagePane = new JEditorPane("text/html", message); messagePane.setEditable(false); if (SwingTools.getResolutionScale() != 1) { messagePane.putClientProperty(JEditorPane.HONOR_DISPLAY_PROPERTIES, Boolean.TRUE); } // Add a listener that displays hyperlinks content in browser messagePane.addHyperlinkListener(new HyperlinkListener() { public void hyperlinkUpdate(HyperlinkEvent ev) { if (ev.getEventType() == HyperlinkEvent.EventType.ACTIVATED) { SwingTools.showDocumentInBrowser(ev.getURL()); } } }); return messagePane; }
public HtmlPane() { this.addHyperlinkListener(new HyperlinkListener() { @Override public void hyperlinkUpdate(HyperlinkEvent e) { if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) { String ref = e.getURL().getRef(); if (ref != null) { log.debug("reference to scroll to = '" + ref + "'"); if (ref.length() > 0) { scrollToReference(ref); } else { // href="#" scrollRectToVisible(new Rectangle(1,1,1,1)); } } } } }); }
private MyCellEditor() { editorComponent = installJep(new MyJEditorPane(EditableNotificationMessageElement.this)); HyperlinkListener hyperlinkListener = new ActivatedHyperlinkListener(); editorComponent.addHyperlinkListener(hyperlinkListener); editorComponent.addMouseListener(new PopupHandler() { @Override public void invokePopup(Component comp, int x, int y) { if (myTree == null) return; final TreePath path = myTree.getLeadSelectionPath(); if (path == null) { return; } DefaultActionGroup group = new DefaultActionGroup(); group.add(ActionManager.getInstance().getAction(IdeActions.ACTION_EDIT_SOURCE)); group.add(ActionManager.getInstance().getAction(IdeActions.ACTION_COPY)); ActionPopupMenu menu = ActionManager.getInstance().createActionPopupMenu(ActionPlaces.COMPILER_MESSAGES_POPUP, group); menu.getComponent().show(comp, x, y); } }); }
@NotNull public static JEditorPane createTipBrowser() { JEditorPane browser = new JEditorPane(); browser.setEditable(false); browser.setBackground(UIUtil.getTextFieldBackground()); browser.addHyperlinkListener( new HyperlinkListener() { public void hyperlinkUpdate(HyperlinkEvent e) { if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) { BrowserUtil.browse(e.getURL()); } } } ); URL resource = ResourceUtil.getResource(TipUIUtil.class, "/tips/css/", UIUtil.isUnderDarcula() ? "tips_darcula.css" : "tips.css"); final StyleSheet styleSheet = UIUtil.loadStyleSheet(resource); HTMLEditorKit kit = new HTMLEditorKit() { @Override public StyleSheet getStyleSheet() { return styleSheet != null ? styleSheet : super.getStyleSheet(); } }; browser.setEditorKit(kit); return browser; }
@Nullable public static HyperlinkListener wrapListener(@NotNull final Notification notification) { final NotificationListener listener = notification.getListener(); if (listener == null) return null; return new HyperlinkListener() { public void hyperlinkUpdate(HyperlinkEvent e) { if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) { final NotificationListener listener1 = notification.getListener(); if (listener1 != null) { listener1.hyperlinkUpdate(notification, e); } } } }; }
public static MessageTreeNode createInfoMessage(XDebuggerTree tree, @NotNull String message, @Nullable HyperlinkListener hyperlinkListener) { Matcher matcher = MessageTreeNodeWithLinks.HREF_PATTERN.matcher(message); if (hyperlinkListener == null || !matcher.find()) { return new MessageTreeNode(tree, null, message, SimpleTextAttributes.REGULAR_ATTRIBUTES, XDebuggerUIConstants.INFORMATION_MESSAGE_ICON); } List<Object> objects = new ArrayList<Object>(); int prev = 0; do { if (matcher.start() != prev) { objects.add(message.substring(prev, matcher.start())); } objects.add(new HyperlinkListenerDelegator(matcher.group(2), matcher.group(1), hyperlinkListener)); prev = matcher.end(); } while (matcher.find()); if (prev < message.length()) { objects.add(message.substring(prev)); } return new MessageTreeNodeWithLinks(tree, objects); }
public Browser(@NotNull InspectionResultsView view) { super(new BorderLayout()); myView = view; myCurrentEntity = null; myCurrentDescriptor = null; myHTMLViewer = new JEditorPane(UIUtil.HTML_MIME, InspectionsBundle.message("inspection.offline.view.empty.browser.text")); myHTMLViewer.setEditable(false); myHyperLinkListener = new HyperlinkListener() { @Override public void hyperlinkUpdate(HyperlinkEvent e) { Browser.this.hyperlinkUpdate(e); } }; myHTMLViewer.addHyperlinkListener(myHyperLinkListener); final JScrollPane pane = ScrollPaneFactory.createScrollPane(myHTMLViewer); pane.setBorder(null); add(pane, BorderLayout.CENTER); setupStyle(); }
protected MyEnvironmentVariablesDialog() { super(EnvironmentVariablesTextFieldWithBrowseButton.this, true); myEnvVariablesTable = new EnvVariablesTable(); myEnvVariablesTable.setValues(convertToVariables(myData.getEnvs(), false)); myUseDefaultCb.setSelected(isPassParentEnvs()); myWholePanel.add(myEnvVariablesTable.getComponent(), BorderLayout.CENTER); JPanel useDefaultPanel = new JPanel(new BorderLayout()); useDefaultPanel.add(myUseDefaultCb, BorderLayout.CENTER); HyperlinkLabel showLink = new HyperlinkLabel(ExecutionBundle.message("env.vars.show.system")); useDefaultPanel.add(showLink, BorderLayout.EAST); showLink.addHyperlinkListener(new HyperlinkListener() { @Override public void hyperlinkUpdate(HyperlinkEvent e) { if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) { showParentEnvironmentDialog(MyEnvironmentVariablesDialog.this.getWindow()); } } }); myWholePanel.add(useDefaultPanel, BorderLayout.SOUTH); setTitle(ExecutionBundle.message("environment.variables.dialog.title")); init(); }
public void showNoSdkNotification(@NotNull final Project project) { final String text = "<html>No Python interpreter configured for the project<br><a href=\"\">Configure interpreter</a></html>"; final BalloonBuilder balloonBuilder = JBPopupFactory.getInstance(). createHtmlTextBalloonBuilder(text, null, MessageType.WARNING.getPopupBackground(), new HyperlinkListener() { @Override public void hyperlinkUpdate(HyperlinkEvent event) { if (event.getEventType() == HyperlinkEvent.EventType.ACTIVATED) { ApplicationManager.getApplication() .invokeLater(new Runnable() { @Override public void run() { ShowSettingsUtil.getInstance().showSettingsDialog(project, "Project Interpreter"); } }); } } }); balloonBuilder.setHideOnLinkClick(true); final Balloon balloon = balloonBuilder.createBalloon(); StudyUtils.showCheckPopUp(project, balloon); }
public HyperlinkLabel addLink(@NotNull String text, @NotNull final URI uri) { HyperlinkLabel linkLabel = new HyperlinkLabel(text); linkLabel.addHyperlinkListener(new HyperlinkListener() { @Override public void hyperlinkUpdate(HyperlinkEvent e) { try { Desktop.getDesktop().browse(uri); } catch (IOException e1) { // Don't care } } }); addComponent(linkLabel); return linkLabel; }
public LabelWithEditLink() { setLayout(new BorderLayout()); myCardPanel.add(EDIT, myEditField); myCardPanel.add(DISPLAY, myContentLabel); myCardPanel.revalidate(); myCardPanel.repaint(); myCardLayout.show(myCardPanel, DISPLAY); add(myCardPanel, BorderLayout.CENTER); add(myEditLabel, BorderLayout.EAST); myContentLabel.setHorizontalTextPosition(SwingConstants.RIGHT); myEditLabel.addHyperlinkListener(new HyperlinkListener() { @Override public void hyperlinkUpdate(HyperlinkEvent e) { if (HyperlinkEvent.EventType.ACTIVATED.equals(e.getEventType())) { toggleEdit(); } } }); myContentLabel.setForeground(JBColor.gray); setFont(UIUtil.getLabelFont()); myEditLabel.setHtmlText(EDIT_TEXT); }
private static void configureHyperLinkLabelForClassName(final RenderingParameters renderingParameters, HyperlinkLabel link, @Nullable final String className) { link.setOpaque(false); if (className == null) { return; } link.setHyperlinkText(className.substring(1 + className.lastIndexOf('.'))); link.addHyperlinkListener(new HyperlinkListener() { @Override public void hyperlinkUpdate(HyperlinkEvent hyperlinkEvent) { PsiClass psiClass = NavigationEditorUtils.getPsiClass(renderingParameters.configuration.getModule(), className); if (psiClass != null) { AndroidRootComponent.launchEditor(renderingParameters, psiClass.getContainingFile(), false); } } }); }
private static void configureHyperlinkForXMLFile(final RenderingParameters renderingParameters, HyperlinkLabel link, @Nullable final String linkText, @Nullable final String xmlFileName, final boolean isMenu) { link.setOpaque(false); link.setHyperlinkText(linkText == null ? "" : linkText); link.addHyperlinkListener(new HyperlinkListener() { @Override public void hyperlinkUpdate(HyperlinkEvent hyperlinkEvent) { PsiFile layoutXmlFile = NavigationView.getLayoutXmlFile(isMenu, xmlFileName, renderingParameters.configuration, renderingParameters.project); AndroidRootComponent.launchEditor(renderingParameters, layoutXmlFile, false); } }); }
public CharSequence getValue(JTextComponent component, Document document, Object attributeKey, int startOffset, int endOffset) { try { String tooltipText = provider.getTooltipText(document, offset, type); HyperlinkListener hl = (HyperlinkListener)document.getProperty(HYPERLINK_LISTENER); return hl != null ? new TooltipInfo(tooltipText, hl) : tooltipText; } finally { document.putProperty(HYPERLINK_LISTENER, null); } }
/** * Creates new form ProblemComponent */ public ProblemComponent(Problem problem, RefactoringUI ui, boolean single) { initComponents(); this.ui = ui; icon.setIcon(problem.isFatal()?ErrorPanel.getFatalErrorIcon():ErrorPanel.getNonfatalErrorIcon()); problemDescription.setText(problem.getMessage()); this.problem = problem; this.details = problem.getDetails(); //setLightBackground(); if (!single && details != null) { org.openide.awt.Mnemonics.setLocalizedText(showDetails, details.getDetailsHint()); showDetails.setPreferredSize(new Dimension((int) buttonWidth, (int) showDetails.getMinimumSize().getHeight())); } else { showDetails.setVisible(false); } problemDescription.addHyperlinkListener(new HyperlinkListener() { @Override public void hyperlinkUpdate(HyperlinkEvent e) { if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED && Desktop.isDesktopSupported()) { try { Desktop.getDesktop().browse(e.getURL().toURI()); } catch (IOException | URISyntaxException ex) { LOGGER.log(Level.INFO, "Desktop.browse failed: ", ex); // NOI18N } } } }); }
private SwingBrowser() { setEditable(false); addHyperlinkListener( new HyperlinkListener() { public void hyperlinkUpdate(HyperlinkEvent e) { if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) { if (e instanceof HTMLFrameHyperlinkEvent) { HTMLFrameHyperlinkEvent evt = (HTMLFrameHyperlinkEvent) e; HTMLDocument doc = (HTMLDocument) getDocument(); URL old = getURL(); doc.processHTMLFrameHyperlinkEvent(evt); pcs.firePropertyChange(PROP_URL, old, e.getURL()); } else { try { SwingBrowserImpl.this.setURL(e.getURL()); } catch (Exception ex) { LOG.log(Level.WARNING, null, ex); } } } } } ); //when up/down arrow keys are pressed, ensure the whole browser content //scrolls up/down instead of moving the caret position only ActionMap actionMap = getActionMap(); actionMap.put(DefaultEditorKit.upAction, new ScrollAction(-1)); actionMap.put(DefaultEditorKit.downAction, new ScrollAction(1)); }
private void makeHyperLinkListener(final Action action) { actionLinkListener = new HyperlinkListener() { @Override public void hyperlinkUpdate(HyperlinkEvent e) { if (e.getEventType() == EventType.ACTIVATED) { action.actionPerformed( new ActionEvent(LinkButton.this, ActionEvent.ACTION_PERFORMED, e.getDescription())); } } }; addHyperlinkListener(actionLinkListener); }
/** * Creates the hyperlink listener for the given action. * * @param action */ private void makeHyperLinkListener(final Action action) { actionLinkListener = new HyperlinkListener() { @Override public void hyperlinkUpdate(HyperlinkEvent e) { if (e.getEventType() == EventType.ACTIVATED) { action.actionPerformed(new ActionEvent(AbstractLinkButton.this, ActionEvent.ACTION_PERFORMED, e .getDescription())); } } }; addHyperlinkListener(actionLinkListener); }