Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Scout » PlannerField in 6.0
PlannerField in 6.0 [message #1745738] Sun, 16 October 2016 20:27 Go to next message
Stefan Mutschler is currently offline Stefan MutschlerFriend
Messages: 24
Registered: June 2012
Location: Baden-Baden, Germany
Junior Member
Hi,

back on a Scout project again I would like to use the PlannerField in conjunction with Scout 6.0. I never used the planner before and the best information I have found is a gist created about two years ago. Helpful and clearifying the general concept - but nevertheless I got stuck (or perhaps confused) in the actual implementation. Can anybody point me to the right direction with a short example or some code hints.

Thanks in advance

Stefan
Re: PlannerField in 6.0 [message #1745822 is a reply to message #1745738] Mon, 17 October 2016 22:27 Go to previous messageGo to next message
Stefan Mutschler is currently offline Stefan MutschlerFriend
Messages: 24
Registered: June 2012
Location: Baden-Baden, Germany
Junior Member
After further investigation I still run into a problem. But in the meantime I am not sure if it is a problem of my understanding. More and more I believe it could also be a bug in 6.0.100.RC4.
With a planner field in a form like this
	@Order(1000)
	public class MainBox extends AbstractGroupBox {
		
		@Order(101000)
		public class TrainerPlannerField extends AbstractPlannerField<TrainerPlannerField.Planner, Long, Long> {
			
			public class Planner extends AbstractPlanner<Long, Long> {
				
				@Override
				protected Set<Integer> getConfiguredAvailableDisplayModes() {
					return CollectionUtility.hashSet(
					        IPlannerDisplayMode.MONTH,
					        IPlannerDisplayMode.YEAR);
				}

				@Override
				protected int getConfiguredDisplayMode() {
					return IPlannerDisplayMode.MONTH;
				}
			}
			
			@Override
			protected List<Resource<Long>> execLoadResources() {
				List<Resource<Long>> rl = new ArrayList<Resource<Long>>();
				Resource<Long> r = new Resource<Long>(1L, "Test Resource");
				Activity<Long, Long> a = new Activity<Long, Long>(1L, 4711L);
				a.setText("Test Activity");
				Calendar start = Calendar.getInstance();
				start.clear();
				start.set(2016, 9, 24, 7, 0);
				a.setBeginTime(start.getTime());
				Calendar end = Calendar.getInstance();
				end.clear();
				end.set(2016, 9, 24, 9, 0);
				a.setEndTime(end.getTime());
				r.addActivity(a);
				rl.add(r);
				return rl;
			}
			
			@Override
			protected int getConfiguredGridH() {
				return 10;
			}

			@Override
			protected boolean getConfiguredLabelVisible() {
				return false;
			}			
		}
	}


I get an "internal UI error (code T6)" and the browser console (chrome) shows
application-all-bb337778.min.js:9 Uncaught TypeError: Cannot read property 'children' of undefined
at the following code line
var scaleItemsLarge=this.planner.$timelineLarge.children(".scale-item")
It seems that $timelineLarge is undefined at that time.
Any ideas on this? Do I have to add something to make this work?

[Updated on: Wed, 26 October 2016 18:15]

Report message to a moderator

Re: PlannerField in 6.0 [message #1746315 is a reply to message #1745822] Wed, 26 October 2016 18:18 Go to previous messageGo to next message
Stefan Mutschler is currently offline Stefan MutschlerFriend
Messages: 24
Registered: June 2012
Location: Baden-Baden, Germany
Junior Member
Hmmm... do I have bad luck? Does anyone face the same phenomenon?
If I am the only one I believe something is wrong with my test code.
No hints for me?
Re: PlannerField in 6.0 [message #1746380 is a reply to message #1746315] Thu, 27 October 2016 20:35 Go to previous messageGo to next message
Jeremie Bresson is currently offline Jeremie BressonFriend
Messages: 1252
Registered: October 2011
Senior Member
Sorry for the delay, we were busy at the EclipseCon Europe (and the days before that preparing the event). I have the same error with the code snippet you have provided... I have compared it with some code I have developed a long time ago.

The error disappears when I set the display mode of the planner during field initialization. I have also added "loadResources()" to load the data.

@Order(101000)
public class TrainerPlannerField extends AbstractPlannerField<TrainerPlannerField.Planner, Long, Long> {
	
	@Override
	protected void execInitField() {
		getPlanner().setDisplayMode(ICalendarDisplayMode.WEEK);
		loadResources();
	}

	//... rest of the implementation


The planner field probably deserves some documentation and some updated example, because the field is not easy to use.

Related discussion (old topic):
Swing PlannerField

----
I will be offline until the middle of next week.
Re: PlannerField in 6.0 [message #1746387 is a reply to message #1746380] Thu, 27 October 2016 23:29 Go to previous messageGo to next message
Stefan Mutschler is currently offline Stefan MutschlerFriend
Messages: 24
Registered: June 2012
Location: Baden-Baden, Germany
Junior Member
Thanks for the reply! EclipseCon of course... that wasn't on my mind any more. Hope it was a successful conference for you.

I just tried your suggestion and it worked. But as soon as I tried to switch to ICalendarDisplayMode.MONTH in execInitField() (since I wanted only to offer display mode 'month' and 'year') the problem occurred again. Playing around with some permutations I figured out that after having removed my override of getConfiguredDisplayMode() everything works fine.

A sample and some docs would be great but so far I am glad that I can go on with my implementation.

Thanks a lot for your help!
Re: PlannerField in 6.0 [message #1837828 is a reply to message #1746387] Mon, 08 February 2021 11:31 Go to previous messageGo to next message
Mark Ashworth is currently offline Mark AshworthFriend
Messages: 40
Registered: January 2012
Member
Good day,

I have followed the suggestions in this thread to get the PlannerField to work. If someone could indicate which children the error is referring to because it seems like it is meant to be the Actvities/Resources but I have added those in the execLoadResources and I am not sure what other field I am meant to declare as an inner class of Planner since I have tried the TableField when I saw the Swing PlannerField discussion but TableField also did not work.

@Order(1250)
			public class ActivityPlannerField extends AbstractPlannerField<ActivityPlanner, Long, Long> {

				@Override
				protected boolean getConfiguredLabelVisible() {
					return false;
				}

				@Override
				protected int getConfiguredGridW() {
					return FULL_WIDTH;
				}
				
				
				@Override
				protected void execInitField() {
					
					
					getPlanner().setDisplayMode(IPlannerDisplayMode.CALENDAR_WEEK);
					loadResources();
				}
				
				
				
				
				@Override
				protected List<Resource<Long>> execLoadResources() {
					
					System.out.println("Planner load resources");
					
					ProjectPlan projectPlan = BEANS.get(IPlanningService.class).retrieveProjectPlan(1L);
					
					List<Resource<Long>> resources = new ArrayList<>();
					
					try {
						Resource<Long> resource = new Resource<>(1L, "DEV1");
						
						for (ProjectActivity projectActivity : projectPlan.getActivities()) {
							
							Activity<Long, Long> activity = new Activity<>(projectActivity.getProperties());
							resource.addActivity(activity);
						}
						
						resources.add(resource);
						
					} catch (Exception e) {
						e.printStackTrace();
					}
					
					System.out.println("Planner load resources " + resources.size());
					return resources;
				}
				
				
				
				public class ActivityPlanner extends AbstractPlanner<Long, Long> {

					
					@Override
					protected Set<Integer> getConfiguredAvailableDisplayModes() {
						return CollectionUtility.hashSet(
								IPlannerDisplayMode.WEEK,
								IPlannerDisplayMode.CALENDAR_WEEK,
								IPlannerDisplayMode.MONTH);
					}
					
					
					@Override
					protected boolean getConfiguredActivitySelectable() {
						return true;
					}
					
					@Order(1000)
					public class TestMenu extends AbstractMenu  {
						@Override
						protected String getConfiguredText() {
							return TEXTS.get("MyNlsKey");
						}

						@Override
						protected Set<? extends IMenuType> getConfiguredMenuTypes() {
							return CollectionUtility.hashSet();
						}

						@Override
						protected void execAction() {
						}
					}
				}
			}


2021-02-06 11:35:18,441 INFO  [qtp1179792105-34] org.eclipse.scout.rt.ui.html.json.JsonMessageRequestHandler.createUiSession(JsonMessageRequestHandler.java:362) - Created new UI session with ID 1:11vitsd36lao6kqrbs816a995aunna95tm05dd3oi3j1kcuqlguo in 1315.383300 ms [maxIdleTime=14400s, httpSession.maxInactiveInterval=3600s] - MDC[principal=USER, cid=kB5Kr2dG2DW/1]
Planner load resources
Planner load resources 1
2021-02-06 11:35:29,462 ERROR [qtp1179792105-31] org.eclipse.scout.rt.ui.html.json.JsonMessageRequestHandler.handleLogRequest(JsonMessageRequestHandler.java:254) - JavaScript exception occured while processing event pageChanged for adapter Outline[id=12, modelClass=com.github.markash.micro.client.work.WorkOutline, parentId=1]
Cannot read property 'children' of undefined
    at PlannerLayout._minWidth (webpack:///node_modules/@eclipse-scout/core/src/planner/PlannerLayout.js:142:0)
    at PlannerLayout._updateMinWidth (webpack:///node_modules/@eclipse-scout/core/src/planner/PlannerLayout.js:76:0)
    at PlannerLayout.layout (webpack:///node_modules/@eclipse-scout/core/src/planner/PlannerLayout.js:65:0)
    at HtmlComponent.validateLayout (webpack:///node_modules/@eclipse-scout/core/src/layout/HtmlComponent.js:143:0)
    at HtmlComponent.setBounds (webpack:///node_modules/@eclipse-scout/core/src/layout/HtmlComponent.js:461:0)
    at FormFieldLayout.layout (webpack:///node_modules/@eclipse-scout/core/src/form/fields/FormFieldLayout.js:143:0)
    at HtmlComponent.validateLayout (webpack:///node_modules/@eclipse-scout/core/src/layout/HtmlComponent.js:143:0)
    at HtmlComponent.setBounds (webpack:///node_modules/@eclipse-scout/core/src/layout/HtmlComponent.js:461:0)
    at LogicalGridLayout._layout (webpack:///node_modules/@eclipse-scout/core/src/layout/logicalgrid/LogicalGridLayout.js:192:0)
    at LogicalGridLayout.layout (webpack:///node_modules/@eclipse-scout/core/src/layout/logicalgrid/LogicalGridLayout.js:125:0) - MDC[principal=USER, httpUri=log, uiSession=1:11vitsd36lao6kqrbs816a995aunna95tm05dd3oi3j1kcuqlguo, cid=UX9KC9zS5xx/4]
2021-02-06 11:35:36,266 ERROR [qtp1179792105-34] org.eclipse.scout.rt.ui.html.json.JsonMessageRequestHandler.handleLogRequest(JsonMessageRequestHandler.java:254) - JavaScript exception occured
Cannot read property 'children' of undefined
    at PlannerLayout._minWidth (webpack:///node_modules/@eclipse-scout/core/src/planner/PlannerLayout.js:142:0)
    at PlannerLayout._updateMinWidth (webpack:///node_modules/@eclipse-scout/core/src/planner/PlannerLayout.js:76:0)
    at PlannerLayout.layout (webpack:///node_modules/@eclipse-scout/core/src/planner/PlannerLayout.js:65:0)
    at HtmlComponent.validateLayout (webpack:///node_modules/@eclipse-scout/core/src/layout/HtmlComponent.js:143:0)
    at HtmlComponent.setBounds (webpack:///node_modules/@eclipse-scout/core/src/layout/HtmlComponent.js:461:0)
    at FormFieldLayout.layout (webpack:///node_modules/@eclipse-scout/core/src/form/fields/FormFieldLayout.js:143:0)
    at HtmlComponent.validateLayout (webpack:///node_modules/@eclipse-scout/core/src/layout/HtmlComponent.js:143:0)
    at HtmlComponent.setBounds (webpack:///node_modules/@eclipse-scout/core/src/layout/HtmlComponent.js:461:0)
    at LogicalGridLayout._layout (webpack:///node_modules/@eclipse-scout/core/src/layout/logicalgrid/LogicalGridLayout.js:192:0)
    at LogicalGridLayout.layout (webpack:///node_modules/@eclipse-scout/core/src/layout/logicalgrid/LogicalGridLayout.js:125:0) - MDC[principal=USER


Thank you for your assistance.


Kind regards,
Mark Ashworth
Re: PlannerField in 6.0 [message #1837856 is a reply to message #1837828] Mon, 08 February 2021 17:13 Go to previous messageGo to next message
Beat Schwarzentrub is currently offline Beat SchwarzentrubFriend
Messages: 201
Registered: November 2010
Senior Member
Your code looks alright, no need to mix tables and planners. The "children" mentioned in the error message are releated to DOM elements in the browser.

Unfortunately, the implementation seems to be quite picky about the correct property values. In your case, the property "viewRange" is not initialized, which the planner doesn't like. Apparently the viewRange would be automatically calculated when you set the display mode. Unfortunately, CALENDAR_WEEK is already the default value, so this calculation is not triggered. The easiest fix would therefore be to initialize the display mode to some other value first.

      @Override
      protected void execInitField() {
        getPlanner().setDisplayMode(0); // <--
        getPlanner().setDisplayMode(IPlannerDisplayMode.CALENDAR_WEEK);
        loadResources();
      }

I'm not an expert on the Planner widget, but this seems to do the trick. If someone knows of a better way, please let us know.

Regards,
Beat
Re: PlannerField in 6.0 [message #1837866 is a reply to message #1837856] Tue, 09 February 2021 05:47 Go to previous messageGo to next message
Mark Ashworth is currently offline Mark AshworthFriend
Messages: 40
Registered: January 2012
Member
Good morning Beat,


Thank you, I will give that a try :-)


Kind regards,
Mark Ashworth
Re: PlannerField in 6.0 [message #1839157 is a reply to message #1837866] Tue, 16 March 2021 07:21 Go to previous message
Mark Ashworth is currently offline Mark AshworthFriend
Messages: 40
Registered: January 2012
Member
Good morning Beat,

Just to let you know that it worked, thank you.
Previous Topic:Sticky columns in tablea
Next Topic:How BSI handles deployment
Goto Forum:
  


Current Time: Sun Feb 25 16:15:13 GMT 2024

Powered by FUDForum. Page generated in 0.02210 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top