⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 vschedule.java

📁 大家共享愉快, 共享愉快, 共享愉快, 共享愉快,共享愉快
💻 JAVA
字号:
/******************************************************************************
 * The contents of this file are subject to the   Compiere License  Version 1.1
 * ("License"); You may not use this file except in compliance with the License
 * You may obtain a copy of the License at http://www.compiere.org/license.html
 * Software distributed under the License is distributed on an  "AS IS"  basis,
 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
 * the specific language governing rights and limitations under the License.
 * The Original Code is Compiere ERP & CRM Smart Business Solution. The Initial
 * Developer of the Original Code is Jorg Janke. Portions created by Jorg Janke
 * are Copyright (C) 1999-2005 Jorg Janke.
 * All parts are Copyright (C) 1999-2005 ComPiere, Inc.  All Rights Reserved.
 * Contributor(s): ______________________________________.
 *****************************************************************************/
package org.compiere.apps.search;

import java.awt.*;
import java.sql.*;
import java.util.*;
import java.util.logging.*;
import javax.swing.*;

import org.compiere.model.*;
import org.compiere.util.*;
import org.compiere.swing.*;

/**
 *	Visual and Control Part of Schedule.
 *  Contains Time and Schedule Panels
 *
 * 	@author 	Jorg Janke
 * 	@version 	$Id: VSchedule.java,v 1.11 2005/10/08 02:03:04 jjanke Exp $
 */
public class VSchedule extends CPanel
{
	/**
	 *	Constructor
	 *  @param is InfoSchedule for call back
	 *  @param type Type of schedule TYPE_...
	 */
	public VSchedule (InfoSchedule is, int type)
	{
		m_type = type;
		m_model = new MSchedule (Env.getCtx());
		schedulePanel.setType (m_type);
		schedulePanel.setTimePanel (timePanel);
		schedulePanel.setInfoSchedule (is);	//	for callback
		try
		{
			jbInit();
		}
		catch(Exception e)
		{
			log.log(Level.SEVERE, "VSchedule", e);
		}
	}	//	VSchedule

	/**	Day Display				*/
	static public final int	TYPE_DAY = Calendar.DAY_OF_MONTH;
	/**	Week Display			*/
	static public final int	TYPE_WEEK = Calendar.WEEK_OF_YEAR;
	/**	Month Display			*/
	static public final int	TYPE_MONTH = Calendar.MONTH;

	/** Type					*/
	private int				m_type = TYPE_DAY;
	/** Model					*/
	private MSchedule		m_model = null;
	/**	 Start Date				*/
	private Timestamp		m_startDate;
	/**	End Date				*/
	private Timestamp		m_endDate;
	/**	Logger			*/
	private static CLogger log = CLogger.getCLogger(VSchedule.class);

	private BorderLayout mainLayout = new BorderLayout();
	private VScheduleTimePanel timePanel = new VScheduleTimePanel();
	private VSchedulePanel schedulePanel = new VSchedulePanel();
	private JScrollPane schedulePane = new JScrollPane();

	/**
	 * 	Static init
	 *  <pre>
	 * 	timePanel (West)
	 *  schedlePanel (in schedulePane - Center)
	 *  </pre>
	 * 	@throws Exception
	 */
	private void jbInit() throws Exception
	{
		this.setLayout(mainLayout);
		this.add(timePanel, BorderLayout.WEST);
		//
	//	schedulePane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
		schedulePane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_NEVER);
		schedulePane.getViewport().add(schedulePanel, null);
		schedulePane.setPreferredSize(new Dimension(200, 200));
		schedulePane.setBorder(null);
		this.add(schedulePane, BorderLayout.CENTER);
	}	//	jbInit

	/**
	 * 	Recreate View
	 * 	@param S_Resource_ID Resource
	 * 	@param date Date
	 */
	public void recreate (int S_Resource_ID, Timestamp date)
	{
		//	Calculate Start Day
		GregorianCalendar cal = new GregorianCalendar();
		cal.setTime(date);
		cal.set(Calendar.HOUR, 0);
		cal.set(Calendar.MINUTE, 0);
		cal.set(Calendar.SECOND, 0);
		cal.set(Calendar.MILLISECOND, 0);
		if (m_type == TYPE_WEEK)
			cal.set(Calendar.DAY_OF_WEEK, cal.getFirstDayOfWeek());
		else if (m_type == TYPE_MONTH)
			cal.set(Calendar.DAY_OF_MONTH, 1);
		m_startDate = new Timestamp(cal.getTimeInMillis());
		//	Calculate End Date
		cal.add(m_type, 1);
		m_endDate = new Timestamp (cal.getTimeInMillis());
		//
		log.config("(" + m_type + ") Resource_ID=" + S_Resource_ID + ": " + m_startDate + "->" + m_endDate);
		//	Create Slots
		MAssignmentSlot[] mas = m_model.getAssignmentSlots (S_Resource_ID, m_startDate, m_endDate, null, true, null);
		MAssignmentSlot[] mts = m_model.getDayTimeSlots ();
		//	Set Panels
		timePanel.setTimeSlots(mts);
		schedulePanel.setAssignmentSlots(mas, S_Resource_ID, m_startDate, m_endDate);
		//	Set Height
		schedulePanel.setHeight(timePanel.getPreferredSize().height);
	//	repaint();
	}	//	recreate

	/**
	 * 	Enable/disable to Create New Assignments
	 * 	@param createNew if true, allows to create new Assignments
	 */
	public void setCreateNew (boolean createNew)
	{
		schedulePanel.setCreateNew(createNew);
	}	//	setCreateNew

	/**
	 * 	Dispose
	 */
	public void dispose()
	{
		m_model = null;
		timePanel = null;
		if (schedulePanel != null)
			schedulePanel.dispose();
		schedulePanel = null;
		this.removeAll();
	}	//	dispose

	/**
	 * 	Get Start Date
	 * 	@return start date
	 */
	public Timestamp getStartDate()
	{
		return m_startDate;
	}	//	getStartDate

}	//	VSchedule

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -