@Inject public TransUnitsTableView( FilterViewConfirmationDisplay filterViewConfirmationDisplay, LoadingPanel loadingPanel) { this.filterViewConfirmationDisplay = filterViewConfirmationDisplay; this.loadingPanel = loadingPanel; initWidget(uiBinder.createAndBindUi(this)); noContentLabel.setText(messages.noContent()); noContentLabel.setStyleName("gamma"); transUnitTable.addClickHandler( new ClickHandler() { @Override public void onClick(ClickEvent event) { HTMLTable.Cell cellForEvent = transUnitTable.getCellForEvent(event); if (cellForEvent != null) { selectRow(cellForEvent.getRowIndex()); } } }); transUnitTable.resize(0, 2); transUnitTable.getColumnFormatter().setWidth(0, "49%"); transUnitTable.getColumnFormatter().setWidth(1, "51%"); Window.addResizeHandler( new ResizeHandler() { @Override public void onResize(ResizeEvent event) { listener.refreshView(); } }); transUnitTable.ensureDebugId("transUnitTable"); }
private void refreshTable(boolean needToSort) { if (needToSort) { // Sort the projects. Comparator<Project> comparator; switch (sortField) { default: case NAME: comparator = (sortOrder == SortOrder.ASCENDING) ? ProjectComparators.COMPARE_BY_NAME_ASCENDING : ProjectComparators.COMPARE_BY_NAME_DESCENDING; break; case DATE_CREATED: comparator = (sortOrder == SortOrder.ASCENDING) ? ProjectComparators.COMPARE_BY_DATE_CREATED_ASCENDING : ProjectComparators.COMPARE_BY_DATE_CREATED_DESCENDING; break; case DATE_MODIFIED: comparator = (sortOrder == SortOrder.ASCENDING) ? ProjectComparators.COMPARE_BY_DATE_MODIFIED_ASCENDING : ProjectComparators.COMPARE_BY_DATE_MODIFIED_DESCENDING; break; } Collections.sort(projects, comparator); } refreshSortIndicators(); // Refill the table. table.resize(1 + projects.size(), 5); int row = 1; for (Project project : projects) { ProjectWidgets pw = projectWidgets.get(project); if (selectedProjects.contains(project)) { table.getRowFormatter().setStyleName(row, "ode-ProjectRowHighlighted"); pw.checkBox.setValue(true); } else { table.getRowFormatter().setStyleName(row, "ode-ProjectRowUnHighlighted"); pw.checkBox.setValue(false); } table.setWidget(row, 0, pw.checkBox); table.setWidget(row, 1, pw.nameLabel); table.setWidget(row, 2, pw.dateCreatedLabel); table.setWidget(row, 3, pw.dateModifiedLabel); table.setWidget(row, 4, pw.editButton); preparePublishApp(project, pw); row++; } Ode.getInstance().getProjectToolbar().updateButtons(); }
@Override public void setValueAndCreateNewEditors(TransUnit transUnit) { cachedValue = transUnit; editors.clear(); List<String> cachedTargets = cachedValue.getTargets(); if (cachedTargets == null) { cachedTargets = Lists.newArrayList(""); } editorGrid.resize(cachedTargets.size(), COLUMNS); int rowIndex = 0; for (String target : cachedTargets) { Editor editor = new Editor(target, rowIndex, listener, transUnit.getId()); editor.setEnableSpellCheck(listener.getConfigState().isSpellCheckEnabled()); editorGrid.setWidget(rowIndex, 0, editor); editors.add(editor); rowIndex++; } editorGrid.setStyleName(resolveStyleName(cachedValue.getStatus())); editingState = EditingState.SAVED; }
private void populateData(final List<QuestionAnswerStoreDto> data) { dataGrid.clear(true); updateSaveButtonStatus(false); if (data != null && data.size() > 0) { statusLabel.setVisible(false); dataGrid.resize(data.size() + 2, 3); loadHeaderRow(); for (int i = 0; i < data.size(); i++) { final int idx = i; dataGrid.setWidget(i + 1, 0, new Label(data.get(i).getSurveyInstanceId().toString())); TextBox temp = new TextBox(); temp.setText(data.get(i).getValue()); currentTextboxes.add(temp); temp.addChangeHandler( new ChangeHandler() { @Override public void onChange(ChangeEvent event) { String oldVal = data.get(idx).getValue(); String newVal = ((TextBox) event.getSource()).getValue(); if (!newVal.trim().equals(oldVal)) { dataGrid.getCellFormatter().setStyleName(idx + 1, 1, EDITED_ROW_CSS); // create a new copy of the answer so we don't // overwrite the old value QuestionAnswerStoreDto newAnswer = new QuestionAnswerStoreDto(); newAnswer.setKeyId(data.get(idx).getKeyId()); newAnswer.setArbitratyNumber(data.get(idx).getArbitratyNumber()); newAnswer.setCollectionDate(data.get(idx).getCollectionDate()); newAnswer.setType(data.get(idx).getType()); newAnswer.setQuestionID(data.get(idx).getQuestionID()); newAnswer.setValue(newVal.trim()); newAnswer.setSurveyId(data.get(idx).getSurveyId()); newAnswer.setSurveyInstanceId(data.get(idx).getSurveyInstanceId()); newAnswer.setOldValue(data.get(idx).getValue()); changedAnswers.put(newAnswer.getKeyId(), newAnswer); } else { dataGrid.getCellFormatter().setStyleName(idx + 1, 1, ""); changedAnswers.remove(data.get(idx).getKeyId()); } if (changedAnswers.size() > 0) { updateSaveButtonStatus(true); } else { updateSaveButtonStatus(false); } } }); dataGrid.setWidget(i + 1, 1, temp); dataGrid.getCellFormatter().setStyleName(idx + 1, 1, ""); dataGrid.setWidget(i + 1, 2, new Label(DATE_FMT.format(data.get(i).getCollectionDate()))); } if (data.size() >= 20) { nextButton.setVisible(true); } else { nextButton.setVisible(false); } if (currentPage > 0) { previousButton.setVisible(true); } else { previousButton.setVisible(false); } dataGrid.setWidget(data.size() + 1, 0, paginationPanel); dataGrid.setWidget(data.size() + 1, 1, saveButton); dataGrid.setWidget(data.size() + 1, 2, clearButton); } else { dataGrid.resize(1, 1); statusLabel.setText(TEXT_CONSTANTS.noResponsesForQuestion()); statusLabel.setVisible(true); } }
/** Initializes the Graphics */ public Graphics( FBCore fbCore, String userToken, String userEmail, String nickName, String playerRating, String playerRD) { initWidget(uiBinder.createAndBindUi(this)); treasureGridN = new Grid(1, 1); treasureGridN.setHeight(TREASURE_CHEST_HEIGHT + PADDING * 2 + "px"); treasureGridN.setCellPadding(PADDING); treasureGridS = new Grid(1, 1); treasureGridS.setHeight(TREASURE_CHEST_HEIGHT + PADDING * 2 + "px"); treasureGridS.setCellPadding(PADDING); AbsolutePanel treasurePanelN = new AbsolutePanel(); treasurePanelN.setSize(TREASURE_CHEST_WIDTH + "px", TREASURE_CHEST_HEIGHT + "px"); treasureGridN.setWidget(0, 0, treasurePanelN); AbsolutePanel treasurePanelS = new AbsolutePanel(); treasurePanelS.setSize(TREASURE_CHEST_WIDTH + "px", TREASURE_CHEST_HEIGHT + "px"); treasureGridS.setWidget(0, 0, treasurePanelS); gameGrid = new Grid(2, 6); gameGrid.resize(2, 6); for (int row = 0; row < 2; row++) { for (int col = 0; col < 6; col++) { AbsolutePanel pitPanel = new AbsolutePanel(); pitPanel.setSize(PIT_WIDTH + "px", PIT_HEIGHT + "px"); addSeeds(pitPanel, 0); if (row == 0) { handlerRegs[row][col] = pitPanel.addDomHandler( new ClickHandler() { @Override public void onClick(ClickEvent event) { // presenter.makeMove(colB); } }, ClickEvent.getType()); gameGrid.setWidget(row, 5 - col, pitPanel); // setPitEnabled(PlayerColor.NORTH, col, false); } else { handlerRegs[row][col] = pitPanel.addDomHandler( new ClickHandler() { @Override public void onClick(ClickEvent event) { // presenter.makeMove(colB); } }, ClickEvent.getType()); gameGrid.setWidget(row, col, pitPanel); // setPitEnabled(PlayerColor.SOUTH, col, true); } } } gameGrid.setCellPadding(20); gameAbsolutePanel.add(treasureGridN); gameAbsolutePanel.add(gameGrid, TREASURE_CHEST_WIDTH + 2 * PADDING, 0); gameAbsolutePanel.add( treasureGridS, TREASURE_CHEST_WIDTH + 14 * PADDING + PIT_WIDTH * 6 + 6 * 2, 0); gameAbsolutePanel.setSize( 12 + TREASURE_CHEST_WIDTH * 2 + 16 * PADDING + PIT_WIDTH * 6 + "px", 4 + 4 * PADDING + 2 * PIT_HEIGHT + "px"); gameAbsolutePanel.getElement().getStyle().setProperty("margin", "auto"); DOM.setStyleAttribute(gameAbsolutePanel.getElement(), "backgroundColor", "#b0c4de"); Image bgImg = new Image(); bgImg.setResource(gameImages.board()); DOM.setStyleAttribute( gameAbsolutePanel.getElement(), "backgroundImage", "url(" + bgImg.getUrl() + ")"); // Create a CellList. ContactCell contactCell = new ContactCell(); // Set a key provider that provides a unique key for each contact. If key is used to identify // contacts when fields (such as // the name and address) change. cellList = new CellList<ContactInfo>(contactCell, ContactInfo.KEY_PROVIDER); cellList.setPageSize(30); cellList.setKeyboardPagingPolicy(KeyboardPagingPolicy.INCREASE_RANGE); cellList.setKeyboardSelectionPolicy(KeyboardSelectionPolicy.BOUND_TO_SELECTION); // Add a selection model so we can select cells. final SingleSelectionModel<ContactInfo> selectionModel = new SingleSelectionModel<ContactInfo>(ContactInfo.KEY_PROVIDER); cellList.setSelectionModel(selectionModel); selectionModel.addSelectionChangeHandler( new SelectionChangeEvent.Handler() { public void onSelectionChange(SelectionChangeEvent event) { showPlayGameElements(selectionModel.getSelectedObject()); } }); // Set the cellList as the display of the pagers. This example has two pagers. pagerPanel is a // scrollable pager that extends // the range when the user scrolls to the bottom. rangeLabelPager is a pager that displays the // current range, but does not // have any controls to change the range. contactsPanel.setDisplay(cellList); // rangeLabelPager.setDisplay(cellList); presenter = new Presenter(this, fbCore, userEmail.toLowerCase(), userToken); turnLabel.setHorizontalAlignment(Label.ALIGN_CENTER); warnLabel.setHorizontalAlignment(Label.ALIGN_CENTER); aiMovesLabel.setHorizontalAlignment(Label.ALIGN_CENTER); hideStartGameElements(); initializeAudios(); initializeHandlers(); // presenter.setState(Presenter.deserializeState(stateStr)); setUserNameLabelText("Name: " + nickName + " (" + playerRating + "|" + playerRD + ")"); initializeUILanguage(); }