parent
805882802e
commit
be2a7baee2
|
@ -16,22 +16,9 @@
|
|||
|
||||
package org.eevolution.form;
|
||||
|
||||
import org.jfree.chart.ChartFactory;
|
||||
import org.jfree.chart.ChartPanel;
|
||||
import org.jfree.chart.JFreeChart;
|
||||
import org.jfree.chart.axis.CategoryAxis;
|
||||
import org.jfree.chart.axis.CategoryLabelPositions;
|
||||
import org.jfree.chart.labels.ItemLabelAnchor;
|
||||
import org.jfree.chart.labels.ItemLabelPosition;
|
||||
//import org.jfree.chart.labels.StandardCategoryLabelGenerator;
|
||||
import org.jfree.chart.labels.StandardCategoryItemLabelGenerator;
|
||||
import org.jfree.chart.plot.CategoryPlot;
|
||||
import org.jfree.chart.plot.PlotOrientation;
|
||||
import org.jfree.chart.renderer.category.BarRenderer3D;
|
||||
import org.jfree.data.category.CategoryDataset;
|
||||
import org.jfree.ui.TextAnchor;
|
||||
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.Color;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.GridBagConstraints;
|
||||
import java.awt.Insets;
|
||||
import java.awt.event.ActionEvent;
|
||||
|
@ -39,8 +26,6 @@ import java.awt.event.ActionListener;
|
|||
import java.awt.event.MouseEvent;
|
||||
import java.awt.event.WindowAdapter;
|
||||
import java.awt.event.WindowEvent;
|
||||
import java.awt.Color;
|
||||
import java.awt.Dimension;
|
||||
import java.sql.Timestamp;
|
||||
import java.util.Date;
|
||||
import java.util.Properties;
|
||||
|
@ -54,23 +39,40 @@ import javax.swing.event.TreeSelectionEvent;
|
|||
import javax.swing.event.TreeSelectionListener;
|
||||
import javax.swing.tree.DefaultMutableTreeNode;
|
||||
|
||||
import org.compiere.apps.*;
|
||||
import org.compiere.util.*;
|
||||
import org.compiere.apps.ConfirmPanel;
|
||||
import org.compiere.apps.form.FormFrame;
|
||||
import org.compiere.grid.ed.VDate;
|
||||
import org.compiere.grid.ed.VLookup;
|
||||
import org.compiere.model.MColumn;
|
||||
import org.compiere.model.MLookup;
|
||||
import org.compiere.model.MLookupFactory;
|
||||
import org.compiere.model.MResource;
|
||||
import org.compiere.model.MUOM;
|
||||
import org.compiere.swing.CLabel;
|
||||
import org.compiere.swing.CPanel;
|
||||
import org.compiere.util.DisplayType;
|
||||
import org.compiere.util.Env;
|
||||
import org.compiere.util.Msg;
|
||||
import org.eevolution.form.action.PopupAction;
|
||||
import org.eevolution.form.action.ZoomMenuAction;
|
||||
import org.eevolution.form.crp.CRPDatasetFactory;
|
||||
import org.eevolution.form.crp.CRPModel;
|
||||
import org.compiere.model.*;
|
||||
|
||||
import org.compiere.apps.form.FormFrame;
|
||||
import org.compiere.grid.ed.VDate;
|
||||
import org.compiere.grid.ed.VLookup;
|
||||
import org.compiere.swing.CLabel;
|
||||
import org.compiere.swing.CPanel;
|
||||
|
||||
import org.eevolution.tools.worker.SingleWorker;
|
||||
import org.eevolution.tools.swing.SwingTool;
|
||||
import org.eevolution.model.MPPOrderNode;
|
||||
import org.eevolution.tools.swing.SwingTool;
|
||||
import org.eevolution.tools.worker.SingleWorker;
|
||||
import org.jfree.chart.ChartFactory;
|
||||
import org.jfree.chart.ChartPanel;
|
||||
import org.jfree.chart.JFreeChart;
|
||||
import org.jfree.chart.axis.CategoryAxis;
|
||||
import org.jfree.chart.axis.CategoryLabelPositions;
|
||||
import org.jfree.chart.labels.ItemLabelAnchor;
|
||||
import org.jfree.chart.labels.ItemLabelPosition;
|
||||
import org.jfree.chart.labels.StandardCategoryItemLabelGenerator;
|
||||
import org.jfree.chart.plot.CategoryPlot;
|
||||
import org.jfree.chart.plot.PlotOrientation;
|
||||
import org.jfree.chart.renderer.category.BarRenderer3D;
|
||||
import org.jfree.data.category.CategoryDataset;
|
||||
import org.jfree.ui.TextAnchor;
|
||||
|
||||
/**
|
||||
* Capacity Requirement Planning Form
|
||||
|
@ -89,23 +91,23 @@ public class CCRP extends CAbstractForm {
|
|||
|
||||
if (e.getActionCommand().equals(ConfirmPanel.A_OK)) {
|
||||
|
||||
SwingTool.setCursorsFromParent(getWindow(), true);
|
||||
SwingTool.setCursorsFromParent(getWindow(), true);
|
||||
|
||||
final ActionEvent evt = e;
|
||||
worker = new SingleWorker() {
|
||||
final ActionEvent evt = e;
|
||||
worker = new SingleWorker() {
|
||||
|
||||
protected Object doIt() {
|
||||
protected Object doIt() {
|
||||
|
||||
handleActionEvent(evt);
|
||||
return null;
|
||||
}
|
||||
};
|
||||
worker.start();
|
||||
handleActionEvent(evt);
|
||||
return null;
|
||||
}
|
||||
};
|
||||
worker.start();
|
||||
}
|
||||
if (e.getActionCommand().equals(ConfirmPanel.A_CANCEL)) {
|
||||
if (e.getActionCommand().equals(ConfirmPanel.A_CANCEL)) {
|
||||
|
||||
dispose();
|
||||
}
|
||||
dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -138,8 +140,8 @@ public class CCRP extends CAbstractForm {
|
|||
//m_tree.setToolTipText(msg.getToolTipText(e));
|
||||
}
|
||||
|
||||
public void valueChanged(TreeSelectionEvent event) {
|
||||
}
|
||||
public void valueChanged(TreeSelectionEvent event) {
|
||||
}
|
||||
}
|
||||
|
||||
class FrameHandler extends WindowAdapter {
|
||||
|
@ -153,17 +155,17 @@ public class CCRP extends CAbstractForm {
|
|||
class LabelGenerator extends StandardCategoryItemLabelGenerator
|
||||
{
|
||||
|
||||
public String generateItemLabel(CategoryDataset categorydataset, int i, int j) {
|
||||
public String generateItemLabel(CategoryDataset categorydataset, int i, int j) {
|
||||
|
||||
return categorydataset.getRowKey(i).toString();
|
||||
}
|
||||
return categorydataset.getRowKey(i).toString();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private VLookup resource;
|
||||
private VDate dateFrom;
|
||||
private VDate dateTo;
|
||||
private ChartPanel chartPanel;
|
||||
private VDate dateFrom;
|
||||
private VDate dateTo;
|
||||
private ChartPanel chartPanel;
|
||||
private JSplitPane contentPanel;
|
||||
|
||||
private SingleWorker worker;
|
||||
|
@ -188,47 +190,47 @@ public class CCRP extends CAbstractForm {
|
|||
private void jbInit() {
|
||||
|
||||
dateFrom = new VDate("DateFrom", true, false, true, DisplayType.Date, "DateFrom");
|
||||
dateTo = new VDate("DateTo", true, false, true, DisplayType.Date, "DateTo");
|
||||
dateTo = new VDate("DateTo", true, false, true, DisplayType.Date, "DateTo");
|
||||
|
||||
CPanel northPanel = new CPanel();
|
||||
northPanel.setLayout(new java.awt.GridBagLayout());
|
||||
|
||||
northPanel.add(
|
||||
new CLabel(Msg.translate(Env.getCtx(), "S_Resource_ID")),
|
||||
new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)
|
||||
);
|
||||
northPanel.add(
|
||||
resource,
|
||||
new GridBagConstraints(1, 1, 1, 1, 0.0, 0.0,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5), 0, 0)
|
||||
);
|
||||
new CLabel(Msg.translate(Env.getCtx(), "S_Resource_ID")),
|
||||
new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)
|
||||
);
|
||||
northPanel.add(
|
||||
resource,
|
||||
new GridBagConstraints(1, 1, 1, 1, 0.0, 0.0,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5), 0, 0)
|
||||
);
|
||||
|
||||
northPanel.add(
|
||||
new CLabel(Msg.translate(Env.getCtx(), "DateFrom")),
|
||||
new GridBagConstraints(2, 1, 1, 1, 0.0, 0.0,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)
|
||||
);
|
||||
northPanel.add(
|
||||
dateFrom,
|
||||
new GridBagConstraints(3, 1, 1, 1, 0.0, 0.0,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5), 0, 0)
|
||||
);
|
||||
northPanel.add(
|
||||
new CLabel(Msg.translate(Env.getCtx(), "DateFrom")),
|
||||
new GridBagConstraints(2, 1, 1, 1, 0.0, 0.0,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)
|
||||
);
|
||||
northPanel.add(
|
||||
dateFrom,
|
||||
new GridBagConstraints(3, 1, 1, 1, 0.0, 0.0,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5), 0, 0)
|
||||
);
|
||||
|
||||
northPanel.add(
|
||||
new CLabel(Msg.translate(Env.getCtx(), "DateTo")),
|
||||
new GridBagConstraints(4, 1, 1, 1, 0.0, 0.0,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)
|
||||
);
|
||||
northPanel.add(
|
||||
dateTo,
|
||||
new GridBagConstraints(5, 1, 1, 1, 0.0, 0.0,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5), 0, 0)
|
||||
);
|
||||
northPanel.add(
|
||||
new CLabel(Msg.translate(Env.getCtx(), "DateTo")),
|
||||
new GridBagConstraints(4, 1, 1, 1, 0.0, 0.0,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)
|
||||
);
|
||||
northPanel.add(
|
||||
dateTo,
|
||||
new GridBagConstraints(5, 1, 1, 1, 0.0, 0.0,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5), 0, 0)
|
||||
);
|
||||
|
||||
ConfirmPanel confirmPanel = new ConfirmPanel(true);
|
||||
confirmPanel.addActionListener(new ActionHandler());
|
||||
ConfirmPanel confirmPanel = new ConfirmPanel(true);
|
||||
confirmPanel.addActionListener(new ActionHandler());
|
||||
|
||||
contentPanel = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT);
|
||||
contentPanel.setPreferredSize(new Dimension(800, 600));
|
||||
contentPanel.setPreferredSize(new Dimension(800, 600));
|
||||
|
||||
getWindow().getContentPane().add(northPanel, BorderLayout.NORTH);
|
||||
getWindow().getContentPane().add(contentPanel, BorderLayout.CENTER);
|
||||
getWindow().getContentPane().add(confirmPanel, BorderLayout.SOUTH);
|
||||
getWindow().getContentPane().add(northPanel, BorderLayout.NORTH);
|
||||
getWindow().getContentPane().add(contentPanel, BorderLayout.CENTER);
|
||||
getWindow().getContentPane().add(confirmPanel, BorderLayout.SOUTH);
|
||||
}
|
||||
|
||||
private void fillPicks() {
|
||||
|
@ -237,7 +239,7 @@ public class CCRP extends CAbstractForm {
|
|||
|
||||
// Hardcoded Column ID - Manufacturing Resource ID
|
||||
MLookup resourceL = MLookupFactory.get (ctx, getWindowNo(), 0, MColumn.getColumn_ID(MResource.Table_Name,"S_Resource_ID"), DisplayType.TableDir);
|
||||
resource = new VLookup ("S_Resource_ID", false, false, true, resourceL);
|
||||
resource = new VLookup ("S_Resource_ID", false, false, true, resourceL);
|
||||
}
|
||||
|
||||
protected JPopupMenu createPopup(JTree tree) {
|
||||
|
@ -277,40 +279,40 @@ public class CCRP extends CAbstractForm {
|
|||
|
||||
private void handleActionEvent(ActionEvent e) {
|
||||
|
||||
Timestamp df = getDateFrom();
|
||||
Timestamp dt = getDateTo();
|
||||
MResource r = getResource();
|
||||
Timestamp df = getDateFrom();
|
||||
Timestamp dt = getDateTo();
|
||||
MResource r = getResource();
|
||||
|
||||
if (df != null && dt != null && r != null) {
|
||||
if (df != null && dt != null && r != null) {
|
||||
|
||||
model = CRPDatasetFactory.get(df, dt, r);
|
||||
|
||||
JFreeChart jfreechart = createChart(model.getDataset(), getChartTitle(), getSourceUOM());
|
||||
JFreeChart jfreechart = createChart(model.getDataset(), getChartTitle(), getSourceUOM());
|
||||
|
||||
chartPanel = new ChartPanel(jfreechart, false);
|
||||
contentPanel.setLeftComponent(chartPanel);
|
||||
chartPanel = new ChartPanel(jfreechart, false);
|
||||
contentPanel.setLeftComponent(chartPanel);
|
||||
|
||||
JTree tree = model.getTree();
|
||||
tree.addMouseListener(new TreeHandler());
|
||||
contentPanel.setRightComponent(new JScrollPane(tree));
|
||||
popup = createPopup(tree);
|
||||
JTree tree = model.getTree();
|
||||
tree.addMouseListener(new TreeHandler());
|
||||
contentPanel.setRightComponent(new JScrollPane(tree));
|
||||
popup = createPopup(tree);
|
||||
|
||||
contentPanel.setVisible(true);
|
||||
contentPanel.setVisible(true);
|
||||
|
||||
contentPanel.validate();
|
||||
contentPanel.repaint();
|
||||
}
|
||||
contentPanel.validate();
|
||||
contentPanel.repaint();
|
||||
}
|
||||
|
||||
SwingTool.setCursorsFromParent(getWindow(), false);
|
||||
SwingTool.setCursorsFromParent(getWindow(), false);
|
||||
}
|
||||
|
||||
private String getChartTitle() {
|
||||
|
||||
MResource r = getResource();
|
||||
String title = r.getName() != null ? r.getName() : "";
|
||||
title = title + " " + r.getDescription() != null ? r.getDescription() : "";
|
||||
MResource r = getResource();
|
||||
String title = r.getName() != null ? r.getName() : "";
|
||||
title = title + " " + r.getDescription() != null ? r.getDescription() : "";
|
||||
|
||||
return title;
|
||||
return title;
|
||||
}
|
||||
|
||||
public Timestamp getDateFrom() {
|
||||
|
@ -338,9 +340,9 @@ public class CCRP extends CAbstractForm {
|
|||
}
|
||||
|
||||
public MUOM getSourceUOM() {
|
||||
MResource r = getResource();
|
||||
MResource r = getResource();
|
||||
int uom_id = r.getResourceType().getC_UOM_ID();
|
||||
return (uom_id > 0) ? MUOM.get(Env.getCtx(),uom_id) : null;
|
||||
return (uom_id > 0) ? MUOM.get(Env.getCtx(),uom_id) : null;
|
||||
}
|
||||
|
||||
public MResource getResource() {
|
||||
|
@ -386,21 +388,21 @@ public class CCRP extends CAbstractForm {
|
|||
|
||||
BarRenderer3D barrenderer = (BarRenderer3D)plot.getRenderer();
|
||||
barrenderer.setDrawBarOutline(false);
|
||||
barrenderer.setBaseItemLabelGenerator(new LabelGenerator());
|
||||
barrenderer.setBaseItemLabelGenerator(new LabelGenerator());
|
||||
//barrenderer.setBaseLabelGenerator(new LabelGenerator());
|
||||
barrenderer.setBaseItemLabelsVisible(true);
|
||||
barrenderer.setSeriesPaint(0, new Color(200, 200, 200, 128));
|
||||
barrenderer.setSeriesPaint(1, new Color(60, 60, 100, 128));
|
||||
barrenderer.setSeriesPaint(0, new Color(200, 200, 200, 128));
|
||||
barrenderer.setSeriesPaint(1, new Color(60, 60, 100, 128));
|
||||
|
||||
ItemLabelPosition itemlabelposition = new ItemLabelPosition(ItemLabelAnchor.OUTSIDE12, TextAnchor.TOP_CENTER);
|
||||
barrenderer.setPositiveItemLabelPosition(itemlabelposition);
|
||||
ItemLabelPosition itemlabelposition = new ItemLabelPosition(ItemLabelAnchor.OUTSIDE12, TextAnchor.TOP_CENTER);
|
||||
barrenderer.setPositiveItemLabelPosition(itemlabelposition);
|
||||
|
||||
CategoryAxis domainAxis = plot.getDomainAxis();
|
||||
domainAxis.setCategoryLabelPositions(
|
||||
CategoryLabelPositions.createUpRotationLabelPositions(Math.PI / 6.0)
|
||||
);
|
||||
domainAxis.setCategoryLabelPositions(
|
||||
CategoryLabelPositions.createUpRotationLabelPositions(Math.PI / 6.0)
|
||||
);
|
||||
|
||||
return chart;
|
||||
return chart;
|
||||
}
|
||||
|
||||
public void dispose() {
|
||||
|
@ -431,7 +433,7 @@ public class CCRP extends CAbstractForm {
|
|||
}
|
||||
worker = null;
|
||||
|
||||
chartPanel = null;
|
||||
chartPanel = null;
|
||||
contentPanel = null;
|
||||
popup = null;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue