Java Code Examples for org.apache.wicket.event.IEvent#getPayload()

The following examples show how to use org.apache.wicket.event.IEvent#getPayload() . 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: OIDCProvidersDirectoryPanel.java    From syncope with Apache License 2.0 6 votes vote down vote up
@Override
public void onEvent(final IEvent<?> event) {
    super.onEvent(event);

    if (event.getPayload() instanceof AjaxWizard.NewItemEvent) {
        AjaxWizard.NewItemEvent<?> newItemEvent = AjaxWizard.NewItemEvent.class.cast(event.getPayload());
        WizardModalPanel<?> modalPanel = newItemEvent.getModalPanel();

        if (newItemEvent instanceof AjaxWizard.NewItemActionEvent && modalPanel != null) {
            final IModel<Serializable> model = new CompoundPropertyModel<>(modalPanel.getItem());
            templateModal.setFormModel(model);
            templateModal.header(newItemEvent.getResourceModel());
            newItemEvent.getTarget().ifPresent(target -> target.add(templateModal.setContent(modalPanel)));
            templateModal.show(true);
        } else if (newItemEvent instanceof AjaxWizard.NewItemCancelEvent) {
            newItemEvent.getTarget().ifPresent(target -> templateModal.close(target));
        } else if (newItemEvent instanceof AjaxWizard.NewItemFinishEvent) {
            newItemEvent.getTarget().ifPresent(target -> templateModal.close(target));
        }
    }
}
 
Example 2
Source File: AbstractSelect2Choice.java    From onedev with MIT License 6 votes vote down vote up
@Override
public void onEvent(IEvent<?> event) {
	super.onEvent(event);

	if (event.getPayload() instanceof AjaxRequestTarget) {

		AjaxRequestTarget target = (AjaxRequestTarget) event.getPayload();

		if (target.getComponents().contains(this)) {

			// if this component is being repainted by ajax, directly, we
			// must destroy Select2 so it removes
			// its elements from DOM

			target.prependJavaScript(JQuery.execute("$('#%s').select2('destroy');", getJquerySafeMarkupId()));
		}
	}
}
 
Example 3
Source File: Topology.java    From syncope with Apache License 2.0 6 votes vote down vote up
@Override
@SuppressWarnings("unchecked")
public void onEvent(final IEvent<?> event) {
    super.onEvent(event);

    if (event.getPayload() instanceof CreateEvent) {
        final CreateEvent resourceCreateEvent = CreateEvent.class.cast(event.getPayload());

        final TopologyNode node = new TopologyNode(
                resourceCreateEvent.getKey(),
                resourceCreateEvent.getDisplayName(),
                resourceCreateEvent.getKind());

        newlyCreated.getModelObject().add(node);
        resourceCreateEvent.getTarget().add(newlyCreatedContainer);

        resourceCreateEvent.getTarget().appendJavaScript(String.format(
                "window.Wicket.WebSocket.send('"
                + "{\"kind\":\"%s\",\"target\":\"%s\",\"source\":\"%s\",\"scope\":\"%s\"}"
                + "');",
                SupportedOperation.ADD_ENDPOINT,
                resourceCreateEvent.getKey(),
                resourceCreateEvent.getParent(),
                resourceCreateEvent.getKind()));
    }
}
 
Example 4
Source File: DirectoryPanel.java    From syncope with Apache License 2.0 6 votes vote down vote up
@Override
public void onEvent(final IEvent<?> event) {
    if (event.getPayload() instanceof EventDataWrapper) {
        final EventDataWrapper data = (EventDataWrapper) event.getPayload();

        if (data.getRows() < 1) {
            updateResultTable(data.isCreate());
        } else {
            updateResultTable(data.isCreate(), data.getRows());
        }

        if (DirectoryPanel.this.container.isVisibleInHierarchy()) {
            data.getTarget().add(DirectoryPanel.this.container);
        }
    }
    super.onEvent(event);
}
 
Example 5
Source File: LearningCurveChartPanel.java    From inception with Apache License 2.0 6 votes vote down vote up
@Override
public void onEvent(IEvent<?> event)
{
    super.onEvent(event);
    if (event.getPayload() instanceof DropDownEvent) {
        DropDownEvent dEvent = (DropDownEvent) event.getPayload();
        
        RecommenderEvaluationScoreMetricEnum aSelectedMetric = dEvent.getSelectedValue();
        AjaxRequestTarget target = dEvent.getTarget();
        
        target.add(this);

        selectedMetric = aSelectedMetric;
        LOG.debug("Option selected: " + aSelectedMetric);
        
        event.stop();
    }
}
 
Example 6
Source File: LoginInfoPanel.java    From AppStash with Apache License 2.0 5 votes vote down vote up
@Override
public void onEvent(IEvent<?> event) {
    super.onEvent(event);
    if (event.getPayload() instanceof LoginEvent) {
        setVisible(true);
        ((LoginEvent) event.getPayload()).getTarget().add(this);
    }
}
 
Example 7
Source File: ReportletDirectoryPanel.java    From syncope with Apache License 2.0 5 votes vote down vote up
@Override
public void onEvent(final IEvent<?> event) {
    super.onEvent(event);
    if (event.getPayload() instanceof ExitEvent && modal != null) {
        final AjaxRequestTarget target = ExitEvent.class.cast(event.getPayload()).getTarget();
        baseModal.show(false);
        baseModal.close(target);
    }
}
 
Example 8
Source File: PrivilegeDirectoryPanel.java    From syncope with Apache License 2.0 5 votes vote down vote up
@Override
public void onEvent(final IEvent<?> event) {
    super.onEvent(event);
    if (event.getPayload() instanceof ExitEvent && modal != null) {
        final AjaxRequestTarget target = ExitEvent.class.cast(event.getPayload()).getTarget();
        baseModal.show(false);
        baseModal.close(target);
    }
}
 
Example 9
Source File: BeanPropertyEditor.java    From onedev with MIT License 5 votes vote down vote up
@Override
public void onEvent(IEvent<?> event) {
	super.onEvent(event);
	
	if (event.getPayload() instanceof BeanUpdating) {
		event.stop();
		onPropertyUpdating(((BeanUpdating)event.getPayload()).getHandler());
	}		
}
 
Example 10
Source File: PivotPanel.java    From nextreports-server with Apache License 2.0 5 votes vote down vote up
@Override
 public void onEvent(IEvent<?> event) {
       if (event.getPayload() instanceof AreaChangedEvent) {
       	AjaxRequestTarget target = ((AreaChangedEvent) event.getPayload()).getAjaxRequestTarget();
      	 	target.add(areasContainer);
      	 	target.add(computeLink);
       }
}
 
Example 11
Source File: BlobEditPanel.java    From onedev with MIT License 5 votes vote down vote up
@Override
public void onEvent(IEvent<?> event) {
	super.onEvent(event);
	if (event.getPayload() instanceof BlobNameChanging) {
		/*
		 * Blob name is changing and current editor might be inappropriate for current  
		 * blob name, so we need to re-create the editor if the form does not have 
		 * any change yet
		 */
		BlobNameChanging payload = (BlobNameChanging) event.getPayload();
		String script = String.format("onedev.server.blobEdit.onNameChanging('%s', %s, %s);", 
				getMarkupId(), context.getMode() == Mode.ADD, recreateBehavior.getCallbackFunction());
		payload.getHandler().appendJavaScript(script);
	}
}
 
Example 12
Source File: JobWidget.java    From syncope with Apache License 2.0 5 votes vote down vote up
@Override
public void onEvent(final IEvent<?> event) {
    if (event.getPayload() instanceof JobActionPanel.JobActionPayload) {
        available.clear();
        available.addAll(getUpdatedAvailable());
        availableJobsPanel.modelChanged();
        JobActionPanel.JobActionPayload.class.cast(event.getPayload()).getTarget().add(availableJobsPanel);
    }
}
 
Example 13
Source File: JobPrivilegeListEditPanel.java    From onedev with MIT License 5 votes vote down vote up
@Override
public void onEvent(IEvent<?> event) {
	super.onEvent(event);
	
	if (event.getPayload() instanceof PropertyUpdating) {
		event.stop();
		onPropertyUpdating(((PropertyUpdating)event.getPayload()).getHandler());
	}		
}
 
Example 14
Source File: Realms.java    From syncope with Apache License 2.0 5 votes vote down vote up
@Override
public void onEvent(final IEvent<?> event) {
    super.onEvent(event);

    if (event.getPayload() instanceof ChosenRealm) {
        @SuppressWarnings("unchecked")
        ChosenRealm<RealmTO> choosenRealm = ChosenRealm.class.cast(event.getPayload());
        updateRealmContent(choosenRealm.getObj(), 0);
        choosenRealm.getTarget().add(content);
    } else if (event.getPayload() instanceof AjaxWizard.NewItemEvent) {
        AjaxWizard.NewItemEvent<?> newItemEvent = AjaxWizard.NewItemEvent.class.cast(event.getPayload());
        WizardModalPanel<?> modalPanel = newItemEvent.getModalPanel();

        if (event.getPayload() instanceof AjaxWizard.NewItemActionEvent && modalPanel != null) {
            final IModel<Serializable> model = new CompoundPropertyModel<>(modalPanel.getItem());
            templateModal.setFormModel(model);
            templateModal.header(newItemEvent.getResourceModel());
            newItemEvent.getTarget().ifPresent(t -> t.add(templateModal.setContent(modalPanel)));
            templateModal.show(true);
        } else if (event.getPayload() instanceof AjaxWizard.NewItemCancelEvent) {
            if (newItemEvent.getTarget().isPresent()) {
                templateModal.close(newItemEvent.getTarget().get());
            }
        } else if (event.getPayload() instanceof AjaxWizard.NewItemFinishEvent) {
            SyncopeConsoleSession.get().success(getString(Constants.OPERATION_SUCCEEDED));
            if (newItemEvent.getTarget().isPresent()) {
                ((BasePage) getPage()).getNotificationPanel().refresh(newItemEvent.getTarget().get());
                templateModal.close(newItemEvent.getTarget().get());
            }
        }
    }
}
 
Example 15
Source File: NavigationPanel.java    From the-app with Apache License 2.0 5 votes vote down vote up
@Override
public void onEvent(IEvent<?> event) {
    if (event.getPayload() instanceof AddToCartEvent
            || event.getPayload() instanceof RemoveFromCartEvent
            || event.getPayload() instanceof LoginEvent) {
        ((AjaxEvent) event.getPayload()).getTarget().add(this);
    }
}
 
Example 16
Source File: JobServiceListEditPanel.java    From onedev with MIT License 5 votes vote down vote up
@Override
public void onEvent(IEvent<?> event) {
	super.onEvent(event);
	
	if (event.getPayload() instanceof PropertyUpdating) {
		event.stop();
		onPropertyUpdating(((PropertyUpdating)event.getPayload()).getHandler());
	}		
}
 
Example 17
Source File: ParamSpecListEditPanel.java    From onedev with MIT License 5 votes vote down vote up
@Override
public void onEvent(IEvent<?> event) {
	super.onEvent(event);
	
	if (event.getPayload() instanceof PropertyUpdating) {
		event.stop();
		onPropertyUpdating(((PropertyUpdating)event.getPayload()).getHandler());
	}		
}
 
Example 18
Source File: OrienteerFeedbackPanel.java    From Orienteer with Apache License 2.0 5 votes vote down vote up
@Override
public void onEvent(IEvent<?> event) {
	super.onEvent(event);
	if(event.getPayload() instanceof AjaxRequestHandler)
	{
		AjaxRequestHandler handler = (AjaxRequestHandler)event.getPayload();
		handler.add(this);
		if(anyMessage()) handler.focusComponent(this);
	}
}
 
Example 19
Source File: BeanListPropertyEditor.java    From onedev with MIT License 5 votes vote down vote up
@Override
public void onEvent(IEvent<?> event) {
	super.onEvent(event);
	
	if (event.getPayload() instanceof PropertyUpdating) {
		event.stop();
		onPropertyUpdating(((PropertyUpdating)event.getPayload()).getHandler());
	}		
}
 
Example 20
Source File: AnyPanel.java    From syncope with Apache License 2.0 4 votes vote down vote up
@Override
public void onEvent(final IEvent<?> event) {
    if (event.getPayload() instanceof SearchClausePanel.SearchEvent) {
        AjaxRequestTarget target = SearchClausePanel.SearchEvent.class.cast(event.getPayload()).getTarget();

        String precond = realmTO.getFullPath().startsWith(SyncopeConstants.ROOT_REALM)
                ? StringUtils.EMPTY
                : String.format("$dynRealms=~%s;", realmTO.getKey());

        switch (anyTypeTO.getKind()) {
            case USER:
                UserDirectoryPanel.class.cast(AnyPanel.this.directoryPanel).search(
                        precond + SearchUtils.buildFIQL(
                                AnyPanel.this.searchPanel.getModel().getObject(),
                                SyncopeClient.getUserSearchConditionBuilder(),
                                AnyPanel.this.searchPanel.getAvailableSchemaTypes(),
                                SearchUtils.NO_CUSTOM_CONDITION),
                        target);
                break;

            case GROUP:
                GroupDirectoryPanel.class.cast(AnyPanel.this.directoryPanel).search(
                        precond + SearchUtils.buildFIQL(
                                AnyPanel.this.searchPanel.getModel().getObject(),
                                SyncopeClient.getGroupSearchConditionBuilder(),
                                AnyPanel.this.searchPanel.getAvailableSchemaTypes(),
                                SearchUtils.NO_CUSTOM_CONDITION),
                        target);
                break;

            case ANY_OBJECT:
                AnyObjectDirectoryPanel.class.cast(AnyPanel.this.directoryPanel).search(
                        precond + SearchUtils.buildFIQL(
                                AnyPanel.this.searchPanel.getModel().getObject(),
                                SyncopeClient.getAnyObjectSearchConditionBuilder(anyTypeTO.getKey()),
                                AnyPanel.this.searchPanel.getAvailableSchemaTypes(),
                                SearchUtils.NO_CUSTOM_CONDITION),
                        target);
                break;

            default:
        }
    } else {
        super.onEvent(event);
    }
}