66import UI .common .NBSAbstractPanel ;
77import UI .common .ToolbarStatsPanel ;
88import UI .templete .WihteBackJPanel ;
9+ import com .nbs .entity .ContactsItem ;
910import com .nbs .entity .PeerInfoBase ;
1011import com .nbs .tools .DateHelper ;
1112import com .nbs .ui .components .ColorCnst ;
2829public class IMPanel extends NBSAbstractPanel {
2930 private static final long serialVersionUID = 1L ;
3031 public static final String PKUI_PANEL_IM_LABEL = "nbs.ui.panel.im.label" ;
32+ private static IMPanel context ;
3133
3234 /**
3335 * 在线peers
3436 */
35- private static JPanel peersJPanel ;
36-
3737 private static JPanel peerList ;
38+ /**
39+ * 左侧IM peers
40+ */
41+ private ImLeftPanel leftPanel ;
3842
3943 private static JScrollPane scrollPane ;
4044
4145 private static JTextArea imMSGShow = new JTextArea ();
46+ /**
47+ * 顶部显示
48+ */
49+ private static ToolbarStatsPanel toolbarStatsPanel = new ToolbarStatsPanel (PKUI_PANEL_IM_LABEL );;
4250 /**
4351 *
4452 */
@@ -47,6 +55,10 @@ public class IMPanel extends NBSAbstractPanel {
4755 private static JTextArea inputArea = new JTextArea ();
4856
4957 private PeerInfoBase currentContactPeer = null ;
58+ /**
59+ *
60+ */
61+ private static ContactsItem CURRENT_TO_CONTACTS_ITEM = null ;
5062
5163
5264
@@ -64,6 +76,7 @@ public class IMPanel extends NBSAbstractPanel {
6476
6577 public IMPanel (boolean isDoubleBuffered ) {
6678 super (isDoubleBuffered );
79+ context = this ;
6780 }
6881
6982 @ Override
@@ -73,13 +86,11 @@ protected void init() {
7386
7487 @ Override
7588 protected void addComponent () {
76- ToolbarStatsPanel toolbarStatsPanel = new ToolbarStatsPanel (PKUI_PANEL_IM_LABEL );
7789 this .add (toolbarStatsPanel ,BorderLayout .NORTH );
7890 /**
7991 *
8092 */
8193 this .add (getCenterPanel (),BorderLayout .CENTER );
82-
8394 }
8495
8596
@@ -97,13 +108,18 @@ private JPanel getCenterPanel(){
97108 WihteBackJPanel centerPanel = new WihteBackJPanel ();
98109 centerPanel .setLayout (new BorderLayout ());
99110
111+ /**
112+ *
113+ */
100114 peerList = new JPanel ();
101- peerList .setBackground (new Color (221 ,221 ,221 ));
102- Dimension leftDimsnsion = new Dimension (245 ,ConstantsUI .MAIN_WINDOW_HEIGHT );
115+ Dimension leftDimsnsion = new Dimension (260 ,ConstantsUI .MAIN_WINDOW_HEIGHT );
103116 peerList .setPreferredSize (leftDimsnsion );
104117 peerList .setLayout (new FlowLayout (FlowLayout .LEFT ,0 ,0 ));
105118
106- centerPanel .add (peerList ,BorderLayout .WEST );
119+ leftPanel = new ImLeftPanel ();
120+ leftPanel .setPreferredSize (leftDimsnsion );
121+
122+ centerPanel .add (leftPanel ,BorderLayout .WEST );
107123
108124 /**
109125 * 聊天主窗口
@@ -246,10 +262,28 @@ private void sendMsg(){
246262 } catch (Exception e ) {
247263 e .printStackTrace ();
248264 }
265+ }
249266
267+ public static void setCurrentToPeer (ContactsItem item ){
268+ CURRENT_TO_CONTACTS_ITEM = item ;
269+ }
250270
271+ /**
272+ * 切换聊天peer
273+ */
274+ public void contactsItemChanged (ContactsItem item ){
275+ //TODO
276+ CURRENT_TO_CONTACTS_ITEM = item ;
277+ if (item ==null )return ;
278+ toolbarStatsPanel .resetContacts (item .getName ());
251279
280+ }
252281
253-
282+ /**
283+ *
284+ * @return
285+ */
286+ public static IMPanel getContext () {
287+ return context ;
254288 }
255289}
0 commit comments