use of org.jivesoftware.spark.ui.history.HistoryWindow in project Spark by igniterealtime.
the class TranscriptWindow method poppingUp.
/**
* Adds Print and Clear actions.
*
* @param object the TransferWindow
* @param popup the popup menu to add to.
*/
public void poppingUp(final Object object, JPopupMenu popup) {
popup.addSeparator();
popup.add(new AbstractAction(Res.getString("action.print"), SparkRes.getImageIcon(SparkRes.PRINTER_IMAGE_16x16)) {
public void actionPerformed(ActionEvent actionEvent) {
SparkManager.printChatTranscript((TranscriptWindow) object);
}
});
if (!Default.getBoolean("HIDE_HISTORY_SETTINGS") && Enterprise.containsFeature(Enterprise.HISTORY_SETTINGS_FEATURE) && !Default.getBoolean("HISTORY_DISABLED") && Enterprise.containsFeature(Enterprise.HISTORY_TRANSCRIPTS_FEATURE)) {
popup.add(new AbstractAction(Res.getString("action.clear"), SparkRes.getImageIcon(SparkRes.ERASER_IMAGE)) {
public void actionPerformed(ActionEvent actionEvent) {
String user = null;
try {
ChatManager manager = SparkManager.getChatManager();
ChatRoom room = manager.getChatContainer().getActiveChatRoom();
user = room.getRoomname();
int ok = JOptionPane.showConfirmDialog((TranscriptWindow) object, Res.getString("delete.permanently"), Res.getString("delete.log.permanently"), JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE);
if (ok == JOptionPane.YES_OPTION) {
// This actions must be move into Transcript Plugin!
File transcriptDir = new File(SparkManager.getUserDirectory(), "transcripts");
File transcriptFile = new File(transcriptDir, user + ".xml");
transcriptFile.delete();
transcriptFile = new File(transcriptDir, user + "_current.xml");
transcriptFile.delete();
clear();
}
} catch (Exception ex) {
Log.error("An exception occurred while trying to clear history for a chat room " + user, ex);
}
}
});
}
// History window
if (!Default.getBoolean("HISTORY_DISABLED") && Enterprise.containsFeature(Enterprise.HISTORY_TRANSCRIPTS_FEATURE)) {
popup.add(new AbstractAction(Res.getString("action.viewlog")) {
@Override
public void actionPerformed(ActionEvent e) {
ChatRoom room = null;
try {
room = SparkManager.getChatManager().getChatContainer().getActiveChatRoom();
HistoryWindow hw = new HistoryWindow(SparkManager.getUserDirectory(), room.getRoomname());
hw.showWindow();
} catch (Exception ex) {
Log.error("An exception occurred while trying to open history window for room " + room, ex);
}
}
});
}
}
Aggregations