I'm using the calendar of JFXtras, by default the events have 24 groups (categories) and I want to change them.
this is the default code :
public final static List<AppointmentGroup> DEFAULT_APPOINTMENT_GROUPS = IntStream.range(0, 24)
.mapToObj(i -> new Agenda.AppointmentGroupImpl()
.withStyleClass("group" + i)
.withDescription("group" + (i < 10 ? "0" : "") + i))
.collect(Collectors.toList());
final public static List<String> CATEGORIES = IntStream.range(0, 24)
.mapToObj(i -> new String("group" + (i < 10 ? "0" : "") + i))
.collect(Collectors.toList());
Well, an Appointment tells Agenda to what group it belongs. That AppointmentGroup provides the CSS class to use (for styling all appointments in the group). So the 24 predefined groups are just there because there is an associated definition present in Agenda.css.
https://github.com/JFXtras/jfxtras/blob/8.0/jfxtras-agenda/src/main/resources/jfxtras/internal/scene/control/skin/agenda/Agenda.css
Line 71
.group0 { -fx-background-color: #AC725E; -fx-fill: #AC725E; }
.group1 { -fx-background-color: #D06B64; -fx-fill: #D06B64; }
.group2 { -fx-background-color: #F83A22; -fx-fill: #F83A22; }
...
So if you create a new AppointmentGroup class, set a style class id (do not use existing id's like "group0", as is done in the code above, that is a bit useless), and then assign that AppointmentGroup to an Appointment, Agenda will render it use the style class. You then of course need to define that in a CSS file.
You can also override the styling of the existing group0, group1, ...
To give an idea..
1: Load your css-file
vbox_root.getStylesheets().add("/styles/styles.css");
2: Add new AppointmentGroups
agenda.appointmentGroups().add(new Agenda.AppointmentGroupImpl().withDescription("group24").withStyleClass("group24"));
agenda.appointmentGroups().add(new Agenda.AppointmentGroupImpl().withDescription("group25").withStyleClass("group25"));
agenda.appointmentGroups().add(new Agenda.AppointmentGroupImpl().withDescription("group26").withStyleClass("group26"));
agenda.appointmentGroups().add(new Agenda.AppointmentGroupImpl().withDescription("group27").withStyleClass("group27"));
3: Define in styles/styles.css your styles
.group24 {
-fx-background-color: #424242;
-fx-fill: #424242;
}
.group25 {
-fx-background-color: #CDCDCD;
-fx-fill: #CDCDCD;
}
.group26 {
-fx-background-color: #000000;
-fx-fill: #000000;
}
.group27 {
-fx-background-color: #000000;
-fx-fill: #000000;
}
Related
Currently im using ng2-date-picker node modules, also im using theme="dp-material" theme for this components. i want to override the css for that date picker components. Please help me on this. I tried the below css but no luck.
dp-date-picker {
color: #000;
&.dp-material{
&.dp-day-calendar{
color:red;
}
}
}
I used to do this for override this date picker ( ng2-date-picker ) an other css from module that are hard to change :
In *.ts
constructor(private elRef: ElementRef) {}
couleurBouton() {
var header = this.elRef.nativeElement.querySelector('.dp-nav-header');
if (header) {
header.style.color = "#c8960f";
}
var current = this.elRef.nativeElement.querySelector('.dp-current-month');
if (current) {
current.style.border = "1px solid #c8960f";
}
var selected = this.elRef.nativeElement.querySelector('.dp-selected');
if (selected) {
selected.style.background = "#c8960f";
}
}
In template :
<dp-date-picker (click)="couleurBouton()" theme="dp-material" mode="month" [(ngModel)]="selectedDate" placeholder="Date par mois" [config]="datePickerConfig"></dp-date-picker>
If someone have a solution more clean it will be a pleasure
I have a calendar which is working fine. it displays records on click and changes the colour to green or red. if records are available date will become red colored.
I don't want onclick I want calendar to displays date colours on
calendars onload event.** KIndly help. following is my code . I think problem with css, I guess
.postive-records .rf-cal-sel {
background-color: green;
}
.no-records .rf-cal-sel {
background-color: red;
}
<rich:calendar styleClass="#{eventMaster.eventMasterList!=null and eventMaster.eventMasterList.size()>0?'postive-records':'no-records'}" locale="EN"
id="searchDateCalendarcommon" popup="false"
showApplyButton="false" datePattern="dd/MM/yyyy"
value="#{eventMaster.eventSearchDate}" >
<rich:tooltip followMouse="false"
showDelay="100"
direction="topRight"
layout="block"
onmouseover="">
<h:outputText value="#{eventMaster.calendarTooltipText}"
style="color: red;font-size: 12px;"/>
</rich:tooltip>
<f:ajax event="change" listener="#{commonOutputContentBean.showEvents()}"
render="cmnoplayoutfrm searchDateCalendarcommon" />
</rich:calendar>
The calendar simply displays days in a month, it isn't linked to any data. Furthermore styleClass is applied to the entire calendar not to the cells. You need to provide a dataModel.
The datamodel has to implement org.richfaces.model.CalendarDataModel, and you also need to implement org.richfaces.model.CalendarDataModelItem for the days which is a plain object with getters and setters. The CalendarModel would be something like this:
public class MyCalendarModel implements CalendarDataModel {
private boolean hasEvents(Calendar calendar) {
// …
}
#Override
public CalendarDataModelItem[] getData(Date[] dateArray) {
CalendarDataModelItem[] modelItems = new MyCalendarModelItem[dateArray.length];
Calendar current = GregorianCalendar.getInstance();
Calendar today = GregorianCalendar.getInstance();
today.setTime(new Date());
CalendarModelItem modelItem;
for (int i = 0; i < dateArray.length; i++) {
current.setTime(dateArray[i]);
modelItem = new MyCalendarModelItem();
if (hasEvents(current)) {
modelItem.setStyleClass("postive-records");
} else {
modelItem.setStyleClass("no-records");
}
modelItems[i] = modelItem;
}
return modelItems;
}
#Override
public Object getToolTip(Date date) {
return null;
}
}
You can check the example in the showcase.
I've used guard expressions elsewhere in my CSS to achieve IF statements in LESS, however these don't work for me when trying to declare variables like so...
#neutral: false;
#warm: true;
when (#neutral = true) {
#green: #91C95B;
#red: #F15647;
etc...
}
when (#warm = true) {
#green: #91AD3C;
#red: #BF2A23;
etc...
}
This is an example of how I would like to be able to use that variable
h1 {
color:#green;
}
This is how I would expect it to compile down to CSS
h1 {
color: #91AD3C;
}
Is this possible with LESS or would I need to modify my code to use mixin guards?
You can use Guarded Mixins like this :
#neutral: false;
#warm: true;
.color() when (#neutral) {
#green: #91C95B;
}
.color() when (#warm) {
#green: #91AD3C;
}
.color();
h1 {
color:#green;
}
I use primefaces 4.0 and i try to change the color of the event in Primefaces Lazy Schedule, so i have the following xhtml code
<style type="text/css">
.Ajout .fc-event-skin {
background: #00FF00;
}
.Livraison .fc-event-skin {
background:#DF013A;
</style>
<p:schedule value="#{scheduleController.lazyEventModel}" locale="fr" showWeekends="true" eventSelectListener="#{scheduleController.onEventSelect}" >
<p:ajax event="eventSelect" listener="#{scheduleController.onEventSelect}" update="eventDetails" oncomplete="PF('eventDialog').show()" />
</p:schedule>
<p:dialog widgetVar="eventDialog" header="Event Details" showEffect="clip" hideEffect="clip">
<h:panelGrid id="eventDetails" columns="2">
</h:panelGrid>
</p:dialog>
And this is the backing bean
public class ScheduleController implements Serializable {
private ScheduleModel lazyEventModel;
#Inject CalculDAO calculdao;
#Inject RibhDAO ribhdao;
public ScheduleController() {
lazyEventModel = new LazyScheduleModel() {
#Override
public void loadEvents(Date start, Date end) {
clear();
for(Calcul str: calculdao.DisplayCalculs())
{
Calendar cal = Calendar.getInstance();
Date random1 = getRandomDate1(str.getDate());
Date random2 = getRandomDate2(str.getDate());
addEvent(new DefaultScheduleEvent(""+str.getAjouteroulivr(),random1, random2,str.getAjouteroulivr()));
}
for(Ribh str: ribhdao.DisplayRibh())
{
Date random1 = getRandomDate1(str.getDate());
Date random2 = getRandomDate2(str.getDate());
addEvent(new DefaultScheduleEvent("Bénéfices Net du jour = "+str.getNet()+"dinars",random1, random2));
}
}
};
}
public Date getRandomDate1(Date base) {
Calendar date = Calendar.getInstance();
date.setTime(base);
return date.getTime();
}
public Date getRandomDate2(Date base) {
Calendar date = Calendar.getInstance();
date.setTime(base);
date.add(Calendar.MINUTE, 10);
return date.getTime();
}
/////
public void onEventSelect(SelectEvent selectEvent)
{ ScheduleEvent event = (ScheduleEvent) selectEvent.getObject();
//event. = (ScheduleEvent) ((SelectEvent) lazyEventModel).getObject();
}
////
public ScheduleModel getLazyEventModel()
{
return lazyEventModel;
}
}
The problem is that this code use to work fine with primefaces 3.3 JARS but when i switched to Primefaces 4.0, colors of events are no more displayed and events became kind of transparent ! what could be the problem with this code ??
PS: str.getAjouteroulivr() is a String that contains the Styleclass of the event it contains "Ajout" or "Livraison"
I had the same problem and solved it by using the following css:
.myclass .fc-event,
.myclass a,
.myclass .fc-event-inner{
background-color: red;
border-color: red;
color: white;
}
and then apply the styleClass in code:
event.setStyleClass("myclass");
Found out solution for Schedule event Apply this code:
Apply this style in front end
.event1 .fc-event-inner {
background: Red;
border-color: Yellow;
}
set this style class in schedule event
event.setStyleClass("event1");
Add this in your main.css
.event1{
background: Red !important;
border-color: Yellow !important;
}
Add <h:outputStyleSheet name="main.css" link="css"/> in the h:body of your xhtml.
Then in your controller class:
event.setStyleSheet("event1");
This code in working fine in my project.
Try out.......
I am trying to pass a QLabel as a parameter to another function that is supposed to change the style of the label:
main
{
...
setSeatColor(ui->lblPan2Seat5B, 2);
}
void setSeatColor(QLabel& lbl, int i)
{
if(i == 1)
{
lbl.setStyleSheet("QLabel { background-color : blue; color : white; }");
}
else if(i == 2)
{
lbl.setStyleSheet("QLabel { background-color : red; color : white; }");
}
else if(i == 3)
{
lbl.setStyleSheet("QLabel { background-color : green; color : white; }");
}
else
{
lbl.setStyleSheet("QLabel { background-color : rgb(240,240,240); color : back; }");
}
}
The error in the function:
"No matching function for call to setSeatColor(QLabel*&,int)"
Your help is much appreciated!
You pass a QLabel pointer to a function that takes a QLabel&, so replace this call:
setSeatColor(ui->lblPan2Seat5B, 2);
with this one (notice the dereference operator *)
setSeatColor(*ui->lblPan2Seat5B, 2);
//you can use extra parentheses for your colleagues, so that they can understand what are you doing there: setSeatColor( *(ui->lblPan2Seat5B), 2); - that way is a little clearer that you intend to dereference the lblPan2Seat5B not the ui that is dereferenced by the -> operator