Example usage for com.google.gwt.view.client CellPreviewEvent getValue

List of usage examples for com.google.gwt.view.client CellPreviewEvent getValue

Introduction

In this page you can find the example usage for com.google.gwt.view.client CellPreviewEvent getValue.

Prototype

public T getValue() 

Source Link

Document

Get the value where the event occurred.

Usage

From source file:org.jbpm.console.ng.dm.client.experimental.pagination.DocumentListViewImpl.java

License:Apache License

private void initTableColumns(final SelectionModel<CMSContentSummary> selectionModel) {

    processdefListGrid.addCellPreviewHandler(new CellPreviewEvent.Handler<CMSContentSummary>() {

        @Override//from w  ww  . j ava 2  s  .co  m
        public void onCellPreview(final CellPreviewEvent<CMSContentSummary> event) {
            CMSContentSummary summary = event.getValue();

            if (BrowserEvents.DBLCLICK.equalsIgnoreCase(event.getNativeEvent().getType())) {
                selectDocEvent.fire(new DocumentsListSearchEvent(summary));
                pathLink.setText(summary.getPath());
            }
        }
    });

    // Name String.
    Column<CMSContentSummary, String> processNameColumn = new Column<CMSContentSummary, String>(
            new TextCell()) {
        @Override
        public String getValue(CMSContentSummary object) {
            return object.getName();
        }
    };
    processNameColumn.setSortable(true);
    sortHandler.setComparator(processNameColumn, new Comparator<CMSContentSummary>() {
        @Override
        public int compare(CMSContentSummary o1, CMSContentSummary o2) {
            return o1.getName().toLowerCase().compareTo(o2.getName().toLowerCase());
        }
    });

    processdefListGrid.addColumn(processNameColumn,
            new ResizableHeader<CMSContentSummary>("Name", processdefListGrid, processNameColumn));

    // Version Type
    Column<CMSContentSummary, String> idColumn = new Column<CMSContentSummary, String>(new TextCell()) {
        @Override
        public String getValue(CMSContentSummary object) {
            return object.getId();
        }
    };

    processdefListGrid.addColumn(idColumn, new ResizableHeader("ID", processdefListGrid, idColumn));

    // actions (icons)
    List<HasCell<CMSContentSummary, ?>> cells = new LinkedList<HasCell<CMSContentSummary, ?>>();

    cells.add(new GoHasCell("Go", new Delegate<CMSContentSummary>() {
        @Override
        public void execute(CMSContentSummary process) {
            selectDocEvent.fire(new DocumentsListSearchEvent(process));
            pathLink.setText(process.getPath());
        }
    }));

    cells.add(new RemoveHasCell("Remove", new Delegate<CMSContentSummary>() {
        @Override
        public void execute(CMSContentSummary process) {
            removeDocEvent.fire(new DocumentRemoveSearchEvent(process));
        }
    }));

    CompositeCell<CMSContentSummary> cell = new CompositeCell<CMSContentSummary>(cells);
    Column<CMSContentSummary, CMSContentSummary> actionsColumn = new Column<CMSContentSummary, CMSContentSummary>(
            cell) {
        @Override
        public CMSContentSummary getValue(CMSContentSummary object) {
            return object;
        }
    };
    processdefListGrid.addColumn(actionsColumn,
            new ResizableHeader("Actions", processdefListGrid, actionsColumn));
    processdefListGrid.setColumnWidth(actionsColumn, "70px");
}

From source file:org.jbpm.console.ng.ht.client.editors.taskslist.grid.dash.DataSetTasksListGridViewImpl.java

License:Apache License

private void onMouseOverGrid(ExtendedPagedTable extendedPagedTable, final CellPreviewEvent<TaskSummary> event) {
    TaskSummary task = event.getValue();

    if (task.getDescription() != null) {
        extendedPagedTable.setTooltip(extendedPagedTable.getKeyboardSelectedRow(), event.getColumn(),
                task.getDescription());/*from  ww  w .  ja  v a  2 s  .co m*/
    }
}

From source file:org.jbpm.workbench.common.client.list.ExtendedPagedTable.java

License:Apache License

protected DefaultSelectionEventManager<T> createNoActionColumnManager() {
    final ExtendedPagedTable<T> extendedPagedTable = this;
    return DefaultSelectionEventManager
            .createCustomManager(new DefaultSelectionEventManager.EventTranslator<T>() {

                @Override/*from w  w  w .  java 2  s  . co m*/
                public boolean clearCurrentSelection(CellPreviewEvent<T> event) {
                    return false;
                }

                @Override
                public DefaultSelectionEventManager.SelectAction translateSelectionEvent(
                        CellPreviewEvent<T> event) {
                    DefaultSelectionEventManager.SelectAction ret = DefaultSelectionEventManager.SelectAction.DEFAULT;
                    NativeEvent nativeEvent = event.getNativeEvent();
                    if (BrowserEvents.CLICK.equals(nativeEvent.getType())) {
                        // Ignore if the event didn't occur in the correct column.
                        if (extendedPagedTable.isSelectionIgnoreColumn(event.getColumn())) {
                            ret = DefaultSelectionEventManager.SelectAction.IGNORE;
                        }
                        //Extension for checkboxes
                        Element target = nativeEvent.getEventTarget().cast();
                        if ("input".equals(target.getTagName().toLowerCase())) {
                            final InputElement input = target.cast();
                            if ("checkbox".equals(input.getType().toLowerCase())) {
                                // Synchronize the checkbox with the current selection state.
                                final T domain = event.getValue();
                                if (domain.isSelected()) {
                                    input.setChecked(false);
                                    domain.setSelected(false);
                                } else {
                                    input.setChecked(true);
                                    domain.setSelected(true);
                                }
                                extendedPagedTable.redraw();
                                ret = DefaultSelectionEventManager.SelectAction.IGNORE;
                            }
                        }
                    }
                    return ret;
                }
            });
}

From source file:org.jbpm.workbench.ht.client.editors.taskslist.AbstractTaskListView.java

License:Apache License

private void onMouseOverGrid(ExtendedPagedTable<TaskSummary> extendedPagedTable,
        final CellPreviewEvent<TaskSummary> event) {
    TaskSummary task = event.getValue();

    if (task.getDescription() != null) {
        extendedPagedTable.setTooltip(extendedPagedTable.getKeyboardSelectedRow(), event.getColumn(),
                task.getDescription());/* w  w w .  ja v  a  2s.  c o  m*/
    }
}

From source file:org.rstudio.core.client.widget.ModifyKeyboardShortcutsWidget.java

License:Open Source License

private void onShortcutCellPreview(CellPreviewEvent<KeyboardShortcutEntry> preview) {
    NativeEvent event = preview.getNativeEvent();
    String type = event.getType();

    if (type.equals("keydown")) {
        int keyCode = event.getKeyCode();
        int modifiers = KeyboardShortcut.getModifierValue(event);

        // Don't handle raw 'Enter' keypresses (let underlying input
        // widget process)
        if (keyCode == KeyCodes.KEY_ENTER && modifiers == 0)
            return;

        // Handle any other key events.
        if (modifiers != 0)
            swallowNextKeyUpEvent_ = true;

        event.stopPropagation();//from  w ww.  j  av  a2  s.  co  m
        event.preventDefault();

        if (KeyboardHelper.isModifierKey(event.getKeyCode()))
            return;

        if (keyCode == KeyCodes.KEY_BACKSPACE && modifiers == 0) {
            buffer_.pop();
        } else if (keyCode == KeyCodes.KEY_DELETE && modifiers == 0) {
            buffer_.clear();
        } else if (keyCode == KeyCodes.KEY_ESCAPE && modifiers == 0) {
            buffer_.set(preview.getValue().getOriginalKeySequence());
        } else {
            buffer_.add(event);
        }

        // Sneak into the element and find the active <input>, then update it.
        Element el = getElement(table_, preview.getIndex(), preview.getColumn());
        Element input = el.getFirstChildElement().getFirstChildElement();
        if (input == null)
            return;

        assert input.getTagName().toLowerCase().equals("input") : "Failed to find <input> element in table";

        String bufferString = buffer_.toString();
        input.setAttribute("value", bufferString);
        input.setInnerHTML(bufferString);

        // Move the cursor to the end of the selection.
        DomUtils.setSelectionRange(input, bufferString.length(), bufferString.length());
    }
}

From source file:us.softoption.proofs.TProofDisplayCellTable.java

License:Open Source License

/************** Selection and Clicks or Touches ************************/

void addSelectionModel() {

    this.sinkEvents(Event.ONCLICK);

    //but we want click to toggle selection not require command click for multiple
    this.addCellPreviewHandler(new CellPreviewEvent.Handler<TProofline>() {
        public void onCellPreview(CellPreviewEvent<TProofline> event) {
            String type = event.getNativeEvent().getType();
            if (type.equals("click")) {

                TProofline value = event.getValue();

                handleClick(value);/* w  w w . j av  a  2s .c o  m*/

                event.setCanceled(true);

                //    Window.alert("CLICKED " + value.fLineno);  DEBUG
            }
        }
    });

    this.setSelectionModel(fSelectionModel, DefaultSelectionEventManager.<TProofline>createCheckboxManager());

    /*
    final Handler<TProofline> selectionEventManager = DefaultSelectionEventManager.createCheckboxManager();
    this.setSelectionModel(fSelectionModel,selectionEventManager);  Jan 2013 */

    /*Google sample code 
     * 
     *  // Add a selection model so we can select cells.
        final SelectionModel<ContactInfo> selectionModel = new MultiSelectionModel<ContactInfo>(
            ContactDatabase.ContactInfo.KEY_PROVIDER);
        cellTable.setSelectionModel(selectionModel,
            DefaultSelectionEventManager.<ContactInfo> createCheckboxManager());
     */

    // We want multiple selection
    // final MultiSelectionModel<TProofline> selectionModel = new MultiSelectionModel<TProofline>();
    /*  this.setSelectionModel(fSelectionModel);
      fSelectionModel.addSelectionChangeHandler(new SelectionChangeEvent.Handler() {
        public void onSelectionChange(SelectionChangeEvent event) {
           Set <TProofline> selected = fSelectionModel.getSelectedSet();
          if (selected != null) {
            Window.alert("You selected: " + selected.size());
          }
        }
      });   
              
    */

    /*   this.addCellPreviewHandler(new CellPreviewEvent.Handler<TProofline>() {
           public void onCellPreview(CellPreviewEvent<TProofline> event) {
    String type = event.getNativeEvent().getType();
    if (type.equals("click")) {
               
               
       TProofline value=event.getValue();
               
        final Boolean state = !event.getDisplay().getSelectionModel().isSelected(value);
        event.getDisplay().getSelectionModel().setSelected(value, state);
        event.setCanceled(true);
               
               
               
        Window.alert("CLICKED");
    }
           }
       });
               
       */

    /*
            
            
    this.addCellPreviewHandler(new Handler<T>() {
            
        @Override
        public void onCellPreview(final CellPreviewEvent<T> event) {
            
    if (BrowserEvents.CLICK.equals(event.getNativeEvent().getType())) {
            
        final T value = event.getValue();
        final Boolean state = !event.getDisplay().getSelectionModel().isSelected(value);
        event.getDisplay().getSelectionModel().setSelected(value, state);
        event.setCanceled(true);
    }
        }
    }); 
            
            
    */

}