private ContactInformationPanel(User user) { super(); setLayout(new BoxLayout(this, BoxLayout.PAGE_AXIS)); JLabel lblName; JLabel lblPhone; JLabel lblEmail; String text = ""; // $NON-NLS-1$ String name = (user.getFirstname().trim().length() > 0 ? user.getFirstname().trim() + " " : ""); //$NON-NLS-1$ //$NON-NLS-2$ name += (user.getLastname().trim().length() > 0 ? user.getLastname().trim() : ""); // $NON-NLS-1$ if (name.trim().length() > 0) { text += name.trim(); text += " (" + user.getName().trim() + ")"; // $NON-NLS-1$ //$NON-NLS-2$ } else { text += user.getName().trim(); } lblName = new HTMLEscapedJLabel(text); add(lblName); if (user.getTelephone().length() > 0) { lblPhone = new HTMLEscapedJLabel(user.getTelephone()); add(lblPhone); } lblEmail = new HTMLEscapedJLabel(user.getEmail()); add(lblEmail); setBorder( BorderFactory.createTitledBorder( Messages.getString( "QuotaExceededDialog.border_title_contact_information"))); //$NON-NLS-1$ }
public QuotaExceededDialog(Vault vault) { super(); setTitle(Messages.getString("QuotaExceededDialog.window_title")); // $NON-NLS-1$ setModal(true); setLayout(new BorderLayout()); User owner = vault.getOwner(); User accountAdmin = BeaverGUI.getClient().getAccountAdmin(); User currentUser = BeaverGUI.getClient().getCurrentUser(); JPanel contentPanel = new JPanel(); contentPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 0, 5)); contentPanel.setLayout(new BoxLayout(contentPanel, BoxLayout.PAGE_AXIS)); JLabel infoLabel = new JLabel( Messages.getString("QuotaExceededDialog.explanation_1_no_capacity")); // $NON-NLS-1$ contentPanel.add(infoLabel); contentPanel.add(Box.createVerticalStrut(15)); JLabel contactLabel = new JLabel(); if (owner.getAccount().getId() == currentUser.getAccount().getId()) { if (currentUser.getId() == accountAdmin.getId()) { contactLabel.setText( Messages.getString( "QuotaExceededDialog.explanation_account_admin_purchase")); //$NON-NLS-1$ contentPanel.add(contactLabel); JLabel linkLabel = new JLabel(Messages.getString("QuotaExceededDialog.link_purchase")); // $NON-NLS-1$ linkLabel.setForeground(Color.BLUE); linkLabel.addMouseListener( new MouseListener() { @Override public void mouseReleased(MouseEvent arg0) {} @Override public void mousePressed(MouseEvent arg0) {} @Override public void mouseExited(MouseEvent arg0) { setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); } @Override public void mouseEntered(MouseEvent arg0) { setCursor(new Cursor(Cursor.HAND_CURSOR)); } @Override public void mouseClicked(MouseEvent arg0) { Desktop desktop = Desktop.getDesktop(); try { desktop.browse( new URI( Messages.getString( "QuotaExceededDialog.subscription_link"))); //$NON-NLS-1$ } catch (IOException e) { e.printStackTrace(); } catch (URISyntaxException e) { e.printStackTrace(); } } }); contentPanel.add(linkLabel); } else { contactLabel.setText( Messages.getString( "QuotaExceededDialog.explanation_2_normal_user_own_account")); //$NON-NLS-1$ contentPanel.add(contactLabel); contentPanel.add(Box.createVerticalStrut(10)); contentPanel.add(new ContactInformationPanel(accountAdmin)); } } else { contactLabel.setText( Messages.getString("QuotaExceededDialog.explanation_2_external_account")); // $NON-NLS-1$ contentPanel.add(contactLabel); contentPanel.add(Box.createVerticalStrut(10)); contentPanel.add(new ContactInformationPanel(owner)); } add(contentPanel, BorderLayout.CENTER); contentPanel.setPreferredSize(new Dimension(300, 150)); JButton closeButton = new JButton(Messages.getString("QuotaExceededDialog.button_close")); // $NON-NLS-1$ closeButton.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { dispose(); } }); add(closeButton, BorderLayout.SOUTH); pack(); setVisible(true); }