List of usage examples for javax.swing JButton setToolTipText
@BeanProperty(bound = false, preferred = true, description = "The text to display in a tool tip.") public void setToolTipText(String text)
From source file:shuffle.fwk.service.teams.EditTeamService.java
private Component makeUpperPanel() { JPanel ret = new JPanel(new GridBagLayout()); GridBagConstraints c = new GridBagConstraints(); c.fill = GridBagConstraints.HORIZONTAL; c.weightx = 1.0;/*from w w w . jav a 2 s.co m*/ c.weighty = 0.0; c.gridx = 1; c.gridy = 1; c.gridwidth = 1; c.gridheight = 1; c.gridx += 1; c.weightx = 0.0; JPanel typePanel = new JPanel(); typePanel.add(new JLabel(getString(KEY_TYPE))); typeChooser = new TypeChooser(true); typePanel.add(typeChooser); typePanel.setToolTipText(getString(KEY_TYPE_TOOLTIP)); typeChooser.setToolTipText(getString(KEY_TYPE_TOOLTIP)); ret.add(typePanel, c); c.gridx += 1; c.weightx = 0.0; JPanel levelPanel = new JPanel(); levelPanel.add(new JLabel(getString(KEY_LEVEL))); SpinnerNumberModel snm = new SpinnerNumberModel(0, 0, Species.MAX_LEVEL, 1); levelSpinner = new JSpinner(snm); levelPanel.add(levelSpinner); levelPanel.setToolTipText(getString(KEY_LEVEL_TOOLTIP)); levelSpinner.setToolTipText(getString(KEY_LEVEL_TOOLTIP)); ret.add(levelPanel, c); c.gridx += 1; c.weightx = 1.0; JPanel stringPanel = new JPanel(new GridBagLayout()); GridBagConstraints sc = new GridBagConstraints(); sc.fill = GridBagConstraints.HORIZONTAL; sc.gridx = 1; stringPanel.add(new JLabel(getString(KEY_NAME)), sc); textField = new JTextField(); sc.gridx += 1; sc.weightx = 1.0; sc.insets = new Insets(0, 5, 0, 5); stringPanel.add(textField, sc); stringPanel.setToolTipText(getString(KEY_NAME_TOOLTIP)); textField.setToolTipText(getString(KEY_NAME_TOOLTIP)); ret.add(stringPanel, c); c.gridx += 1; c.weightx = 0.0; megaFilter = new JCheckBox(getString(KEY_MEGA_FILTER)); megaFilter.setToolTipText(getString(KEY_MEGA_FILTER_TOOLTIP)); ; ret.add(megaFilter, c); c.gridx += 1; c.weightx = 0.0; effectFilter = new EffectChooser(false, EffectChooser.DefaultEntry.NO_FILTER); effectFilter.setToolTipText(getString(KEY_EFFECT_FILTER_TOOLTIP)); ret.add(effectFilter, c); c.gridx += 1; c.weightx = 0.0; @SuppressWarnings("serial") JButton copyToLauncher = new JButton(new AbstractAction(getString(KEY_MAKE_DEFAULT)) { @Override public void actionPerformed(ActionEvent e) { makeTeamDefault(); } }); copyToLauncher.setToolTipText(getString(KEY_MAKE_DEFAULT_TOOLTIP)); ret.add(copyToLauncher, c); getMinUpperPanel = new Supplier<Dimension>() { @Override public Dimension get() { Dimension ret = new Dimension(10 + 50, 0); for (Component c : new Component[] { typePanel, levelPanel, stringPanel, megaFilter, effectFilter, copyToLauncher }) { Dimension temp = c.getPreferredSize(); int width = temp.width + ret.width; int height = Math.max(temp.height, ret.height); ret.setSize(width, height); } return ret; } }; return ret; }
From source file:shuffle.fwk.service.teams.EditTeamService.java
@SuppressWarnings("serial") private Component makeTeamPanel() { JPanel firstOptionRow = new JPanel(new GridBagLayout()); GridBagConstraints rowc = new GridBagConstraints(); rowc.fill = GridBagConstraints.HORIZONTAL; rowc.weightx = 0.0;/* w w w . ja v a2s. c om*/ rowc.weighty = 0.0; rowc.weightx = 1.0; rowc.gridx = 1; stageChooser = new StageChooser(this); firstOptionRow.add(stageChooser, rowc); rowc.weightx = 0.0; JPanel secondOptionRow = new JPanel(new GridBagLayout()); rowc.gridx = 1; JLabel megaLabel = new JLabel(getString(KEY_MEGA_LABEL)); megaLabel.setToolTipText(getString(KEY_MEGA_TOOLTIP)); secondOptionRow.add(megaLabel, rowc); rowc.gridx = 2; megaChooser = new JComboBox<String>(); megaChooser.setToolTipText(getString(KEY_MEGA_TOOLTIP)); secondOptionRow.add(megaChooser, rowc); rowc.gridx = 3; JPanel progressPanel = new JPanel(new BorderLayout()); megaActive = new JCheckBox(getString(KEY_ACTIVE)); megaActive.setSelected(false); megaActive.setToolTipText(getString(KEY_ACTIVE_TOOLTIP)); progressPanel.add(megaActive, BorderLayout.WEST); megaProgressChooser = new JComboBox<Integer>(); progressPanel.add(megaProgressChooser, BorderLayout.EAST); megaProgressChooser.setToolTipText(getString(KEY_MEGA_PROGRESS_TOOLTIP)); secondOptionRow.add(progressPanel, rowc); JPanel thirdOptionRow = new JPanel(new GridBagLayout()); rowc.gridx = 1; JButton clearTeamButton = new JButton(getString(KEY_CLEAR_TEAM)); clearTeamButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { clearTeam(); } }); clearTeamButton.setToolTipText(getString(KEY_CLEAR_TEAM_TOOLTIP)); thirdOptionRow.add(clearTeamButton, rowc); rowc.gridx = 2; woodCheckBox = new JCheckBox(getString(KEY_WOOD)); woodCheckBox.setToolTipText(getString(KEY_WOOD_TOOLTIP)); thirdOptionRow.add(woodCheckBox, rowc); rowc.gridx = 3; metalCheckBox = new JCheckBox(getString(KEY_METAL)); metalCheckBox.setToolTipText(getString(KEY_METAL_TOOLTIP)); thirdOptionRow.add(metalCheckBox, rowc); rowc.gridx = 4; coinCheckBox = new JCheckBox(getString(KEY_COIN)); coinCheckBox.setToolTipText(getString(KEY_COIN_TOOLTIP)); thirdOptionRow.add(coinCheckBox, rowc); rowc.gridx = 5; freezeCheckBox = new JCheckBox(getString(KEY_FREEZE)); freezeCheckBox.setToolTipText(getString(KEY_FREEZE_TOOLTIP)); thirdOptionRow.add(freezeCheckBox, rowc); JPanel topPart = new JPanel(new GridBagLayout()); GridBagConstraints topC = new GridBagConstraints(); topC.fill = GridBagConstraints.HORIZONTAL; topC.weightx = 0.0; topC.weighty = 0.0; topC.gridx = 1; topC.gridy = 1; topC.gridwidth = 1; topC.gridheight = 1; topC.anchor = GridBagConstraints.CENTER; topC.gridy = 1; topPart.add(firstOptionRow, topC); topC.gridy = 2; topPart.add(secondOptionRow, topC); topC.gridy = 3; topPart.add(thirdOptionRow, topC); addOptionListeners(); teamPanel = new JPanel(new WrapLayout()) { // Fix to make it play nice with the scroll bar. @Override public Dimension getPreferredSize() { Dimension d = super.getPreferredSize(); d.width = (int) (d.getWidth() - 20); return d; } }; final JScrollPane scrollPane = new JScrollPane(teamPanel, ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER) { @Override public Dimension getMinimumSize() { Dimension d = super.getMinimumSize(); d.width = topPart.getMinimumSize().width; d.height = rosterScrollPane.getPreferredSize().height - topPart.getPreferredSize().height; return d; } @Override public Dimension getPreferredSize() { Dimension d = super.getPreferredSize(); d.width = topPart.getMinimumSize().width; d.height = rosterScrollPane.getPreferredSize().height - topPart.getPreferredSize().height; return d; } }; scrollPane.addComponentListener(new ComponentAdapter() { @Override public void componentResized(ComponentEvent e) { scrollPane.revalidate(); } }); scrollPane.getVerticalScrollBar().setUnitIncrement(27); JPanel ret = new JPanel(new GridBagLayout()); GridBagConstraints rc = new GridBagConstraints(); rc.fill = GridBagConstraints.VERTICAL; rc.weightx = 0.0; rc.weighty = 0.0; rc.gridx = 1; rc.gridy = 1; rc.insets = new Insets(5, 5, 5, 5); ret.add(topPart, rc); rc.gridy += 1; rc.weightx = 0.0; rc.weighty = 1.0; rc.insets = new Insets(0, 0, 0, 0); ret.add(scrollPane, rc); return ret; }
From source file:shuffle.fwk.service.teams.EditTeamService.java
private Component makeBottomPanel() { JPanel ret = new JPanel(new GridBagLayout()); GridBagConstraints c = new GridBagConstraints(); c.fill = GridBagConstraints.NONE; c.weightx = 1.0;//from w ww. ja va 2 s . c om c.weighty = 0.0; c.gridx = 1; c.gridy = 1; c.gridwidth = 1; c.gridheight = 1; c.anchor = GridBagConstraints.LINE_START; c.weightx = 0.0; c.gridx += 1; c.insets = new Insets(0, 10, 0, 10); selectedDisplayLabel = new JLabel(getString(KEY_NONE_SELECTED)); selectedDisplayLabel.setToolTipText(getString(KEY_SELECTED_TOOLTIP)); ret.add(selectedDisplayLabel, c); c.anchor = GridBagConstraints.LINE_END; c.weightx = 1.0; c.gridx++; survivalMode = new JCheckBox(getString(KEY_SURVIVAL)); JPanel survivalModePanel = new JPanel(new BorderLayout()); survivalModePanel.add(survivalMode, BorderLayout.WEST); survivalMode.setToolTipText(getString(KEY_SURVIVAL_TOOLTIP)); ret.add(survivalModePanel, c); c.anchor = GridBagConstraints.LINE_END; c.weightx = 0.0; c.gridx += 1; JButton okButton = new JButton(getString(KEY_OK)); okButton.setToolTipText(getString(KEY_OK_TOOLTIP)); ret.add(okButton, c); setDefaultButton(okButton); c.anchor = GridBagConstraints.CENTER; c.weightx = 0.0; c.gridx += 1; JButton applyButton = new JButton(getString(KEY_APPLY)); applyButton.setToolTipText(getString(KEY_APPLY_TOOLTIP)); ret.add(applyButton, c); c.anchor = GridBagConstraints.LINE_START; c.weightx = 0.0; c.gridx += 1; JButton cancelButton = new JButton(new DisposeAction(getString(KEY_CANCEL), this)); cancelButton.setToolTipText(getString(KEY_CANCEL_TOOLTIP)); ret.add(cancelButton, c); okButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { onOK(); } }); applyButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { onApply(); } }); return ret; }
From source file:shuffle.fwk.service.teams.EditTeamService.java
private JPanel createRosterComponent(Species s) { JPanel ret = new JPanel(new GridBagLayout()); GridBagConstraints c = new GridBagConstraints(); c.fill = GridBagConstraints.HORIZONTAL; c.gridx = 1;/*from ww w . j ava 2 s.c o m*/ c.gridy = 1; c.anchor = GridBagConstraints.CENTER; MouseAdapter ma = new PressOrClickMouseAdapter() { @Override protected void onRight(MouseEvent e) { onLeft(e); } @Override protected void onLeft(MouseEvent e) { setSelected(s, ret); selectedDisplayLabel.repaint(); } @Override protected void onEnter() { // Do nothing } }; SpeciesPaint sp = new SpeciesPaint(s, false, getMegaFilter()); ImageIcon icon = getUser().getImageManager().getImageFor(sp); JLabel iconLabel = new JLabel(icon); iconLabel.addMouseListener(ma); ret.add(iconLabel, c); c.gridy += 1; JLabel jLabel = new JLabel(s.getLocalizedName(getMegaFilter())); jLabel.setHorizontalTextPosition(SwingConstants.CENTER); jLabel.setHorizontalAlignment(SwingConstants.CENTER); jLabel.addMouseListener(ma); ret.add(jLabel, c); JButton addToTeam = new JButton(getString(KEY_ADD)); addToTeam.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { addSpeciesToTeam(s); updateTeamPanel(); } }); addToTeam.setToolTipText(getString(KEY_ADD_TOOLTIP)); c.gridy += 1; ret.add(addToTeam, c); return ret; }
From source file:shuffle.fwk.service.teams.EditTeamService.java
private Component createTeamComponent(Species s) { Team curTeam = getCurrentTeam();/*from w ww . j ava 2 s .c om*/ JPanel ret = new JPanel(new GridBagLayout()); GridBagConstraints c = new GridBagConstraints(); c.gridx = 1; c.gridy = 1; c.gridwidth = 2; Indicator<SpeciesPaint> ind = new Indicator<SpeciesPaint>(this); boolean isMega = megaProgress >= megaThreshold && s.getName().equals(curTeam.getMegaSlotName()); SpeciesPaint paint = new SpeciesPaint(s, s.equals(Species.FREEZE), isMega); ind.setVisualized(paint); ret.add(ind, c); c.gridy += 1; c.gridwidth = 1; JButton removeButton = new JButton(getString(KEY_REMOVE)); removeButton.setToolTipText(getString(KEY_REMOVE_TOOLTIP)); removeButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { removeSpeciesFromTeam(s.getName()); updateTeamPanel(); } }); removeButton.setEnabled( s.getEffect(getUser().getRosterManager()).isPickable() && !s.getType().equals(PkmType.NONE)); ret.add(removeButton, c); c.gridx += 1; JComboBox<Character> keybindsComboBox = new JComboBox<Character>(); Character curBinding = curTeam.getBinding(s); LinkedHashSet<Character> allBindingsFor = new LinkedHashSet<Character>(Arrays.asList(curBinding)); LinkedHashSet<Character> availableBindings = myData.getAllAvailableBindingsFor(s.getName(), curTeam); allBindingsFor.addAll(availableBindings); for (Character ch : allBindingsFor) { keybindsComboBox.addItem(ch); } keybindsComboBox.setSelectedItem(curBinding); final ItemListener bindingListener = new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { JComboBox<?> source = (JComboBox<?>) e.getSource(); int selectedIndex = source.getSelectedIndex(); Character selected = (Character) source.getItemAt(selectedIndex); setBinding(s, selected); updateKeybindComboBoxes(); } }; nameToKeybindComboboxMap.put(s.getName(), keybindsComboBox); nameToItemListenerMap.put(s.getName(), bindingListener); keybindsComboBox.addItemListener(bindingListener); keybindsComboBox.setToolTipText(getString(KEY_KEYBINDS_TOOLTIP)); ret.add(keybindsComboBox, c); MouseAdapter ma = new PressToggleMouseAdapter() { @Override protected void onRight(MouseEvent e) { doToggle(); } @Override protected void onLeft(MouseEvent e) { doToggle(); } private void doToggle() { toggleSupport(s); updateTeamPanel(); } }; ret.addMouseListener(ma); setBorderFor(ret, false, false); if (!Species.FIXED_SPECIES.contains(s)) { boolean isSupport = !curTeam.isNonSupport(s); Color indColor = isSupport ? Color.GREEN : Color.RED; ret.setBackground(indColor); ret.setOpaque(true); } return ret; }
From source file:tkwatch.Utilities.java
/** * Returns a quit button.//from ww w . j a v a2 s . co m * * @return A button that cleans up and exits. */ public static final JButton getQuitButton() { final JButton button = new JButton("Quit"); button.setToolTipText("Exit the application."); button.setSize(Constants.BUTTON_WIDTH, Constants.BUTTON_HEIGHT); button.addActionListener(new ActionListener() { public void actionPerformed(final ActionEvent e) { System.out.flush(); System.exit(0); } }); return button; }
From source file:uk.ac.soton.mib104.t2.workbench.ui.ActivityConfigurationPanelWithInputPortAndOutputPortComponents.java
/** * Initializes the graphical user interface (GUI). * <p>//from w w w . j a va 2 s.c om * Subclasses may refine the implementation of this method. */ protected void initGui() { this.setDoubleBuffered(false); this.setLayout(new BorderLayout()); tabbedPane.setBorder(BorderFactory.createEmptyBorder()); tabbedPane.addTab(defaultInputPortsTabText, defaultInputPortsTabIcon, inputPortsPane, defaultInputPortsTabTip); tabbedPane.addTab(defaultOutputPortsTabText, defaultOutputPortsTabIcon, outputPortsPane, defaultOutputPortsTabTip); this.add(tabbedPane, BorderLayout.CENTER); inputPortsPane.setBorder(BorderFactory.createEmptyBorder()); inputPortsPane.setLayout(new BorderLayout()); emptyInputPortsLabel.setHorizontalAlignment(JLabel.CENTER); emptyInputPortsLabel.setText(defaultEmptyInputPortsText); final JButton addInputPortButton = new JButton(); addInputPortButton.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(final MouseEvent e) { final String portName = nextPortName(defaultInputPortName, ActivityConfigurationPanelWithInputPortAndOutputPortComponents.this.getInputPortComponents() .keySet()); final IN_CONFIG inputPortConfigBean = ActivityConfigurationPanelWithInputPortAndOutputPortComponents.this .newInputPortConfiguration(); final IN_COMPONENT inputPortComponent = ActivityConfigurationPanelWithInputPortAndOutputPortComponents.this .toInputPortComponent(portName, inputPortConfigBean); inputPortsTabbedPane.addTab(portName, inputPortComponent); } }); addInputPortButton.setIcon(defaultAddInputPortButtonIcon); addInputPortButton.setText(defaultAddInputPortButtonText); addInputPortButton.setToolTipText(defaultAddInputPortButtonTip); inputPortsPane.add(emptyInputPortsLabel, BorderLayout.CENTER); inputPortsPane.add(addInputPortButton, BorderLayout.SOUTH); outputPortsPane.setBorder(BorderFactory.createEmptyBorder()); outputPortsPane.setLayout(new BorderLayout()); emptyOutputPortsLabel.setHorizontalAlignment(JLabel.CENTER); emptyOutputPortsLabel.setText(defaultEmptyOutputPortsText); final JButton addOutputPortButton = new JButton(); addOutputPortButton.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(final MouseEvent e) { final String portName = nextPortName(defaultOutputPortName, ActivityConfigurationPanelWithInputPortAndOutputPortComponents.this .getOutputPortComponents().keySet()); final OUT_CONFIG outputPortConfigBean = ActivityConfigurationPanelWithInputPortAndOutputPortComponents.this .newOutputPortConfiguration(); final OUT_COMPONENT outputPortComponent = ActivityConfigurationPanelWithInputPortAndOutputPortComponents.this .toOutputPortComponent(portName, outputPortConfigBean); outputPortsTabbedPane.addTab(portName, outputPortComponent); } }); addOutputPortButton.setIcon(defaultAddOutputPortButtonIcon); addOutputPortButton.setText(defaultAddOutputPortButtonText); addOutputPortButton.setToolTipText(defaultAddOutputPortButtonTip); outputPortsPane.add(emptyOutputPortsLabel, BorderLayout.CENTER); outputPortsPane.add(addOutputPortButton, BorderLayout.SOUTH); }
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);// www .j a v a 2 s.c om 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:util.program.ProgramTextCreator.java
/** * * @param prog/* ww w .java 2s . 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:util.ui.UiUtilities.java
/** * Gibt einen Button mit Icon und Schrift zurck, der so initialisiert ist, * da man ihn gut fr Symbolleisten nutzen kann (Rahmen nur bei Rollover * sichtbar usw.).// w w w . j av a 2 s. co m * <P> * Wenn text und iconDateiname angegeben sind, dann wird text als TooltipText * gesetzt. * * @param text * Der Text des Buttons (Kann null sein, wenn der Button keinen Text * enthalten soll) * @param icon * Das Icon des Buttons (Kann ebenfalls null sein, wenn der Button * kein Icon enthalten soll). * @return button */ public static JButton createToolBarButton(String text, Icon icon) { final JButton btn; if (icon == null) { btn = new JButton(text); } else { btn = new JButton(icon); btn.setToolTipText(text); btn.setBorderPainted(false); btn.setMargin(ZERO_INSETS); btn.addMouseListener(new MouseAdapter() { @Override public void mouseEntered(MouseEvent e) { if (btn.isEnabled()) { btn.setBorderPainted(true); } } @Override public void mouseExited(MouseEvent e) { btn.setBorderPainted(false); } }); } btn.setFocusPainted(false); return btn; }