Java Code Examples for org.apache.wicket.markup.html.form.Form

The following are top voted examples for showing how to use org.apache.wicket.markup.html.form.Form. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: GeoCrawler   File: SeedPage.java   View source code 7 votes vote down vote up
private void addUrlForm() {
  urlForm = new Form<SeedUrl>("urlForm", CompoundPropertyModel.of(Model
      .of(new SeedUrl())));
  urlForm.setOutputMarkupId(true);
  urlForm.add(new TextField<String>("url"));
  urlForm.add(new AjaxSubmitLink("addUrl", urlForm) {
    @Override
    protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
      addSeedUrl();
      urlForm.setModelObject(new SeedUrl());
      target.add(urlForm);
      target.add(seedUrlsTable);
    }
  });
  add(urlForm);
}
 
Example 2
Project: Unicorn   File: NotificationPage.java   View source code 7 votes vote down vote up
public NotificationPage() {
	super();

	// Create the modal window.
	this.addNotificationModal = new AddNotificationModal("addNotificationModal", this);
	this.add(this.addNotificationModal);

	// add notificationList
	if (((AuthenticatedSession) Session.get()).getUser() != null) {
		// logged in users see their notifications
		final NotificationList notificationList = new NotificationList("notificationList", this);
		notificationList.setOutputMarkupId(true);
		this.add(notificationList);
	} else {
		final Label notificationListLabel = new Label("notificationList", "Log in to check your notifications.");
		notificationListLabel.setOutputMarkupId(true);
		this.add(notificationListLabel);
	}

	this.form = new Form<Void>("form");
	this.form.add(this.addAddButton());
	this.form.add(this.addDeleteAllButton());
	this.add(this.form);

	this.addNotificationRules();
}
 
Example 3
Project: Unicorn   File: LoginPage.java   View source code 7 votes vote down vote up
private void buildMainLayout() {
	this.loginForm = new WarnOnExitForm("loginForm");

	this.emailInput = new TextField<String>("emailInput", Model.of(""));
	this.loginForm.add(this.emailInput);

	this.passwordInput = new PasswordTextField("passwordInput", Model.of(""));
	this.loginForm.add(this.passwordInput);

	this.addLoginButton();
	this.addRegisterLink();

	this.add(this.loginForm);

	this.logoutForm = new Form<Object>("logoutForm");

	this.addLogoutButton();

	this.add(this.logoutForm);

	if (((AuthenticatedSession) Session.get()).getUser() != null) {
		this.loginForm.setVisible(false);
	} else {
		this.logoutForm.setVisible(false);
	}
}
 
Example 4
Project: karate   File: PostmanConvertPanel.java   View source code 6 votes vote down vote up
public PostmanConvertPanel(String id) {
    super(id);
    setDefaultModel(new CompoundPropertyModel(this));
    Form form = new Form("form") {
        @Override
        protected void onSubmit() {
            logger.debug("text is: {}", text);
            List<PostmanRequest> requests = ConvertUtils.readPostmanJson(text);
            String feature = ConvertUtils.toKarateFeature(requests);
            KarateSession session = service.createSession("dev", feature);
            setResponsePage(new FeaturePage(session.getId()));
        }
    };
    form.add(new TextArea("text"));
    add(form);
    add(new FeedbackPanel("feedback"));
    text = "Paste your postman collection here.";
}
 
Example 5
Project: gitplex-mit   File: SystemSettingPage.java   View source code 6 votes vote down vote up
@Override
protected void onInitialize() {
	super.onInitialize();
	
	SystemSetting systemSetting = GitPlex.getInstance(ConfigManager.class).getSystemSetting();

	Form<?> form = new Form<Void>("form") {

		@Override
		protected void onSubmit() {
			super.onSubmit();
			GitPlex.getInstance(ConfigManager.class).saveSystemSetting(systemSetting);
			getSession().success("System setting has been updated");
			
			setResponsePage(SystemSettingPage.class);
		}
		
	};
	form.add(BeanContext.editBean("editor", systemSetting));
	
	add(form);
}
 
Example 6
Project: gitplex-mit   File: SecuritySettingPage.java   View source code 6 votes vote down vote up
@Override
protected void onInitialize() {
	super.onInitialize();
	
	SecuritySetting securitySetting = GitPlex.getInstance(ConfigManager.class).getSecuritySetting();

	Form<?> form = new Form<Void>("securitySetting") {

		@Override
		protected void onSubmit() {
			super.onSubmit();
			GitPlex.getInstance(ConfigManager.class).saveSecuritySetting(securitySetting);
			getSession().success("Security setting has been updated");
			
			setResponsePage(SecuritySettingPage.class);
		}
		
	};
	form.add(BeanContext.editBean("editor", securitySetting));
	
	add(form);
}
 
Example 7
Project: vlo-curation   File: FacetValuesPanel.java   View source code 6 votes vote down vote up
/**
 * Creates a form with an input bound to the filter model
 *
 * @param id component id
 * @return filter form
 */
private Form createFilterForm(String id) {
    final Form filterForm = new Form(id);
    final TextField<String> filterField = new TextField<>("filterText",
            new PropertyModel<String>(filterModel, "name"));
    // make field update 
    filterField.add(new AjaxFormComponentUpdatingBehavior("keyup") {

        @Override
        protected void onUpdate(AjaxRequestTarget target) {
            //update values
            target.add(valuesContainer);
        }
    });
    filterForm.add(filterField);
    return filterForm;
}
 
Example 8
Project: engerek   File: PrismObjectPanel.java   View source code 6 votes vote down vote up
protected Component createHeader(String id, final IModel<ObjectWrapper<O>> model, final Form<ObjectWrapper<O>> form) {
 	PrismHeaderPanel header = new PrismHeaderPanel(ID_HEADER, model) {
private static final long serialVersionUID = 1L;

@Override
protected void onButtonClick(AjaxRequestTarget target) {
             addOrReplaceContainers(model, form, true);
	target.add(PrismObjectPanel.this);
}
 		
@Override
public boolean isButtonsVisible() {
	return true;
}
 	};
     return header;
 }
 
Example 9
Project: engerek   File: PrismObjectPanel.java   View source code 6 votes vote down vote up
private void addOrReplaceContainers(IModel<ObjectWrapper<O>> model, final Form form, boolean isToBeReplaced){
    ListView<ContainerWrapper> containers = new ListView<ContainerWrapper>(ID_CONTAINERS,
            createContainerModel(model)) {
        private static final long serialVersionUID = 1L;

        @Override
        protected void populateItem(ListItem<ContainerWrapper> item) {
            PrismContainerPanel containerPanel = createContainerPanel(item, form);
            createMetadataPanel(model, item, containerPanel);
        }
    };
    containers.setReuseItems(true);

    if (isToBeReplaced) {
        replace(containers);
    } else {
        add(containers);
    }
}
 
Example 10
Project: singular-server   File: AbstractFormPage.java   View source code 6 votes vote down vote up
private Component buildSaveButton() {
    final Component button = new SingularButton("save-btn", getFormInstance()) {

        @Override
        protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
            super.onSubmit(target, form);
            try {
                saveForm(getFormInstance());
                addToastrSuccessMessage("message.success");
                atualizarContentWorklist(target);
            } catch (HibernateOptimisticLockingFailureException e) {
                getLogger().debug(e.getMessage(), e);
                addToastrErrorMessage("message.save.concurrent_error");
            }
        }
    };
    return button.add(visibleOnlyInEditionBehaviour());
}
 
Example 11
Project: engerek   File: ConfigurationStep.java   View source code 6 votes vote down vote up
private void updateConfigurationTabs() {
	final com.evolveum.midpoint.web.component.form.Form form = getForm();
	TabbedPanel<ITab> tabbedPanel = getConfigurationTabbedPanel();
	List<ITab> tabs = tabbedPanel.getTabs().getObject();
	tabs.clear();

	List<ContainerWrapper> wrappers = configurationPropertiesModel.getObject();
	for (final ContainerWrapper wrapper : wrappers) {
		String tabName = getString(wrapper.getDisplayName(), null, wrapper.getDisplayName());
		tabs.add(new AbstractTab(new Model<>(tabName)) {
			@Override
			public WebMarkupContainer getPanel(String panelId) {
				return new PrismContainerPanel(panelId, new Model<>(wrapper), true, form, parentPage);
			}
		});
	}
	int i = tabbedPanel.getSelectedTab();
	if (i < 0 || i > tabs.size()) {
		i = 0;
	}
	tabbedPanel.setSelectedTab(i);
}
 
Example 12
Project: Unicorn   File: RepeatPatternOperatorRangePanel.java   View source code 6 votes vote down vote up
public RepeatPatternOperatorRangePanel(final String id, final PatternOperatorElement element, final AdvancedTransformationRuleEditorPanel panel) {
	super(id);

	this.layoutForm = new Form<Void>("layoutForm");

	final RangeElement rangeElement = element.getRangeElement();

	this.matchCount = rangeElement.getLeftEndpoint();

	this.matchCountInput = new TextField<Integer>("matchCountInput", new PropertyModel<Integer>(this, "matchCount"));
	final OnChangeAjaxBehavior onChangeAjaxBehavior = new OnChangeAjaxBehavior() {
		private static final long serialVersionUID = 2251803290291534439L;

		@Override
		protected void onUpdate(final AjaxRequestTarget target) {
			rangeElement.setLeftEndpoint(RepeatPatternOperatorRangePanel.this.matchCount);
			target.add(panel.getAttributeTreePanel().getAttributeTreeTable());
		}
	};
	this.matchCountInput.add(onChangeAjaxBehavior);
	this.matchCountInput.setOutputMarkupId(true);
	this.layoutForm.add(this.matchCountInput);

	this.add(this.layoutForm);
}
 
Example 13
Project: Unicorn   File: CategoryPanel.java   View source code 6 votes vote down vote up
private void addEventsCheckBoxMultipleChoice(final Form<Void> layoutForm) {
	this.eventsCheckBoxMultipleChoice = new CheckBoxMultipleChoice<ReplayFileBean>("eventsCheckBoxMultipleChoice", new PropertyModel<List<ReplayFileBean>>(this, "selectedFiles"), beans);
	this.eventsCheckBoxMultipleChoice.setOutputMarkupId(true);
	layoutForm.add(this.eventsCheckBoxMultipleChoice);

	// this.eventsCheckGroup = new
	// CheckGroup<ReplayFileBean>("eventsCheckGroup",
	// new PropertyModel<List<ReplayFileBean>>(this, "selectedFiles"));
	// this.eventsCheckGroup.add(new CheckGroupSelector("groupSelector"));
	//
	// ListView<ReplayFileBean> files = new
	// ListView<ReplayFileBean>("beans", beans) {
	// @Override
	// protected void populateItem(ListItem<ReplayFileBean> item) {
	// item.add(new Label("name", item.getModelObject().toString()));
	// }
	// };
	// files.setReuseItems(true);
	// this.eventsCheckGroup.add(files);
	// this.eventsCheckGroup.setOutputMarkupId(true);
	// layoutForm.add(this.eventsCheckGroup);
}
 
Example 14
Project: Unicorn   File: NotificationPage.java   View source code 6 votes vote down vote up
private Component addDeleteAllButton() {
	this.deleteAllButton = new BlockingAjaxButton("deleteAllNotificationsButton", this.form) {
		private static final long serialVersionUID = 1L;

		@Override
		public void onSubmit(final AjaxRequestTarget target, final Form form) {
			super.onSubmit(target, form);
			final List<NotificationRule> rules = new ArrayList<NotificationRule>(NotificationPage.this.notificationRulesListView.notificationRuleProvider.getEntities());
			for (final NotificationRule rule : rules) {
				rule.remove();
				NotificationPage.this.notificationRulesListView.notificationRuleProvider.removeItem(rule);
				NotificationPage.this.notificationRulesListView.notificationRuleTable.detach();
				target.add(NotificationPage.this.notificationRulesListView.notificationRuleTable);
			}
		}
	};
	this.deleteAllButton.setOutputMarkupId(true);
	return this.deleteAllButton;
}
 
Example 15
Project: engerek   File: PageAccount.java   View source code 6 votes vote down vote up
private void initLayout() {
    Form mainForm = new Form("mainForm");
    mainForm.setMultiPart(true);
    add(mainForm);

    WebMarkupContainer protectedMessage = new WebMarkupContainer(ID_PROTECTED_MESSAGE);
    protectedMessage.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            ObjectWrapper wrapper = accountModel.getObject();
            return wrapper.isProtectedAccount();
        }
    });
    mainForm.add(protectedMessage);

    PrismObjectPanel<ShadowType> userForm = new PrismObjectPanel<ShadowType>("account", accountModel, new PackageResourceReference(
            ImgResources.class, ImgResources.HDD_PRISM), mainForm, this);
    mainForm.add(userForm);

    initButtons(mainForm);
}
 
Example 16
Project: engerek   File: PageCertDecisions.java   View source code 6 votes vote down vote up
private void initLayout() {
    Form mainForm = new Form(ID_MAIN_FORM);
    add(mainForm);
    CertWorkItemDtoProvider provider = createProvider();
    int itemsPerPage = (int) getItemsPerPage(UserProfileStorage.TableId.PAGE_CERT_DECISIONS_PANEL);
    BoxedTablePanel<CertWorkItemDto> table = new BoxedTablePanel<CertWorkItemDto>(ID_DECISIONS_TABLE, provider, initColumns(),
            UserProfileStorage.TableId.PAGE_CERT_DECISIONS_PANEL, itemsPerPage) {

        @Override
        protected WebMarkupContainer createHeader(String headerId) {
            return new SearchFragment(headerId, ID_TABLE_HEADER, PageCertDecisions.this, showNotDecidedOnlyModel);
        }
    };
    table.setShowPaging(true);
    table.setOutputMarkupId(true);
    table.setItemsPerPage(itemsPerPage);        // really don't know why this is necessary, as e.g. in PageRoles the size setting works without it
    mainForm.add(table);

    // adding this on outer feedback panel prevents displaying the error messages
    //addVisibleOnWarningBehavior(getMainFeedbackPanel());
    //addVisibleOnWarningBehavior(getTempFeedbackPanel());
}
 
Example 17
Project: Unicorn   File: ExportImportDependenciesPanel.java   View source code 6 votes vote down vote up
/**
 * Add a button for exporting the dependencies of the given event type.
 */
private void addExportButton() {
        final AjaxButton exportButton = new AjaxButton("exportButton") {
           private static final long serialVersionUID = 1L;
            @Override
            public void onSubmit(final AjaxRequestTarget target, final Form form) {
                final AJAXDownload jsonDownload = new AJAXDownload() {
                    @Override
                    protected IResourceStream getResourceStream() {
                        final File csv = JsonExporter.generateExportFileWithDependencies(selectedEventType);
                        return new FileResourceStream(new org.apache.wicket.util.file.File(csv));
                    }
                    @Override
                    protected String getFileName() {
                        return selectedEventType.getTypeName() + "-dependencies.json";
                    }
                };
                ExportImportDependenciesPanel.this.add(jsonDownload);
                jsonDownload.initiate(target);
                ExportImportDependenciesPanel.this.page.getFeedbackPanel().success("Json created.");
                target.add(ExportImportDependenciesPanel.this.page.getFeedbackPanel());
            }
        };
        exportForm.add(exportButton);
}
 
Example 18
Project: engerek   File: TsaValidator.java   View source code 6 votes vote down vote up
@Override
public void validate(Form<?> form) {

	if (runUntilNodeDown.getConvertedInput()) {
		if (ThreadStopActionType.RESTART.equals(threadStop.getConvertedInput())
				|| ThreadStopActionType.RESCHEDULE.equals(threadStop.getConvertedInput())){
			error(runUntilNodeDown, "pageTask.runUntilNodeDown.error1");
		}
			
	} else {
		if (ThreadStopActionType.CLOSE.equals(threadStop.getConvertedInput())
				|| ThreadStopActionType.SUSPEND.equals(threadStop.getConvertedInput())){
			error(runUntilNodeDown, "pageTask.runUntilNodeDown.error2");
		}
	}

}
 
Example 19
Project: engerek   File: PageDebugList.java   View source code 6 votes vote down vote up
private void addOrReplaceTable(RepositoryObjectDataProvider provider) {
	Form mainForm = (Form) get(ID_MAIN_FORM);

	BoxedTablePanel table = new BoxedTablePanel(ID_TABLE, provider, initColumns(provider.getType()),
			UserProfileStorage.TableId.CONF_DEBUG_LIST_PANEL,
			(int) getItemsPerPage(UserProfileStorage.TableId.CONF_DEBUG_LIST_PANEL)) {

		@Override
		protected WebMarkupContainer createHeader(String headerId) {
			return new SearchFragment(headerId, ID_TABLE_HEADER, PageDebugList.this, searchModel,
					resourcesModel);
		}

	};
	table.setOutputMarkupId(true);

	ConfigurationStorage storage = getSessionStorage().getConfiguration();
	table.setCurrentPage(storage.getPaging());

	mainForm.addOrReplace(table);
}
 
Example 20
Project: Unicorn   File: NotificationCreationPanel.java   View source code 6 votes vote down vote up
public NotificationCreationPanel(final String id, final NotificationPage notificationPage) {
	super(id);
	this.panel = this;

	this.visualisationPage = notificationPage;

	this.layoutForm = new Form<Void>("layoutForm");
	this.add(this.layoutForm);
	this.addFeedbackPanel(this.layoutForm);
	// layoutForm.add(addTypeSelect());
	this.layoutForm.add(this.addPrioritySelect());
	this.layoutForm.add(this.addUserSelect());
	// layoutForm.add(addEventDiv());
	this.layoutForm.add(this.addQueryDiv());
	this.addButtonsToForm(this.layoutForm);
}
 
Example 21
Project: engerek   File: PageAccounts.java   View source code 6 votes vote down vote up
private void initTotals(Form form) {
    WebMarkupContainer totals = new WebMarkupContainer(ID_TOTALS);
    totals.setOutputMarkupId(true);

    totalModel = createTotalModel();
    deletedModel = createTotalsModel(SynchronizationSituationType.DELETED);
    unmatchedModel = createTotalsModel(SynchronizationSituationType.UNMATCHED);
    disputedModel = createTotalsModel(SynchronizationSituationType.DISPUTED);
    linkedModel = createTotalsModel(SynchronizationSituationType.LINKED);
    unlinkedModel = createTotalsModel(SynchronizationSituationType.UNLINKED);
    nothingModel = createTotalsModel(null);

    totals.add(new Label(ID_TOTAL, totalModel));
    totals.add(new Label(ID_DELETED, deletedModel));
    totals.add(new Label(ID_UNMATCHED, unmatchedModel));
    totals.add(new Label(ID_DISPUTED, disputedModel));
    totals.add(new Label(ID_LINKED, linkedModel));
    totals.add(new Label(ID_UNLINKED, unlinkedModel));
    totals.add(new Label(ID_NOTHING, nothingModel));

    form.add(totals);
}
 
Example 22
Project: Unicorn   File: DerivationTypeDropDownChoicePanel.java   View source code 6 votes vote down vote up
public DerivationTypeDropDownChoicePanel(final String id, final int entryId, final SimulationTreeTableProvider<Object> simulationTreeTableProvider) {
	super(id);
	final Form<Void> layoutForm = new Form<Void>("layoutForm");

	final DropDownChoice<DerivationType> derivationTypeDropDownChoice = new DropDownChoice<DerivationType>("derivationTypeDropDownChoice", Model.of(simulationTreeTableProvider.getDerivationTypeForEntry(entryId)), this.derivationTypes);
	derivationTypeDropDownChoice.add(new AjaxFormComponentUpdatingBehavior("onchange") {

		private static final long serialVersionUID = 1L;

		@Override
		protected void onUpdate(final AjaxRequestTarget target) {
			simulationTreeTableProvider.setDerivationTypeForEntry(derivationTypeDropDownChoice.getModelObject(), entryId);

			if (DerivationTypeDropDownChoicePanel.this.treeTable != null) {
				target.add(DerivationTypeDropDownChoicePanel.this.treeTable);
			} else {
				target.add(DerivationTypeDropDownChoicePanel.this.getPage());
			}
		}
	});

	derivationTypeDropDownChoice.setEnabled(true);
	layoutForm.add(derivationTypeDropDownChoice);
	this.add(layoutForm);
}
 
Example 23
Project: singular-server   File: ExtensionButtonsPanel.java   View source code 6 votes vote down vote up
private void addButtons() {
    add(new ListView<RequirementButtonExtension>("buttons", extensions) {
        @Override
        protected void populateItem(ListItem<RequirementButtonExtension> item) {
            final RequirementButtonExtension itemModel = item.getModelObject();
            SingularSaveButton button = new SingularSaveButton("button", formModel, itemModel.shouldValidateForm()) {
                @Override
                protected void onValidationSuccess(AjaxRequestTarget target, Form<?> form, IModel<? extends SInstance> instanceModel) {
                    itemModel.onAction(new RequirementButtonExtension
                            .ActionContext(target, form, petInstanceModel.getObject(), instanceModel.getObject()));
                }
            };
            RequirementButtonExtension.ButtonView buttonView = itemModel.getButtonView();
            WebMarkupContainer                    icon       = new WebMarkupContainer("icon");
            if (buttonView.getIcon() != null) {
                icon.add($b.classAppender(buttonView.getIcon().getCssClass()));
            }
            else {
                icon.setVisible(false);
            }
            button.add(icon);
            button.add(new Label("label", buttonView.getLabel()).setRenderBodyOnly(true));
            item.add(button);
        }
    }.setRenderBodyOnly(true));
}
 
Example 24
Project: Unicorn   File: ExternalKnowledgePanel.java   View source code 6 votes vote down vote up
private void buildHeader() {

		final Label attributeToFillLabel = new Label("attributeToFillLabel", "Attribute: " + this.attributeToFill.getAttributeExpression() + " (" + this.attributeToFill.getType() + ")");
		this.layoutForm.addOrReplace(attributeToFillLabel);

		final AjaxButton addCriteriaAttributesAndValuesButton = new AjaxButton("addCriteriaAttributesAndValuesButton", this.layoutForm) {
			private static final long serialVersionUID = 6456362459418575615L;

			@Override
			public void onSubmit(final AjaxRequestTarget target, final Form<?> form) {
				ExternalKnowledgePanel.this.coalesceExpressions.add(new ExternalKnowledgeExpression());
				ExternalKnowledgePanel.this.criteriaAttributesAndValuesListView.setList(ExternalKnowledgePanel.this.coalesceExpressions);
				target.add(ExternalKnowledgePanel.this.container);
			}
		};
		this.layoutForm.addOrReplace(addCriteriaAttributesAndValuesButton);
	}
 
Example 25
Project: Unicorn   File: EventTypeElementOptionsPanel.java   View source code 6 votes vote down vote up
private void buildAddFilterExpressionButton() {
	final AjaxButton addFilterExpressionButton = new AjaxButton("addFilterExpressionButton", this.layoutForm) {
		private static final long serialVersionUID = -2611608162033482853L;

		@Override
		public void onSubmit(final AjaxRequestTarget target, final Form<?> form) {
			final FilterExpressionElement newFilterExpressionElement = new FilterExpressionElement(((TreeTableProvider<Serializable>) EventTypeElementOptionsPanel.this.table.getProvider()).getNextID(), FilterExpressionOperatorEnum.EQUALS);
			newFilterExpressionElement.setParent(EventTypeElementOptionsPanel.this.element);
			EventTypeElementOptionsPanel.this.tree.addElement(newFilterExpressionElement);
			EventTypeElementOptionsPanel.this.provider.setRootElements(EventTypeElementOptionsPanel.this.tree.getRoots());
			EventTypeElementOptionsPanel.this.table.getSelectedElements().clear();
			target.add(EventTypeElementOptionsPanel.this.table);
			EventTypeElementOptionsPanel.this.panel.updateOnTreeElementSelection(target);
		}
	};
	this.layoutForm.add(addFilterExpressionButton);
}
 
Example 26
Project: engerek   File: WebComponentUtil.java   View source code 6 votes vote down vote up
public static DateValidator getRangeValidator(Form<?> form, ItemPath path) {
    DateValidator validator = null;
    List<DateValidator> validators = form.getBehaviors(DateValidator.class);
    if (validators != null) {
        for (DateValidator val : validators) {
            if (path.equivalent(val.getIdentifier())) {
                validator = val;
                break;
            }
        }
    }

    if (validator == null) {
        validator = new DateValidator();
        validator.setIdentifier(path);
        form.add(validator);
    }

    return validator;
}
 
Example 27
Project: vlo-curation   File: AvailabilityFacetPanel.java   View source code 6 votes vote down vote up
public AvailabilityFacetPanel(String id, final IModel<QueryFacetsSelection> selectionModel, FacetFieldsModel facetFieldsModel) {
    super(id, selectionModel);
    this.facetFieldsModel = facetFieldsModel;
    this.availabilityLevels = ImmutableList.copyOf(getLevelsFromConfig(vloConfig));

    final AvailabilityValuesProvider valuesProvider = new AvailabilityValuesProvider();
    add(new Form("availability")
            .add(new AvailabilityDataView("option", valuesProvider))
            .add(indicatorAppender)
    );

    if (selectionModel.getObject().getSelectionValues(AVAILABILITY_FIELD) != null) {
        //if there any selection, make initially expanded
        getExpansionModel().setObject(ExpansionState.EXPANDED);
    }
}
 
Example 28
Project: karate   File: HomePanel.java   View source code 5 votes vote down vote up
private void setUpPanel(String id) {
    setDefaultModel(new CompoundPropertyModel(this));
    Form form = new Form("form") {
        @Override
        protected void onSubmit() {
            logger.debug("text is: {}", text);
            KarateSession session = service.createSession("dev", text);
            setResponsePage(new FeaturePage(session.getId()));
        }
    };
    form.add(new TextArea("text"));
    add(form);
    add(new FeedbackPanel("feedback"));
}
 
Example 29
Project: gitplex-mit   File: ConcreteListPropertyEditor.java   View source code 5 votes vote down vote up
private WebMarkupContainer addRow(final RepeatingView rows, Serializable element) {
	final WebMarkupContainer row = new WebMarkupContainer(rows.newChildId());
	row.setOutputMarkupId(true);
	rows.add(row);
	
	RepeatingView columns = new RepeatingView("properties");
	row.add(columns);
	
	for (PropertyContext<Serializable> propertyContext: propertyContexts) {
		WebMarkupContainer column = new WebMarkupContainer(columns.newChildId());
		column.add(AttributeAppender.append("class", " " + propertyContext.getPropertyName()));
		columns.add(column);
		
		Serializable propertyValue = (Serializable) propertyContext.getPropertyValue(element);
		PropertyEditor<?> propertyEditor = propertyContext.renderForEdit("propertyEditor", Model.of(propertyValue));
		column.add(propertyEditor);
		column.add(new FencedFeedbackPanel("feedback", propertyEditor));
	}
	
	row.add(new AjaxButton("deleteElement") {

		@Override
		protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
			super.onSubmit(target, form);
			
			target.appendJavaScript($(row).chain("remove").get());
			rows.remove(row);

			if (rows.size() == 0) {
				WebMarkupContainer table = (WebMarkupContainer) ConcreteListPropertyEditor.this.get("listEditor");
				target.add(table.get("noElementsRow"));
			}
			send(ConcreteListPropertyEditor.this, Broadcast.BUBBLE, new EditorChanged(target));								
		}

	}.setDefaultFormProcessing(false));
	
	return row;
}
 
Example 30
Project: gitplex-mit   File: NewProjectPage.java   View source code 5 votes vote down vote up
@Override
protected void onInitialize() {
	super.onInitialize();
	
	Project project = new Project();
	
	BeanEditor<?> editor = BeanContext.editBean("editor", project);
	
	Form<?> form = new Form<Void>("form") {

		@Override
		protected void onSubmit() {
			super.onSubmit();
			
			ProjectManager projectManager = GitPlex.getInstance(ProjectManager.class);
			Project projectWithSameName = projectManager.find(project.getName());
			if (projectWithSameName != null) {
				editor.getErrorContext(new PathSegment.Property("name"))
						.addError("This name has already been used by another project");
			} else {
				projectManager.save(project, null);
				Session.get().success("New project created");
				setResponsePage(ProjectBlobPage.class, ProjectBlobPage.paramsOf(project));
			}
		}
		
	};
	form.add(editor);
	
	add(form);
}
 
Example 31
Project: gitplex-mit   File: CommitMessageTransformPage.java   View source code 5 votes vote down vote up
@Override
protected void onInitialize() {
	super.onInitialize();
	
	Form<?> form = new Form<Void>("commitMessageTransformSetting") {

		@Override
		protected void onSubmit() {
			super.onSubmit();
			GitPlex.getInstance(ProjectManager.class).save(getProject());
			Session.get().success("Commit message transform setting is updated");
		}
		
	};
	form.add(new ReflectionPropertyEditor("editor", new PropertyDescriptor(Project.class, "commitMessageTransformSetting"), new IModel<Serializable>() {

		@Override
		public void detach() {
		}

		@Override
		public Serializable getObject() {
			return getProject().getCommitMessageTransformSetting();
		}

		@Override
		public void setObject(Serializable object) {
			getProject().setCommitMessageTransformSetting((CommitMessageTransformSetting) object);
		}

	}));

	add(form);
}
 
Example 32
Project: gitplex-mit   File: PasswordEditPage.java   View source code 5 votes vote down vote up
@Override
protected void onInitialize() {
	super.onInitialize();
	
	PasswordEditBean bean = new PasswordEditBean();
	
	Set<String> excludedProperties = new HashSet<>();
	
	// in case administrator changes password we do not ask for old password
	if (SecurityUtils.isAdministrator()) 
		excludedProperties.add("oldPassword");
	
	Form<?> form = new Form<Void>("form") {

		@Override
		protected void onSubmit() {
			super.onSubmit();
			getUser().setPassword(AppLoader.getInstance(PasswordService.class).encryptPassword(bean.getNewPassword()));
			GitPlex.getInstance(UserManager.class).save(getUser(), null);
			Session.get().success("Password has been changed");

			bean.setOldPassword(null);
			replace(BeanContext.editBean("editor", bean, excludedProperties));
		}

	};
	add(form);
	
	form.add(BeanContext.editBean("editor", bean, excludedProperties));
}
 
Example 33
Project: GeoCrawler   File: SeedPage.java   View source code 5 votes vote down vote up
private void addBaseForm() {
  Form<SeedList> form = new Form<SeedList>("seedList", getModel()) {
    @Override
    protected void onSubmit() {
      seedListService.save(getModelObject());
      setResponsePage(SeedListsPage.class);
    }
  };
  form.add(new TextField<String>("name"));
  add(form);
}
 
Example 34
Project: Unicorn   File: Scenario3Panel.java   View source code 5 votes vote down vote up
private void addEventsCheckBoxMultipleChoice(final Form<Void> layoutForm) {

		final List<String> fileNames = Arrays.asList("shipToEnns", "shipToEnns_additionalKremsToEnns");

		this.eventsCheckBoxMultipleChoice = new CheckBoxMultipleChoice<String>("eventsCheckBoxMultipleChoice", new PropertyModel<List<String>>(this, "selectedFiles"), fileNames);
		this.eventsCheckBoxMultipleChoice.setOutputMarkupId(true);
		layoutForm.add(this.eventsCheckBoxMultipleChoice);
	}
 
Example 35
Project: MBaaS   File: FileCreatePage.java   View source code 5 votes vote down vote up
@Override
protected void doInitialize(Border layout) {
    add(layout);

    this.form = new Form<>("form");
    layout.add(this.form);

    this.nameField = new TextField<>("nameField", new PropertyModel<>(this, "name"));
    this.nameField.setRequired(true);
    this.nameField.setLabel(Model.of("name"));
    this.form.add(nameField);
    this.nameFeedback = new TextFeedbackPanel("nameFeedback", this.nameField);
    this.form.add(nameFeedback);

    this.fileField = new FileUploadField("fileField", new PropertyModel<>(this, "file"));
    this.fileField.setRequired(true);
    this.form.add(this.fileField);
    this.fileFeedback = new TextFeedbackPanel("fileFeedback", this.fileField);
    this.form.add(fileFeedback);

    this.saveButton = new AjaxButton("saveButton");
    this.saveButton.setOnError(this::saveButtonOnError);
    this.saveButton.setOnSubmit(this::saveButtonOnSubmit);
    this.form.add(saveButton);

    this.closeButton = new BookmarkablePageLink<>("closeButton", FileBrowsePage.class);
    this.form.add(this.closeButton);
}
 
Example 36
Project: singular-server   File: FeedbackAposEnvioPanel.java   View source code 5 votes vote down vote up
private void addCloseButton() {
    modal.addButton(BSModalBorder.ButtonStyle.CANCEL, Shortcuts.$m.ofValue("Fechar"), new AjaxButton("close-button") {
        @Override
        protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
            super.onSubmit(target, form);
            getOnClose().ifPresent(f -> f.accept(target, modal));
            target.appendJavaScript("; window.close();");
        }
    });
}
 
Example 37
Project: engerek   File: ACAttributePanel.java   View source code 5 votes vote down vote up
protected void initLayout(boolean ignoreMandatoryAttributes) {
    Label attributeLabel = new Label(ID_ATTRIBUTE_LABEL, new PropertyModel(getModel(), ACAttributeDto.F_NAME));
    add(attributeLabel);

    WebMarkupContainer required = new WebMarkupContainer(ID_REQUIRED);
    required.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            ACAttributeDto dto = getModel().getObject();
            PrismPropertyDefinition def = dto.getDefinition();

            return def.isMandatory();
        }
    });
    add(required);

    WebMarkupContainer hasOutbound = new WebMarkupContainer(ID_HAS_OUTBOUND);
    hasOutbound.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            return hasOutbound();
        }
    });
    add(hasOutbound);


    ListView<ACValueConstructionDto> values = new ListView<ACValueConstructionDto>(ID_VALUES,
            new PropertyModel<List<ACValueConstructionDto>>(getModel(), ACAttributeDto.F_VALUES)) {

        @Override
        protected void populateItem(ListItem<ACValueConstructionDto> listItem) {
            Form form = findParent(Form.class);
            listItem.add(new ACAttributeValuePanel(ID_VALUE, listItem.getModel(), ignoreMandatoryAttributes, form));
        }
    };
    add(values);
}
 
Example 38
Project: singular-server   File: CachePanel.java   View source code 5 votes vote down vote up
@Override
protected void onInitialize() {
	super.onInitialize();
	
	add(new AjaxButton("clearAllCaches") {
		@Override
		protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
			adminFacade.clearCaches();
			
			new SingularToastrHelper(this).
				addToastrMessage(ToastrType.SUCCESS, "Caches cleaned!");
		}
	});
	
}
 
Example 39
Project: Unicorn   File: ChartConfigurationPanel.java   View source code 5 votes vote down vote up
public ChartConfigurationPanel(final String id, final AttributeChartPage visualisationPage) {
	super(id);
	this.panel = this;

	this.parentPage = visualisationPage;

	this.layoutForm = new Form<Void>("layoutForm");
	this.add(this.layoutForm);
	this.addFeedbackPanel(this.layoutForm);

	this.layoutForm.add(this.addChartTitleInput());
	this.layoutForm.add(this.addChartTypeSelect());
	this.layoutForm.add(this.addEventTypeSelect());
	this.updateAttributes();
	this.layoutForm.add(this.addAttributeSelect());

	this.sliderContainer = new WebMarkupContainer("sliderDiv") {
		@Override
		public boolean isVisible() {
			return ChartConfigurationPanel.this.isSliderVisible();
		}

		;
	};
	this.sliderContainer.setOutputMarkupPlaceholderTag(true);
	this.sliderContainer.add(this.addSlider());
	this.sliderContainer.add(this.addSliderLabel());
	this.layoutForm.add(this.sliderContainer);

	this.addButtonsToForm(this.layoutForm);
}
 
Example 40
Project: Unicorn   File: BPMNProcessUploadPanel.java   View source code 5 votes vote down vote up
private void createProcessEditModalWindow(final Form<Void> layoutForm) {
	this.processEditorModal = new ProcessEditorModal("processEditorModal", this.processSelect);
	this.add(this.processEditorModal);

	layoutForm.add(new AjaxLink<Void>("showProcessEditModal") {

		private static final long serialVersionUID = 1L;

		@Override
		public void onClick(final AjaxRequestTarget target) {
			BPMNProcessUploadPanel.this.processEditorModal.show(target);
		}
	});
}