コード例 #1
0
ファイル: ChatRoomImpl.java プロジェクト: kadet108/blucargo
  private void loadHistory() {
    // Add VCard Panel
    final VCardPanel vcardPanel = new VCardPanel(participantJID);

    vcardPanel.setPreferredSize(new Dimension(10, 71));
    vcardPanel.setMaximumSize(new Dimension(1100, 71));
    vcardPanel.setMinimumSize(new Dimension(1100, 71));

    getToolBar()
        .add(
            vcardPanel,
            new GridBagConstraints(
                0,
                1,
                1,
                1,
                1.0,
                0.0,
                GridBagConstraints.NORTHWEST,
                GridBagConstraints.HORIZONTAL,
                new Insets(0, 2, 0, 2),
                0,
                0));

    final LocalPreferences localPreferences = SettingsManager.getLocalPreferences();
    if (!localPreferences.isChatHistoryEnabled()) {
      return;
    }

    if (!localPreferences.isPrevChatHistoryEnabled()) {
      return;
    }

    final String bareJID = StringUtils.parseBareAddress(getParticipantJID());
    final ChatTranscript chatTranscript = ChatTranscripts.getCurrentChatTranscript(bareJID);
    final String personalNickname = SparkManager.getUserManager().getNickname();

    for (HistoryMessage message : chatTranscript.getMessages()) {
      String nickname = SparkManager.getUserManager().getUserNicknameFromJID(message.getFrom());
      String messageBody = message.getBody();
      if (nickname.equals(message.getFrom())) {
        String otherJID = StringUtils.parseBareAddress(message.getFrom());
        String myJID = SparkManager.getSessionManager().getBareAddress();

        if (otherJID.equals(myJID)) {
          nickname = personalNickname;
        } else {
          nickname = StringUtils.parseName(nickname);
        }
      }

      if (ModelUtil.hasLength(messageBody) && messageBody.startsWith("/me ")) {
        messageBody = messageBody.replaceFirst("/me", nickname);
      }

      final Date messageDate = message.getDate();
      getTranscriptWindow().insertHistoryMessage(nickname, messageBody, messageDate);
    }
  }
コード例 #2
0
ファイル: VCardEditor.java プロジェクト: kadet108/blucargo
  /**
   * Displays the VCard for an individual.
   *
   * @param vCard the users vcard.
   * @param parent the parent component, used for location.
   */
  public void editProfile(final VCard vCard, JComponent parent) {
    final JTabbedPane tabbedPane = new JTabbedPane();

    // Initialize Panels
    personalPanel = new PersonalPanel();
    personalPanel.showJID(false);

    businessPanel = new BusinessPanel();
    homePanel = new HomePanel();
    avatarPanel = new AvatarPanel();
    // employeePanel		= new EmployeePanel();

    String employeeOf = vCard.getField("employeeOf");
    if (vCard.getJabberId()
        == SparkManager.getUserManager()
            .getJIDFromDisplayName(SparkManager.getUserManager().getNickname())) {
      if ((employeeOf == null || employeeOf.isEmpty())) {
        employeeListPanel = new EmployeeListPanel();

        tabbedPane.addTab(Res.getString("tab.home"), homePanel);
        tabbedPane.addTab(Res.getString("tab.business"), personalPanel);
        tabbedPane.addTab(Res.getString("tab.business"), businessPanel);
        tabbedPane.addTab(Res.getString("tab.employees"), employeeListPanel); // zmienione
        employee = false;
      } else {
      }
    }

    tabbedPane.addTab(Res.getString("tab.avatar"), avatarPanel);

    // Build the UI
    buildUI(vCard);

    final JOptionPane pane;
    final JDialog dlg;

    TitlePanel titlePanel;

    ImageIcon icon = VCardManager.getAvatarIcon(vCard);
    if (icon == null) {
      icon = SparkRes.getImageIcon(SparkRes.BLANK_24x24);
    }

    // Create the title panel for this dialog
    titlePanel =
        new TitlePanel(
            Res.getString("title.edit.profile"), Res.getString("message.save.profile"), icon, true);

    // Construct main panel w/ layout.
    final JPanel mainPanel = new JPanel();
    mainPanel.setLayout(new BorderLayout());
    mainPanel.add(titlePanel, BorderLayout.NORTH);

    // The user should only be able to close this dialog.
    Object[] options = {Res.getString("save"), Res.getString("cancel")};
    pane =
        new JOptionPane(
            tabbedPane,
            JOptionPane.PLAIN_MESSAGE,
            JOptionPane.OK_CANCEL_OPTION,
            null,
            options,
            options[0]);

    mainPanel.add(pane, BorderLayout.CENTER);

    JOptionPane p = new JOptionPane();
    dlg = p.createDialog(parent, Res.getString("title.profile.information"));
    dlg.setModal(false);

    dlg.pack();
    dlg.setSize(600, 400);
    dlg.setResizable(true);
    dlg.setContentPane(mainPanel);
    dlg.setLocationRelativeTo(parent);

    PropertyChangeListener changeListener =
        new PropertyChangeListener() {
          public void propertyChange(PropertyChangeEvent e) {
            String value = (String) pane.getValue();
            if (Res.getString("cancel").equals(value)) {
              pane.removePropertyChangeListener(this);
              dlg.dispose();
            } else if (Res.getString("save").equals(value)) {
              //                    pane.removePropertyChangeListener(this);
              // dlg.dispose();
              // saveVCard();
              preSaveVCard();
            }
          }
        };

    // JPanel bottomPanel = (JPanel)pane.getComponent(0);

    JButton saveButton = new JButton();

    tabbedPane.addChangeListener(
        new ChangeListener() {

          @Override
          public void stateChanged(ChangeEvent e) {
            preSaveVCard();
          }
        });

    for (Component component : pane.getComponents()) {
      if (component instanceof JButton) {
        JButton b = (JButton) component;

        if (b.getText().equalsIgnoreCase("Save")) {
          saveButton = (JButton) component;
        }
      }
    }

    saveButton.addActionListener(
        new ActionListener() {

          @Override
          public void actionPerformed(ActionEvent e) {
            preSaveVCard();
          }
        });

    avatarPanel.setParentDialog(dlg);
    dlg.setVisible(true);
    dlg.toFront();
    dlg.requestFocus();

    personalPanel.focus();
  }
コード例 #3
0
ファイル: VCardEditor.java プロジェクト: kadet108/blucargo
  /**
   * Displays the VCard for an individual.
   *
   * @param vCard the users vcard.
   * @param parent the parent component, used for location.
   */
  public void viewFullProfile(final VCard vCard, JComponent parent) {
    final JTabbedPane tabbedPane = new JTabbedPane();

    // Initialize Panels
    personalPanel = new PersonalPanel();
    personalPanel.allowEditing(false);
    personalPanel.showJID(false);

    //        tabbedPane.addTab(Res.getString("tab.personal"), personalPanel);

    businessPanel = new BusinessPanel();
    businessPanel.allowEditing(false);
    tabbedPane.addTab(Res.getString("tab.business"), businessPanel);

    homePanel = new HomePanel();
    homePanel.allowEditing(false);
    //        tabbedPane.addTab(Res.getString("tab.home"), homePanel);

    avatarPanel = new AvatarPanel();
    avatarPanel.allowEditing(false);
    tabbedPane.addTab(Res.getString("tab.avatar"), avatarPanel);

    //        employeePanel = new EmployeePanel();
    //        employeePanel.allowEditing(false);
    //        tabbedPane.addTab("Pracownicy", employeePanel);

    String employeeOf = vCard.getField("employeeOf");
    if (vCard.getJabberId()
        == SparkManager.getUserManager()
            .getJIDFromDisplayName(SparkManager.getUserManager().getNickname())) {
      if ((employeeOf == null || employeeOf.isEmpty())) {
        employeeListPanel = new EmployeeListPanel();
        tabbedPane.addTab(Res.getString("tab.home"), homePanel);
        tabbedPane.addTab(Res.getString("tab.business"), businessPanel);
        tabbedPane.addTab("Pracownicy", employeeListPanel);
        employee = false;
      } else {

      }
    }

    // Build the UI
    buildUI(vCard);

    final JOptionPane pane;
    final JDialog dlg;

    TitlePanel titlePanel;

    ImageIcon icon = VCardManager.getAvatarIcon(vCard);
    if (icon == null) {
      icon = SparkRes.getImageIcon(SparkRes.BLANK_24x24);
    }

    // Create the title panel for this dialog
    titlePanel = new TitlePanel(Res.getString("title.profile.information"), "", icon, true);

    // Construct main panel w/ layout.
    final JPanel mainPanel = new JPanel();
    mainPanel.setLayout(new BorderLayout());
    mainPanel.add(titlePanel, BorderLayout.NORTH);

    // The user should only be able to close this dialog.
    Object[] options = {Res.getString("close")};
    pane =
        new JOptionPane(
            tabbedPane,
            JOptionPane.PLAIN_MESSAGE,
            JOptionPane.OK_CANCEL_OPTION,
            null,
            options,
            options[0]);

    mainPanel.add(pane, BorderLayout.CENTER);

    JOptionPane p = new JOptionPane();
    dlg = p.createDialog(parent, Res.getString("title.profile.information"));
    dlg.setModal(false);

    dlg.pack();
    dlg.setSize(600, 400);
    dlg.setResizable(true);
    dlg.setContentPane(mainPanel);
    dlg.setLocationRelativeTo(parent);

    PropertyChangeListener changeListener =
        new PropertyChangeListener() {
          public void propertyChange(PropertyChangeEvent e) {
            Object o = pane.getValue();
            if (o instanceof Integer) {
              pane.removePropertyChangeListener(this);
              dlg.dispose();
              return;
            }

            String value = (String) pane.getValue();
            if (Res.getString("close").equals(value)) {
              pane.removePropertyChangeListener(this);
              dlg.dispose();
            }
          }
        };

    pane.addPropertyChangeListener(changeListener);

    dlg.setVisible(true);
    dlg.toFront();
    dlg.requestFocus();

    personalPanel.focus();
  }