1 14 package org.compiere.apps.search; 15 16 import java.awt.*; 17 import javax.swing.*; 18 import java.util.*; 19 import java.sql.*; 20 21 import org.compiere.util.*; 22 import org.compiere.model.*; 23 24 31 public class VSchedule extends JPanel 32 { 33 38 public VSchedule (InfoSchedule is, int type) 39 { 40 m_type = type; 41 m_model = new MSchedule (Env.getCtx()); 42 schedulePanel.setType (m_type); 43 schedulePanel.setTimePanel (timePanel); 44 schedulePanel.setInfoSchedule (is); try 46 { 47 jbInit(); 48 } 49 catch(Exception e) 50 { 51 Log.error("VSchedule", e); 52 } 53 } 55 56 static public final int TYPE_DAY = Calendar.DAY_OF_MONTH; 57 58 static public final int TYPE_WEEK = Calendar.WEEK_OF_YEAR; 59 60 static public final int TYPE_MONTH = Calendar.MONTH; 61 62 63 private int m_type = TYPE_DAY; 64 65 private MSchedule m_model = null; 66 67 private Timestamp m_startDate; 68 69 private Timestamp m_endDate; 70 71 72 private BorderLayout mainLayout = new BorderLayout(); 73 private VScheduleTimePanel timePanel = new VScheduleTimePanel(); 74 private VSchedulePanel schedulePanel = new VSchedulePanel(); 75 private JScrollPane schedulePane = new JScrollPane(); 76 77 85 private void jbInit() throws Exception 86 { 87 this.setLayout(mainLayout); 88 this.add(timePanel, BorderLayout.WEST); 89 schedulePane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_NEVER); 92 schedulePane.getViewport().add(schedulePanel, null); 93 schedulePane.setPreferredSize(new Dimension(200, 200)); 94 schedulePane.setBorder(null); 95 this.add(schedulePane, BorderLayout.CENTER); 96 } 98 103 public void recreate (int S_Resource_ID, Timestamp date) 104 { 105 GregorianCalendar cal = new GregorianCalendar(); 107 cal.setTime(date); 108 cal.set(Calendar.HOUR, 0); 109 cal.set(Calendar.MINUTE, 0); 110 cal.set(Calendar.SECOND, 0); 111 cal.set(Calendar.MILLISECOND, 0); 112 if (m_type == TYPE_WEEK) 113 cal.set(Calendar.DAY_OF_WEEK, cal.getFirstDayOfWeek()); 114 else if (m_type == TYPE_MONTH) 115 cal.set(Calendar.DAY_OF_MONTH, 1); 116 m_startDate = new Timestamp(cal.getTimeInMillis()); 117 cal.add(m_type, 1); 119 m_endDate = new Timestamp (cal.getTimeInMillis()); 120 Log.trace(Log.l3_Util, "VSchedule.recreate (" + m_type + ") Resource_ID=" + S_Resource_ID, m_startDate + "->" + m_endDate); 122 MAssignmentSlot[] mas = m_model.getAssignmentSlots (S_Resource_ID, m_startDate, m_endDate, null, true); 124 MAssignmentSlot[] mts = m_model.getDayTimeSlots (); 125 timePanel.setTimeSlots(mts); 127 schedulePanel.setAssignmentSlots(mas, S_Resource_ID, m_startDate, m_endDate); 128 schedulePanel.setHeight(timePanel.getPreferredSize().height); 130 } 133 137 public void setCreateNew (boolean createNew) 138 { 139 schedulePanel.setCreateNew(createNew); 140 } 142 145 public void dispose() 146 { 147 m_model = null; 148 timePanel = null; 149 if (schedulePanel != null) 150 schedulePanel.dispose(); 151 schedulePanel = null; 152 this.removeAll(); 153 } 155 159 public Timestamp getStartDate() 160 { 161 return m_startDate; 162 } 164 } | Popular Tags |