org.apache.wicket.event.IEvent Java Examples

The following examples show how to use org.apache.wicket.event.IEvent. 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: 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 #2
Source File: SAML2IdPsDirectoryPanel.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 #3
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 #4
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 #5
Source File: SideInfoPanel.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 SideInfoOpened) {
		SideInfoOpened moreInfoSideOpened = (SideInfoOpened) event.getPayload();
		String script = String.format(""
				+ "$('#%s').show('slide', {"
				+ "  direction: 'right', "
				+ "  duration: 200, "
				+ "  complete: function() {"
				+ "    if (!onedev.server.util.isDevice()) "
				+ "      $(this).data('ps').update();"
				+ "  }"
				+ "});"
				+ "$(window).resize();", getMarkupId());
		moreInfoSideOpened.getHandler().appendJavaScript(script);
	}
}
 
Example #6
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 #7
Source File: NewIssueEditor.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 BeanUpdating) {
		try {
			Issue issue = getEditingIssue();
			String descriptionTemplate = getDescriptionTemplate(issue);
			if (!Objects.equal(descriptionTemplate, lastDescriptionTemplate)) {
				BeanUpdating beanUpdating = (BeanUpdating)event.getPayload();
				CallbackParameter description = CallbackParameter.explicit("description");
				CallbackParameter template = CallbackParameter.explicit("template");
				String script = String.format("var callback=%s;callback($('.new-issue>.description textarea').val(), '%s');", 
						ajaxBehavior.getCallbackFunction(description, template), 
						JavaScriptEscape.escapeJavaScript(descriptionTemplate!=null?descriptionTemplate:""));
				beanUpdating.getHandler().appendJavaScript(script);
			}
		} catch (ConversionException e) {
		}
	}
	
}
 
Example #8
Source File: JobWidget.java    From syncope with Apache License 2.0 6 votes vote down vote up
@Override
@SuppressWarnings("unchecked")
public void onEvent(final IEvent<?> event) {
    if (event.getPayload() instanceof AjaxWizard.NewItemEvent) {
        Optional<AjaxRequestTarget> target = ((AjaxWizard.NewItemEvent<?>) event.getPayload()).getTarget();

        if (target.isPresent()
                && event.getPayload() instanceof AjaxWizard.NewItemCancelEvent
                || event.getPayload() instanceof AjaxWizard.NewItemFinishEvent) {

            jobModal.close(target.get());
        }
    }

    super.onEvent(event);
}
 
Example #9
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 #10
Source File: SchemaTypePanel.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 SchemaSearchEvent) {
        SchemaSearchEvent payload = SchemaSearchEvent.class.cast(event.getPayload());
        AjaxRequestTarget target = payload.getTarget();

        keyword = payload.getKeyword();
        if (StringUtils.isNotBlank(keyword)) {
            if (!StringUtils.startsWith(keyword, "*")) {
                keyword = "*" + keyword;
            }
            if (!StringUtils.endsWith(keyword, "*")) {
                keyword = keyword + "*";
            }
        }

        updateResultTable(target);
    } else {
        super.onEvent(event);
    }
}
 
Example #11
Source File: LambdaBehavior.java    From webanno with Apache License 2.0 6 votes vote down vote up
public static <T> Behavior onEvent(Class<T> aEventClass,
        SerializableBiConsumer<Component, T> aAction)
{
    return new Behavior()
    {
        private static final long serialVersionUID = -1956074724077271777L;

        @Override
        public void onEvent(Component aComponent, IEvent<?> aEvent)
        {
            if (aEventClass.isAssignableFrom(aEvent.getPayload().getClass())) {
                aAction.accept(aComponent, (T) aEvent.getPayload());
            }
        }
    };
}
 
Example #12
Source File: Self.java    From syncope with Apache License 2.0 6 votes vote down vote up
@Override
@SuppressWarnings("unchecked")
public void onEvent(final IEvent<?> event) {
    if (event.getPayload() instanceof AjaxWizard.NewItemEvent) {
        if (event.getPayload() instanceof AjaxWizard.NewItemCancelEvent) {
            @SuppressWarnings("unchecked")
            final Class<? extends WebPage> beforeLogout = (Class<? extends WebPage>) SyncopeEnduserSession.get().
                    getAttribute(Constants.BEFORE_LOGOUT_PAGE);
            if (beforeLogout == null) {
                SyncopeEnduserSession.get().invalidate();
                setResponsePage(getApplication().getHomePage());
            } else {
                setResponsePage(beforeLogout);
            }
        } else if (event.getPayload() instanceof AjaxWizard.NewItemFinishEvent) {
            SyncopeEnduserSession.get().invalidate();

            final PageParameters parameters = new PageParameters();
            parameters.add(Constants.NOTIFICATION_MSG_PARAM, getString("self.wizard.success"));
            setResponsePage(getApplication().getHomePage(), parameters);
        }
    }
    super.onEvent(event);
}
 
Example #13
Source File: TopologyNodePanel.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 UpdateEvent) {
        final UpdateEvent updateEvent = UpdateEvent.class.cast(event.getPayload());
        final String key = updateEvent.getKey();
        final AjaxRequestTarget target = updateEvent.getTarget();

        if (node.getKind() == Kind.CONNECTOR && key.equalsIgnoreCase(node.getKey())) {
            ConnInstanceTO conn = ConnectorRestClient.read(key);

            String displayName =
                    // [SYNCOPE-1233]
                    StringUtils.isBlank(conn.getDisplayName()) ? conn.getBundleName() : conn.getDisplayName();

            final String resourceName = displayName.length() > 14
                    ? displayName.subSequence(0, 10) + "..."
                    : displayName;

            label.setDefaultModelObject(resourceName);
            target.add(label);
            node.setDisplayName(displayName);
        }
    }
}
 
Example #14
Source File: MergeLinkedAccountsSearchPanel.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 SearchClausePanel.SearchEvent) {
        final AjaxRequestTarget target = SearchClausePanel.SearchEvent.class.cast(event.getPayload()).getTarget();
        final String fiql = "username!~" + this.wizardModel.getBaseUser().getUsername() + ';'
            + SearchUtils.buildFIQL(userSearchPanel.getModel().getObject(),
            SyncopeClient.getUserSearchConditionBuilder());
        userDirectoryPanel.search(fiql, target);
    } else if (event.getPayload() instanceof AnySelectionDirectoryPanel.ItemSelection) {
        AnySelectionDirectoryPanel.ItemSelection payload =
            (AnySelectionDirectoryPanel.ItemSelection) event.getPayload();

        final AnyTO sel = payload.getSelection();
        this.wizardModel.setMergingUser(new UserRestClient().read(sel.getKey()));

        String tableId = ((Component) event.getSource()).
            get("container:content:searchContainer:resultTable:tablePanel:groupForm:checkgroup:dataTable").
            getMarkupId();
        String js = "$('#" + tableId + " tr').removeClass('active');";
        js += "$('#" + tableId + " td[title=" + sel.getKey() + "]').parent().addClass('active');";
        payload.getTarget().prependJavaScript(js);
    }
}
 
Example #15
Source File: MergeLinkedAccountsWizardBuilder.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 AjaxWizard.NewItemCancelEvent) {
        ((AjaxWizard.NewItemCancelEvent<?>) event.getPayload()).getTarget().ifPresent(modal::close);
    }
    if (event.getPayload() instanceof AjaxWizard.NewItemFinishEvent) {
        Optional<AjaxRequestTarget> targetResult =
                ((AjaxWizard.NewItemFinishEvent<?>) event.getPayload()).getTarget();
        try {
            mergeAccounts();
            this.parentPanel.info(this.parentPanel.getString(Constants.OPERATION_SUCCEEDED));
            targetResult.ifPresent(target -> {
                ((BasePage) this.parentPanel.getPage()).getNotificationPanel().refresh(target);
                parentPanel.updateResultTable(target);
                modal.close(target);
            });
        } catch (Exception e) {
            this.parentPanel.error(this.parentPanel.getString(Constants.ERROR) + ": " + e.getMessage());
            targetResult.ifPresent(target -> ((BasePage) pageRef.getPage()).getNotificationPanel().refresh(target));
        }
    }
}
 
Example #16
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 #17
Source File: ReportDirectoryPanel.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) {
        container.modelChanged();
        JobActionPanel.JobActionPayload.class.cast(event.getPayload()).getTarget().add(container);
    } else {
        super.onEvent(event);
    }
}
 
Example #18
Source File: PolicyRuleDirectoryPanel.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 #19
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 #20
Source File: BpmnPanel.java    From Orienteer with Apache License 2.0 5 votes vote down vote up
@Override
public void onEvent(IEvent<?> event) {
	if(event.getPayload() instanceof ActionPerformedEvent && event.getType().equals(Broadcast.BUBBLE)) {
		ActionPerformedEvent<?> apEvent = (ActionPerformedEvent<?>)event.getPayload();
		if(apEvent.getCommand()!=null && apEvent.getCommand().isChangingDisplayMode() && apEvent.isAjax()) {
			apEvent.getTarget().get().add(this);
		}
	}
}
 
Example #21
Source File: UpdateOnDashboardDisplayModeChangeBehavior.java    From Orienteer with Apache License 2.0 5 votes vote down vote up
@Override
protected boolean match(Component component, ActionPerformedEvent<?> event,
		IEvent<?> wicketEvent) {
	if(component instanceof AbstractWidget && event.getCommand().isChangingDisplayMode()) {
		AbstractWidget<?> widget = (AbstractWidget<?>)component;
		return Objects.equal(widget.getDashboardPanel().getDashboardDocument(), event.getObject());
	} else return false;
}
 
Example #22
Source File: TaskDirectoryPanel.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 #23
Source File: ProvisioningTaskDirectoryPanel.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) {
        container.modelChanged();
        JobActionPanel.JobActionPayload.class.cast(event.getPayload()).getTarget().add(container);
    } else {
        super.onEvent(event);
    }
}
 
Example #24
Source File: UpdateOnActionPerformedEventBehavior.java    From Orienteer with Apache License 2.0 5 votes vote down vote up
@Override
public void onEvent(Component component, IEvent<?> wicketEvent) {
	Object payload = wicketEvent.getPayload();
	if(payload instanceof ActionPerformedEvent) {
		ActionPerformedEvent<?> event = (ActionPerformedEvent<?>)payload;
		if(event.isAjax() && match(component, event, wicketEvent)) {
			update(component, event, wicketEvent);
		}
		if(stopEvent) wicketEvent.stop();
	}
}
 
Example #25
Source File: TopologyTogglePanel.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 AjaxWizard.NewItemFinishEvent) {
        final AjaxWizard.NewItemFinishEvent<?> item = AjaxWizard.NewItemFinishEvent.class.cast(event.getPayload());
        final Serializable result = item.getResult();
        final Optional<AjaxRequestTarget> target = item.getTarget();
        if (result != null && result instanceof ConnInstanceTO && target.isPresent()) {
            // update Toggle Panel header
            ConnInstanceTO conn = ConnInstanceTO.class.cast(result);
            setHeader(target.get(), StringUtils.abbreviate(conn.getDisplayName(), HEADER_FIRST_ABBREVIATION));
        }
    }
}
 
Example #26
Source File: DefaultPageHeaderMenu.java    From Orienteer with Apache License 2.0 5 votes vote down vote up
@Override
public void onEvent(IEvent<?> event) {
	if(event.getPayload() instanceof SwitchDashboardTabEvent) {
		((SwitchDashboardTabEvent)event.getPayload()).getTarget().ifPresent(target -> target.add(getParent()));
	}
	else if(event.getPayload() instanceof ActionPerformedEvent) {
		ActionPerformedEvent<?> action = (ActionPerformedEvent<?>) event.getPayload();
		Command<?> command = action.getCommand();
		if(command.isChangingModel() || command.isChangingDisplayMode()) {
			action.getTarget().ifPresent(target -> target.add(getParent()));
		}
	}
}
 
Example #27
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 #28
Source File: AbstractWidget.java    From Orienteer with Apache License 2.0 5 votes vote down vote up
@Override
public void onEvent(IEvent<?> event) {
	Object payload = event.getPayload();
	if(payload instanceof ActionPerformedEvent) {
		onActionPerformed((ActionPerformedEvent<?>)payload, event);
	}
}
 
Example #29
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 #30
Source File: ListViewPanel.java    From syncope with Apache License 2.0 5 votes vote down vote up
@Override
@SuppressWarnings("unchecked")
public void onEvent(final IEvent<?> event) {
    if (event.getPayload() instanceof AjaxWizard.NewItemEvent) {
        final T item = ((AjaxWizard.NewItemEvent<T>) event.getPayload()).getItem();
        final Optional<AjaxRequestTarget> target = ((AjaxWizard.NewItemEvent<T>) event.getPayload()).getTarget();

        if (event.getPayload() instanceof AjaxWizard.NewItemFinishEvent) {
            final T old = getActualItem(item, ListViewPanel.this.listOfItems);
            int indexOf = ListViewPanel.this.listOfItems.size();
            if (old != null) {
                indexOf = ListViewPanel.this.listOfItems.indexOf(old);
                ListViewPanel.this.listOfItems.remove(old);
            }
            ListViewPanel.this.listOfItems.add(indexOf, item);
        }

        target.ifPresent(t -> t.add(ListViewPanel.this));
        super.onEvent(event);
    } else if (event.getPayload() instanceof ListViewPanel.ListViewReload) {
        final ListViewPanel.ListViewReload<?> payload = (ListViewPanel.ListViewReload<?>) event.getPayload();
        if (payload.getItems() != null) {
            ListViewPanel.this.listOfItems.clear();
            try {
                ListViewPanel.this.listOfItems.addAll((List<T>) payload.getItems());
            } catch (RuntimeException re) {
                LOG.warn("Error reloading items", re);
            }
        }
        payload.getTarget().add(ListViewPanel.this);
    } else {
        super.onEvent(event);
    }
}