📄 massignmentslot.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 Business Solution
* The Initial Developer of the Original Code is Jorg Janke and ComPiere, Inc.
* Portions created by Jorg Janke are Copyright (C) 1999-2002 Jorg Janke, parts
* created by ComPiere are Copyright (C) ComPiere, Inc.; All Rights Reserved.
* Contributor(s): ______________________________________.
*****************************************************************************/
package org.compiere.model;
import java.util.*;
import java.sql.*;
import java.awt.*;
import org.compiere.util.*;
/**
* Assignment Slot.
* Display Information about Assignment Slot
*
* @author Jorg Janke
* @version $Id: MAssignmentSlot.java,v 1.11 2002/08/12 01:55:12 danb Exp $
*/
public class MAssignmentSlot implements Comparator
{
/**
* Comparator Constructor
*/
public MAssignmentSlot ()
{
this (null, null, null, null, STATUS_TimeSlot);
} // MAssignmentSlot
/**
* Timeslot Constructor
* @param startTime start time
* @param endTime end time
*/
public MAssignmentSlot (Timestamp startTime, Timestamp endTime)
{
this (startTime, endTime, null, null, STATUS_TimeSlot);
setDisplay(DISPLAY_TIME_FROM);
} // MAssignmentSlot
/**
* Timeslot Constructor
* @param startTime start time
* @param endTime end time
*/
public MAssignmentSlot (long startTime, long endTime)
{
this (new Timestamp(startTime), new Timestamp(endTime), null, null, STATUS_TimeSlot);
setDisplay(DISPLAY_TIME_FROM);
} // MAssignmentSlot
/**
* Non Assignment Constructor
* @param startTime start time
* @param endTime end time
* @param name name
* @param description description
* @param status status
*/
public MAssignmentSlot (Timestamp startTime, Timestamp endTime,
String name, String description, int status)
{
setStartTime(startTime);
setEndTime(endTime);
setName(name);
setDescription(description);
setStatus(status);
//
// Log.trace(Log.l6_Database, toString());
} // MAssignmentSlot
/**
* Assignment Constructor
* @param assignment MAssignment
*/
public MAssignmentSlot (MAssignment assignment)
{
setStatus(assignment.isConfirmed() ? STATUS_Confirmed : STATUS_NotConfirmed);
setMAssignment(assignment);
// Log.trace(Log.l6_Database, toString());
} // MAssignmentSlot
/** Not Available Code */
public static final int STATUS_NotAvailable = 0;
/** Not Available Code */
public static final int STATUS_UnAvailable = 11;
/** Not Available Code */
public static final int STATUS_NonBusinessDay = 12;
/** Not Available Code */
public static final int STATUS_NotInSlotDay = 21;
/** Not Available Code */
public static final int STATUS_NotInSlotTime = 22;
/** Assignment Code */
public static final int STATUS_NotConfirmed = 101;
/** Assignment Code */
public static final int STATUS_Confirmed = 102;
/** Assignment Code */
public static final int STATUS_TimeSlot = 100000;
/** Start Time */
private Timestamp m_startTime;
/** End Time */
private Timestamp m_endTime;
/** Name */
private String m_name;
/** Description */
private String m_description;
/** Status */
private int m_status = STATUS_NotAvailable;
/** Y position */
private int m_yStart = 0;
private int m_yEnd = 0;
private int m_xPos = 0;
private int m_xMax = 1;
/** The assignment */
private MAssignment m_mAssignment;
/** Language used for formatting */
private Language m_language = Language.getLanguage();
/** toString displays everything */
public static final int DISPLAY_ALL = 0;
/** toString displays formatted time from */
public static final int DISPLAY_TIME_FROM = 1;
/** toString displays formatted time from-to */
public static final int DISPLAY_TIME_FROM_TO = 1;
/** toString displays formatted day time from-to */
public static final int DISPLAY_DATETIME_FROM_TO = 1;
/** toString displays name */
public static final int DISPLAY_NAME = 1;
/** toString displays name and optional description */
public static final int DISPLAY_NAME_DESCRIPTION = 1;
/** toString displays formatted all info */
public static final int DISPLAY_FULL = 1;
/** DisplayMode */
private int m_displayMode = DISPLAY_FULL;
/*************************************************************************/
/**
* Set Status
* @param status STATUS_..
*/
public void setStatus (int status)
{
m_status = status;
} // setStatus
/**
* Get Status
* @return STATUS_..
*/
public int getStatus()
{
return m_status;
} // getStatus
/**
* Is the Slot an Assignment?
* @return true if slot is an assignment
*/
public boolean isAssignment()
{
return (m_status == STATUS_NotConfirmed || m_status == STATUS_Confirmed);
} // isAssignment
/**
* Get Color for Status
* @param background true if background - or foreground
* @return Color
*/
public Color getColor (boolean background)
{
// Not found, Inactive, not available
if (m_status == STATUS_NotAvailable)
return background ? Color.gray : Color.magenta;
// Holiday
else if (m_status == STATUS_UnAvailable)
return background ? Color.gray : Color.pink;
// Vacation
else if (m_status == STATUS_NonBusinessDay)
return background ? Color.lightGray : Color.red;
// Out of normal hours
else if (m_status == STATUS_NotInSlotDay || m_status == STATUS_NotInSlotTime)
return background ? Color.lightGray : Color.black;
// Assigned
else if (m_status == STATUS_NotConfirmed)
return background ? Color.blue : Color.white;
// Confirmed
else if (m_status == STATUS_Confirmed)
return background ? Color.blue : Color.black;
// Unknown
return background ? Color.black : Color.white;
} // getColor
/*************************************************************************/
/**
* Get Start time
* @return start time
*/
public Timestamp getStartTime()
{
return m_startTime;
}
/**
* Set Start time
* @param startTime start time, if null use current time
*/
public void setStartTime (Timestamp startTime)
{
if (startTime == null)
m_startTime = new Timestamp(System.currentTimeMillis());
else
m_startTime = startTime;
} // setStartTime
/**
* Get End time
* @return end time
*/
public Timestamp getEndTime()
{
return m_endTime;
}
/**
* Set End time
* @param endTime end time, if null use start time
*/
public void setEndTime (Timestamp endTime)
{
if (endTime == null)
m_endTime = m_startTime;
else
m_endTime = endTime;
}
/*************************************************************************/
/**
* Set Assignment
* @param assignment MAssignment
*/
public void setMAssignment (MAssignment assignment)
{
if (assignment == null)
return;
if (!isAssignment())
throw new IllegalArgumentException("Assignment Slot not an Assignment");
//
m_mAssignment = assignment;
setStartTime(m_mAssignment.getAssignDateFrom());
setEndTime(m_mAssignment.getAssignDateTo());
setName(m_mAssignment.getName());
setDescription(m_mAssignment.getDescription());
setStatus(m_mAssignment.isConfirmed() ? STATUS_Confirmed : STATUS_NotConfirmed);
} // setMAssignment
/**
* Get Assugnment
* @return assignment
*/
public MAssignment getMAssignment()
{
return m_mAssignment;
} // getAssignment
/**
* Set Name
* @param name name
*/
public void setName (String name)
{
if (name == null)
m_name = "";
else
m_name = name;
} // setName
/**
* Get Name
* @return name
*/
public String getName()
{
return m_name;
} // getName
/**
* Set Description
* @param description description
*/
public void setDescription (String description)
{
if (description == null)
m_description = "";
else
m_description = description;
} // setDescription
/**
* Get Description
* @return description
*/
public String getDescription()
{
return m_description;
} // getDescription
/*************************************************************************/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -