use of org.jivesoftware.smackx.workgroup.packet.Transcript in project Spark by igniterealtime.
the class ChatHistory method showTranscript.
private void showTranscript(String sessionID) {
if (frame == null) {
frame = new JFrame(FpRes.getString("title.chat.transcript"));
frame.setIconImage(SparkManager.getMainWindow().getIconImage());
}
if (frame.isVisible()) {
return;
}
Transcript transcript = null;
try {
transcript = FastpathPlugin.getAgentSession().getTranscript(sessionID);
} catch (XMPPException | SmackException e) {
Log.error("Error showing transcripts.", e);
}
if (transcript == null) {
JOptionPane.showMessageDialog(this, FpRes.getString("message.transcript.not.found.error"), FpRes.getString("title.error"), JOptionPane.ERROR_MESSAGE);
return;
}
final ChatViewer chatViewer = new ChatViewer(transcript);
frame.getContentPane().removeAll();
frame.getContentPane().setLayout(new BorderLayout());
frame.getContentPane().add(chatViewer, BorderLayout.CENTER);
frame.pack();
frame.setSize(600, 400);
frame.setLocationRelativeTo(mainFrame);
frame.setVisible(true);
}
use of org.jivesoftware.smackx.workgroup.packet.Transcript in project Spark by igniterealtime.
the class ChatSearch method search.
public void search(String query) {
final List<ChatSearchResult> results = new ArrayList<ChatSearchResult>();
AgentSession agentSession = FastpathPlugin.getAgentSession();
try {
Form form = agentSession.getTranscriptSearchForm();
Form filledForm = form.createAnswerForm();
filledForm.setAnswer("queryString", query);
// Define Workgroups
final List<String> workgroups = new ArrayList<String>();
workgroups.add(FastpathPlugin.getWorkgroup().getWorkgroupJID());
filledForm.setAnswer("workgroups", workgroups);
ReportedData reportedData = null;
try {
reportedData = agentSession.searchTranscripts(filledForm);
for (final ReportedData.Row row : reportedData.getRows()) {
ChatSearchResult result = new ChatSearchResult(row, query);
results.add(result);
}
} catch (XMPPException | SmackException e) {
Log.error(e);
}
Collections.sort(results, dateComporator);
DefaultListModel model = new DefaultListModel();
final JList list = new JList(model);
list.setCellRenderer(new HistoryItemRenderer());
Iterator<ChatSearchResult> iter = results.iterator();
while (iter.hasNext()) {
ChatSearchResult result = iter.next();
String person = result.getUsername();
String question = result.getQuestion();
String sessionID = result.getSessionID();
Date date = result.getStartDate();
final SearchItem item = new SearchItem(person, date, question);
item.setSessionID(sessionID);
model.addElement(item);
}
list.addMouseListener(new MouseAdapter() {
public void mouseClicked(MouseEvent e) {
if (e.getClickCount() == 2) {
SearchItem item = (SearchItem) list.getSelectedValue();
Transcript transcript = null;
try {
transcript = FastpathPlugin.getAgentSession().getTranscript(item.getSessionID());
} catch (XMPPException | SmackException ee) {
Log.error("Error showing transcripts.", ee);
}
if (transcript == null) {
return;
}
ChatViewer chatViewer = new ChatViewer(transcript);
final JFrame frame = new JFrame(FpRes.getString("title.chat.transcript"));
frame.setIconImage(SparkManager.getMainWindow().getIconImage());
frame.getContentPane().setLayout(new BorderLayout());
frame.getContentPane().add(chatViewer, BorderLayout.CENTER);
frame.pack();
frame.setSize(600, 400);
frame.setLocationRelativeTo(SparkManager.getMainWindow());
frame.setVisible(true);
}
}
});
JScrollPane scrollPane = new JScrollPane(list);
scrollPane.getViewport().setBackground(Color.white);
JFrame frame = new JFrame(FpRes.getString("title.search.results"));
frame.setIconImage(SparkManager.getMainWindow().getIconImage());
frame.getContentPane().setLayout(new BorderLayout());
frame.getContentPane().add(scrollPane, BorderLayout.CENTER);
final BackgroundPane titlePane = new BackgroundPane() {
private static final long serialVersionUID = -5603280927139789177L;
public Dimension getPreferredSize() {
final Dimension size = super.getPreferredSize();
size.width = 0;
return size;
}
};
titlePane.setLayout(new GridBagLayout());
titlePane.setBorder(BorderFactory.createMatteBorder(0, 0, 1, 0, Color.LIGHT_GRAY));
JLabel userImage = new JLabel(FastpathRes.getImageIcon(FastpathRes.FASTPATH_IMAGE_24x24));
userImage.setHorizontalAlignment(JLabel.LEFT);
userImage.setText(FpRes.getString("title.chat.transcripts.search"));
titlePane.add(userImage, new GridBagConstraints(0, 0, 4, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5), 0, 0));
userImage.setFont(new Font("Dialog", Font.BOLD, 12));
JLabel itemsFound = new JLabel(Integer.toString(results.size()));
titlePane.add(new JLabel(FpRes.getString("title.number.of.conversations.found")), new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0));
titlePane.add(itemsFound, new GridBagConstraints(1, 1, 3, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0));
JLabel searchTerm = new JLabel(FpRes.getString("query") + ": " + query);
titlePane.add(searchTerm, new GridBagConstraints(0, 2, 4, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 5, 5, 5), 0, 0));
frame.getContentPane().add(titlePane, BorderLayout.NORTH);
frame.pack();
frame.setSize(400, 400);
GraphicUtils.centerWindowOnScreen(frame);
frame.setVisible(true);
} catch (XMPPException | SmackException e) {
Log.error(e);
}
}
use of org.jivesoftware.smackx.workgroup.packet.Transcript in project ecf by eclipse.
the class TranscriptManager method getTranscript.
/**
* Returns the full conversation transcript of a given session.
*
* @param sessionID the id of the session to get the full transcript.
* @param workgroupJID the JID of the workgroup that will process the request.
* @return the full conversation transcript of a given session.
* @throws XMPPException if an error occurs while getting the information.
*/
public Transcript getTranscript(String workgroupJID, String sessionID) throws XMPPException {
Transcript request = new Transcript(sessionID);
request.setTo(workgroupJID);
PacketCollector collector = connection.createPacketCollector(new PacketIDFilter(request.getPacketID()));
// Send the request
connection.sendPacket(request);
Transcript response = (Transcript) collector.nextResult(SmackConfiguration.getPacketReplyTimeout());
// Cancel the collector.
collector.cancel();
if (response == null) {
throw new XMPPException("No response from server on status set.");
}
if (response.getError() != null) {
throw new XMPPException(response.getError());
}
return response;
}
use of org.jivesoftware.smackx.workgroup.packet.Transcript in project Smack by igniterealtime.
the class TranscriptManager method getTranscript.
/**
* Returns the full conversation transcript of a given session.
*
* @param sessionID the id of the session to get the full transcript.
* @param workgroupJID the JID of the workgroup that will process the request.
* @return the full conversation transcript of a given session.
* @throws XMPPErrorException
* @throws NoResponseException
* @throws NotConnectedException
* @throws InterruptedException
*/
public Transcript getTranscript(Jid workgroupJID, String sessionID) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
Transcript request = new Transcript(sessionID);
request.setTo(workgroupJID);
Transcript response = (Transcript) connection.createStanzaCollectorAndSend(request).nextResultOrThrow();
return response;
}
use of org.jivesoftware.smackx.workgroup.packet.Transcript in project Spark by igniterealtime.
the class UserHistory method showTranscript.
private void showTranscript(String sessionID) {
if (frame == null) {
frame = new JFrame(FpRes.getString("title.transcript"));
frame.setIconImage(SparkManager.getMainWindow().getIconImage());
}
if (frame.isVisible()) {
return;
}
Transcript transcript = null;
try {
transcript = FastpathPlugin.getAgentSession().getTranscript(sessionID);
} catch (XMPPException | SmackException e) {
Log.error("Error showing transcripts.", e);
}
if (transcript == null) {
return;
}
final ChatViewer chatViewer = new ChatViewer(transcript);
frame.getContentPane().removeAll();
frame.getContentPane().setLayout(new BorderLayout());
frame.getContentPane().add(chatViewer, BorderLayout.CENTER);
frame.pack();
frame.setSize(600, 400);
frame.setLocationRelativeTo(SparkManager.getMainWindow());
frame.setVisible(true);
}
Aggregations