Esempio n. 1
0
  private void saveNotes() {
    String note = textPane.getText();

    // Check for empty note.
    if (!ModelUtil.hasLength(note)) {
      return;
    }

    // Save note.
    AgentSession agentSession = FastpathPlugin.getAgentSession();
    try {
      agentSession.setNote(sessionID, note);
      saveButton.setEnabled(false);
      statusLabel.setText(" " + FpRes.getString("message.notes.updated"));
      SwingWorker worker =
          new SwingWorker() {
            public Object construct() {
              try {
                Thread.sleep(3000);
              } catch (InterruptedException e1) {
                Log.error(e1);
              }
              return true;
            }

            public void finished() {
              statusLabel.setText("");
            }
          };
      worker.start();
    } catch (XMPPException e1) {
      showError(FpRes.getString("message.unable.to.update.notes"));
      Log.error("Could not commit note.", e1);
    }
  }
Esempio n. 2
0
  public void showDialog() {
    if (notesFrame != null && notesFrame.isVisible()) {
      return;
    }

    notesFrame = new JFrame(FpRes.getString("title.chat.notes"));
    notesFrame.setIconImage(SparkManager.getMainWindow().getIconImage());
    notesFrame.getContentPane().setLayout(new BorderLayout());
    notesFrame.getContentPane().add(new JScrollPane(this), BorderLayout.CENTER);
    notesFrame.pack();
    notesFrame.setSize(500, 400);

    notesFrame.setLocationRelativeTo(SparkManager.getChatManager().getChatContainer());
    notesFrame.setVisible(true);

    textPane.requestFocusInWindow();
  }
Esempio n. 3
0
  public Notes(String sessionID, ChatRoom room) {
    setLayout(new BorderLayout());

    this.chatRoom = room;

    this.sessionID = sessionID;

    textPane = new JTextPane();
    textPane.setText(FpRes.getString("message.click.to.add.notes"));
    textPane.addMouseListener(
        new MouseAdapter() {
          public void mouseClicked(MouseEvent e) {
            if (!hasClickedInPane) {
              textPane.setText("");
              hasClickedInPane = true;
            }
          }
        });

    scrollPane = new JScrollPane(textPane);

    this.add(scrollPane, BorderLayout.CENTER);

    toolBar = new JToolBar();
    toolBar.setFloatable(false);

    saveButton = new RolloverButton(FastpathRes.getImageIcon(FastpathRes.SAVE_AS_16x16));

    toolBar.add(saveButton);

    ResourceUtils.resButton(saveButton, FpRes.getString("button.save.note"));

    final BackgroundPane titlePanel = new BackgroundPane();
    titlePanel.setLayout(new GridBagLayout());

    JLabel notesLabel = new JLabel();
    notesLabel.setFont(new Font("Dialog", Font.BOLD, 12));

    ResourceUtils.resLabel(notesLabel, textPane, FpRes.getString("label.notes"));

    JLabel descriptionLabel = new JLabel();
    descriptionLabel.setText(FpRes.getString("message.chat.notes"));

    titlePanel.add(
        notesLabel,
        new GridBagConstraints(
            0,
            0,
            1,
            1,
            1.0,
            0.0,
            GridBagConstraints.WEST,
            GridBagConstraints.HORIZONTAL,
            new Insets(5, 5, 5, 5),
            0,
            0));
    titlePanel.add(
        descriptionLabel,
        new GridBagConstraints(
            0,
            1,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.WEST,
            GridBagConstraints.HORIZONTAL,
            new Insets(5, 10, 5, 5),
            0,
            0));
    titlePanel.add(
        saveButton,
        new GridBagConstraints(
            1,
            1,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.WEST,
            GridBagConstraints.HORIZONTAL,
            new Insets(5, 10, 5, 5),
            0,
            0));

    // add(titlePanel, BorderLayout.NORTH);

    textPane
        .getDocument()
        .addDocumentListener(
            new DocumentListener() {
              public void changedUpdate(DocumentEvent e) {
                saveButton.setEnabled(true);
                updated = true;
              }

              public void insertUpdate(DocumentEvent e) {
                saveButton.setEnabled(true);
                updated = true;
              }

              public void removeUpdate(DocumentEvent e) {
                saveButton.setEnabled(true);
                updated = true;
              }
            });

    saveButton.setEnabled(false);

    // Add status label
    statusLabel = new JLabel();
    this.add(statusLabel, BorderLayout.SOUTH);

    chatRoom.addClosingListener(
        new ChatRoomClosingListener() {
          public void closing() {
            if (updated) {
              saveNotes();
            }
          }
        });
  }
Esempio n. 4
0
 public void showError(String error) {
   JOptionPane.showMessageDialog(
       this, error, FpRes.getString("title.notes"), JOptionPane.ERROR_MESSAGE);
 }