Search in sources :

Example 1 with MResource

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();
    }
}
Also used : MResource(org.compiere.model.MResource) MUOM(org.compiere.model.MUOM) ChartPanel(org.jfree.chart.ChartPanel) DefaultCategoryDataset(org.jfree.data.category.DefaultCategoryDataset) CategoryDataset(org.jfree.data.category.CategoryDataset) Timestamp(java.sql.Timestamp) JFreeChart(org.jfree.chart.JFreeChart)

Example 2 with MResource

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;
}
Also used : MResource(org.compiere.model.MResource)

Example 3 with MResource

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;
}
Also used : MResource(org.compiere.model.MResource) Query(org.compiere.model.Query) Properties(java.util.Properties)

Example 4 with MResource

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);
}
Also used : MResource(org.compiere.model.MResource) JScrollPane(javax.swing.JScrollPane) JTree(javax.swing.JTree) ChartPanel(org.jfree.chart.ChartPanel) Timestamp(java.sql.Timestamp) JFreeChart(org.jfree.chart.JFreeChart)

Example 5 with MResource

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;
}
Also used : MResource(org.compiere.model.MResource)

Aggregations

MResource (org.compiere.model.MResource)18 Timestamp (java.sql.Timestamp)6 Query (org.compiere.model.Query)4 MPPOrder (org.eevolution.model.MPPOrder)4 JFreeChart (org.jfree.chart.JFreeChart)4 MUOM (org.compiere.model.MUOM)3 MPPOrderNode (org.eevolution.model.MPPOrderNode)3 ArrayList (java.util.ArrayList)2 Properties (java.util.Properties)2 AdempiereException (org.adempiere.exceptions.AdempiereException)2 I_AD_Workflow (org.compiere.model.I_AD_Workflow)2 MOrg (org.compiere.model.MOrg)2 MProduct (org.compiere.model.MProduct)2 MResourceType (org.compiere.model.MResourceType)2 MWarehouse (org.compiere.model.MWarehouse)2 MPPOrderWorkflow (org.eevolution.model.MPPOrderWorkflow)2 BOMWrapper (org.eevolution.model.wrapper.BOMWrapper)2 ChartPanel (org.jfree.chart.ChartPanel)2 CategoryDataset (org.jfree.data.category.CategoryDataset)2 DefaultCategoryDataset (org.jfree.data.category.DefaultCategoryDataset)2