List of usage examples for javax.swing JLabel setToolTipText
@BeanProperty(bound = false, preferred = true, description = "The text to display in a tool tip.") public void setToolTipText(String text)
From source file:uk.ac.ucl.cs.cmic.giftcloud.uploadapp.ConfigurationDialog.java
ConfigurationDialog(final Component owner, final UploaderGuiController controller, final GiftCloudPropertiesFromApplication giftCloudProperties, final ProjectListModel projectListModel, final ResourceBundle resourceBundle, final GiftCloudDialogs giftCloudDialogs, final GiftCloudReporter reporter) { this.controller = controller; this.giftCloudProperties = giftCloudProperties; this.projectListModel = projectListModel; this.resourceBundle = resourceBundle; this.giftCloudDialogs = giftCloudDialogs; this.reporter = reporter; temporaryDropDownListModel = new TemporaryProjectListModel(projectListModel, giftCloudProperties.getLastProject()); componentToCenterDialogOver = owner; dialog = new JDialog(); dialog.setModal(true);/*from w w w. j a v a 2 s . c o m*/ dialog.setResizable(false); // Call custom dialog close code when the close button is clicked dialog.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE); dialog.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent ev) { closeDialog(); } }); dialog.setLocationRelativeTo(componentToCenterDialogOver); // without this, appears at TLHC rather then center of parent or screen dialog.setTitle(resourceBundle.getString("configurationDialogTitle")); final GridBagConstraints sectionTitleConstraints = new GridBagConstraints(); sectionTitleConstraints.gridx = 0; sectionTitleConstraints.gridy = 1; sectionTitleConstraints.gridwidth = 2; sectionTitleConstraints.weightx = 1; sectionTitleConstraints.weighty = 1; sectionTitleConstraints.anchor = GridBagConstraints.CENTER; sectionTitleConstraints.fill = GridBagConstraints.HORIZONTAL; final GridBagConstraints labelConstraints = new GridBagConstraints(); labelConstraints.gridx = 0; labelConstraints.gridy = 0; labelConstraints.gridwidth = 1; labelConstraints.weightx = 1; labelConstraints.weighty = 1; labelConstraints.anchor = GridBagConstraints.LINE_START; labelConstraints.fill = GridBagConstraints.NONE; final GridBagConstraints inputConstraints = new GridBagConstraints(); inputConstraints.gridx = 1; inputConstraints.gridy = 0; inputConstraints.gridwidth = 1; inputConstraints.weightx = 1; inputConstraints.weighty = 1; inputConstraints.anchor = GridBagConstraints.LINE_END; inputConstraints.fill = GridBagConstraints.HORIZONTAL; GridBagConstraints separatorConstraint = new GridBagConstraints(); separatorConstraint.weightx = 1.0; separatorConstraint.fill = GridBagConstraints.HORIZONTAL; separatorConstraint.gridwidth = GridBagConstraints.REMAINDER; // The panel containing the GIFT-Cloud server configuration final JPanel giftCloudServerPanel = new JPanel(); { GridBagLayout projectUploadlayout = new GridBagLayout(); giftCloudServerPanel.setLayout(projectUploadlayout); JLabel serverPanelLabel = new JLabel(resourceBundle.getString("configPanelServerConfig"), SwingConstants.CENTER); giftCloudServerPanel.add(serverPanelLabel, sectionTitleConstraints); // GIFT-Cloud server URL { labelConstraints.gridwidth = 1; labelConstraints.gridy = 2; final JLabel giftCloudServerLabel = new JLabel(resourceBundle.getString("giftCloudServerText"), SwingConstants.RIGHT); giftCloudServerLabel.setToolTipText(resourceBundle.getString("giftCloudServerTextToolTipText")); giftCloudServerPanel.add(giftCloudServerLabel, labelConstraints); giftCloudServerText = new AutoFocusTextField(giftCloudProperties.getGiftCloudUrl().orElse(""), textFieldLengthForGiftCloudServerUrl); inputConstraints.gridy = 2; giftCloudServerPanel.add(giftCloudServerText, inputConstraints); } // GIFT-Cloud username { labelConstraints.gridy = 3; final JLabel giftCloudUserNameLabel = new JLabel(resourceBundle.getString("giftCloudUsername"), SwingConstants.RIGHT); giftCloudUserNameLabel.setToolTipText(resourceBundle.getString("giftCloudUsernameToolTipText")); giftCloudServerPanel.add(giftCloudUserNameLabel, labelConstraints); final Optional<String> serverUrl = giftCloudProperties.getLastUserName(); final String initialServerText = serverUrl.isPresent() ? serverUrl.get() : ""; giftCloudUsernameText = new AutoFocusTextField(initialServerText); inputConstraints.gridy = 3; giftCloudServerPanel.add(giftCloudUsernameText, inputConstraints); } // GIFT-Cloud password { labelConstraints.gridy = 4; final JLabel giftCloudPasswordLabel = new JLabel(resourceBundle.getString("giftCloudPassword"), SwingConstants.RIGHT); giftCloudPasswordLabel.setToolTipText(resourceBundle.getString("giftCloudPasswordToolTipText")); giftCloudServerPanel.add(giftCloudPasswordLabel, labelConstraints); final Optional<char[]> password = giftCloudProperties.getLastPassword(); final char[] initialPassword = password.isPresent() ? password.get() : "".toCharArray(); giftCloudPasswordText = new JPasswordField(new String(initialPassword), 16); // Shouldn't create a String but there's no other way to initialize the password field inputConstraints.gridy = 4; giftCloudServerPanel.add(giftCloudPasswordText, inputConstraints); } // Project list { labelConstraints.gridy = 5; JLabel projectListLabel = new JLabel(resourceBundle.getString("giftCloudProjectLabelText"), SwingConstants.RIGHT); giftCloudServerPanel.add(projectListLabel, labelConstraints); inputConstraints.gridy = 5; projectList = new BackwardsCompatibleComboBox(); projectList.setEditable(false); projectList.setToolTipText(resourceBundle.getString("giftCloudProjectTooltip")); giftCloudServerPanel.add(projectList, inputConstraints); labelConstraints.gridx = 1; projectListWaitingLabel = new JLabel(resourceBundle.getString("giftCloudProjectWaitingLabelText"), SwingConstants.RIGHT); giftCloudServerPanel.add(projectListWaitingLabel, labelConstraints); labelConstraints.gridx = 0; } // Subject prefix { labelConstraints.gridy = 6; JLabel subjectPrefixLabel = new JLabel(resourceBundle.getString("configPanelListenerSubjectPrefix"), SwingConstants.RIGHT); subjectPrefixLabel .setToolTipText(resourceBundle.getString("configPanelListenerSubjectPrefixTooltip")); giftCloudServerPanel.add(subjectPrefixLabel, labelConstraints); inputConstraints.gridy = 6; final Optional<String> subjectPrefixText = giftCloudProperties.getSubjectPrefix(); subjectPrefixField = new AutoFocusTextField(subjectPrefixText.orElse("")); giftCloudServerPanel.add(subjectPrefixField, inputConstraints); } } // Local Dicom node configuration final JPanel listenerPanel = new JPanel(); { GridBagLayout listenerPanellayout = new GridBagLayout(); listenerPanel.setLayout(listenerPanellayout); JSeparator separator = new JSeparator(); listenerPanel.add(separator, separatorConstraint); JLabel listenerPanelLabel = new JLabel(resourceBundle.getString("configPanelListenerConfig"), SwingConstants.CENTER); listenerPanel.add(listenerPanelLabel, sectionTitleConstraints); { labelConstraints.gridy = 2; JLabel listeningAETitleJLabel = new JLabel(resourceBundle.getString("configPanelListenerAe"), SwingConstants.RIGHT); listeningAETitleJLabel.setToolTipText(resourceBundle.getString("configPanelListenerAeToolTip")); listenerPanellayout.setConstraints(listeningAETitleJLabel, labelConstraints); listenerPanel.add(listeningAETitleJLabel); inputConstraints.gridy = 2; final String listeningAETitleInitialText = giftCloudProperties.getListenerAETitle(); listeningAETitleField = new AutoFocusTextField(listeningAETitleInitialText); listenerPanellayout.setConstraints(listeningAETitleField, inputConstraints); listenerPanel.add(listeningAETitleField); } { labelConstraints.gridy = 3; JLabel listeningPortJLabel = new JLabel(resourceBundle.getString("configPanelListenerPort"), SwingConstants.RIGHT); listeningPortJLabel.setToolTipText(resourceBundle.getString("configPanelListenerPortToolTip")); listenerPanellayout.setConstraints(listeningPortJLabel, labelConstraints); listenerPanel.add(listeningPortJLabel); inputConstraints.gridy = 3; final int port = giftCloudProperties.getListeningPort(); final String portValue = Integer.toString(port); listeningPortField = new AutoFocusTextField(portValue); listenerPanellayout.setConstraints(listeningPortField, inputConstraints); listenerPanel.add(listeningPortField); } { labelConstraints.gridy = 4; JLabel patientListExportFolderLabel = new JLabel( resourceBundle.getString("configPanelListenerPatientListExportFolder"), SwingConstants.RIGHT); patientListExportFolderLabel.setToolTipText( resourceBundle.getString("configPanelListenerPatientListExportFolderTooltip")); listenerPanellayout.setConstraints(patientListExportFolderLabel, labelConstraints); listenerPanel.add(patientListExportFolderLabel); inputConstraints.gridy = 4; final Optional<String> patientListExportFolder = giftCloudProperties.getPatientListExportFolder(); patientListExportFolderField = new AutoFocusTextField(patientListExportFolder.orElse("")); listenerPanellayout.setConstraints(patientListExportFolderField, inputConstraints); listenerPanel.add(patientListExportFolderField); } // Patient list spreadsheet password { labelConstraints.gridy = 5; final JLabel patientListSpreadsheetPasswordLabel = new JLabel( resourceBundle.getString("configPanelListenerPatientListSpreadhsheetPassword"), SwingConstants.RIGHT); patientListSpreadsheetPasswordLabel.setToolTipText( resourceBundle.getString("configPanelListenerPatientListSpreadhsheetPasswordTooltip")); listenerPanel.add(patientListSpreadsheetPasswordLabel, labelConstraints); final Optional<char[]> password = giftCloudProperties.getPatientListPassword(); final char[] initialPassword = password.isPresent() ? password.get() : "".toCharArray(); patientListSpreadsheetPasswordField = new JPasswordField(new String(initialPassword), 16); // Shouldn't create a String but there's no other way to initialize the password field inputConstraints.gridy = 5; listenerPanel.add(patientListSpreadsheetPasswordField, inputConstraints); } } // Remote PACS configuration final JPanel remoteAEPanel = new JPanel(); { GridBagLayout pacsPanellayout = new GridBagLayout(); remoteAEPanel.setLayout(pacsPanellayout); JSeparator separator = new JSeparator(); remoteAEPanel.add(separator, separatorConstraint); JLabel remotePanelLabel = new JLabel(resourceBundle.getString("pacsPanelListenerConfig"), SwingConstants.CENTER); remoteAEPanel.add(remotePanelLabel, sectionTitleConstraints); { labelConstraints.gridy = 2; JLabel remoteAeTitleLabel = new JLabel(resourceBundle.getString("configPanelPacsAeTitle"), SwingConstants.RIGHT); remoteAeTitleLabel.setToolTipText(resourceBundle.getString("configPanelPacsAeTitleTooltip")); remoteAEPanel.add(remoteAeTitleLabel, labelConstraints); final Optional<String> pacsAeTitle = giftCloudProperties.getPacsAeTitle(); remoteAETitleField = new AutoFocusTextField(pacsAeTitle.isPresent() ? pacsAeTitle.get() : ""); inputConstraints.gridy = 2; remoteAEPanel.add(remoteAETitleField, inputConstraints); } { labelConstraints.gridy = 3; JLabel remoteAeHostLabel = new JLabel(resourceBundle.getString("configPanelPacsHostname"), SwingConstants.RIGHT); remoteAeHostLabel.setToolTipText(resourceBundle.getString("configPanelPacsHostnameTooltip")); remoteAEPanel.add(remoteAeHostLabel, labelConstraints); remoteAEHostName = new AutoFocusTextField(giftCloudProperties.getPacsHostName().orElse("")); inputConstraints.gridy = 3; remoteAEPanel.add(remoteAEHostName, inputConstraints); } { labelConstraints.gridy = 4; JLabel remoteAeTitleLabel = new JLabel(resourceBundle.getString("configPanelPacsPort"), SwingConstants.RIGHT); remoteAeTitleLabel.setToolTipText(resourceBundle.getString("configPanelPacsPortTooltip")); remoteAEPanel.add(remoteAeTitleLabel, labelConstraints); remoteAEPortField = new AutoFocusTextField(Integer.toString(giftCloudProperties.getPacsPort())); inputConstraints.gridy = 4; remoteAEPanel.add(remoteAEPortField, inputConstraints); } } // The panel containing the cancel and apply buttons JPanel buttonPanel = new JPanel(); JPanel closeButtonPanel = new JPanel(); { final GridBagLayout buttonPanellayout = new GridBagLayout(); buttonPanel.setLayout(buttonPanellayout); JSeparator separator = new JSeparator(); buttonPanel.add(separator, separatorConstraint); closeButtonPanel.setLayout(new FlowLayout(FlowLayout.RIGHT)); JButton cancelButton = new JButton(resourceBundle.getString("cancelSettingsButtonLabelText")); cancelButton.setToolTipText(resourceBundle.getString("cancelSettingsButtonToolTipText")); closeButtonPanel.add(cancelButton); cancelButton.addActionListener(new CancelActionListener()); JButton applyButton = new JButton(resourceBundle.getString("applySettingsButtonLabelText")); applyButton.setToolTipText(resourceBundle.getString("applySettingsButtonToolTipText")); closeButtonPanel.add(applyButton); applyButton.addActionListener(new ApplyActionListener()); JButton closeButton = new JButton(resourceBundle.getString("closeSettingsButtonLabelText")); closeButton.setToolTipText(resourceBundle.getString("closeSettingsButtonToolTipText")); closeButtonPanel.add(closeButton); closeButton.addActionListener(new CloseActionListener()); final GridBagConstraints constraints = new GridBagConstraints(); constraints.gridx = 0; constraints.gridy = 1; constraints.weightx = 1; constraints.weighty = 1; constraints.insets = new Insets(5, 5, 5, 5); constraints.fill = GridBagConstraints.HORIZONTAL; buttonPanellayout.setConstraints(closeButtonPanel, constraints); buttonPanel.add(closeButtonPanel); } // The main panel of the configuration dialog JPanel configPanel = new JPanel(); { final GridBagLayout configPanelLayout = new GridBagLayout(); configPanel.setLayout(configPanelLayout); { final GridBagConstraints constraints = new GridBagConstraints(); constraints.gridx = 0; constraints.gridy = 0; constraints.weightx = 1; constraints.weighty = 1; constraints.insets = new Insets(5, 5, 5, 5); constraints.fill = GridBagConstraints.HORIZONTAL; configPanelLayout.setConstraints(giftCloudServerPanel, constraints); configPanel.add(giftCloudServerPanel); } { final GridBagConstraints constraints = new GridBagConstraints(); constraints.gridx = 0; constraints.gridy = 1; constraints.weightx = 1; constraints.weighty = 1; constraints.insets = new Insets(5, 5, 5, 5); constraints.fill = GridBagConstraints.HORIZONTAL; configPanelLayout.setConstraints(listenerPanel, constraints); configPanel.add(listenerPanel); } { final GridBagConstraints constraints = new GridBagConstraints(); constraints.gridx = 0; constraints.gridy = 2; constraints.insets = new Insets(5, 5, 5, 5); constraints.fill = GridBagConstraints.HORIZONTAL; configPanelLayout.setConstraints(remoteAEPanel, constraints); configPanel.add(remoteAEPanel); } { final GridBagConstraints constraints = new GridBagConstraints(); constraints.gridx = 0; constraints.gridy = 3; constraints.insets = new Insets(5, 5, 5, 5); constraints.fill = GridBagConstraints.HORIZONTAL; configPanelLayout.setConstraints(buttonPanel, constraints); configPanel.add(buttonPanel); } } projectList.setModel(temporaryDropDownListModel); showProjectList(projectListModel.isEnabled()); // Create a listener to enable/disable the project list when it is set from the server. // The reason for this is that the project list is set after logging into the server, which can happen asynchronously after property changes have been applied. // If the server was configured in the dialog and apply clicked, it might take a few seconds for the project list to be updated, and we want it to become available when this happens projectListEnabledListener = new DropDownListModel.EnabledListener<Boolean>() { @Override public void statusChanged(final Boolean visibility) { showProjectList(projectListModel.isEnabled()); } }; projectListModel.addListener(projectListEnabledListener); GridBagLayout layout = new GridBagLayout(); dialog.setLayout(layout); Container content = dialog.getContentPane(); content.add(configPanel); dialog.pack(); dialog.setVisible(true); dialog.pack(); }
From source file:uk.nhs.cfh.dsp.yasb.searchpanel.renderer.SearchResultListCellRenderer.java
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean hasFocus) { JLabel label = new JLabel(); label.setOpaque(true);// www . j a v a 2 s . c om if (value instanceof Document) { // get field that has value of the fully specified name Document doc = (Document) value; if (isRenderConceptId()) { label.setText("<html><b>" + doc.get("TERM") + "</b><font color=\"eee\">|" + doc.get("CONCEPTID") + "|</font></html>"); } else { label.setText("<html><b>" + doc.get("TERM") + "</b></html>"); } // set icon based on status String status = doc.get("STATUS"); if ("limited".equalsIgnoreCase(status)) { label.setIcon(limitedStatusIcon); } else if ("duplicate".equalsIgnoreCase(status)) { label.setIcon(duplicateStatusIcon); } else if ("ambiguous".equalsIgnoreCase(status)) { label.setIcon(ambiguousStatusIcon); } else { label.setIcon(currentStatusIcon); } // always set tooltip to FSN + concept id label.setToolTipText("<html><b>" + doc.get("TERM") + "</b><font color=\"eee\">|" + doc.get("CONCEPTID") + "|</font></html>"); } if (isSelected) { label.setBackground(UIManager.getColor("Tree.selectionbackground")); } else { label.setBackground(UIManager.getColor("Tree.background")); } return label; }
From source file:util.program.ProgramTextCreator.java
/** * * @param prog//from w ww .j a va2 s.com * The Program to show * @param doc * The HTMLDocument. * @param fieldArr * The object array with the field types. * @param tFont * The title Font. * @param bFont * The body Font. * @param settings * Settings of the ProgramPanel * @param showHelpLinks * Show the Help-Links (Quality of Data, ShowView) * @param zoom * The zoom value for the picture. * @param showPluginIcons * If the plugin icons should be shown. * @return The HTML String. * @since 3.0 */ public static String createInfoText(Program prog, ExtendedHTMLDocument doc, Object[] fieldArr, Font tFont, Font bFont, ProgramPanelSettings settings, boolean showHelpLinks, int zoom, boolean showPluginIcons, boolean showPersonLinks) { String debugTables = "0"; //set to "1" for debugging, to "0" for no debugging try { // NOTE: All field types are included until type 25 (REPETITION_ON_TYPE) StringBuilder buffer = new StringBuilder(1024); String titleFont, titleSize, bodyFont; int bodyStyle; int titleStyle; if (tFont == null && bFont != null) { titleFont = bodyFont = bFont.getFamily(); titleSize = mBodyFontSize = String.valueOf(bFont.getSize()); titleStyle = bodyStyle = bFont.getStyle(); } else if (tFont != null && bFont != null) { titleFont = tFont.getFamily(); bodyFont = bFont.getFamily(); titleSize = String.valueOf(tFont.getSize()); mBodyFontSize = String.valueOf(bFont.getSize()); titleStyle = tFont.getStyle(); bodyStyle = bFont.getStyle(); } else { return null; } if (fieldArr == null) { return null; } buffer.append("<html>"); buffer.append("<table width=\"100%\" border=\"" + debugTables + "\" style=\"font-family:"); buffer.append(bodyFont); buffer.append(";").append(getCssStyle(bodyStyle)).append("\"><tr>"); buffer.append("<td width=\"60\">"); buffer.append("<p \"align=center\">"); JLabel channelLogo = new JLabel(prog.getChannel().getIcon()); channelLogo.setToolTipText(prog.getChannel().getName()); buffer.append(doc.createCompTag(channelLogo)); buffer.append( "</p></td><td><table width=\"100%\" border=\"" + debugTables + "\" cellpadding=\"0\"><tr><td>"); buffer.append("<div style=\"color:#ff0000; font-size:"); buffer.append(mBodyFontSize); buffer.append(";\"><b>"); Date currentDate = Date.getCurrentDate(); Date programDate = prog.getDate(); if (programDate.equals(currentDate.addDays(-1))) { buffer.append(Localizer.getLocalization(Localizer.I18N_YESTERDAY)); buffer.append(" "); } else if (programDate.equals(currentDate)) { buffer.append(Localizer.getLocalization(Localizer.I18N_TODAY)); buffer.append(" "); } else if (programDate.equals(currentDate.addDays(1))) { buffer.append(Localizer.getLocalization(Localizer.I18N_TOMORROW)); buffer.append(" "); } buffer.append(prog.getDateString()); buffer.append(" "); buffer.append(prog.getTimeString()); if (prog.getLength() > 0) { buffer.append('-'); buffer.append(prog.getEndTimeString()); } buffer.append(" "); buffer.append(prog.getChannel()); buffer.append("</b></div><div style=\"color:#003366; font-size:"); buffer.append(titleSize); buffer.append("; line-height:2.5em; font-family:"); buffer.append(titleFont).append(";").append(getCssStyle(titleStyle)); buffer.append("\">"); buffer.append(prog.getTitle()); buffer.append("</div>"); String episode = CompoundedProgramFieldType.EPISODE_COMPOSITION.getFormattedValueForProgram(prog); if (episode != null && episode.trim().length() > 0) { buffer.append("<div style=\"color:#808080; font-size:"); buffer.append(mBodyFontSize); buffer.append("\">"); buffer.append(episode); buffer.append("</div>"); } buffer.append("</td><td align=\"right\" valign=\"top\"><table border=\"" + debugTables + "\"><tr><td>"); JButton btn = new JButton(TVBrowserIcons.left(TVBrowserIcons.SIZE_SMALL)); buffer.append(doc.createCompTag(btn)); btn.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { ProgramInfo.getInstance().historyBack(); } }); btn.setEnabled(ProgramInfo.getInstance().canNavigateBack()); btn.setToolTipText(ProgramInfo.getInstance().navigationBackwardText()); buffer.append("</td><td>"); btn = new JButton(TVBrowserIcons.right(TVBrowserIcons.SIZE_SMALL)); buffer.append(doc.createCompTag(btn)); btn.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { ProgramInfo.getInstance().historyForward(); } }); btn.setEnabled(ProgramInfo.getInstance().canNavigateForward()); btn.setToolTipText(ProgramInfo.getInstance().navigationForwardText()); buffer.append("</td></tr></table></td></tr></table></td></tr>"); boolean show = false; if (settings.isShowingPictureForPlugins()) { String[] pluginIds = settings.getPluginIds(); Marker[] markers = prog.getMarkerArr(); if (markers != null && pluginIds != null) { for (Marker marker : markers) { for (String pluginId : pluginIds) { if (marker.getId().compareTo(pluginId) == 0) { show = true; break; } } } } } Color foreground = Color.black;//Settings.propProgramPanelForegroundColor.getColor(); if (settings.isShowingPictureEver() || (settings.isShowingPictureInTimeRange() && !ProgramUtilities.isNotInTimeRange(settings.getPictureTimeRangeStart(), settings.getPictureTimeRangeEnd(), prog)) || show || (settings.isShowingPictureForDuration() && settings.getDuration() <= prog.getLength())) { byte[] image = prog.getBinaryField(ProgramFieldType.PICTURE_TYPE); if (image != null) { String line = "<tr><td></td><td valign=\"top\" style=\"color:rgb(" + foreground.getRed() + "," + foreground.getGreen() + "," + foreground.getBlue() + "); font-size:0\">"; buffer.append(line); try { ImageIcon imageIcon = new ImageIcon(image); if (zoom != 100) { imageIcon = (ImageIcon) UiUtilities.scaleIcon(imageIcon, imageIcon.getIconWidth() * zoom / 100); } StringBuilder value = new StringBuilder(); String textField = prog.getTextField(ProgramFieldType.PICTURE_COPYRIGHT_TYPE); if (textField != null) { value.append(textField); } if (settings.isShowingPictureDescription()) { textField = prog.getTextField(ProgramFieldType.PICTURE_DESCRIPTION_TYPE); if (textField != null) { value.append("<br>").append(textField); } } buffer.append(doc.createCompTag(new JLabel(imageIcon))); buffer.append("<div style=\"font-size:"); buffer.append(mBodyFontSize); buffer.append("\">"); buffer.append(value); buffer.append("</div>"); buffer.append("</td></tr>"); } catch (Exception e) { // Picture was wrong; buffer.delete(buffer.length() - line.length(), buffer.length()); } } } Marker[] pluginArr = prog.getMarkerArr(); if (showPluginIcons && (pluginArr != null) && (pluginArr.length != 0)) { addSeparator(doc, buffer); buffer.append("<tr><td valign=\"top\" style=\"color:#808080; font-size:"); buffer.append(mBodyFontSize); buffer.append("\"><b>"); buffer.append(mLocalizer.msg("markedBy", "Marked by")); buffer.append("</b></td><td valign=\"middle\" style=\"font-size:4\">"); openPara(buffer, "info"); // Workaround: Without the the component are not put in one line. buffer.append(" "); for (int markerCount = pluginArr.length - 1; markerCount >= 0; markerCount--) { Icon[] icons = pluginArr[markerCount].getMarkIcons(prog); if (icons != null) { for (int i = icons.length - 1; i >= 0; i--) { JLabel iconLabel = new JLabel(icons[i]); PluginAccess plugin = Plugin.getPluginManager() .getActivatedPluginForId(pluginArr[markerCount].getId()); if (plugin != null) { iconLabel.setToolTipText(plugin.getInfo().getName()); } else { InternalPluginProxyIf internalPlugin = InternalPluginProxyList.getInstance() .getProxyForId(pluginArr[markerCount].getId()); if (internalPlugin != null) { iconLabel.setToolTipText(internalPlugin.getName()); if (internalPlugin.equals(FavoritesPluginProxy.getInstance())) { // if this is a favorite, add the names of the favorite String favTitles = ""; for (Favorite favorite : FavoriteTreeModel.getInstance() .getFavoritesContainingProgram(prog)) { if (favTitles.length() > 0) { favTitles = favTitles + ", "; } favTitles = favTitles + favorite.getName(); } if (favTitles.length() > 0) { iconLabel.setToolTipText( iconLabel.getToolTipText() + " (" + favTitles + ")"); } } } else { iconLabel.setToolTipText(pluginArr[markerCount].toString()); } } buffer.append(doc.createCompTag(iconLabel)); buffer.append(" "); } } } closePara(buffer); buffer.append("</td></tr>"); } PluginAccess[] plugins = Plugin.getPluginManager().getActivatedPlugins(); ArrayList<JLabel> iconLabels = new ArrayList<JLabel>(); for (PluginAccess plugin : plugins) { Icon[] icons = plugin.getProgramTableIcons(prog); if (icons != null) { for (Icon icon : icons) { JLabel iconLabel = new JLabel(icon); iconLabel.setToolTipText(plugin.getInfo().getName()); iconLabels.add(iconLabel); } } } if (showPluginIcons && iconLabels.size() > 0) { addSeparator(doc, buffer); buffer.append("<tr><td valign=\"middle\" style=\"color:#808080; font-size:"); buffer.append(mBodyFontSize); buffer.append("\"><b>"); buffer.append("Plugin-Icons"); buffer.append("</b></td><td valign=\"top\" style=\"font-size:4\">"); openPara(buffer, "info"); // Workaround: Without the the component are not put in one line. buffer.append(" "); for (JLabel iconLabel : iconLabels) { buffer.append(doc.createCompTag(iconLabel)); buffer.append(" "); } closePara(buffer); buffer.append("</td></tr>"); } addSeparator(doc, buffer); for (Object id : fieldArr) { ProgramFieldType type = null; if (id instanceof String) { if (((String) id).matches("\\d+")) { try { type = ProgramFieldType.getTypeForId(Integer.parseInt((String) id, 10)); } catch (Exception e) { // Empty Catch } } if (type == null) { int length = prog.getLength(); if (length > 0 && ((String) id).trim().length() > 0) { buffer.append("<tr><td valign=\"top\" style=\"color:gray; font-size:"); buffer.append(mBodyFontSize); buffer.append("\"><b>"); buffer.append(mLocalizer.msg("duration", "Program duration/<br>-end")); buffer.append("</b></td><td style=\"color:rgb(" + foreground.getRed() + "," + foreground.getGreen() + "," + foreground.getBlue() + "); font-size:"); buffer.append(mBodyFontSize); buffer.append("\">"); openPara(buffer, "time"); String msg = mLocalizer.msg("minutes", "{0} min", length); buffer.append(msg).append(" ("); buffer.append(mLocalizer.msg("until", "until {0}", prog.getEndTimeString())); int netLength = prog.getIntField(ProgramFieldType.NET_PLAYING_TIME_TYPE); if (netLength != -1) { msg = mLocalizer.msg("netMinuted", "{0} min net", netLength); buffer.append(" - ").append(msg); } buffer.append(')'); closePara(buffer); buffer.append("</td></tr>"); addSeparator(doc, buffer); } } } else if (id instanceof CompoundedProgramFieldType) { CompoundedProgramFieldType value = (CompoundedProgramFieldType) id; String entry = value.getFormattedValueForProgram(prog); if (entry != null) { startInfoSection(buffer, value.getName()); buffer.append(HTMLTextHelper.convertTextToHtml(entry, false)); addSeparator(doc, buffer); } } else { type = (ProgramFieldType) id; if (type == ProgramFieldType.DESCRIPTION_TYPE) { String description = checkDescription(prog.getDescription()); if (description != null && description.length() > 0) { addEntry(doc, buffer, prog, ProgramFieldType.DESCRIPTION_TYPE, true, showHelpLinks, showPersonLinks); } else { addEntry(doc, buffer, prog, ProgramFieldType.SHORT_DESCRIPTION_TYPE, true, showHelpLinks, showPersonLinks); } } else if (type == ProgramFieldType.INFO_TYPE) { int info = prog.getInfo(); if ((info != -1) && (info != 0)) { buffer.append("<tr><td valign=\"top\" style=\"color:gray; font-size:"); buffer.append(mBodyFontSize); buffer.append("\"><b>"); buffer.append(type.getLocalizedName()); buffer.append("</b></td><td valign=\"middle\" style=\"font-size:5\">"); openPara(buffer, "info"); // Workaround: Without the the component are not put in one // line. buffer.append(" "); int[] infoBitArr = ProgramInfoHelper.getInfoBits(); Icon[] infoIconArr = ProgramInfoHelper.getInfoIcons(); String[] infoMsgArr = ProgramInfoHelper.getInfoIconMessages(); for (int i = 0; i < infoBitArr.length; i++) { if (ProgramInfoHelper.bitSet(info, infoBitArr[i])) { JLabel iconLabel; if (infoIconArr[i] != null) { iconLabel = new JLabel(infoIconArr[i]); } else { iconLabel = new JLabel(infoMsgArr[i]); } iconLabel.setToolTipText(infoMsgArr[i]); buffer.append(doc.createCompTag(iconLabel)); buffer.append(" "); } } closePara(buffer); buffer.append("</td></tr>"); addSeparator(doc, buffer); } } else if (type == ProgramFieldType.URL_TYPE) { addEntry(doc, buffer, prog, ProgramFieldType.URL_TYPE, true, showHelpLinks, showPersonLinks); } else if (type == ProgramFieldType.ACTOR_LIST_TYPE) { ArrayList<String> knownNames = new ArrayList<String>(); String[] recognizedActors = ProgramUtilities.getActorNames(prog); if (recognizedActors != null) { knownNames.addAll(Arrays.asList(recognizedActors)); } String actorField = prog.getTextField(type); if (actorField != null) { ArrayList<String>[] lists = ProgramUtilities.splitActors(prog); if (lists == null) { lists = splitActorsSimple(prog); } if (lists != null && lists[0].size() > 0) { startInfoSection(buffer, type.getLocalizedName()); buffer.append("<table border=\"0\" cellpadding=\"0\" style=\"font-family:"); buffer.append(bodyFont); buffer.append(";\">"); for (int i = 0; i < lists[0].size(); i++) { String[] parts = new String[2]; parts[0] = lists[0].get(i); parts[1] = ""; if (i < lists[1].size()) { parts[1] = lists[1].get(i); } int actorIndex = 0; if (showPersonLinks) { if (knownNames.contains(parts[0])) { parts[0] = addPersonLink(parts[0]); } else if (knownNames.contains(parts[1])) { parts[1] = addPersonLink(parts[1]); actorIndex = 1; } } buffer.append("<tr><td valign=\"top\">• </td><td valign=\"top\">"); buffer.append(parts[actorIndex]); buffer.append("</td><td width=\"10\"> </td>"); if (parts[1 - actorIndex].length() > 0) { buffer.append("<td valign=\"top\">"); buffer.append(parts[1 - actorIndex]); buffer.append("</td>"); } else { // if roles are missing add next actor in the same line if (i + 1 < lists[0].size() && lists[1].size() == 0) { i++; buffer.append( "<td valign=\"top\">• </td><td valign=\"top\">"); if (showPersonLinks) { buffer.append(addSearchLink(lists[0].get(i))); } else { buffer.append(lists[0].get(i)); } buffer.append("</td>"); } } buffer.append("</td></tr>"); } buffer.append("</table>"); buffer.append("</td></tr>"); addSeparator(doc, buffer); } else { addEntry(doc, buffer, prog, type, showHelpLinks, showPersonLinks); } } } else { addEntry(doc, buffer, prog, type, showHelpLinks, showPersonLinks); } } } if (showHelpLinks) { buffer.append( "<tr><td colspan=\"2\" valign=\"top\" align=\"center\" style=\"color:#808080; font-size:"); buffer.append(mBodyFontSize).append("\">"); buffer.append("<a href=\""); buffer.append( mLocalizer.msg("dataInfo", "http://wiki.tvbrowser.org/index.php/Qualit%C3%A4t_der_Daten")) .append("\">"); buffer.append(mLocalizer.msg("dataQuality", "Details of the data quality")); buffer.append("</a>"); buffer.append("</td></tr>"); } buffer.append("</table></html>"); return buffer.toString(); } catch (Exception e) { e.printStackTrace(); } return ""; }
From source file:verdandi.ui.settings.DefaultSettingsPanel.java
private JPanel getPersistenceSettingsPanel() { JPanel res = new JPanel(new GridBagLayout()); res.setBorder(BorderFactory.createTitledBorder(RC.getString("settingseditor.persistence.title"))); GridBagConstraints c = new GridBagConstraints(); c.insets = new Insets(5, 5, 5, 5); c.gridy = 0;// ww w . j av a2 s . c o m c.weighty = 0.0; c.anchor = GridBagConstraints.WEST; PersistenceConfigurationDescription pdc = conf.getPersistenceConfigurationDescription(); if (pdc == null) { return res; } for (String key : pdc.getOrderedKeys()) { c.weightx = 0.1; c.gridx = 0; c.fill = GridBagConstraints.NONE; JLabel lbl = new JLabel(pdc.get(key).getName()); lbl.setToolTipText(pdc.get(key).getDescription()); res.add(lbl, c); c.gridx = 1; c.weightx = 1.0; c.fill = GridBagConstraints.HORIZONTAL; JTextField txt = new JTextField(20); txt.setText(conf.getString(pdc.get(key).getConfigKey())); res.add(txt, c); persistenceFields.put(pdc.get(key).getConfigKey(), txt); c.gridy++; } return res; }