1 14 package org.compiere.grid; 15 16 import java.awt.*; 17 import javax.swing.*; 18 import java.awt.event.*; 19 20 import org.compiere.util.*; 21 import org.compiere.apps.*; 22 import org.compiere.swing.*; 23 24 30 public class VOnlyCurrentDays extends JDialog implements ActionListener 31 { 32 37 public VOnlyCurrentDays(Frame parent, Point buttonLocation) 38 { 39 super (parent, Msg.getMsg(Env.getCtx(), "VOnlyCurrentDays", true), true); 41 try 42 { 43 jbInit(); 44 } 45 catch(Exception e) 46 { 47 Log.error("VOnlyCurrentDays", e); 48 } 49 this.pack(); 50 buttonLocation.x -= (int)getPreferredSize().getWidth()/2; 51 this.setLocation(buttonLocation); 52 this.setVisible(true); 53 } 55 private CPanel mainPanel = new CPanel(); 56 private CButton bShowAll = new CButton(); 57 private CButton bShowMonth = new CButton(); 58 private CButton bShowWeek = new CButton(); 59 private CButton bShowDay = new CButton(); 60 private CButton bShowYear = new CButton(); 61 62 63 private int m_days = 1; 64 65 private static Insets s_margin = new Insets (2, 2, 2, 2); 66 67 71 private void jbInit() throws Exception 72 { 73 this.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); 74 bShowAll.setText(Msg.getMsg(Env.getCtx(), "All")); 75 bShowAll.addActionListener(this); 76 bShowAll.setMargin(s_margin); 77 bShowYear.setText(Msg.getMsg(Env.getCtx(), "Year")); 78 bShowYear.addActionListener(this); 79 bShowYear.setMargin(s_margin); 80 bShowMonth.setText(Msg.getMsg(Env.getCtx(), "Month")); 81 bShowMonth.addActionListener(this); 82 bShowMonth.setMargin(s_margin); 83 bShowWeek.setText(Msg.getMsg(Env.getCtx(), "Week")); 84 bShowWeek.addActionListener(this); 85 bShowWeek.setMargin(s_margin); 86 bShowDay.setText(Msg.getMsg(Env.getCtx(), "Day")); 87 bShowDay.addActionListener(this); 88 bShowDay.setMargin(s_margin); 89 bShowDay.setDefaultCapable(true); 90 mainPanel.add(bShowDay, null); 92 mainPanel.add(bShowWeek, null); 93 mainPanel.add(bShowMonth, null); 94 mainPanel.add(bShowYear, null); 95 mainPanel.add(bShowAll, null); 96 mainPanel.setToolTipText(Msg.getMsg(Env.getCtx(), "VOnlyCurrentDays", false)); 98 this.getContentPane().add(mainPanel, BorderLayout.CENTER); 99 this.getRootPane().setDefaultButton(bShowDay); 100 } 102 106 public void actionPerformed(ActionEvent e) 107 { 108 if (e.getSource() == bShowDay) 109 m_days = 1; 110 else if (e.getSource() == bShowWeek) 111 m_days = 7; 112 else if (e.getSource() == bShowMonth) 113 m_days = 31; 114 else if (e.getSource() == bShowYear) 115 m_days = 356; 116 else 117 m_days = -1; 118 dispose(); 119 } 121 125 public int getCurrentDays() 126 { 127 return m_days; 128 } 130 } | Popular Tags |