Search in sources :

Example 1 with ChatFrame

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());
}
Also used : SparkToaster(org.jivesoftware.spark.roar.gui.SparkToaster) ChatFrame(org.jivesoftware.spark.ui.ChatFrame) ActionEvent(java.awt.event.ActionEvent) AbstractAction(javax.swing.AbstractAction)

Example 2 with ChatFrame

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();
        }
    });
}
Also used : ChatFrame(org.jivesoftware.spark.ui.ChatFrame) MainWindow(org.jivesoftware.MainWindow) ApplicationEvent(com.apple.eawt.ApplicationEvent) ApplicationAdapter(com.apple.eawt.ApplicationAdapter)

Example 3 with ChatFrame

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();
}
Also used : ChatFrame(org.jivesoftware.spark.ui.ChatFrame) ChatRoom(org.jivesoftware.spark.ui.ChatRoom) ChatRoomNotFoundException(org.jivesoftware.spark.ui.ChatRoomNotFoundException) ContactItem(org.jivesoftware.spark.ui.ContactItem)

Example 4 with ChatFrame

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());
    }
}
Also used : ChatFrame(org.jivesoftware.spark.ui.ChatFrame) ChatRoom(org.jivesoftware.spark.ui.ChatRoom)

Example 5 with ChatFrame

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();
}
Also used : Frame(java.awt.Frame) ChatFrame(org.jivesoftware.spark.ui.ChatFrame) MouseEvent(java.awt.event.MouseEvent) KeyAdapter(java.awt.event.KeyAdapter) Rectangle(java.awt.Rectangle) MouseAdapter(java.awt.event.MouseAdapter) Cursor(java.awt.Cursor) GraphicsEnvironment(java.awt.GraphicsEnvironment) BufferedImage(java.awt.image.BufferedImage) URISyntaxException(java.net.URISyntaxException) UnsupportedFlavorException(java.awt.datatransfer.UnsupportedFlavorException) AWTException(java.awt.AWTException) MalformedURLException(java.net.MalformedURLException) IOException(java.io.IOException) KeyEvent(java.awt.event.KeyEvent) GraphicsDevice(java.awt.GraphicsDevice) ChatFrame(org.jivesoftware.spark.ui.ChatFrame) MainWindow(org.jivesoftware.MainWindow) SwingWorker(org.jivesoftware.spark.util.SwingWorker)

Aggregations

ChatFrame (org.jivesoftware.spark.ui.ChatFrame)5 MainWindow (org.jivesoftware.MainWindow)2 ChatRoom (org.jivesoftware.spark.ui.ChatRoom)2 ApplicationAdapter (com.apple.eawt.ApplicationAdapter)1 ApplicationEvent (com.apple.eawt.ApplicationEvent)1 AWTException (java.awt.AWTException)1 Cursor (java.awt.Cursor)1 Frame (java.awt.Frame)1 GraphicsDevice (java.awt.GraphicsDevice)1 GraphicsEnvironment (java.awt.GraphicsEnvironment)1 Rectangle (java.awt.Rectangle)1 UnsupportedFlavorException (java.awt.datatransfer.UnsupportedFlavorException)1 ActionEvent (java.awt.event.ActionEvent)1 KeyAdapter (java.awt.event.KeyAdapter)1 KeyEvent (java.awt.event.KeyEvent)1 MouseAdapter (java.awt.event.MouseAdapter)1 MouseEvent (java.awt.event.MouseEvent)1 BufferedImage (java.awt.image.BufferedImage)1 IOException (java.io.IOException)1 MalformedURLException (java.net.MalformedURLException)1