⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 sendclusterimwindow.java

📁 lumaQQ的源文件
💻 JAVA
📖 第 1 页 / 共 4 页
字号:
            }
        });
        inputForm.setTopLeft(tb);
        ToolBar tbSwitch = new ToolBar(inputForm, SWT.FLAT);
        tbSwitch.setBackground(Colors.VIEWFORM_BANNER_BACKGROUND);
        ToolItem tiSwitch = new ToolItem(tbSwitch, SWT.NONE);
        tiSwitch.setImage(res.getImage(Resources.icoRightArrow));
        tiSwitch.setToolTipText(tooltip_button_hide);
        inputForm.setTopRight(tbSwitch);
        inputBox = new RichBox(inputForm);
        inputBox.setBackground(Colors.WHITE);
        inputForm.setContent(inputBox);
        tiSwitch.addSelectionListener(new SelectionAdapter() {
            public void widgetSelected(SelectionEvent e) {
				ToolItem item = (ToolItem)e.getSource();
                GridData d = (GridData)sideContainer.getLayoutData();
				d.exclude = !d.exclude;
				d = (GridData)vSash.getLayoutData();
				d.exclude = !d.exclude;
				if(d.exclude) {
					sideContainer.setVisible(false);
					((GridData)chatContainer.getLayoutData()).horizontalSpan = 3;
                    item.setImage(res.getImage(Resources.icoLeftArrow));
                    item.setToolTipText(tooltip_button_show);
				} else {
					sideContainer.setVisible(true);
					((GridData)chatContainer.getLayoutData()).horizontalSpan = 1;
                    item.setImage(res.getImage(Resources.icoRightArrow));
                    item.setToolTipText(tooltip_button_hide);
				}
				
                sideContainer.getParent().layout();
            }
        });
        
        // 垂直sash
        vSash = new Sash(container, SWT.VERTICAL);
        gd = new GridData(GridData.FILL_VERTICAL);
        gd.verticalSpan = 2;
		vSash.setLayoutData(gd);
		vSash.setBackground(Colors.MAINSHELL_BACKGROUND);
		vSash.addSelectionListener(new SelectionAdapter() {
            public void widgetSelected(SelectionEvent e) {
                GridData d = (GridData)sideContainer.getLayoutData();   
                GridLayout l = (GridLayout)sideContainer.getParent().getLayout();
                d.widthHint = sideContainer.getParent().getClientArea().width - e.x - (l.marginWidth << 1);
                sideContainer.getParent().layout();
            }
        });
        
        // 成员列表区
        sideContainer = new Composite(container, SWT.NONE);
        gd = new GridData(GridData.FILL_VERTICAL);
        gd.verticalSpan = 2;
        gd.widthHint = 140;
        sideContainer.setLayoutData(gd);
        layout = new GridLayout();
        layout.marginHeight = layout.marginWidth = 1;
        layout.horizontalSpacing = layout.verticalSpacing = 0;
        sideContainer.setLayout(layout);
        sideContainer.addPaintListener(new PaintListener() {
            public void paintControl(PaintEvent e) {
                Composite c = (Composite)e.getSource();
                Rectangle rect = c.getClientArea();
                rect.width--;
                rect.height--;
                if(rect.width > 0 && rect.height > 0) {
	                e.gc.setForeground(Colors.WIDGET_BORDER);
	                e.gc.drawRectangle(rect);                    
                }
            }
        });
        
        // 群栏目
        MouseTrackListener mtl = new MouseTrackAdapter() {
        	@Override
        	public void mouseEnter(MouseEvent e) {
        		if(!infoBar.isVisible())
        			infoBar.setVisible(true);
        	}
        	@Override
        	public void mouseExit(MouseEvent e) {
        		Control control = main.getDisplay().getCursorControl();
        		if(control == null)
        			infoBar.setVisible(false);
        		else if(control == infoBar ||
        				control == noticeContainer ||
        				control.getParent() == noticeContainer)
        			return;
        		else
        			infoBar.setVisible(false);
        	}
        };
        
        if(model.isPermanent()) {
        	infoForm = new ViewForm(sideContainer, SWT.FLAT);
        	gd = new GridData(GridData.FILL_HORIZONTAL);
        	gd.heightHint = 140; 
        	infoForm.setLayoutData(gd);
        	final CLabel lblExpand = new CLabel(infoForm, SWT.LEFT);
        	lblExpand.setImage(res.getImage(Resources.icoFlatCollapse));
        	lblExpand.setText(cluster_im_list_info);
        	lblExpand.setBackground(Colors.VIEWFORM_BANNER_BACKGROUND);
        	lblExpand.setForeground(Colors.VIEWFORM_BANNER_TEXT);
        	infoForm.setTopLeft(lblExpand);
        	lblExpand.addMouseListener(new MouseAdapter() {
        		@Override
        		public void mouseUp(MouseEvent e) {
        			infoFormExpanded = !infoFormExpanded;
        			if(infoFormExpanded) {
        				lblExpand.setImage(res.getImage(Resources.icoFlatCollapse));
        				GridData gd = (GridData)infoForm.getLayoutData();
        				gd.heightHint = 140;
        				sideContainer.layout();
        			} else {
        				lblExpand.setImage(res.getImage(Resources.icoFlatExpand));
        				GridData gd = (GridData)infoForm.getLayoutData();
        				gd.heightHint = infoForm.getTopLeft().getSize().y;
        				sideContainer.layout();
        			}
        		}
        	});
        	Composite content = new Composite(infoForm, SWT.NONE);
        	content.setLayout(new FormLayout());
        	FormData fd = new FormData();
        	fd.left = fd.top = new FormAttachment(0, 0);
        	fd.bottom = fd.right = new FormAttachment(100, 0);
        	noticeContainer = new Composite(content, SWT.NONE);
        	noticeContainer.setBackground(Colors.TOOLTIP_BACKGROUND);
        	noticeContainer.setLayout(new GridLayout());
        	noticeContainer.setLayoutData(fd);
        	CLabel lblNotice = new CLabel(noticeContainer, SWT.LEFT);
        	lblNotice.setImage(res.getImage(Resources.icoSysMsg));
        	lblNotice.setText(cluster_im_label_notice);
        	lblNotice.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_CENTER));
        	lblNotice.setBackground(noticeContainer.getBackground());
        	lblNotice.addMouseTrackListener(mtl);
        	textNotice = new Text(noticeContainer, SWT.MULTI | SWT.WRAP | SWT.READ_ONLY);
        	textNotice.setBackground(noticeContainer.getBackground());
        	textNotice.setLayoutData(new GridData(GridData.FILL_BOTH));
        	textNotice.addMouseTrackListener(mtl);
        	infoBar = new ToolBar(content, SWT.FLAT);
        	infoBar.setBackground(Colors.WHITE);
        	ToolItem tiInfo = new ToolItem(infoBar, SWT.PUSH);
        	tiInfo.setImage(res.getImage(Resources.icoClusterInfo));
        	tiInfo.setToolTipText(cluster_im_button_info);
        	tiInfo.addSelectionListener(new SelectionAdapter() {
        		@Override
        		public void widgetSelected(SelectionEvent e) {
					main.getShellLauncher().openClusterInfoWindow(model);
        		}
        	});
        	ToolItem tiCard = new ToolItem(infoBar, SWT.PUSH);
        	tiCard.setImage(res.getImage(Resources.icoClusterCard));
        	tiCard.setToolTipText(cluster_im_button_card);
        	tiCard.addSelectionListener(new SelectionAdapter() {
        		@Override
        		public void widgetSelected(SelectionEvent e) {
    				User u = model.getMember(main.getMyModel().qq);
    				if(u == null)
    					return;
   					u.info = main.getMyModel().info;
    				UserInfoWindow uiw = main.getShellLauncher().openUserInfoWindow(u, UserInfoWindow.EDITABLE);
    				uiw.setCurrentPage(UserInfoWindow.CARD);
        		}
        	});
        	ToolItem tiUpdate = new ToolItem(infoBar, SWT.PUSH);
        	tiUpdate.setImage(res.getImage(Resources.icoRefresh));
        	tiUpdate.setToolTipText(cluster_im_button_update);
        	tiUpdate.addSelectionListener(new SelectionAdapter() {
        		@Override
        		public void widgetSelected(SelectionEvent e) {
        			main.getClient().getClusterInfo(model.clusterId);
        			model.cardUpdated = false;
    				main.getClient().getCardBatch(model.clusterId, 0);
        		}
        	});
        	fd = new FormData();
        	fd.right = fd.bottom = new FormAttachment(100, 0);
        	infoBar.setLayoutData(fd);
        	infoBar.moveAbove(noticeContainer);
        	infoBar.setVisible(false);
        	infoBar.addMouseTrackListener(mtl);
        	infoBar.addPaintListener(new PaintListener() {
        		public void paintControl(PaintEvent e) {
        			Rectangle rect = infoBar.getClientArea();
        			e.gc.setForeground(Colors.PAGE_CONTROL_BORDER);
        			rect.height--;
        			rect.width--;
        			e.gc.drawRectangle(rect);
        		}
        	});
        	noticeContainer.addMouseTrackListener(mtl);
        	infoForm.setContent(content);
        	setNotice(model.notice);        	
        }
        
        // 群成员列表
        ViewForm listForm = new ViewForm(sideContainer, SWT.FLAT);
        listForm.setLayoutData(new GridData(GridData.FILL_BOTH));
        lblList = new CLabel(listForm, SWT.LEFT);
        lblList.setImage(res.getSmallClusterHead(6));
        lblList.setBackground(Colors.VIEWFORM_BANNER_BACKGROUND);
        lblList.setForeground(Colors.VIEWFORM_BANNER_TEXT);
        setListLabel(model.members.size(), 0);
        listForm.setTopLeft(lblList);
        listViewer = new TableViewer(listForm, SWT.SINGLE | SWT.V_SCROLL | SWT.FULL_SELECTION);
        listViewer.setContentProvider(new MapValueContentProvider(model.members));
        listViewer.setLabelProvider(new ClusterMemberLabelProvider());
        listViewer.setSorter(new ModelSorter());
        listViewer.setInput(this);
        Table t = listViewer.getTable();
        new TableColumn(t, SWT.LEFT);
        new TableColumn(t, SWT.LEFT);
        t.addControlListener(new ControlAdapter() {
            public void controlResized(ControlEvent e) {
                Table table = (Table)e.getSource();
                table.getColumn(0).setWidth(20);
                table.getColumn(1).setWidth(table.getClientArea().width - 20);
            }
        });
        t.addMouseListener(new MouseAdapter() {
            public void mouseUp(MouseEvent e) {
                if(e.button == 3) {        
                    Table table = (Table)e.getSource();
                    memberMenu.setLocation(table.toDisplay(e.x, e.y));
                    memberMenu.setVisible(true);
                }
            }
        });
        t.addSelectionListener(new SelectionAdapter() {
            public void widgetDefaultSelected(SelectionEvent e) {
			    IStructuredSelection selection = (IStructuredSelection)listViewer.getSelection();	    
				if(!selection.isEmpty()) {
					User f = (User)selection.getFirstElement();
					main.getShellLauncher().openUserInfoWindow(f, UserInfoWindow.READ_ONLY);
					main.getClient().getUserInfo(f.qq);
				}
            }
        });
        t.setHeaderVisible(false);
        t.setLinesVisible(false);        
        listViewer.setInput(this);
        listForm.setContent(t);           
        
        // 按钮区
        Composite buttonContainer = new Composite(container, SWT.NONE);
        gd = new GridData(GridData.FILL_HORIZONTAL);
        buttonContainer.setLayoutData(gd);
        layout = new GridLayout(4, false);
        layout.marginHeight = layout.marginWidth = layout.verticalSpacing = layout.horizontalSpacing = 0;
        buttonContainer.setLayout(layout);
        buttonContainer.setBackground(container.getBackground());
        
        Slat btnRecord = new Slat(buttonContainer);
        btnRecord.setText(button_record_accel);
        btnRecord.setLayoutData(new GridData());
        btnRecord.addMouseListener(new MouseAdapter() {
            public void mouseUp(MouseEvent e) {
				Slat temp = (Slat) e.getSource();
				if (e.x > temp.getSize().x || e.y > temp.getSize().y || e.x < 0 || e.y < 0) {
					return;
				}
                showRecord();
            }
        });
        
        Slat btnClose = new Slat(buttonContainer);
        btnClose.setText(button_close_accel);
        gd = new GridData(GridData.HORIZONTAL_ALIGN_END);
        gd.grabExcessHorizontalSpace = true;
        btnClose.setLayoutData(gd);
		btnClose.addMouseListener(new MouseAdapter() {
			public void mouseUp(MouseEvent e) {
				Slat temp = (Slat) e.getSource();
				if (e.x > temp.getSize().x || e.y > temp.getSize().y || e.x < 0 || e.y < 0) {
					return;
				}
			    closeAction.run();
			}
		});
        
        final Slat btnSend = new Slat(buttonContainer);
        btnSend.setText(button_send_accel);
        gd = new GridData();
        gd.horizontalIndent = 3;
        btnSend.setLayoutData(gd);
		btnSend.addMouseListener(new MouseAdapter() {
			public void mouseUp(MouseEvent e) {
				Slat temp = (Slat) e.getSource();
				if (e.x > temp.getSize().x || e.y > temp.getSize().y || e.x < 0 || e.y < 0) {
					return;
				}
				sendMessage(inputBox.getText());
			}
		});
        
        Slat btnDropDown = new Slat(buttonContainer, SWT.ARROW_DOWN);
        btnDropDown.setText("↓");
        gd = new GridData();
        gd.horizontalIndent = 1;
        btnDropDown.setLayoutData(gd);
        btnDropDown.addMouseListener(new MouseAdapter() {
            public void mouseUp(MouseEvent e) {
				Slat temp = (Slat) e.getSource();
				if (e.x > temp.getSize().x || e.y > temp.getSize().y || e.x < 0 || e.y < 0) {
					return;
				}
				// 设置菜单位置
				Rectangle bound = btnSend.getBounds();
				enterMenu.setLocation(btnSend.getParent().toDisplay(bound.x, bound.y + bound.height));
				// 显示菜单
				enterMenu.setVisible(true);
            }
		});
        
		// 聊天记录面板
		viewer = new RecordViewer(container, new ClusterRecordProvider(model), main);
		viewer.setFont(res.getDefaultFont());
		viewer.setRecordManager(main.getRecordManager());
		viewer.setVisible(false);
		viewer.setBackground(container.getBackground());
		gd = new GridData(GridData.FILL_HORIZONTAL);
		gd.horizontalSpan = 3;
		gd.heightHint = 200;
		gd.exclude = true;
		viewer.setLayoutData(gd);
		// tableitem双击事件监听器
		viewer.addSelectionListener(new SelectionAdapter() {
			public void widgetDefaultSelected(SelectionEvent e) {
				inputBox.appendText(viewer.getSelectedFullText(), main.getDefaultStyle());
			}
		});
		
		// 初始化菜单
		initEnterMenu();
		initMemberMenu();
		
		// 初始化快捷键设置
		initKeyAction();
		
        return container;
    }
    
    /**
     * 打开表情选择窗口
     */
    private void openImageSelectionShell(Point loc) {
    	ImageSelector fss = new ImageSelector(getShell(), new FaceImageAdvisor(main));
    	fss.setListener(this);
		fss.setLocation(loc);
		fss.open();	
    }

    /**
     * 初始化快捷键设置
     */
    private void initKeyAction() {
        // mod3 -> alt
        inputBox.setUserKeyAction('C' | SWT.MOD3, closeAction);
        inputBox.setUserKeyAction('S' | SWT.MOD3, sendAction);
        inputBox.setUserKeyAction('H' | SWT.MOD3, showRecordAction);
        
        // 发送消息的快捷键
        if(main.getOptionHelper().isUseEnterInTalkMode()) {
		    inputBox.removeUserKeyAction(SWT.MOD1 | SWT.CR);
		    inputBox.setUserKeyAction(SWT.CR, sendAction);
		    inputBox.setKeyBinding(SWT.MOD1 | SWT.CR, RichBox.NEW_LINE);
        } else {
		    inputBox.removeUserKeyAction(SWT.CR);
		    inputBox.setUserKeyAction(SWT.MOD1 | SWT.CR, sendAction);
		    inputBox.setKeyBinding(SWT.CR, RichBox.NEW_LINE);
        }           
    }

    /**
     * 刷新群名称标签
     */
    private void setClusterNameLabel() {
    	if(model.clusterType == ClusterType.NORMAL)
    		lblName.setImage(res.getSmallClusterHead(model.headId));

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -