Java Code Examples for com.vaadin.data.Property

The following are top voted examples for showing how to use com.vaadin.data.Property. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: holon-vaadin7   File: DefaultPropertyBoxProperty.java   Source Code and License 6 votes vote down vote up
@Override
public void setValue(T newValue) throws com.vaadin.data.Property.ReadOnlyException {

	// Check read-only
	if (isReadOnly()) {
		throw new Property.ReadOnlyException();
	}

	try {
		getPropertyBox().setValue(getPropertyId(), newValue);
	} catch (@SuppressWarnings("unused") PropertyReadOnlyException e) {
		throw new com.vaadin.data.Property.ReadOnlyException("Property is read-only: " + getPropertyId());
	}

	// fire value change event
	fireValueChange();
}
 
Example 2
Project: holon-vaadin7   File: ItemPropertyValueChangeListener.java   Source Code and License 6 votes vote down vote up
/**
 * Constructor
 * @param item Item
 * @param itemStore Item store
 */
public ItemPropertyValueChangeListener(Item item, ItemStore<Item> itemStore) {
	super();
	this.item = new WeakReference<>(item);
	this.itemStore = itemStore;

	if (item != null) {
		// add value change listener to track property modifications
		Collection<?> itemPropertyIds = item.getItemPropertyIds();
		if (itemPropertyIds != null) {
			trackedItemProperties = new HashSet<>(itemPropertyIds.size());
			for (Object itemPropertyId : itemPropertyIds) {
				Property<?> itemProperty = item.getItemProperty(itemPropertyId);
				if (itemProperty instanceof ValueChangeNotifier) {
					((ValueChangeNotifier) itemProperty).addValueChangeListener(this);
					trackedItemProperties.add(new WeakReference<>(itemProperty));
				}
			}
		}
	}
}
 
Example 3
Project: holon-vaadin7   File: AbstractViewComponent.java   Source Code and License 6 votes vote down vote up
@Override
public void setValue(T newValue) throws com.vaadin.data.Property.ReadOnlyException {
	this.value = newValue;
	// update internal component
	updateValue(newValue);
	// fire value change
	fireValueChange(newValue);
}
 
Example 4
Project: esup-ecandidat   File: InsensitiveStringFilter.java   Source Code and License 6 votes vote down vote up
/**
 * Pass le filtre
 * 
 * @param itemId
 * @param item
 * @return true si filtre ok
 */
@Override
public boolean passesFilter(Object itemId, Item item) {
	final Property<?> p = item.getItemProperty(propertyId);
	if (p == null) {
		return false;
	}
	Object propertyValue = p.getValue();
	if (propertyValue == null) {
		return false;
	}

	final String value = stripAccents(propertyValue.toString());
	if (!value.contains(filterString)) {
		return false;
	}
	return true;
}
 
Example 5
Project: osc-core   File: BindSecurityGroupWindow.java   Source Code and License 6 votes vote down vote up
@SuppressWarnings({ "rawtypes" })
private void serviceTableClicked(long itemId) {
	ComboBox policyComboBox = (ComboBox) this.serviceTable.getContainerProperty(itemId, PROPERTY_ID_POLICY)
			.getValue();
	ComboBox failurePolicyComboBox = (ComboBox) this.serviceTable
			.getContainerProperty(itemId, PROPERTY_ID_FAILURE_POLICY).getValue();
	Property itemProperty = this.serviceTable.getContainerProperty(itemId, PROPERTY_ID_ENABLED);

	boolean currentValue = (boolean) itemProperty.getValue();
	if (policyComboBox.getContainerDataSource().size() > 0) {
		if (isBindedWithMultiplePolicies(itemId)) {
			policyComboBox.setEnabled(false);
		} else {
			policyComboBox.setEnabled(currentValue);
		}
	}
	if (failurePolicyComboBox.getData() != null) {
		failurePolicyComboBox.setEnabled(currentValue);
	}
}
 
Example 6
Project: metasfresh-procurement-webui   File: TextOverlay.java   Source Code and License 6 votes vote down vote up
@Override
@SuppressWarnings({ "rawtypes", "unchecked" })
public void setPropertyDataSource(final Property newDataSource)
{
	// Stops listening the old data source changes
	if (dataSource instanceof Property.ValueChangeNotifier)
	{
		((Property.ValueChangeNotifier)dataSource).removeValueChangeListener(propertyListener);
	}

	dataSource = newDataSource;
	updateTextFromDataSource();

	// Listens the new data source if possible
	if (dataSource instanceof Property.ValueChangeNotifier)
	{
		((Property.ValueChangeNotifier)dataSource).addValueChangeListener(propertyListener);
	}

	markAsDirty();
}
 
Example 7
Project: metasfresh-procurement-webui   File: SendService.java   Source Code and License 6 votes vote down vote up
@Override
public <BT extends ISendAwareBean> void updateSentStatus(final BeanItem<BT> item)
{
	final BT bean = item.getBean();
	final boolean sent = bean.checkSent();

	@SuppressWarnings("unchecked")
	final Property<Boolean> sentProperty = item.getItemProperty(ProductQtyReport.PROPERTY_Sent);
	if (sentProperty.getValue() == sent)
	{
		return;
	}

	sentProperty.setValue(sent);

	//
	// Adjust the not-sent counter
	if (sent)
	{
		decrementNotSentCounter();
	}
	else
	{
		incrementNotSentCounter();
	}
}
 
Example 8
Project: cuba   File: CubaTreeTable.java   Source Code and License 6 votes vote down vote up
@Override
protected Object getPropertyValue(Object rowId, Object colId,
                                  Property property) {
    if (isColumnEditable(colId, isEditable()) && fieldFactory != null) {
        final Field<?> f = fieldFactory.createField(
                getContainerDataSource(), rowId, colId, this);
        if (f != null) {
            // Remember that we have made this association so we can remove
            // it when the component is removed
            associatedProperties.put(f, property);
            if (autowirePropertyDsForFields) {
                bindPropertyToField(rowId, colId, property, f);
            }
            return f;
        }
    }

    return formatPropertyValue(rowId, colId, property);
}
 
Example 9
Project: cuba   File: CubaTable.java   Source Code and License 6 votes vote down vote up
@Override
protected Object getPropertyValue(Object rowId, Object colId,
                                  Property property) {
    if (isColumnEditable(colId, isEditable()) && fieldFactory != null) {
        final Field<?> f = fieldFactory.createField(
                getContainerDataSource(), rowId, colId, this);
        if (f != null) {
            // Remember that we have made this association so we can remove
            // it when the component is removed
            associatedProperties.put(f, property);
            if (autowirePropertyDsForFields) {
                bindPropertyToField(rowId, colId, property, f);
            }
            return f;
        }
    }

    return formatPropertyValue(rowId, colId, property);
}
 
Example 10
Project: cuba   File: DataGridIndexedCollectionDsWrapper.java   Source Code and License 6 votes vote down vote up
@Override
public void itemPropertyChanged(Datasource.ItemPropertyChangeEvent e) {
    Item wrapper = getItemWrapper(e.getItem());

    // MetaProperty worked wrong with properties from inherited superclasses
    MetaClass metaClass = datasource.getMetaClass();
    String property = e.getProperty();
    MetaPropertyPath metaPropertyPath = metaClass.getPropertyPath(property);
    if (metaPropertyPath == null && DynamicAttributesUtils.isDynamicAttribute(property)) {
        metaPropertyPath = DynamicAttributesUtils.getMetaPropertyPath(metaClass, property);
    }
    if (metaPropertyPath == null) {
        return;
    }
    Property itemProperty = wrapper.getItemProperty(metaPropertyPath);
    if (itemProperty instanceof PropertyWrapper) {
        ((PropertyWrapper) itemProperty).fireValueChangeEvent();
    }
}
 
Example 11
Project: cuba   File: WebLookupField.java   Source Code and License 6 votes vote down vote up
protected void createComponent() {
    this.component = new CubaComboBox() {
        @Override
        public void setPropertyDataSource(Property newDataSource) {
            if (newDataSource == null)
                super.setPropertyDataSource(null);
            else
                super.setPropertyDataSource(new LookupPropertyAdapter(newDataSource));
        }

        @Override
        public void setComponentError(ErrorMessage componentError) {
            boolean handled = false;
            if (componentErrorHandler != null)
                handled = componentErrorHandler.handleError(componentError);

            if (!handled)
                super.setComponentError(componentError);
        }
    };
}
 
Example 12
Project: incubator-openaz   File: AttributeContainer.java   Source Code and License 6 votes vote down vote up
@Override
public Property<?> getContainerProperty(Object itemId, Object propertyId) {
	if (this.isObjectSupported(itemId) == false) {
		return null;
	}
       if (propertyId.equals(PROPERTY_ID)) {
           return new MethodProperty<Object>(getType(propertyId), 
           						new AttributeItem(itemId), ATTRIBUTEITEM_ID, null);
       }
       if (propertyId.equals(PROPERTY_CATEGORY)) {
           return new MethodProperty<Object>(getType(propertyId), 
           						new AttributeItem(itemId), ATTRIBUTEITEM_CATEGORY, null);
       }
       if (propertyId.equals(PROPERTY_DATATYPE)) {
           return new MethodProperty<Object>(getType(propertyId), 
           						new AttributeItem(itemId), ATTRIBUTEITEM_DATATYPE, null);
       }
       if (propertyId.equals(PROPERTY_VALUES)) {
           return new MethodProperty<Object>(getType(propertyId), 
           						new AttributeItem(itemId), ATTRIBUTEITEM_VALUES, null);
       }
	return null;
}
 
Example 13
Project: incubator-openaz   File: GitStatusContainer.java   Source Code and License 6 votes vote down vote up
@Override
	public Property<Object> getContainerProperty(Object itemId, Object propertyId) {
		GitEntry entry = this.map.get(itemId);
		if (entry == null) {
//			logger.error("unknown itemId: " + itemId);
			return null;
		}
        if (propertyId.equals(PROPERTY_NAME)) {
            return new MethodProperty<Object>(getType(propertyId),
                    new StatusItem(entry), GITSTATUSITEM_NAME, null);
        }
        if (propertyId.equals(PROPERTY_STATUS)) {
            return new MethodProperty<Object>(getType(propertyId),
                    new StatusItem(entry), GITSTATUSITEM_STATUS, null);
        }
        if (propertyId.equals(PROPERTY_ENTRY)) {
            return new MethodProperty<Object>(getType(propertyId),
                    new StatusItem(entry), GITSTATUSITEM_ENTRY, null);
        }
		return null;
	}
 
Example 14
Project: incubator-openaz   File: PDPPIPContainer.java   Source Code and License 6 votes vote down vote up
@Override
public Property<?> getContainerProperty(Object itemId, Object propertyId) {
	if (this.isSupported(itemId) == false) {
		return null;
	}
	
       if (propertyId.equals(PROPERTY_ID)) {
           return new MethodProperty<Object>(getType(propertyId),
                   new PDPPIPItem(itemId), PDPPIPITEM_ID, null);
       }

       if (propertyId.equals(PROPERTY_NAME)) {
           return new MethodProperty<Object>(getType(propertyId),
                   new PDPPIPItem(itemId), PDPPIPITEM_NAME, null);
       }
       
       if (propertyId.equals(PROPERTY_DESCRIPTION)) {
           return new MethodProperty<Object>(getType(propertyId),
                   new PDPPIPItem(itemId), PDPPIPITEM_DESCRIPTION, null);
       }
       
	return null;
}
 
Example 15
Project: incubator-openaz   File: AttributeValueContainer.java   Source Code and License 6 votes vote down vote up
@Override
public Property<?> getContainerProperty(Object itemId, Object propertyId) {
	if (this.isObjectSupported(itemId) == false) {
		return null;
	}
       if (propertyId.equals(PROPERTY_VALUE)) {
           return new MethodProperty<Object>(getType(propertyId),
                   new AttributeValueItem((ContainerAttribute) itemId), ATTRIBUTEVALUEITEM_VALUE, null);
       }

       if (propertyId.equals(PROPERTY_SOURCE)) {
           return new MethodProperty<Object>(getType(propertyId),
                   new AttributeValueItem((ContainerAttribute) itemId), ATTRIBUTEVALUEITEM_SOURCE, null);
       }
	return null;
}
 
Example 16
Project: hybridbpm   File: ChartEditor.java   Source Code and License 6 votes vote down vote up
@Override
public void valueChange(Property.ValueChangeEvent event) {
    if (chartConfigurationLayoutLayout != null && Objects.equals(designEditorLayout, chartConfigurationLayoutLayout.getParent())) {
        designEditorLayout.removeComponent(chartConfigurationLayoutLayout);
    }
    DiagrammeChartType chartType = DiagrammeChartType.valueOf(event.getProperty().getValue().toString());
    chartConfigurationLayoutLayout = chartType.createConfigLayout(preferences);
    designEditorLayout.addComponent(chartConfigurationLayoutLayout);
    designEditorLayout.setExpandRatio(chartConfigurationLayoutLayout, 1f);
    refreshChartConfigurationLayout();

    if (bandLayout != null && Objects.equals(designEditorLayout, bandLayout.getParent())) {
        designEditorLayout.removeComponent(bandLayout);
    }

    if (Objects.equals(chartType, DiagrammeChartType.GAUGE)) {
        bandLayout = chartType.getColorLayout(preferences);
        bandLayout.bindConfigurationValues();
        designEditorLayout.addComponent(bandLayout);
        designEditorLayout.setExpandRatio(bandLayout, 1f);
    }
}
 
Example 17
Project: hybridbpm   File: FieldForm.java   Source Code and License 6 votes vote down vote up
@Override
public void valueChange(Property.ValueChangeEvent event) {
    String className = (String) event.getProperty().getValue();
    if (FieldModelUtil.isSimple(className)) {
        switch (FieldModelUtil.getCLASSByCanonicalName(className)) {
            case STRING:
                editor.setValue(EDITOR_TYPE.TEXT_FIELD);
                break;
            case DATE:
                editor.setValue(EDITOR_TYPE.DATE_FIELD);
                break;
            case BIG_DECIMAL:
                editor.setValue(EDITOR_TYPE.TEXT_FIELD);
                break;
            case BOOLEAN:
                editor.setValue(EDITOR_TYPE.CHECK_BOX);
                break;
            case INTEGER:
                editor.setValue(EDITOR_TYPE.DATE_FIELD);
                break;
            default:
                editor.setValue(null);
                break;
        }
    }
}
 
Example 18
Project: hawkbit   File: DurationField.java   Source Code and License 6 votes vote down vote up
@Override
public void valueChange(final Property.ValueChangeEvent event) {
    // do not delete this method, even when removing the code inside this
    // method. This method overwrites the super method, which is
    // necessary, that parsing works correctly on pressing enter key

    if (!(event.getProperty() instanceof DurationField)) {
        return;
    }
    final Date value = (Date) event.getProperty().getValue();

    // setValue() calls valueChanged again, when the minimum is greater
    // than the maximum this can lead to an endless loop
    if (value != null && minimumDuration != null && maximumDuration != null
            && minimumDuration.before(maximumDuration)) {

        if (compareTimeOfDates(value, maximumDuration) > 0) {
            ((DateField) event.getProperty()).setValue(maximumDuration);
        }

        if (compareTimeOfDates(minimumDuration, value) > 0) {
            ((DateField) event.getProperty()).setValue(minimumDuration);
        }
    }
}
 
Example 19
Project: VaadHL   File: VaadHLi18n.java   Source Code and License 6 votes vote down vote up
@SuppressWarnings("unchecked")
public void changeAll(HasComponents root) {
	for (Component child : root) {
		if (child instanceof HasComponents) {
			changeAll((HasComponents) child);
		} else {
			String s;
			s = valueI18(child, "caption");
			if (s != null)
				child.setCaption(s);

			if (child instanceof Property) {
				s = valueI18(child, "value");
				if (s != null)
					((Property<String>) child).setValue(s);
			}

		}
	}
}
 
Example 20
Project: SecureBPMN   File: DatabasePage.java   Source Code and License 6 votes vote down vote up
@Override
protected Table createList() {
  final Table tableList = new Table();
  
  // Listener to change right panel when clicked on a task
  tableList.addListener(new Property.ValueChangeListener() {
    private static final long serialVersionUID = 8811553575319455854L;
    public void valueChange(ValueChangeEvent event) {
      // The itemId of the table list is the tableName
      String tableName = (String) event.getProperty().getValue();
      setDetailComponent(new DatabaseDetailPanel(tableName));
     
     // Update URL
     ExplorerApp.get().setCurrentUriFragment(
       new UriFragment(DatabaseNavigator.TABLE_URI_PART, tableName));
    }
  });
  
  // Create column headers
  tableList.addContainerProperty("icon", Embedded.class, null);
  tableList.setColumnWidth("icon", 22);
  tableList.addContainerProperty("tableName", String.class, null);
  tableList.setColumnHeaderMode(Table.COLUMN_HEADER_MODE_HIDDEN);
  
  return tableList;
}
 
Example 21
Project: SecureBPMN   File: TaskPage.java   Source Code and License 6 votes vote down vote up
protected ValueChangeListener getListSelectionListener() {
  return new Property.ValueChangeListener() {
    private static final long serialVersionUID = 1L;
    public void valueChange(ValueChangeEvent event) {
      Item item = taskTable.getItem(event.getProperty().getValue()); // the value of the property is the itemId of the table entry
      
      if(item != null) {
        String id = (String) item.getItemProperty("id").getValue();
        setDetailComponent(createDetailComponent(id));
        
        UriFragment taskFragment = getUriFragment(id);
        ExplorerApp.get().setCurrentUriFragment(taskFragment);
      } else {
        // Nothing is selected
        setDetailComponent(null);
        ExplorerApp.get().setCurrentUriFragment(getUriFragment(null));
      }
    }
  };
}
 
Example 22
Project: XACML   File: GitStatusContainer.java   Source Code and License 6 votes vote down vote up
@Override
	public Property<Object> getContainerProperty(Object itemId, Object propertyId) {
		GitEntry entry = this.map.get(itemId);
		if (entry == null) {
//			logger.error("unknown itemId: " + itemId);
			return null;
		}
        if (propertyId.equals(PROPERTY_NAME)) {
            return new MethodProperty<Object>(getType(propertyId),
                    new StatusItem(entry), GITSTATUSITEM_NAME, null);
        }
        if (propertyId.equals(PROPERTY_STATUS)) {
            return new MethodProperty<Object>(getType(propertyId),
                    new StatusItem(entry), GITSTATUSITEM_STATUS, null);
        }
        if (propertyId.equals(PROPERTY_ENTRY)) {
            return new MethodProperty<Object>(getType(propertyId),
                    new StatusItem(entry), GITSTATUSITEM_ENTRY, null);
        }
		return null;
	}
 
Example 23
Project: FiWare-Template-Handler   File: DatabasePage.java   Source Code and License 6 votes vote down vote up
@Override
protected Table createList() {
  final Table tableList = new Table();
  
  // Listener to change right panel when clicked on a task
  tableList.addListener(new Property.ValueChangeListener() {
    private static final long serialVersionUID = 8811553575319455854L;
    public void valueChange(ValueChangeEvent event) {
      // The itemId of the table list is the tableName
      String tableName = (String) event.getProperty().getValue();
      setDetailComponent(new DatabaseDetailPanel(tableName));
     
     // Update URL
     ExplorerApp.get().setCurrentUriFragment(
       new UriFragment(DatabaseNavigator.TABLE_URI_PART, tableName));
    }
  });
  
  // Create column headers
  tableList.addContainerProperty("icon", Embedded.class, null);
  tableList.setColumnWidth("icon", 22);
  tableList.addContainerProperty("tableName", String.class, null);
  tableList.setColumnHeaderMode(Table.COLUMN_HEADER_MODE_HIDDEN);
  
  return tableList;
}
 
Example 24
Project: opennmszh   File: EventTable.java   Source Code and License 6 votes vote down vote up
/**
 * Instantiates a new event table.
 *
 * @param events the OpenNMS events
 */
public EventTable(final Events events) {
    container.addAll(events.getEventCollection());
    setContainerDataSource(container);
    setStyleName(Runo.TABLE_SMALL);
    setImmediate(true);
    setSelectable(true);
    setVisibleColumns(COLUMN_NAMES);
    setColumnHeaders(COLUMN_LABELS);
    setWidth("100%");
    setHeight("250px");
    addListener(new Property.ValueChangeListener() {
        public void valueChange(Property.ValueChangeEvent event) {
            if (getValue() != null) {
                updateExternalSource(getEvent(getValue()));
            }
        }
    });
}
 
Example 25
Project: opennmszh   File: SSHOperation.java   Source Code and License 6 votes vote down vote up
public Undoer execute(final List<VertexRef> targets, final OperationContext operationContext) {
    String ipAddr = "";
    int port = 22;

    if (targets != null) {
        for(final VertexRef target : targets) {
            final Item vertexItem = operationContext.getGraphContainer().getBaseTopology().getVertex(target).getItem();
            if (vertexItem != null) {
                final Property ipAddrProperty = vertexItem.getItemProperty("ipAddr");
                ipAddr = ipAddrProperty == null ? "" : (String) ipAddrProperty.getValue();
                //Property portProperty = operationContext.getGraphContainer().getVertexItem(target).getItemProperty("port");
                port = 22; //portProperty == null ? -1 : (Integer) portProperty.getValue();
            }
        }
    }
    operationContext.getMainWindow().addWindow(new AuthWindow(ipAddr, port));
    return null;
}
 
Example 26
Project: XACML   File: PDPPIPContainer.java   Source Code and License 6 votes vote down vote up
@Override
public Property<?> getContainerProperty(Object itemId, Object propertyId) {
	if (this.isSupported(itemId) == false) {
		return null;
	}
	
       if (propertyId.equals(PROPERTY_ID)) {
           return new MethodProperty<Object>(getType(propertyId),
                   new PDPPIPItem(itemId), PDPPIPITEM_ID, null);
       }

       if (propertyId.equals(PROPERTY_NAME)) {
           return new MethodProperty<Object>(getType(propertyId),
                   new PDPPIPItem(itemId), PDPPIPITEM_NAME, null);
       }
       
       if (propertyId.equals(PROPERTY_DESCRIPTION)) {
           return new MethodProperty<Object>(getType(propertyId),
                   new PDPPIPItem(itemId), PDPPIPITEM_DESCRIPTION, null);
       }
       
	return null;
}
 
Example 27
Project: root   File: PatientSelectionView.java   Source Code and License 6 votes vote down vote up
@Override
public void wardChanged(WardChangeEvent event) {
	if (event.getWard() == null){
		patientsForTable = allPatients;
		propertiesForTable = allProperties;
		wardBtn.setCaption(MessageResources.getString("allPatients"));
	} else {
		patientsOfWard = patientProvider.getPatientsOfWard(event.getWard());
		propertiesOfWard = new Property[patientsOfWard.size()][5];
		patientsForTable = patientsOfWard;
		propertiesForTable = propertiesOfWard;
		wardBtn.setCaption(event.getWard().getCharacterisation());
	}
	
	container.removeAllItems();
	
	fillTable();
}
 
Example 28
Project: opennmszh   File: RrdField.java   Source Code and License 6 votes vote down vote up
@Override
public void setPropertyDataSource(Property newDataSource) {
    Object value = newDataSource.getValue();
    if (value instanceof Rrd) {
        Rrd dto = (Rrd) value;
        step.setValue(dto.getStep().toString());
        container.removeAllItems();
        List<RRA> rras = new ArrayList<RRA>();
        for (String rra : dto.getRraCollection()) {
            try {
                rras.add(new RRA(rra));
            } catch (Exception e) {} // Silently discard any bad RRAs.
        }
        container.addAll(rras);
        table.setPageLength(dto.getRraCount());
    } else {
        throw new ConversionException("Invalid type");
    }
    super.setPropertyDataSource(newDataSource);
}
 
Example 29
Project: XACML   File: AttributeValueContainer.java   Source Code and License 6 votes vote down vote up
@Override
public Property<?> getContainerProperty(Object itemId, Object propertyId) {
	if (this.isObjectSupported(itemId) == false) {
		return null;
	}
       if (propertyId.equals(PROPERTY_VALUE)) {
           return new MethodProperty<Object>(getType(propertyId),
                   new AttributeValueItem((ContainerAttribute) itemId), ATTRIBUTEVALUEITEM_VALUE, null);
       }

       if (propertyId.equals(PROPERTY_SOURCE)) {
           return new MethodProperty<Object>(getType(propertyId),
                   new AttributeValueItem((ContainerAttribute) itemId), ATTRIBUTEVALUEITEM_SOURCE, null);
       }
	return null;
}
 
Example 30
Project: opennmszh   File: SnmpCollectionTable.java   Source Code and License 6 votes vote down vote up
/**
 * Instantiates a new SNMP collection table.
 *
 * @param dataCollectionConfigDao the OpenNMS data collection configuration DAO
 */
public SnmpCollectionTable(final DataCollectionConfigDao dataCollectionConfigDao) {
    this.dataCollectionConfigDao = dataCollectionConfigDao;
    container.setBeanIdProperty("name");
    refreshSnmpCollections();
    setContainerDataSource(container);
    setStyleName(Runo.TABLE_SMALL);
    setImmediate(true);
    setSelectable(true);
    setVisibleColumns(COLUMN_NAMES);
    setColumnHeaders(COLUMN_LABELS);
    setWidth("100%");
    setHeight("250px");
    addListener(new Property.ValueChangeListener() {
        @SuppressWarnings("unchecked")
        public void valueChange(Property.ValueChangeEvent event) {
            if (getValue() != null) {
                BeanItem<SnmpCollection> item = (BeanItem<SnmpCollection>) getContainerDataSource().getItem(getValue());
                updateExternalSource(item);
            }
        }
    });
}
 
Example 31
Project: GPIO_Vaadin_Project   File: Rpi_gpio_controllerApplication.java   Source Code and License 6 votes vote down vote up
private void createAnimationSelector(final AbstractOrderedLayout parentLayout) {		
	ArrayList<Animation> animations = Animator.INSTANCE.getRegisteredAnimations();
	
	mAnimationSelector = new NativeSelect("Animation");
	mAnimationSelector.addItem(AnimationName_Random);
       for (int i = 0; i < animations.size(); ++i) {
       	mAnimationSelector.addItem(animations.get(i).getName());
       }

       mAnimationSelector.setNullSelectionAllowed(false);
       mAnimationSelector.setValue(AnimationName_Random);
       mAnimationSelector.setImmediate(true);
       mAnimationSelector.addListener(new Property.ValueChangeListener () {
       	public void valueChange(ValueChangeEvent event) {
           }
       });

       parentLayout.addComponent(mAnimationSelector);
       parentLayout.setComponentAlignment(mAnimationSelector, Alignment.MIDDLE_CENTER);
}
 
Example 32
Project: ilves   File: Grid.java   Source Code and License 6 votes vote down vote up
/**
 * Sets the filter definitions.
 * @param filterDefinitions the filterDefinitions to set
 */
public final void setFilters(final List<FilterDescriptor> filterDefinitions) {
    this.filters = filterDefinitions;
    if (filterLayout != null) {
        filterLayout.removeAllComponents();
        for (final FilterDescriptor filterDefinition : filterDefinitions) {
            filterDefinition.getField().setWidth(filterDefinition.getWidth() + "px");
            filterDefinition.getField().setCaption(filterDefinition.getLabel());
            filterDefinition.getField().setValue(filterDefinition.getDefaultValue());
            ((AbstractComponent) filterDefinition.getField()).setImmediate(true);
            filterDefinition.getField().addValueChangeListener(new Property.ValueChangeListener() {
                private static final long serialVersionUID = 1L;

                @Override
                public void valueChange(final ValueChangeEvent event) {
                    refresh();
                }
            });
            filterLayout.addComponent(filterDefinition.getField());
        }
    }
}
 
Example 33
Project: magnolia-handlebars   File: SupplierPageSelectorFieldFactory.java   Source Code and License 6 votes vote down vote up
@Override
protected AbstractSelect createFieldComponent() {

    final AbstractSelect supplierPageSelect = super.createFieldComponent();
    supplierPageSelect.setItemCaptionMode(AbstractSelect.ItemCaptionMode.EXPLICIT_DEFAULTS_ID);

    final AbstractSelect templateSelect = findTemplateSelect();
    if (templateSelect == null) {
        throw new RuntimeException("Cannot find template ComboBox");
    }
    Property.ValueChangeListener listener = getValueChangeListener(templateSelect, supplierPageSelect);
    templateSelect.addValueChangeListener(listener);
    listener.valueChange(new Field.ValueChangeEvent(templateSelect));

    supplierPageSelect.setVisible(utils.requiresParentTemplate((String) templateSelect.getValue()));
    return supplierPageSelect;
}
 
Example 34
Project: magnolia-handlebars   File: SupplierPageSelectorFieldFactory.java   Source Code and License 6 votes vote down vote up
private Property.ValueChangeListener getValueChangeListener(final AbstractSelect templateComboBox,
                                                            final AbstractSelect supplierPageSelect) {
    final Map<String, String> parentTemplates = utils.getParentTemplates();
    return new Property.ValueChangeListener() {
        @Override
        public void valueChange(Property.ValueChangeEvent event) {
            String templateId = (String) templateComboBox.getValue();
            boolean requiresSupplierPage = parentTemplates.containsKey(templateId);
            if (requiresSupplierPage) {
                supplierPageSelect.removeAllItems();
                String parentTemplateId = parentTemplates.get(templateId);
                final Map<String, String> pages = utils.findPagesUsingTemplate(parentTemplateId);
                for (Map.Entry<String, String> entry : pages.entrySet()) {
                    supplierPageSelect.addItem(entry.getValue());
                    supplierPageSelect.setItemCaption(entry.getValue(), entry.getKey());
                }
                supplierPageSelect.setRequired(true);
                supplierPageSelect.setVisible(true);
            } else {
                supplierPageSelect.setValue(null);
                supplierPageSelect.setRequired(false);
                supplierPageSelect.setVisible(false);
            }
        }
    };
}
 
Example 35
Project: magnolia-handlebars   File: SupplierPageColumnFormatter.java   Source Code and License 6 votes vote down vote up
@Override
public Object generateCell(Table source, Object itemId, Object columnId) {
    Item item = source.getItem(itemId);
    Property property = (item == null) ? null : item.getItemProperty(columnId);

    if (property != null) {
        Node supplierPage = null;
        try {
            supplierPage = MgnlContext.getJCRSession(RepositoryConstants.WEBSITE).getNodeByIdentifier(property.toString());
        } catch (RepositoryException e) {
            LOGGER.error("Cannot fetch supplier page", e);
        }
        return PropertyUtil.getString(supplierPage, "title");
    }
    return null;
}
 
Example 36
Project: opennmszh   File: ResourceTypeTable.java   Source Code and License 6 votes vote down vote up
/**
 * Instantiates a new resource type table.
 *
 * @param group the OpenNMS Data Collection Group
 */
public ResourceTypeTable(final DatacollectionGroup group) {
    OnmsBeanContainer<ResourceType> container = new OnmsBeanContainer<ResourceType>(ResourceType.class);
    container.addAll(group.getResourceTypeCollection());
    setContainerDataSource(container);
    setStyleName(Runo.TABLE_SMALL);
    setImmediate(true);
    setSelectable(true);
    setVisibleColumns(COLUMN_NAMES);
    setColumnHeaders(COLUMN_LABELS);
    setWidth("100%");
    setHeight("250px");
    addListener(new Property.ValueChangeListener() {
        @SuppressWarnings("unchecked")
        public void valueChange(Property.ValueChangeEvent event) {
            if (getValue() != null) {
                BeanItem<ResourceType> item = (BeanItem<ResourceType>) getContainerDataSource().getItem(getValue());
                updateExternalSource(item);
            }
        }
    });
}
 
Example 37
Project: holon-vaadin7   File: DefaultItemDataSourceContainer.java   Source Code and License 5 votes vote down vote up
@SuppressWarnings("rawtypes")
@Override
public Property getContainerProperty(Object itemId, Object propertyId) {
	final Item item = getItem(itemId);
	if (item != null) {
		return item.getItemProperty(propertyId);
	}
	return null;
}
 
Example 38
Project: holon-vaadin7   File: DefaultPropertyBoxItem.java   Source Code and License 5 votes vote down vote up
@Override
public Property<?> getItemProperty(Object id) {
	if (id instanceof com.holonplatform.core.property.Property) {
		com.holonplatform.core.property.Property<?> p = (com.holonplatform.core.property.Property<?>) id;
		if (getPropertyBox().contains(p)) {
			return getOrCreateProperty(p);
		}
	}
	return null;
}
 
Example 39
Project: holon-vaadin7   File: DefaultPropertyBoxProperty.java   Source Code and License 5 votes vote down vote up
public DefaultPropertyBoxProperty(com.holonplatform.core.property.Property<T> propertyId, PropertyBox propertyBox) {
	super();

	ObjectUtils.argumentNotNull(propertyId, "Property must be not null");
	ObjectUtils.argumentNotNull(propertyBox, "PropertyBox must be not null");

	this.propertyId = propertyId;
	this.propertyBox = propertyBox;
}
 
Example 40
Project: holon-vaadin7   File: ItemPropertyValueChangeListener.java   Source Code and License 5 votes vote down vote up
/**
 * Detach this listener from item properties
 */
public void detach() {
	if (trackedItemProperties != null) {
		for (WeakReference<Property<?>> itemProperty : trackedItemProperties) {
			Property<?> property = itemProperty.get();
			if (property != null) {
				((ValueChangeNotifier) property).removeValueChangeListener(this);
			}
		}
	}
}