public void onCellOver(CellOverEvent event) { ListGridField gridField = AttributeListGrid.this.getField(event.getColNum()); if (gridField.getName().equals(attributeInfo.getName())) { ListGridRecord record = event.getRecord(); String value = record.getAttribute(attributeInfo.getName()); if (event.getRowNum() != row) { if (img != null) { cleanup(); } img = new Img(value); img.setMaxWidth(300); img.setMaxHeight(300); img.setKeepInParentRect(true); img.setShowEdges(true); img.setLeft(AttributeListGrid.this.getAbsoluteLeft() + 10); img.setTop(AttributeListGrid.this.getAbsoluteTop() + 10); img.draw(); killTimer = new Timer() { public void run() { img.destroy(); } }; killTimer.schedule(Math.round(3000)); row = event.getRowNum(); } } }
public void onCellClick(CellClickEvent event) { ListGridField gridField = AttributeListGrid.this.getField(event.getColNum()); if (gridField.getName().equals(attributeInfo.getName())) { ListGridRecord record = event.getRecord(); String value = record.getAttribute(attributeInfo.getName()); Window.open(value, "urlWindow", null); } }
private void updateAttributes(AssociationValue associationValue, ListGridRecord record) { for (AttributeInfo attributeInfo : featureInfo.getAttributes()) { Attribute<?> attr = associationValue.getAllAttributes().get(attributeInfo.getName()); if (attr.isPrimitive()) { Object value = attr.getValue(); if (value != null) { if (value instanceof Boolean) { record.setAttribute(attributeInfo.getName(), (Boolean) value); // "false" != false } else { record.setAttribute(attributeInfo.getName(), value.toString()); } } else { record.setAttribute(attributeInfo.getName(), ""); } } else { AssociationAttributeInfo associationAttributeInfo = (AssociationAttributeInfo) attributeInfo; String displayName = associationAttributeInfo.getFeature().getDisplayAttributeName(); Object value = attr.getValue(); if (value != null) { if (displayName == null) { displayName = associationAttributeInfo.getFeature().getAttributes().get(0).getName(); } switch (associationAttributeInfo.getType()) { case MANY_TO_ONE: ManyToOneAttribute manyToOneAttribute = (ManyToOneAttribute) attr; Object displayValue = manyToOneAttribute.getValue().getAllAttributes().get(displayName).getValue(); if (displayValue != null) { record.setAttribute(attributeInfo.getName(), displayValue.toString()); } else { record.setAttribute(attributeInfo.getName(), ""); } break; case ONE_TO_MANY: OneToManyAttribute oneToManyAttribute = (OneToManyAttribute) attr; List<String> values = new ArrayList<String>(); for (AssociationValue assoc : oneToManyAttribute.getValue()) { Object o = assoc.getAllAttributes().get(displayName).getValue(); if (o != null) { values.add(o.toString()); } } record.setAttribute(attributeInfo.getName(), StringUtil.join(values, ",")); break; } } else { record.setAttribute(attributeInfo.getName(), ""); } } } record.setAttribute(VALUE_HOLDER_RECORD_ATTRIBUTE, associationValue); }
/** * Create a single field definition from a attribute definition. * * @param attributeInfo attribute info * @return field for grid */ private ListGridField createAttributeGridField(final AttributeInfo attributeInfo) { ListGridField gridField = new ListGridField(attributeInfo.getName(), attributeInfo.getLabel()); gridField.setAlign(Alignment.LEFT); gridField.setCanEdit(false); gridField.setShowIfCondition( new IdentifyingListGridFieldIfFunction(attributeInfo.isIdentifying())); if (attributeInfo instanceof PrimitiveAttributeInfo) { PrimitiveAttributeInfo info = (PrimitiveAttributeInfo) attributeInfo; if (info.getType().equals(PrimitiveType.BOOLEAN)) { gridField.setType(ListGridFieldType.BOOLEAN); } else if (info.getType().equals(PrimitiveType.STRING)) { gridField.setType(ListGridFieldType.TEXT); } else if (info.getType().equals(PrimitiveType.DATE)) { gridField.setType(ListGridFieldType.DATE); } else if (info.getType().equals(PrimitiveType.SHORT)) { gridField.setType(ListGridFieldType.INTEGER); } else if (info.getType().equals(PrimitiveType.INTEGER)) { gridField.setType(ListGridFieldType.INTEGER); } else if (info.getType().equals(PrimitiveType.LONG)) { gridField.setType(ListGridFieldType.INTEGER); } else if (info.getType().equals(PrimitiveType.FLOAT)) { gridField.setType(ListGridFieldType.FLOAT); } else if (info.getType().equals(PrimitiveType.DOUBLE)) { gridField.setType(ListGridFieldType.FLOAT); } else if (info.getType().equals(PrimitiveType.IMGURL)) { gridField.setType(ListGridFieldType.IMAGE); if (showImageAttributeOnHover) { addCellOverHandler(new ImageCellHandler(attributeInfo)); } } else if (info.getType().equals(PrimitiveType.CURRENCY)) { gridField.setType(ListGridFieldType.TEXT); } else if (info.getType().equals(PrimitiveType.URL)) { gridField.setType(ListGridFieldType.TEXT); gridField.setAttribute("text-decoration", "underline"); addCellClickHandler(new UrlCellHandler(attributeInfo)); } } else if (attributeInfo instanceof AssociationAttributeInfo) { gridField.setType(ListGridFieldType.TEXT); } return gridField; }