Java Code Examples for javax.swing.event.HyperlinkEvent

The following examples show how to use javax.swing.event.HyperlinkEvent. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may want to check out the right sidebar which shows the related API usage.
Example 1
Source Project: mzmine3   Source File: ResultsTextPane.java    License: GNU General Public License v2.0 6 votes vote down vote up
public ResultsTextPane(StyledDocument doc) {
  super(doc);
  createStyles();
  setEditorKit(JTextPane.createEditorKitForContentType("text/html"));
  setEditable(false);
  addHyperlinkListener(new HyperlinkListener() {
    @Override
    public void hyperlinkUpdate(HyperlinkEvent e) {
      if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
        if (Desktop.isDesktopSupported()) {
          try {
            Desktop.getDesktop().browse(e.getURL().toURI());
          } catch (IOException | URISyntaxException e1) {
            e1.printStackTrace();
          }
        }
      }
    }
  });
}
 
Example 2
/**
 * Turns HTML into a clickable dialog text component.
 * @param html String of valid HTML.
 * @return a JTextComponent with the HTML inside.
 */
public JTextComponent createHyperlinkListenableJEditorPane(String html) {
	final JEditorPane bottomText = new JEditorPane();
	bottomText.setContentType("text/html");
	bottomText.setEditable(false);
	bottomText.setText(html);
	bottomText.setOpaque(false);
	final HyperlinkListener hyperlinkListener = new HyperlinkListener() {
		public void hyperlinkUpdate(HyperlinkEvent hyperlinkEvent) {
			if (hyperlinkEvent.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
				if (Desktop.isDesktopSupported()) {
					try {
						Desktop.getDesktop().browse(hyperlinkEvent.getURL().toURI());
					} catch (IOException | URISyntaxException exception) {
						// Auto-generated catch block
						exception.printStackTrace();
					}
				}

			}
		}
	};
	bottomText.addHyperlinkListener(hyperlinkListener);
	return bottomText;
}
 
Example 3
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();
}
 
Example 4
Source Project: consulo   Source File: CtrlMouseHandler.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public void hyperlinkUpdate(@Nonnull HyperlinkEvent e) {
  if (e.getEventType() != HyperlinkEvent.EventType.ACTIVATED) {
    return;
  }

  String description = e.getDescription();
  if (StringUtil.isEmpty(description) || !description.startsWith(DocumentationManagerProtocol.PSI_ELEMENT_PROTOCOL)) {
    return;
  }

  String elementName = e.getDescription().substring(DocumentationManagerProtocol.PSI_ELEMENT_PROTOCOL.length());

  DumbService.getInstance(myProject).withAlternativeResolveEnabled(() -> {
    PsiElement targetElement = myProvider.getDocumentationElementForLink(PsiManager.getInstance(myProject), elementName, myContext);
    if (targetElement != null) {
      LightweightHint hint = myHint;
      if (hint != null) {
        hint.hide(true);
      }
      DocumentationManager.getInstance(myProject).showJavaDocInfo(targetElement, myContext, null);
    }
  });
}
 
Example 5
Source Project: lizzie   Source File: ConfigDialog.java    License: GNU General Public License v3.0 6 votes vote down vote up
public LinkLabel(String text) {
  super("text/html", text);
  setEditable(false);
  setOpaque(false);
  putClientProperty(JEditorPane.HONOR_DISPLAY_PROPERTIES, Boolean.TRUE);
  addHyperlinkListener(
      new HyperlinkListener() {
        public void hyperlinkUpdate(HyperlinkEvent e) {
          if (HyperlinkEvent.EventType.ACTIVATED.equals(e.getEventType())) {
            if (Desktop.isDesktopSupported()) {
              try {
                Desktop.getDesktop().browse(e.getURL().toURI());
              } catch (Exception ex) {
              }
            }
          }
        }
      });
}
 
Example 6
/**
 * 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());
			}
		}
	});

}
 
Example 7
Source Project: netbeans   Source File: DocumentationScrollPane.java    License: Apache License 2.0 6 votes vote down vote up
public void hyperlinkUpdate(HyperlinkEvent e) {
    if (e != null && HyperlinkEvent.EventType.ACTIVATED.equals(e.getEventType())) {
        final String desc = e.getDescription();
        if (desc != null) {
            RP.post(new Runnable() {
                public @Override void run() {
                    final ElementJavadoc cd;
                    synchronized (DocumentationScrollPane.this) {
                        cd = currentDocumentation;
                    }
                    if (cd != null) {
                        final ElementJavadoc doc = cd.resolveLink(desc);
                        if (doc != null) {
                            EventQueue.invokeLater(new Runnable() {
                                public @Override void run() {
                                    setData(doc, false);
                                }
                            });
                        }
                    }
                }
            });
        }
    }
}
 
Example 8
Source Project: netbeans   Source File: BrowserUtils.java    License: Apache License 2.0 6 votes vote down vote up
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);
                    }
                }
            }
        }
    };
}
 
Example 9
Source Project: EclipseCodeFormatter   Source File: ProjectComponent.java    License: Apache License 2.0 6 votes vote down vote up
public void installOrUpdate(@NotNull Settings settings) {
	if (settings.isEnabled() && (settings.isEnableCppFormatting() || settings.isEnableJSFormatting() || settings.isEnableGWT())) {
		SwingUtilities.invokeLater(() -> Notifications.Bus.notify(
				GROUP_DISPLAY_ID_ERROR.createNotification(
						"Eclipse Code Formatter plugin", "Support for Cpp, JS, GWT formatting was dropped. Install an older version or <a href=\"#\">click here</a> to disable this warning.", NotificationType.WARNING, new NotificationListener() {
							@Override
							public void hyperlinkUpdate(@NotNull Notification notification, @NotNull HyperlinkEvent hyperlinkEvent) {
								settings.setEnableJSFormatting(false);
								settings.setEnableGWT(false);
								settings.setEnableCppFormatting(false);
								if (!settings.isProjectSpecific()) {
									GlobalSettings.getInstance().updateSettings(settings, project);
								}

								notification.hideBalloon();
							}
						}),
				project));

	}
	if (eclipseCodeStyleManager == null) {
		eclipseCodeStyleManager = projectCodeStyle.install(settings);
	} else {
		eclipseCodeStyleManager.updateSettings(settings);
	}
}
 
Example 10
Source Project: netbeans   Source File: HTMLTextArea.java    License: Apache License 2.0 6 votes vote down vote up
public void hyperlinkUpdate(HyperlinkEvent e) {
    if (!isEnabled()) {
        return;
    }

    if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
        activeLink = e.getURL();
        showURL(activeLink, e.getInputEvent());
    } else if (e.getEventType() == HyperlinkEvent.EventType.ENTERED) {
        activeLink = e.getURL();
        setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
    } else if (e.getEventType() == HyperlinkEvent.EventType.EXITED) {
        activeLink = null;
        setCursor(Cursor.getDefaultCursor());
    }
}
 
Example 11
Source Project: Darcula   Source File: HTMLPanel.java    License: Apache License 2.0 6 votes vote down vote up
public void hyperlinkUpdate(HyperlinkEvent event) {
    JEditorPane descriptionPane = (JEditorPane) event.getSource();
    HyperlinkEvent.EventType type = event.getEventType();
    if (type == HyperlinkEvent.EventType.ACTIVATED) {
        try {
            DemoUtilities.browse(event.getURL().toURI());
        } catch (Exception e) {
            e.printStackTrace();
            System.err.println(e);
        }

    } else if (type == HyperlinkEvent.EventType.ENTERED) {
        defaultCursor = descriptionPane.getCursor();
        descriptionPane.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));

    } else if (type == HyperlinkEvent.EventType.EXITED) {
        descriptionPane.setCursor(defaultCursor);
    }
}
 
Example 12
Source Project: ganttproject   Source File: UIFacadeImpl.java    License: GNU General Public License v3.0 6 votes vote down vote up
@Override
public void showNotificationDialog(NotificationChannel channel, String message) {
  String i18nPrefix = channel.name().toLowerCase() + ".channel.";
  getNotificationManager().addNotifications(
      channel,
      Collections.singletonList(new NotificationItem(i18n(i18nPrefix + "itemTitle"),
          GanttLanguage.getInstance().formatText(i18nPrefix + "itemBody", message), new HyperlinkListener() {
        @Override
        public void hyperlinkUpdate(HyperlinkEvent e) {
          if (e.getEventType() != EventType.ACTIVATED) {
            return;
          }
          if ("localhost".equals(e.getURL().getHost()) && "/log".equals(e.getURL().getPath())) {
            onViewLog();
          } else {
            NotificationManager.DEFAULT_HYPERLINK_LISTENER.hyperlinkUpdate(e);
          }
        }
      })));
}
 
Example 13
/**
 * Visualizes the specified event's type and URL on the specified label.
 *
 * @param event
 *            the {@link HyperlinkEvent} to visualize
 * @param urlLabel
 *            the {@link Label} which will visualize the event
 */
private static void showEventOnLabel(HyperlinkEvent event, Label urlLabel) {
	if (event.getEventType() == EventType.ENTERED) {
		urlLabel.setTextFill(Color.BLACK);
		urlLabel.setText("ENTERED: " + event.getURL().toExternalForm());
		System.out.println("EVENT: " + WebViews.hyperlinkEventToString(event));
	} else if (event.getEventType() == EventType.EXITED) {
		urlLabel.setTextFill(Color.BLACK);
		urlLabel.setText("EXITED: " + event.getURL().toExternalForm());
		System.out.println("EVENT: " + WebViews.hyperlinkEventToString(event));
	} else if (event.getEventType() == EventType.ACTIVATED) {
		urlLabel.setText("ACTIVATED: " + event.getURL().toExternalForm());
		urlLabel.setTextFill(Color.RED);
		System.out.println("EVENT: " + WebViews.hyperlinkEventToString(event));
	}
}
 
Example 14
Source Project: consulo   Source File: PackagesNotificationPanel.java    License: Apache License 2.0 6 votes vote down vote up
public PackagesNotificationPanel() {
  myHtmlViewer = SwingHelper.createHtmlViewer(true, null, null, null);
  myHtmlViewer.setVisible(false);
  myHtmlViewer.setOpaque(true);
  myHtmlViewer.addHyperlinkListener(new HyperlinkAdapter() {
    @Override
    protected void hyperlinkActivated(HyperlinkEvent e) {
      final Runnable handler = myLinkHandlers.get(e.getDescription());
      if (handler != null) {
        handler.run();
      }
      else if (myErrorTitle != null && myErrorDescription != null) {
        showError(myErrorTitle, myErrorDescription);
      }
    }
  });
}
 
Example 15
Source Project: beautyeye   Source File: EditorPaneDemo.java    License: Apache License 2.0 6 votes vote down vote up
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);
                    }
                }
            }
        }
    };
}
 
Example 16
private void showResult(boolean success) {
    String message = success ? I18n.Text("Export to GURPS Calculator was successful.") : I18n.Text("There was an error exporting to GURPS Calculator. Please try again later.");
    String key     = Preferences.getInstance().getGURPSCalculatorKey();
    if (key == null || !key.matches("[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-5][0-9a-fA-F]{3}-[89ab][0-9a-fA-F]{3}-[0-9a-fA-F]{12}")) {
        message = String.format(I18n.Text("You need to set a valid GURPS Calculator Key in sheet preferences.<br><a href='%s'>Click here</a> for more information."), OutputPreferences.GURPS_CALCULATOR_URL);
    }
    JLabel      styleLabel  = new JLabel();
    Font        font        = styleLabel.getFont();
    Color       color       = styleLabel.getBackground();
    JEditorPane messagePane = new JEditorPane("text/html", "<html><body style='font-family:" + font.getFamily() + ";font-weight:" + (font.isBold() ? "bold" : "normal") + ";font-size:" + font.getSize() + "pt;background-color: rgb(" + color.getRed() + "," + color.getGreen() + "," + color.getBlue() + ");'>" + message + "</body></html>");
    messagePane.setEditable(false);
    messagePane.setBorder(null);
    messagePane.addHyperlinkListener(event -> {
        if (Desktop.isDesktopSupported() && event.getEventType().equals(HyperlinkEvent.EventType.ACTIVATED)) {
            URL url = event.getURL();
            try {
                Desktop.getDesktop().browse(url.toURI());
            } catch (IOException | URISyntaxException exception) {
                WindowUtils.showError(null, MessageFormat.format(I18n.Text("Unable to open {0}"), url.toExternalForm()));
            }
        }
    });
    JOptionPane.showMessageDialog(Command.getFocusOwner(), messagePane, success ? I18n.Text("Success") : I18n.Text("Error"), success ? JOptionPane.INFORMATION_MESSAGE : JOptionPane.ERROR_MESSAGE);
}
 
Example 17
Source Project: scelight   Source File: Browser.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * 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 );
		}
	} );
}
 
Example 18
@Override
public void hyperlinkUpdate(@Nonnull Notification notification, @Nonnull HyperlinkEvent event) {
  if (event.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
    final String description = event.getDescription();
    if ("enable".equals(description)) {
      KeyboardSettingsExternalizable.getInstance().setNonEnglishKeyboardSupportEnabled(true);
    }
    else if ("settings".equals(description)) {
      final ShowSettingsUtil util = ShowSettingsUtil.getInstance();
      IdeFrame ideFrame = WindowManagerEx.getInstanceEx().findFrameFor(null);
      //util.editConfigurable((JFrame)ideFrame, new StatisticsConfigurable(true));
      util.showSettingsDialog(ideFrame.getProject(), KeymapPanel.class);
    }

    NotificationsConfiguration.getNotificationsConfiguration().changeSettings(LOCALIZATION_GROUP_DISPLAY_ID, NotificationDisplayType.NONE, false, false);
    notification.expire();
  }
}
 
Example 19
Source Project: visualvm   Source File: HTMLTextArea.java    License: GNU General Public License v2.0 6 votes vote down vote up
public void hyperlinkUpdate(HyperlinkEvent e) {
    if (!isEnabled()) {
        return;
    }

    if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
        activeLink = e.getURL();
        showURL(activeLink, e.getInputEvent());
    } else if (e.getEventType() == HyperlinkEvent.EventType.ENTERED) {
        activeLink = e.getURL();
        setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
    } else if (e.getEventType() == HyperlinkEvent.EventType.EXITED) {
        activeLink = null;
        setCursor(Cursor.getDefaultCursor());
    }
}
 
Example 20
Source Project: eslint-plugin   Source File: ESLintInspection.java    License: MIT License 6 votes vote down vote up
@NotNull
    private HyperlinkLabel createHyperLink() {
        List path = ContainerUtil.newArrayList(JSBundle.message("settings.javascript.root.configurable.name"), JSBundle.message("settings.javascript.linters.configurable.name"), getDisplayName());

        String title = Joiner.on(" / ").join(path);
        final HyperlinkLabel settingsLink = new HyperlinkLabel(title);
        settingsLink.addHyperlinkListener(new HyperlinkAdapter() {
            public void hyperlinkActivated(HyperlinkEvent e) {
//                DataContext dataContext = DataManager.getInstance().getDataContext(settingsLink);
//                OptionsEditor optionsEditor = OptionsEditor.KEY.getData(dataContext);
//                if (optionsEditor == null) {
//                    Project project = CommonDataKeys.PROJECT.getData(dataContext);
//                    if (project != null) {
//                        showSettings(project);
//                    }
//                    return;
//                }
//                Configurable configurable = optionsEditor.findConfigurableById(ESLintInspection.this.getId());
//                if (configurable != null) {
//                    optionsEditor.clearSearchAndSelect(configurable);
//                }
            }
        });
        return settingsLink;
    }
 
Example 21
Source Project: tmc-intellij   Source File: AboutTmcDialog.java    License: MIT License 6 votes vote down vote up
public AboutTmcDialog() {
    super(
            WindowManager.getInstance()
                    .getFrame(ProjectManager.getInstance().getDefaultProject()),
            false);
    initComponents();

    this.headerLabel.setText("About Test My Code");
    this.infoTextPane.setText("<html> <body> <div> Test My Code is a service designed for learning and teaching programming. It is open "
                    + "source, provides support for automatic assessment of programming assignments, and comes with a server "
                    + "that can be used to maintain course-specific point lists and grading. </div> <br> <div> "
                    + "Find out more at <a href=\"https://mooc.fi/tmc\">https://mooc.fi/tmc</a>. </div> </body> </html>");
    this.closeButton.setText("Close");

    this.infoTextPane.addHyperlinkListener((HyperlinkEvent e) -> {
        if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
            try {
                Desktop desktop = Desktop.getDesktop();
                desktop.browse(new URI("https://mooc.fi/tmc"));
            } catch (Exception ex) {
                new ErrorMessageService().showErrorMessagePopup("Failed to open browser.\n" + ex.getMessage());
            }
        }
    });
}
 
Example 22
Source Project: beautyeye   Source File: HTMLPanel.java    License: Apache License 2.0 6 votes vote down vote up
public void hyperlinkUpdate(HyperlinkEvent event) {
    JEditorPane descriptionPane = (JEditorPane) event.getSource();
    HyperlinkEvent.EventType type = event.getEventType();
    if (type == HyperlinkEvent.EventType.ACTIVATED) {
        try {
            DemoUtilities.browse(event.getURL().toURI());
        } catch (Exception e) {
            e.printStackTrace();
            System.err.println(e);
        }

    } else if (type == HyperlinkEvent.EventType.ENTERED) {
        defaultCursor = descriptionPane.getCursor();
        descriptionPane.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));

    } else if (type == HyperlinkEvent.EventType.EXITED) {
        descriptionPane.setCursor(defaultCursor);
    }
}
 
Example 23
Source Project: consulo   Source File: Browser.java    License: Apache License 2.0 6 votes vote down vote up
public Browser(@Nonnull 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();
}
 
Example 24
Source Project: fabric-installer   Source File: ClientHandler.java    License: Apache License 2.0 6 votes vote down vote up
private void showInstalledMessage(String loaderVersion, String gameVersion) {
	JEditorPane pane = new JEditorPane("text/html", "<html><body style=\"" + buildEditorPaneStyle() + "\">" + new MessageFormat(Utils.BUNDLE.getString("prompt.install.successful")).format(new Object[]{loaderVersion, gameVersion, Reference.fabricApiUrl}) + "</body></html>");
	pane.setEditable(false);
	pane.addHyperlinkListener(e -> {
		try {
			if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
				if (Desktop.isDesktopSupported() && Desktop.getDesktop().isSupported(Desktop.Action.BROWSE)) {
					Desktop.getDesktop().browse(e.getURL().toURI());
				} else {
					throw new UnsupportedOperationException("Failed to open " + e.getURL().toString());
				}
			}
		} catch (Throwable throwable) {
			error(throwable);
		}
	});
	JOptionPane.showMessageDialog(null, pane, Utils.BUNDLE.getString("prompt.install.successful.title"), JOptionPane.INFORMATION_MESSAGE);
}
 
Example 25
public TagInfoPanel(MainPanel mainPanel) {
    this.mainPanel = mainPanel;
    setLayout(new BorderLayout());
    JLabel topLabel = new JLabel(AppStrings.translate("taginfo.header"), JLabel.CENTER);
    add(topLabel, BorderLayout.NORTH);
    add(new JScrollPane(editorPane), BorderLayout.CENTER);

    editorPane.setContentType("text/html");
    editorPane.setEditable(false);

    HyperlinkListener listener = new HyperlinkListener() {
        @Override
        public void hyperlinkUpdate(HyperlinkEvent hyperLink) {

            if (HyperlinkEvent.EventType.ACTIVATED.equals(hyperLink.getEventType())) {
                String url = hyperLink.getDescription();
                String strId = url.substring(7);
                Integer id = Integer.parseInt(strId);

                mainPanel.setTagTreeSelectedNode(mainPanel.getCurrentSwf().getCharacter(id));
            }
        }

    };

    editorPane.addHyperlinkListener(listener);
}
 
Example 26
Source Project: bigtable-sql   Source File: HtmlViewerPanel.java    License: Apache License 2.0 5 votes vote down vote up
private HyperlinkListener createHyperLinkListener()
{
	return new HyperlinkListener()
	{
		public void hyperlinkUpdate(HyperlinkEvent e)
		{
			if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED)
			{
				if (e instanceof HTMLFrameHyperlinkEvent)
				{
					((HTMLDocument)_contentsTxt.getDocument()).processHTMLFrameHyperlinkEvent((HTMLFrameHyperlinkEvent)e);
				}
				else
				{
					try
					{
						gotoURL(e.getURL());
					}
					catch (IOException ex)
					{
                           // i18n[HtmlViewerPanel.error.processhyperlink=Error processing hyperlink]
						s_log.error(s_stringMgr.getString("HtmlViewerPanel.error.processhyperlink"), ex);
					}
				}
			}
		}
	};
}
 
Example 27
@Override
public void hyperlinkUpdate(HyperlinkEvent e) {
    UIWebView wv = getIOSWidget();
    if (wv == null)
        return;

    UIWebViewDelegate del = wv.delegate();
    if (del != null && e.getURL() != null && del.shouldStartLoadWithRequest(wv, NSURLRequest.requestWithURL(NSURL.URLWithString(e.getURL().toString())), UIWebViewNavigationType.LinkClicked))
        Native.system().debug("Will move to URL " + e.getURL(), null);
}
 
Example 28
Source Project: consulo   Source File: SearchForUsagesRunnable.java    License: Apache License 2.0 5 votes vote down vote up
@Nonnull
private HyperlinkListener createGotToOptionsListener(@Nonnull final UsageTarget[] targets) {
  return new HyperlinkAdapter() {
    @Override
    protected void hyperlinkActivated(HyperlinkEvent e) {
      if (e.getDescription().equals(FIND_OPTIONS_HREF_TARGET)) {
        TransactionGuard.getInstance().submitTransactionAndWait(() -> FindManager.getInstance(myProject).showSettingsAndFindUsages(targets));
      }
    }
  };
}
 
Example 29
Source Project: consulo   Source File: NotificationData.java    License: Apache License 2.0 5 votes vote down vote up
public NotificationData(@Nonnull String title,
                        @Nonnull String message,
                        @Nonnull NotificationCategory notificationCategory,
                        @Nonnull NotificationSource notificationSource,
                        @Nullable String filePath,
                        int line,
                        int column,
                        boolean balloonNotification) {
  myTitle = title;
  myMessage = message;
  myNotificationCategory = notificationCategory;
  myNotificationSource = notificationSource;
  myListenerMap = ContainerUtil.newHashMap();
  myListener = new NotificationListener.Adapter() {
    @Override
    protected void hyperlinkActivated(@Nonnull Notification notification, @Nonnull HyperlinkEvent event) {
      if (event.getEventType() != HyperlinkEvent.EventType.ACTIVATED) return;

      final NotificationListener notificationListener = myListenerMap.get(event.getDescription());
      if (notificationListener != null) {
        notificationListener.hyperlinkUpdate(notification, event);
      }
    }
  };
  myFilePath = filePath;
  myLine = line;
  myColumn = column;
  myBalloonNotification = balloonNotification;
}
 
Example 30
Source Project: mktool   Source File: MainGUI.java    License: GNU General Public License v3.0 5 votes vote down vote up
private Object getUpdateInfo() {
  showProgress(true);
  String str;
  if (UnpackRepackUtil.internet()) {
    if (!UnpackRepackUtil.getAppVersion().contains(appVersion)) {
      str = "New Update Available!<br>" +
        "For the latest update visit:<br>" +
        "<a href=\"https://techstop.github.io/mktool/\" style=\"color: #0099cc\">https://techstop.github.io/mktool/</a>";
    } else {
      str = "No updates available!";
    }
  } else {
    str = "No internet connection detected!";
  }
  JEditorPane editor = new JEditorPane();
  editor.setEditorKit(JEditorPane.createEditorKitForContentType("text/html"));
  editor.setEditable(false);
  editor.setText(str);
  editor.addHyperlinkListener(new HyperlinkListener() {
    public void hyperlinkUpdate(HyperlinkEvent e) {
      if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
        if (Desktop.isDesktopSupported()) {
          try {
            Desktop.getDesktop().browse(e.getURL().toURI());
          } catch (IOException | URISyntaxException ex) {
            ex.printStackTrace();
          }
        }
      }
    }
  });
  showProgress(false);
  return editor;
}