use of javax.swing.event.HyperlinkListener in project processing by processing.
the class DetailPanel method addPaneComponents.
/**
* Create the widgets for the header panel which is visible when the
* library panel is not clicked.
*/
private void addPaneComponents() {
setLayout(new BorderLayout());
descriptionPane = new JTextPane();
descriptionPane.setInheritsPopupMenu(true);
// why would this ever be true?
descriptionPane.setEditable(false);
Insets margin = descriptionPane.getMargin();
margin.bottom = 0;
descriptionPane.setMargin(margin);
descriptionPane.setContentType("text/html");
setTextStyle(descriptionPane, "0.95em");
descriptionPane.setOpaque(false);
if (UIManager.getLookAndFeel().getID().equals("Nimbus")) {
descriptionPane.setBackground(new Color(0, 0, 0, 0));
}
descriptionPane.setBorder(new EmptyBorder(4, 7, 7, 7));
descriptionPane.setHighlighter(null);
descriptionPane.addHyperlinkListener(new HyperlinkListener() {
public void hyperlinkUpdate(HyperlinkEvent e) {
if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
// adding/removing the listener repeatedly
if (isSelected()) {
if (enableHyperlinks && e.getURL() != null) {
Platform.openURL(e.getURL().toString());
}
}
}
}
});
add(descriptionPane, BorderLayout.CENTER);
JPanel updateBox = new JPanel();
updateBox.setLayout(new BorderLayout());
notificationLabel = new JLabel();
notificationLabel.setInheritsPopupMenu(true);
notificationLabel.setVisible(false);
notificationLabel.setOpaque(false);
notificationLabel.setFont(ManagerFrame.SMALL_PLAIN);
{
updateButton = new JButton("Update");
updateButton.setInheritsPopupMenu(true);
Dimension dim = new Dimension(BUTTON_WIDTH, updateButton.getPreferredSize().height);
updateButton.setMinimumSize(dim);
updateButton.setPreferredSize(dim);
updateButton.setOpaque(false);
updateButton.setVisible(false);
updateButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
update();
}
});
}
updateBox.add(updateButton, BorderLayout.EAST);
updateBox.add(notificationLabel, BorderLayout.WEST);
updateBox.setBorder(new EmptyBorder(4, 7, 7, 7));
updateBox.setOpaque(false);
add(updateBox, BorderLayout.SOUTH);
JPanel rightPane = new JPanel();
rightPane.setInheritsPopupMenu(true);
rightPane.setOpaque(false);
rightPane.setLayout(new BoxLayout(rightPane, BoxLayout.Y_AXIS));
rightPane.setMinimumSize(new Dimension(BUTTON_WIDTH, 1));
add(rightPane, BorderLayout.EAST);
barButtonCardLayout = new CardLayout();
barButtonCardPane.setLayout(barButtonCardLayout);
barButtonCardPane.setInheritsPopupMenu(true);
barButtonCardPane.setOpaque(false);
barButtonCardPane.setMinimumSize(new Dimension(BUTTON_WIDTH, 1));
{
installProgressBar = new JProgressBar();
installProgressBar.setInheritsPopupMenu(true);
installProgressBar.setStringPainted(true);
resetInstallProgressBarState();
Dimension dim = new Dimension(BUTTON_WIDTH, installProgressBar.getPreferredSize().height);
installProgressBar.setPreferredSize(dim);
installProgressBar.setMaximumSize(dim);
installProgressBar.setMinimumSize(dim);
installProgressBar.setOpaque(false);
installProgressBar.setAlignmentX(CENTER_ALIGNMENT);
}
installRemoveButton = new JButton(" ");
installRemoveButton.setInheritsPopupMenu(true);
installRemoveButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
String mode = installRemoveButton.getText();
if (mode.equals(installText)) {
install();
} else if (mode.equals(removeText)) {
remove();
} else if (mode.equals(undoText)) {
undo();
}
}
});
Dimension installButtonDimensions = installRemoveButton.getPreferredSize();
installButtonDimensions.width = BUTTON_WIDTH;
installRemoveButton.setPreferredSize(installButtonDimensions);
installRemoveButton.setMaximumSize(installButtonDimensions);
installRemoveButton.setMinimumSize(installButtonDimensions);
installRemoveButton.setOpaque(false);
installRemoveButton.setAlignmentX(CENTER_ALIGNMENT);
JPanel barPane = new JPanel();
barPane.setOpaque(false);
JPanel buttonPane = new JPanel();
buttonPane.setOpaque(false);
buttonPane.add(installRemoveButton);
barButtonCardPane.add(buttonPane, BUTTON_CONSTRAINT);
barButtonCardPane.add(barPane, PROGRESS_BAR_CONSTRAINT);
barButtonCardLayout.show(barButtonCardPane, BUTTON_CONSTRAINT);
rightPane.add(barButtonCardPane);
// Set the minimum size of this pane to be the sum of the height of the
// progress bar and install button
Dimension dim = new Dimension(BUTTON_WIDTH, installRemoveButton.getPreferredSize().height);
rightPane.setMinimumSize(dim);
rightPane.setPreferredSize(dim);
}
use of javax.swing.event.HyperlinkListener in project android by JetBrains.
the class ServicePanelBuilder method addLink.
public HyperlinkLabel addLink(@NotNull String text, @NotNull final URI uri) {
HyperlinkLabel linkLabel = new HyperlinkLabel(text);
linkLabel.addHyperlinkListener(new HyperlinkListener() {
@Override
public void hyperlinkUpdate(HyperlinkEvent e) {
try {
Desktop.getDesktop().browse(uri);
} catch (IOException e1) {
// Don't care
}
}
});
addComponent(linkLabel);
return linkLabel;
}
use of javax.swing.event.HyperlinkListener in project android by JetBrains.
the class ManifestPanel method createDetailsPane.
private JEditorPane createDetailsPane(@NotNull final AndroidFacet facet) {
JEditorPane details = new JEditorPane();
details.setMargin(JBUI.insets(5));
details.setContentType(UIUtil.HTML_MIME);
details.setEditable(false);
details.setFont(myDefaultFont);
details.setBackground(myBackgroundColor);
HyperlinkListener hyperLinkListener = e -> {
if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
String url = e.getDescription();
myHtmlLinkManager.handleUrl(url, facet.getModule(), null, null, null);
}
};
details.addHyperlinkListener(hyperLinkListener);
return details;
}
use of javax.swing.event.HyperlinkListener in project intellij-plugins by JetBrains.
the class FlexBaseRunner method checkDebuggerFromSdk4.
private static void checkDebuggerFromSdk4(final Project project, final RunProfile runProfile, final FlashRunnerParameters params, final FlexBuildConfiguration bc) {
final Sdk sdk = bc.getSdk();
assert sdk != null;
final Sdk sdkForDebugger = FlexDebugProcess.getDebuggerSdk(params.getDebuggerSdkRaw(), sdk);
if (!FlexSdkUtils.isAirSdkWithoutFlex(sdk) && StringUtil.compareVersionNumbers(sdkForDebugger.getVersionString(), "4") < 0) {
final HyperlinkListener listener = new HyperlinkAdapter() {
@Override
protected void hyperlinkActivated(final HyperlinkEvent e) {
if ("RunConfiguration".equals(e.getDescription())) {
for (RunnerAndConfigurationSettings configuration : RunManager.getInstance(project).getConfigurationSettingsList(((RunConfiguration) runProfile).getType())) {
if (configuration.getConfiguration() == runProfile) {
RunDialog.editConfiguration(project, configuration, FlexBundle.message("edit.configuration.title"));
break;
}
}
}
}
};
final String message = FlexBundle.message("flex.sdk.3.mac.debug.problem", sdkForDebugger.getVersionString());
ToolWindowManager.getInstance(project).notifyByBalloon(ToolWindowId.DEBUG, MessageType.WARNING, message, null, listener);
}
}
use of javax.swing.event.HyperlinkListener in project intellij-community by JetBrains.
the class SheetController method createSheetPanel.
private JPanel createSheetPanel(String title, String message, JButton[] buttons) {
JPanel sheetPanel = new JPanel() {
@Override
protected void paintComponent(@NotNull Graphics g2d) {
final Graphics2D g = (Graphics2D) g2d.create();
super.paintComponent(g);
g.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, getSheetAlpha()));
g.setColor(new JBColor(Gray._230, UIUtil.getPanelBackground()));
Rectangle2D dialog = new Rectangle2D.Double(SHADOW_BORDER, 0, SHEET_WIDTH, SHEET_HEIGHT);
paintShadow(g);
// draw the sheet background
if (UIUtil.isUnderDarcula()) {
g.fillRoundRect((int) dialog.getX(), (int) dialog.getY() - 5, (int) dialog.getWidth(), (int) (5 + dialog.getHeight()), 5, 5);
} else {
//todo make bottom corners
g.fill(dialog);
}
paintShadowFromParent(g);
}
};
sheetPanel.setOpaque(false);
sheetPanel.setLayout(null);
JPanel ico = new JPanel() {
@Override
protected void paintComponent(@NotNull Graphics g) {
super.paintComponent(g);
myIcon.paintIcon(this, g, 0, 0);
}
};
JEditorPane headerLabel = new JEditorPane();
headerLabel.putClientProperty(JEditorPane.HONOR_DISPLAY_PROPERTIES, Boolean.TRUE);
headerLabel.setFont(UIUtil.getLabelFont().deriveFont(Font.BOLD));
headerLabel.setEditable(false);
headerLabel.setContentType("text/html");
headerLabel.setSize(250, Short.MAX_VALUE);
headerLabel.setText(title);
headerLabel.setSize(250, headerLabel.getPreferredSize().height);
headerLabel.setOpaque(false);
headerLabel.setFocusable(false);
sheetPanel.add(headerLabel);
headerLabel.repaint();
messageTextPane.putClientProperty(JEditorPane.HONOR_DISPLAY_PROPERTIES, Boolean.TRUE);
Font font = UIUtil.getLabelFont(UIUtil.FontSize.SMALL);
messageTextPane.setFont(font);
messageTextPane.setEditable(false);
messageTextPane.setContentType("text/html");
messageTextPane.addHyperlinkListener(new HyperlinkListener() {
@Override
public void hyperlinkUpdate(HyperlinkEvent he) {
if (he.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
if (Desktop.isDesktopSupported()) {
try {
URL url = he.getURL();
if (url != null) {
Desktop.getDesktop().browse(url.toURI());
} else {
LOG.warn("URL is null; HyperlinkEvent: " + he.toString());
}
} catch (IOException | URISyntaxException e) {
LOG.error(e);
}
}
}
}
});
FontMetrics fontMetrics = sheetPanel.getFontMetrics(font);
int widestWordWidth = 250;
String[] words = (message == null) ? ArrayUtil.EMPTY_STRING_ARRAY : message.split(SPACE_OR_LINE_SEPARATOR_PATTERN);
for (String word : words) {
widestWordWidth = Math.max(fontMetrics.stringWidth(word), widestWordWidth);
}
messageTextPane.setSize(widestWordWidth, Short.MAX_VALUE);
messageTextPane.setText(handleBreaks(message));
messageArea.setSize(widestWordWidth, messageTextPane.getPreferredSize().height);
SHEET_WIDTH = Math.max(LEFT_SHEET_OFFSET + widestWordWidth + RIGHT_OFFSET, SHEET_WIDTH);
messageTextPane.setSize(messageArea);
messageTextPane.setOpaque(false);
messageTextPane.setFocusable(false);
sheetPanel.add(messageTextPane);
messageTextPane.repaint();
ico.setOpaque(false);
ico.setSize(new Dimension(AllIcons.Logo_welcomeScreen.getIconWidth(), AllIcons.Logo_welcomeScreen.getIconHeight()));
ico.setLocation(LEFT_SHEET_PADDING, TOP_SHEET_PADDING);
sheetPanel.add(ico);
headerLabel.setLocation(LEFT_SHEET_OFFSET, TOP_SHEET_PADDING);
messageTextPane.setLocation(LEFT_SHEET_OFFSET, TOP_SHEET_PADDING + headerLabel.getPreferredSize().height + GAP_BETWEEN_LINES);
SHEET_HEIGHT = TOP_SHEET_PADDING + headerLabel.getPreferredSize().height + GAP_BETWEEN_LINES + messageArea.height + GAP_BETWEEN_LINES;
if (myDoNotAskOption != null) {
layoutDoNotAskCheckbox(sheetPanel);
}
layoutWithAbsoluteLayout(buttons, sheetPanel);
int BOTTOM_SHEET_PADDING = 10;
SHEET_HEIGHT += BOTTOM_SHEET_PADDING;
if (SHEET_HEIGHT < SHEET_MINIMUM_HEIGHT) {
SHEET_HEIGHT = SHEET_MINIMUM_HEIGHT;
shiftButtonsToTheBottom(SHEET_MINIMUM_HEIGHT - SHEET_HEIGHT);
}
sheetPanel.setFocusCycleRoot(true);
recalculateShadow();
sheetPanel.setSize(SHEET_NC_WIDTH, SHEET_NC_HEIGHT);
return sheetPanel;
}
Aggregations