<commit_before>package de.atomfrede.mate.application.wicket;

import java.util.Properties;

import org.apache.wicket.AttributeModifier;
import org.apache.wicket.Component;
import org.apache.wicket.ajax.AjaxEventBehavior;
import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.behavior.AttributeAppender;
import org.apache.wicket.markup.head.CssHeaderItem;
import org.apache.wicket.markup.head.IHeaderResponse;
import org.apache.wicket.markup.html.GenericWebPage;
import org.apache.wicket.markup.html.link.Link;
import org.apache.wicket.model.IModel;
import org.apache.wicket.model.Model;
import org.apache.wicket.request.mapper.parameter.PageParameters;
import org.apache.wicket.request.resource.CssResourceReference;
import org.apache.wicket.spring.injection.annot.SpringBean;

import de.agilecoders.wicket.Bootstrap;
import de.agilecoders.wicket.markup.html.bootstrap.button.ButtonBehavior;
import de.agilecoders.wicket.markup.html.bootstrap.button.ButtonSize;
import de.agilecoders.wicket.markup.html.bootstrap.button.ButtonType;
import de.agilecoders.wicket.markup.html.bootstrap.button.TypedAjaxButton;
import de.agilecoders.wicket.markup.html.bootstrap.button.TypedButton;
import de.agilecoders.wicket.markup.html.bootstrap.button.TypedLink;
import de.agilecoders.wicket.markup.html.bootstrap.button.dropdown.MenuBookmarkablePageLink;
import de.agilecoders.wicket.markup.html.bootstrap.extensions.button.DropDownAutoOpen;
import de.agilecoders.wicket.markup.html.bootstrap.image.IconType;
import de.agilecoders.wicket.markup.html.bootstrap.navbar.ImmutableNavbarComponent;
import de.agilecoders.wicket.markup.html.bootstrap.navbar.Navbar;
import de.agilecoders.wicket.markup.html.bootstrap.navbar.NavbarButton;
import de.agilecoders.wicket.markup.html.bootstrap.navbar.NavbarComponents;
import de.agilecoders.wicket.markup.html.bootstrap.navbar.NavbarDropDownButton;
import de.atomfrede.mate.application.wicket.base.AbstractBasePage;
import de.atomfrede.mate.application.wicket.footer.Footer;
import de.atomfrede.mate.application.wicket.homepage.Homepage;
import de.atomfrede.mate.application.wicket.login.LoginPage;
import de.atomfrede.mate.application.wicket.logout.LogoutPage;
import de.atomfrede.mate.application.wicket.security.UserAuthModel;
import de.atomfrede.mate.application.wicket.security.UserSession;
import de.atomfrede.mate.domain.entities.user.User;
import de.atomfrede.mate.service.bottle.BottleService;
import de.atomfrede.mate.service.consumption.ConsumptionService;

public abstract class BasePage<T> extends GenericWebPage<T> {

	@SpringBean
	protected ConsumptionService consumptionService;
	
	@SpringBean
	protected BottleService bottleService;

	protected User currentUser;
	
	TypedLink<Void> bottleBtn;

	public BasePage() {
		super();
		commonInit(new PageParameters());
	}

	/**
	 * Construct.
	 * 
	 * @param model
	 *            The model to use for this page
	 */
	public BasePage(IModel<T> model) {
		super(model);
		commonInit(new PageParameters());
	}

	/**
	 * Construct.
	 * 
	 * @param parameters
	 *            current page parameters
	 */
	public BasePage(PageParameters parameters) {
		super(parameters);
		commonInit(parameters);
	}

	/**
	 * @return application properties
	 */
	public Properties getProperties() {
		return WicketApplication.get().getProperties();
	}

	@Override
	public void onBeforeRender(){
		super.onBeforeRender();
		System.out.println("Number of not consumed bottles "+bottleService.getNumberOfNotConsumedBottles());
		if(bottleService.getNumberOfNotConsumedBottles() == 0){
			bottleBtn.add(new AttributeAppender("class", " disabled"));
			bottleBtn.setEnabled(false);
		}else{
			bottleBtn.add(new AttributeModifier("class", "btn btn-block btn-large btn-primary"));
			bottleBtn.setEnabled(true);
		}
	}
	
	private void commonInit(PageParameters pageParameters) {

		currentUser = getSession().getUser().getObject();
		initConsumeButton();
		initCrateButton();
		initUserButton();

		
		add(newNavbar("navbar"));
		add(new Footer("footer"));
	}

	@SuppressWarnings("serial")
	protected void initUserButton() {
		TypedLink<Void> userAdminBtn = new TypedLink<Void>("btn-user-admin",
				ButtonType.Default) {

			@Override
			public void onClick() {
				// TODO Auto-generated method stub

			}
		};

		userAdminBtn.setIconType(IconType.user).setSize(ButtonSize.Large)
				.setLabel(Model.of("Mein Konto")).setInverted(false);
		
		add(userAdminBtn);
	}

	@SuppressWarnings("serial")
	protected void initCrateButton() {
		TypedLink<Void> createBtn = new TypedLink<Void>("btn-crate",
				ButtonType.Default) {

			@Override
			public void onClick() {
				bottleService.newCrate();
			}
		};

		createBtn.setIconType(IconType.gift).setSize(ButtonSize.Large);
		createBtn.setLabel(Model.of("Versorgung")).setInverted(false);

		add(createBtn);
	}

	@SuppressWarnings("serial")
	protected void initConsumeButton() {

		bottleBtn = new TypedLink<Void>("btn-get-bottle",
				ButtonType.Primary) {

			@Override
			public void onClick() {
				consumeClicked();

			}
		};
		bottleBtn.setIconType(IconType.briefcase);
		bottleBtn.setSize(ButtonSize.Large);
		bottleBtn.setLabel(Model.of("Erfrischung"));

		add(bottleBtn);
		<commit_msg>Changed Icon for "getting refresh" button.<commit_after>package de.atomfrede.mate.application.wicket;

import java.util.Properties;

import org.apache.wicket.AttributeModifier;
import org.apache.wicket.Component;
import org.apache.wicket.ajax.AjaxEventBehavior;
import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.behavior.AttributeAppender;
import org.apache.wicket.markup.head.CssHeaderItem;
import org.apache.wicket.markup.head.IHeaderResponse;
import org.apache.wicket.markup.html.GenericWebPage;
import org.apache.wicket.markup.html.link.Link;
import org.apache.wicket.model.IModel;
import org.apache.wicket.model.Model;
import org.apache.wicket.request.mapper.parameter.PageParameters;
import org.apache.wicket.request.resource.CssResourceReference;
import org.apache.wicket.spring.injection.annot.SpringBean;

import de.agilecoders.wicket.Bootstrap;
import de.agilecoders.wicket.markup.html.bootstrap.button.ButtonBehavior;
import de.agilecoders.wicket.markup.html.bootstrap.button.ButtonSize;
import de.agilecoders.wicket.markup.html.bootstrap.button.ButtonType;
import de.agilecoders.wicket.markup.html.bootstrap.button.TypedAjaxButton;
import de.agilecoders.wicket.markup.html.bootstrap.button.TypedButton;
import de.agilecoders.wicket.markup.html.bootstrap.button.TypedLink;
import de.agilecoders.wicket.markup.html.bootstrap.button.dropdown.MenuBookmarkablePageLink;
import de.agilecoders.wicket.markup.html.bootstrap.extensions.button.DropDownAutoOpen;
import de.agilecoders.wicket.markup.html.bootstrap.image.IconType;
import de.agilecoders.wicket.markup.html.bootstrap.navbar.ImmutableNavbarComponent;
import de.agilecoders.wicket.markup.html.bootstrap.navbar.Navbar;
import de.agilecoders.wicket.markup.html.bootstrap.navbar.NavbarButton;
import de.agilecoders.wicket.markup.html.bootstrap.navbar.NavbarComponents;
import de.agilecoders.wicket.markup.html.bootstrap.navbar.NavbarDropDownButton;
import de.atomfrede.mate.application.wicket.base.AbstractBasePage;
import de.atomfrede.mate.application.wicket.footer.Footer;
import de.atomfrede.mate.application.wicket.homepage.Homepage;
import de.atomfrede.mate.application.wicket.login.LoginPage;
import de.atomfrede.mate.application.wicket.logout.LogoutPage;
import de.atomfrede.mate.application.wicket.security.UserAuthModel;
import de.atomfrede.mate.application.wicket.security.UserSession;
import de.atomfrede.mate.domain.entities.user.User;
import de.atomfrede.mate.service.bottle.BottleService;
import de.atomfrede.mate.service.consumption.ConsumptionService;

public abstract class BasePage<T> extends GenericWebPage<T> {

	@SpringBean
	protected ConsumptionService consumptionService;
	
	@SpringBean
	protected BottleService bottleService;

	protected User currentUser;
	
	TypedLink<Void> bottleBtn;

	public BasePage() {
		super();
		commonInit(new PageParameters());
	}

	/**
	 * Construct.
	 * 
	 * @param model
	 *            The model to use for this page
	 */
	public BasePage(IModel<T> model) {
		super(model);
		commonInit(new PageParameters());
	}

	/**
	 * Construct.
	 * 
	 * @param parameters
	 *            current page parameters
	 */
	public BasePage(PageParameters parameters) {
		super(parameters);
		commonInit(parameters);
	}

	/**
	 * @return application properties
	 */
	public Properties getProperties() {
		return WicketApplication.get().getProperties();
	}

	@Override
	public void onBeforeRender(){
		super.onBeforeRender();
		if(bottleService.getNumberOfNotConsumedBottles() == 0){
			bottleBtn.add(new AttributeAppender("class", " disabled"));
			bottleBtn.setEnabled(false);
		}else{
			bottleBtn.add(new AttributeModifier("class", "btn btn-block btn-large btn-primary"));
			bottleBtn.setEnabled(true);
		}
	}
	
	private void commonInit(PageParameters pageParameters) {

		currentUser = getSession().getUser().getObject();
		initConsumeButton();
		initCrateButton();
		initUserButton();

		
		add(newNavbar("navbar"));
		add(new Footer("footer"));
	}

	@SuppressWarnings("serial")
	protected void initUserButton() {
		TypedLink<Void> userAdminBtn = new TypedLink<Void>("btn-user-admin",
				ButtonType.Default) {

			@Override
			public void onClick() {
				// TODO Auto-generated method stub

			}
		};

		userAdminBtn.setIconType(IconType.user).setSize(ButtonSize.Large)
				.setLabel(Model.of("Mein Konto")).setInverted(false);
		
		add(userAdminBtn);
	}

	@SuppressWarnings("serial")
	protected void initCrateButton() {
		TypedLink<Void> createBtn = new TypedLink<Void>("btn-crate",
				ButtonType.Default) {

			@Override
			public void onClick() {
				bottleService.newCrate();
			}
		};

		createBtn.setIconType(IconType.gift).setSize(ButtonSize.Large);
		createBtn.setLabel(Model.of("Versorgung")).setInverted(false);

		add(createBtn);
	}

	@SuppressWarnings("serial")
	protected void initConsumeButton() {

		bottleBtn = new TypedLink<Void>("btn-get-bottle",
				ButtonType.Primary) {

			@Override
			public void onClick() {
				consumeClicked();

			}
		};
		bottleBtn.setIconType(IconType.shoppingcart);
		bottleBtn.setSize(ButtonSize.Large);
		bottleBtn.setLabel(Model.of("Erfrischung"));

		add(bottleBtn);
		
{'fraction_non_alphanumeric': 0.12079112397491558, 'fraction_numerical': 0.0001929570670525808, 'mean_word_length': 5.313032886723508, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1569114', 'n_tokens_mistral': 3614, 'n_tokens_neox': 3385, 'n_words': 465}