public Component generateCell(Table source, Object itemId, Object columnId) { Property property = source.getContainerProperty(itemId, columnId); if (property == null) { return null; } Object cellContent = property.getValue(); if (cellContent instanceof Collection) { StringBuilder sb = new StringBuilder(); Iterator<?> it = ((Collection<?>) cellContent).iterator(); while (it.hasNext()) { if (displayProperty != null) { Object value = new MethodProperty(it.next(), displayProperty).getValue(); sb.append(value); } else { sb.append(it.next()); } if (it.hasNext()) { sb.append(", "); } } return new Label(sb.toString()); } else if (cellContent != null) { Object value = cellContent; if (displayProperty != null) { value = new MethodProperty(cellContent, displayProperty).getValue(); } return new Label(value != null ? value.toString() : ""); } else { return null; } }
@Override public Object generateCell(Table source, Object itemId, Object columnId) { Property<OnmsServiceType> property = source.getContainerProperty(itemId, columnId); if (property == null || property.getValue() == null) { return null; } else { return property.getValue().getName(); } }
@Override public String getStyle(Object itemId, Object propertyId) { if (propertyId == null) { StringBuffer retval = new StringBuffer(); Integer severity = (Integer) m_table.getContainerProperty(itemId, "severityId").getValue(); Property prop = m_table.getContainerProperty(itemId, "acknowledged"); Boolean acknowledged = false; if (prop != null) { acknowledged = (Boolean) prop.getValue(); } if (OnmsSeverity.CLEARED.getId() == severity) { } else if (OnmsSeverity.CRITICAL.getId() == severity) { retval.append("alarm-critical"); } else if (OnmsSeverity.INDETERMINATE.getId() == severity) { retval.append("alarm-indeterminate"); } else if (OnmsSeverity.MAJOR.getId() == severity) { retval.append("alarm-major"); } else if (OnmsSeverity.MINOR.getId() == severity) { retval.append("alarm-minor"); } else if (OnmsSeverity.NORMAL.getId() == severity) { retval.append("alarm-normal"); } else if (OnmsSeverity.WARNING.getId() == severity) { retval.append("alarm-warning"); } if (!acknowledged) { retval.append("-noack"); } return retval.toString(); } else if ("severity".equals(propertyId)) { return "bright"; } return null; }
@Override public Object generateCell(final Table source, Object itemId, Object columnId) { if (source == null) return null; // no source Property alarmIdProperty = source.getContainerProperty(itemId, alarmIdPropertyName); final Object alarmId = alarmIdProperty.getValue(); if (alarmId == null) return null; // no value // create Link Button button = new Button("" + alarmId); button.setStyleName(BaseTheme.BUTTON_LINK); button.addListener( new ClickListener() { @Override public void buttonClick(ClickEvent event) { try { source .getWindow() .addWindow( new InfoWindow( new URL( source.getWindow().getURL(), "../../alarm/detail.htm?id=" + alarmId), new LabelCreator() { @Override public String getLabel() { return "Alarm Info " + alarmId; } })); } catch (MalformedURLException e) { // TODO Auto-generated catch block e.printStackTrace(); } } }); return button; }
public EditVehicleWindow(final VehicleView parent, final long vehID) { super("Edycja pojazdu"); FormLayout newVehicleLayout = new FormLayout(); final FieldGroup fields = new FieldGroup(); Table vehiclesList = parent.getVehiclesList(); fields.setBuffered(true); String fieldName = ""; fieldName = VehicleView.BRAND; TextField fieldBRAND = new TextField(fieldName); fieldBRAND.setValue( (String) vehiclesList .getContainerProperty(vehiclesList.getValue(), VehicleView.BRAND) .getValue()); fieldBRAND.addValidator( new StringLengthValidator("Niepoprawna długość pola marka", 3, 64, false)); fieldBRAND.addValidator( new RegexpValidator("^[\\p{L}0-9- ]*$", "Model zawiera nie właściwe znaki")); fieldBRAND.setWidth("20em"); fieldBRAND.setRequired(true); fieldBRAND.setRequiredError("Pole Model jest wymagane"); fieldBRAND.setImmediate(true); newVehicleLayout.addComponent(fieldBRAND); fields.bind(fieldBRAND, fieldName); fieldName = VehicleView.COLOUR; TextField fieldCOLOUR = new TextField(fieldName); fieldCOLOUR.setValue( (String) vehiclesList .getContainerProperty(vehiclesList.getValue(), VehicleView.COLOUR) .getValue()); fieldCOLOUR.addValidator( new StringLengthValidator("Niepoprawna długość pola Kolor nadwozia", 3, 64, false)); fieldCOLOUR.addValidator( new RegexpValidator("^[\\p{L}]*$", "pole Kolor nadwozia zawiera niewłaściwe znaki")); fieldCOLOUR.setWidth("20em"); fieldCOLOUR.setRequired(true); fieldCOLOUR.setRequiredError("Pole Kolor nadwozia jest wymagane"); fieldCOLOUR.setImmediate(true); newVehicleLayout.addComponent(fieldCOLOUR); fields.bind(fieldCOLOUR, fieldName); fieldName = VehicleView.MAX_LOAD; TextField fieldMAX_LOAD = new TextField(fieldName); fieldMAX_LOAD.setValue( vehiclesList .getContainerProperty(vehiclesList.getValue(), VehicleView.MAX_LOAD) .getValue() .toString()); fieldMAX_LOAD.setConverter(Integer.class); fieldMAX_LOAD.setConversionError("Wprowadzona wartość nie jest liczbą"); fieldMAX_LOAD.addValidator( new IntegerRangeValidator("Niewłaściwa wartość ładowności", 0, Integer.MAX_VALUE)); fieldMAX_LOAD.setWidth("20em"); fieldMAX_LOAD.setRequired(true); fieldMAX_LOAD.setRequiredError("Pole Ładowność jest wymagane"); fieldMAX_LOAD.setImmediate(true); newVehicleLayout.addComponent(fieldMAX_LOAD); fields.bind(fieldMAX_LOAD, fieldName); fieldName = VehicleView.REGISTRATION_NR; TextField fieldREGISTRATION_NR = new TextField(fieldName); fieldREGISTRATION_NR.setValue( (String) vehiclesList .getContainerProperty(vehiclesList.getValue(), VehicleView.REGISTRATION_NR) .getValue()); fieldREGISTRATION_NR.addValidator( new StringLengthValidator("Niepoprawna długość pola Nr rejestracyjny", 4, 12, false)); fieldREGISTRATION_NR.addValidator( new RegexpValidator("^[A-Z0-9-]+$", "pole Kolor zawiera nie właściwe znaki")); fieldREGISTRATION_NR.setWidth("20em"); fieldREGISTRATION_NR.setRequired(true); fieldREGISTRATION_NR.setRequiredError("Pole Nr rejestracyjny jest wymagane"); fieldREGISTRATION_NR.setImmediate(true); newVehicleLayout.addComponent(fieldREGISTRATION_NR); fields.bind(fieldREGISTRATION_NR, fieldName); Button changeDriver = new Button("Zatwierdź"); Button cancel = new Button("Anuluj"); HorizontalLayout hl = new HorizontalLayout(); hl.addComponent(changeDriver); hl.addComponent(cancel); newVehicleLayout.addComponent(hl); cancel.addClickListener( new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { close(); } }); changeDriver.addClickListener( new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { Vehicle veh = new Vehicle(); veh.setId(vehID); veh.setBrand((String) fields.getField(VehicleView.BRAND).getValue()); veh.setColour((String) fields.getField(VehicleView.COLOUR).getValue()); Integer truckLoad = null; try { truckLoad = Integer.parseInt(fields.getField(VehicleView.MAX_LOAD).getValue().toString()); } catch (NumberFormatException e) { Notification delayNot = new Notification("Proszę wypełnić pola poprawnie"); delayNot.setDelayMsec(1000); delayNot.show(Page.getCurrent()); return; } veh.setTruckload(truckLoad); veh.setRegistrationNumber( (String) fields.getField(VehicleView.REGISTRATION_NR).getValue()); Boolean valOk = true; Collection colFields = fields.getFields(); for (Object o : colFields) { Field fi = (Field) o; try { fi.validate(); } catch (Validator.InvalidValueException e) { Notification delayNot = new Notification("Proszę wypełnić pola poprawnie"); delayNot.setDelayMsec(1000); delayNot.show(Page.getCurrent()); valOk = false; break; } } if (valOk) { veh = ReceiveVehicle.changeVehicle(veh); if (veh == null) { Notification.show("Nie wprowadzono zmian"); close(); return; } Notification.show("Wprowadzono zmiany"); parent.refreshDataSource(); close(); } } }); addCloseListener( new Window.CloseListener() { @Override public void windowClose(Window.CloseEvent e) { parent.setEnabled(true); } }); parent.setEnabled(false); setContent(newVehicleLayout); setResizable(false); setDraggable(false); center(); }