* Started implementation for resource schedule and assignment.

This commit is contained in:
Heng Sin Low 2008-07-23 08:50:27 +00:00
parent d1ab1ad3e3
commit 7edf003267
9 changed files with 749 additions and 6 deletions

View File

@ -20,5 +20,7 @@
<classpathentry kind="lib" path="WEB-INF/lib/zkplus.jar" sourcepath="WEB-INF/lib/zkplus-sources.jar"/> <classpathentry kind="lib" path="WEB-INF/lib/zkplus.jar" sourcepath="WEB-INF/lib/zkplus-sources.jar"/>
<classpathentry kind="lib" path="WEB-INF/lib/zhtml.jar"/> <classpathentry kind="lib" path="WEB-INF/lib/zhtml.jar"/>
<classpathentry kind="lib" path="/tools/lib/j2ee.jar"/> <classpathentry kind="lib" path="/tools/lib/j2ee.jar"/>
<classpathentry kind="lib" path="WEB-INF/lib/timelinez.jar" sourcepath="WEB-INF/lib/timelinez-sources.jar"/>
<classpathentry kind="lib" path="WEB-INF/lib/zweb.jar"/>
<classpathentry kind="output" path="WEB-INF/classes"/> <classpathentry kind="output" path="WEB-INF/classes"/>
</classpath> </classpath>

View File

@ -53,5 +53,20 @@
<webClassPathEntry>/tools/lib/swingx-0.9.0.jar</webClassPathEntry> <webClassPathEntry>/tools/lib/swingx-0.9.0.jar</webClassPathEntry>
<webClassPathEntry>/tools/lib/xdoclet-1.2.3.jar</webClassPathEntry> <webClassPathEntry>/tools/lib/xdoclet-1.2.3.jar</webClassPathEntry>
<webClassPathEntry>/tools/lib/xercesImpl.jar</webClassPathEntry> <webClassPathEntry>/tools/lib/xercesImpl.jar</webClassPathEntry>
<webClassPathEntry>/zkwebui/WEB-INF/classes</webClassPathEntry>
<webClassPathEntry>/zkwebui/WEB-INF/lib/junit.jar</webClassPathEntry>
<webClassPathEntry>/zkwebui/WEB-INF/lib/timelinez.jar</webClassPathEntry>
<webClassPathEntry>/zkwebui/WEB-INF/lib/zcommon.jar</webClassPathEntry>
<webClassPathEntry>/zkwebui/WEB-INF/lib/zhtml.jar</webClassPathEntry>
<webClassPathEntry>/zkwebui/WEB-INF/lib/zk.jar</webClassPathEntry>
<webClassPathEntry>/zkwebui/WEB-INF/lib/zkex.jar</webClassPathEntry>
<webClassPathEntry>/zkwebui/WEB-INF/lib/zkmax.jar</webClassPathEntry>
<webClassPathEntry>/zkwebui/WEB-INF/lib/zkplus.jar</webClassPathEntry>
<webClassPathEntry>/zkwebui/WEB-INF/lib/zul.jar</webClassPathEntry>
<webClassPathEntry>C:/Users/Low Heng Sin/Applications/eclipse/plugins/org.junit_3.8.2.v200706111738/junit.jar</webClassPathEntry>
<webClassPathEntry>org.eclipse.jdt.junit.JUNIT_CONTAINER/3</webClassPathEntry>
<webClassPathEntry>org.eclipse.jst.j2ee.internal.module.container</webClassPathEntry>
<webClassPathEntry>org.eclipse.jst.j2ee.internal.web.container</webClassPathEntry>
<webClassPathEntry>org.eclipse.jst.server.core.container/org.eclipse.jst.server.tomcat.runtimeTarget/C-_applications_apache-tomcat-5.5.26</webClassPathEntry>
</webClassPathEntries> </webClassPathEntries>
</tomcatProjectProperties> </tomcatProjectProperties>

View File

@ -43,6 +43,7 @@ import org.adempiere.webui.panel.SidePanel;
import org.adempiere.webui.part.AbstractUIPart; import org.adempiere.webui.part.AbstractUIPart;
import org.adempiere.webui.part.WindowContainer; import org.adempiere.webui.part.WindowContainer;
import org.adempiere.webui.window.ADWindow; import org.adempiere.webui.window.ADWindow;
import org.adempiere.webui.window.InfoSchedule;
import org.compiere.model.MClient; import org.compiere.model.MClient;
import org.compiere.model.MMenu; import org.compiere.model.MMenu;
import org.compiere.model.MQuery; import org.compiere.model.MQuery;
@ -500,6 +501,7 @@ public class Desktop extends AbstractUIPart implements MenuListener, Serializabl
{ {
// TODO: Schedule Info Panel // TODO: Schedule Info Panel
// new org.compiere.apps.search.InfoSchedule (Env.getFrame(c), null, false); // new org.compiere.apps.search.InfoSchedule (Env.getFrame(c), null, false);
new InfoSchedule(null, false);
} }
else if (actionCommand.equals("InfoOrder") && AEnv.canAccessInfo("ORDER")) else if (actionCommand.equals("InfoOrder") && AEnv.canAccessInfo("ORDER"))
{ {

View File

@ -0,0 +1,127 @@
package org.adempiere.webui;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.PrintWriter;
import java.sql.Timestamp;
import java.text.DateFormat;
import java.text.ParseException;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.adempiere.webui.component.ZkCssHelper;
import org.adempiere.webui.session.SessionContextListener;
import org.adempiere.webui.session.WebContext;
import org.compiere.model.MAssignmentSlot;
import org.compiere.model.ScheduleUtil;
import org.compiere.util.Env;
import org.zkforge.timeline.util.TimelineUtil;
import org.zkoss.web.fn.XMLFns;
import org.zkoss.xml.XMLs;
public class TimelineEventFeed extends HttpServlet {
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException {
WebContext ctx = (WebContext)req.getSession().getAttribute(SessionContextListener.SESSION_CTX);
if (ctx == null) {
return;
} else {
WebContext.setCurrentInstance(ctx);
}
int resourceId = 0;
String resourceIdParam = req.getParameter("S_Resource_ID");
if (resourceIdParam != null && resourceIdParam.trim().length() > 0) {
try {
resourceId = Integer.parseInt(resourceIdParam.trim());
} catch (Exception e) {
return;
}
} else {
return;
}
String uuid = req.getParameter("uuid");
if (uuid == null || uuid.trim().length() == 0) return;
Date date = null;
String dateParam = req.getParameter("date");
if (dateParam != null && dateParam.trim().length() > 0) {
try {
date = DateFormat.getInstance().parse(dateParam);
} catch (ParseException e) {
return;
}
} else {
return;
}
resp.setContentType("application/xml");
ScheduleUtil m_model = new ScheduleUtil (Env.getCtx());
// 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);
cal.set(Calendar.DAY_OF_MONTH, 1);
Timestamp startDate = new Timestamp(cal.getTimeInMillis());
// Calculate End Date
cal.add(Calendar.MONTH, 1);
Timestamp endDate = new Timestamp (cal.getTimeInMillis());
MAssignmentSlot[] mas = m_model.getAssignmentSlots (resourceId, startDate, endDate, null, true, null);
if (mas == null || mas.length == 0) return;
StringBuffer xml = new StringBuffer();
xml.append("<data>").append("\r\n");
for (MAssignmentSlot slot : mas) {
xml.append("<event ").append("\r\n");
xml.append(XMLFns.attr("start", TimelineUtil.formatDateTime(new Date(slot.getStartTime().getTime()))));
if (slot.getEndTime() != null) {
xml.append("\r\n");
xml.append(XMLFns.attr("end", TimelineUtil.formatDateTime(new Date(slot.getEndTime().getTime()))));
xml.append("\r\n");
xml.append(XMLFns.attr("isDuration", "true"));
}
xml.append(XMLFns.attr("color", "#"+ZkCssHelper.createHexColorString(slot.getColor(true))));
xml.append("\r\n")
.append(XMLFns.attr("title", slot.getName()))
.append("\r\n")
.append(">");
if (slot.getDescription() != null && slot.getDescription().trim().length() > 0) {
xml.append("\r\n")
.append(XMLs.encodeText(slot.getDescription()))
.append("<br/>");
}
if (slot.getMAssignment() != null) {
//encode assignment id as coordinate x
String link = "<a href=\"javascript:void(0)\" onclick=\""
+ "zkau.send({uuid: '" + uuid + "', cmd: 'onClick', data: "
+ "[" + slot.getMAssignment().getS_ResourceAssignment_ID() + ", 0]"
+ ", ctl: true})\">Edit</a>";
xml.append("\r\n").append(XMLs.encodeText(link));
}
xml.append("\r\n").append("</event>").append("\r\n");
}
xml.append("</data>").append("\r\n");
PrintWriter writer = resp.getWriter();
BufferedWriter buffer = new BufferedWriter(writer);
buffer.write(xml.toString());
buffer.flush();
}
}

View File

@ -0,0 +1,143 @@
/******************************************************************************
* Product: Adempiere ERP & CRM Smart Business Solution *
* Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. *
* This program is free software; you can redistribute it and/or modify it *
* under the terms version 2 of the GNU General Public License as published *
* by the Free Software Foundation. This program is distributed in the hope *
* that it will be useful, but WITHOUT ANY WARRANTY; without even the implied *
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
* See the GNU General Public License for more details. *
* You should have received a copy of the GNU General Public License along *
* with this program; if not, write to the Free Software Foundation, Inc., *
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
* For the text or an alternative of this public license, you may reach us *
* ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA *
* or via info@compiere.org or http://www.compiere.org/license.html *
*****************************************************************************/
package org.adempiere.webui.panel;
import java.text.DateFormat;
import java.util.*;
import java.util.logging.*;
import org.adempiere.webui.component.Panel;
import org.adempiere.webui.component.ToolBarButton;
import org.adempiere.webui.window.InfoSchedule;
import org.compiere.util.*;
import org.zkforge.timeline.Bandinfo;
import org.zkforge.timeline.Timeline;
import org.zkoss.zk.ui.event.Event;
import org.zkoss.zk.ui.event.EventListener;
import org.zkoss.zk.ui.event.Events;
/**
* Visual and Control Part of Schedule.
* Contains Time and Schedule Panels
*
* @author Jorg Janke
* @version $Id: VSchedule.java,v 1.3 2006/07/30 00:51:27 jjanke Exp $
*/
public class WSchedule extends Panel implements EventListener
{
private InfoSchedule infoSchedule;
/**
* Constructor
* @param is InfoSchedule for call back
* @param type Type of schedule TYPE_...
*/
public WSchedule (InfoSchedule is)
{
infoSchedule = is;
try
{
init();
}
catch(Exception e)
{
log.log(Level.SEVERE, "VSchedule", e);
}
} // WSchedule
/** Logger */
private static CLogger log = CLogger.getCLogger(WSchedule.class);
Timeline schedulePanel;
private Bandinfo hourBand;
private Bandinfo dayBand;
private ToolBarButton button;
/**
* Static init
* <pre>
* timePanel (West)
* schedlePanel (in schedulePane - Center)
* </pre>
* @throws Exception
*/
private void init() throws Exception
{
schedulePanel = new Timeline();
schedulePanel.setHeight("400px");
schedulePanel.setWidth("100%");
schedulePanel.setId("resoureSchedule");
this.appendChild(schedulePanel);
hourBand = new Bandinfo();
schedulePanel.appendChild(hourBand);
hourBand.setIntervalUnit("hour");
hourBand.setWidth("60%");
hourBand.setIntervalPixels(40);
hourBand.setId("hour");
hourBand.setTimeZone(TimeZone.getDefault());
dayBand = new Bandinfo();
schedulePanel.appendChild(dayBand);
dayBand.setIntervalUnit("day");
dayBand.setWidth("40%");
dayBand.setIntervalPixels(100);
dayBand.setId("day");
dayBand.setSyncWith("hour");
dayBand.setTimeZone(TimeZone.getDefault());
dayBand.setShowEventText(false);
button = new ToolBarButton();
button.setLabel("Edit");
button.setStyle("visibility: hidden; height: 0px; width: 0px");
button.addEventListener(Events.ON_CLICK, this);
this.appendChild(button);
} // jbInit
/**
* Recreate View
* @param S_Resource_ID Resource
* @param date Date
*/
public void recreate (int S_Resource_ID, Date date)
{
hourBand.setDate(date);
hourBand.scrollToCenter(date);
String feedUrl = "timeline?S_Resource_ID=" + S_Resource_ID + "&date=" + DateFormat.getInstance().format(date)
+ "&uuid=" + button.getUuid();
hourBand.setEventSourceUrl(feedUrl);
dayBand.setEventSourceUrl(feedUrl);
schedulePanel.invalidate();
} // 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
public void onEvent(Event event) throws Exception {
//TODO: Edit, S_ResourceAssignment_ID is in MouseEvent.x
}
} // WSchedule

View File

@ -95,7 +95,7 @@ public class MultiTabPart extends AbstractUIPart
tabbox.getSelectedTab().onClose(); tabbox.getSelectedTab().onClose();
} }
public Component getComponent() { public Tabbox getComponent() {
return tabbox; return tabbox;
} }
} }

View File

@ -38,7 +38,7 @@ import org.zkoss.zkplus.util.ThreadLocals;
public class SessionContextListener implements ExecutionInit, public class SessionContextListener implements ExecutionInit,
ExecutionCleanup, EventThreadInit, EventThreadResume ExecutionCleanup, EventThreadInit, EventThreadResume
{ {
private static final String SESSION_CTX = "WebUISessionContext"; public static final String SESSION_CTX = "WebUISessionContext";
public void init(Execution exec, Execution parent) public void init(Execution exec, Execution parent)
{ {
@ -48,9 +48,9 @@ public class SessionContextListener implements ExecutionInit,
if (ctx == null) if (ctx == null)
{ {
ctx = new WebContext(); ctx = new WebContext();
setWebContext(ctx);
exec.getDesktop().getSession().setAttribute(SESSION_CTX, ctx); exec.getDesktop().getSession().setAttribute(SESSION_CTX, ctx);
} }
setWebContext(ctx);
exec.setAttribute(SESSION_CTX, ctx); exec.setAttribute(SESSION_CTX, ctx);
} }
} }
@ -93,9 +93,10 @@ public class SessionContextListener implements ExecutionInit,
} }
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
private void setWebContext(WebContext ctx) public void setWebContext(WebContext ctx)
{ {
getContextThreadLocal().set(ctx); getContextThreadLocal().set(ctx);
WebContext.setCurrentInstance(ctx);
} }
private ThreadLocal getContextThreadLocal() private ThreadLocal getContextThreadLocal()

View File

@ -0,0 +1,442 @@
/******************************************************************************
* Product: Adempiere ERP & CRM Smart Business Solution *
* Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. *
* This program is free software; you can redistribute it and/or modify it *
* under the terms version 2 of the GNU General Public License as published *
* by the Free Software Foundation. This program is distributed in the hope *
* that it will be useful, but WITHOUT ANY WARRANTY; without even the implied *
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
* See the GNU General Public License for more details. *
* You should have received a copy of the GNU General Public License along *
* with this program; if not, write to the Free Software Foundation, Inc., *
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
* For the text or an alternative of this public license, you may reach us *
* ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA *
* or via info@compiere.org or http://www.compiere.org/license.html *
*****************************************************************************/
package org.adempiere.webui.window;
import java.sql.*;
import java.util.*;
import java.util.Date;
import java.util.logging.*;
import org.adempiere.webui.apps.AEnv;
import org.adempiere.webui.component.Button;
import org.adempiere.webui.component.ConfirmPanel;
import org.adempiere.webui.component.Datebox;
import org.adempiere.webui.component.Grid;
import org.adempiere.webui.component.Label;
import org.adempiere.webui.component.ListItem;
import org.adempiere.webui.component.Listbox;
import org.adempiere.webui.component.Row;
import org.adempiere.webui.component.Rows;
import org.adempiere.webui.component.Window;
import org.adempiere.webui.panel.StatusBarPanel;
import org.adempiere.webui.panel.WSchedule;
import org.compiere.model.*;
import org.compiere.util.*;
import org.zkoss.zk.ui.event.Event;
import org.zkoss.zk.ui.event.EventListener;
import org.zkoss.zk.ui.event.Events;
import org.zkoss.zul.Div;
import org.zkoss.zul.Vbox;
/**
* Schedule - Resource availability & assigment.
*
* @author Jorg Janke
* @version $Id: InfoSchedule.java,v 1.2 2006/07/30 00:51:27 jjanke Exp $
*
* Zk Port
* @author Low Heng Sin
*/
public class InfoSchedule extends Window implements EventListener //, ChangeListener
{
/**
* Constructor
* @param mAssignment optional assignment
* @param createNew if true, allows to create new assignments
*/
public InfoSchedule (MResourceAssignment mAssignment, boolean createNew)
{
super();
setTitle(Msg.getMsg(Env.getCtx(), "InfoSchedule"));
// setAttribute("modal", Boolean.valueOf(createNew));
setAttribute("mode", "overlapped");
this.setWidth("600px");
this.setHeight("600px");
this.setBorder("normal");
this.setStyle("position: absolute");
if (mAssignment == null)
m_mAssignment = new MResourceAssignment(Env.getCtx(), 0, null);
else
m_mAssignment = mAssignment;
if (mAssignment != null)
log.info(mAssignment.toString());
m_dateFrom = m_mAssignment.getAssignDateFrom();
if (m_dateFrom == null)
m_dateFrom = new Timestamp(System.currentTimeMillis());
m_createNew = createNew;
try
{
init();
dynInit(createNew);
}
catch(Exception ex)
{
log.log(Level.SEVERE, "InfoSchedule", ex);
}
AEnv.showWindow(this);
} // InfoSchedule
/**
* IDE Constructor
*/
public InfoSchedule()
{
this (null, false);
} // InfoSchedule
/** Resource */
private MResourceAssignment m_mAssignment;
/** Date */
private Timestamp m_dateFrom = null;
/** Loading */
private boolean m_loading = false;
/** Ability to create new assignments */
private boolean m_createNew;
/** Logger */
private static CLogger log = CLogger.getCLogger(InfoSchedule.class);
private Vbox mainLayout = new Vbox();
private Grid parameterPanel = new Grid();
private Label labelResourceType = new Label();
private Listbox fieldResourceType = new Listbox();
private Label labelResource = new Label();
private Listbox fieldResource = new Listbox();
private Button bPrevious = new Button();
private Label labelDate = new Label();
private Datebox fieldDate = new Datebox();
private Button bNext = new Button();
private WSchedule schedulePane = new WSchedule(this);
private StatusBarPanel statusBar = new StatusBarPanel();
private ConfirmPanel confirmPanel = new ConfirmPanel(true);
/**
* Static Layout
* @throws Exception
*/
private void init() throws Exception
{
this.appendChild(mainLayout);
mainLayout.setHeight("100%");
mainLayout.setWidth("100%");
labelResourceType.setValue(Msg.translate(Env.getCtx(), "S_ResourceType_ID"));
labelResource.setValue(Msg.translate(Env.getCtx(), "S_Resource_ID"));
bPrevious.setLabel("<");
labelDate.setValue(Msg.translate(Env.getCtx(), "Date"));
bNext.setLabel(">");
mainLayout.appendChild(parameterPanel);
Rows rows = new Rows();
rows.setParent(parameterPanel);
Row row = new Row();
rows.appendChild(row);
row.appendChild(labelResourceType);
row.appendChild(labelResource);
row.appendChild(bPrevious);
row.appendChild(labelDate);
row.appendChild(bNext);
row = new Row();
rows.appendChild(row);
row.appendChild(fieldResourceType);
row.appendChild(fieldResource);
row.appendChild(new Label(" "));
row.appendChild(fieldDate);
//
mainLayout.appendChild(schedulePane);
schedulePane.setWidth("100%");
schedulePane.setHeight("400px");
Div div = new Div();
div.appendChild(confirmPanel);
div.appendChild(statusBar);
mainLayout.appendChild(div);
fieldResourceType.setMold("select");
fieldResource.setMold("select");
} // jbInit
/**
* Dynamic Init
* @param createNew if true, allows to create new assignments
*/
private void dynInit (boolean createNew)
{
// Resource
fillResourceType();
fillResource();
fieldResourceType.addEventListener(Events.ON_SELECT, this);
fieldResource.addEventListener(Events.ON_SELECT, this);
// Date
fieldDate.setValue(m_dateFrom);
fieldDate.addEventListener(Events.ON_CHANGE, this);
bPrevious.addEventListener(Events.ON_CLICK, this);
bNext.addEventListener(Events.ON_CLICK, this);
//
confirmPanel.addActionListener(Events.ON_CLICK, this);
Button button = confirmPanel.createButton("Add");
confirmPanel.addComponentsLeft(button);
button.addEventListener(Events.ON_CLICK, this);
button.setLabel("Add");
displayCalendar();
} // dynInit
/**
* Fill Resource Type (one time)
*/
private void fillResourceType()
{
// Get ResourceType of selected Resource
int S_ResourceType_ID = 0;
if (m_mAssignment.getS_Resource_ID() != 0)
{
String sql = "SELECT S_ResourceType_ID FROM S_Resource WHERE S_Resource_ID=?";
try
{
PreparedStatement pstmt = DB.prepareStatement(sql, null);
pstmt.setInt(1, m_mAssignment.getS_Resource_ID());
ResultSet rs = pstmt.executeQuery();
if (rs.next())
S_ResourceType_ID = rs.getInt(1);
rs.close();
pstmt.close();
}
catch (SQLException e)
{
log.log(Level.SEVERE, sql, e);
}
}
// Get Resource Types
String sql = MRole.getDefault().addAccessSQL(
"SELECT S_ResourceType_ID, Name FROM S_ResourceType WHERE IsActive='Y' ORDER BY 2",
"S_ResourceType", MRole.SQL_NOTQUALIFIED, MRole.SQL_RO);
KeyNamePair defaultValue = null;
try
{
PreparedStatement pstmt = DB.prepareStatement(sql, null);
ResultSet rs = pstmt.executeQuery();
while (rs.next())
{
KeyNamePair pp = new KeyNamePair(rs.getInt(1), rs.getString(2));
if (S_ResourceType_ID == pp.getKey())
defaultValue = pp;
fieldResourceType.appendItem(pp.getName(), pp.getKey());
}
rs.close();
pstmt.close();
}
catch (SQLException e)
{
log.log(Level.SEVERE, sql, e);
}
if (defaultValue != null) {
int cnt = fieldResourceType.getItemCount();
for(int i = 0; i < cnt; i++) {
ListItem li = fieldResourceType.getItemAtIndex(i);
Integer key = (Integer) li.getValue();
if (key.intValue() == defaultValue.getKey()) {
fieldResourceType.setSelectedItem(li);
break;
}
}
} else if (fieldResourceType.getItemCount() > 0) {
fieldResourceType.setSelectedIndex(0);
}
} // fillResourceType
/**
* Fill Resource Pick from Resource Type
*/
private void fillResource()
{
ListItem listItem = fieldResourceType.getSelectedItem();
if (listItem == null)
return;
// Get Resource Type
KeyNamePair pp = new KeyNamePair((Integer)listItem.getValue(), listItem.getLabel());
int S_ResourceType_ID = pp.getKey();
KeyNamePair defaultValue = null;
// Load Resources
m_loading = true;
fieldResource.getChildren().clear();
String sql = "SELECT S_Resource_ID, Name FROM S_Resource WHERE S_ResourceType_ID=? ORDER BY 2";
try
{
PreparedStatement pstmt = DB.prepareStatement(sql, null);
pstmt.setInt(1, S_ResourceType_ID);
ResultSet rs = pstmt.executeQuery();
while (rs.next())
{
pp = new KeyNamePair(rs.getInt(1), rs.getString(2));
if (m_mAssignment.getS_Resource_ID() == pp.getKey())
defaultValue = pp;
fieldResource.appendItem(pp.getName(), pp.getKey());
}
rs.close();
pstmt.close();
}
catch (SQLException e)
{
log.log(Level.SEVERE, sql, e);
}
if (defaultValue != null) {
int cnt = fieldResource.getItemCount();
for(int i = 0; i < cnt; i++) {
ListItem li = fieldResource.getItemAtIndex(i);
Integer key = (Integer) li.getValue();
if (key.intValue() == defaultValue.getKey()) {
fieldResource.setSelectedItem(li);
break;
}
}
} else if ( fieldResource.getItemCount() > 0) {
fieldResource.setSelectedIndex(0);
}
m_loading = false;
} // fillResource
/**
* Display Calendar for selected Resource, Time(day/week/month) and Date
*/
private void displayCalendar ()
{
// Get Values
ListItem listItem = fieldResource.getSelectedItem();
if (listItem == null)
return;
KeyNamePair pp = new KeyNamePair((Integer)listItem.getValue(), listItem.getLabel());
int S_Resource_ID = pp.getKey();
m_mAssignment.setS_Resource_ID(S_Resource_ID);
Date date = fieldDate.getValue();
// Set Info
m_loading = true;
schedulePane.recreate(S_Resource_ID, date);
m_loading = false;
invalidate();
} // displayCalendar
/**************************************************************************
* Dispose.
*/
public void dispose()
{
this.detach();
} // dispose
/**
* Adjust Date
* @param diff difference
*/
private void adjustDate (int diff)
{
Date date = fieldDate.getValue();
GregorianCalendar cal = new GregorianCalendar();
cal.setTime(date);
cal.add(java.util.Calendar.DAY_OF_YEAR, diff);
fieldDate.setValue(new Date(cal.getTimeInMillis()));
displayCalendar ();
} // adjustDate
/*************************************************************************/
/**
* Callback.
* Called from VSchedulePanel after VAssignmentDialog finished
* @param assignment New/Changed Assignment
*/
public void mAssignmentCallback (MResourceAssignment assignment)
{
m_mAssignment = assignment;
if (m_createNew)
dispose();
else
displayCalendar();
} // mAssignmentCallback
/**
* Get Assignment
* @return Assignment
*/
public MResourceAssignment getMResourceAssignment()
{
return m_mAssignment;
} // getMResourceAssignment
public void onEvent(Event event) throws Exception {
if (m_loading)
return;
if (event.getTarget().getId().equals("Ok"))
dispose();
else if (event.getTarget().getId().equals("Cancel"))
dispose();
//
else if (event.getTarget() == fieldResourceType)
{
fillResource();
displayCalendar();
}
//
else if (event.getTarget() == fieldResource || event.getTarget() == fieldDate)
displayCalendar();
//
else if (event.getTarget() == bPrevious)
adjustDate(-1);
else if (event.getTarget() == bNext)
adjustDate(+1);
else if (event.getTarget().getId().equals("Add"))
doAdd();
//
}
private void doAdd() {
// TODO Auto-generated method stub
}
/**
SELECT o.DocumentNo, ol.Line, ol.Description
FROM C_OrderLine ol, C_Order o
WHERE ol.S_ResourceAssignment_ID=1
AND ol.C_Order_ID=o.C_Order_ID
UNION
SELECT i.DocumentNo, il.Line, il.Description
FROM C_InvoiceLine il, C_Invoice i
WHERE il.S_ResourceAssignment_ID=1
AND il.C_Invoice_ID=i.C_Invoice_ID
UNION
SELECT e.DocumentNo, el.Line, el.Description
FROM S_TimeExpenseLine el, S_TimeExpense e
WHERE el.S_ResourceAssignment_ID=1
AND el.S_TimeExpense_ID=el.S_TimeExpense_ID
*/
} // InfoSchedule

View File

@ -65,6 +65,17 @@
<url-pattern>/zkau/*</url-pattern> <url-pattern>/zkau/*</url-pattern>
</servlet-mapping> </servlet-mapping>
<!-- //// --> <!-- //// -->
<servlet>
<description>servlet to provide timeline xml event feed</description>
<servlet-name>timelineFeed</servlet-name>
<servlet-class>
org.adempiere.webui.TimelineEventFeed
</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>timelineFeed</servlet-name>
<url-pattern>/timeline</url-pattern>
</servlet-mapping>
<!-- /////////// --> <!-- /////////// -->
<!-- Miscellaneous --> <!-- Miscellaneous -->