Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Resource View beginner's questions (Read 6132 times)
DamianC
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 16
Joined: Aug 19th, 2015
Resource View beginner's questions
Aug 24th, 2015 at 12:13am
Print Post  
Hi,

I'm still in my first few days with JPlanner - and although I am struggling a bit - I am very much enjoying the power and the (relative) simplicity. It's an impressive product that I am glad I found.

Now I'm playing around with Resources View, and I have a few questions that I am struggling to answer myself. I had some of these things working in "List View", but Resource view is a bit different. Also, I'm not sure if I have all the names of the components correct, so I have attached a screenshot to explain.

Referring to the attached screen shot ...

1. How do I adjust the width of the "Row header"?

2. These rows will never be shrunk. Can I remove the "shrink" symbol?

3. How do I adjust the font and background color of the "Row header"?

4. These Items will never be edited directly - so how can I stop the "text editor" from starting when I select an Item?

5. I would like the height of the Item to be a bit smaller that the height of the row. How can I introduce "padding" or whatever to give some space above and below?

6. I would like to adjust the color of the top bar across each item. I want to use this to signify some emergency states. How can I set this color?

7. I want "today" to be clearly visible. In "List view" I can use "DateStyle todayStyle = new DateStyle();" and "calendar.getDayStyles().add(todayStyle);", but that does not seem to work here. Any suggestions?

8. Formatting date headers. I want to "center", and possibly change font. Any thoughts?

9. (not on screenshot) Later I expect that I will want to adjust the start/end times of Appointments. However - I don't want it to ever change Resource/Row. How can I allow date modification but disallow Resource/Row changes?

Any clues would be much appreciated.

Many thanks,
-Damian
  

JPlannerResourceViewIssuesMkup.jpg ( 67 KB | 139 Downloads )
JPlannerResourceViewIssuesMkup.jpg
Back to top
 
IP Logged
 
Meppy
God Member
*****
Offline


MindFusion support

Posts: 1783
Joined: Jul 20th, 2005
Re: Resource View beginner's questions
Reply #1 - Aug 24th, 2015 at 8:15am
Print Post  
Hi,

I'm glad you are enjoying the control so far. Here are the answers to your questions:

1. Use the ResourceViewSettings.setRowHeaderSize method:

Code
Select All
calendar.getResourceViewSettings().setRowHeaderSize(200); 


2. Use the ResourceViewSettings.setExpandableRows method;

Code
Select All
calendar.getResourceViewSettings().setExpandableRows(false); 


3. Use the Style object returned by the ResourceViewSettings.getStyle method:

Code
Select All
Style style = calendar.getResourceViewSettings().getStyle();
style.setHeaderFont(style.getHeaderFont().deriveFont(12, FontStyles.Bold));
style.setHeaderBrush(Brushes.PaleGoldenrod); 


4. If you want to disable in-place editing for specific items, you need to add a CalendarListener to the Calendar component and override the itemInplaceEditStarting method:

Code
Select All
calendar.addCalendarListener(new CalendarAdapter()
{
	@Override
	public void itemInplaceEditStarting(ItemConfirmEvent e) {
		if ("RESERVED".equals(e.getItem().getHeaderText()))
			e.setConfirm(false);
	}
}); 


If you want to disable editing globally, call calendar.setAllowInplaceEdit(false).

5. There are various setPadding* methods in the ItemSettings class, but they appear to be ignored in the Resource view. We will look into it.

6. Use the Item.getStyle().setFillColor method of the individual items:

Code
Select All
item.getStyle().setFillColor(Colors.Red); 


7. Indeed, the date styles are not used in Resourc view. Instead you can use custom drawing to achieve the desired result. First, call the Calendar.setCustomDraw method with CustomDrawElements.ResourceViewCell to indicate the element that should be customized.

Code
Select All
calendar.setCustomDraw(CustomDrawElements.ResourceViewCell); 


Then, add a CalendarListener and override the draw method:

Code
Select All
@Override
public void draw(DrawEvent e) {
	if (e.getElement() == CustomDrawElements.ResourceViewCell)
	{
		if (DateTime.op_Equality(e.getDate(), DateTime.today()))
			e.getGraphics().fillRectangle(Brushes.PaleGoldenrod, e.getBounds());
	}
} 


8. Each timeline is customized through its respective TimelineSettings object, which can be obtained through the ResourceViewSettings.getBottomTimelineSettings, ResourceViewSettings.getMiddleTimelineSettings, and ResourceViewSettings.getTopTimelineSettings methods respectively. To set the font and text alignment use the setHeaderFont and setHeaderTextAlignment methods of the timeline's Style:

Code
Select All
style = calendar.getResourceViewSettings().getBottomTimelineSettings().getStyle();
style.setHeaderFont(style.getHeaderFont().deriveFont(11, FontStyles.Regular));
style.setHeaderTextAlignment(TextAlignment.MiddleCenter); 


9. You can use the Calendar.setItemChangeResourceKey method and specify any key other than the three modifier keys (Control, Alt, Shift). For example:

Code
Select All
calendar.setItemChangeResourceKey(Keys.Home); 



Regards,
Meppy
  
Back to top
 
IP Logged
 
Meppy
God Member
*****
Offline


MindFusion support

Posts: 1783
Joined: Jul 20th, 2005
Re: Resource View beginner's questions
Reply #2 - Aug 24th, 2015 at 10:50am
Print Post  
In fact the Top and Bottom padding properties should work in Resource view. Use the following code to specify them:

Code
Select All
calendar.getItemSettings().setPaddingTop(...);
calendar.getItemSettings().setPaddingBottom(...); 

  
Back to top
 
IP Logged
 
DamianC
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 16
Joined: Aug 19th, 2015
Re: Resource View beginner's questions
Reply #3 - Aug 25th, 2015 at 8:58am
Print Post  
Hi Meppy,

Many thanks for the outstanding responses. Now I'm just looking for 2 further clarifications ...

Re #8: I have successfully changed the format of the text. Is there any way to set the background color for "today" only? Under the Appointments I have made "today" as yellow, and I would like this date area to also be yellow.


Re #9: Sorry, I don't understand your response. What I will have is a ResourceView calendar with (exactly) 2 resources (ie rows).
Resource #1 will have one Appointment for each and every day (pre defined by the system). These are not allowed to be edited or moved ever.
Resource #2 will have exactly one Appointment. The user is allowed to adjust the dates & duration for this appointment. However - they will not be allowed to edit any other aspect of that Appointment. So they will not be able to edit the text, or (for example) drag the appointment from Resource #2 onto Resource #1. To stop the text being edited I can use your answer to #4 (using itemInplaceEditStarting() & e.setConfirm(false)). However, I do not know how to stop the Appointment simply being dragged onto Resource #1 lane. This is against the business rules, and I just want to forbid it in JPlanner too.

Many thanks,
-Damian
  
Back to top
 
IP Logged
 
Meppy
God Member
*****
Offline


MindFusion support

Posts: 1783
Joined: Jul 20th, 2005
Re: Resource View beginner's questions
Reply #4 - Aug 25th, 2015 at 11:03am
Print Post  
Hi,

8. You need to rely on custom drawing again. To draw the cells in the timeline header, specify the CustomDrawElements.ResourceViewTimelineCell value in addition to CustomDrawElements.ResourceViewCell as an argument to setCustomDraw:

Code
Select All
calendar.setCustomDraw(CustomDrawElements.ResourceViewCell | CustomDrawElements.ResourceViewTimelineCell); 


The draw method will be called for each cell in the view as well as the timeline header. You need to ensure that you are drawing the right cell by checking getDate and getIndex.

Code
Select All
@Override
public void draw(DrawEvent e) {
	if (e.getElement() == CustomDrawElements.ResourceViewCell)
	{
		if (DateTime.op_Equality(e.getDate(), DateTime.today()))
			e.getGraphics().fillRectangle(Brushes.Yellow, e.getBounds());
	}
	else if (e.getElement() == CustomDrawElements.ResourceViewTimelineCell)
	{
		if (DateTime.op_Equality(e.getDate(), DateTime.today()) && e.getIndex() == 2)
		{
			e.getGraphics().fillRectangle(Brushes.Yellow, e.getBounds());

			// You need to draw the text inside the cell again
			// because the default text will be obscured by the fill above
			Brush brush = new SolidBrush(e.getStyle().getHeaderTextColor());
			TextFormat format = new TextFormat();
			format.setHorizontalAlign(Align.Center);
			format.setVerticalAlign(Align.Center);
			e.getGraphics().drawString(e.getText(), e.getStyle().getHeaderFont(), brush, new RectangleD(e.getBounds()), format);
		}
	}
} 


9. The following code will prevent the user from dragging appointments to different resources.

Code
Select All
calendar.setItemChangeResourceKey(Keys.Home); 


Generally, the setItemChangeResourceKey method is used to specify a modifier key (Control, Alt, or Shift). When the key specified by this method is hold down while the user initiates a dragging operation, the dragged appointment is allowed to be moved to different resources. When this method is called with Keys.None, the appointments can be moved to different resources without holding down any modifier keys. This is why I suggested to call this method with any non-modifier key.

To prevent the user from modifying specific appointments altogether, either set the AllowMove, AllowChangeStart, and AllowChangeEnd properties of these appointments to false or override the itemModifying method in the CalendarListener and call setConfirm with false.

I hope this helps.

Regards,
Meppy
  
Back to top
 
IP Logged
 
DamianC
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 16
Joined: Aug 19th, 2015
Re: Resource View beginner's questions
Reply #5 - Aug 25th, 2015 at 1:30pm
Print Post  
Perfect. It all works.
Thank you.
  
Back to top
 
IP Logged
 
DamianC
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 16
Joined: Aug 19th, 2015
Re: Resource View beginner's questions
Reply #6 - Aug 26th, 2015 at 1:23am
Print Post  
Hi Meppy & everyone,

I am pretty much done with my first 2 components using JPlanner. Thanks for all your help getting me this far. Just one more little question for now.

I can set the color of the bar across the top of each Appointment using "this.getStyle().setFillColor(MY_COLOR);" This is how I set the GREEN ("all OK") and ORANGE ("issue") status for each Appointment.

However - this does not work when the Appointment is selected. Instead it defaults to a dark gray (as shown in the screenshot). Is there a reasonable way I can set this color when the appointment is selected?

Again, many thanks,
-Damian
  

JPlannerV2.jpg ( 138 KB | 158 Downloads )
JPlannerV2.jpg
Back to top
 
IP Logged
 
Meppy
God Member
*****
Offline


MindFusion support

Posts: 1783
Joined: Jul 20th, 2005
Re: Resource View beginner's questions
Reply #7 - Aug 26th, 2015 at 6:10am
Print Post  
Hi Damian,

The appointments use different style when they are selected, namely, the one returned by Item.getSelectedStyle().

Regards,
Meppy
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint