Java Code Examples for org.apache.wicket.markup.html.form.Button#setVisible()

The following examples show how to use org.apache.wicket.markup.html.form.Button#setVisible() . 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: AvatarEditPanel.java    From onedev with MIT License 4 votes vote down vote up
@Override
protected void onInitialize() {
	super.onInitialize();

	add(new UserAvatar("avatar", getUser().getId(), getUser().getDisplayName()));
	
	add(new Link<Void>("useDefault") {

		@Override
		protected void onConfigure() {
			super.onConfigure();
			setVisible(getAvatarManager().getUploaded(getUser()).exists());
		}

		@Override
		public void onClick() {
			getAvatarManager().useAvatar(getUser(), null);
			setResponsePage(getPage().getClass(), getPage().getPageParameters());
		}
		
	});

	Button uploadButton = new Button("upload");
	uploadButton.setVisible(false).setOutputMarkupPlaceholderTag(true);
	
	Form<?> form = new Form<Void>("form") {

		@Override
		protected void onSubmit() {
			super.onSubmit();
			AvatarManager avatarManager = OneDev.getInstance(AvatarManager.class);
           	avatarManager.useAvatar(getUser(), uploadedAvatarData);
			setResponsePage(getPage().getClass(), getPage().getPageParameters());
		}

		@Override
		public void onEvent(IEvent<?> event) {
			super.onEvent(event);
			if (event.getPayload() instanceof AvatarFileSelected) {
				AvatarFileSelected avatarFileSelected = (AvatarFileSelected) event.getPayload();
				uploadButton.setVisible(true);
				avatarFileSelected.getHandler().add(uploadButton);
			}
		}
	};

	PropertyModel<String> avatarDataModel = new PropertyModel<String>(this, "uploadedAvatarData");
	form.add(new AvatarUploadField("avatar", avatarDataModel));
	form.add(uploadButton);
	
	add(form);
}
 
Example 2
Source File: AvatarEditPage.java    From onedev with MIT License 4 votes vote down vote up
@Override
protected void onInitialize() {
	super.onInitialize();

	add(new ProjectAvatar("avatar", getProject()));
	
	add(new Link<Void>("useDefault") {

		@Override
		protected void onConfigure() {
			super.onConfigure();
			setVisible(getAvatarManager().getUploaded(getProject()).exists());
		}

		@Override
		public void onClick() {
			getAvatarManager().useAvatar(getProject(), null);
			setResponsePage(AvatarEditPage.class, AvatarEditPage.paramsOf(getProject()));
		}
		
	});

	Button uploadButton = new Button("upload");
	uploadButton.setVisible(false).setOutputMarkupPlaceholderTag(true);
	
	Form<?> form = new Form<Void>("form") {

		@Override
		protected void onSubmit() {
			super.onSubmit();
			AvatarManager avatarManager = OneDev.getInstance(AvatarManager.class);
           	avatarManager.useAvatar(getProject(), uploadedAvatarData);
			setResponsePage(AvatarEditPage.class, AvatarEditPage.paramsOf(getProject()));
		}

		@Override
		public void onEvent(IEvent<?> event) {
			super.onEvent(event);
			if (event.getPayload() instanceof AvatarFileSelected) {
				AvatarFileSelected avatarFileSelected = (AvatarFileSelected) event.getPayload();
				uploadButton.setVisible(true);
				avatarFileSelected.getHandler().add(uploadButton);
			}
		}
	};

	PropertyModel<String> avatarDataModel = new PropertyModel<String>(this, "uploadedAvatarData");
	form.add(new AvatarUploadField("avatar", avatarDataModel));
	form.add(uploadButton);
	
	add(form);
}
 
Example 3
Source File: AssociationTransformPage.java    From ontopia with Apache License 2.0 4 votes vote down vote up
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);    
}