\r
import java.util.List;\r
\r
+import com.gargoylesoftware.htmlunit.javascript.host.KeyboardEvent;\r
import com.google.gwt.core.client.GWT;\r
+import com.google.gwt.dom.client.NativeEvent;\r
import com.google.gwt.event.dom.client.ContextMenuEvent;\r
import com.google.gwt.event.dom.client.ContextMenuHandler;\r
import com.google.gwt.event.logical.shared.OpenEvent;\r
import com.google.gwt.event.logical.shared.SelectionHandler;\r
import com.google.gwt.resources.client.ClientBundle;\r
import com.google.gwt.resources.client.ImageResource;\r
+import com.google.gwt.user.client.DOM;\r
import com.google.gwt.user.client.DeferredCommand;\r
import com.google.gwt.user.client.Event;\r
import com.google.gwt.user.client.ui.AbstractImagePrototype;\r
@Source("gr/ebs/gss/resources/groupevent.png")\r
ImageResource groupImage();\r
\r
+ @Override\r
@Source("gr/ebs/gss/resources/editdelete.png")\r
ImageResource delete();\r
- }\r
- private boolean ctrlKeyPressed = false;\r
-\r
- private boolean leftClicked = false;\r
\r
- private boolean rightClicked = false;\r
+ }\r
\r
/**\r
* cached latest group selection (for selecting and expanding on refresh)\r
private TreeItem previous;\r
\r
/**\r
- * A cached copy of the currently changed group widget.\r
- */\r
- private TreeItem changed;\r
-\r
- /**\r
* The widget's image bundle.\r
*/\r
private final Images images;\r
\r
private GroupContextMenu menu;\r
\r
- private boolean showMenu=false;\r
/**\r
* Constructs a new groups widget with a bundle of images.\r
*\r
@Override\r
public void onContextMenu(ContextMenuEvent event) {\r
if(current==null) return;\r
-\r
int left = current.getAbsoluteLeft() + 40;\r
int top = current.getAbsoluteTop() + 20;\r
- GWT.log("SHOWING POPUP", null);\r
showPopup(left, top);\r
\r
}\r
}, ContextMenuEvent.getType());\r
+ tree.getElement().setId("groupsList.tree");\r
tree.addSelectionHandler(this);\r
tree.addOpenHandler(this);\r
tree.setAnimationEnabled(true);\r
initWidget(tree);\r
+ this.getElement().setAttribute("id", "CreativeFilesPanel");\r
setStylePrimaryName("gss-Groups");\r
sinkEvents(Event.ONCONTEXTMENU);\r
sinkEvents(Event.ONMOUSEUP);\r
sinkEvents(Event.ONDBLCLICK);\r
+ sinkEvents(Event.KEYEVENTS);\r
}\r
\r
\r
* user.\r
*/\r
public void updateGroups() {\r
- GetCommand<GroupsResource> gg = new GetCommand<GroupsResource>(GroupsResource.class, GSS.get().getCurrentUserResource().getGroupsPath()){\r
+ GetCommand<GroupsResource> gg = new GetCommand<GroupsResource>(GroupsResource.class, GSS.get().getCurrentUserResource().getGroupsPath(),null){\r
\r
@Override\r
public void onComplete() {\r
GroupsResource res = getResult();\r
- MultipleGetCommand<GroupResource> ga = new MultipleGetCommand<GroupResource>(GroupResource.class, res.getGroupPaths().toArray(new String[]{})){\r
+ MultipleGetCommand<GroupResource> ga = new MultipleGetCommand<GroupResource>(GroupResource.class, res.getGroupPaths().toArray(new String[]{}), null){\r
\r
@Override\r
public void onComplete() {\r
List<GroupResource> groupList = getResult();\r
tree.clear();\r
for (int i = 0; i < groupList.size(); i++) {\r
- final TreeItem item = new TreeItem(imageItemHTML(images.groupImage(), groupList.get(i).getName()));\r
- item.setUserObject(groupList.get(i));\r
+ final TreeItem item = new TreeItem();\r
+ item.setWidget(imageItemHTML(images.groupImage(), groupList.get(i).getName(),item));\r
+ item.setUserObject(groupList.get(i)); \r
tree.addItem(item);\r
updateUsers(item);\r
}\r
* @return the new tree item\r
*/\r
private TreeItem addImageItem(final TreeItem parent, final String title, final ImageResource imageProto) {\r
- final TreeItem item = new TreeItem(imageItemHTML(imageProto, title));\r
+ final TreeItem item = new TreeItem();\r
+ item.setWidget(imageItemHTML(imageProto, title,item));\r
parent.addItem(item);\r
return item;\r
}\r
* @param title the title of the item\r
* @return the resultant HTML\r
*/\r
- private HTML imageItemHTML(final ImageResource imageProto, final String title) {\r
- final HTML link = new HTML("<a class='hidden-link' href='javascript:;'>" + "<span>" + AbstractImagePrototype.create(imageProto).getHTML() + " " + title + "</span>" + "</a>");\r
+ private HTML imageItemHTML(final ImageResource imageProto, final String title,final TreeItem item) {\r
+ final HTML link = new HTML("<a class='hidden-link' href='javascript:;'>" + "<span id='groupsList."+title+"'>" + AbstractImagePrototype.create(imageProto).getHTML() + " " + title + "</span>" + "</a>"){\r
+ @Override\r
+ public void onBrowserEvent(Event event) {\r
+ switch (DOM.eventGetType(event)) {\r
+ case Event.ONMOUSEDOWN:\r
+ if (DOM.eventGetButton(event) == NativeEvent.BUTTON_RIGHT || DOM.eventGetButton(event) == NativeEvent.BUTTON_LEFT)\r
+ onSelection(item);\r
+ break;\r
+ }\r
+ super.onBrowserEvent(event);\r
+\r
+ }\r
+ }; \r
+ link.sinkEvents(Event.ONMOUSEDOWN);\r
+ link.sinkEvents(Event.ONCONTEXTMENU);\r
+ link.sinkEvents(Event.ONCLICK);\r
+ link.sinkEvents(Event.ONKEYDOWN); \r
return link;\r
}\r
\r
menu.hide();\r
menu = new GroupContextMenu(images);\r
menu.setPopupPosition(x, y);\r
- showMenu=false;\r
menu.show();\r
}\r
\r
void updateUsers(final TreeItem groupItem) {\r
if(groupItem.getUserObject() instanceof GroupResource){\r
GroupResource res = (GroupResource) groupItem.getUserObject();\r
- MultipleGetCommand<GroupUserResource> gu = new MultipleGetCommand<GroupUserResource>(GroupUserResource.class, res.getUserPaths().toArray(new String[]{})){\r
+ MultipleGetCommand<GroupUserResource> gu = new MultipleGetCommand<GroupUserResource>(GroupUserResource.class, res.getUserPaths().toArray(new String[]{}), null){\r
@Override\r
public void onComplete() {\r
List<GroupUserResource> users = getResult();\r
}\r
\r
/**\r
- * Modify the changed.\r
- *\r
- * @param newChanged the changed to set\r
- */\r
- private void setChanged(final TreeItem newChanged) {\r
- changed = newChanged;\r
- }\r
-\r
- /**\r
* Retrieve the previous.\r
*\r
* @return the previous\r
@Override\r
public void onOpen(OpenEvent event) {\r
final TreeItem item = (TreeItem) event.getTarget();\r
- setChanged(item);\r
updateUsers(item);\r
-\r
}\r
}\r