List of usage examples for com.google.gwt.dom.client TableRowElement getRowIndex
public int getRowIndex()
From source file:org.lorislab.smonitor.admin.client.AgentsView.java
License:Apache License
public AgentsView() { initWidget(uiBinder.createAndBindUi(this)); dialogBox.setCreateHandler(new DialogEventHandler<Agent>() { @Override/*w w w . j a va2 s .c o m*/ public void event(Agent value) { agentService.call(agentUpdate).update(value.getGuid(), value); } }); dialogBox.setUpdateHandler(new DialogEventHandler<Agent>() { @Override public void event(Agent value) { agentService.call(agentUpdate).update(value.getGuid(), value); } }); btnAgentRefresh.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { refresh(); } }); btnAgentAdd.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { agentService.call(agentCreate).create(); } }); deleteQuestion.setOkHandler(new DialogEventHandler<String>() { @Override public void event(String value) { agentService.call(agentDelete).delete(value); } }); tableMenu.setHandler(new AgentToolbarPanel.ClickButtonHandler() { @Override public void edit(AgentWrapper data) { openDialog(data.data, EntityDialogBox.Mode.UPDATE); } @Override public void password(AgentWrapper data) { } @Override public void info(AgentWrapper data) { } @Override public void refresh(AgentWrapper data) { refreshAgent(data); } @Override public void delete(AgentWrapper data) { deleteQuestion.open(data.data.getGuid(), "Delete Agent", "Do you really want to delete selected agent " + data.data.getName() + " ?"); } }); agentPanel.setTableRowHoverHandler(new TableRowHoverHandler() { @Override public void onRowOver(TableRowElement row) { int index = row.getRowIndex(); AgentWrapper w = agentPanel.get(index); TableCellElement cell = row.getCells().getItem(0); tableMenu.open(cell.getAbsoluteLeft(), cell.getAbsoluteTop(), w); } @Override public void onRowOut() { tableMenu.close(); } }); agentPanel.setChangeSizeHandler(new EntityDataGrid.ChangeSizeHandler() { @Override public void changeSize(int size) { resultCount.setText("# " + size); } }); }
From source file:org.lorislab.smonitor.admin.client.SessionsView.java
License:Apache License
public SessionsView() { ChosenOptions options = new ChosenOptions(); options.setResources(GWT.<MyResources>create(MyResources.class)); agentsList = new ChosenListBox(true, options); options = new ChosenOptions(); options.setResources(GWT.<MyResources>create(MyResources.class)); appList = new ChosenListBox(true, options); initWidget(uiBinder.createAndBindUi(this)); searchCriteria.getElement().getParentElement().getStyle().setOverflow(Overflow.VISIBLE); searchCriteriaItems.getElement().getParentElement().getStyle().setOverflow(Overflow.VISIBLE); btnSessionReset.addClickHandler(new ClickHandler() { @Override/*from w w w. j a v a2s .c om*/ public void onClick(ClickEvent event) { ChosenListBoxUtil.clearSelected(agentsList); ChosenListBoxUtil.clearSelected(appList); } }); btnSessionSearch.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { SessionSearchCriteria criteria = new SessionSearchCriteria(); criteria.setAgents(ChosenListBoxUtil.getSelectedValues(agentsList)); criteria.setApplications(ChosenListBoxUtil.getSelectedValues(appList)); sessionPanel.reset(); appService.call(sessionSearch, sessionSearchError).findSessions(criteria); } }); sessionPanel.setTableRowHoverHandler(new TableRowHoverHandler() { @Override public void onRowOver(TableRowElement row) { int index = row.getRowIndex(); SessionWrapper w = sessionPanel.get(index); TableCellElement cell = row.getCells().getItem(0); sessionToolbar.open(cell.getAbsoluteLeft(), cell.getAbsoluteTop(), w); } @Override public void onRowOut() { sessionToolbar.close(); } }); sessionPanel.setChangeSizeHandler(new EntityDataGrid.ChangeSizeHandler() { @Override public void changeSize(int size) { resultCount.setText("# " + sessionPanel.size()); } }); sessionToolbar.setHandler(new SessionToolbarPanel.ClickButtonHandler() { @Override public void info(SessionWrapper data) { PleaseWaitPanelFactory.open(); appService.call(sessionDetails).getSesssionDetails(data.data.getGuid(), data.data.getHost(), data.data.getApplication(), data.data.getId()); } @Override public void delete(SessionWrapper data) { deleteQuestion.open(data, "Delete Session", "Do you really want to delete selected session " + data.data.getId() + " ?"); } @Override public void refresh(SessionWrapper data) { sessionPanel.request(data); appService.call(sessionRefresh).getSesssion(data.data.getGuid(), data.data.getHost(), data.data.getApplication(), data.data.getId()); } }); deleteQuestion.setOkHandler(new DialogEventHandler<SessionWrapper>() { @Override public void event(SessionWrapper data) { appService.call(sessionDelete).deleteSesssion(data.data.getGuid(), data.data.getHost(), data.data.getApplication(), data.data.getId()); } }); }
From source file:org.rstudio.core.client.widget.FastSelectTable.java
License:Open Source License
private void handleRowClick(MouseDownEvent event, TableRowElement row) { int modifiers = KeyboardShortcut.getModifierValue(event.getNativeEvent()); modifiers &= ~KeyboardShortcut.ALT; // ALT has no effect if (!allowMultiSelect_) modifiers = KeyboardShortcut.NONE; // We'll treat Ctrl and Meta as equivalent--and normalize to Ctrl. if (KeyboardShortcut.META == (modifiers & KeyboardShortcut.META)) modifiers |= KeyboardShortcut.CTRL; modifiers &= ~KeyboardShortcut.META; if (modifiers == KeyboardShortcut.NONE) { // Select only the target row clearSelection();/*from www .ja va2 s . c o m*/ setSelected(row, true); } else if (modifiers == KeyboardShortcut.CTRL) { // Toggle the target row setSelected(row, !isSelected(row)); } else { // SHIFT or CTRL+SHIFT int target = row.getRowIndex(); Integer min = null; Integer max = null; for (TableRowElement selectedRow : selectedRows_) { if (min == null) min = selectedRow.getRowIndex(); max = selectedRow.getRowIndex(); } int offset; // selection offset int length; // selection length if (min == null) { // Nothing is selected offset = target; length = 1; } else if (target < min) { // Select target..max offset = target; length = max - target + 1; } else if (target > max) { offset = min; length = target - min + 1; } else { // target is in between min and max if (modifiers == (KeyboardShortcut.CTRL | KeyboardShortcut.SHIFT)) { offset = min; length = target - min + 1; } else { offset = target; length = 1; } } clearSelection(); if (length > 0) { setSelectedPhysical(offset, length, true); } } }
From source file:org.rstudio.core.client.widget.FastSelectTable.java
License:Open Source License
public ArrayList<Integer> getSelectedRowIndexes() { sortSelectedRows();/* ww w .jav a 2 s . c o m*/ ArrayList<Integer> results = new ArrayList<Integer>(); for (TableRowElement row : selectedRows_) results.add(codec_.physicalOffsetToLogicalOffset(table_, row.getRowIndex())); return results; }
From source file:org.rstudio.core.client.widget.FastSelectTable.java
License:Open Source License
private void sortSelectedRows() { Collections.sort(selectedRows_, new Comparator<TableRowElement>() { public int compare(TableRowElement r1, TableRowElement r2) { return r1.getRowIndex() - r2.getRowIndex(); }/* w w w .j av a 2s . co m*/ }); }
From source file:org.xwiki.gwt.wysiwyg.client.plugin.table.feature.DeleteRow.java
License:Open Source License
@Override public boolean execute(String parameter) { Node selectedNode = TableUtils.getInstance().getCaretNode(rta.getDocument()); // If the selection is inside a table cell then move the caret to the previous/next cell on the same column. TableCellElement selectedCell = TableUtils.getInstance().getCell(selectedNode); if (selectedCell != null) { TableCellElement newCaretCell = TableUtils.getInstance().getPreviousCellInColumn(selectedCell); if (newCaretCell == null) { newCaretCell = TableUtils.getInstance().getNextCellInColumn(selectedCell); }/* w w w . j a v a 2 s.com*/ if (newCaretCell != null) { TableUtils.getInstance().putCaretInNode(rta, newCaretCell); } } // Delete the selected table row. TableRowElement selectedRow = TableUtils.getInstance().getRow(selectedNode); TableUtils.getInstance().getTable(selectedRow).deleteRow(selectedRow.getRowIndex()); return true; }
From source file:org.xwiki.gwt.wysiwyg.client.plugin.table.util.TableUtils.java
License:Open Source License
/** * Get next cell in cell's column.// w ww . j ava 2 s.c o m * * @param cell currently edited cell. * @return the next TableCellElement if any, null otherwise. */ public TableCellElement getNextCellInColumn(TableCellElement cell) { TableRowElement row = getRow(cell); TableElement table = getTable(row); NodeList<TableRowElement> rows = table.getRows(); if (rows.getLength() > row.getRowIndex() + 1) { return rows.getItem(row.getRowIndex() + 1).getCells().getItem(cell.getCellIndex()); } else { return null; } }
From source file:org.xwiki.gwt.wysiwyg.client.plugin.table.util.TableUtils.java
License:Open Source License
/** * Get previous cell in cell's column./*from ww w .ja v a 2 s . co m*/ * * @param cell currently edited cell. * @return the previous TableCellElement if any, null otherwise. */ public TableCellElement getPreviousCellInColumn(TableCellElement cell) { TableRowElement row = getRow(cell); TableElement table = getTable(row); NodeList<TableRowElement> rows = table.getRows(); if (row.getRowIndex() > 0) { return rows.getItem(row.getRowIndex() - 1).getCells().getItem(cell.getCellIndex()); } else { return null; } }
From source file:org.xwiki.gwt.wysiwyg.client.plugin.table.util.TableUtils.java
License:Open Source License
/** * Insert a row in the currently edited table. * /*from ww w .j a v a 2 s .c o m*/ * @param doc the Document to get the selection from. * @param insertBefore indicates the creation position relatively to the currently edited row. * @return the newly created TableRowElement. */ public TableRowElement insertRow(Document doc, boolean insertBefore) { TableRowElement row = getRow(getCaretNode(doc)); TableElement table = getTable(row); int index = row.getRowIndex(); if (!insertBefore) { index++; } TableRowElement newRow = table.insertRow(index); // Populate the row int cellCount = row.getCells().getLength(); for (int i = 0; i < cellCount; i++) { TableCellElement cell = newRow.insertCell(i); cell.setInnerHTML(CELL_DEFAULTHTML); } return newRow; }