/**
* -----------------------------------------------------------------------------------------------
* File: DesktopOptionPanel.java
*
* Copyright (c) 2007 by Keymind Computing as.
* All rights reserved.
*
* This file is subject to the terms and conditions of the Apache Licence 2.0.
* See the file LICENCE in the main directory of the Keywatch distribution for more details.
*
* Revision History:
* $URL: http://keywatch.googlecode.com/svn/trunk/src/server/gwtgui/src/keymind/keywatch/gui/client/desktop/DesktopOptionPanel.java $
* $Date: 2009-04-16 06:23:28 -0700 (Thu, 16 Apr 2009) $, $Rev: $
* -----------------------------------------------------------------------------------------------
*/
package keymind.keywatch.gui.client.desktop;
import com.google.gwt.user.client.ui.*;
import keymind.keywatch.gui.client.util.Constants;
/**
* Displays options for closing and renaming a desktop pad
*/
class DesktopOptionPanel extends PopupPanel implements ClickListener, Constants
{
public static final int ACTION_NONE = 0;
public static final int ACTION_CLOSE = 1;
public static final int ACTION_RENAME = 2;
/**
* Action code
*/
private int action = ACTION_NONE;
private Hyperlink lnkClose;
private Hyperlink lnkRename;
/**
* C'tor
*/
public DesktopOptionPanel(DesktopPanel desktop)
{
// Auto-hide when clicked outside
super(true);
setStyleName(STYLE_MENU_POPUP);
VerticalPanel controllers = new VerticalPanel();
if (!desktop.isSettingsDesktop())
{
lnkClose = new Hyperlink("Remove tab", "");
}
else
{
lnkClose = new Hyperlink("Hide settings", "");
}
lnkClose.addClickListener(this);
controllers.add(lnkClose);
if (!desktop.isSettingsDesktop())
{
lnkRename = new Hyperlink("Change name", "");
lnkRename.addClickListener(this);
controllers.add(lnkRename);
}
add(controllers);
}
/**
* An option has been clicked
*
* @param widget
*/
public void onClick(Widget widget)
{
if (widget == lnkClose)
{
action = ACTION_CLOSE;
}
else
{
action = ACTION_RENAME;
}
hide();
}
/**
* Returns an action code
*
* @see keymind.keywatch.gui.client.desktop.DesktopOptionPanel#ACTION_CLOSE and DesktopOptionPanel#ACTION_RENAME
*/
public int getAction()
{
return action;
}
}
|