repositorybox: Format a github url and add a click listener
This commit is contained in:
@@ -149,11 +149,31 @@ public class RepositoryBox extends JPanel
|
||||
titleWrapper.add(titleActions, BorderLayout.EAST);
|
||||
|
||||
JMultilineLabel repository = new JMultilineLabel();
|
||||
repository.setText(urlString.split("/", 2)[1]);
|
||||
repository.setText(formatURL(urlString));
|
||||
repository.setFont(smallFont);
|
||||
repository.setDisabledTextColor(Color.WHITE);
|
||||
|
||||
String finalUrlString = urlString;
|
||||
repository.addMouseListener(new MouseAdapter()
|
||||
{
|
||||
@Override
|
||||
public void mouseClicked(MouseEvent e)
|
||||
{
|
||||
LinkBrowser.browse(formatURL(finalUrlString));
|
||||
}
|
||||
});
|
||||
|
||||
add(titleWrapper, BorderLayout.NORTH);
|
||||
add(repository, BorderLayout.CENTER);
|
||||
}
|
||||
|
||||
private String formatURL(String url)
|
||||
{
|
||||
if (url.contains("githubusercontent"))
|
||||
{
|
||||
url = url.replace("raw.githubusercontent", "github").replace("/master/", "");
|
||||
}
|
||||
|
||||
return url;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user