Java Code Examples for org.apache.wicket.Component#getDefaultModelObject()

The following examples show how to use org.apache.wicket.Component#getDefaultModelObject() . These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: onedev   File: BeanEditor.java    License: MIT License 6 votes vote down vote up
public ComponentContext newComponentContext() {
	return new ComponentContext(this) {

		@Override
		public ComponentContext getChildContext(String childName) {
			for (Component groupContainer: groupsView) {
				RepeatingView propertiesView = (RepeatingView) groupContainer.get("content").get("properties");
				for (Component item: propertiesView) {
					@SuppressWarnings("unchecked")
					PropertyContext<Serializable> propertyContext = (PropertyContext<Serializable>) item.getDefaultModelObject(); 
					if (propertyContext.getPropertyName().equals(childName))
						return new ComponentContext(item);
				}
			}
			return null;
		}
		
	};
}
 
Example 2
@Override
public void onConfigure(Component component) {
	super.onConfigure(component);
	Object object = component.getDefaultModelObject();
	if(object!=null && object instanceof OIdentifiable) {
		ORID rid = ((OIdentifiable)object).getIdentity();
		if(rid.isPersistent()) {
			component.setEnabled(true);
		} else {
			// Is record scheduled for creation?
			OTransaction transaction = OrientDbWebSession.get().getDatabase().getTransaction();
			ORecordOperation operation = transaction.getRecordEntry(rid);
			component.setEnabled(operation!=null && operation.type==ORecordOperation.CREATED);
		}
	}
}
 
Example 3
Source Project: onedev   File: ParamListEditPanel.java    License: MIT License 5 votes vote down vote up
@Override
protected void onBeforeRender() {
	Component paramsView = get("params");
	String paramBeanClassName = (String) paramsView.getDefaultModelObject();
	if (!paramBeanClassName.equals(getDefaultParamBean().getClass().getName()))
		replace(newParamsView(getDefaultParamBean().getClass()));
	super.onBeforeRender();
}
 
Example 4
Source Project: onedev   File: ParamListEditPanel.java    License: MIT License 5 votes vote down vote up
@SuppressWarnings("unchecked")
@Override
protected List<Serializable> convertInputToValue() throws ConversionException {
	List<Serializable> value = new ArrayList<>();
	for (Component paramContainer: (WebMarkupContainer)get("params")) {
		Label label = (Label) paramContainer.get("name");
		ParamSupply param = new ParamSupply();
		param.setName((String) label.getDefaultModelObject());
		ParamSpec paramSpec = Preconditions.checkNotNull(getParamSpecs().get(param.getName()));
		param.setSecret(paramSpec instanceof SecretParam);
		Class<?> valuesProviderClass = (Class<?>) paramContainer.getDefaultModelObject();
		Component valuesEditor = paramContainer.get("values");
		if (valuesProviderClass == ScriptingValues.class) {
			ScriptingValues scriptingValues = new ScriptingValues();
			scriptingValues.setScriptName((String) ((PropertyEditor<Serializable>) valuesEditor).getConvertedInput()); 
			param.setValuesProvider(scriptingValues);
		} else if (valuesProviderClass == SpecifiedValues.class) {
			SpecifiedValues specifiedValues = new SpecifiedValues();
			for (Component valueContainer: (WebMarkupContainer)valuesEditor.get("values")) {
				Object propertyValue = ((PropertyEditor<Serializable>) valueContainer.get("value")).getConvertedInput();
				specifiedValues.getValues().add(paramSpec.convertToStrings(propertyValue));
			}
			param.setValuesProvider(specifiedValues);
		} else {
			param.setValuesProvider(new Ignore());
		}
		value.add(param);
	}
	return value;
}
 
Example 5
Source Project: onedev   File: FieldListEditPanel.java    License: MIT License 5 votes vote down vote up
@Override
protected void onBeforeRender() {
	Component fieldsView = get("fields");
	String fieldBeanClassName = (String) fieldsView.getDefaultModelObject();
	if (!fieldBeanClassName.equals(getDefaultFieldBean().getClass().getName()))
		replace(newFieldsView(getDefaultFieldBean().getClass()));
	super.onBeforeRender();
}
 
Example 6
Source Project: onedev   File: FieldListEditPanel.java    License: MIT License 5 votes vote down vote up
@SuppressWarnings("unchecked")
@Override
protected List<Serializable> convertInputToValue() throws ConversionException {
	List<Serializable> value = new ArrayList<>();
	for (Component container: (WebMarkupContainer)get("fields")) {
		Label label = (Label) container.get("name");
		FieldSupply field = new FieldSupply();
		field.setName((String) label.getDefaultModelObject());
		FieldSpec fieldSpec = Preconditions.checkNotNull(getFieldSpecs().get(field.getName()));
		field.setSecret(fieldSpec instanceof SecretField);
		if (container.get("value") instanceof PropertyEditor) {
			PropertyEditor<Serializable> propertyEditor = (PropertyEditor<Serializable>) container.get("value");
			Class<?> valueProviderClass = (Class<?>) container.getDefaultModelObject();
			if (valueProviderClass == SpecifiedValue.class) {
				SpecifiedValue specifiedValue = new SpecifiedValue();
				Object propertyValue = propertyEditor.getConvertedInput();
				specifiedValue.setValue(fieldSpec.convertToStrings(propertyValue));
				field.setValueProvider(specifiedValue);
			} else {
				ScriptingValue scriptingValue = new ScriptingValue();
				scriptingValue.setScriptName((String) propertyEditor.getConvertedInput()); 
				field.setValueProvider(scriptingValue);
			} 
		} else {
			field.setValueProvider(new Ignore());
		}
		value.add(field);
	}
	return value;
}
 
Example 7
Source Project: onedev   File: MilestoneListPage.java    License: MIT License 5 votes vote down vote up
@Override
protected Collection<MilestoneAndState> load() {
	List<Milestone> milestones = new ArrayList<>();
	for (Component row: (WebMarkupContainer)milestonesTable.get("body").get("rows")) {
		Milestone milestone = (Milestone) row.getDefaultModelObject();
		milestones.add(milestone);
	}
	return OneDev.getInstance(IssueManager.class).queryMilestoneAndStates(getProject(), milestones);
}
 
Example 8
Source Project: openmeetings   File: FolderPanel.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void onDrop(AjaxRequestTarget target, Component component) {
	Object o = component.getDefaultModelObject();
	if (o instanceof BaseFileItem) {
		BaseFileItem p = (BaseFileItem)getDefaultModelObject();
		BaseFileItem f = (BaseFileItem)o;
		if (treePanel.isSelected(f)) {
			moveAll(target, p);
		} else {
			move(target, p, f);
		}
		treePanel.updateNode(target, p);
	}
	target.add(treePanel.trees);
}
 
Example 9
protected Component getTreeRow(final Serializable hashId)
{
  @SuppressWarnings("unchecked")
  final Iterator<Component> it = rowRepeater.iterator();
  while (it.hasNext() == true) {
    final Component child = it.next();
    final TreeTableNode node = (TreeTableNode) child.getDefaultModelObject();
    if (node.getHashId().equals(hashId) == true) {
      return child;
    }
  }
  return null;
}
 
Example 10
Source Project: onedev   File: BeanEditor.java    License: MIT License 4 votes vote down vote up
@Override
public void onEvent(IEvent<?> event) {
	super.onEvent(event);
	
	if (event.getPayload() instanceof PropertyUpdating) {
		event.stop();
		PropertyUpdating propertyUpdating = (PropertyUpdating) event.getPayload();
		for (Component groupContainer: groupsView) {
			RepeatingView propertiesView = (RepeatingView) groupContainer.get("content").get("properties");
			for (Component propertyContainer: propertiesView) {
				@SuppressWarnings("unchecked")
				PropertyContext<Serializable> propertyContext = 
						(PropertyContext<Serializable>) propertyContainer.getDefaultModelObject(); 
				Set<String> checkedPropertyNames = new HashSet<>();
				if (hasTransitiveDependency(propertyContext.getPropertyName(), 
						propertyUpdating.getPropertyName(), checkedPropertyNames)) {
					/*
					 * Create new property container instead of simply refreshing it as some dependent 
					 * properties may only take effect when re-create the property container. For instance
					 * If default value of an issue field depends on input value of another issue field  
					 */
					PropertyContainer newPropertyContainer = 
							newPropertyContainer(propertyContainer.getId(), propertyContext);
					propertyContainer.replaceWith(newPropertyContainer);
					componentContexts.put(propertyContext.getPropertyName(), 
							new ComponentContext(newPropertyContainer));
					propertyUpdating.getHandler().add(newPropertyContainer);
					String script = String.format("$('#%s').addClass('no-autofocus');", 
							newPropertyContainer.getMarkupId());
					propertyUpdating.getHandler().appendJavaScript(script);
				}
			}
		}				
		
		convertInput();
		clearErrors();
		/**
		 * Bump up event even if some properties are invalid as we may need to do something with 
		 * partial properties of the bean. For instance to update issue description template
		 */
		send(this, Broadcast.BUBBLE, new BeanUpdating(propertyUpdating.getHandler()));
	}		
}
 
Example 11
@Override
public void onConfigure(Component component) {
	Object object = component.getDefaultModelObject();
	component.setEnabled(!(object instanceof IPrototype));
}