| 注册
请输入搜索内容

热门搜索

Java Linux MySQL PHP JavaScript Hibernate jQuery Nginx
xilong008
11年前发布

spark部分代码分析,修改笔记

org.jivesoftware.resource  图片声音资料路径



1.修改字体:各个界面类中改11为12  org.jivesoftware--Spark.java--installBaseUIProperties()--setApplicationFont(new Font("Dialog", Font.PLAIN, 12));


2.聊天窗口加“发送”按钮:

org.jivesoftware.spark.ui--ChatRoom.java--ChatRoom()中加入如下代码:

  button = new JButton();
        button.addActionListener(new ActionListener() {
         public void actionPerformed(final ActionEvent arg0) {
                  sendMessage();
                    getChatInputEditor().setText("");
                    getChatInputEditor().setCaretPosition(0);
       
         }
        });
        button.setBorder(new EmptyBorder(0,0,0,0));
       
        button.setText("发送");
        button.setBounds(115, 181, 106, 28);
找到init()方法,加入:
 bottomPanel.add(button, new GridBagConstraints(4, 5, 1, 1, 0.0, 0.0, GridBagConstraints.EAST,
                GridBagConstraints.NONE, new Insets(0,0,5,10), 0, 0));


3.登录界面修改

设置个人头像位置路径
/spark/src/java/org/jivesoftware/sparkimpl/profile/AvatarPanel.java

/spark/src/java/org/jivesoftware/spark/ui/status/StatusBar.java   
 imageLabel.setIcon(Default.getImageIcon(Default.MAIN_IMAGE)); //584行,修改主界面个人头像为默认。    


登陆界面上部背景
LoginDialog.java
private final ImageIcon icons = Default.getImageIcon(Default.MAIN_IMAGE);

/spark/src/java/org/jivesoftware/resource/default.properties
default.properties--MAIN_IMAGE = images/spark.gif  //个人头像修改

/spark/src/java/org/jivesoftware/spark/ui/status/StatusBar.java  536-596行

 mainPanel.add(imagePanel,
        new GridBagConstraints(0,0, 1, 1, 1.0, 0.0,
                     GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(40,0,40,0),24,24)); //登陆界面设置头像大小为24x24,居中

mainPanel.add(loginPanel,
                   new GridBagConstraints(0, 2, 2, 1,
                           1.0, 1.0, GridBagConstraints.NORTHWEST, GridBagConstraints.BOTH,
                           new Insets(0, 0, 0, 0), 0,100));  //设置登陆框大小



//登陆界面加入状态下拉列表
/spark/src/resources/i18n/spark_i18n_zh_CN.properties
status.online=在线   status.pending=挂起  status.on.phone=电话中   

org.jivesoftware.spark.ui.status //状态栏包















4.个人信息
4.1
/spark/src/resources/i18n/spark_i18n_zh_CN.properties   tab.avatar 个性头像
menuitem.edit.my.profile=编辑我的简介 ...
menuitem.lookup.profile=查看简介 ...
/spark/src/java/org/jivesoftware/sparkimpl/profile/VCardEditor.java 个人资料编辑对话框

/spark/src/java/org/jivesoftware/sparkimpl/profile/PersonalPanel.java 修改“个人资料”编辑对话框布局
 JLabel firstNameLabel = new JLabel();
          firstNameField = new JTextField();
          ResourceUtils.resLabel(firstNameLabel, firstNameField, Res.getString("label.first.name") + ":");
          add(firstNameLabel, new GridBagConstraints(2, 0, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0));
          add(firstNameField, new GridBagConstraints(3, 0, 1, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5), 0, 0));

/spark/src/java/org/jivesoftware/sparkimpl/profile/VCardEditor.java     修改“编辑我的简介”对话框布局

label.job.title=(&J) 职务
修改对输入内容持久化
/spark/src/java/org/jivesoftware/sparkimpl/profile/VCardEditor.java
private void fillUI(VCard vcard){
  personalPanel.setFirstName(vcard.getFirstName());
        personalPanel.setMiddleName(vcard.getMiddleName());
。。。}

  private void saveVCard() {
final VCard vcard = new VCard();
// Save personal info
vcard.setFirstName(personalPanel.getFirstName());
vcard.setLastName(personalPanel.getLastName());

。。。}



4.2加个性签名
spark是没有签名功能的,为了满足用户的需求,需要加入签名功能,今天搞了搞 。不是很完美,以后会慢慢的完善。 我的思路是 :利用vcard中的中间名,修改成签名信息。

首先,要把布局修改下 workspace 中的buildlayout方法   statusbox.loadvcard 。在声明statusbox时候,进行了statusbox界面加载。 进入org.jivesoftware.spark.ui.status.StatusBar  在 StatusBar的构造方法中 进行了如下修改

         add(statusPanel, new GridBagConstraints(1, 0, 1, 1, 1.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(2,12, 0, 0), 0, 0));
        add(qianmingLabel, new GridBagConstraints(1, 1, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(0, 7, 0, 0), 0, 0));
         add(commandPanel, new GridBagConstraints(1, 2, 1, 1, 0.0, 0.0, GridBagConstraints.SOUTHWEST, GridBagConstraints.NONE, new Insets(0, 5, 0, 0), 0, 0));
  主要做的工作是 吧statuspanel移到了 nicknamelable位置,然后 把 nicknamelable加载到了statuspanel上

在statusbar中 要声明

   private JLabel qianmingLabel = new JLabel();

添加两个方法

   public void setQianMing(String qianming) {
        qianmingLabel.setText(qianming);
    }

    public JLabel getQianMingLabel() {
        return qianmingLabel;
    }

   String qianming=    SparkManager.getVCardManager().getVCard().getMiddleName();
     if(qianming!=null) setQianMing(qianming);

然后到statuspanel的构造方法内 进行如下修改

   add(nicknameLabel, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
            add(iconLabel, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
            add(statusLabel, new GridBagConstraints(2, 0, 1, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 2, 0, 0), 0, 0));

            statusLabel.setFont(new Font("宋体", Font.PLAIN, 11));
            statusLabel.setIcon(SparkRes.getImageIcon(SparkRes.DOWN_ARROW_IMAGE));
            statusLabel.setHorizontalTextPosition(JLabel.LEFT);
         // nicknameLabel.setToolTipText(SparkManager.getConnection().getUser());
          nicknameLabel.setFont(new Font("宋体", Font.BOLD, 12));
主要工作是把nicknamelabel 加到这个面板上。

接下来的工作就是要修改vcard了 把 中间名修改为状态。首先,修改界面

先修改下i18  zh_CN 吧 label.middle.name 修改为 签名信息

然后修改   把firstname  与 middlename进行位置调换

   // Handle First Name
        JLabel firstNameLabel = new JLabel();
        firstNameField = new JTextField();
        ResourceUtils.resLabel(firstNameLabel, firstNameField, Res.getString("label.first.name") + ":");

        add(firstNameLabel, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0));
        add(firstNameField, new GridBagConstraints(1, 1, 1, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5), 0, 0));

        // Handle Middle Name
        JLabel middleNameLabel = new JLabel();
        middleNameField = new JTextField();
        ResourceUtils.resLabel(middleNameLabel, middleNameField, Res.getString("label.middle.name") + ":");
        add(middleNameLabel, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0));
        add(middleNameField, new GridBagConstraints(1, 0, 1, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5), 0, 0)); 

然后在 vcardeditor(org.jivesoftware.sparkimpl.profile )saveVCard() 方法 添加如下代码

 

 vcard.setMiddleName(personalPanel.getMiddleName());
 SparkManager.getWorkspace().getStatusBar().getQianMingLabel().setText(personalPanel.getMiddleName()); //添加的代码。 作用就是 当点击保存的时候,进行statusbar签名信息更新。

最好 还要修改contactitem  要进行监听,设置签名信息  ,当用户修改签名的时候也要对应的进行更新

setstatusText 这个方法已经修改成了进行签名信息更新了 跟staus没有任何关系了

    public void setStatusText(String status) {
        String qianming=   SparkManager.getVCardManager().getVCard(getJID()).getMiddleName();
   
        if(qianming==null||qianming.equals("")){qianming="";}
        getDescriptionLabel().setText(qianming);

//        if (ModelUtil.hasLength(status)) {
//            getDescriptionLabel().setText(" - " + status);
//        }
//        else {
//            getDescriptionLabel().setText("");
//        }
    }

 

最后 在contactitem进行处理,生成contactitem的时候,要进行签名初始化;

 

 // 获取签名信息
    VCard vCard = SparkManager.getVCardManager().getVCard(fullyQualifiedJID);
    String qianming=vCard.getMiddleName();
    setStatusText(qianming);

5.设置面板。
样式面板
/spark/src/java/org/jivesoftware/spark/ui/themes/ThemePanel.java
        add(emoticonCheckBox, new GridBagConstraints(0, 2, 3, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); //342行,改布局位置



6.个人简介小窗口

/spark/src/java/org/jivesoftware/spark/ui/VCardViewer.java
204行:修改Email信息        final JLabel emailTimeLabel = new JLabel(Res.getString("label.email.address").replace("&", "") + ": ");
        add(emailTimeLabel, new GridBagConstraints(1, 3, 1, 1, 1.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, new Insets(0, 7, 2, 0), 0, 0));
        add(emailTime, new GridBagConstraints(1, 3, 1, 1, 1.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, new Insets(-3,81, 2, 0), 0, 0));

230-258行:修改 部门、职务、电话、手机

7.查找搜索
/spark/src/java/org/jivesoftware/sparkimpl/search/users/SearchForm.java
311行:职务信息


8.主界面
/spark/src/java/org/jivesoftware/spark/ui/ContactInfoWindow.java




9.个人信息悬浮窗口
/spark/src/java/org/jivesoftware/spark/ui/ContactInfoWindow.java

添加邮箱信息:
417行:   
     emailAddress = vcard.getEmailHome();
         if (!ModelUtil.hasLength(emailAddress)) {
        emailAddress = Res.getString("label.na");
         }
         Color linkColor = new Color(49, 89, 151);
         final String unselectedText = "<html><body><font color=" + GraphicUtils.toHTMLColor(linkColor) + "><u>" + emailAddress + "</u></font></body></html>";
         final String hoverText = "<html><body><font color=red><u>" + emailAddress + "</u></font></body></html>";
         emailTime.setText(unselectedText);
        //鼠标事件监听
         emailTime.addMouseListener(new MouseAdapter() {
            public void mouseClicked(MouseEvent e) {
                startEmailClient(emailAddress);
            }

            public void mouseEntered(MouseEvent e) {
                emailTime.setText(hoverText);
                setCursor(LINK_CURSOR);

            }

            public void mouseExited(MouseEvent e) {
                setCursor(DEFAULT_CURSOR);
            }
        });
150行:
JLabel emailtext=new JLabel();
        emailtext.setText(Res.getString("label.email.address")+":");
        add(emailtext,new GridBagConstraints(0, 7, 4, 1, 1.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, new Insets(0,5, 2, 2), 0, 0));
        add(emailTime, new GridBagConstraints(0,7,4, 1, 1.5, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, new Insets(-2,60, 2, 2), 0, 0));
        emailtext.setFont(new Font("Dialog", Font.PLAIN, 12));
        emailtext.setForeground(Color.gray);
460行:
设置窗体大小
        size.width = 300;
        size.height = 190;



10.主界面联系人列表

/spark/src/java/org/jivesoftware/spark/ui/ContactItem.java
需要修改显示联系人姓名(现在显示的是id)

资料卡中 nickname=生日,nickname可以取到,但在主窗口中取不到



11.搜索框
org.jivesoftware.spark.search/searchservice.java
93.97行,去掉锁子图标
//add(lockLabel, new GridBagConstraints(2, 1, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 0, 5, 15), 0, 0));


12."登陆设置"界面
/spark/src/java/org/jivesoftware/sparkimpl/settings/local/LocalPreferencePanel.java
/spark/src/java/org/jivesoftware/sparkimpl/settings/local/LocalPreference.java








 本文由用户 xilong008 自行上传分享,仅供网友学习交流。所有权归原作者,若您的权利被侵害,请联系管理员。
 转载本站原创文章,请注明出处,并保留原始链接、图片水印。
 本站是一个以用户分享为主的开源技术平台,欢迎各类分享!
 本文地址:https://www.open-open.com/lib/view/open1372294756041.html
电话/通讯/IM聊天 开源,im,spark Openfire