Java Code Examples for org.apache.wicket.markup.html.form.Button#add()
The following examples show how to use
org.apache.wicket.markup.html.form.Button#add() .
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: ModalInstancePage.java From ontopia with Apache License 2.0 | 6 votes |
public ModalInstancePage(String id, TopicModel<Topic> topicModel, TopicTypeModel topicTypeModel, FieldsViewModel fieldsViewModel) { super(id); this.topicModel = topicModel; this.topicTypeModel = topicTypeModel; this.fieldsViewModel = fieldsViewModel; // page is read-only if topic type is read-only this.isReadOnly = ((topicTypeModel != null && topicTypeModel.getTopicType().isReadOnly()) || (Objects.equals(getRequest().getParameter("ro"), "true"))); this.popupContent = new WebMarkupContainer("popupContent"); popupContent.setOutputMarkupId(true); add(popupContent); popupContent.add(createInstancePanel("instancePanel")); Button closeOkButton = new Button("closeOK"); closeOkButton.add(new AjaxFormComponentUpdatingBehavior("onclick") { @Override protected void onUpdate(AjaxRequestTarget target) { onCloseOk(target); } }); popupContent.add(closeOkButton); }
Example 2
Source File: AssociationTransformFunctionBoxPanel.java From ontopia with Apache License 2.0 | 6 votes |
public AssociationTransformFunctionBoxPanel(String id, final TopicModel<Topic> topicModel) { super(id); add(new Label("title", new ResourceModel("transform.association.instances"))); Button addButton = new Button("button", new ResourceModel("transform")); addButton.add(new AjaxFormComponentUpdatingBehavior("onclick") { @Override protected void onUpdate(AjaxRequestTarget target) { Topic instance = topicModel.getTopic(); Map<String,String> pageParametersMap = new HashMap<String,String>(); pageParametersMap.put("topicMapId", instance.getTopicMap().getId()); pageParametersMap.put("topicId", instance.getId()); setResponsePage(AssociationTransformPage.class, new PageParameters(pageParametersMap)); } }); add(addButton); }
Example 3
Source File: OrienteerBasePage.java From Orienteer with Apache License 2.0 | 6 votes |
private WebMarkupContainer createPerspectivesContainer(String id, IModel<ODocument> perspectiveModel, IModel<List<ODocument>> perspectivesModel) { return new WebMarkupContainer(id) { @Override protected void onInitialize() { super.onInitialize(); add(createPerspectivesList("perspectives", perspectivesModel)); Button perspectiveButton = new Button("perspectiveButton"); perspectiveButton.add(new FAIcon("icon", new PropertyModel<>(perspectiveModel, "icon"))); perspectiveButton.add(new Label("name", new ODocumentNameModel(perspectiveModel))); add(perspectiveButton); setOutputMarkupPlaceholderTag(true); } @Override protected void onConfigure() { super.onConfigure(); List<ODocument> perspectives = perspectivesModel.getObject(); setVisible(perspectives != null && perspectives.size() > 1); } }; }
Example 4
Source File: AdministrationUserGroupPortfolioPage.java From artifact-listener with Apache License 2.0 | 5 votes |
public AdministrationUserGroupPortfolioPage(PageParameters parameters) { super(parameters); addBreadCrumbElement(new BreadCrumbElement(new ResourceModel("navigation.administration.usergroup"), AdministrationUserGroupPortfolioPage.linkDescriptor())); IModel<List<UserGroup>> userGroupListModel = new LoadableDetachableModel<List<UserGroup>>() { private static final long serialVersionUID = -4518288683578265677L; @Override protected List<UserGroup> load() { return userGroupService.list(); } }; add(new UserGroupPortfolioPanel("portfolio", userGroupListModel, configurer.getPortfolioItemsPerPage())); // User group create popup UserGroupFormPopupPanel userGroupCreatePanel = new UserGroupFormPopupPanel("userGroupCreatePopupPanel"); add(userGroupCreatePanel); Button createUserGroup = new Button("createUserGroup"); createUserGroup.add(new AjaxModalOpenBehavior(userGroupCreatePanel, MouseEvent.CLICK) { private static final long serialVersionUID = 5414159291353181776L; @Override protected void onShow(AjaxRequestTarget target) { } }); add(createUserGroup); }
Example 5
Source File: LoginPage.java From webanno with Apache License 2.0 | 5 votes |
public LoginPage() { setStatelessHint(true); setVersioned(false); add(form = new LoginForm("loginForm")); signInBtn = new Button("signInBtn"); signInBtn.add(LambdaBehavior.enabledWhen(() -> !isTooManyUsers())); tooManyUsersLabel = new WebMarkupContainer("usersLabel"); tooManyUsersLabel.add(LambdaBehavior.visibleWhen(this::isTooManyUsers)); form.add(signInBtn); form.add(tooManyUsersLabel); form.add(LambdaBehavior.enabledWhen(() -> !isTooManyUsers())); redirectIfAlreadyLoggedIn(); // Create admin user if there is no user yet if (userRepository.list().isEmpty()) { User admin = new User(); admin.setUsername(ADMIN_DEFAULT_USERNAME); admin.setPassword(ADMIN_DEFAULT_PASSWORD); admin.setEnabled(true); admin.setRoles(EnumSet.of(Role.ROLE_ADMIN, Role.ROLE_USER)); userRepository.create(admin); String msg = "No user accounts have been found. An admin account has been created: " + ADMIN_DEFAULT_USERNAME + "/" + ADMIN_DEFAULT_PASSWORD; // We log this as a warning so the message sticks on the screen. Success and info // messages are set to auto-close after a short time. warn(msg); } }
Example 6
Source File: AdministrationUserPortfolioPage.java From artifact-listener with Apache License 2.0 | 5 votes |
public AdministrationUserPortfolioPage(PageParameters parameters) { super(parameters); addBreadCrumbElement(new BreadCrumbElement(new ResourceModel("navigation.administration.user"), AdministrationUserPortfolioPage.linkDescriptor())); IModel<String> searchTermModel = Model.of(""); UserPortfolioPanel portfolioPanel = new UserPortfolioPanel("portfolio", new UserDataProvider(searchTermModel), configurer.getPortfolioItemsPerPage()); add(portfolioPanel); add(new AdministrationUserSearchPanel("searchPanel", portfolioPanel.getPageable(), searchTermModel)); // User create popup UserFormPopupPanel userCreatePanel = new UserFormPopupPanel("userCreatePopupPanel"); add(userCreatePanel); Button createUser = new Button("createUser"); createUser.add(new AjaxModalOpenBehavior(userCreatePanel, MouseEvent.CLICK) { private static final long serialVersionUID = 5414159291353181776L; @Override protected void onShow(AjaxRequestTarget target) { } }); add(createUser); }
Example 7
Source File: ProjectListPage.java From artifact-listener with Apache License 2.0 | 5 votes |
public ProjectListPage(PageParameters parameters) { super(parameters); String term = parameters.get(LinkUtils.SEARCH_TERM_PARAMETER).toString(); long pageNumber = LinkUtils.extractPageNumberParameter(parameters); IModel<String> searchTermModel = Model.of(term); addBreadCrumbElement(new BreadCrumbElement(new ResourceModel("project.list.pageTitle"), ProjectListPage.linkDescriptor())); // Add project button final ProjectFormPopupPanel addProjectPopup = new ProjectFormPopupPanel("addProjectPopup", FormPanelMode.ADD); add(addProjectPopup); Button addProjectButton = new AuthenticatedOnlyButton("addProject") { private static final long serialVersionUID = 1L; @Override protected void onConfigure() { super.onConfigure(); setVisible(MavenArtifactNotifierSession.get().hasRoleAdmin()); } }; addProjectButton.add(new AjaxModalOpenBehavior(addProjectPopup, MouseEvent.CLICK)); add(addProjectButton); // Page content ProjectPortfolioPanel portfolioPanel = new ProjectPortfolioPanel("portfolio", new ProjectDataProvider(searchTermModel), configurer.getPortfolioItemsPerPage()); portfolioPanel.getPageable().setCurrentPage(pageNumber); add(portfolioPanel); add(new ProjectSearchPanel("searchPanel", portfolioPanel.getPageable(), searchTermModel)); }
Example 8
Source File: ProjectPortfolioPanel.java From artifact-listener with Apache License 2.0 | 5 votes |
@Override protected MarkupContainer getEditLink(String id, final IModel<? extends Project> projectModel) { Button editLink = new Button(id); editLink.add(new AjaxModalOpenBehavior(editProjectPopup, MouseEvent.CLICK) { private static final long serialVersionUID = 1L; @Override protected void onShow(AjaxRequestTarget target) { editProjectPopup.getModel().setObject(projectModel.getObject()); } }); return editLink; }
Example 9
Source File: SingleButtonPanel.java From projectforge-webapp with GNU General Public License v3.0 | 5 votes |
/** * * @param id * @param button * @param label * @param classnames css class names */ public SingleButtonPanel(final String id, final Button button, final IModel<String> label, final String... classnames) { super(id); this.button = button; add(button); button.add(new Label("label", label).setRenderBodyOnly(true)); if (classnames != null) { button.add(AttributeModifier.append("class", StringHelper.listToString(" ", classnames))); } }
Example 10
Source File: ButtonPanel.java From projectforge-webapp with GNU General Public License v3.0 | 5 votes |
public ButtonPanel(final String id, final String title, final Button button, final ButtonType... buttonTypes) { super(id); this.button = button; button.add(new Label("title", title)); for (final ButtonType buttonType : buttonTypes) { button.add(AttributeModifier.append("class", buttonType.getClassAttrValue())); } add(button); }
Example 11
Source File: ButtonPanel.java From projectforge-webapp with GNU General Public License v3.0 | 5 votes |
public ButtonPanel(final String id, final String label, final ButtonType... buttonTypes) { super(id); button = new Button(BUTTON_ID, new Model<String>(label)); button.add(new Label("title", label)); for (final ButtonType buttonType : buttonTypes) { button.add(AttributeModifier.append("class", buttonType.getClassAttrValue())); } add(button); }
Example 12
Source File: UserEditForm.java From projectforge-webapp with GNU General Public License v3.0 | 5 votes |
@SuppressWarnings("serial") public static void createAuthenticationToken(final GridBuilder gridBuilder, final PFUserDO user, final UserDao userDao, final Form< ? > form) { // Authentication token final FieldsetPanel fs = gridBuilder.newFieldset(gridBuilder.getString("user.authenticationToken")).suppressLabelForWarning(); fs.add(new DivTextPanel(fs.newChildId(), new Model<String>() { @Override public String getObject() { if (PFUserContext.getUserId().equals(user.getId()) == true) { return userDao.getAuthenticationToken(user.getId()); } else { // Administrators shouldn't see the token. return "*****"; } } })); fs.addHelpIcon(gridBuilder.getString("user.authenticationToken.tooltip")); final Button button = new Button(SingleButtonPanel.WICKET_ID, new Model<String>("renewAuthenticationKey")) { @Override public final void onSubmit() { userDao.renewAuthenticationToken(user.getId()); form.error(getString("user.authenticationToken.renew.successful")); } }; button.add(WicketUtils.javaScriptConfirmDialogOnClick(form.getString("user.authenticationToken.renew.securityQuestion"))); fs.add(new SingleButtonPanel(fs.newChildId(), button, gridBuilder.getString("user.authenticationToken.renew"), SingleButtonPanel.DANGER)); WicketUtils.addTooltip(button, gridBuilder.getString("user.authenticationToken.renew.tooltip")); }
Example 13
Source File: AbstractMassEditForm.java From projectforge-webapp with GNU General Public License v3.0 | 4 votes |
@SuppressWarnings("serial") @Override protected void init() { super.init(); feedbackPanel = new FeedbackPanel("feedback"); feedbackPanel.setOutputMarkupId(true); add(feedbackPanel); gridBuilder = newGridBuilder(this, "flowform"); actionButtons = new MyComponentsRepeater<SingleButtonPanel>("buttons"); add(actionButtons.getRepeatingView()); { final Button cancelButton = new Button("button", new Model<String>("cancel")) { @Override public final void onSubmit() { parentPage.cancel(); } }; cancelButton.setDefaultFormProcessing(false); // No validation of the final SingleButtonPanel cancelButtonPanel = new SingleButtonPanel(actionButtons.newChildId(), cancelButton, getString("cancel"), SingleButtonPanel.CANCEL); actionButtons.add(cancelButtonPanel); } { final Button updateAllButton = new Button("button", new Model<String>("updateAll")) { @Override public final void onSubmit() { parentPage.updateAll(); } }; final SingleButtonPanel updateAllButtonPanel = new SingleButtonPanel(actionButtons.newChildId(), updateAllButton, getString("updateAll"), SingleButtonPanel.DEFAULT_SUBMIT); updateAllButton.add(AttributeModifier.replace("onclick", "return showUpdateQuestionDialog()")); actionButtons.add(updateAllButtonPanel); setDefaultButton(updateAllButton); } }
Example 14
Source File: SendSmsForm.java From projectforge-webapp with GNU General Public License v3.0 | 4 votes |
@Override @SuppressWarnings("serial") protected void init() { super.init(); FieldsetPanel fs = gridBuilder.newFieldset(getString("address.sendSms.phoneNumber")); final PFAutoCompleteTextField<String> numberTextField = new PFAutoCompleteTextField<String>(InputPanel.WICKET_ID, new PropertyModel<String>(data, "phoneNumber")) { @Override protected List<String> getChoices(final String input) { final AddressFilter addressFilter = new AddressFilter(); addressFilter.setSearchString(input); final List<String> list = new ArrayList<String>(); for (final AddressDO address : addressDao.getList(addressFilter)) { buildAutocompleteEntry(list, address, address.getMobilePhone()); buildAutocompleteEntry(list, address, address.getPrivateMobilePhone()); } return list; } @Override protected List<String> getFavorites() { return getRecentSearchTermsQueue().getRecents(); } }; numberTextField.withMatchContains(true).withMinChars(2).withFocus(true); numberTextField.setRequired(true); fs.add(numberTextField); data.setMessage(getInitalMessageText()); fs = gridBuilder.newFieldset(getString("address.sendSms.message")); final MaxLengthTextArea messageTextArea = new MaxLengthTextArea(TextAreaPanel.WICKET_ID, new PropertyModel<String>(data, "message"), MAX_MESSAGE_LENGTH); // messageTextArea.add(AttributeModifier.append("onKeyDown", "limitText(this.form.limitedtextarea,this.form.countdown," // + MAX_MESSAGE_LENGTH // + ")")); // messageTextArea.add(AttributeModifier.append("onKeyUp", "limitText(this.form.limitedtextarea,this.form.countdown," // + MAX_MESSAGE_LENGTH // + ")")); messageTextArea.add(AttributeModifier.append("maxlength", MAX_MESSAGE_LENGTH)); fs.add(messageTextArea); fs = gridBuilder.newFieldset(""); final DivTextPanel charsRemaining = new DivTextPanel(fs.newChildId(), ""); charsRemaining.setMarkupId("charsRemaining"); fs.add(charsRemaining); { final Button resetButton = new Button(SingleButtonPanel.WICKET_ID, new Model<String>("reset")) { @Override public final void onSubmit() { data.setMessage(getInitalMessageText()); data.setPhoneNumber(""); numberTextField.modelChanged(); messageTextArea.modelChanged(); } }; resetButton.setDefaultFormProcessing(false); final SingleButtonPanel resetButtonPanel = new SingleButtonPanel(actionButtons.newChildId(), resetButton, getString("reset"), SingleButtonPanel.RESET); actionButtons.add(resetButtonPanel); final Button sendButton = new Button(SingleButtonPanel.WICKET_ID, new Model<String>("send")) { @Override public final void onSubmit() { parentPage.send(); } }; sendButton.add(AttributeModifier.replace("onclick", "return showSendQuestionDialog();")); final SingleButtonPanel sendButtonPanel = new SingleButtonPanel(actionButtons.newChildId(), sendButton, getString("send"), SingleButtonPanel.DEFAULT_SUBMIT); actionButtons.add(sendButtonPanel); setDefaultButton(sendButton); } }
Example 15
Source File: InstanceSearchPanel.java From ontopia with Apache License 2.0 | 4 votes |
public InstanceSearchPanel(String id, TopicTypeModel model) { super(id, model); final TopicTypeModel topicTypeModel = model; final AjaxOntopolyTextField searchField = new AjaxOntopolyTextField("searchField", new Model<String>("")); add(searchField); final IModel<List<Topic>> searchResultModel = new LoadableDetachableModel<List<Topic>>() { @Override protected List<Topic> load() { try { errorInSearch = false; return topicTypeModel.getTopicType().searchAll(searchField.getModel().getObject()); } catch(Exception e) { errorInSearch = true; return Collections.emptyList(); } } }; final WebMarkupContainer searchResultContainer = new WebMarkupContainer("searchResultContainer") { @Override public boolean isVisible() { return searchResultModel.getObject().isEmpty() ? false : true; } }; searchResultContainer.setOutputMarkupPlaceholderTag(true); add(searchResultContainer); final WebMarkupContainer unsuccessfulSearchContainer = new WebMarkupContainer("unsuccessfulSearchContainer") { @Override public boolean isVisible() { return !searchField.getModel().getObject().equals("") && searchResultModel.getObject().isEmpty() ? true : false; } }; unsuccessfulSearchContainer.setOutputMarkupPlaceholderTag(true); add(unsuccessfulSearchContainer); Button button = new Button("searchButton", new ResourceModel("button.find")); button.add(new AjaxFormComponentUpdatingBehavior("onclick") { @Override protected void onUpdate(AjaxRequestTarget target) { if(target != null) { target.addComponent(searchResultContainer); target.addComponent(unsuccessfulSearchContainer); } } }); add(button); Label message = new Label("message", new ResourceModel(errorInSearch ? "search.error" : "search.empty")); unsuccessfulSearchContainer.add(message); ListView<Topic> searchResult = new ListView<Topic>("searchResult", searchResultModel) { @Override protected void populateItem(ListItem<Topic> item) { Topic topic = item.getModelObject(); TopicMap topicMap = topic.getTopicMap(); Map<String,String> pageParametersMap = new HashMap<String,String>(); pageParametersMap.put("topicMapId", topicMap.getId()); pageParametersMap.put("topicId", topic.getId()); pageParametersMap.put("topicTypeId", topicTypeModel.getTopicType().getId()); // link to instance item.add(new OntopolyBookmarkablePageLink("topic", InstancePage.class, new PageParameters(pageParametersMap), topic.getName())); // link to type Iterator<TopicType> it = topic.getTopicTypes().iterator(); if (it.hasNext()) { TopicType tt = it.next(); if(!tt.isSystemTopic()) { pageParametersMap.put("topicId", tt.getId()); item.add(new OntopolyBookmarkablePageLink("topicType", InstancesPage.class, new PageParameters(pageParametersMap), tt.getName())); } else { item.add(new Label("topicType")); } } else { item.add(new Label("topicType")); } } }; searchResultContainer.add(searchResult); }
Example 16
Source File: UserGroupDescriptionPanel.java From artifact-listener with Apache License 2.0 | 4 votes |
public UserGroupDescriptionPanel(String id, final IModel<UserGroup> userGroupModel) { super(id, userGroupModel); add(new WebMarkupContainer("lockedWarningContainer") { private static final long serialVersionUID = -6522648858912041466L; @Override protected void onConfigure() { super.onConfigure(); setVisible(userGroupModel.getObject().isLocked()); } }); add(new MultiLineLabel("description", BindingModel.of(userGroupModel, Binding.userGroup().description()))); add(new ListView<Authority>("authorities", Model.ofList(authorityUtils.getPublicAuthorities())) { private static final long serialVersionUID = -4307272691513553800L; @Override protected void populateItem(ListItem<Authority> item) { Authority authority = item.getModelObject(); item.add(new Label("authorityName", new ResourceModel( "administration.usergroup.authority." + authority.getName()))); item.add(new BooleanIcon("authorityCheck", Model.of( userGroupModel.getObject().getAuthorities().contains(authority)))); } }); // User group update popup UserGroupFormPopupPanel userGroupUpdatePanel = new UserGroupFormPopupPanel("userGroupUpdatePopupPanel", getModel()); add(userGroupUpdatePanel); Button updateUserGroup = new Button("updateUserGroup") { private static final long serialVersionUID = 993019796184673872L; @Override protected void onConfigure() { super.onConfigure(); setVisible(!UserGroupDescriptionPanel.this.getModelObject().isLocked()); } }; updateUserGroup.add(new AjaxModalOpenBehavior(userGroupUpdatePanel, MouseEvent.CLICK) { private static final long serialVersionUID = 5414159291353181776L; @Override protected void onShow(AjaxRequestTarget target) { } }); add(updateUserGroup); }
Example 17
Source File: CreateNewTopicMapPanel.java From ontopia with Apache License 2.0 | 4 votes |
public CreateNewTopicMapPanel(String id) { super(id); IModel<List<TopicMapSource>> sourcesChoicesModel = new LoadableDetachableModel<List<TopicMapSource>>() { @Override protected List<TopicMapSource> load() { List<TopicMapSource> result = OntopolyContext.getOntopolyRepository().getEditableSources(); numberOfSources = result.size(); return result; } }; List<TopicMapSource> sources = sourcesChoicesModel.getObject(); TopicMapSourceModel topicMapSourceModel = null; if (numberOfSources > 0) { topicMapSourceModel = new TopicMapSourceModel((TopicMapSource)sources.get(0)); } WebMarkupContainer sourcesDropDownContainer = new WebMarkupContainer("sourcesDropDownContainer") { @Override public boolean isVisible() { return numberOfSources > 1 ? true : false; } }; sourcesDropDownContainer.setOutputMarkupPlaceholderTag(true); add(sourcesDropDownContainer); final AjaxOntopolyDropDownChoice<TopicMapSource> sourcesDropDown = new AjaxOntopolyDropDownChoice<TopicMapSource>("sourcesDropDown", topicMapSourceModel, sourcesChoicesModel, new ChoiceRenderer<TopicMapSource>("title", "id")); sourcesDropDownContainer.add(sourcesDropDown); final AjaxOntopolyTextField nameField = new AjaxOntopolyTextField("content", new Model<String>("")); add(nameField); final Button button = new Button("button", new ResourceModel("create")); button.setOutputMarkupId(true); button.add(new AjaxFormComponentUpdatingBehavior("onclick") { @Override protected void onUpdate(AjaxRequestTarget target) { String name = nameField.getModel().getObject(); if(!name.isEmpty()) { TopicMapSource topicMapSource = (TopicMapSource) sourcesDropDown.getModelObject(); String referenceId = OntopolyContext.getOntopolyRepository().createOntopolyTopicMap(topicMapSource.getId(), name); Map<String,String> pageParametersMap = new HashMap<String,String>(); pageParametersMap.put("topicMapId", referenceId); setResponsePage(TopicTypesPage.class, new PageParameters(pageParametersMap)); } } }); add(button); }
Example 18
Source File: AssociationTransformPage.java From ontopia with Apache License 2.0 | 4 votes |
private void createPanel() { Form<Object> form = new Form<Object>("form"); add(form); AssociationType associationType = getAssociationType(); // get used role type combinations Collection<List<RoleType>> roleCombos = associationType.getUsedRoleTypeCombinations(); // then remove the combination that is valid according to declaration List<RoleType> declaredRoleTypes = associationType.getDeclaredRoleTypes(); Collections.sort(declaredRoleTypes, new Comparator<RoleType>() { @Override public int compare(RoleType rt1, RoleType rt2) { return ObjectIdComparator.INSTANCE.compare(rt1.getTopicIF(), rt2.getTopicIF()); } }); roleCombos.remove(declaredRoleTypes); RepeatingView rview = new RepeatingView("combos"); Iterator<List<RoleType>> citer = roleCombos.iterator(); while (citer.hasNext()) { List<RoleType> roleTypes = citer.next(); if (roleTypes.size() != declaredRoleTypes.size()) { citer.remove(); continue; } rview.add(new AssociationTransformerPanel(rview.newChildId(), associationType, roleTypes)); } form.add(rview); Label message = new Label("message", new ResourceModel("transform.association.instances.none")); message.setVisible(roleCombos.isEmpty()); form.add(message); Button button = new Button("button", new ResourceModel("button.ok")); button.setVisible(roleCombos.isEmpty()); button.add(new AjaxFormComponentUpdatingBehavior("onclick") { @Override protected void onUpdate(AjaxRequestTarget target) { Topic t = getAssociationType(); Map<String,String> pageParametersMap = new HashMap<String,String>(); pageParametersMap.put("topicMapId", t.getTopicMap().getId()); pageParametersMap.put("topicId", t.getId()); pageParametersMap.put("ontology", "true"); setResponsePage(InstancePage.class, new PageParameters(pageParametersMap)); } }); form.add(button); }