private void jbInit() throws Exception { setTitle("Privacy Settings"); this.setSize(new Dimension(480, 160)); _separator.setBounds(new Rectangle(10, 60, 460, 1)); _buttonCancel.setLocation(165, 70); _buttonCancel.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent actionEvent) { _buttonCancel_actionPerformed(actionEvent); } }); _buttonOkay.setLocation(280, 70); _buttonOkay.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent actionEvent) { _buttonOkay_actionPerformed(actionEvent); } }); _checkBoxInvisible.setBounds(new Rectangle(10, 15, 230, 35)); _checkBoxUpdateLocation.setBounds(new Rectangle(245, 15, 230, 35)); _panelContent.add(_checkBoxInvisible, null); _panelContent.add(_checkBoxUpdateLocation, null); _panelContent.add(_separator, null); _panelContent.add(_buttonOkay, null); _panelContent.add(_buttonCancel, null); _checkBoxInvisible.setChecked(!Session.getInstance().getUserInfo().isLocationIsVisible()); _checkBoxUpdateLocation.setChecked(Settings.getInstance().getDTO().isUpdateMyLocation()); }
private void _buttonOkay_actionPerformed(ActionEvent actionEvent) { InfoUserTypeVO newInfoUserTypeVO = new InfoUserTypeVO(); newInfoUserTypeVO.setLocationIsVisible(!_checkBoxInvisible.isChecked()); try { API.getInstance().getUser().infoSet(Session.getInstance().getUserInfo(), newInfoUserTypeVO); } catch (Exception exception) { getParentPanel() .showWindow( new WarningWindow( "Unable to save", "Unable to save privacy settings. Please try it later.", 30, "privacy-settings-unable-to-save-warning.wav")); return; } try { Session.getInstance().setUserInfo(API.getInstance().getUser().infoGet(null)); } catch (Exception exception) { Debug.displayStack(this, exception); } Settings.getInstance().getDTO().setUpdateMyLocation(_checkBoxUpdateLocation.isChecked()); Settings.getInstance().save(); _buttonWindowClose_actionPerformed(null); }
public class SendToContactListWindow extends ModalWindow { private ScrollPane _scrollPaneContactList = new ScrollPane(); private JList _listContactList = new JList(Session.getInstance().getFriendList()); private ItemVO _itemVO; private MessageType _messageType; public SendToContactListWindow(ItemVO itemVO, MessageType messageType) { super(); try { _itemVO = itemVO; _messageType = messageType; jbInit(); } catch (Exception exception) { Debug.displayStack(this, exception); } } private void jbInit() throws Exception { this.setSize(new Dimension(560, 293)); setTitle("Please select a contact to send"); _scrollPaneContactList.setBounds(15, 10, 530, 237); _listContactList.setOpaque(false); _listContactList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); _listContactList.setCellRenderer(new ContactListRenderer()); _listContactList.addListSelectionListener( new ListSelectionListener() { public void valueChanged(ListSelectionEvent listSelectionEvent) { _listContactList_valueChanged(listSelectionEvent); } }); _listContactList.setVisibleRowCount(JLIST_VISIBLE_ROW_COUNT); _scrollPaneContactList.addScrollUpButtonActionListener( new ActionListener() { public void actionPerformed(ActionEvent actionEvent) { _scrollPaneContactList_scrollUp(actionEvent); } }); _scrollPaneContactList.addScrollDownButtonActionListener( new ActionListener() { public void actionPerformed(ActionEvent actionEvent) { _scrollPaneContactList_scrollDown(actionEvent); } }); _scrollPaneContactList.addToViewport(_listContactList); _panelContent.add(_scrollPaneContactList, null); } private void _listContactList_valueChanged(ListSelectionEvent listSelectionEvent) { try { if (!listSelectionEvent.getValueIsAdjusting()) { ItemVO contactItemVO = (ItemVO) _listContactList.getSelectedValue(); if (API.getInstance().getSocial().canMessageSend(contactItemVO.getService())) { if (_messageType == MessageType.TEXT) getParentPanel() .discardAndShowWindow( new MessageSendWindow( (ItemVO) _listContactList.getSelectedValue(), _itemVO, null)); else if (_messageType == MessageType.VOICE) getParentPanel() .discardAndShowWindow( new VoiceNoteSendWindow( (ItemVO) _listContactList.getSelectedValue(), _itemVO, null)); } else { getParentPanel() .showWindow( new WarningWindow( "Cannot send message", "The service \"" + contactItemVO.getService() + "\" does not let you send private messages to \"" + contactItemVO.getName() + "\". Please select another contact.", 30, "send-message-contact-list-can-not-send.wav")); _listContactList.clearSelection(); } } } catch (APICommunicationException apiCommunicationException) { Debug.displayStack(this, apiCommunicationException); } catch (APIProtocolException apiProtocolException) { Debug.displayStack(this, apiProtocolException); } } protected void _buttonWindowClose_actionPerformed(ActionEvent actionEvent) { getParentPanel().discardWindow(); } private void _scrollPaneContactList_scrollUp(ActionEvent actionEvent) { if (_listContactList.getFirstVisibleIndex() - _listContactList.getVisibleRowCount() >= 0) _listContactList.ensureIndexIsVisible( _listContactList.getFirstVisibleIndex() - _listContactList.getVisibleRowCount()); else _listContactList.ensureIndexIsVisible(0); } private void _scrollPaneContactList_scrollDown(ActionEvent actionEvent) { if (_listContactList.getLastVisibleIndex() + _listContactList.getVisibleRowCount() < _listContactList.getModel().getSize()) _listContactList.ensureIndexIsVisible( _listContactList.getLastVisibleIndex() + _listContactList.getVisibleRowCount()); else _listContactList.ensureIndexIsVisible(_listContactList.getModel().getSize()); } }