<commit_before>package jadx.gui.utils;

import java.awt.Color;
import java.awt.Cursor;
import java.awt.Desktop;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.util.Map;

import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JTextArea;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import static java.awt.Desktop.Action;

public class Link extends JLabel implements MouseListener {
	private static final long serialVersionUID = 3655322136444908178L;

	private static final Logger LOG = LoggerFactory.getLogger(Link.class);

	private final String url;

	public Link(String text, String url) {
		super(text);
		this.url = url;
		this.setToolTipText("Open " + url + " in your browser");
		this.addMouseListener(this);
		this.setForeground(Color.BLUE);
	}

	@Override
	public void mouseClicked(MouseEvent arg0) {
		browse();
	}

	@Override
	public void mouseEntered(MouseEvent arg0) {
		setCursor(new Cursor(Cursor.HAND_CURSOR));
	}

	@Override
	public void mouseExited(MouseEvent arg0) {
		setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
	}

	@Override
	public void mousePressed(MouseEvent arg0) {
		// ignore
	}

	@Override
	public void mouseReleased(MouseEvent arg0) {
		// ignore
	}

	private void browse() {
		if (Desktop.isDesktopSupported()) {
			Desktop desktop = Desktop.getDesktop();
			if (desktop.isSupported(Action.BROWSE)) {
				try {
					desktop.browse(new java.net.URI(url));
					return;
				} catch (Exception e) {
					LOG.debug("Open url error", e);
				}
			}
		}
		try {
			String os = System.getProperty("os.name").toLowerCase();
			if (os.contains("win")) {
				new ProcessBuilder()
						.command(new String[] { "rundll32", "url.dll,FileProtocolHandler", url })
						.start();
				return;
			}
			if (os.contains("mac")) {
				new ProcessBuilder()
						.command(new String[] { "open", url })
						.start();
				return;
			}
			Map<String, String> env = System.getenv();
			if (env.get("BROWSER") != null) {
				new ProcessBuilder()
						.command(new String[] { env.get("BROWSER"), url })
						.start();
				return;
			}
		} catch (Exception e) {
			LOG.debug("Open url error", e);
		}
		showUrlDialog();
	}
<commit_msg>fix(gui): don't use hardcoded color for link component (#1398)<commit_after>package jadx.gui.utils;

import java.awt.Cursor;
import java.awt.Desktop;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.util.Map;

import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JTextArea;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import static java.awt.Desktop.Action;

public class Link extends JLabel {
	private static final long serialVersionUID = 3655322136444908178L;

	private static final Logger LOG = LoggerFactory.getLogger(Link.class);

	private final String url;

	public Link(String text, String url) {
		super(text);
		this.url = url;
		setText(text);
		setToolTipText("Open " + url + " in your browser");
		setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
		this.addMouseListener(new MouseAdapter() {
			@Override
			public void mouseClicked(MouseEvent e) {
				browse();
			}
		});
	}

	private void browse() {
		if (Desktop.isDesktopSupported()) {
			Desktop desktop = Desktop.getDesktop();
			if (desktop.isSupported(Action.BROWSE)) {
				try {
					desktop.browse(new java.net.URI(url));
					return;
				} catch (Exception e) {
					LOG.debug("Open url error", e);
				}
			}
		}
		try {
			if (SystemInfo.IS_WINDOWS) {
				new ProcessBuilder()
						.command(new String[] { "rundll32", "url.dll,FileProtocolHandler", url })
						.start();
				return;
			}
			if (SystemInfo.IS_MAC) {
				new ProcessBuilder()
						.command(new String[] { "open", url })
						.start();
				return;
			}
			Map<String, String> env = System.getenv();
			if (env.get("BROWSER") != null) {
				new ProcessBuilder()
						.command(new String[] { env.get("BROWSER"), url })
						.start();
				return;
			}
		} catch (Exception e) {
			LOG.debug("Open url error", e);
		}
		showUrlDialog();
	}

{'fraction_non_alphanumeric': 0.1355392156862745, 'fraction_numerical': 0.013480392156862746, 'mean_word_length': 3.580246913580247, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6532869', 'n_tokens_mistral': 1648, 'n_tokens_neox': 1353, 'n_words': 309}