List of usage examples for javax.swing JButton setEnabled
public void setEnabled(boolean b)
From source file:savant.util.swing.TrackChooser.java
private JButton createAllLeft() { JButton allLeft = new JButton("<<"); allLeft.setToolTipText("Remove all from selected"); if (!this.multiple) allLeft.setEnabled(false); allLeft.addActionListener(new ActionListener() { @Override/*from w ww . ja va2 s .c o m*/ public void actionPerformed(ActionEvent e) { String[] stringsRight = ((TrackListModel) rightList.getModel()).getAll(); for (int i = 0; i < stringsRight.length; i++) { ((TrackListModel) leftList.getModel()).add(stringsRight[i]); } ((TrackListModel) rightList.getModel()).removeAll(); leftList.updateUI(); rightList.updateUI(); leftList.clearSelection(); rightList.clearSelection(); } }); return allLeft; }
From source file:shuffle.fwk.service.teams.EditTeamService.java
private Component createTeamComponent(Species s) { Team curTeam = getCurrentTeam();// w w w. j av a 2s . co m 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:the.bytecode.club.bytecodeviewer.gui.WorkPane.java
@Override public void actionPerformed(final ActionEvent arg0) { Thread t = new Thread() { public void run() { if (BytecodeViewer.viewer.autoCompileOnRefresh.isSelected()) try { if (!BytecodeViewer.compile(false)) return; } catch (java.lang.NullPointerException e) { }// w ww . j a v a2 s. c o m final JButton src = (JButton) arg0.getSource(); if (src == refreshClass) { final Component tabComp = tabs.getSelectedComponent(); if (tabComp != null) { if (tabComp instanceof ClassViewer) { src.setEnabled(false); BytecodeViewer.viewer.setIcon(true); ((ClassViewer) tabComp).startPaneUpdater(src); BytecodeViewer.viewer.setIcon(false); } else if (tabComp instanceof FileViewer) { src.setEnabled(false); BytecodeViewer.viewer.setIcon(true); ((FileViewer) tabComp).refresh(src); BytecodeViewer.viewer.setIcon(false); } } } //Xposed Generator if (src == generateXposedClass) { //Get actual file class content final Component tabComp = tabs.getSelectedComponent(); String className = tabComp.getName(); String containerName = BytecodeViewer.files.get(0).name; ClassNode classnode = BytecodeViewer.getCurrentlyOpenedClassNode(); if (tabComp != null) { //Call XposedGenerator class XposedGenerator xposed = new XposedGenerator(); xposed.ParseChosenFileContent(className, containerName, classnode); } } } }; t.start(); }
From source file:tvbrowser.extras.reminderplugin.ReminderSettingsTab.java
/** * Creates the settings panel for this tab. */// w ww . j ava 2 s. c om public JPanel createSettingsPanel() { FormLayout layout = new FormLayout("5dlu,pref,5dlu,pref,pref:grow,3dlu,pref,3dlu,pref,5dlu", "pref,5dlu,pref,1dlu,pref,1dlu,pref,1dlu,pref,10dlu,pref,5dlu," + "pref,10dlu,pref,5dlu,pref,10dlu,pref,5dlu,pref,10dlu," + "pref,5dlu,pref,3dlu,pref,10dlu,pref,5dlu,pref"); layout.setColumnGroups(new int[][] { { 7, 9 } }); PanelBuilder pb = new PanelBuilder(layout, new ScrollableJPanel()); pb.setDefaultDialogBorder(); CellConstraints cc = new CellConstraints(); final String[] extArr = { ".wav", ".aif", ".rmf", ".au", ".mid" }; String soundFName = mSettings.getProperty("soundfile", "/"); String msg = mLocalizer.msg("soundFileFilter", "Sound file ({0})", "*" + StringUtils.join(extArr, ", *")); mReminderWindowChB = new JCheckBox(mLocalizer.msg("reminderWindow", "Reminder window"), mSettings.getProperty("usemsgbox", "false").equalsIgnoreCase("true")); mShowAlwaysOnTop = new JCheckBox(mLocalizer.msg("alwaysOnTop", "Show always on top"), mSettings.getProperty("alwaysOnTop", "true").equalsIgnoreCase("true")); mShowAlwaysOnTop.setEnabled(mReminderWindowChB.isSelected()); JPanel reminderWindowCfg = new JPanel(new FormLayout("12dlu,default:grow", "pref,1dlu,pref")); reminderWindowCfg.add(mReminderWindowChB, cc.xyw(1, 1, 2)); reminderWindowCfg.add(mShowAlwaysOnTop, cc.xy(2, 3)); mSoundFileChB = new FileCheckBox(mLocalizer.msg("playlingSound", "Play sound"), new File(soundFName), 0, false); JFileChooser soundChooser = new JFileChooser((String) null); soundChooser.setFileFilter(new ExtensionFileFilter(extArr, msg)); mSoundFileChB.setFileChooser(soundChooser); mSoundFileChB.setSelected(mSettings.getProperty("usesound", "false").equals("true")); mBeep = new JCheckBox(mLocalizer.msg("beep", "Speaker sound"), mSettings.getProperty("usebeep", "true").equalsIgnoreCase("true")); mExecFileStr = mSettings.getProperty("execfile", ""); mExecParamStr = mSettings.getProperty("execparam", ""); final JButton soundTestBt = new JButton(mLocalizer.msg("test", "Test")); mExecChB = new JCheckBox(mLocalizer.msg("executeProgram", "Execute program")); mExecChB.setSelected(mSettings.getProperty("useexec", "false").equals("true")); mExecFileDialogBtn = new JButton(mLocalizer.msg("executeConfig", "Configure")); mExecFileDialogBtn.setEnabled(mExecChB.isSelected()); mPluginLabel = new JLabel(); JButton choose = new JButton(mLocalizer.msg("selectPlugins", "Choose Plugins")); mClientPluginTargets = ReminderPlugin.getInstance().getClientPluginsTargets(); handlePluginSelection(); choose.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { try { Window parent = UiUtilities.getLastModalChildOf(MainFrame.getInstance()); PluginChooserDlg chooser = null; chooser = new PluginChooserDlg(parent, mClientPluginTargets, null, ReminderPluginProxy.getInstance()); chooser.setLocationRelativeTo(parent); chooser.setVisible(true); if (chooser.getReceiveTargets() != null) { mClientPluginTargets = chooser.getReceiveTargets(); } handlePluginSelection(); } catch (Exception ee) { ee.printStackTrace(); } } }); int autoCloseReminderTime = 10; try { String asString = mSettings.getProperty("autoCloseReminderTime", "10"); autoCloseReminderTime = Integer.parseInt(asString); if (autoCloseReminderTime == 0) { autoCloseReminderTime = 10; } } catch (Exception exc) { // ignore } mCloseOnEnd = new JRadioButton(mLocalizer.msg("autoCloseReminderAtProgramEnd", "Program end"), mSettings.getProperty("autoCloseBehaviour", "onEnd").equals("onEnd")); mCloseOnEnd.setEnabled(mReminderWindowChB.isSelected()); mCloseNever = new JRadioButton(mLocalizer.msg("autoCloseNever", "Never close"), mSettings.getProperty("autoCloseBehaviour", "onEnd").equals("never")); mCloseNever.setEnabled(mReminderWindowChB.isSelected()); mCloseOnTime = new JRadioButton(mLocalizer.ellipsisMsg("autoCloseAfterTime", "After time"), mSettings.getProperty("autoCloseBehaviour", "onEnd").equals("onTime")); mCloseOnTime.setEnabled(mReminderWindowChB.isSelected()); ButtonGroup bg = new ButtonGroup(); bg.add(mCloseOnEnd); bg.add(mCloseNever); bg.add(mCloseOnTime); mAutoCloseReminderTimeSp = new JSpinner( new SpinnerNumberModel(autoCloseReminderTime, autoCloseReminderTime < 5 ? 1 : 5, 600, 1)); mAutoCloseReminderTimeSp.setEnabled(mCloseOnTime.isSelected() && mReminderWindowChB.isSelected()); mShowTimeCounter = new JCheckBox(mLocalizer.msg("showTimeCounter", "Show time counter"), mSettings.getProperty("showTimeCounter", "false").compareTo("true") == 0); mShowTimeCounter.setEnabled(!mCloseNever.isSelected() && mReminderWindowChB.isSelected()); PanelBuilder autoClosePanel = new PanelBuilder( new FormLayout("12dlu,default,2dlu,default:grow", "pref,2dlu,pref,2dlu,pref,2dlu,pref,10dlu,pref")); autoClosePanel.add(mCloseOnEnd, cc.xyw(1, 1, 4)); autoClosePanel.add(mCloseNever, cc.xyw(1, 3, 4)); autoClosePanel.add(mCloseOnTime, cc.xyw(1, 5, 4)); autoClosePanel.add(mAutoCloseReminderTimeSp, cc.xy(2, 7)); final JLabel secondsLabel = autoClosePanel.addLabel(mLocalizer.msg("seconds", "seconds (0 = off)"), cc.xy(4, 7)); autoClosePanel.add(mShowTimeCounter, cc.xyw(1, 9, 4)); secondsLabel.setEnabled(mCloseOnTime.isSelected() && mReminderWindowChB.isSelected()); String defaultReminderEntryStr = (String) mSettings.get("defaultReminderEntry"); mDefaultReminderEntryList = new JComboBox(ReminderDialog.SMALL_REMIND_MSG_ARR); if (defaultReminderEntryStr != null) { try { int inx = Integer.parseInt(defaultReminderEntryStr); if (inx < ReminderDialog.SMALL_REMIND_MSG_ARR.length) { mDefaultReminderEntryList.setSelectedIndex(inx); } } catch (NumberFormatException e) { // ignore } } mShowTimeSelectionDlg = new JCheckBox( mLocalizer.msg("showTimeSelectionDialog", "Show time selection dialog")); mShowTimeSelectionDlg .setSelected(mSettings.getProperty("showTimeSelectionDialog", "true").compareTo("true") == 0); mShowRemovedDlg = new JCheckBox( mLocalizer.msg("showRemovedDialog", "Show removed reminders after data update")); mShowRemovedDlg.setSelected(mSettings.getProperty("showRemovedDialog", "true").compareTo("true") == 0); pb.addSeparator(mLocalizer.msg("remindBy", "Remind me by"), cc.xyw(1, 1, 10)); pb.add(reminderWindowCfg, cc.xyw(2, 3, 4)); pb.add(mSoundFileChB, cc.xyw(2, 5, 4)); pb.add(mSoundFileChB.getButton(), cc.xy(7, 5)); pb.add(soundTestBt, cc.xy(9, 5)); pb.add(mBeep, cc.xy(2, 7)); pb.add(mExecChB, cc.xyw(2, 9, 4)); pb.add(mExecFileDialogBtn, cc.xyw(7, 9, 3)); pb.addSeparator(mLocalizer.msg("sendToPlugin", "Send reminded program to"), cc.xyw(1, 11, 10)); pb.add(mPluginLabel, cc.xyw(2, 13, 4)); pb.add(choose, cc.xyw(7, 13, 3)); final JLabel c = (JLabel) pb .addSeparator(mLocalizer.msg("autoCloseReminder", "Automatically close reminder"), cc.xyw(1, 15, 10)) .getComponent(0); c.setEnabled(mReminderWindowChB.isSelected()); pb.add(autoClosePanel.getPanel(), cc.xyw(2, 17, 5)); JPanel reminderEntry = new JPanel(new FlowLayout(FlowLayout.LEADING, 0, 0)); reminderEntry.add(mDefaultReminderEntryList); pb.addSeparator(mLocalizer.msg("defaltReminderEntry", "Default reminder time"), cc.xyw(1, 19, 10)); pb.add(reminderEntry, cc.xyw(2, 21, 4)); pb.addSeparator(mLocalizer.msg("miscSettings", "Misc settings"), cc.xyw(1, 23, 10)); pb.add(mShowTimeSelectionDlg, cc.xyw(2, 25, 7)); pb.add(mShowRemovedDlg, cc.xyw(2, 27, 7)); pb.addSeparator(DefaultMarkingPrioritySelectionPanel.getTitle(), cc.xyw(1, 29, 10)); pb.add(mMarkingsPanel = DefaultMarkingPrioritySelectionPanel .createPanel(ReminderPlugin.getInstance().getMarkPriority(), false, false), cc.xyw(2, 31, 9)); mReminderWindowChB.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { mShowAlwaysOnTop.setEnabled(e.getStateChange() == ItemEvent.SELECTED); c.setEnabled(e.getStateChange() == ItemEvent.SELECTED); secondsLabel.setEnabled(e.getStateChange() == ItemEvent.SELECTED && mCloseOnTime.isSelected()); mCloseOnEnd.setEnabled(e.getStateChange() == ItemEvent.SELECTED); mCloseNever.setEnabled(e.getStateChange() == ItemEvent.SELECTED); mCloseOnTime.setEnabled(e.getStateChange() == ItemEvent.SELECTED); mShowTimeCounter.setEnabled(e.getStateChange() == ItemEvent.SELECTED && !mCloseNever.isSelected()); mAutoCloseReminderTimeSp .setEnabled(e.getStateChange() == ItemEvent.SELECTED && mCloseOnTime.isSelected()); } }); soundTestBt.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { if (evt.getActionCommand().compareTo(mLocalizer.msg("test", "Test")) == 0) { mTestSound = ReminderPlugin.playSound(mSoundFileChB.getTextField().getText()); if (mTestSound != null) { soundTestBt.setText(mLocalizer.msg("stop", "Stop")); } if (mTestSound != null) { if (mTestSound instanceof SourceDataLine) { ((SourceDataLine) mTestSound).addLineListener(new LineListener() { public void update(LineEvent event) { if (event.getType() == Type.CLOSE) { soundTestBt.setText(mLocalizer.msg("test", "Test")); } } }); } else if (mTestSound instanceof Sequencer) { new Thread("Test MIDI sound") { public void run() { setPriority(Thread.MIN_PRIORITY); while (((Sequencer) mTestSound).isRunning()) { try { Thread.sleep(100); } catch (Exception ee) { } } soundTestBt.setText(mLocalizer.msg("test", "Test")); } }.start(); } } } else if (mTestSound != null) { if (mTestSound instanceof SourceDataLine && ((SourceDataLine) mTestSound).isRunning()) { ((SourceDataLine) mTestSound).stop(); } else if (mTestSound instanceof Sequencer && ((Sequencer) mTestSound).isRunning()) { ((Sequencer) mTestSound).stop(); } } } }); mSoundFileChB.getCheckBox().addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { soundTestBt.setEnabled(mSoundFileChB.isSelected()); } }); mSoundFileChB.getTextField().addKeyListener(new KeyAdapter() { public void keyReleased(KeyEvent e) { String text = mSoundFileChB.getTextField().getText(); if ((new File(text)).isFile()) { boolean notFound = true; for (String extension : extArr) { if (StringUtils.endsWithIgnoreCase(text, extension)) { notFound = false; break; } } if (notFound) { soundTestBt.setEnabled(false); } else { soundTestBt.setEnabled(true); } } else { soundTestBt.setEnabled(false); } } }); mSoundFileChB.getTextField().getKeyListeners()[0].keyReleased(null); mExecChB.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { mExecFileDialogBtn.setEnabled(mExecChB.isSelected()); if (mExecFileDialogBtn.isEnabled()) { showFileSettingsDialog(); } } }); mExecFileDialogBtn.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { showFileSettingsDialog(); } }); ItemListener autoCloseListener = new ItemListener() { public void itemStateChanged(ItemEvent e) { mAutoCloseReminderTimeSp.setEnabled(mCloseOnTime.isSelected()); secondsLabel.setEnabled(mCloseOnTime.isSelected()); mShowTimeCounter.setEnabled(mCloseOnTime.isSelected() || mCloseOnEnd.isSelected()); } }; mCloseOnEnd.addItemListener(autoCloseListener); mCloseOnTime.addItemListener(autoCloseListener); mCloseOnTime.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { mShowTimeCounter.setEnabled(e.getStateChange() == ItemEvent.SELECTED); } }); JScrollPane scrollPane = new JScrollPane(pb.getPanel()); scrollPane.setBorder(null); scrollPane.setViewportBorder(null); JPanel scrollPanel = new JPanel(new FormLayout("default:grow", "default")); scrollPanel.add(scrollPane, cc.xy(1, 1)); return scrollPanel; }
From source file:UI.BlackJackUINew.java
public void TerminateControlOfPlayer() { for (JButton button : YourActionList) { button.setEnabled(false); } }
From source file:UI.BlackJackUINew.java
public void RestoreControlOfPlayer() { for (JButton button : YourActionList) { button.setEnabled(true); } }
From source file:util.program.ProgramTextCreator.java
/** * * @param prog/* w w w . j a v a 2 s . co m*/ * 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 ""; }