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

The following examples show how to use org.apache.wicket.Component#setEnabled() . 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 File: DisableIfDocumentNotSavedBehavior.java    From wicket-orientdb with Apache License 2.0 6 votes vote down vote up
@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 2
Source File: OIntegrationConfigStopBehavior.java    From Orienteer with Apache License 2.0 6 votes vote down vote up
@Override
public void onConfigure(Component component) {
	super.onConfigure(component);
		ODocumentModel docModel=null;
		if(component.getDefaultModel() instanceof ODocumentModel){
			docModel = (ODocumentModel) component.getDefaultModel();
		}else if(component.getDefaultModel() instanceof IWrapModel){
			docModel = (ODocumentModel) ((IWrapModel<?>) component.getDefaultModel()).getWrappedModel();
		}
		if (docModel!=null && docModel.getObject()!=null){
			OIntegrationConfig config = new OIntegrationConfig(docModel.getObject());
			CamelContext context = config.getOrMakeContext(component);
			ServiceStatus status = context.getStatus();
			if (status.isStopped()){
				component.setEnabled(false);
			}else{
				component.setEnabled(true);
			}
		}
}
 
Example 3
Source File: LambdaBehavior.java    From webanno with Apache License 2.0 5 votes vote down vote up
public static Behavior enabledWhen(SerializableBooleanSupplier aPredicate)
{
    return new Behavior()
    {
        private static final long serialVersionUID = -1435780281900876366L;

        @Override
        public void onConfigure(Component aComponent)
        {
            aComponent.setEnabled(aPredicate.getAsBoolean());
        }
    };
}
 
Example 4
Source File: OTaskSessionInterruptBehavior.java    From Orienteer with Apache License 2.0 5 votes vote down vote up
@Override
public void onConfigure(Component component) {
	super.onConfigure(component);
		ODocumentModel docModel=null;
		if(component.getDefaultModel() instanceof ODocumentModel){
			docModel = (ODocumentModel) component.getDefaultModel();
		}else if(component.getDefaultModel() instanceof IWrapModel){
			docModel = (ODocumentModel) ((IWrapModel<?>) component.getDefaultModel()).getWrappedModel();
		}
		if (docModel!=null && docModel.getObject()!=null){
			component.setEnabled(new OTaskSession(docModel.getObject()).isInterruptable());
		}
}
 
Example 5
Source File: DynamicParameterRuntimePanel.java    From nextreports-server with Apache License 2.0 5 votes vote down vote up
private void enableItem(ListItem<QueryParameter> item, IModel dynamicModel, AjaxRequestTarget target) {
    Iterator it = item.iterator();
    while (it.hasNext()) {
        Component component = (Component) it.next();
        if (component.isVisible()) {
        	if (!component.getId().startsWith("dynamic")) {
        		component.setEnabled(!(Boolean) dynamicModel.getObject());
        		if (target != null) {
        			target.add(component);
        		}
        	}            	            	            		            	
        }
    }
}
 
Example 6
Source File: SecurityBehavior.java    From wicket-orientdb with Apache License 2.0 4 votes vote down vote up
protected void trigger(Component component, boolean value)
{
	if(Component.ENABLE.equals(action)) component.setEnabled(value);
	else if(Component.RENDER.equals(action)) component.setVisibilityAllowed(value);
}
 
Example 7
Source File: DisableIfPrototypeBehavior.java    From wicket-orientdb with Apache License 2.0 4 votes vote down vote up
@Override
public void onConfigure(Component component) {
	Object object = component.getDefaultModelObject();
	component.setEnabled(!(object instanceof IPrototype));
}
 
Example 8
Source File: UsersITCase.java    From syncope with Apache License 2.0 4 votes vote down vote up
@Test
public void editRelationships() {
    TESTER.clickLink("body:realmsLI:realms");
    TESTER.clickLink("body:content:body:container:content:tabbedPanel:tabs-container:tabs:1:link");

    Component component = findComponentByProp("username", CONTAINER
            + ":searchContainer:resultTable:tablePanel:groupForm:checkgroup:dataTable", "puccini");
    assertNotNull(component);

    TESTER.executeAjaxEvent(component.getPageRelativePath(), Constants.ON_CLICK);
    TESTER.clickLink(TAB_PANEL
            + "outerObjectsRepeater:1:outer:container:content:togglePanelContainer:container:"
            + "actions:actions:actionRepeater:0:action:action");

    TESTER.assertComponent(TAB_PANEL
            + "outerObjectsRepeater:0:outer:form:content:form:view:username:textField",
            TextField.class);

    FormTester formTester = TESTER.newFormTester(TAB_PANEL
            + "outerObjectsRepeater:0:outer:form:content:form");
    assertNotNull(formTester);

    formTester.submit("buttons:next");

    formTester = TESTER.newFormTester(TAB_PANEL + "outerObjectsRepeater:0:outer:form:content:form");
    assertNotNull(formTester);
    formTester.submit("buttons:next");

    formTester = TESTER.newFormTester(TAB_PANEL + "outerObjectsRepeater:0:outer:form:content:form");
    assertNotNull(formTester);
    formTester.submit("buttons:next");

    formTester = TESTER.newFormTester(TAB_PANEL + "outerObjectsRepeater:0:outer:form:content:form");
    assertNotNull(formTester);
    formTester.submit("buttons:next");

    formTester = TESTER.newFormTester(TAB_PANEL + "outerObjectsRepeater:0:outer:form:content:form");
    assertNotNull(formTester);
    formTester.submit("buttons:next");

    formTester = TESTER.newFormTester(TAB_PANEL + "outerObjectsRepeater:0:outer:form:content:form");
    assertNotNull(formTester);
    formTester.submit("buttons:next");

    formTester = TESTER.newFormTester(TAB_PANEL + "outerObjectsRepeater:0:outer:form:content:form");
    assertNotNull(formTester);
    formTester.submit("buttons:next");

    TESTER.executeAjaxEvent(TAB_PANEL
            + "outerObjectsRepeater:0:outer:form:content:form:view:relationships:actions:"
            + "actionRepeater:0:action:action", Constants.ON_CLICK);

    formTester = TESTER.newFormTester(TAB_PANEL + "outerObjectsRepeater:0:outer:form:content:form");
    assertNotNull(formTester);

    formTester.setValue("view:relationships:specification:type:dropDownChoiceField", "1");
    TESTER.executeAjaxEvent(TAB_PANEL
            + "outerObjectsRepeater:0:outer:form:content:form:view:relationships:"
            + "specification:type:dropDownChoiceField", Constants.ON_CHANGE);
    // The ON_CHANGE above should enable this component, but it doesn't; doing it by hand
    Component otherType = findComponentById(
            TAB_PANEL + "outerObjectsRepeater:0:outer:form:content:form:view:relationships:specification",
            "otherType");
    assertNotNull(otherType);
    otherType.setEnabled(true);

    formTester.setValue("view:relationships:specification:otherType:dropDownChoiceField", "PRINTER");
    TESTER.executeAjaxEvent(TAB_PANEL
            + "outerObjectsRepeater:0:outer:form:content:form:view:relationships:"
            + "specification:otherType:dropDownChoiceField", Constants.ON_CHANGE);

    component = findComponentByProp("name", TAB_PANEL + "outerObjectsRepeater:"
            + "0:outer:form:content:form:view:relationships:specification:searchPanelContainer:searchPanel:"
            + "searchResultPanel:container:content:searchContainer:resultTable:tablePanel:groupForm:checkgroup:"
            + "dataTable:body:rows:1:cells:2:cell", "Canon MF 8030cn");
    assertNotNull(component);

    formTester.submit("buttons:cancel");
}