javax.swing.event.HyperlinkEvent Java Examples

The following examples show how to use javax.swing.event.HyperlinkEvent. 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 check out the related API usage on the sidebar.
Example #1
Source File: HTMLTextArea.java    From netbeans with 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 #2
Source File: EnvironmentVariablesTextFieldWithBrowseButton.java    From consulo with Apache License 2.0 6 votes vote down vote up
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 #3
Source File: HTMLTextArea.java    From visualvm with 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 #4
Source File: ESLintInspection.java    From eslint-plugin with 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 #5
Source File: HTMLDialogBox.java    From Robot-Overlord-App with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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 #6
Source File: AboutTmcDialog.java    From tmc-intellij with 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 #7
Source File: HTMLPanel.java    From beautyeye with 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 #8
Source File: ClientHandler.java    From fabric-installer with 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 #9
Source File: Browser.java    From consulo with 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 #10
Source File: ResultsTextPane.java    From mzmine3 with 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 #11
Source File: KeyboardInternationalizationNotificationManager.java    From consulo with Apache License 2.0 6 votes vote down vote up
@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 #12
Source File: CtrlMouseHandler.java    From consulo with 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 #13
Source File: FixedWidthEditorPane.java    From rapidminer-studio with GNU Affero General Public License v3.0 6 votes vote down vote up
/**
 * 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 #14
Source File: ExportToGURPSCalculatorCommand.java    From gcs with Mozilla Public License 2.0 6 votes vote down vote up
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 #15
Source File: DocumentationScrollPane.java    From netbeans with 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 #16
Source File: BrowserUtils.java    From netbeans with 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 #17
Source File: EditorPaneDemo.java    From beautyeye with 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 #18
Source File: PackagesNotificationPanel.java    From consulo with 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 #19
Source File: WebViewHyperlinkListenerDemo.java    From mars-sim with GNU General Public License v3.0 6 votes vote down vote up
/**
 * 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 #20
Source File: UIFacadeImpl.java    From ganttproject with 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 #21
Source File: Browser.java    From scelight with 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 #22
Source File: ProjectComponent.java    From EclipseCodeFormatter with 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 #23
Source File: HTMLPanel.java    From Darcula with 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 #24
Source File: ConfigDialog.java    From lizzie with 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 #25
Source File: ProblemComponent.java    From netbeans with Apache License 2.0 5 votes vote down vote up
/**
 * 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
                }
            }
        }
    });
}
 
Example #26
Source File: AboutDialog.java    From spotbugs with GNU Lesser General Public License v2.1 5 votes vote down vote up
static void editorPaneHyperlinkUpdate(HyperlinkEvent evt) {// GEN-FIRST:event_editorPaneHyperlinkUpdate
    try {
        if (evt.getEventType().equals(HyperlinkEvent.EventType.ACTIVATED)) {
            URL url = evt.getURL();
            LaunchBrowser.showDocument(url);
        }
    } catch (Exception e) {
    }
}
 
Example #27
Source File: CodeChickenCorePlugin.java    From CodeChickenCore with MIT License 5 votes vote down vote up
public static void versionCheck(String reqVersion, String mod) {
    String mcVersion = (String) FMLInjectionData.data()[4];
    if (!VersionParser.parseRange(reqVersion).containsVersion(new DefaultArtifactVersion(mcVersion))) {
        String err = "This version of " + mod + " does not support minecraft version " + mcVersion;
        logger.error(err);

        JEditorPane ep = new JEditorPane("text/html",
                "<html>" +
                        err +
                        "<br>Remove it from your coremods folder and check <a href=\"http://www.minecraftforum.net/topic/909223-\">here</a> for updates" +
                        "</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 ignored) {}
            }
        });

        JOptionPane.showMessageDialog(null, ep, "Fatal error", JOptionPane.ERROR_MESSAGE);
        System.exit(1);
    }
}
 
Example #28
Source File: MissingClient.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Override
public void hyperlinkUpdate(HyperlinkEvent e) {
    if(e.getEventType() != HyperlinkEvent.EventType.ACTIVATED) return;
    URL url = e.getURL();
    assert url != null;
    HtmlBrowser.URLDisplayer displayer = HtmlBrowser.URLDisplayer.getDefault ();
    assert displayer != null : "HtmlBrowser.URLDisplayer found.";
    if (displayer != null) {
        displayer.showURL (url);
    } else {
        Subversion.LOG.info("No URLDisplayer found.");
    }
}
 
Example #29
Source File: JUnitPluginDependencyWarning.java    From intellij with Apache License 2.0 5 votes vote down vote up
private static void showPopupNotification(String message) {
  JComponent component = WindowManager.getInstance().findVisibleFrame().getRootPane();
  if (component == null) {
    return;
  }
  Rectangle rect = component.getVisibleRect();
  JBPopupFactory.getInstance()
      .createHtmlTextBalloonBuilder(
          message,
          MessageType.WARNING,
          new HyperlinkAdapter() {
            @Override
            protected void hyperlinkActivated(HyperlinkEvent e) {
              PluginUtils.installOrEnablePlugin(JUNIT_PLUGIN_ID);
            }
          })
      .setFadeoutTime(-1)
      .setHideOnLinkClick(true)
      .setHideOnFrameResize(false)
      .setHideOnClickOutside(false)
      .setHideOnKeyOutside(false)
      .setDisposable(ApplicationManager.getApplication())
      .createBalloon()
      .show(
          new RelativePoint(component, new Point(rect.x + 30, rect.y + rect.height - 10)),
          Balloon.Position.above);
}
 
Example #30
Source File: NotificationTestAction.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public void hyperlinkUpdate(@Nonnull Notification notification, @Nonnull HyperlinkEvent event) {
  if (MessageDialogBuilder.yesNo("Notification Listener", event.getDescription() + "      Expire?").isYes()) {
    myNotification.expire();
    myNotification = null;
  }
}