Source:
public AssetList() { assetList = new Tree(); assetList.setWidth("100%"); panel = new VerticalPanel(); panel.setWidth("100%"); panel.add(assetList); TextButton addButton = new TextButton(MESSAGES.addButton()); addButton.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { if (assetsFolder != null) { FileUploadWizard uploader = new FileUploadWizard(assetsFolder); uploader.show(); } } }); SimplePanel buttonPanel = new SimplePanel(); buttonPanel.setStyleName("ode-PanelButtons"); buttonPanel.add(addButton); panel.add(buttonPanel); panel.setCellHorizontalAlignment(buttonPanel, VerticalPanel.ALIGN_CENTER); initWidget(panel); assetList.setScrollOnSelectEnabled(false); assetList.sinkEvents(Event.ONMOUSEMOVE); assetList.addMouseMoveHandler(new MouseMoveHandler() { @Override public void onMouseMove(MouseMoveEvent event) { clientX = event.getClientX(); clientY = event.getClientY(); } }); assetList.addSelectionHandler(new SelectionHandler<TreeItem>() { private int clickCount = 0; @Override public void onSelection(SelectionEvent<TreeItem> event) { clickCount++; if (clickCount == 1) { Timer timer = new Timer() { @Override public void run() { if (clickCount == 1) { TreeItem selected = event.getSelectedItem(); ProjectNode node = (ProjectNode) selected.getUserObject(); ProjectNodeContextMenu.show(node, selected.getWidget(), clientX, clientY); } if (clickCount == 2) { TreeItem selected = event.getSelectedItem(); ProjectNode node = (ProjectNode) selected.getUserObject(); PreviewFileCommand cmd = new PreviewFileCommand(); cmd.execute(node); } clickCount = 0; } }; timer.schedule(300); } } }); }

Target:
public AssetList() { assetList = new Tree(); assetList.setWidth("100%"); panel = new VerticalPanel(); panel.setWidth("100%"); panel.add(assetList); TextButton addButton = new TextButton(MESSAGES.addButton()); addButton.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { if (assetsFolder != null) { FileUploadWizard uploader = new FileUploadWizard(assetsFolder); uploader.show(); } } }); SimplePanel buttonPanel = new SimplePanel(); buttonPanel.setStyleName("ode-PanelButtons"); buttonPanel.add(addButton); panel.add(buttonPanel); panel.setCellHorizontalAlignment(buttonPanel, VerticalPanel.ALIGN_CENTER); initWidget(panel); assetList.setScrollOnSelectEnabled(false); assetList.sinkEvents(Event.ONMOUSEMOVE); assetList.addMouseMoveHandler(new MouseMoveHandler() { @Override public void onMouseMove(MouseMoveEvent event) { clientX = event.getClientX(); clientY = event.getClientY(); } }); assetList.addSelectionHandler(new SelectionHandler<TreeItem>() { private int clickCount = 0; @Override public void onSelection(final SelectionEvent<TreeItem> event) { clickCount++; if (clickCount == 1) { Timer timer = new Timer() { @Override public void run() { if (clickCount == 1) { TreeItem selected = event.getSelectedItem(); ProjectNode node = (ProjectNode) selected.getUserObject(); ProjectNodeContextMenu.show(node, selected.getWidget(), clientX, clientY); } if (clickCount == 2) { TreeItem selected = event.getSelectedItem(); ProjectNode node = (ProjectNode) selected.getUserObject(); PreviewFileCommand cmd = new PreviewFileCommand(); cmd.execute(node); } clickCount = 0; } }; timer.schedule(300); } } }); }