use of org.apache.wicket.extensions.ajax.markup.html.IndicatingAjaxLink in project the-app by devops-dojo.
the class CartPanel method cartView.
private Component cartView() {
cartView = new ListView<CartItemInfo>("cart", cartListModel()) {
@Override
protected void populateItem(ListItem<CartItemInfo> item) {
WebMarkupContainer cartItem = new WebMarkupContainer("item");
cartItem.add(new Label("name", new PropertyModel<String>(item.getModel(), "product.name")));
cartItem.add(new IndicatingAjaxLink<Void>("delete") {
@Override
public void onClick(AjaxRequestTarget target) {
IModel<CartItemInfo> model = item.getModel();
send(CartPanel.this, Broadcast.BREADTH, new RemoveFromCartEvent(model.getObject(), target));
}
});
cartItem.add(new Label("price", new PriceModel(new PropertyModel<>(item.getModel(), "totalSum"))));
item.add(cartItem);
}
};
cartView.setReuseItems(false);
cartView.setOutputMarkupId(true);
return cartView;
}
use of org.apache.wicket.extensions.ajax.markup.html.IndicatingAjaxLink in project syncope by apache.
the class TopologyTogglePanel method getResourceFragment.
private Fragment getResourceFragment(final TopologyNode node, final PageReference pageRef) {
Fragment fragment = new Fragment("actions", "resourceActions", this);
AjaxLink<String> delete = new IndicatingOnConfirmAjaxLink<String>("delete", true) {
private static final long serialVersionUID = 3776750333491622263L;
@Override
public void onClick(final AjaxRequestTarget target) {
try {
resourceRestClient.delete(node.getKey());
target.appendJavaScript(String.format("jsPlumb.remove('%s');", node.getKey()));
SyncopeConsoleSession.get().info(getString(Constants.OPERATION_SUCCEEDED));
toggle(target, false);
} catch (SyncopeClientException e) {
LOG.error("While deleting resource {}", node.getKey(), e);
SyncopeConsoleSession.get().error(StringUtils.isBlank(e.getMessage()) ? e.getClass().getName() : e.getMessage());
}
((BasePage) pageRef.getPage()).getNotificationPanel().refresh(target);
}
};
MetaDataRoleAuthorizationStrategy.authorize(delete, RENDER, StandardEntitlement.RESOURCE_DELETE);
fragment.add(delete);
AjaxLink<String> edit = new IndicatingAjaxLink<String>("edit") {
private static final long serialVersionUID = 3776750333491622263L;
@Override
public void onClick(final AjaxRequestTarget target) {
ResourceTO resource = resourceRestClient.read(node.getKey());
ConnInstanceTO connInstance = connectorRestClient.read(resource.getConnector());
IModel<ResourceTO> model = new CompoundPropertyModel<>(resource);
modal.setFormModel(model);
target.add(modal.setContent(new ResourceWizardBuilder(resource, pageRef).build(BaseModal.CONTENT_ID, SyncopeConsoleSession.get().owns(StandardEntitlement.RESOURCE_UPDATE, connInstance.getAdminRealm()) ? AjaxWizard.Mode.EDIT : AjaxWizard.Mode.READONLY)));
modal.header(new Model<>(MessageFormat.format(getString("resource.edit"), node.getKey())));
modal.show(true);
}
@Override
public String getAjaxIndicatorMarkupId() {
return Constants.VEIL_INDICATOR_MARKUP_ID;
}
};
MetaDataRoleAuthorizationStrategy.authorize(edit, RENDER, StandardEntitlement.RESOURCE_READ);
fragment.add(edit);
AjaxLink<String> status = new IndicatingAjaxLink<String>("status") {
private static final long serialVersionUID = 3776750333491622263L;
@Override
public void onClick(final AjaxRequestTarget target) {
ResourceTO modelObject = resourceRestClient.read(node.getKey());
target.add(propTaskModal.setContent(new ResourceStatusModal(propTaskModal, pageRef, modelObject)));
propTaskModal.header(new Model<>(MessageFormat.format(getString("resource.provisioning.status"), node.getKey())));
propTaskModal.show(true);
}
@Override
public String getAjaxIndicatorMarkupId() {
return Constants.VEIL_INDICATOR_MARKUP_ID;
}
};
MetaDataRoleAuthorizationStrategy.authorize(status, RENDER, StandardEntitlement.USER_UPDATE);
fragment.add(status);
AjaxLink<String> provision = new IndicatingAjaxLink<String>("provision") {
private static final long serialVersionUID = 3776750333491622263L;
@Override
public void onClick(final AjaxRequestTarget target) {
ResourceTO resource = resourceRestClient.read(node.getKey());
ConnInstanceTO connInstance = connectorRestClient.read(resource.getConnector());
if (SyncopeConsoleSession.get().owns(StandardEntitlement.RESOURCE_UPDATE, connInstance.getAdminRealm())) {
provisionModal.addSubmitButton();
} else {
provisionModal.removeSubmitButton();
}
IModel<ResourceTO> model = new CompoundPropertyModel<>(resource);
provisionModal.setFormModel(model);
target.add(provisionModal.setContent(new ResourceProvisionPanel(provisionModal, resource, connInstance.getAdminRealm(), pageRef)));
provisionModal.header(new Model<>(MessageFormat.format(getString("resource.edit"), node.getKey())));
provisionModal.show(true);
}
@Override
public String getAjaxIndicatorMarkupId() {
return Constants.VEIL_INDICATOR_MARKUP_ID;
}
};
MetaDataRoleAuthorizationStrategy.authorize(edit, RENDER, StandardEntitlement.RESOURCE_READ);
fragment.add(provision);
AjaxLink<String> explore = new IndicatingAjaxLink<String>("explore") {
private static final long serialVersionUID = 3776750333491622263L;
@Override
public void onClick(final AjaxRequestTarget target) {
ResourceTO resource = resourceRestClient.read(node.getKey());
target.add(propTaskModal.setContent(new ConnObjects(resource, pageRef)));
propTaskModal.header(new StringResourceModel("resource.explore.list", Model.of(node)));
propTaskModal.show(true);
}
@Override
public String getAjaxIndicatorMarkupId() {
return Constants.VEIL_INDICATOR_MARKUP_ID;
}
};
MetaDataRoleAuthorizationStrategy.authorize(explore, RENDER, StandardEntitlement.RESOURCE_LIST_CONNOBJECT);
fragment.add(explore);
AjaxLink<String> propagation = new IndicatingAjaxLink<String>("propagation") {
private static final long serialVersionUID = 3776750333491622263L;
@Override
@SuppressWarnings("unchecked")
public void onClick(final AjaxRequestTarget target) {
target.add(propTaskModal.setContent(new PropagationTasks(propTaskModal, node.getKey(), pageRef)));
propTaskModal.header(new Model<>(MessageFormat.format(getString("task.propagation.list"), node.getKey())));
propTaskModal.show(true);
}
@Override
public String getAjaxIndicatorMarkupId() {
return Constants.VEIL_INDICATOR_MARKUP_ID;
}
};
MetaDataRoleAuthorizationStrategy.authorize(propagation, RENDER, StandardEntitlement.TASK_LIST);
fragment.add(propagation);
AjaxLink<String> pull = new IndicatingAjaxLink<String>("pull") {
private static final long serialVersionUID = 3776750333491622263L;
@Override
public void onClick(final AjaxRequestTarget target) {
target.add(schedTaskModal.setContent(new PullTasks(schedTaskModal, pageRef, node.getKey())));
schedTaskModal.header(new Model<>(MessageFormat.format(getString("task.pull.list"), node.getKey())));
schedTaskModal.show(true);
}
@Override
public String getAjaxIndicatorMarkupId() {
return Constants.VEIL_INDICATOR_MARKUP_ID;
}
};
MetaDataRoleAuthorizationStrategy.authorize(pull, RENDER, StandardEntitlement.TASK_LIST);
fragment.add(pull);
AjaxLink<String> push = new IndicatingAjaxLink<String>("push") {
private static final long serialVersionUID = 3776750333491622263L;
@Override
public void onClick(final AjaxRequestTarget target) {
target.add(schedTaskModal.setContent(new PushTasks(schedTaskModal, pageRef, node.getKey())));
schedTaskModal.header(new Model<>(MessageFormat.format(getString("task.push.list"), node.getKey())));
schedTaskModal.show(true);
}
@Override
public String getAjaxIndicatorMarkupId() {
return Constants.VEIL_INDICATOR_MARKUP_ID;
}
};
MetaDataRoleAuthorizationStrategy.authorize(push, RENDER, StandardEntitlement.TASK_LIST);
fragment.add(push);
AjaxLink<String> history = new IndicatingAjaxLink<String>("history") {
private static final long serialVersionUID = -1876519166660008562L;
@Override
public void onClick(final AjaxRequestTarget target) {
String resourceKey = String.class.cast(node.getKey());
final ResourceTO modelObject = resourceRestClient.read(String.class.cast(node.getKey()));
target.add(historyModal.setContent(new HistoryConfList<>(historyModal, resourceKey, pageRef, modelObject)));
historyModal.header(new Model<>(MessageFormat.format(getString("resource.menu.history"), node.getDisplayName())));
historyModal.show(true);
}
@Override
public String getAjaxIndicatorMarkupId() {
return Constants.VEIL_INDICATOR_MARKUP_ID;
}
};
MetaDataRoleAuthorizationStrategy.authorize(history, RENDER, StandardEntitlement.RESOURCE_HISTORY_LIST);
fragment.add(history);
// [SYNCOPE-1161] - Option to clone a resource
AjaxLink<String> clone = new IndicatingOnConfirmAjaxLink<String>("clone", "confirmClone", true) {
private static final long serialVersionUID = -7978723352517770644L;
@Override
public void onClick(final AjaxRequestTarget target) {
try {
ResourceTO resource = resourceRestClient.read(node.getKey());
resource.setKey("Copy of " + resource.getKey());
// reset some resource objects keys
if (resource.getOrgUnit() != null) {
resource.getOrgUnit().setKey(null);
for (ItemTO item : resource.getOrgUnit().getItems()) {
item.setKey(null);
}
}
for (ProvisionTO provision : resource.getProvisions()) {
provision.setKey(null);
if (provision.getMapping() != null) {
for (ItemTO item : provision.getMapping().getItems()) {
item.setKey(null);
}
provision.getMapping().getLinkingItems().clear();
}
provision.getVirSchemas().clear();
}
resourceRestClient.create(resource);
// refresh Topology
send(pageRef.getPage(), Broadcast.DEPTH, new AbstractResourceWizardBuilder.CreateEvent(resource.getKey(), resource.getKey(), TopologyNode.Kind.RESOURCE, resource.getConnector(), target));
SyncopeConsoleSession.get().info(getString(Constants.OPERATION_SUCCEEDED));
toggle(target, false);
} catch (SyncopeClientException e) {
LOG.error("While cloning resource {}", node.getKey(), e);
SyncopeConsoleSession.get().error(StringUtils.isBlank(e.getMessage()) ? e.getClass().getName() : e.getMessage());
}
((BasePage) pageRef.getPage()).getNotificationPanel().refresh(target);
}
};
MetaDataRoleAuthorizationStrategy.authorize(clone, RENDER, StandardEntitlement.RESOURCE_CREATE);
fragment.add(clone);
return fragment;
}
use of org.apache.wicket.extensions.ajax.markup.html.IndicatingAjaxLink in project syncope by apache.
the class TopologyTogglePanel method getConnectorFragment.
private Fragment getConnectorFragment(final TopologyNode node, final PageReference pageRef) {
Fragment fragment = new Fragment("actions", "connectorActions", this);
AjaxLink<String> delete = new IndicatingOnConfirmAjaxLink<String>("delete", true) {
private static final long serialVersionUID = 3776750333491622263L;
@Override
public void onClick(final AjaxRequestTarget target) {
try {
connectorRestClient.delete(String.class.cast(node.getKey()));
target.appendJavaScript(String.format("jsPlumb.remove('%s');", node.getKey()));
SyncopeConsoleSession.get().info(getString(Constants.OPERATION_SUCCEEDED));
toggle(target, false);
} catch (SyncopeClientException e) {
LOG.error("While deleting resource {}", node.getKey(), e);
SyncopeConsoleSession.get().error(StringUtils.isBlank(e.getMessage()) ? e.getClass().getName() : e.getMessage());
}
((BasePage) pageRef.getPage()).getNotificationPanel().refresh(target);
}
};
MetaDataRoleAuthorizationStrategy.authorize(delete, RENDER, StandardEntitlement.CONNECTOR_DELETE);
fragment.add(delete);
AjaxLink<String> create = new IndicatingAjaxLink<String>("create") {
private static final long serialVersionUID = 3776750333491622263L;
@Override
public void onClick(final AjaxRequestTarget target) {
final ResourceTO modelObject = new ResourceTO();
modelObject.setConnector(String.class.cast(node.getKey()));
modelObject.setConnectorDisplayName(node.getDisplayName());
final IModel<ResourceTO> model = new CompoundPropertyModel<>(modelObject);
modal.setFormModel(model);
target.add(modal.setContent(new ResourceWizardBuilder(modelObject, pageRef).build(BaseModal.CONTENT_ID, AjaxWizard.Mode.CREATE)));
modal.header(new Model<>(MessageFormat.format(getString("resource.new"), node.getKey())));
modal.show(true);
}
@Override
public String getAjaxIndicatorMarkupId() {
return Constants.VEIL_INDICATOR_MARKUP_ID;
}
};
MetaDataRoleAuthorizationStrategy.authorize(create, RENDER, StandardEntitlement.RESOURCE_CREATE);
fragment.add(create);
AjaxLink<String> edit = new IndicatingAjaxLink<String>("edit") {
private static final long serialVersionUID = 3776750333491622263L;
@Override
public void onClick(final AjaxRequestTarget target) {
ConnInstanceTO connInstance = connectorRestClient.read(String.class.cast(node.getKey()));
final IModel<ConnInstanceTO> model = new CompoundPropertyModel<>(connInstance);
modal.setFormModel(model);
target.add(modal.setContent(new ConnectorWizardBuilder(connInstance, pageRef).build(BaseModal.CONTENT_ID, SyncopeConsoleSession.get().owns(StandardEntitlement.CONNECTOR_UPDATE, connInstance.getAdminRealm()) ? AjaxWizard.Mode.EDIT : AjaxWizard.Mode.READONLY)));
modal.header(new Model<>(MessageFormat.format(getString("connector.edit"), connInstance.getDisplayName())));
modal.show(true);
}
@Override
public String getAjaxIndicatorMarkupId() {
return Constants.VEIL_INDICATOR_MARKUP_ID;
}
};
MetaDataRoleAuthorizationStrategy.authorize(edit, RENDER, StandardEntitlement.CONNECTOR_READ);
fragment.add(edit);
AjaxLink<String> history = new IndicatingAjaxLink<String>("history") {
private static final long serialVersionUID = -1876519166660008562L;
@Override
public void onClick(final AjaxRequestTarget target) {
String connKey = String.class.cast(node.getKey());
ConnInstanceTO connInstance = connectorRestClient.read(connKey);
target.add(historyModal.setContent(new HistoryConfList<>(historyModal, connKey, pageRef, connInstance)));
historyModal.header(new Model<>(MessageFormat.format(getString("connector.menu.history"), node.getDisplayName())));
historyModal.show(true);
}
@Override
public String getAjaxIndicatorMarkupId() {
return Constants.VEIL_INDICATOR_MARKUP_ID;
}
};
MetaDataRoleAuthorizationStrategy.authorize(history, RENDER, StandardEntitlement.CONNECTOR_HISTORY_LIST);
fragment.add(history);
return fragment;
}
use of org.apache.wicket.extensions.ajax.markup.html.IndicatingAjaxLink in project syncope by apache.
the class TopologyTogglePanel method getLocationFragment.
private Fragment getLocationFragment(final TopologyNode node, final PageReference pageRef) {
Fragment fragment = new Fragment("actions", "locationActions", this);
AjaxLink<String> create = new IndicatingAjaxLink<String>("create") {
private static final long serialVersionUID = 3776750333491622263L;
@Override
public void onClick(final AjaxRequestTarget target) {
final ConnInstanceTO modelObject = new ConnInstanceTO();
modelObject.setLocation(node.getKey());
final IModel<ConnInstanceTO> model = new CompoundPropertyModel<>(modelObject);
modal.setFormModel(model);
target.add(modal.setContent(new ConnectorWizardBuilder(modelObject, pageRef).build(BaseModal.CONTENT_ID, AjaxWizard.Mode.CREATE)));
modal.header(new Model<>(MessageFormat.format(getString("connector.new"), node.getKey())));
modal.show(true);
}
@Override
public String getAjaxIndicatorMarkupId() {
return Constants.VEIL_INDICATOR_MARKUP_ID;
}
};
fragment.add(create);
MetaDataRoleAuthorizationStrategy.authorize(create, RENDER, StandardEntitlement.CONNECTOR_CREATE);
return fragment;
}
use of org.apache.wicket.extensions.ajax.markup.html.IndicatingAjaxLink in project ocvn by devgateway.
the class FileInputBootstrapFormComponentWrapper method addPendingFilesComponent.
/**
* pending files section
*/
private void addPendingFilesComponent() {
pendingFiles = new WebMarkupContainer("pendingFiles") {
private static final long serialVersionUID = 1L;
@Override
protected void onConfigure() {
if (filesModel != null && filesModel.size() > 0) {
for (FileMetadata file : filesModel) {
if (file.isNew()) {
setVisibilityAllowed(true);
return;
}
}
}
setVisibilityAllowed(false);
}
};
pendingFiles.setOutputMarkupPlaceholderTag(true);
pendingFiles.setOutputMarkupId(true);
add(pendingFiles);
pendingFiles.add(new Label("pendingFilesTitle", new StringResourceModel("pendingFilesTitle", this, null)));
AbstractReadOnlyModel<List<FileMetadata>> pendingFilesModel = new AbstractReadOnlyModel<List<FileMetadata>>() {
private static final long serialVersionUID = 1L;
@Override
public List<FileMetadata> getObject() {
List<FileMetadata> fileObject = new ArrayList<>();
// upload)
for (FileMetadata file : filesModel) {
if (file.isNew()) {
fileObject.add(file);
}
}
return fileObject;
}
};
ListView<FileMetadata> list = new ListView<FileMetadata>("list", pendingFilesModel) {
private static final long serialVersionUID = 1L;
@Override
protected void populateItem(final ListItem<FileMetadata> item) {
item.add(new Label("fileTitle", item.getModelObject().getName()));
IndicatingAjaxLink<Void> delete = new IndicatingAjaxLink<Void>("delete") {
private static final long serialVersionUID = 1L;
@SuppressWarnings("unchecked")
@Override
public void onClick(final AjaxRequestTarget target) {
filesModel.remove(item.getModelObject());
FileInputBootstrapFormComponentWrapper.this.getModel().setObject((T) filesModel);
target.add(pendingFiles);
}
};
delete.add(new IconBehavior(GlyphIconType.remove));
delete.add(new TooltipBehavior(new StringResourceModel("removeUploadedFileTooltip", FileInputBootstrapFormComponentWrapper.this, null), TOOLTIP_CONFIG));
delete.setVisible(true);
item.add(delete);
}
};
pendingFiles.add(list);
}
Aggregations