Search in sources :

Example 1 with VAssignmentDialog

use of org.compiere.grid.ed.VAssignmentDialog in project adempiere by adempiere.

the class VSchedulePanel method mouseClicked.

//	getHeading
/**
	 *	Mouse Clicked. Start AssignmentDialog
	 * 	@param e event
	 */
public void mouseClicked(MouseEvent e) {
    if (e.getClickCount() < 2)
        return;
    log.finer(e.toString());
    Rectangle hitRect = new Rectangle(e.getX() - 1, e.getY() - 1, 3, 3);
    //	Day
    int dayIndex = e.getX() / m_dayWidth;
    if (dayIndex >= m_noDays)
        dayIndex = m_noDays - 1;
    //	System.out.println("DayIndex=" + dayIndex + ": " + TimeUtil.addDays(m_startDate, dayIndex));
    //	Time
    int timeIndex = m_timePanel.getTimeSlotIndex(e.getY());
    //	check if there is an existing assignment
    for (int i = 0; i < m_slots.length; i++) {
        if (m_where[i].intersects(hitRect)) {
            MAssignmentSlot mas = m_slots[i];
            System.out.println("Existing=" + mas.getInfo());
            if (!mas.isAssignment())
                return;
            //
            VAssignmentDialog vad = new VAssignmentDialog(Env.getFrame(this), m_slots[i].getMAssignment(), false, m_createNew);
            m_infoSchedule.mAssignmentCallback(vad.getMResourceAssignment());
            return;
        }
    }
    if (m_createNew) {
        MResourceAssignment ma = new MResourceAssignment(Env.getCtx(), 0, null);
        ma.setS_Resource_ID(m_S_Resource_ID);
        ma.setAssignDateFrom(TimeUtil.getDayTime(TimeUtil.addDays(m_startDate, dayIndex), m_timePanel.getTimeSlot(timeIndex).getStartTime()));
        ma.setQty(new BigDecimal(1));
        VAssignmentDialog vad = new VAssignmentDialog(Env.getFrame(this), ma, false, m_createNew);
        m_infoSchedule.mAssignmentCallback(vad.getMResourceAssignment());
        return;
    }
}
Also used : MResourceAssignment(org.compiere.model.MResourceAssignment) MAssignmentSlot(org.compiere.model.MAssignmentSlot) Rectangle(java.awt.Rectangle) VAssignmentDialog(org.compiere.grid.ed.VAssignmentDialog) BigDecimal(java.math.BigDecimal)

Aggregations

Rectangle (java.awt.Rectangle)1 BigDecimal (java.math.BigDecimal)1 VAssignmentDialog (org.compiere.grid.ed.VAssignmentDialog)1 MAssignmentSlot (org.compiere.model.MAssignmentSlot)1 MResourceAssignment (org.compiere.model.MResourceAssignment)1