public void onContextMenu(ContextMenuEvent event) { if (this.dateCell.weekgrid.getCalendar().getMouseEventListener() != null) { event.preventDefault(); event.stopPropagation(); this.dateCell.weekgrid.getCalendar().getMouseEventListener().contextMenu(event, this); } }
@Override public void onContextMenu(ContextMenuEvent event) { event.getNativeEvent().stopPropagation(); event.getNativeEvent().preventDefault(); editMenu = new EditMarkMenu( this, event.getNativeEvent().getClientX(), event.getNativeEvent().getClientY()); editMenu.show(); }
@Override protected void onAttach() { super.onAttach(); handlers.add(addMouseDownHandler(this)); handlers.add(addMouseUpHandler(this)); handlers.add(addKeyDownHandler(this)); handlers.add(addDomHandler(this, ContextMenuEvent.getType())); }
public FirstPersonControls(Object3D object, Widget widget) { super(object, widget); this.viewHalfX = widget.getOffsetWidth() / 2; this.viewHalfY = widget.getOffsetHeight() / 2; if (getWidget().getClass() != RootPanel.class) getWidget().getElement().setAttribute("tabindex", "-1"); this.target = new Vector3(); getWidget().addDomHandler(this, ContextMenuEvent.getType()); getWidget().addDomHandler(this, MouseMoveEvent.getType()); getWidget().addDomHandler(this, MouseDownEvent.getType()); getWidget().addDomHandler(this, MouseUpEvent.getType()); RootPanel.get().addDomHandler(this, KeyDownEvent.getType()); RootPanel.get().addDomHandler(this, KeyUpEvent.getType()); }
@Override public void setPlatypusPopupMenu(PlatypusPopupMenu aMenu) { if (menu != aMenu) { if (menuTriggerReg != null) menuTriggerReg.removeHandler(); menu = aMenu; if (menu != null) { menuTriggerReg = super.addDomHandler( new ContextMenuHandler() { @Override public void onContextMenu(ContextMenuEvent event) { event.preventDefault(); event.stopPropagation(); menu.setPopupPosition( event.getNativeEvent().getClientX(), event.getNativeEvent().getClientY()); menu.show(); } }, ContextMenuEvent.getType()); } } }
public void showPopupMenu(ContextMenuEvent event) { final PopupPanel popupPanel = new PopupPanel(true); popupPanel.setAnimationEnabled(true); popupPanel.setStyleName("popup"); MenuBar popupMenuBar = new MenuBar(true); MenuItem deleteItem = new MenuItem( "Delete Selected Items", true, new Command() { @Override public void execute() { popupPanel.hide(); m_Container.doConfirm( "Are you sure you wish to delete selected items?", new ConfirmDialogBox.ConfirmCallBack() { public void ok() { JSONArray jsa = Utils.extractIds(m_Container.getDragController().getDragContext()); m_Container.doJSONRequest( G3Viewer.DELETE_ALL_URL + "?sourceids=" + jsa.toString(), new HttpSuccessHandler() { public void success(JSONValue aValue) { final List<Widget> widgets = m_Container.getDragController().getSelectedWidgets(); Item i; for (Widget widget : widgets) { i = (Item) widget; removeFromView(i); i.removeLinkedAlbum(); } } }, true, true); } }); } }); deleteItem.addStyleName("popup-item"); popupMenuBar.addItem(deleteItem); popupMenuBar.setVisible(true); popupPanel.add(popupMenuBar); MenuItem rotateAllCW = new MenuItem( "Rotate All Clockwise", true, new Command() { @Override public void execute() { // change all thumbs into loading final List<Widget> widgets = m_Container.getDragController().getSelectedWidgets(); for (Widget widget : widgets) { final Item i = ((Item) widget); if (i.isPhoto()) { i.setLoadingThumb(); } m_Container.doJSONRequest( G3Viewer.ROTATE_URL + i.getID() + "/cw", new HttpSuccessHandler() { public void success(JSONValue aValue) { i.updateImages(aValue); } }, false, true); } popupPanel.hide(); } }); rotateAllCW.addStyleName("popup-item"); popupMenuBar.addItem(rotateAllCW); MenuItem rotateAllCCW = new MenuItem( "Rotate All Counter-Clockwise", true, new Command() { @Override public void execute() { // change all thumbs into loading final List<Widget> widgets = m_Container.getDragController().getSelectedWidgets(); for (Widget widget : widgets) { final Item i = ((Item) widget); if (i.isPhoto()) { i.setLoadingThumb(); } m_Container.doJSONRequest( G3Viewer.ROTATE_URL + i.getID() + "/cw", new HttpSuccessHandler() { public void success(JSONValue aValue) { i.updateImages(aValue); } }, false, true); } popupPanel.hide(); } }); rotateAllCW.addStyleName("popup-item"); popupMenuBar.addItem(rotateAllCCW); int x = DOM.eventGetClientX((Event) event.getNativeEvent()); int y = DOM.eventGetClientY((Event) event.getNativeEvent()); popupPanel.setPopupPosition(x, y); popupPanel.show(); }
private void createDataGrid() { dataGrid = new DataGrid<InputItem>(1024 * 1024, ZicoDataGridResources.INSTANCE, KEY_PROVIDER); selectionModel = new SingleSelectionModel<InputItem>(KEY_PROVIDER); dataGrid.setSelectionModel(selectionModel); recordStore = new ListDataProvider<InputItem>(KEY_PROVIDER); recordStore.addDataDisplay(dataGrid); sortHandler = new ColumnSortEvent.ListHandler<InputItem>(recordStore.getList()); Column<InputItem, InputItem> colId = new IdentityColumn<InputItem>(ID_CELL); dataGrid.addColumn(colId, new ResizableHeader<InputItem>("#", dataGrid, colId)); dataGrid.setColumnWidth(colId, 35, Style.Unit.PX); final EditTextCell cellName = new EditTextCell(); Column<InputItem, String> colName = new Column<InputItem, String>(cellName) { @Override public String getValue(InputItem rec) { return rec.getName(); } }; colName.setFieldUpdater( new FieldUpdater<InputItem, String>() { @Override public void update(int index, InputItem rec, String value) { if (!value.equals(rec.getName())) { markChange(rec); rec.setName(value); cellName.clearViewData(rec.getId()); } } }); dataGrid.addColumn(colName, new ResizableHeader<InputItem>("Name", dataGrid, colName)); dataGrid.setColumnWidth(colName, 128, Style.Unit.PX); colName.setSortable(true); sortHandler.setComparator( colName, new Comparator<InputItem>() { @Override public int compare(InputItem o1, InputItem o2) { return o1.getName().compareTo(o2.getName()); } }); // final SelectCell<String,Integer> cellActive = new SelectCell<String,Integer>( // ZicoWidgets.<String,Integer>map("NO",0,"YES",1)); // Column<InputItem,Integer> colActive = new Column<InputItem, Integer>(cellActive) { // @Override // public Integer getValue(InputItem rec) { // return rec.getActive(); // } // }; // colActive.setFieldUpdater(new FieldUpdater<InputItem, Integer>() { // @Override // public void update(int index, InputItem rec, Integer value) { // if (rec.getActive() != value) { // markChange(rec); // rec.setActive(value); // cellActive.clearViewData(rec.getId()); // } // } // }); // dataGrid.addColumn(colActive, new ResizableHeader<InputItem>("Active", dataGrid, // colActive)); // dataGrid.setColumnWidth(colActive, 128, Style.Unit.PX); // final DatePickerCell cellTstart = new DatePickerCell(ClientUtil.TSTAMP_FORMAT0); // Column<InputItem,Date> colTstart = new Column<InputItem, Date>(cellTstart) { // @Override // public Date getValue(InputItem rec) { // return ClientUtil.unix2date(rec.getTstart()); // } // }; // colTstart.setFieldUpdater(new FieldUpdater<InputItem, Date>() { // @Override // public void update(int index, InputItem rec, Date value) { // long t = ClientUtil.date2unix(value); // if (t != rec.getTstart()) { // markChange(rec); // rec.setTstart(t); // cellTstart.clearViewData(rec.getId()); // } // } // }); // colTstart.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER); // dataGrid.addColumn(colTstart, new ResizableHeader<InputItem>("TStart", dataGrid, // colTstart)); // dataGrid.setColumnWidth(colTstart, 100, Style.Unit.PX); // final DatePickerCell cellTstop = new DatePickerCell(ClientUtil.TSTAMP_FORMAT0); // Column<InputItem,Date> colTstop = new Column<InputItem, Date>(cellTstop) { // @Override // public Date getValue(InputItem rec) { // return ClientUtil.unix2date(rec.getTstop()); // } // }; // colTstop.setFieldUpdater(new FieldUpdater<InputItem, Date>() { // @Override // public void update(int index, InputItem rec, Date value) { // long t = ClientUtil.date2unix(value); // if (t != rec.getTstop()) { // markChange(rec); // rec.setTstop(t); // cellTstop.clearViewData(rec.getId()); // } // } // }); // colTstop.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER); // dataGrid.addColumn(colTstop, new ResizableHeader<InputItem>("TStop", dataGrid, // colTstop)); // dataGrid.setColumnWidth(colTstop, 100, Style.Unit.PX); Column<InputItem, Integer> colInput = new Column<InputItem, Integer>(cellInput) { @Override public Integer getValue(InputItem iitem) { return iitem.getInputId(); } }; colInput.setFieldUpdater( new FieldUpdater<InputItem, Integer>() { @Override public void update(int index, InputItem rec, Integer value) { if (rec.getInputId() != value) { markChange(rec); rec.setInputId(value); cellInput.clearViewData(rec.getId()); } } }); dataGrid.addColumn(colInput, new ResizableHeader<InputItem>("Input", dataGrid, colInput)); dataGrid.setColumnWidth(colInput, 128, Style.Unit.PX); Column<InputItem, Integer> colTxForm = new Column<InputItem, Integer>(cellTxForm) { @Override public Integer getValue(InputItem rec) { return rec.getTxFormid(); } }; colTxForm.setFieldUpdater( new FieldUpdater<InputItem, Integer>() { @Override public void update(int index, InputItem iitem, Integer value) { if (iitem.getTxFormid() != value) { markChange(iitem); iitem.setTxFormid(value); cellTxForm.clearViewData(iitem.getId()); } } }); dataGrid.addColumn(colTxForm, new ResizableHeader<InputItem>("TxForm", dataGrid, colTxForm)); dataGrid.setColumnWidth(colTxForm, 128, Style.Unit.PX); final EditTextCell cellComment = new EditTextCell(); Column<InputItem, String> colComment = new Column<InputItem, String>(cellComment) { @Override public String getValue(InputItem rec) { return rec.getComment(); } }; colComment.setFieldUpdater( new FieldUpdater<InputItem, String>() { @Override public void update(int index, InputItem rec, String value) { if (!value.equals(rec.getComment())) { markChange(rec); rec.setComment(value); cellComment.clearViewData(rec.getId()); } } }); dataGrid.addColumn(colComment, new ResizableHeader<InputItem>("Comment", dataGrid, colComment)); colComment.setSortable(true); sortHandler.setComparator( colComment, new Comparator<InputItem>() { @Override public int compare(InputItem o1, InputItem o2) { return o1.getComment().compareTo(o2.getComment()); } }); dataGrid.addCellPreviewHandler( new CellPreviewEvent.Handler<InputItem>() { @Override public void onCellPreview(CellPreviewEvent<InputItem> event) { NativeEvent nev = event.getNativeEvent(); String eventType = nev.getType(); if (BrowserEvents.CONTEXTMENU.equals(eventType)) { selectionModel.setSelected(event.getValue(), true); if (event.getValue() != null) { contextMenu.setPopupPosition( event.getNativeEvent().getClientX(), event.getNativeEvent().getClientY()); contextMenu.show(); } } } }); dataGrid.setKeyboardSelectionPolicy( HasKeyboardSelectionPolicy.KeyboardSelectionPolicy.DISABLED); dataGrid.addDomHandler( new DoubleClickHandler() { @Override public void onDoubleClick(DoubleClickEvent event) { event.preventDefault(); } }, DoubleClickEvent.getType()); dataGrid.addDomHandler( new ContextMenuHandler() { @Override public void onContextMenu(ContextMenuEvent event) { event.preventDefault(); } }, ContextMenuEvent.getType()); }
protected void addHandlers() { this.addMouseOverHandler(new MarkOnMouseOverHandler()); this.addMouseOutHandler(new MarkOnMouseOutHandler()); this.addDomHandler(this, ContextMenuEvent.getType()); }
@Override public void onContextMenu(ContextMenuEvent event) { event.preventDefault(); }
public ExplorerViewImpl() { checkBoxList = new ArrayList<CheckBox>(); selectedFileSet = new TreeSet<String>(); clickHandlerStopPropagation = new ClickHandler() { public void onClick(ClickEvent event) { event.stopPropagation(); } }; DockPanel dockPanel = new DockPanel(); dockPanel.setWidth("100%"); viewPanel = new SimplePanel(dockPanel); initWidget(viewPanel); MenuBar menuBar = new MenuBar(false); dockPanel.add(menuBar, DockPanel.NORTH); menuBar.setHeight("30px"); MenuBar mnbrFile = new MenuBar(true); MenuItem mntmFile = new MenuItem("File", false, mnbrFile); menuBar.addItem(mntmFile); mntmMakeDirectory = new MenuItem( "Make Directory", false, new Command() { public void execute() { new FileDialogBox(presenter, Operation.MAKE_DIRECTORY).center(); } }); mnbrFile.addItem(mntmMakeDirectory); mntmUploadFile = new MenuItem( "Upload", false, new Command() { public void execute() { new FileDialogBox(presenter, Operation.UPLOAD).center(); } }); mnbrFile.addItem(mntmUploadFile); mntmDownloadFile = new MenuItem( "Download", false, new Command() { public void execute() { presenter.downloadFiles(selectedFileSet); } }); mnbrFile.addItem(mntmDownloadFile); mntmDownloadFile.setEnabled(false); mntmDeleteFile = new MenuItem( "Delete", false, new Command() { public void execute() {} }); mnbrFile.addItem(mntmDeleteFile); mntmDeleteFile.setEnabled(false); mntmRenameFile = new MenuItem( "Rename", false, new Command() { public void execute() {} }); mnbrFile.addItem(mntmRenameFile); mntmRenameFile.setEnabled(false); MenuItemSeparator misFile = new MenuItemSeparator(); mnbrFile.addSeparator(misFile); MenuItem mntmCloseVolume = new MenuItem( "Close volume", false, new Command() { public void execute() { presenter.closeVolume(); } }); mnbrFile.addItem(mntmCloseVolume); MenuBar mnbrHelp = new MenuBar(true); MenuItem mntmHelp = new MenuItem("Help", false, mnbrHelp); menuBar.addItem(mntmHelp); MenuItem mntmAbout = new MenuItem( "About", false, new Command() { public void execute() { Window.alert(""); } }); mnbrHelp.addItem(mntmAbout); flowPanel = new FlowPanel(); explorerScrollPanel = new ScrollPanel(flowPanel); dockPanel.add(explorerScrollPanel, DockPanel.CENTER); explorerScrollPanel.sinkEvents(Event.ONCLICK); explorerScrollPanel.addHandler( new ClickHandler() { public void onClick(ClickEvent event) { setAllCheckBoxFalse(); } }, ClickEvent.getType()); explorerScrollPanel.sinkEvents(Event.ONCONTEXTMENU); explorerScrollPanel.addHandler( new ContextMenuHandler() { public void onContextMenu(ContextMenuEvent event) { event.preventDefault(); event.stopPropagation(); FileContextMenu fileContextMenu = new FileContextMenu(presenter, ContextMenuType.BACKGROUND); fileContextMenu.setPopupPosition( event.getNativeEvent().getClientX(), event.getNativeEvent().getClientY()); fileContextMenu.show(); setAllCheckBoxFalse(); } }, ContextMenuEvent.getType()); Tree tree = new Tree(); treeScrollPanel = new ScrollPanel(tree); dockPanel.add(treeScrollPanel, DockPanel.WEST); treeScrollPanel.setWidth("120px"); resizeScrollPanel(); Window.addResizeHandler( new ResizeHandler() { public void onResize(ResizeEvent event) { resizeScrollPanel(); } }); tree.setAnimationEnabled(true); // tree.addOpenHandler(new OpenHandler<TreeItem>() { // public void onOpen(OpenEvent<TreeItem> event) { // TreeItem trtmTarget = event.getTarget(); // String path = getPath(trtmTarget); // for (int i = 0; i < trtmTarget.getChildCount(); i++) { // TreeItem trtmChild = trtmTarget.getChild(i); // String childPath = path + trtmChild.getText(); // presenter.getFiles(trtmChild, childPath); // } // } // }); tree.addSelectionHandler( new SelectionHandler<TreeItem>() { public void onSelection(SelectionEvent<TreeItem> event) { TreeItem selectedItem = event.getSelectedItem(); String path = getPath(selectedItem); selectedItem.setState(true, true); presenter.changeDirectory(path); } }); trtmRoot = new TreeItem(); trtmSelectedItem = trtmRoot; tree.addItem(trtmRoot); trtmRoot.setText("/"); }
public void sprayFileList(List<FileWrapper> list) { checkBoxList.clear(); selectedFileSet.clear(); flowPanel.clear(); for (final FileWrapper fileWrapper : list) { final FlowPanel tempFlowPanel = new FlowPanel(); flowPanel.add(tempFlowPanel); tempFlowPanel.getElement().getStyle().setProperty("margin", 50, Unit.PX); tempFlowPanel.getElement().getStyle().setProperty("textAlign", "center"); tempFlowPanel.getElement().getStyle().setProperty("verticalAlign", "top"); tempFlowPanel.getElement().getStyle().setProperty("display", "inline-block"); tempFlowPanel.sinkEvents(Event.ONDBLCLICK); tempFlowPanel.sinkEvents(Event.ONCONTEXTMENU); final CheckBox chckbxFileName = new CheckBox(fileWrapper.getName()); Image imgFileIcon; switch (fileWrapper.getKind()) { case DIR: imgFileIcon = new Image("/img/folder.png"); tempFlowPanel.addHandler( new DoubleClickHandler() { public void onDoubleClick(DoubleClickEvent event) { presenter.changeDirectory(fileWrapper.getPath()); } }, DoubleClickEvent.getType()); tempFlowPanel.addHandler( new ContextMenuHandler() { public void onContextMenu(ContextMenuEvent event) { event.preventDefault(); event.stopPropagation(); FileContextMenu fileContextMenu = new FileContextMenu( presenter, ContextMenuType.DIRECTORY, fileWrapper.getPath(), selectedFileSet); fileContextMenu.setPopupPosition( event.getNativeEvent().getClientX(), event.getNativeEvent().getClientY()); fileContextMenu.show(); chckbxFileName.setValue(true, true); } }, ContextMenuEvent.getType()); break; default: imgFileIcon = new Image("/img/file.png"); tempFlowPanel.addHandler( new DoubleClickHandler() { public void onDoubleClick(DoubleClickEvent event) { presenter.downloadFiles(selectedFileSet); } }, DoubleClickEvent.getType()); tempFlowPanel.addHandler( new ContextMenuHandler() { public void onContextMenu(ContextMenuEvent event) { event.preventDefault(); event.stopPropagation(); FileContextMenu fileContextMenu = new FileContextMenu( presenter, ContextMenuType.OTHERS, fileWrapper.getPath(), selectedFileSet); fileContextMenu.setPopupPosition( event.getNativeEvent().getClientX(), event.getNativeEvent().getClientY()); fileContextMenu.show(); chckbxFileName.setValue(true, true); } }, ContextMenuEvent.getType()); break; } tempFlowPanel.add(imgFileIcon); imgFileIcon.setSize("128px", "128px"); imgFileIcon.getElement().getStyle().setProperty("display", "block"); checkBoxList.add(chckbxFileName); tempFlowPanel.add(chckbxFileName); chckbxFileName.addStyleName("iconName"); chckbxFileName.getElement().getStyle().setProperty("display", "block"); chckbxFileName.addClickHandler(clickHandlerStopPropagation); chckbxFileName.addValueChangeHandler( new ValueChangeHandler<Boolean>() { public void onValueChange(ValueChangeEvent<Boolean> event) { if (event.getValue()) { tempFlowPanel.getElement().getStyle().setBackgroundColor("lightblue"); selectedFileSet.add(fileWrapper.getPath()); } else { tempFlowPanel.getElement().getStyle().clearBackgroundColor(); selectedFileSet.remove(fileWrapper.getPath()); } if (!mntmDeleteFile.isEnabled() && selectedFileSet.size() > 0) { mntmDeleteFile.setEnabled(true); } else if (selectedFileSet.size() == 0) { mntmDeleteFile.setEnabled(false); } if (selectedFileSet.size() == 1 && !mntmDownloadFile.isEnabled() && !mntmRenameFile.isEnabled()) { mntmDownloadFile.setEnabled(true); mntmRenameFile.setEnabled(true); } else if (selectedFileSet.size() != 1 && mntmDownloadFile.isEnabled() && mntmRenameFile.isEnabled()) { mntmDownloadFile.setEnabled(false); mntmRenameFile.setEnabled(false); } } }); imgFileIcon.addClickHandler( new ClickHandler() { public void onClick(ClickEvent event) { event.stopPropagation(); setAllCheckBoxFalse(); chckbxFileName.setValue(true, true); } }); imgFileIcon.addMouseOverHandler( new MouseOverHandler() { public void onMouseOver(MouseOverEvent event) { if (!chckbxFileName.getValue()) tempFlowPanel.getElement().getStyle().setBackgroundColor("lightgray"); } }); imgFileIcon.addMouseOutHandler( new MouseOutHandler() { public void onMouseOut(MouseOutEvent event) { if (!chckbxFileName.getValue()) tempFlowPanel.getElement().getStyle().clearBackgroundColor(); } }); } }