Java Code Examples for org.apache.wicket.Component#isEnabledInHierarchy()

The following examples show how to use org.apache.wicket.Component#isEnabledInHierarchy() . 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: BootstrapDatePickerBehaviour.java    From pm-wicket-utils with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public void renderHead(Component component, IHeaderResponse response) {
	super.renderHead(component, response);
	Collection<SpecialDate> specialDates = getSpecialDates();

	if(component.isEnabledInHierarchy()){
		response.render(CssReferenceHeaderItem.forReference(DATE_PICKER_CSS));
		response.render(JavaScriptHeaderItem.forReference(DATE_PICKER_JAVASCRIPT));
		response.render(JavaScriptHeaderItem.forReference(DATE_PICKER_EXTENSION_JAVASCRIPT));
		if(!component.getLocale().getLanguage().equals("en")){
			response.render(JavaScriptHeaderItem.forReference(new JavaScriptResourceReference(BootstrapDatePickerBehaviour.class, "locales/bootstrap-datepicker."+component.getLocale().getLanguage()+".min.js")));
		}

		if(null != specialDates && !specialDates.isEmpty()) {
			StringBuilder sb = new StringBuilder();
			sb.append("[");
			DateFormat df = new SimpleDateFormat("yyyy-MM-dd");
			SpecialDate[] sdArray = specialDates.toArray(new SpecialDate[20]);
			for(int i = 0; i < specialDates.size(); ++i) {
				SpecialDate sd = sdArray[i];
				sb.append("{dt:new Date('"+df.format(sd.getDt())+"'), css:'"+sd.getCssClass()+"', tooltip:'"+ sd.getTooltip() +"'}");
				if(i < specialDates.size() - 1) {
					sb.append(",");
				}
			}
			sb.append("]");

			response.render(OnDomReadyHeaderItem.forScript("$(\"#"+component.getMarkupId()+"\").datepicker(null, "+sb.toString()+")"));
		} else {
			response.render(OnDomReadyHeaderItem.forScript("$(\"#"+component.getMarkupId()+"\").datepicker()"));
		}
	}
}
 
Example 2
Source File: BootstrapDatePickerBehaviour.java    From pm-wicket-utils with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public void onComponentTag(Component component, ComponentTag tag) {
	super.onComponentTag(component, tag);
	
	if(component.isEnabledInHierarchy()){
		tag.put("data-date-language", component.getLocale().getLanguage());
	}
}
 
Example 3
Source File: BootstrapDateTimePickerBehaviour.java    From pm-wicket-utils with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public void renderHead(Component component, IHeaderResponse response) 
{
	super.renderHead(component, response);
	
	if(component.isEnabledInHierarchy()) {
		
		response.render(CssReferenceHeaderItem.forReference(DATETIME_PICKER_CSS));
		response.render(JavaScriptHeaderItem.forReference(MOMENT_JAVASCRIPT));
		response.render(JavaScriptHeaderItem.forReference(DATETIME_PICKER_JAVASCRIPT));
		
		if(!component.getLocale().getLanguage().equals("en")) {
			
			response.render(JavaScriptHeaderItem.forReference(
								new JavaScriptResourceReference(BootstrapDateTimePickerBehaviour.class
															  , "locales/" + component.getLocale().getLanguage() + ".js")));
		}
		
		/** Not supporting special dates at the moment **/
		
		response.render(OnDomReadyHeaderItem.forScript("$(\"#" + component.getMarkupId() + "\").datetimepicker({ "
																									+ " format: 'DD/MM/YYYY HH:mm:ss',"
																									+ " icons: { "
																										+ " time: 'fa fa-clock-o',"
																										+ " date: 'fa fa-calendar',"
																										+ " up: 'fa fa-arrow-up',"
																										+ " down: 'fa fa-arrow-down',"
																										+ " previous: 'fa fa-arrow-left',"
																										+ " next: 'fa fa-arrow-right'"
																									+ "}"
																								+ "});"
				
		));
	}
}
 
Example 4
Source File: BootstrapDateTimePickerBehaviour.java    From pm-wicket-utils with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public void onComponentTag(Component component, ComponentTag tag) 
{
	super.onComponentTag(component, tag);
	
	if(component.isEnabledInHierarchy()) {
		
		tag.put("data-date-language", component.getLocale().getLanguage());
	}
}
 
Example 5
Source File: DatePicker.java    From pm-wicket-utils with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
public void renderHead(Component component, IHeaderResponse response) {
	response.render(CssReferenceHeaderItem.forReference(DATE_PICKER_DATE_CSS, "screen"));
	response.render(JavaScriptHeaderItem.forReference(DATE_PICKER_JS));
	response.render(JavaScriptHeaderItem.forReference(DATE_PICKER_ATTACH_JS));
	response.render(JavaScriptHeaderItem.forReference(DATE_PICKER_DATE_JS));
	
	if(component.isEnabledInHierarchy()){
		
		StringBuilder sb = new StringBuilder();
		sb.append("Date.defineParser(\"").append(getDatePattern()).append("\");");
		response.render(JavaScriptHeaderItem.forScript(sb.toString(), "pickerDatePattern"));
		
		sb = new StringBuilder();
		
		sb.append("new Picker.Date($(\"").append(component.getMarkupId()).append("\"), {");
		
		sb.append("format : \"").append(getDatePattern()).append("\",");
		sb.append("inject : $(\"").append(container.getMarkupId()).append("\"),");

		sb.append("months_abr : [");
		sb.append("\"Jan\",");
		sb.append("\"Fev\",");
		sb.append("\"Mar\",");
		sb.append("\"Abr\",");
		sb.append("\"Mai\",");
		sb.append("\"Jun\",");
		sb.append("\"Jul\",");
		sb.append("\"Ago\",");
		sb.append("\"Set\",");
		sb.append("\"Out\",");
		sb.append("\"Nov\",");
		sb.append("\"Dez\",");
		sb.append("],");

		sb.append("days_abr : [");
		sb.append("\"Seg\",");
		sb.append("\"Ter\",");
		sb.append("\"Qua\",");
		sb.append("\"Qui\",");
		sb.append("\"Sex\",");
		sb.append("\"Sab\",");
		sb.append("\"Dom\",");
		sb.append("],");
		
		sb.append("})");
		
		response.render(OnLoadHeaderItem.forScript(sb.toString()));
	}
}
 
Example 6
Source File: Command.java    From Orienteer with Apache License 2.0 4 votes vote down vote up
@Override
public boolean isEnabled(Component component) {
	return !component.isEnabledInHierarchy();
}