use of org.compiere.model.MResource in project adempiere by adempiere.
the class VCRP method actionPerformed.
@Override
public void actionPerformed(ActionEvent e) {
if (e.getActionCommand().equals(ConfirmPanel.A_OK)) {
Timestamp date = null;
if (dateFrom.getValue() != null)
date = (Timestamp) dateFrom.getValue();
int S_Resource_ID = 0;
if (resource.getValue() != null)
S_Resource_ID = ((Integer) resource.getValue()).intValue();
if (date != null && S_Resource_ID != 0) {
MResource r = MResource.get(Env.getCtx(), S_Resource_ID);
int uom_id = r.getResourceType().getC_UOM_ID();
MUOM uom = MUOM.get(Env.getCtx(), uom_id);
CategoryDataset dataset = null;
if (uom.isHour()) {
dataset = createDataset(date, r);
} else {
dataset = createWeightDataset(date, r);
}
String title = r.getName() != null ? r.getName() : "";
title = title + " " + r.getDescription() != null ? r.getDescription() : "";
JFreeChart jfreechart = createChart(dataset, title, uom);
centerPanel.removeAll();
chartPanel = new ChartPanel(jfreechart, false);
centerPanel.add(chartPanel, BorderLayout.CENTER);
centerPanel.setVisible(true);
m_frame.pack();
}
}
if (e.getActionCommand().equals(ConfirmPanel.A_CANCEL)) {
dispose();
}
}
use of org.compiere.model.MResource in project adempiere by adempiere.
the class CRPDetail method getSourceUOM.
public MUOM getSourceUOM(Object value) {
MResource r = getResource(value);
int uom_id = r.getResourceType().getC_UOM_ID();
return (uom_id > 0) ? MUOM.get(Env.getCtx(), uom_id) : null;
}
use of org.compiere.model.MResource in project adempiere by adempiere.
the class MRPUtil method getCreatePlant.
/**
* Helper Method : Create Plant (S_Resource_ID)
*/
public static I_S_Resource getCreatePlant(String value, int M_Warehouse_ID, int PlanningHorizon) {
Properties ctx = Env.getCtx();
int AD_Client_ID = Env.getAD_Client_ID(ctx);
String whereClause = MResource.COLUMNNAME_Value + "=? AND AD_Client_ID=?";
MResource r = new Query(ctx, MResource.Table_Name, whereClause, null).setParameters(new Object[] { value, AD_Client_ID }).firstOnly();
if (r == null) {
r = new MResource(ctx, 0, null);
int S_ResourceType_ID = DB.getSQLValueEx(null, "SELECT MIN(S_ResourceType_ID) FROM S_Resource WHERE AD_Client_ID=? AND IsAvailable=?", AD_Client_ID, true);
r.setS_ResourceType_ID(S_ResourceType_ID);
}
r.setValue(value);
r.setName(value);
r.setIsManufacturingResource(true);
r.setManufacturingResourceType(MResource.MANUFACTURINGRESOURCETYPE_Plant);
r.setIsAvailable(true);
r.setM_Warehouse_ID(M_Warehouse_ID);
r.setPlanningHorizon(PlanningHorizon);
r.setPercentUtilization(Env.ONEHUNDRED);
r.saveEx();
return r;
}
use of org.compiere.model.MResource in project adempiere by adempiere.
the class VCRPDetail method handleActionEvent.
private void handleActionEvent(ActionEvent e) {
Timestamp df = getDateFrom();
Timestamp dt = getDateTo();
MResource r = getResource(resource.getValue());
if (df != null && dt != null && r != null) {
model = CRPDatasetFactory.get(df, dt, r);
JFreeChart jfreechart = createChart(model.getDataset(), getChartTitle(), getSourceUOM(resource.getValue()));
chartPanel = new ChartPanel(jfreechart, false);
contentPanel.setLeftComponent(chartPanel);
JTree tree = model.getTree();
tree.addMouseListener(new TreeHandler());
contentPanel.setRightComponent(new JScrollPane(tree));
popup = createPopup(tree);
contentPanel.setDividerLocation(0.70);
contentPanel.setVisible(true);
contentPanel.validate();
contentPanel.repaint();
}
SwingTool.setCursorsFromParent(m_form.getWindow(), false);
}
use of org.compiere.model.MResource in project adempiere by adempiere.
the class VCRPDetail method getChartTitle.
private String getChartTitle() {
MResource r = getResource(resource.getValue());
String title = r.getName() != null ? r.getName() : "";
title = title + " " + r.getDescription() != null ? r.getDescription() : "";
return title;
}
Aggregations