It works with the demonstrator but not when I extract the sample to test it into a new java class.
The exception:
2022-07-28 16:42:01:245 >>>> [Py:1,Th:AWT-EventQueue-0]>SCHEDULING_LOG : Could not insert operation : [ BT220616-03-1 ] Libération {Libération } in assigned resource : Libération java.lang.NullPointerException at com.mindfusion.common.RangeSelector.<init>(Unknown Source) at com.notixia.common.client.scheduling.simple.cSimpleGanttComponent.mBuildUI(cSimp leGanttComponent.java:83) . at com.notixia.common.client.scheduling.simple.cSimpleGanttComponent.<init>(cSimple GanttComponent.java:43) at com.notixia.common.client.scheduling.simple.cSimpleSchedulingApplicationView.mGe tSpecificPane(cSimpleSchedulingApplicationView.java:134) at com.notixia.common.client.cGenericADOTreeTableAV$cBackgroundModelPreparation$2.r un(cGenericADOTreeTableAV.java:673) at java.awt.event.InvocationEvent.dispatch$$$capture(InvocationEvent.java:311) at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java) at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:758) at java.awt.EventQueue.access$500(EventQueue.java:97) at java.awt.EventQueue$3.run(EventQueue.java:709) at java.awt.EventQueue$3.run(EventQueue.java:703) at java.security.AccessController.doPrivileged(Native Method) at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Pr otectionDomain.java:74) at java.awt.EventQueue.dispatchEvent(EventQueue.java:728) at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:205 ) at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116) at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105 ) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93) at java.awt.EventDispatchThread.run(EventDispatchThread.java:82) Warning: Could not get charToByteConverterClass!
S ============================================================= CLASS source:
package com.notixia.common.client.scheduling.simple;
import com.mindfusion.common.*; import com.mindfusion.drawing.*; import com.mindfusion.scheduling.*; import com.mindfusion.scheduling.Calendar; import com.mindfusion.scheduling.model.Appointment; import com.mindfusion.scheduling.model.Resource; import com.notixia.common.model.resource.cAPMResource; import com.notixia.ecip.client.cDefaultToolBar; import com.notixia.ecip.core.cProxy; import com.notixia.ecip.model.cADOID;
import javax.swing.*; import java.awt.*; import java.awt.event.*; import java.awt.geom.Rectangle2D; import java.util.*;
public class cSimpleGanttComponent extends JPanel implements ItemListener {
Calendar aCalendar; RangeSelector aTimeLine; private JRadioButton aView1; private JRadioButton aView2; private JRadioButton aView3;
boolean initialized;
/** * A list with all defined zones. */ private ArrayList<cSimpleZone> zones = new ArrayList<>();
public cSimpleGanttComponent(java.util.List<cSimpleResource> pSimpleResources) { super(new BorderLayout()); this.addComponentListener(new ComponentAdapter() { public void componentResized(ComponentEvent e) { updateTimeline(); } });
mBuildUI();
mInitResources(pSimpleResources); mInitZones();
for(cSimpleResource lResource : pSimpleResources) { java.util.List<cSimpleOperation> lListOfSimpleOperations = lResource.mGetSequence(); for(cSimpleOperation lSimpleOperation : lListOfSimpleOperations) aCalendar.getSchedule().getItems().add(lSimpleOperation); }
add(BorderLayout.CENTER, aCalendar); add(BorderLayout.SOUTH, aTimeLine); }
private void mInitZones() { java.util.Calendar lCalendar = java.util.Calendar.getInstance(); lCalendar.set(2022,java.util.Calendar.JULY,26,9,0); Date lD1 = lCalendar.getTime(); lCalendar.set(2022,java.util.Calendar.JULY,27,9,0); Date lD2 = lCalendar.getTime();
DateTime lBegin = new DateTime(lD1); DateTime lEnd = new DateTime(lD2); cSimpleZone lZone = new cSimpleZone(lBegin, lEnd, "hey",true); zones.add(lZone); }
private void mInitResources(java.util.List<cSimpleResource> pSimpleResources) {
for (cSimpleResource lResource : pSimpleResources) aCalendar.getResources().add(lResource);
aCalendar.setGroupType(GroupType.GroupByResources); }
private void mBuildUI() {
aTimeLine = new RangeSelector(); <<<<<<<<<<<<<<< This is the line 83 aTimeLine.setButtonSize(12); aTimeLine.setLocation(0, 430); aTimeLine.setMinimum(0D); aTimeLine.setName("timeline"); aTimeLine.setSize(628, 65); aTimeLine.setPreferredSize(new Dimension(628, 65));
aTimeLine.addRangeSelectorListener(new RangeSelectorListener(){
@Override public void valueChanged(EventObject e) { aCalendar.setViewport(new DateTime((long)aTimeLine.getSelectionStart()), new DateTime((long)aTimeLine.getSelectionEnd()), true); aTimeLine.repaint(); }
@Override public void drawBackground(DrawEvent e) { Rectangle2D bounds = e.getBounds(); Graphics2D g = (Graphics2D)e.getGraphics(); // Draw days DateTime date = aCalendar.getDate(); while (date.isLessThan(aCalendar.getEndDate())) { double prc = (double)(date.getTicks() - aCalendar.getDate().getTicks()) / (aCalendar.getEndDate().getTicks() - aCalendar.getDate().getTicks());
int x = (int)(bounds.getX() + (int)(prc * bounds.getWidth())); Pen pen = new Pen(aCalendar.getResourceViewSettings().getStyle().getBorderLeftColor()); pen.applyTo(g); g.drawLine(x, (int)bounds.getY(), x, (int)(bounds.getY()+bounds.getHeight())); Brush brush = new SolidBrush(aCalendar.getResourceViewSettings().getStyle().getHeaderTextColor());
Font f = aCalendar.getResourceViewSettings().getStyle().getHeaderFont(); g.setFont(f); brush.applyTo(g, bounds); g.drawString(date.toString("MMM"), x+2, (int)(bounds.getY()+bounds.getHeight()-2));
date = date.addDays(DateTime.daysInMonth(date.getYear(), date.getMonth()) - date.getDay() + 1); } }
});
aView1 = new JRadioButton("Gantt"); aView2 = new JRadioButton("Calendar"); aView3 = new JRadioButton("Week"); aView1.setSelected(true);
aView1.addItemListener(this); aView2.addItemListener(this); aView3.addItemListener(this);
ButtonGroup lGroup = new ButtonGroup(); lGroup.add(aView1); lGroup.add(aView2); lGroup.add(aView3);
cDefaultToolBar lToolbar = new cDefaultToolBar(); lToolbar.add(aView1); lToolbar.add(aView2); lToolbar.add(aView3); add(BorderLayout.NORTH, lToolbar);
aCalendar = new Calendar(); aCalendar.addCalendarListener(new CalendarAdapter() { public void draw(CalendarDrawEvent e) { calendar_Draw(e); } public void itemCreating(ItemConfirmEvent e) { onCalendarItemCreating(e); } public void itemModifying(ItemModifyConfirmEvent e) { onItemModifying(e); } public void itemCreated(ItemEvent e) { onItemCreated(e); } public void itemClick(ItemMouseEvent e) { onItemClick(e); } });
aCalendar.setCurrentTime(DateTime.now());
java.util.Calendar lCalendar = java.util.Calendar.getInstance(); lCalendar.roll(java.util.Calendar.MONTH,-1); Date lBegin = lCalendar.getTime(); lCalendar.roll(java.util.Calendar.MONTH,14); Date lEnd = lCalendar.getTime();
aCalendar.setDate(new DateTime(lBegin)); aCalendar.setEndDate(new DateTime(lEnd)); aCalendar.getTimetableSettings().getDates().add(new DateTime(lBegin)); aCalendar.getTimetableSettings().getDates().add(new DateTime(lEnd));
aCalendar.setTheme(ThemeType.Light); aCalendar.getMonthSettings().setWeekHeaderStyle(MonthWeekHeaderStyle.Left); aCalendar.getListViewSettings().setCellUnits(TimeUnit.Month); // aCalendar.setCustomDraw(EnumSet.of(CustomDrawElements.TimetableCell));
EnumSet<ListViewHeaderStyles> style = aCalendar.getListViewSettings().getHeaderStyle(); style.add(ListViewHeaderStyles.Subheader); style.add(ListViewHeaderStyles.SubheaderPerCell);
aCalendar.getResourceViewSettings().setViewStyle(ResourceViewStyle.Lanes); aCalendar.getResourceViewSettings().getMiddleTimelineSettings().setUnit(TimeUnit .Day); aCalendar.getResourceViewSettings().getMiddleTimelineSettings().setFormat("d"); aCalendar.getResourceViewSettings().getBottomTimelineSettings().setUnit(TimeUnit .Hour); aCalendar.getResourceViewSettings().getBottomTimelineSettings().setFormat("HH:mm ");
aCalendar.getTimetableSettings().setShowInfoHeader(true); aCalendar.getTimetableSettings().setVisibleColumns(3);
aCalendar.getTimetableSettings().setSnapInterval(Duration.fromMinutes(1)); aCalendar.setInteractiveItemType(cSimpleZoneEvent.class); aCalendar.setCurrentView(CalendarView.ResourceView); aCalendar.setCustomDraw(EnumSet.of(CustomDrawElements.ResourceViewTimeline));
aCalendar.addCalendarListener(new CalendarAdapter(){ @Override public void hScroll(ScrollEvent e) { if (e.getType() == 5)//ScrollEventType.EndScroll) { updateTimeline(); } }
}); aCalendar.addComponentListener(new ComponentAdapter() {
@Override public void componentResized(ComponentEvent e) { if (!initialized) { aCalendar.setViewport(new DateTime((long)aTimeLine.getSelectionStart()), new DateTime((long)aTimeLine.getSelectionEnd()), true); initialized = true; } super.componentResized(e); } });
// Calendar initialization end initTimeline(); updateTimeline();
aCalendar.setViewport(new DateTime((long)aTimeLine.getSelectionStart()), new DateTime((long)aTimeLine.getSelectionEnd()), true); aCalendar.invalidate(); }
void initTimeline() { DateTime start = aCalendar.getDate(); DateTime end = aCalendar.getEndDate();
aTimeLine.setMinimum(start.getTicks()); aTimeLine.setMaximum(end.getTicks());
aTimeLine.setMinimumSelectionLength((aTimeLine.getMaximum() - aTimeLine.getMinimum()) / 30);
aTimeLine.setStep(Duration.TicksPerDay);//TimeSpan.TicksPerDay; aTimeLine.setSelectionStart(aTimeLine.getMinimum()); aTimeLine.setSelectionEnd(aTimeLine.getSelectionStart() + aTimeLine.getMinimumSelectionLength()); }
void updateTimeline() { aTimeLine.setSelectionStart(aCalendar.getFirstVisibleDate().getTicks()); aTimeLine.setSelectionEnd(aCalendar.getLastVisibleDate().getTicks()); }
@Override public void itemStateChanged(ItemEvent e) {
if (e.getSource() == aView1) { if (aView1.isSelected()) { aCalendar.setCurrentView(CalendarView.ResourceView); aCalendar.setCustomDraw(EnumSet.of(CustomDrawElements.ResourceViewTimeline)); } } else if (e.getSource() == aView2) { if (aView2.isSelected()) { aCalendar.setCurrentView(CalendarView.MonthRange); aCalendar.setCustomDraw(EnumSet.of(CustomDrawElements.MonthContents)); } } else if (e.getSource() == aView3) { if (aView3.isSelected()) { aCalendar.setCurrentView(CalendarView.WeekRange); aCalendar.setCustomDraw(EnumSet.of(CustomDrawElements.WeekRangeResourceHeader));
} }
}
// protected void btnZoneBClick() // { // addZone(false); // } // // protected void btnZoneAClick() // { // addZone(true); // } // // protected void btnDeleteClick() // { // for (int j = 0; j < zones.size(); ) // { // Zone z = zones.get(j); // // // Check if zone is selected // boolean found = false; // for (int i = 0; i < calendar.getSelection().getRanges().size(); i += 2) // { // DateTime start = calendar.getSelection().getRanges().get(i); // DateTime end = calendar.getSelection().getRanges().get(i + 1); // if (intersect(z.getStart(), z.getEnd(), start, end)) // { // zones.remove(j); // found = true; // // // Remove all items from the zone // for (int k = 0; k < calendar.getSchedule().getItems().size(); ) // { // Item item = calendar.getSchedule().getItems().get(k); // // if (intersect(z.getStart(), z.getEnd(), item.getStartTime(), item.getEndTime())) // { //
|