[sip-comm-dev] Re: svn commit: r6952 - trunk/src/net/java/sip/communicator: impl/gui impl/gui/main impl/osdependent/jdic service/gui


#1

Hi Werner,

Thanks and sorry for the inconvenience! Everything messed up, because I have reverted some of these changes some time ago and the update I've done before committing has deleted some of my local changes. Anyway it should be fixed with revision: 6958.

Thanks for the note!
Yana

···

On Apr 6, 2010, at 6:00 PM, Werner Dittmann wrote:

Yana,

can you add the keys for

service.gui.SHOW
service.gui.HIDE

to the language properties. SC reports them as missing. Thanks.

Regards,
Werner

Am 06.04.2010 12:05, schrieb yanas@dev.java.net:

Author: yanas
Date: 2010-04-06 10:05:40+0000
New Revision: 6952

Modified:
  trunk/src/net/java/sip/communicator/impl/gui/UIServiceImpl.java
  trunk/src/net/java/sip/communicator/impl/gui/main/MainFrame.java
  trunk/src/net/java/sip/communicator/impl/osdependent/jdic/TrayMenuFactory.java
  trunk/src/net/java/sip/communicator/service/gui/UIService.java

Log:
Ongoing work on Issue #809 ("Could not show contact list window" : https://sip-communicator.dev.java.net/issues/show_bug.cgi?id=809).

Modified: trunk/src/net/java/sip/communicator/impl/gui/UIServiceImpl.java
Url: https://sip-communicator.dev.java.net/source/browse/sip-communicator/trunk/src/net/java/sip/communicator/impl/gui/UIServiceImpl.java?view=diff&rev=6952&p1=trunk/src/net/java/sip/communicator/impl/gui/UIServiceImpl.java&p2=trunk/src/net/java/sip/communicator/impl/gui/UIServiceImpl.java&r1=6951&r2=6952

--- trunk/src/net/java/sip/communicator/impl/gui/UIServiceImpl.java (original)
+++ trunk/src/net/java/sip/communicator/impl/gui/UIServiceImpl.java 2010-04-06 10:05:40+0000
@@ -351,6 +351,21 @@
    }

    /**
+ * Brings the focus to the main application window.
+ */
+ public void bringToFront()
+ {
+ if (mainFrame.getState() == Frame.ICONIFIED)
+ mainFrame.setState(Frame.NORMAL);
+ // Because toFront() method gives us no guarantee that our frame would
+ // go on top we'll try to also first request the focus and set our
+ // window always on top.
+ mainFrame.requestFocus();
+ mainFrame.setAlwaysOnTop(true);
+ mainFrame.toFront();
+ }
+
+ /**
     * Implements the <code>UIService.setExitOnMainWindowClose</code>. Sets a
     * boolean property, which indicates whether the application should be
     * exited when the main application window is closed.
@@ -1172,4 +1187,23 @@
        else
            return null;
    }
-}
+
+ /**
+ * Adds the given <tt>WindowListener</tt> to the main application window.
+ * @param l the <tt>WindowListener</tt> to add
+ */
+ public void addWindowListener(WindowListener l)
+ {
+ mainFrame.addWindowListener(l);
+ }
+
+ /**
+ * Removes the given <tt>WindowListener</tt> from the main application
+ * window.
+ * @param l the <tt>WindowListener</tt> to remove
+ */
+ public void removeWindowListener(WindowListener l)
+ {
+ mainFrame.removeWindowListener(l);
+ }
+}
\ No newline at end of file

Modified: trunk/src/net/java/sip/communicator/impl/gui/main/MainFrame.java
Url: https://sip-communicator.dev.java.net/source/browse/sip-communicator/trunk/src/net/java/sip/communicator/impl/gui/main/MainFrame.java?view=diff&rev=6952&p1=trunk/src/net/java/sip/communicator/impl/gui/main/MainFrame.java&p2=trunk/src/net/java/sip/communicator/impl/gui/main/MainFrame.java&r1=6951&r2=6952

--- trunk/src/net/java/sip/communicator/impl/gui/main/MainFrame.java (original)
+++ trunk/src/net/java/sip/communicator/impl/gui/main/MainFrame.java 2010-04-06 10:05:40+0000
@@ -117,16 +117,6 @@
            {
                MainFrame.this.windowClosed(event);
            }
-
- public void windowActivated(WindowEvent event)
- {
- ConfigurationManager.setApplicationVisible(true);
- }
-
- public void windowOpened(WindowEvent event)
- {
- ConfigurationManager.setApplicationVisible(true);
- }
        });

        this.initTitleFont();
@@ -1492,4 +1482,4 @@
            return false;
        }
    }
-}
+}
\ No newline at end of file

Modified: trunk/src/net/java/sip/communicator/impl/osdependent/jdic/TrayMenuFactory.java
Url: https://sip-communicator.dev.java.net/source/browse/sip-communicator/trunk/src/net/java/sip/communicator/impl/osdependent/jdic/TrayMenuFactory.java?view=diff&rev=6952&p1=trunk/src/net/java/sip/communicator/impl/osdependent/jdic/TrayMenuFactory.java&p2=trunk/src/net/java/sip/communicator/impl/osdependent/jdic/TrayMenuFactory.java&r1=6951&r2=6952

--- trunk/src/net/java/sip/communicator/impl/osdependent/jdic/TrayMenuFactory.java (original)
+++ trunk/src/net/java/sip/communicator/impl/osdependent/jdic/TrayMenuFactory.java 2010-04-06 10:05:40+0000
@@ -22,10 +22,10 @@
*
* @author Nicolas Chamouard
* @author Lubomir Marinov
+ * @author Yana Stamcheva
*/
public final class TrayMenuFactory
{
-
    /**
     * Handles the <tt>ActionEvent</tt> when one of the menu items is selected.
     *
@@ -68,8 +68,28 @@
                    .showMessagePopupDialog(Resources.getString(
                        "impl.systray.FAILED_TO_OPEN_ADD_CONTACT_DIALOG"));
        }
+ else if (itemName.equals("service.gui.SHOW"))
+ {
+ OsDependentActivator.getUIService().setVisible(true);
+ OsDependentActivator.getUIService().bringToFront();
+
+ changeTrayMenuItem(source, "service.gui.HIDE",
+ "service.gui.HIDE", "service.gui.icons.SEARCH_ICON_16x16");
+ }
+ else if (itemName.equals("service.gui.HIDE"))
+ {
+ OsDependentActivator.getUIService().setVisible(false);
+
+ changeTrayMenuItem(source, "service.gui.SHOW",
+ "service.gui.SHOW", "service.gui.icons.SEARCH_ICON_16x16");
+ }
    }

+ /**
+ * Adds the given <tt>trayMenuItem</tt> to the given <tt>trayMenu</tt>.
+ * @param trayMenu the tray menu to which to add the item
+ * @param trayMenuItem the item to add
+ */
    private static void add(Object trayMenu, Object trayMenuItem)
    {
        if (trayMenu instanceof JPopupMenu)
@@ -78,6 +98,11 @@
            ((PopupMenu) trayMenu).add((MenuItem) trayMenuItem);
    }

+ /**
+ * Adds a <tt>PopupMenuListener</tt> to the given <tt>trayMenu</tt>.
+ * @param trayMenu the tray menu to which to add a popup listener
+ * @param listener the listener to add
+ */
    public static void addPopupMenuListener(Object trayMenu,
        PopupMenuListener listener)
    {
@@ -85,6 +110,10 @@
            ((JPopupMenu) trayMenu).addPopupMenuListener(listener);
    }

+ /**
+ * Adds a separator to the given <tt>trayMenu</tt>.
+ * @param trayMenu the tray menu to which to add a separator
+ */
    private static void addSeparator(Object trayMenu)
    {
        if (trayMenu instanceof JPopupMenu)
@@ -93,6 +122,12 @@
            ((PopupMenu) trayMenu).addSeparator();
    }

+ /**
+ * Creates a tray menu for the given system tray.
+ * @param tray the system tray for which we're creating a menu
+ * @param swing indicates if we should create a Swing or an AWT menu
+ * @return a tray menu for the given system tray
+ */
    public static Object createTrayMenu(SystrayServiceJdicImpl tray,
                                        boolean swing)
    {
@@ -117,13 +152,76 @@
        addSeparator(trayMenu);
        add(trayMenu, new StatusSubMenu(tray, swing).getMenu());
        addSeparator(trayMenu);
- add(trayMenu, createTrayMenuItem("service.gui.QUIT",
- "service.gui.QUIT", "service.systray.QUIT_MENU_ICON", listener,
+
+ String showHideName;
+ String showHideTextId;
+ String showHideIconId;
+
+ if (OsDependentActivator.getUIService().isVisible())
+ {
+ showHideName = "service.gui.HIDE";
+ showHideTextId = "service.gui.HIDE";
+ showHideIconId = "service.gui.icons.SEARCH_ICON_16x16";
+ }
+ else
+ showHideName = "service.gui.SHOW";
+ showHideTextId = "service.gui.SHOW";
+ showHideIconId = "service.gui.icons.SEARCH_ICON_16x16";
+
+ final Object showHideMenuItem = createTrayMenuItem( showHideName,
+ showHideTextId,
+ showHideIconId,
+ listener,
+ swing);
+
+ add(trayMenu, showHideMenuItem);
+
+ add(trayMenu, createTrayMenuItem("service.gui.CLOSE",
+ "service.gui.CLOSE", "service.systray.CLOSE_MENU_ICON", listener,
            swing));

+ OsDependentActivator.getUIService().addWindowListener(
+ new WindowAdapter()
+ {
+ /**
+ * Invoked when a window is activated.
+ */
+ public void windowActivated(WindowEvent e)
+ {
+ changeTrayMenuItem( showHideMenuItem,
+ "service.gui.HIDE",
+ "service.gui.HIDE",
+ "service.gui.icons.SEARCH_ICON_16x16");
+ }
+
+ /**
+ * Invoked when a window is de-activated.
+ */
+ public void windowDeactivated(WindowEvent e)
+ {
+ changeTrayMenuItem( showHideMenuItem,
+ "service.gui.SHOW",
+ "service.gui.SHOW",
+ "service.gui.icons.SEARCH_ICON_16x16");
+ }
+ });
+
        return trayMenu;
    }

+ /**
+ * Creates a tray menu with the given <tt>name</tt>, text given by
+ * <tt>textID</tt> and icon given by <tt>iconID</tt>. The <tt>listener</tt>
+ * is handling item events and the <tt>swing</tt> value indicates if we
+ * should create a Swing menu item or and an AWT item.
+ * @param name the name of the item
+ * @param textID the identifier of the text in the localization resources
+ * @param iconID the identifier of the icon in the image resources
+ * @param listener the <tt>ActionListener</tt> handling action events
+ * @param swing indicates if we should create a Swing menu item or an AWT
+ * item
+ * @return a reference to the newly created item
+ */
    private static Object createTrayMenuItem( String name,
                                                String textID,
                                                String iconID,
@@ -150,10 +248,46 @@
        return trayMenuItem;
    }

+ /**
+ * Changes the tray menu item properties, like name, text and icon.
+ * @param trayItem the tray menu item to change
+ * @param name the new name of the item
+ * @param textID the new text identifier
+ * @param iconID the new icon string identifier
+ */
+ private static void changeTrayMenuItem( Object trayItem,
+ String name,
+ String textID,
+ String iconID)
+ {
+ String text = Resources.getString(textID);
+
+ if (trayItem instanceof JMenuItem)
+ {
+ JMenuItem jmenuItem = (JMenuItem) trayItem;
+ jmenuItem.setName(name);
+ jmenuItem.setText(text);
+ jmenuItem.setIcon(Resources.getImage(iconID));
+ }
+ else if (trayItem instanceof MenuItem)
+ {
+ MenuItem menuItem = (MenuItem) trayItem;
+ menuItem.setName(name);
+ menuItem.setLabel(text);
+ }
+ }
+
+ /**
+ * Returns <tt>true</tt> if the given <tt>trayMenu</tt> is visible,
+ * otherwise returns <tt>false</tt>.
+ * @param trayMenu the <tt>TrayMenu</tt> to check
+ * @return <tt>true</tt> if the given <tt>trayMenu</tt> is visible,
+ * otherwise returns <tt>false</tt>
+ */
    public static boolean isVisible(Object trayMenu)
    {
        if (trayMenu instanceof JPopupMenu)
            return ((JPopupMenu) trayMenu).isVisible();
        return false;
    }
-}
+}
\ No newline at end of file

Modified: trunk/src/net/java/sip/communicator/service/gui/UIService.java
Url: https://sip-communicator.dev.java.net/source/browse/sip-communicator/trunk/src/net/java/sip/communicator/service/gui/UIService.java?view=diff&rev=6952&p1=trunk/src/net/java/sip/communicator/service/gui/UIService.java&p2=trunk/src/net/java/sip/communicator/service/gui/UIService.java&r1=6951&r2=6952

--- trunk/src/net/java/sip/communicator/service/gui/UIService.java (original)
+++ trunk/src/net/java/sip/communicator/service/gui/UIService.java 2010-04-06 10:05:40+0000
@@ -7,6 +7,7 @@
package net.java.sip.communicator.service.gui;

import java.awt.*;
+import java.awt.event.*;
import java.util.*;
import java.util.List;

@@ -133,6 +134,11 @@
    public void move(int x, int y);

    /**
+ * Brings the focus to the main application window.
+ */
+ public void bringToFront();
+
+ /**
     * Sets the exitOnClose property. When TRUE, the user could exit the
     * application by simply closing the main application window (by clicking
     * the X button or pressing Alt-F4). When set to FALSE the main application
@@ -387,4 +393,23 @@
     * configuration window; <tt>false</tt> to hide it
     */
    public void setConfigurationWindowVisible(boolean visible);
-}
+
+ /**
+ * Adds the given <tt>WindowListener</tt> listening for events triggered
+ * by the main UIService component. This is normally the main application
+ * window component, the one containing the contact list. This listener
+ * would also receive events when this window is shown or hidden.
+ * @param l the <tt>WindowListener</tt> to add
+ */
+ public void addWindowListener(WindowListener l);
+
+ /**
+ * Removes the given <tt>WindowListener</tt> from the list of registered
+ * listener. The <tt>WindowListener</tt> is listening for events
+ * triggered by the main UIService component. This is normally the main
+ * application window component, the one containing the contact list. This
+ * listener would also receive events when this window is shown or hidden.
+ * @param l the <tt>WindowListener</tt> to remove
+ */
+ public void removeWindowListener(WindowListener l);
+}
\ No newline at end of file

---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@sip-communicator.dev.java.net
For additional commands, e-mail: commits-help@sip-communicator.dev.java.net

---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@sip-communicator.dev.java.net
For additional commands, e-mail: commits-help@sip-communicator.dev.java.net

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@sip-communicator.dev.java.net
For additional commands, e-mail: dev-help@sip-communicator.dev.java.net