/** * @param itemName * the name of this specific item in the GUI, which may be used to determine how the skinned * item should look or behave. * * @return * a <code>SkinnedJLabel</code> class implementation for the current skin, or a default * JHtmlLabel if no skin-specific implementation is available. */ public JHtmlLabel createSkinnedJHtmlLabel(String itemName, HyperlinkActivatedListener hyperlinkListener) { Object instance = instantiateClass(buildSkinnedClassName("SkinnedJHtmlLabel"), itemName); if (instance != null) { JHtmlLabel label = (JHtmlLabel) instance; label.setHyperlinkeActivatedListener(hyperlinkListener); return label; } else { return new JHtmlLabel(hyperlinkListener); } }
/** * * @param htmlText * the html text to display in the label. This text doesn't necessarily have to be HTML, * but why would you use this control if it isn't? * @param listener * a listener responsible for following an href link if it is triggered. */ public JHtmlLabel(String htmlText, HyperlinkActivatedListener listener) { super(); if (htmlText != null) { this.setText(htmlText); } if (listener != null) { setHyperlinkeActivatedListener(listener); } addMouseListener(this); addMouseMotionListener(this); }
/** * Changes the mouse cursor to a hand to indicate when the mouse moves over a clickable * HTML link. * * @param e event */ public void mouseMoved(MouseEvent e) { AccessibleJLabel acc = (AccessibleJLabel) getAccessibleContext(); int stringIndexAtPoint = acc.getIndexAtPoint(e.getPoint()); if (stringIndexAtPoint < 0) { return; } javax.swing.text.AttributeSet attr = acc.getCharacterAttribute(stringIndexAtPoint); if (attr.getAttribute(HTML.Tag.A) == null) { setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); } else { setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); } }
+ "Select a bucket in the <b>Log to</b> list to apply changes<br><b>Note</b>: The target " + "bucket's ACL permissions are updated if necessary to allow logging<p> </center></html>"; JHtmlLabel introductionLabel = new JHtmlLabel(introductionText, hyperlinkListener); introductionLabel.setHorizontalAlignment(JLabel.CENTER); JHtmlLabel loggingStatusLabel = new JHtmlLabel("<html><b>Logging status</b></html>", hyperlinkListener); loggingStatusLabel.setHorizontalAlignment(JLabel.CENTER); JHtmlLabel loggedBucketLabel = new JHtmlLabel("Bucket:", hyperlinkListener); loggedBucketComboBox = new JComboBox(bucketNames); loggedBucketComboBox.insertItemAt("-- Choose a bucket --", 0); loggedBucketComboBox.addActionListener(this); JHtmlLabel prefixLabel = new JHtmlLabel("Log file prefix:", hyperlinkListener); prefixTextField = new JTextField(); prefixTextField.setToolTipText("Log files for the bucket start with this prefix. The prefix cannot be empty"); JHtmlLabel loggedToBucketLabel = new JHtmlLabel("Log to:", hyperlinkListener); loggedToBucketComboBox = new JComboBox(bucketNames); loggedToBucketComboBox.setToolTipText("Where the bucket's log files will be stored");
messageLabel.setText(message); messageLabel.setHorizontalAlignment(JLabel.CENTER); JHtmlLabel detailsLabel = skinsFactory .createSkinnedJHtmlLabel("ErrorDetailsLabel", hyperlinkListener); detailsLabel.setText(details);
footerLabel.setHyperlinkeActivatedListener(this); footerLabel.setHorizontalAlignment(JLabel.CENTER); if (footerHtml != null) { footerLabel.setText(replaceMessageVariables(footerHtml)); includeFooter = true; screen2Panel.setLayout(GRID_BAG_LAYOUT); dragDropTargetLabel = skinsFactory.createSkinnedJHtmlLabel("DragDropTargetLabel"); dragDropTargetLabel.setHyperlinkeActivatedListener(this); dragDropTargetLabel.setHorizontalAlignment(JLabel.CENTER); dragDropTargetLabel.setVerticalAlignment(JLabel.CENTER); screen3Panel.setLayout(GRID_BAG_LAYOUT); fileToUploadLabel = skinsFactory.createSkinnedJHtmlLabel("FileToUploadLabel"); fileToUploadLabel.setHyperlinkeActivatedListener(this); fileToUploadLabel.setHorizontalAlignment(JLabel.CENTER); fileToUploadLabel.setVerticalAlignment(JLabel.CENTER); screen3Panel.add(fileToUploadLabel, new GridBagConstraints(0, 0, 1, 1, 1, 1, GridBagConstraints.CENTER, GridBagConstraints.BOTH, insetsDefault, 0, 0)); screen4Panel.setLayout(GRID_BAG_LAYOUT); fileInformationLabel = skinsFactory.createSkinnedJHtmlLabel("FileInformationLabel"); fileInformationLabel.setHyperlinkeActivatedListener(this); fileInformationLabel.setHorizontalAlignment(JLabel.CENTER); progressBar = skinsFactory.createSkinnedJProgressBar("ProgressBar", 0, 100); progressBar.setStringPainted(true); progressStatusTextLabel = skinsFactory.createSkinnedJHtmlLabel("ProgressStatusTextLabel"); progressStatusTextLabel.setHyperlinkeActivatedListener(this); progressStatusTextLabel.setText(" ");
public void run() { progressStatusTextLabel.setText(replaceMessageVariables(statusText)); progressBar.setValue(0); } });
/** * Triggers the listener to follow an HTML href link that has been clicked. * * @param e event */ public void mouseClicked(MouseEvent e) { AccessibleJLabel acc = (AccessibleJLabel) getAccessibleContext(); int stringIndexAtPoint = acc.getIndexAtPoint(e.getPoint()); if (stringIndexAtPoint < 0) { return; } AttributeSet attr = (AttributeSet) acc.getCharacterAttribute( acc.getIndexAtPoint(e.getPoint())).getAttribute(HTML.Tag.A); if (attr != null) { String href = (String) attr.getAttribute(HTML.Attribute.HREF); String target = (String) attr.getAttribute(HTML.Attribute.TARGET); try { if (listener == null) { log.warn("No HyperlinkActivatedListener available to follow HTML link for label: " + getText()); } else { listener.followHyperlink(new URL(href), target); } } catch (Exception ex) { log.error("Unable to load URL: " + href, ex); } } }
label.setText(fieldPrompt); label.setHyperlinkeActivatedListener(hyperlinkListener); fieldsPanel.add(label, new GridBagConstraints(0, fieldIndex++, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, insetsDefault, 0, 0)); label.setText(fieldPrompt); label.setHyperlinkeActivatedListener(hyperlinkListener); fieldsPanel.add(label, new GridBagConstraints(0, fieldIndex++, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, insetsDefault, 0, 0)); label.setText(fieldPrompt); label.setHyperlinkeActivatedListener(hyperlinkListener); fieldsPanel.add(label, new GridBagConstraints(0, fieldIndex++, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, insetsDefault, 0, 0)); } else if ("text".equals(fieldType)) { JHtmlLabel label = skinsFactory.createSkinnedJHtmlLabel(fieldName); label.setText(fieldPrompt); label.setHyperlinkeActivatedListener(hyperlinkListener); fieldsPanel.add(label, new GridBagConstraints(0, fieldIndex++, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, insetsDefault, 0, 0)); } else if ("password".equals(fieldType)) { JHtmlLabel label = skinsFactory.createSkinnedJHtmlLabel(fieldName); label.setText(fieldPrompt); label.setHyperlinkeActivatedListener(hyperlinkListener); fieldsPanel.add(label, new GridBagConstraints(0, fieldIndex++, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, insetsDefault, 0, 0));
JHtmlLabel questionLabel = new JHtmlLabel(question, null); container.add(questionLabel, new GridBagConstraints(0, rowIndex++, 2, 1, 0, 0, GridBagConstraints.CENTER, GridBagConstraints.NONE, insetsDefault, 0, 0));
public void mouseDragged(MouseEvent e) { mouseMoved(e); }
JHtmlLabel introductionLabel = new JHtmlLabel(introductionText, hyperlinkListener); introductionLabel.setHorizontalAlignment(JLabel.CENTER); JHtmlLabel expiryTimeLabel = new JHtmlLabel("<html><b>Expiry Time</b> (Hours)</html>", hyperlinkListener); expiryTimeLabel.setHorizontalAlignment(JLabel.RIGHT); JHtmlLabel httpsUrlsLabel = new JHtmlLabel("<html><b>Secure HTTPS URLs?</b></html>", hyperlinkListener); httpsUrlsLabel.setHorizontalAlignment(JLabel.RIGHT); JHtmlLabel virtualHostLabel = new JHtmlLabel("<html><b>Bucket is a Virtual Host?</b></html>", hyperlinkListener); virtualHostLabel.setHorizontalAlignment(JLabel.RIGHT); JHtmlLabel requesterPaysLabel = new JHtmlLabel("<html><b>Bucket is Requester Pays?</b></html>", hyperlinkListener); requesterPaysLabel.setHorizontalAlignment(JLabel.RIGHT);
messageLabel.setText(message); messageLabel.setHorizontalAlignment(JLabel.CENTER); JHtmlLabel detailsLabel = skinsFactory .createSkinnedJHtmlLabel("ErrorDetailsLabel", hyperlinkListener); detailsLabel.setText(details);
footerLabel.setHyperlinkeActivatedListener(this); footerLabel.setHorizontalAlignment(JLabel.CENTER); if (footerHtml != null) { footerLabel.setText(replaceMessageVariables(footerHtml)); includeFooter = true; screen2Panel.setLayout(GRID_BAG_LAYOUT); dragDropTargetLabel = skinsFactory.createSkinnedJHtmlLabel("DragDropTargetLabel"); dragDropTargetLabel.setHyperlinkeActivatedListener(this); dragDropTargetLabel.setHorizontalAlignment(JLabel.CENTER); dragDropTargetLabel.setVerticalAlignment(JLabel.CENTER); screen3Panel.setLayout(GRID_BAG_LAYOUT); fileToUploadLabel = skinsFactory.createSkinnedJHtmlLabel("FileToUploadLabel"); fileToUploadLabel.setHyperlinkeActivatedListener(this); fileToUploadLabel.setHorizontalAlignment(JLabel.CENTER); fileToUploadLabel.setVerticalAlignment(JLabel.CENTER); screen3Panel.add(fileToUploadLabel, new GridBagConstraints(0, 0, 1, 1, 1, 1, GridBagConstraints.CENTER, GridBagConstraints.BOTH, insetsDefault, 0, 0)); screen4Panel.setLayout(GRID_BAG_LAYOUT); fileInformationLabel = skinsFactory.createSkinnedJHtmlLabel("FileInformationLabel"); fileInformationLabel.setHyperlinkeActivatedListener(this); fileInformationLabel.setHorizontalAlignment(JLabel.CENTER); progressBar = skinsFactory.createSkinnedJProgressBar("ProgressBar", 0, 100); progressBar.setStringPainted(true); progressStatusTextLabel = skinsFactory.createSkinnedJHtmlLabel("ProgressStatusTextLabel"); progressStatusTextLabel.setHyperlinkeActivatedListener(this); progressStatusTextLabel.setText(" ");
public void run() { progressStatusTextLabel.setText(replaceMessageVariables(statusText)); progressBar.setValue(0); } });
/** * Triggers the listener to follow an HTML href link that has been clicked. * * @param e event */ public void mouseClicked(MouseEvent e) { AccessibleJLabel acc = (AccessibleJLabel) getAccessibleContext(); int stringIndexAtPoint = acc.getIndexAtPoint(e.getPoint()); if (stringIndexAtPoint < 0) { return; } AttributeSet attr = (AttributeSet) acc.getCharacterAttribute( acc.getIndexAtPoint(e.getPoint())).getAttribute(HTML.Tag.A); if (attr != null) { String href = (String) attr.getAttribute(HTML.Attribute.HREF); String target = (String) attr.getAttribute(HTML.Attribute.TARGET); try { if (listener == null) { log.warn("No HyperlinkActivatedListener available to follow HTML link for label: " + getText()); } else { listener.followHyperlink(new URL(href), target); } } catch (Exception ex) { log.error("Unable to load URL: " + href, ex); } } }
label.setText(fieldPrompt); label.setHyperlinkeActivatedListener(hyperlinkListener); fieldsPanel.add(label, new GridBagConstraints(0, fieldIndex++, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, insetsDefault, 0, 0)); label.setText(fieldPrompt); label.setHyperlinkeActivatedListener(hyperlinkListener); fieldsPanel.add(label, new GridBagConstraints(0, fieldIndex++, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, insetsDefault, 0, 0)); label.setText(fieldPrompt); label.setHyperlinkeActivatedListener(hyperlinkListener); fieldsPanel.add(label, new GridBagConstraints(0, fieldIndex++, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, insetsDefault, 0, 0)); } else if ("text".equals(fieldType)) { JHtmlLabel label = skinsFactory.createSkinnedJHtmlLabel(fieldName); label.setText(fieldPrompt); label.setHyperlinkeActivatedListener(hyperlinkListener); fieldsPanel.add(label, new GridBagConstraints(0, fieldIndex++, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, insetsDefault, 0, 0)); } else if ("password".equals(fieldType)) { JHtmlLabel label = skinsFactory.createSkinnedJHtmlLabel(fieldName); label.setText(fieldPrompt); label.setHyperlinkeActivatedListener(hyperlinkListener); fieldsPanel.add(label, new GridBagConstraints(0, fieldIndex++, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, insetsDefault, 0, 0));
JHtmlLabel questionLabel = new JHtmlLabel(question, null); container.add(questionLabel, new GridBagConstraints(0, rowIndex++, 2, 1, 0, 0, GridBagConstraints.CENTER, GridBagConstraints.NONE, insetsDefault, 0, 0));
public void mouseDragged(MouseEvent e) { mouseMoved(e); }
+ "Select a bucket in the <b>Log to</b> list to apply changes<br><b>Note</b>: The target " + "bucket's ACL permissions are updated if necessary to allow logging<p> </center></html>"; JHtmlLabel introductionLabel = new JHtmlLabel(introductionText, hyperlinkListener); introductionLabel.setHorizontalAlignment(JLabel.CENTER); JHtmlLabel loggingStatusLabel = new JHtmlLabel("<html><b>Logging status</b></html>", hyperlinkListener); loggingStatusLabel.setHorizontalAlignment(JLabel.CENTER); JHtmlLabel loggedBucketLabel = new JHtmlLabel("Bucket:", hyperlinkListener); loggedBucketComboBox = new JComboBox(bucketNames); loggedBucketComboBox.insertItemAt("-- Choose a bucket --", 0); loggedBucketComboBox.addActionListener(this); JHtmlLabel prefixLabel = new JHtmlLabel("Log file prefix:", hyperlinkListener); prefixTextField = new JTextField(); prefixTextField.setToolTipText("Log files for the bucket start with this prefix. The prefix cannot be empty"); JHtmlLabel loggedToBucketLabel = new JHtmlLabel("Log to:", hyperlinkListener); loggedToBucketComboBox = new JComboBox(bucketNames); loggedToBucketComboBox.setToolTipText("Where the bucket's log files will be stored");