示例#1
0
  private void initLayout(
      IModel<String> label, Form form, String valueCssClass, String inputCssClass) {
    // container
    WebMarkupContainer valueContainer = new WebMarkupContainer(ID_VALUE_CONTAINER);
    valueContainer.setOutputMarkupId(true);
    valueContainer.add(new AttributeModifier("class", valueCssClass));
    add(valueContainer);

    // feedback
    FeedbackPanel feedback = new FeedbackPanel(ID_FEEDBACK);
    feedback.setOutputMarkupId(true);
    add(feedback);

    // input
    Panel input = createInputComponent(ID_INPUT, label, form);
    input.add(new AttributeModifier("class", inputCssClass));
    if (input instanceof InputPanel) {
      initAccessBehaviour((InputPanel) input);
      feedback.setFilter(
          new ComponentFeedbackMessageFilter(((InputPanel) input).getBaseFormComponent()));
    }
    valueContainer.add(input);

    // buttons
    AjaxLink addButton =
        new AjaxLink("addButton") {

          @Override
          public void onClick(AjaxRequestTarget target) {
            addValue(target);
          }
        };
    addButton.add(
        new VisibleEnableBehaviour() {

          @Override
          public boolean isVisible() {
            return isAddButtonVisible();
          }
        });
    valueContainer.add(addButton);

    AjaxLink removeButton =
        new AjaxLink("removeButton") {

          @Override
          public void onClick(AjaxRequestTarget target) {
            removeValue(target);
          }
        };
    removeButton.add(
        new VisibleEnableBehaviour() {

          @Override
          public boolean isVisible() {
            return isRemoveButtonVisible();
          }
        });
    valueContainer.add(removeButton);
  }
示例#2
0
  public ConsentWizardForm(String id, IModel interviewConsentModel) {
    super(id, interviewConsentModel);

    consentConfirmationStep = new ManualConsentStep(getStepId());
    electronicConsentStep = new ElectronicConsentStep(getStepId(), consentConfirmationStep);
    consentModeSelectionStep =
        new ConsentModeSelectionStep(getStepId(), electronicConsentStep, consentConfirmationStep);

    WizardStepPanel startStep = setupWizardFlow();

    startStep.onStepInNext(this, null);
    startStep.handleWizardState(this, null);
    add(startStep);

    createModalAdministrationPanel();

    // admin button
    AjaxLink link =
        new AjaxLink("adminLink") {
          private static final long serialVersionUID = 0L;

          @Override
          public void onClick(AjaxRequestTarget target) {
            adminWindow.setInitialWidth(350);
            adminWindow.setInterruptState(false);
            if (getCancelLink() != null) adminWindow.setCancelState(getCancelLink().isEnabled());
            adminWindow.show(target);
          }
        };
    link.add(
        new AttributeModifier(
            "value", true, new StringResourceModel("Administration", this, null)));
    link.add(new AttributeAppender("class", new Model("ui-corner-all"), " "));
    add(link);
  }
示例#3
0
 public ButtonFragment(String id, IModel<Button> model) {
   super(id, "buttonFragment", SortableList.this, model);
   final Button button = model.getObject();
   AjaxLink<Void> ajaxLink =
       new AjaxLink<Void>("button") {
         @Override
         public void onClick(AjaxRequestTarget target) {
           button.callback(target);
         }
       };
   Image image = new Image("buttonImg", button.getImage());
   image.setVisible(button.getImage() != null);
   ajaxLink.add(image);
   ajaxLink.add(new Label("buttonLabel", button.getTitle()));
   add(ajaxLink);
 }
  /**
   * Either creates a link for the action be rendered in a {@link ModalWindow}, or (if none can be
   * {@link ActionPromptProvider#getActionPrompt() provided}, or creates a link to the {@link
   * ActionPromptPage} (ie the {@link PageClassRegistry registered page} for {@link
   * PageType#ACTION_PROMPT action}s).
   *
   * <p>If the action's {@link ObjectAction#getSemantics() semantics} are {@link
   * ActionSemantics.Of#SAFE safe}, then concurrency checking is disabled; otherwise it is enforced.
   */
  protected AbstractLink newLink(
      final String linkId,
      final ObjectAdapter objectAdapter,
      final ObjectAction action,
      final ActionPromptProvider actionPromptProvider) {

    final ActionPrompt actionPrompt = actionPromptProvider.getActionPrompt();
    if (actionPrompt != null) {
      final ActionModel actionModel = ActionModel.create(objectAdapter, action);
      actionModel.setActionPrompt(actionPrompt);
      AjaxLink<Object> link =
          new AjaxLink<Object>(linkId) {
            private static final long serialVersionUID = 1L;

            @Override
            public void onClick(AjaxRequestTarget target) {

              final ActionPanel actionPromptPanel =
                  (ActionPanel)
                      getComponentFactoryRegistry()
                          .createComponent(
                              ComponentType.ACTION_PROMPT,
                              actionPrompt.getContentId(),
                              actionModel);

              actionPrompt.setPanel(actionPromptPanel, target);
              actionPrompt.show(target);

              target.focusComponent(actionPromptPanel);
            }
          };
      link.add(new CssClassAppender("noVeil"));
      return link;

    } else {

      // use the action semantics to determine whether invoking this action will require a
      // concurrency check or not
      // if it's "safe", then we'll just continue without any checking.
      final ConcurrencyChecking concurrencyChecking =
          ConcurrencyChecking.concurrencyCheckingFor(action.getSemantics());
      final PageParameters pageParameters =
          ActionModel.createPageParameters(objectAdapter, action, concurrencyChecking);
      final Class<? extends Page> pageClass =
          getPageClassRegistry().getPageClass(PageType.ACTION_PROMPT);
      AbstractLink link = Links.newBookmarkablePageLink(linkId, pageParameters, pageClass);

      // special case handling if this a no-arg action is returning a URL
      if (action.getParameterCount() == 0) {
        addTargetBlankIfActionReturnsUrl(link, action);
      }

      return link;
    }
  }
示例#5
0
  public InstrumentWizardForm(String id, IModel<InstrumentType> instrumentTypeModel) {
    super(id, instrumentTypeModel);

    // Add Interrupt button.
    add(createInterrupt());

    InstrumentType type = (InstrumentType) instrumentTypeModel.getObject();
    log.debug("instrumentType={}", type.getName());

    observedContraIndicationStep = new ObservedContraIndicationStep(getStepId());
    askedContraIndicationStep = new AskedContraIndicationStep(getStepId());
    instrumentSelectionStep = new InstrumentSelectionStep(getStepId(), instrumentTypeModel);
    noInstrumentAvailableStep = new NoInstrumentAvailableStep(getStepId());
    inputParametersStep = new InputParametersStep(getStepId());
    instrumentLaunchStep = new InstrumentLaunchStep(getStepId());
    conclusionStep = new ConclusionStep(getStepId());
    warningStep = new WarningsStep(getStepId());
    outputParametersStep = new OutputParametersStep(getStepId(), conclusionStep, warningStep);

    warningStep.setNextStep(conclusionStep);
    warningStep.setPreviousStep(outputParametersStep);

    createModalAdministrationPanel();

    // admin button
    AjaxLink link =
        new AjaxLink("adminLink") {
          private static final long serialVersionUID = 0L;

          @Override
          public void onClick(AjaxRequestTarget target) {
            adminWindow.setInterruptState(getInterruptLink().isEnabled());
            if (getCancelLink() != null) adminWindow.setCancelState(getCancelLink().isEnabled());
            adminWindow.show(target);
          }
        };
    link.add(
        new AttributeModifier(
            "value", true, new StringResourceModel("Administration", this, null)));
    link.add(new AttributeAppender("class", new Model("ui-corner-all"), " "));
    add(link);
  }
  /** Initializes UI. */
  protected void initUI() {
    AjaxLink<Void> link =
        new AjaxLink<Void>(CKEY_LINK) {
          private static final long serialVersionUID = 1L;

          @Override
          public void onClick(AjaxRequestTarget target) {
            LinkButton.this.onClick(target);
          }
        };
    add(link);

    link.add(new Label(CKEY_LABEL, getDefaultModel()));
  }
  private void initButtons(WebMarkupContainer buttonGroup, final ListItem<T> item) {
    AjaxLink add =
        new AjaxLink(ID_ADD) {

          @Override
          public void onClick(AjaxRequestTarget target) {
            addValuePerformed(target);
          }
        };
    add.add(
        new VisibleEnableBehaviour() {

          @Override
          public boolean isVisible() {
            return isAddButtonVisible(item);
          }
        });
    buttonGroup.add(add);

    AjaxLink remove =
        new AjaxLink(ID_REMOVE) {

          @Override
          public void onClick(AjaxRequestTarget target) {
            removeValuePerformed(target, item);
          }
        };
    remove.add(
        new VisibleEnableBehaviour() {

          @Override
          public boolean isVisible() {
            return isRemoveButtonVisible();
          }
        });
    buttonGroup.add(remove);
  }
示例#8
0
  private AjaxLink createInterrupt() {
    AjaxLink link =
        new AjaxLink("interrupt") {
          private static final long serialVersionUID = 0L;

          @Override
          public void onClick(AjaxRequestTarget target) {
            onInterrupt(target);
          }

          @Override
          public boolean isVisible() {
            IStageExecution exec =
                activeInterviewService.getStageExecution((Stage) stageModel.getObject());
            return exec.getActionDefinition(ActionType.INTERRUPT) != null;
          }
        };
    link.add(
        new AttributeModifier(
            "value", true, new StringResourceModel("Interrupt", InstrumentWizardForm.this, null)));

    return link;
  }
示例#9
0
  public PageLogin() {
    if (SecurityUtils.getPrincipalUser() != null) {
      MidPointApplication app = getMidpointApplication();
      setResponsePage(app.getHomePage());
    }

    BookmarkablePageLink<String> link =
        new BookmarkablePageLink<>(ID_FORGET_PASSWORD, PageForgotPassword.class);
    link.add(
        new VisibleEnableBehaviour() {
          private static final long serialVersionUID = 1L;

          @Override
          public boolean isVisible() {
            OperationResult parentResult =
                new OperationResult(OPERATION_LOAD_RESET_PASSWORD_POLICY);

            SecurityPolicyType securityPolicy = null;
            try {
              securityPolicy =
                  getModelInteractionService().getSecurityPolicy(null, null, parentResult);
            } catch (ObjectNotFoundException | SchemaException e) {
              LOGGER.warn("Cannot read credentials policy: " + e.getMessage(), e);
            }

            boolean linkIsVisible = false;

            if (securityPolicy == null) {
              return linkIsVisible;
            }

            CredentialsPolicyType creds = securityPolicy.getCredentials();

            if (creds != null
                && ((creds.getSecurityQuestions() != null
                        && creds.getSecurityQuestions().getQuestionNumber() != null)
                    || (securityPolicy.getCredentialsReset() != null))) {
              linkIsVisible = true;
            }

            return linkIsVisible;
          }
        });
    add(link);

    AjaxLink<String> registration =
        new AjaxLink<String>(ID_SELF_REGISTRATION) {

          @Override
          public void onClick(AjaxRequestTarget target) {
            setResponsePage(PageSelfRegistration.class);
          }
        };
    registration.add(
        new VisibleEnableBehaviour() {
          private static final long serialVersionUID = 1L;

          @Override
          public boolean isVisible() {
            OperationResult parentResult = new OperationResult(OPERATION_LOAD_REGISTRATION_POLICY);

            RegistrationsPolicyType registrationPolicies = null;
            try {
              Task task = createAnonymousTask(OPERATION_LOAD_REGISTRATION_POLICY);
              registrationPolicies =
                  getModelInteractionService().getRegistrationPolicy(null, task, parentResult);
            } catch (ObjectNotFoundException | SchemaException e) {
              LOGGER.warn("Cannot read credentials policy: " + e.getMessage(), e);
            }

            boolean linkIsVisible = false;
            if (registrationPolicies != null
                && registrationPolicies.getSelfRegistration() != null) {
              linkIsVisible = true;
            }

            return linkIsVisible;
          }
        });
    add(registration);
  }
  private Fragment getResurceFragment(final TopologyNode node, final PageReference pageRef) {
    final Fragment fragment = new Fragment("actions", "resourceActions", this);

    final AjaxLink<String> delete =
        new IndicatingAjaxLink<String>("delete") {

          private static final long serialVersionUID = 3776750333491622263L;

          @Override
          public void onClick(final AjaxRequestTarget target) {
            try {
              resourceRestClient.delete(node.getKey().toString());
              target.appendJavaScript(String.format("jsPlumb.remove('%s');", node.getKey()));
              info(getString(Constants.OPERATION_SUCCEEDED));
            } catch (SyncopeClientException e) {
              error(getString(Constants.ERROR) + ": " + e.getMessage());
              LOG.error("While deleting resource {}", node.getKey(), e);
            }
            ((BasePage) getPage()).getNotificationPanel().refresh(target);
          }
        };
    fragment.add(delete);

    delete.add(new ConfirmationModalBehavior());

    MetaDataRoleAuthorizationStrategy.authorize(
        delete, ENABLE, StandardEntitlement.RESOURCE_DELETE);

    final AjaxLink<String> edit =
        new IndicatingAjaxLink<String>("edit") {

          private static final long serialVersionUID = 3776750333491622263L;

          @Override
          public void onClick(final AjaxRequestTarget target) {
            final ResourceTO modelObject = resourceRestClient.read(node.getKey().toString());

            final IModel<ResourceTO> model = new CompoundPropertyModel<>(modelObject);
            resourceModal.setFormModel(model);

            target.add(
                resourceModal.setContent(
                    new ResourceModal<>(resourceModal, pageRef, model, false)));

            resourceModal.header(
                new Model<>(MessageFormat.format(getString("resource.edit"), node.getKey())));

            MetaDataRoleAuthorizationStrategy.authorize(
                resourceModal.addSumbitButton(), ENABLE, StandardEntitlement.RESOURCE_UPDATE);

            resourceModal.show(true);
          }
        };
    fragment.add(edit);
    MetaDataRoleAuthorizationStrategy.authorize(edit, ENABLE, StandardEntitlement.RESOURCE_UPDATE);

    final AjaxLink<String> propagation =
        new IndicatingAjaxLink<String>("propagation") {

          private static final long serialVersionUID = 3776750333491622263L;

          @Override
          @SuppressWarnings("unchecked")
          public void onClick(final AjaxRequestTarget target) {
            target.add(
                taskModal.setContent(new PropagationTasks(pageRef, node.getKey().toString())));
            taskModal.header(new ResourceModel("task.propagation.list", "Propagation tasks"));
            taskModal.show(true);
          }
        };
    fragment.add(propagation);
    MetaDataRoleAuthorizationStrategy.authorize(propagation, ENABLE, StandardEntitlement.TASK_LIST);

    final AjaxLink<String> synchronization =
        new IndicatingAjaxLink<String>("synchronization") {

          private static final long serialVersionUID = 3776750333491622263L;

          @Override
          public void onClick(final AjaxRequestTarget target) {
            target.add(taskModal.setContent(new SyncTasks(pageRef, node.getKey().toString())));
            taskModal.header(
                new ResourceModel("task.synchronization.list", "Synchronization tasks"));
            taskModal.show(true);
          }
        };
    fragment.add(synchronization);
    MetaDataRoleAuthorizationStrategy.authorize(
        synchronization, ENABLE, StandardEntitlement.TASK_LIST);

    final AjaxLink<String> push =
        new IndicatingAjaxLink<String>("push") {

          private static final long serialVersionUID = 3776750333491622263L;

          @Override
          public void onClick(final AjaxRequestTarget target) {
            target.add(taskModal.setContent(new PushTasks(pageRef, node.getKey().toString())));
            taskModal.header(new ResourceModel("task.push.list", "Push tasks"));
            taskModal.show(true);
          }
        };
    fragment.add(push);
    MetaDataRoleAuthorizationStrategy.authorize(push, ENABLE, StandardEntitlement.TASK_LIST);

    return fragment;
  }
  private Fragment getConnectorFragment(final TopologyNode node, final PageReference pageRef) {
    final Fragment fragment = new Fragment("actions", "connectorActions", this);

    final AjaxLink<String> delete =
        new IndicatingAjaxLink<String>("delete") {

          private static final long serialVersionUID = 3776750333491622263L;

          @Override
          public void onClick(final AjaxRequestTarget target) {
            try {
              connectorRestClient.delete(Long.class.cast(node.getKey()));
              target.appendJavaScript(String.format("jsPlumb.remove('%s');", node.getKey()));
              info(getString(Constants.OPERATION_SUCCEEDED));
            } catch (SyncopeClientException e) {
              error(getString(Constants.ERROR) + ": " + e.getMessage());
              LOG.error("While deleting resource {}", node.getKey(), e);
            }
            ((BasePage) getPage()).getNotificationPanel().refresh(target);
          }
        };

    fragment.add(delete);
    delete.add(new ConfirmationModalBehavior());

    MetaDataRoleAuthorizationStrategy.authorize(
        delete, ENABLE, StandardEntitlement.CONNECTOR_DELETE);

    final 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(Long.class.cast(node.getKey()));
            modelObject.setConnectorDisplayName(node.getDisplayName());

            final IModel<ResourceTO> model = new CompoundPropertyModel<>(modelObject);
            resourceModal.setFormModel(model);

            target.add(
                resourceModal.setContent(new ResourceModal<>(resourceModal, pageRef, model, true)));

            resourceModal.header(
                new Model<>(MessageFormat.format(getString("resource.new"), node.getKey())));

            MetaDataRoleAuthorizationStrategy.authorize(
                resourceModal.addSumbitButton(), ENABLE, StandardEntitlement.RESOURCE_CREATE);

            resourceModal.show(true);
          }
        };
    fragment.add(create);

    MetaDataRoleAuthorizationStrategy.authorize(
        create, ENABLE, StandardEntitlement.RESOURCE_CREATE);

    final AjaxLink<String> edit =
        new IndicatingAjaxLink<String>("edit") {

          private static final long serialVersionUID = 3776750333491622263L;

          @Override
          public void onClick(final AjaxRequestTarget target) {
            final ConnInstanceTO modelObject =
                connectorRestClient.read(Long.class.cast(node.getKey()));

            final IModel<ConnInstanceTO> model = new CompoundPropertyModel<>(modelObject);
            resourceModal.setFormModel(model);

            target.add(resourceModal.setContent(new ConnectorModal(resourceModal, pageRef, model)));

            resourceModal.header(
                new Model<>(MessageFormat.format(getString("connector.edit"), node.getKey())));

            MetaDataRoleAuthorizationStrategy.authorize(
                resourceModal.addSumbitButton(), ENABLE, StandardEntitlement.CONNECTOR_UPDATE);

            resourceModal.show(true);
          }
        };
    fragment.add(edit);

    MetaDataRoleAuthorizationStrategy.authorize(edit, ENABLE, StandardEntitlement.CONNECTOR_UPDATE);

    return fragment;
  }
示例#12
0
  protected void populateCell(
      WebMarkupContainer cellContainer, final AssignmentEditorDto assignment) {
    AjaxLink inner =
        new AjaxLink(ID_INNER) {
          private static final long serialVersionUID = 1L;

          @Override
          public void onClick(AjaxRequestTarget ajaxRequestTarget) {
            assignmentDetailsPerformed(assignment, ajaxRequestTarget);
          }
        };
    cellContainer.add(inner);

    Label nameLabel = new Label(ID_INNER_LABEL, assignment.getName());
    inner.add(nameLabel);

    AjaxLink detailsLink =
        new AjaxLink(ID_DETAILS_LINK) {
          @Override
          public void onClick(AjaxRequestTarget ajaxRequestTarget) {
            assignmentDetailsPerformed(assignment, ajaxRequestTarget);
          }
        };
    cellContainer.add(detailsLink);

    Label detailsLinkLabel =
        new Label(
            ID_DETAILS_LINK_LABEL, pageBase.createStringResource("MultiButtonPanel.detailsLink"));
    detailsLinkLabel.setRenderBodyOnly(true);
    detailsLink.add(detailsLinkLabel);

    AjaxLink detailsLinkIcon =
        new AjaxLink(ID_DETAILS_LINK_ICON) {
          private static final long serialVersionUID = 1L;

          @Override
          public void onClick(AjaxRequestTarget target) {}
        };
    detailsLink.add(detailsLinkIcon);

    AjaxLink addToCartLink =
        new AjaxLink(ID_ADD_TO_CART_LINK) {
          @Override
          public void onClick(AjaxRequestTarget ajaxRequestTarget) {
            addAssignmentPerformed(assignment, ajaxRequestTarget);
          }
        };
    cellContainer.add(addToCartLink);

    AjaxLink addToCartLinkIcon =
        new AjaxLink(ID_ADD_TO_CART_LINK_ICON) {
          private static final long serialVersionUID = 1L;

          @Override
          public void onClick(AjaxRequestTarget target) {}
        };
    addToCartLink.add(addToCartLinkIcon);

    WebMarkupContainer icon = new WebMarkupContainer(ID_TYPE_ICON);
    icon.add(new AttributeAppender("class", getIconClass(assignment.getType())));
    cellContainer.add(icon);
  }
示例#13
0
  protected void initLayout() {
    final ValueModel valueModel = model.getObject();
    FieldDisplayType display = valueModel.getDefaultDisplay();

    // todo help
    Label label =
        new Label("label", new StringResourceModel(display.getLabel(), null, display.getLabel()));
    label.add(
        new AttributeModifier(
            "style",
            new AbstractReadOnlyModel<String>() {

              @Override
              public String getObject() {
                if (valueModel.getVisibleValueIndex() > 0) {
                  return "visibility: hidden;";
                }
                return null;
              }
            }));

    if (StringUtils.isNotEmpty(display.getTooltip())) {
      label.add(
          new AttributeModifier(
              "title", new StringResourceModel(display.getTooltip(), null, display.getTooltip())));
    }
    add(label);

    FieldToken fieldToken = valueModel.getField().getToken();
    UiWidget widget = initWidget(fieldToken.getWidget(), display.getProperty());
    add(widget);

    FeedbackPanel feedback = new FeedbackPanel("feedback");
    feedback.setFilter(new ComponentFeedbackMessageFilter(widget.getBaseFormComponent()));
    feedback.setOutputMarkupId(true);
    add(feedback);

    AjaxLink addButton =
        new AjaxLink("addButton") {

          @Override
          public void onClick(AjaxRequestTarget target) {
            addValue(target);
          }
        };
    addButton.add(
        new VisibleEnableBehaviour() {

          @Override
          public boolean isVisible() {
            return valueModel.isAddButtonVisible();
          }
        });
    add(addButton);

    AjaxLink removeButton =
        new AjaxLink("removeButton") {

          @Override
          public void onClick(AjaxRequestTarget target) {
            removeValue(target);
          }
        };
    removeButton.add(
        new VisibleEnableBehaviour() {

          @Override
          public boolean isVisible() {
            return valueModel.isRemoveButtonVisible();
          }
        });
    add(removeButton);
  }