use of org.jivesoftware.spark.ui.ChatFrame in project Spark by igniterealtime.
the class SparkToasterHandler method messageReceived.
@Override
public void messageReceived(ChatRoom room, Message message, PropertyBundle property) {
SparkToaster toaster = new SparkToaster();
toaster.setDisplayTime(property.duration);
toaster.setBorder(BorderFactory.createBevelBorder(0));
toaster.setTitle(room.getTabTitle());
toaster.setCustomAction(new AbstractAction() {
private static final long serialVersionUID = 8327372636443172019L;
@Override
public void actionPerformed(ActionEvent e) {
ChatFrame chatFrame = SparkManager.getChatManager().getChatContainer().getChatFrame();
chatFrame.setState(Frame.NORMAL);
chatFrame.setVisible(true);
}
});
toaster.showToaster(room.getTabIcon(), message.getBody());
}
use of org.jivesoftware.spark.ui.ChatFrame in project Spark by igniterealtime.
the class ApplePlugin method initialize.
@SuppressWarnings("deprecation")
public void initialize() {
_props = new AppleProperties();
ApplePreference pref = new ApplePreference(_props);
SparkManager.getPreferenceManager().addPreference(pref);
_applebounce = new AppleBounce(_props);
_appledock = new AppleDock();
SparkManager.getNativeManager().addNativeHandler(this);
handleIdle();
// // register an application listener to show the about box
_application = Application.getApplication();
_application.setEnabledPreferencesMenu(true);
_application.addPreferencesMenuItem();
_application.addApplicationListener(new ApplicationAdapter() {
public void handlePreferences(ApplicationEvent applicationEvent) {
SparkManager.getPreferenceManager().showPreferences();
}
public void handleReOpenApplication(ApplicationEvent event) {
MainWindow mainWindow = SparkManager.getMainWindow();
if (!mainWindow.isVisible()) {
mainWindow.setState(Frame.NORMAL);
mainWindow.setVisible(true);
}
if (SparkManager.getChatManager().getChatContainer().getTotalNumberOfUnreadMessages() > 0) {
final ChatFrame frame = SparkManager.getChatManager().getChatContainer().getChatFrame();
frame.setState(Frame.NORMAL);
frame.setVisible(true);
frame.toFront();
}
}
public void handleQuit(ApplicationEvent applicationEvent) {
SparkManager.getMainWindow().shutdown();
}
});
}
use of org.jivesoftware.spark.ui.ChatFrame in project Spark by igniterealtime.
the class BuzzPlugin method shakeWindow.
private void shakeWindow(Message message) {
String bareJID = XmppStringUtils.parseBareJid(message.getFrom());
ContactItem contact = SparkManager.getWorkspace().getContactList().getContactItemByJID(bareJID);
String nickname = XmppStringUtils.parseLocalpart(bareJID);
if (contact != null) {
nickname = contact.getDisplayName();
}
ChatRoom room;
try {
room = SparkManager.getChatManager().getChatContainer().getChatRoom(bareJID);
} catch (ChatRoomNotFoundException e) {
// Create the room if it does not exist.
room = SparkManager.getChatManager().createChatRoom(bareJID, nickname, nickname);
}
ChatFrame chatFrame = SparkManager.getChatManager().getChatContainer().getChatFrame();
if (chatFrame != null) {
if (SettingsManager.getLocalPreferences().isBuzzEnabled()) {
chatFrame.buzz();
SparkManager.getChatManager().getChatContainer().activateChatRoom(room);
}
}
// Insert offline message
room.getTranscriptWindow().insertNotificationMessage(Res.getString("message.buzz.message", nickname), ChatManager.NOTIFICATION_COLOR);
room.scrollToBottom();
}
use of org.jivesoftware.spark.ui.ChatFrame in project Spark by igniterealtime.
the class SoftPhoneTabHandler method handlePhoneCall.
/**
* Called when the underlying component has a phone call.
*
* @param state the CallRoomState.
* @param tab the SparkTab.
* @param component the component within the tab.
* @param isSelectedTab true if the tab is selected.
* @param chatFrameFocused true if the chat frame is in focus.
*/
private void handlePhoneCall(CallRoomState state, SparkTab tab, Component component, boolean isSelectedTab, boolean chatFrameFocused) {
boolean isTyping = false;
if (component instanceof ChatRoom) {
isTyping = SparkManager.getChatManager().containsTypingNotification(((ChatRoom) component));
}
// Check if is typing.
if (isTyping) {
tab.setIcon(SparkRes.getImageIcon(SparkRes.SMALL_MESSAGE_EDIT_IMAGE));
} else if (CallRoomState.inCall == state) {
tab.setIcon(PhoneRes.getImageIcon("RECEIVER2_IMAGE"));
} else if (CallRoomState.muted == state) {
tab.setIcon(PhoneRes.getImageIcon("MUTE_IMAGE"));
} else if (CallRoomState.onHold == state) {
tab.setIcon(PhoneRes.getImageIcon("ON_HOLD_IMAGE"));
} else if (CallRoomState.callWasEnded == state) {
tab.setIcon(PhoneRes.getImageIcon("HANG_UP_PHONE_16x16_IMAGE"));
}
if (component instanceof ChatRoom) {
handleChatRoom(component, tab, chatFrameFocused, isSelectedTab);
return;
} else {
if (isSelectedTab && chatFrameFocused) {
tab.setTitleColor(Color.black);
tab.setTabFont(tab.getDefaultFont());
}
}
// Handle title frame
if (isSelectedTab && component instanceof PhonePanel) {
final ChatFrame chatFrame = SparkManager.getChatManager().getChatContainer().getChatFrame();
chatFrame.setTitle(((PhonePanel) component).getFrameTitle());
}
}
use of org.jivesoftware.spark.ui.ChatFrame in project Spark by igniterealtime.
the class SparkTransferManager method sendScreenshot.
public void sendScreenshot(final ChatRoomButton button, final ChatRoom room) {
button.setEnabled(false);
final MainWindow mainWindow = SparkManager.getMainWindow();
final ChatFrame chatFrame = SparkManager.getChatManager().getChatContainer().getChatFrame();
final boolean mainWindowVisible = mainWindow.isVisible();
final boolean chatFrameVisible = chatFrame.isVisible();
if (mainWindowVisible) {
mainWindow.setVisible(false);
}
if (chatFrameVisible) {
chatFrame.setVisible(false);
}
final SwingWorker worker = new SwingWorker() {
public Object construct() {
try {
Thread.sleep(1000);
Rectangle area = new Rectangle(Toolkit.getDefaultToolkit().getScreenSize());
return robot.createScreenCapture(area);
} catch (Throwable e) {
Log.error(e);
if (mainWindowVisible) {
mainWindow.setVisible(true);
}
if (chatFrameVisible) {
chatFrame.setVisible(true);
}
}
return null;
}
public void finished() {
bufferedImage = (BufferedImage) get();
if (bufferedImage == null) {
UIManager.put("OptionPane.okButtonText", Res.getString("ok"));
JOptionPane.showMessageDialog(null, Res.getString("title.error"), "Unable to process screenshot.", JOptionPane.ERROR_MESSAGE);
return;
}
final Frame frame = new Frame();
frame.setCursor(new Cursor(Cursor.CROSSHAIR_CURSOR));
selectionPanel.setImage(bufferedImage);
selectionPanel.validate();
selectionPanel.addMouseListener(new MouseAdapter() {
public void mouseReleased(MouseEvent e) {
Rectangle clip = selectionPanel.getClip();
BufferedImage newImage = null;
try {
newImage = bufferedImage.getSubimage((int) clip.getX(), (int) clip.getY(), (int) clip.getWidth(), (int) clip.getHeight());
} catch (Exception e1) {
// Nothing to do
}
if (newImage != null) {
sendImage(newImage, room);
bufferedImage = null;
selectionPanel.clear();
}
frame.dispose();
frame.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
if (mainWindowVisible) {
mainWindow.setVisible(true);
}
if (chatFrameVisible) {
chatFrame.setVisible(true);
}
selectionPanel.removeMouseListener(this);
}
});
frame.addKeyListener(new KeyAdapter() {
public void keyReleased(KeyEvent e) {
if (e.getKeyChar() == KeyEvent.VK_ESCAPE) {
frame.dispose();
frame.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
if (mainWindowVisible) {
mainWindow.setVisible(true);
}
if (chatFrameVisible) {
chatFrame.setVisible(true);
}
}
}
});
frame.setSize(bufferedImage.getWidth(null), bufferedImage.getHeight());
frame.add(selectionPanel);
frame.setUndecorated(true);
// Determine if full-screen mode is supported directly
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
GraphicsDevice gs = ge.getDefaultScreenDevice();
if (gs.isFullScreenSupported()) {
gs.setFullScreenWindow(frame);
} else {
// Full-screen mode will be simulated
frame.setVisible(true);
}
button.setEnabled(true);
}
};
worker.start();
}
Aggregations