/** Creates a DialogRating with the selected Rating */ protected void view() { if ((mTabbedPane.getSelectedIndex() == 0) && (mOverallRatings.getSelectedValue() != null)) { DialogRating dlg = new DialogRating( mPlugin.getParentFrameForTVRater(), mPlugin, ((Rating) mOverallRatings.getSelectedValue()).getTitle()); UiUtilities.centerAndShow(dlg); updateLists(); } else if ((mTabbedPane.getSelectedIndex() == 1) && (mPersonalRatings.getSelectedValue() != null)) { DialogRating dlg = new DialogRating( mPlugin.getParentFrameForTVRater(), mPlugin, ((Rating) mPersonalRatings.getSelectedValue()).getTitle()); UiUtilities.centerAndShow(dlg); updateLists(); } }
/** * Creates the Dialog * * @param frame Frame for modal * @param plugin Plugin for reference * @param settings The settings of the ListViewPlugin */ public ListViewDialog(Frame frame, Plugin plugin, Properties settings) { super(frame, true); setTitle(mLocalizer.msg("viewList", "View List:")); mPlugin = plugin; mSettings = settings; mTimes = Plugin.getPluginManager().getTvBrowserSettings().getTimeButtonTimes(); mModel = new ListTableModel(); mPerformingSingleClick = false; mCurrentFilter = Plugin.getPluginManager().getFilterManager().getCurrentFilter(); generateList(new Date(), getCurrentTime()); createGUI(); addChangeTimer(); UiUtilities.registerForClosing(this); }
/** Creates the GUI */ private void createGUI() { UiUtilities.registerForClosing(this); JPanel panel = (JPanel) getContentPane(); panel.setLayout(new BorderLayout()); RatingComparator comperator = new RatingComparator(); Vector<Rating> overallData = new Vector<Rating>(mPlugin.getDatabase().getServerRatings()); Collections.sort(overallData, comperator); mTabbedPane = new JTabbedPane(); mOverallRatings = new JList(overallData); mOverallRatings.setCellRenderer(new RatingCellRenderer()); mOverallRatings.addMouseListener( new MouseAdapter() { public void mousePressed(MouseEvent evt) { if (evt.isPopupTrigger()) { showPopUpMenu(evt); } } public void mouseReleased(MouseEvent evt) { if (evt.isPopupTrigger()) { showPopUpMenu(evt); } } public void mouseClicked(MouseEvent e) { if ((e.getButton() == MouseEvent.BUTTON1) && (e.getClickCount() == 2)) { view(); } super.mouseClicked(e); } }); mTabbedPane.addTab( mLocalizer.msg("overall", "Overall Ratings"), new JScrollPane(mOverallRatings)); Vector<Rating> personalData = new Vector<Rating>(mPlugin.getDatabase().getPersonalRatings()); Collections.sort(personalData, comperator); mPersonalRatings = new JList(personalData); mPersonalRatings.setCellRenderer(new RatingCellRenderer()); mPersonalRatings.addMouseListener( new MouseAdapter() { public void mousePressed(MouseEvent evt) { if (evt.isPopupTrigger()) { showPopUpMenu(evt); } } public void mouseReleased(MouseEvent evt) { if (evt.isPopupTrigger()) { showPopUpMenu(evt); } } public void mouseClicked(MouseEvent e) { if ((e.getButton() == MouseEvent.BUTTON1) && (e.getClickCount() == 2)) { view(); } super.mouseClicked(e); } }); mTabbedPane.addTab( mLocalizer.msg("personal", "Your Ratings"), new JScrollPane(mPersonalRatings)); panel.add(mTabbedPane, BorderLayout.CENTER); JPanel buttonpanel = new JPanel(new GridBagLayout()); GridBagConstraints c4 = new GridBagConstraints(); c4.gridwidth = GridBagConstraints.REMAINDER; c4.fill = GridBagConstraints.HORIZONTAL; c4.weightx = 1; c4.anchor = GridBagConstraints.CENTER; LinkButton linkButton = new LinkButton("http://tvaddicted.de"); buttonpanel.add(linkButton, c4); GridBagConstraints c = new GridBagConstraints(); c.weightx = 0; c.fill = GridBagConstraints.NONE; c.insets = new Insets(5, 5, 5, 5); mBtnUpdate = new JButton(mLocalizer.msg("update", "Update")); buttonpanel.add(mBtnUpdate, c); mBtnUpdate.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { update(); } }); GridBagConstraints c2 = new GridBagConstraints(); c2.weightx = 1; c2.fill = GridBagConstraints.HORIZONTAL; buttonpanel.add(new JPanel(), c2); JButton view = new JButton(mLocalizer.msg("view", "View")); buttonpanel.add(view, c); view.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { view(); } }); JButton close = new JButton(Localizer.getLocalization(Localizer.I18N_CLOSE)); buttonpanel.add(close, c); close.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { setVisible(false); } }); getRootPane().setDefaultButton(close); panel.add(buttonpanel, BorderLayout.SOUTH); }
public FontsDialog(Frame parent, Font titleFont, Font descriptionFont, Font dateFont) { super(parent, true); setTitle(mLocalizer.msg("dialog.title", "Fonts")); JPanel content = (JPanel) getContentPane(); UiUtilities.registerForClosing(this); CellConstraints cc = new CellConstraints(); FormLayout layout = new FormLayout("5dlu,pref:grow", "pref,5dlu,pref,2dlu,pref,5dlu,pref"); PanelBuilder pb = new PanelBuilder(layout, content); pb.setBorder(Borders.DLU4_BORDER); pb.addSeparator(mLocalizer.msg("fonts", "Fonts"), cc.xyw(1, 1, 2)); mTitleFontPanel = new FontChooserPanel(mLocalizer.msg("title", "Title"), titleFont); mDescriptionFontPanel = new FontChooserPanel(mLocalizer.msg("description", "Description"), descriptionFont); if (dateFont != null) { mDateFontPanel = new FontChooserPanel(mLocalizer.msg("date", "Date"), dateFont); } int y = 3; pb.add(mTitleFontPanel, cc.xy(2, y++)); pb.add(mDescriptionFontPanel, cc.xy(2, ++y)); if (dateFont != null) { layout.insertRow(++y, RowSpec.decode("2dlu")); layout.insertRow(++y, RowSpec.decode("pref")); content.add(mDateFontPanel, cc.xy(2, y)); } y++; JPanel btnPn = new JPanel(new FlowLayout()); JButton okBt = new JButton(Localizer.getLocalization(Localizer.I18N_OK)); JButton cancelBt = new JButton(Localizer.getLocalization(Localizer.I18N_CANCEL)); btnPn.add(okBt); btnPn.add(cancelBt); okBt.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { mResult = OK; setVisible(false); } }); cancelBt.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { close(); } }); content.add(btnPn, cc.xyw(1, ++y, 2)); mResult = CANCEL; pack(); }
public SettingsDialog( final Frame parent, final PrinterJob printerJob, Scheme[] schemes, DialogContent content) { super(parent, true); UiUtilities.registerForClosing(this); mDialogContent = content; mPageFormat = printerJob.defaultPage(); setTitle(content.getDialogTitle()); JPanel contentPane = (JPanel) getContentPane(); contentPane.setBorder(BorderFactory.createEmptyBorder(4, 4, 5, 5)); contentPane.setLayout(new BorderLayout()); JPanel eastPanel = new JPanel(new BorderLayout()); JPanel eastBtnPanel = new JPanel(); eastBtnPanel.setBorder(BorderFactory.createEmptyBorder(0, 3, 0, 0)); eastBtnPanel.setLayout(new GridLayout(-1, 1)); JButton printerSetupBtn = new JButton( mLocalizer.ellipsisMsg("printer", "Printer"), PrintPlugin.getInstance().createImageIcon("devices", "printer", 16)); JButton pageBtn = new JButton( mLocalizer.ellipsisMsg("page", "Page"), PrintPlugin.getInstance().createImageIcon("actions", "document-properties", 16)); JButton previewBtn = new JButton( mLocalizer.ellipsisMsg("preview", "Preview"), PrintPlugin.getInstance().createImageIcon("actions", "document-print-preview", 16)); printerSetupBtn.setHorizontalAlignment(SwingConstants.LEFT); pageBtn.setHorizontalAlignment(SwingConstants.LEFT); previewBtn.setHorizontalAlignment(SwingConstants.LEFT); eastBtnPanel.add(printerSetupBtn); eastBtnPanel.add(pageBtn); eastBtnPanel.add(previewBtn); eastPanel.add(eastBtnPanel, BorderLayout.NORTH); JPanel southPanel = new JPanel(new BorderLayout()); JPanel okCancelBtnPanel = new JPanel(new FlowLayout()); JButton printBt = new JButton(mLocalizer.msg("print", "Drucken")); JButton cancelBt = new JButton(Localizer.getLocalization(Localizer.I18N_CANCEL)); okCancelBtnPanel.add(printBt); okCancelBtnPanel.add(cancelBt); southPanel.add(okCancelBtnPanel, BorderLayout.EAST); printerSetupBtn.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent event) { Thread thread = new Thread("Printer setup") { public void run() { printerJob.printDialog(); } }; thread.start(); } }); pageBtn.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent event) { Thread thread = new Thread("Document properties (printing)") { public void run() { if (mPageFormat == null) { mPageFormat = printerJob.defaultPage(); } mPageFormat = printerJob.pageDialog(mPageFormat); } }; thread.start(); } }); previewBtn.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent event) { printplugin.printer.PrintJob job = getPrintJob(); if (job.getNumOfPages() == 0) { JOptionPane.showMessageDialog( parent, mLocalizer.msg("noPagesToPrint", "Es sind keine Seiten zu drucken.")); } else { PreviewDlg dlg = new PreviewDlg(parent, job.getPrintable(), mPageFormat, job.getNumOfPages()); PrintPlugin.getInstance().layoutWindow("previewDlg", dlg); dlg.setVisible(true); } } }); printBt.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { mResult = OK; setVisible(false); } }); cancelBt.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { close(); } }); JButton newSchemeBtn = new JButton(TVBrowserIcons.newIcon(TVBrowserIcons.SIZE_SMALL)); newSchemeBtn.setToolTipText(mLocalizer.msg("newScheme", "New scheme")); mEditSchemeBtn = new JButton(TVBrowserIcons.edit(TVBrowserIcons.SIZE_SMALL)); mEditSchemeBtn.setToolTipText(mLocalizer.msg("editScheme", "Edit scheme")); mDeleteSchemeBtn = new JButton(TVBrowserIcons.delete(TVBrowserIcons.SIZE_SMALL)); mDeleteSchemeBtn.setToolTipText(mLocalizer.msg("deleteScheme", "Delete scheme")); mSaveSchemeBtn = new JButton(PrintPlugin.getInstance().createImageIcon("actions", "document-save", 16)); mSaveSchemeBtn.setToolTipText(mLocalizer.msg("saveScheme", "Save scheme")); newSchemeBtn.setMargin(UiUtilities.ZERO_INSETS); mDeleteSchemeBtn.setMargin(UiUtilities.ZERO_INSETS); mEditSchemeBtn.setMargin(UiUtilities.ZERO_INSETS); mSaveSchemeBtn.setMargin(UiUtilities.ZERO_INSETS); mDeleteSchemeBtn.setEnabled(false); mEditSchemeBtn.setEnabled(false); newSchemeBtn.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { String newSchemeName = JOptionPane.showInputDialog( parent, mLocalizer.msg("enterNewSchemeName", "Enter new name for scheme:"), mLocalizer.msg("newScheme", "New scheme"), JOptionPane.PLAIN_MESSAGE); if (newSchemeName != null) { if (newSchemeName.trim().length() > 0) { Scheme newScheme = mDialogContent.createNewScheme(newSchemeName); newScheme.setSettings(mDialogContent.getSettings()); mSchemeCBModel.addElement(newScheme); mSchemeCB.setSelectedItem(newScheme); mDialogContent.setSettings(newScheme.getSettings()); } else { JOptionPane.showMessageDialog( parent, mLocalizer.msg("invalidSchemeMsg", "Invalid scheme name"), mLocalizer.msg("invalidInput", "Invalid input"), JOptionPane.INFORMATION_MESSAGE); } } } }); mSaveSchemeBtn.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { Scheme scheme = (Scheme) mSchemeCB.getSelectedItem(); scheme.setSettings(mDialogContent.getSettings()); } }); mEditSchemeBtn.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { Scheme scheme = (Scheme) mSchemeCB.getSelectedItem(); Object newSchemeName = JOptionPane.showInputDialog( parent, mLocalizer.msg("enterNewSchemeName", "Enter new name for scheme:"), mLocalizer.msg("editScheme", "Edit scheme"), JOptionPane.PLAIN_MESSAGE, null, null, scheme.getName()); if (newSchemeName != null) { if (newSchemeName.toString().trim().length() > 0) { scheme.setName(newSchemeName.toString()); mSchemeCB.repaint(); } else { JOptionPane.showMessageDialog( parent, mLocalizer.msg("invalidSchemeMsg", "Invalid scheme name"), mLocalizer.msg("invalidInput", "Invalid input"), JOptionPane.INFORMATION_MESSAGE); } } } }); mDeleteSchemeBtn.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent event) { Scheme scheme = (Scheme) mSchemeCB.getSelectedItem(); if (scheme != null) { if (JOptionPane.showConfirmDialog( parent, mLocalizer.msg( "deleteSchemeMsg", "Do you want to delete the selected scheme?"), mLocalizer.msg("deleteScheme", "Delete Scheme"), JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) { mSchemeCBModel.removeElement(scheme); mSchemeCB.setSelectedIndex(0); } } } }); mSchemeCBModel = new DefaultComboBoxModel(schemes); mSchemeCB = new JComboBox(mSchemeCBModel); JPanel schemePanel = new JPanel(); schemePanel.add(mSchemeCB); schemePanel.add(newSchemeBtn); schemePanel.add(mEditSchemeBtn); schemePanel.add(mSaveSchemeBtn); schemePanel.add(mDeleteSchemeBtn); southPanel.add(schemePanel, BorderLayout.WEST); mSchemeCB.addItemListener( new ItemListener() { public void itemStateChanged(ItemEvent e) { mDeleteSchemeBtn.setEnabled(mSchemeCB.getSelectedIndex() != 0); mEditSchemeBtn.setEnabled(mSchemeCB.getSelectedIndex() != 0); Scheme scheme = (Scheme) mSchemeCB.getSelectedItem(); mDialogContent.setSettings(scheme.getSettings()); } }); contentPane.add(eastPanel, BorderLayout.EAST); contentPane.add(southPanel, BorderLayout.SOUTH); contentPane.add(content.getContent(), BorderLayout.CENTER); content.setSettings(schemes[0].getSettings()); if (mPageFormat == null) { mPageFormat = printerJob.defaultPage(); } PrintPlugin.getInstance().layoutWindow("settingsDlg", this, new Dimension(450, 400)); mResult = CANCEL; }