Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 17 additions & 11 deletions src/io/flutter/samples/FlutterSampleActionsPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

public class FlutterSampleActionsPanel extends JPanel {

protected final JLabel myLabel = new JLabel();
protected final JBLabel myLabel = new JBLabel();
protected final JBLabel goLink;

@NotNull private final List<FlutterSample> samples;
Expand All @@ -51,16 +51,8 @@ public class FlutterSampleActionsPanel extends JPanel {
myLabel.setText("Open sample project:");
myLabel.setBorder(JBUI.Borders.emptyRight(5));

goLink = new JBLabel("<html><a href=\"\">Go...</a></html>");
goLink.setBorder(JBUI.Borders.emptyLeft(8));
goLink.setCursor(new Cursor(Cursor.HAND_CURSOR));
goLink.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
doCreate();
}
});

goLink = createLinkLabel("Go...", this::doCreate);
goLink.setBorder(JBUI.Borders.empty(1, 8, 0, 0));

sampleSelector = setupSelectorComponent();

Expand All @@ -80,6 +72,20 @@ public void mouseClicked(MouseEvent e) {
setupPanel();
}

private static JBLabel createLinkLabel(@NotNull String text, @NotNull Runnable onClick) {
// Standard hyperlinks were rendering oddly on 2018.3, so we create our own.
// See: https://github.com/flutter/flutter-intellij/issues/3197
final JBLabel label = new JBLabel(text);
label.setForeground(JBColor.blue);
label.setCursor(new Cursor(Cursor.HAND_CURSOR));
label.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
onClick.run();
}
});
return label;
}

JComponent setupSelectorComponent() {
if (samples.size() == 1) {
Expand Down