private void createInputTableRowFor(FactPort factPort) { if (longExampleValues) { TextBox nameBox = CTextChangeHandler.createTextBox(factPort, "name"); SuggestBox typeBox = CTextChangeHandler.createTypeSuggestBox( (ServiceDesigner) factPort.getServiceScreen().get("serviceDesigner"), factPort, "factType"); TextArea exampleArea = CTextChangeHandler.createTextArea(factPort, "10cm", "8cm", "exampleValue"); int inputNumRows = inputPortTable.getRowCount(); inputPortTable.getRowFormatter().addStyleName(inputNumRows, "FindStyleForAlignTop"); // add the text and suggest boxes inputPortTable.setWidget(inputNumRows, 0, nameBox); inputPortTable.setWidget(inputNumRows, 1, typeBox); inputPortTable.setWidget(inputNumRows, 2, exampleArea); // add remove button Button removePortButton = new Button("Remove precondition"); removePortButton.setStyleName("fastButton"); RemoveInputPortHandler inputPortHandler = new RemoveInputPortHandler(); inputPortHandler.setFactPort(factPort); removePortButton.addClickHandler(inputPortHandler); inputPortTable.setWidget(inputNumRows, 3, removePortButton); // updateListener UpdateTransformationTabListener updateTabListener = new UpdateTransformationTabListener(); factPort.addPropertyChangeListener("name", updateTabListener); factPort.addPropertyChangeListener("factType", updateTabListener); factPort.addPropertyChangeListener("exampleValue", updateTabListener); } else { TextBox nameBox = CTextChangeHandler.createTextBox(factPort, "name"); SuggestBox typeBox = CTextChangeHandler.createTypeSuggestBox( (ServiceDesigner) factPort.getServiceScreen().get("serviceDesigner"), factPort, "factType"); TextBox exampleBox = CTextChangeHandler.createTextBox(factPort, "exampleValue"); int inputNumRows = inputPortTable.getRowCount(); // add the text and suggest boxes inputPortTable.setWidget(inputNumRows, 0, nameBox); inputPortTable.setWidget(inputNumRows, 1, typeBox); inputPortTable.setWidget(inputNumRows, 2, exampleBox); // add remove button Button removePortButton = new Button("Remove precondition"); removePortButton.setStyleName("fastButton"); RemoveInputPortHandler inputPortHandler = new RemoveInputPortHandler(); inputPortHandler.setFactPort(factPort); removePortButton.addClickHandler(inputPortHandler); inputPortTable.setWidget(inputNumRows, 3, removePortButton); } }
private void ensureBlank() { if (currentEditors.isEmpty() || currentEditors.get(currentEditors.size() - 1).getValue().isPresent()) { addValueEditor(false); } for (int i = 0; i < tableField.getRowCount(); i++) { Widget deleteButton = tableField.getWidget(i, 1); if (i < tableField.getRowCount() - 1 && !deleteButton.isVisible()) { deleteButton.setVisible(true); } } }
private int getRowCount() { int row = table.getRowCount(); int diff = row - rowLimit; if (diff > 0) { int i = 0; while (i < diff) { table.removeRow(i); i++; } return table.getRowCount(); } else { return row; } }
private void createOutputTableRowFor(FactPort factPort) { TextBox nameBox = CTextChangeHandler.createTextBox(factPort, "name"); SuggestBox typeBox = CTextChangeHandler.createTypeSuggestBox( (ServiceDesigner) factPort.getServiceScreen2().get("serviceDesigner"), factPort, "factType"); int outputNumRows = outputPortTable.getRowCount(); // add the text and suggest boxes outputPortTable.setWidget(outputNumRows, 0, nameBox); outputPortTable.setWidget(outputNumRows, 1, typeBox); // add remove button Button removePortButton = new Button("Remove postcondition"); removePortButton.setStyleName("fastButton"); RemoveOutputPortHandler outputPortHandler = new RemoveOutputPortHandler(); outputPortHandler.setFactPort(factPort); removePortButton.addClickHandler(outputPortHandler); outputPortTable.setWidget(outputNumRows, 3, removePortButton); // updateListener UpdateTransformationTabListener updateTabListener = new UpdateTransformationTabListener(); factPort.addPropertyChangeListener("name", updateTabListener); factPort.addPropertyChangeListener("factType", updateTabListener); }
/** * Add a new row to the sub goals table * * @param integer * @param subGoalsTable the flex table for the sub-goals */ private void addRowToTable( String info, String keyInfo, Integer priority, final FlexTable table, boolean isAsset) { // get the current number of rows so we know where to add the new text box int currentNumberOfRows = table.getRowCount(); // Create and add the textbox and supporting links for the mechanics of the UI final ScrollBarTextBox userInput = new ScrollBarTextBox(); userInput.setWidth("100%"); SquareHyperlink removeLink = new SquareHyperlink(messages.remove()); userInput.setName(String.valueOf(currentNumberOfRows)); userInput.setKey(keyInfo); // For tracking db id userInput.setText(info); userInput.setPriority(priority); table.setWidget(currentNumberOfRows, 0, userInput); table.setWidget(currentNumberOfRows, 1, removeLink); FlexCellFormatter formatter = table.getFlexCellFormatter(); formatter.setHorizontalAlignment(currentNumberOfRows, 0, HasHorizontalAlignment.ALIGN_LEFT); formatter.setHorizontalAlignment(currentNumberOfRows, 1, HasHorizontalAlignment.ALIGN_RIGHT); formatter.setWidth(currentNumberOfRows, 1, "10%"); if (isAsset) { this.addAssetToTable(userInput, removeLink); } else { this.addGoalToTable(userInput, removeLink); } }
public void updateRoleTotals() { int mint = 0; int maxt = 0; final int rows = roleft.getRowCount() - 2; for (int row = 0; row < rows; ++row) { TextBox minw = (TextBox) roleft.getWidget(row + 1, 1); TextBox maxw = (TextBox) roleft.getWidget(row + 1, 2); mint += Integer.parseInt(minw.getText()); maxt += Integer.parseInt(maxw.getText()); } roleft.setText(rows + 1, 1, "" + mint); roleft.setText(rows + 1, 2, "" + maxt); int size = getRaidSize(); FlexTable.FlexCellFormatter fcf = roleft.getFlexCellFormatter(); if (mint < size) { fcf.addStyleName(rows + 1, 1, "error"); } else { fcf.removeStyleName(rows + 1, 1, "error"); } if (maxt < size) { fcf.addStyleName(rows + 1, 2, "error"); } else { fcf.removeStyleName(rows + 1, 2, "error"); } updateBadgeRoles(); }
private void displayStock(final String finalSymbol) { // Add the task to the table. int row = tasksFlexTable.getRowCount(); tasks.add(finalSymbol); tasksFlexTable.setText(row, 0, finalSymbol); tasksFlexTable.setWidget(row, 2, new Label()); tasksFlexTable.getCellFormatter().addStyleName(row, 1, "watchListNumericColumn"); tasksFlexTable.getCellFormatter().addStyleName(row, 2, "watchListNumericColumn"); tasksFlexTable.getCellFormatter().addStyleName(row, 3, "watchListRemoveColumn"); // Add a button to remove this task from the table. Button removeTaskButton = new Button("x"); removeTaskButton.addStyleDependentName("remove"); removeTaskButton.addClickHandler( new ClickHandler() { public void onClick(ClickEvent event) { removeStock(finalSymbol); } }); tasksFlexTable.setWidget(row, 3, removeTaskButton); // Get the stock price. refreshWatchList(); newTaskTextBox.setFocus(true); }
private void addAssignmentRow(final Assignment assignment, int insertrow) { int j = 0; int row = (insertrow <= assignmentsTable.getRowCount()) ? assignmentsTable.insertRow(insertrow) : insertrow; Image delIcon = getDeleteIcon(assignment); // assignment assignmentsTable.setWidget(row, j++, delIcon); Image icon = new Image(); icon.setUrl(getIconFile(assignment.getIconFileName())); assignmentsTable.setWidget(row, j++, icon); assignmentsTable.setWidget(row, j++, new Label(assignment.getToolName())); final TextBox textForSolvedAssignment = getHintTextBox(assignment, Result.CORRECT); assignmentsTable.setWidget(row, j++, textForSolvedAssignment); final ListBox fractions = getFractionsLB(assignment, Result.CORRECT); assignmentsTable.setWidget(row, j++, fractions); Image editIcon = new Image(GuiResources.INSTANCE.menu_icon_edit()); editIcon.addClickHandler( new ClickHandler() { public void onClick(ClickEvent event) { handleEditClick(assignment); } }); assignmentsTable.setWidget(row, j++, editIcon); }
private ValueEditor<O> addValueEditor(boolean deleteVisible) { final ValueEditor<O> editor = getFreshValueEditor(); currentEditors.add(editor); final int rowCount = tableField.getRowCount(); tableField.setWidget(rowCount, 0, editor.asWidget()); final DeleteButton deleteButton = new DeleteButton(); deleteButton.addClickHandler( new ClickHandler() { @Override public void onClick(ClickEvent event) { handleDelete(editor); } }); tableField.setWidget(rowCount, 1, deleteButton); final FlexTable.FlexCellFormatter formatter = tableField.getFlexCellFormatter(); formatter.setWidth(rowCount, 0, "100%"); formatter.setVerticalAlignment(rowCount, 0, HasVerticalAlignment.ALIGN_TOP); formatter.setWidth(rowCount, 1, "30px"); formatter.getElement(rowCount, 1).getStyle().setPaddingLeft(1, Style.Unit.PX); formatter.setVerticalAlignment(rowCount, 1, HasVerticalAlignment.ALIGN_TOP); editor.addDirtyChangedHandler(dirtyChangedHandler); editor.addValueChangeHandler(valueChangeHandler); deleteButton.setVisible(deleteVisible); return editor; }
private void layout(final SearchSummaryItem ssi, final int depth) { final int row = table.getRowCount(); final Image loading = new Image(GwtUtil.LOADING_ICON_URL); ssi.checkUpdate(); table.setWidget(row, iconColIdx, loading); if (ssi.isLoaded()) { ssi.renderItem(table, row, curGroupByName); GwtUtil.setStyles(loading, "visibility", "hidden"); } else { ssi.checkUpdate(); table.setWidget(row, iconColIdx, loading); Timer timer = new Timer() { public void run() { ssi.checkUpdate(); ssi.renderItem(table, row, curGroupByName); if (ssi.isLoaded()) { cancel(); GwtUtil.setStyles(loading, "visibility", "hidden"); } } }; bgList.add(timer); timer.scheduleRepeating(1000); } if (ssi.getChildren() != null && ssi.getChildren().size() > 0) { for (SearchSummaryItem child : ssi.getChildren()) { layout(child, depth + 1); } } }
private void update() { // Update the older/newer buttons & label. int count = MailItems.getMailItemCount(); int max = startIndex + VISIBLE_EMAIL_COUNT; if (max > count) { max = count; } // Update the nav bar. navBar.update(startIndex, count, max); // Show the selected emails. int i = 0; for (; i < VISIBLE_EMAIL_COUNT; ++i) { // Don't read past the end. if (startIndex + i >= MailItems.getMailItemCount()) { break; } MailItem item = MailItems.getMailItem(startIndex + i); // Add a new row to the table, then set each of its columns to the // email's sender and subject values. table.setText(i, 0, item.sender); table.setText(i, 1, item.email); table.setText(i, 2, item.subject); } // Clear any remaining slots. for (; i < VISIBLE_EMAIL_COUNT; ++i) { table.removeRow(table.getRowCount() - 1); } }
/** removeAllRows */ private void removeAllRows() { selectedRow = -1; evaluateEnableAction(); while (folderTable.getRowCount() > 0) { folderTable.removeRow(0); } }
public Position getCellPosition(Widget cell) { for (int row = 0; row < table.getRowCount(); row++) { for (int col = 0; col < table.getCellCount(row); col++) { if (cell == table.getWidget(row, col)) return new Position(row, col); } } return null; }
private void BuildList(String Filter) { Iterator<Entry<String, pojoMethod>> it = this.methodList.entrySet().iterator(); int i = 0; this._MenuStack.clear(); this._MenuStack.removeAllRows(); // this._MenuStack.setHeight(height) // We need to set Height of the parent panel dynamically based on the number of items // We need to add a hidden field with a unique id while (it.hasNext()) { // Use of final to allow access to it in the clickHandlers final int index = i; // This keeps track of which item we are looking at Entry<String, pojoMethod> tmpEntry = it.next(); final pojoMethod tmpMethod = tmpEntry.getValue(); // String comp1 = tmpMethod.getMethodName().toLowerCase(); String comp2 = Filter.toLowerCase(); if (comp1.contains(comp2)) { final Label titleLabel = new Label(); titleLabel.setText(tmpMethod.getMethodName()); titleLabel.addStyleName("menuMethodName"); final int _i = i; // _edit.setStyleName("btnEditMethod"); titleLabel.addClickHandler( new ClickHandler() { @Override public void onClick(ClickEvent event) { // set selected style/should shuffle as well setActiveMenu(tmpMethod.getMethodID()); eventBus.fireEvent( new DragEvent(titleLabel.getText(), "EditMethod", index, (IPojo) tmpMethod)); } }); // this._MenuStack.setWidget(i,0,tmpItem.asWidget()); this._MenuStack.setWidget(i, 0, titleLabel); // this._MenuStack.setWidget(i,1,_edit); Hidden tmpHidden = new Hidden(); tmpHidden.setValue(tmpMethod.getMethodID()); this._MenuStack.setWidget(i, 1, tmpHidden); _MenuStack.getFlexCellFormatter() .getElement(i, 0) .setAttribute("style", "border-right:Solid 1px #ccc;"); // _MenuStack.getFlexCellFormatter().getElement(i, 1).setAttribute("style", // "padding-left:5px;"); i++; } } _MenuStack.setCellPadding(0); _MenuStack.setCellSpacing(0); int newHeight = _MenuStack.getRowCount() * 30; this._MenuStack.setHeight(newHeight + "px"); }
public PasswordTextBox insertPasswordWidget(String key) { int row = table.getRowCount(); PasswordTextBox box = new PasswordTextBox(); table.setWidget(row, 0, new Label(key)); table.setWidget(row, 1, box); table.getFlexCellFormatter().addStyleName(row, 0, "property-Table-Key"); table.getFlexCellFormatter().addStyleName(row, 1, "property-Table-Value"); return box; }
public void insertWidget(Widget key, Widget value) { int row = table.getRowCount(); table.setWidget(row, 0, key); table.setWidget(row, 1, value); table.getFlexCellFormatter().addStyleName(row, 0, Resources.INSTANCE.css().propertyTableKey()); table .getFlexCellFormatter() .addStyleName(row, 1, Resources.INSTANCE.css().propertyTableValue()); }
@Override public void addResult(String jobId, String status, String result) { int row = results.getRowCount(); results.getRowFormatter().addStyleName(row, (row % 2) == 0 ? "evenRow" : "oddRow"); results.setWidget(row, 0, new Label(jobId)); results.setWidget(row, 1, new Label(status)); results.setWidget(row, 2, new Label(result)); resultsScroller.scrollToBottom(); }
private int addStockToWatchList(String symbol) { int row = stocksFlexTable.getRowCount(); stocks.add(symbol); stocksFlexTable.setText(row, 0, symbol); stocksFlexTable.setWidget(row, 2, new Label()); stocksFlexTable.getCellFormatter().addStyleName(row, 1, "watchListNumericColumn"); stocksFlexTable.getCellFormatter().addStyleName(row, 2, "watchListNumericColumn"); stocksFlexTable.getCellFormatter().addStyleName(row, 3, "watchListRemoveColumn"); return row; }
public void updateRowVisibility(Set<String> names) { if (names.equals(showNames)) return; this.showNames = names; int row = 0; while (row < table.getRowCount()) { Element rowEl = rowFormatter.getElement(row); String className = rowEl.getClassName().trim(); rowFormatter.setVisible(row, className.isEmpty() || showNames.contains(className)); row++; } }
public TextBox insertTextWidget(String key, String width) { int row = table.getRowCount(); TextBox box = new TextBox(); if (width != null) box.setWidth(width); box.addStyleName("neo-TextBox"); table.setWidget(row, 0, new Label(key)); table.setWidget(row, 1, box); table.getFlexCellFormatter().addStyleName(row, 0, "property-Table-Key"); table.getFlexCellFormatter().addStyleName(row, 1, "property-Table-Value"); return box; }
private void applyDataRowStyles() { HTMLTable.RowFormatter rf = flexTable.getRowFormatter(); for (int row = 1; row < flexTable.getRowCount(); ++row) { if ((row % 2) != 0) { rf.addStyleName(row, "FlexTable-OddRow"); } else { rf.addStyleName(row, "FlexTable-EvenRow"); } } }
public void updateBadgeRoles() { final int role_rows = roleft.getRowCount() - 2; final int badge_rows = badgeft.getRowCount() - 1; for (int i = 0; i < badge_rows; ++i) { ListBox broles = (ListBox) badgeft.getWidget(i + 1, 2); String selected = broles.getItemText(broles.getSelectedIndex()); broles.clear(); broles.addItem(ALL_ROLES); int selected_index = 0; for (int j = 0; j < role_rows; ++j) { String role = roleft.getText(j + 1, 0); broles.addItem(role); if (role.equals(selected)) { selected_index = j + 1; } } broles.setSelectedIndex(selected_index); // should num slots be enabled? boolean enable = false; if (selected_index > 0) { CheckBox cb = (CheckBox) badgeft.getWidget(i + 1, 1); if (cb.getValue()) { enable = true; } } TextBox tb = (TextBox) badgeft.getWidget(i + 1, 3); tb.setEnabled(enable); if (!enable) { tb.setText("0"); } } }
public List<Integer> getSelectedRows() { List<Integer> selectedRows = new ArrayList<Integer>(); for (int i = 0; i < contactsTable.getRowCount(); ++i) { CheckBox checkBox = (CheckBox) contactsTable.getWidget(i, 0); if (checkBox.getValue()) { selectedRows.add(i); } } return selectedRows; }
public int addZone() { Image deleteZone = new Image(AppPresenter.images.closeIcon().getURL()); int rowIndex = listOfZoneDesigner.getRowCount(); deleteZone.getElement().getStyle().setCursor(Cursor.POINTER); listOfZoneDesigner.setWidget(rowIndex, 0, deleteZone); CustomListBox listOfTemplate = new CustomListBox(); listOfZoneDesigner.setWidget(rowIndex, 1, listOfTemplate); return rowIndex - 1; }
/** Add a row to the flex table. */ private void addRows() { int rowIndex = flexTable.getRowCount(); for (int i = 0; i < addRecord.size(); i++) { Widget widget = addWidget(addRecord.get(rowIndex - 1)); flexTable.setText(rowIndex, 0, addRecord.get(i).getFieldName()); flexTable.setWidget(rowIndex, 1, widget); flexTable.setText(rowIndex, 2, getMandatory(addRecord.get(rowIndex - 1))); flexTable.setText(rowIndex, KEY_COLUMN, addRecord.get(i).getFieldKey()); applyDataRowStyles(); flexTable.setCellSpacing(0); flexTable.addStyleName("FlexTable"); flexTable.setWidth("90%"); rowIndex++; } }
@SuppressWarnings("unchecked") public Widget createOutputPortTable() { VerticalPanel outputPanel = new VerticalPanel(); Label hintLabel = new Label("Define the postcondtion where this resource will deliver results:"); outputPanel.add(hintLabel); outputPortTable = new FlexTable(); int numRows = outputPortTable.getRowCount(); // Add new output port Button Button addOutputPortButton = new Button("Add postcondition"); addOutputPortButton.setStyleName("fastButton"); addOutputPortButton.addClickHandler(new AddNewOutputPortHandler()); outputPortTable.setWidget(numRows, 0, addOutputPortButton); numRows++; // add output header row outputPortTable.setWidget(numRows, 0, new Label("Postcondition name")); outputPortTable.setWidget(numRows, 1, new Label("Postcondition type")); numRows++; // add rows for existing output fact ports Iterator<FactPort> iteratorOfPostconditions = buildingBlock.iteratorOfPostconditions(); while (iteratorOfPostconditions.hasNext()) { FactPort factPort = iteratorOfPostconditions.next(); // per fact port add one row with three text boxes for name, type, and example value createOutputTableRowFor(factPort); } if (longExampleValues) { // updateListener UpdateTransformationTabListener updateTabListener = new UpdateTransformationTabListener(); buildingBlock.addPropertyChangeListener( BuildingBlock.PROPERTY_POSTCONDITIONS, updateTabListener); } // return the panel outputPortTable.ensureDebugId("cwFlexTable"); outputPanel.add(outputPortTable); return outputPanel; }
@SuppressWarnings("unchecked") public Widget createInputPortTable() { portPanel = new VerticalPanel(); Label hintLabel = new Label("Define the preconditions where previous building blocks may provide data:"); portPanel.add(hintLabel); inputPortTable = new FlexTable(); int numRows = inputPortTable.getRowCount(); // add the add-buttons // Add new input port Button Button addInputPortButton = new FastButton("Add precondition"); addInputPortButton.addClickHandler(new AddNewInputPortHandler()); inputPortTable.setWidget(numRows, 0, addInputPortButton); numRows++; // add input header row inputPortTable.setWidget(numRows, 0, new Label("Precondition name:")); inputPortTable.setWidget(numRows, 1, new Label("Precondition type:")); if (longExampleValues) { inputPortTable.setWidget(numRows, 2, new Label("List of example values")); } else { inputPortTable.setWidget(numRows, 2, new Label("Example value:")); } numRows++; // add rows for existing input fact ports Iterator<FactPort> iteratorOfPreconditions = buildingBlock.iteratorOfPreconditions(); while (iteratorOfPreconditions.hasNext()) { FactPort factPort = iteratorOfPreconditions.next(); // per fact port add one row with three text boxes for name, type, and example value createInputTableRowFor(factPort); } // return the panel inputPortTable.ensureDebugId("cwFlexTable"); portPanel.add(inputPortTable); return portPanel; }
public void setModel(ProductInfo[] pi) { searchModel = pi; while (items.getRowCount() > 0) items.removeRow(0); if (searchModel == null || searchModel.length == 0) { emptyCartLbl.setVisible(true); return; } RowFormatter fmtr = items.getRowFormatter(); for (int i = 0; i < searchModel.length; i++) { int row = items.insertRow(i); for (int j = 0; j < 2; j++) items.insertCell(row, j); items.setText(row, 0, searchModel[i].name); items.setText(row, 1, searchModel[i].description); fmtr.addStyleName(row, "ps-GridRow ps-GridRow-sel"); } emptyCartLbl.setVisible(false); }
public void init() { trustActionCache = TrustActionCache.getInstance(constants, messages); posttypeCache = PosttypeCache.getInstance(constants, messages); idHolder.init(); while (table.getRowCount() > 1) { table.removeRow(1); } int row = 1; for (JSONObject object : trustActionCache.getAll()) { addRow(object, row); row++; } helpPanel.resize(this); }
/** Configures a flex table and corresponding titles to add to the overall layout. */ private VerticalPanel addToPanel( String sectionText, final FlexTable table, final boolean isAsset) { VerticalPanel layout = new VerticalPanel(); layout.setWidth("60%"); layout.setStyleName("asset-step-layout"); layout.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_RIGHT); table.setWidth("100%"); FlexCellFormatter formatter = table.getFlexCellFormatter(); formatter.setHorizontalAlignment(0, 0, HasHorizontalAlignment.ALIGN_LEFT); // Adding the section headings for the table Label sectionLabel = new Label(sectionText); sectionLabel.setStyleName("square-title"); table.setWidget(0, 0, sectionLabel); if (table.getRowCount() == 0) { this.addRowToTable("", null, -1, table, isAsset); // initially blank } Button newRowButton = null; if (isAsset) { newRowButton = new Button(messages.addAssetButton()); } else { newRowButton = new Button(messages.addSecuritySubGoal()); } newRowButton.setWidth("180px"); newRowButton.addClickHandler( new ClickHandler() { public void onClick(ClickEvent event) { addRowToTable("", null, new Integer(-1), table, isAsset); } }); layout.add(table); layout.add(newRowButton); return layout; }