diff --git a/client/src/org/compiere/apps/StatusBar.java b/client/src/org/compiere/apps/StatusBar.java index ef190033e2..d2e98729de 100644 --- a/client/src/org/compiere/apps/StatusBar.java +++ b/client/src/org/compiere/apps/StatusBar.java @@ -40,6 +40,33 @@ import org.compiere.util.Msg; */ public class StatusBar extends CPanel implements IStatusBar { + + /****************************************************************************** + * Mouse Adapter for Status Bar (statusDB) + */ + class StatusBar_mouseAdapter extends java.awt.event.MouseAdapter + { + private StatusBar adaptee; + + /** + * Constructor + * @param adaptee adaptee + */ + StatusBar_mouseAdapter(StatusBar adaptee) + { + this.adaptee = adaptee; + } + + /** + * Click + * @param e event + */ + public void mouseClicked(MouseEvent e) + { + adaptee.mouseClicked(e); + } + } // StatusBar_mouseAdapter + /** * */ @@ -240,30 +267,3 @@ public class StatusBar extends CPanel implements IStatusBar } // addStatusComponent } // StatusBar - - -/****************************************************************************** - * Mouse Adapter for Status Bar (statusDB) - */ -class StatusBar_mouseAdapter extends java.awt.event.MouseAdapter -{ - private StatusBar adaptee; - - /** - * Constructor - * @param adaptee adaptee - */ - StatusBar_mouseAdapter(StatusBar adaptee) - { - this.adaptee = adaptee; - } - - /** - * Click - * @param e event - */ - public void mouseClicked(MouseEvent e) - { - adaptee.mouseClicked(e); - } -} // StatusBar_mouseAdapter diff --git a/client/src/org/compiere/grid/ed/VAccountDialog.java b/client/src/org/compiere/grid/ed/VAccountDialog.java index 9e6cc385a6..5ddea41c66 100644 --- a/client/src/org/compiere/grid/ed/VAccountDialog.java +++ b/client/src/org/compiere/grid/ed/VAccountDialog.java @@ -83,6 +83,29 @@ public final class VAccountDialog extends CDialog */ private static final long serialVersionUID = -1980622319541357651L; + /** + * Mouse Listener + */ + class VAccountDialog_mouseAdapter extends java.awt.event.MouseAdapter + { + VAccountDialog_mouseAdapter(VAccountDialog adaptee) + { + this.adaptee = adaptee; + } + + VAccountDialog adaptee; + + public void mouseClicked(MouseEvent e) + { + // Table => select + if (e.getSource() instanceof JTable && e.getClickCount() > 1) + { + adaptee.m_changed = true; + adaptee.dispose(); + } + } + } // VAccountDialog_mouseListener + /** * Constructor * @param frame frame @@ -1103,26 +1126,3 @@ public final class VAccountDialog extends CDialog } // vetoableChange } // VAccountDialog - -/** - * Mouse Listener - */ -class VAccountDialog_mouseAdapter extends java.awt.event.MouseAdapter -{ - VAccountDialog_mouseAdapter(VAccountDialog adaptee) - { - this.adaptee = adaptee; - } - - VAccountDialog adaptee; - - public void mouseClicked(MouseEvent e) - { - // Table => select - if (e.getSource() instanceof JTable && e.getClickCount() > 1) - { - adaptee.m_changed = true; - adaptee.dispose(); - } - } -} // VAccountDialog_mouseListener diff --git a/client/src/org/compiere/grid/ed/VAssignment.java b/client/src/org/compiere/grid/ed/VAssignment.java index 9b15ba0bb0..27f024a3cb 100644 --- a/client/src/org/compiere/grid/ed/VAssignment.java +++ b/client/src/org/compiere/grid/ed/VAssignment.java @@ -65,6 +65,38 @@ public class VAssignment extends JComponent */ private static final long serialVersionUID = 796127013756416974L; + /** + * Mouse Listener + */ + final class VAssignment_mouseAdapter extends MouseAdapter + { + /** + * Constructor + * @param adaptee adaptee + */ + VAssignment_mouseAdapter(VAssignment adaptee) + { + this.adaptee = adaptee; + } // VAssignment_mouseAdapter + + private VAssignment adaptee; + + /** + * Mouse Listener + * @param e event + */ + public void mouseClicked(MouseEvent e) + { + // Double Click + if (e.getClickCount() > 1) + adaptee.actionPerformed(new ActionEvent(e.getSource(), e.getID(), "Mouse")); + // popup menu + if (SwingUtilities.isRightMouseButton(e)) + adaptee.popupMenu.show((Component)e.getSource(), e.getX(), e.getY()); + } // mouse Clicked + + } // VAssignment_mouseAdapter + /** * IDE Constructor */ @@ -388,36 +420,3 @@ public class VAssignment extends JComponent } // propertyChange } // VAssignment - -/** - * Mouse Listener - */ -final class VAssignment_mouseAdapter extends MouseAdapter -{ - /** - * Constructor - * @param adaptee adaptee - */ - VAssignment_mouseAdapter(VAssignment adaptee) - { - this.adaptee = adaptee; - } // VAssignment_mouseAdapter - - private VAssignment adaptee; - - /** - * Mouse Listener - * @param e event - */ - public void mouseClicked(MouseEvent e) - { - // Double Click - if (e.getClickCount() > 1) - adaptee.actionPerformed(new ActionEvent(e.getSource(), e.getID(), "Mouse")); - // popup menu - if (SwingUtilities.isRightMouseButton(e)) - adaptee.popupMenu.show((Component)e.getSource(), e.getX(), e.getY()); - } // mouse Clicked - -} // VAssignment_mouseAdapter - diff --git a/client/src/org/compiere/grid/ed/VDate.java b/client/src/org/compiere/grid/ed/VDate.java index b5e099d04d..d21f159397 100644 --- a/client/src/org/compiere/grid/ed/VDate.java +++ b/client/src/org/compiere/grid/ed/VDate.java @@ -69,6 +69,36 @@ public class VDate extends JComponent */ private static final long serialVersionUID = -9090302458969544529L; + /***************************************************************************** + * Mouse Listener for Popup Menu + */ + class VDate_mouseAdapter extends java.awt.event.MouseAdapter + { + /** + * Constructor + * @param adaptee adaptee + */ + VDate_mouseAdapter(VDate adaptee) + { + this.adaptee = adaptee; + } // VLookup_mouseAdapter + + private VDate adaptee; + + /** + * Mouse Listener + * @param e MouseEvent + */ + public void mouseClicked(MouseEvent e) + { + // System.out.println("mouseClicked " + e.getID() + " " + e.getSource().getClass().toString()); + // popup menu + if (SwingUtilities.isRightMouseButton(e)) + adaptee.popupMenu.show((Component)e.getSource(), e.getX(), e.getY()); + } // mouse Clicked + + } // VLookup_mouseAdapter + /** * IDE Bean Constructor */ @@ -585,34 +615,4 @@ public class VDate extends JComponent } } // fireActionPerformed /**/ -} // VDate - -/***************************************************************************** - * Mouse Listener for Popup Menu - */ -final class VDate_mouseAdapter extends java.awt.event.MouseAdapter -{ - /** - * Constructor - * @param adaptee adaptee - */ - VDate_mouseAdapter(VDate adaptee) - { - this.adaptee = adaptee; - } // VLookup_mouseAdapter - - private VDate adaptee; - - /** - * Mouse Listener - * @param e MouseEvent - */ - public void mouseClicked(MouseEvent e) - { - // System.out.println("mouseClicked " + e.getID() + " " + e.getSource().getClass().toString()); - // popup menu - if (SwingUtilities.isRightMouseButton(e)) - adaptee.popupMenu.show((Component)e.getSource(), e.getX(), e.getY()); - } // mouse Clicked - -} // VLookup_mouseAdapter +} // VDate \ No newline at end of file diff --git a/client/src/org/compiere/grid/ed/VFile.java b/client/src/org/compiere/grid/ed/VFile.java index 378c6ab27f..b865f76483 100644 --- a/client/src/org/compiere/grid/ed/VFile.java +++ b/client/src/org/compiere/grid/ed/VFile.java @@ -58,6 +58,33 @@ public class VFile extends JComponent */ private static final long serialVersionUID = 7246339063197204992L; + /****************************************************************************** + * Mouse Listener for Popup Menu + */ + final class VFile_mouseAdapter extends java.awt.event.MouseAdapter + { + /** + * Constructor + * @param adaptee adaptee + */ + VFile_mouseAdapter(VFile adaptee) + { + m_adaptee = adaptee; + } // VLookup_mouseAdapter + + private VFile m_adaptee; + + /** + * Mouse Listener + * @param e MouseEvent + */ + public void mouseClicked(MouseEvent e) + { + + } // mouse Clicked + + } // VFile_mouseAdapter + /** * Constructor * @@ -382,30 +409,3 @@ public class VFile extends JComponent } } // VFile - -/****************************************************************************** - * Mouse Listener for Popup Menu - */ -final class VFile_mouseAdapter extends java.awt.event.MouseAdapter -{ - /** - * Constructor - * @param adaptee adaptee - */ - VFile_mouseAdapter(VFile adaptee) - { - m_adaptee = adaptee; - } // VLookup_mouseAdapter - - private VFile m_adaptee; - - /** - * Mouse Listener - * @param e MouseEvent - */ - public void mouseClicked(MouseEvent e) - { - - } // mouse Clicked - -} // VFile_mouseAdapter diff --git a/client/src/org/compiere/grid/ed/VLocation.java b/client/src/org/compiere/grid/ed/VLocation.java index 576872ee54..536bb486f6 100644 --- a/client/src/org/compiere/grid/ed/VLocation.java +++ b/client/src/org/compiere/grid/ed/VLocation.java @@ -59,6 +59,35 @@ public class VLocation extends JComponent */ private static final long serialVersionUID = -3155246553879767899L; + /** + * Mouse Listener for Popup Menu + */ + final class VLocation_mouseAdapter extends java.awt.event.MouseAdapter + { + /** + * Constructor + * @param adaptee adaptee + */ + VLocation_mouseAdapter(VLocation adaptee) + { + this.adaptee = adaptee; + } // VLookup_mouseAdapter + + private VLocation adaptee; + + /** + * Mouse Listener + * @param e MouseEvent + */ + public void mouseClicked(MouseEvent e) + { + // popup menu + if (SwingUtilities.isRightMouseButton(e)) + adaptee.popupMenu.show((Component)e.getSource(), e.getX(), e.getY()); + } // mouse Clicked + + } // VLocation_mouseAdapter + /** * Constructor * @@ -370,33 +399,4 @@ public class VLocation extends JComponent } // VLocation -/*****************************************************************************/ - -/** - * Mouse Listener for Popup Menu - */ -final class VLocation_mouseAdapter extends java.awt.event.MouseAdapter -{ - /** - * Constructor - * @param adaptee adaptee - */ - VLocation_mouseAdapter(VLocation adaptee) - { - this.adaptee = adaptee; - } // VLookup_mouseAdapter - - private VLocation adaptee; - - /** - * Mouse Listener - * @param e MouseEvent - */ - public void mouseClicked(MouseEvent e) - { - // popup menu - if (SwingUtilities.isRightMouseButton(e)) - adaptee.popupMenu.show((Component)e.getSource(), e.getX(), e.getY()); - } // mouse Clicked - -} // VLocation_mouseAdapter +/*****************************************************************************/ \ No newline at end of file diff --git a/client/src/org/compiere/grid/ed/VLocator.java b/client/src/org/compiere/grid/ed/VLocator.java index 8142658171..955c566db5 100644 --- a/client/src/org/compiere/grid/ed/VLocator.java +++ b/client/src/org/compiere/grid/ed/VLocator.java @@ -1,612 +1,612 @@ -/****************************************************************************** - * 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.compiere.grid.ed; - -import java.awt.BorderLayout; -import java.awt.Color; -import java.awt.Component; -import java.awt.Cursor; -import java.awt.Dimension; -import java.awt.Insets; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.awt.event.MouseEvent; -import java.beans.PropertyChangeEvent; -import java.beans.PropertyVetoException; -import java.sql.PreparedStatement; -import java.sql.ResultSet; -import java.sql.SQLException; -import java.util.logging.Level; - -import javax.swing.ImageIcon; -import javax.swing.JComponent; -import javax.swing.JPopupMenu; -import javax.swing.JTextField; -import javax.swing.LookAndFeel; -import javax.swing.SwingUtilities; - -import org.adempiere.plaf.AdempierePLAF; -import org.compiere.apps.AEnv; -import org.compiere.apps.AWindow; -import org.compiere.model.MLocator; -import org.compiere.model.MLocatorLookup; -import org.compiere.model.MQuery; -import org.compiere.model.MRole; -import org.compiere.model.MTable; -import org.compiere.model.MWarehouse; -import org.compiere.swing.CButton; -import org.compiere.swing.CMenuItem; -import org.compiere.util.CLogger; -import org.compiere.util.DB; -import org.compiere.util.Env; -import org.compiere.util.Msg; - -/** - * Warehouse Locator Control - * - * @author Jorg Janke - * @version $Id: VLocator.java,v 1.5 2006/07/30 00:51:27 jjanke Exp $ - */ -public class VLocator extends JComponent - implements VEditor, ActionListener -{ - /** - * - */ - private static final long serialVersionUID = 6173109396306219205L; - - /** - * IDE Constructor - */ - public VLocator () - { - this("M_Locator_ID", false, false, true, null, 0); - } // VLocator - - /** - * Constructor - * - * @param columnName ColumnName - * @param mandatory mandatory - * @param isReadOnly read only - * @param isUpdateable updateable - * @param mLocator locator (lookup) model - * @param WindowNo window no - */ - public VLocator(String columnName, boolean mandatory, boolean isReadOnly, boolean isUpdateable, - MLocatorLookup mLocator, int WindowNo) - { - super(); - super.setName(columnName); - m_columnName = columnName; - m_mLocator = mLocator; - m_WindowNo = WindowNo; - // - LookAndFeel.installBorder(this, "TextField.border"); - this.setLayout(new BorderLayout()); - // Size - this.setPreferredSize(m_text.getPreferredSize()); // causes r/o to be the same length - int height = m_text.getPreferredSize().height; - - // *** Button & Text *** - m_text.setBorder(null); - m_text.setEditable(true); - m_text.setFocusable(true); - m_text.addMouseListener(new VLocator_mouseAdapter(this)); // popup - m_text.setFont(AdempierePLAF.getFont_Field()); - m_text.setForeground(AdempierePLAF.getTextColor_Normal()); - m_text.addActionListener(this); - this.add(m_text, BorderLayout.CENTER); - - m_button.setIcon(new ImageIcon(org.compiere.Adempiere.class.getResource("images/Locator10.gif"))); - m_button.setMargin(new Insets(0, 0, 0, 0)); - m_button.setPreferredSize(new Dimension(height, height)); - m_button.addActionListener(this); - this.add(m_button, BorderLayout.EAST); - - // Prefereed Size - this.setPreferredSize(this.getPreferredSize()); // causes r/o to be the same length - - // ReadWrite - if (isReadOnly || !isUpdateable) - setReadWrite (false); - else - setReadWrite (true); - setMandatory (mandatory); - // - mZoom = new CMenuItem(Msg.getMsg(Env.getCtx(), "Zoom"), Env.getImageIcon("Zoom16.gif")); - mZoom.addActionListener(this); - popupMenu.add(mZoom); - mRefresh = new CMenuItem(Msg.getMsg(Env.getCtx(), "Refresh"), Env.getImageIcon("Refresh16.gif")); - mRefresh.addActionListener(this); - popupMenu.add(mRefresh); - setDefault_Locator_ID(); // set default locator, teo_sarca [ 1661546 ] - } // VLocator - - /** - * Dispose - */ - public void dispose() - { - m_text = null; - m_button = null; - m_mLocator = null; - } // dispose - - private JTextField m_text = new JTextField (VLookup.DISPLAY_LENGTH); - private CButton m_button = new CButton(); - private MLocatorLookup m_mLocator; - private Object m_value; - // - private String m_columnName; - private int m_WindowNo; - /** Logger */ - private static CLogger log = CLogger.getCLogger(VLocator.class); - // Popup - JPopupMenu popupMenu = new JPopupMenu(); - private CMenuItem mZoom; - private CMenuItem mRefresh; - - /** - * Enable/disable - * @param value r/w - */ - public void setReadWrite (boolean value) - { - m_button.setReadWrite(value); - if (m_button.isVisible() != value) - m_button.setVisible(value); - setBackground(false); - } // setReadWrite - - /** - * IsReadWrite - * @return true if ReadWrite - */ - public boolean isReadWrite() - { - return m_button.isReadWrite(); - } // isReadWrite - - /** - * Set Mandatory (and back bolor) - * @param mandatory true if mandatory - */ - public void setMandatory (boolean mandatory) - { - m_button.setMandatory(mandatory); - setBackground(false); - } // setMandatory - - /** - * Is it mandatory - * @return true if mandatory - */ - public boolean isMandatory() - { - return m_button.isMandatory(); - } // isMandatory - - /** - * Set Background - * @param color color - */ - public void setBackground (Color color) - { - if (!color.equals(m_text.getBackground())) - m_text.setBackground(color); - } // setBackground - - /** - * Set Background based on editable / mandatory / error - * @param error if true, set background to error color, otherwise mandatory/editable - */ - public void setBackground (boolean error) - { - if (error) - setBackground(AdempierePLAF.getFieldBackground_Error()); - else if (!isReadWrite()) - setBackground(AdempierePLAF.getFieldBackground_Inactive()); - else if (isMandatory()) - setBackground(AdempierePLAF.getFieldBackground_Mandatory()); - else - setBackground(AdempierePLAF.getFieldBackground_Normal()); - } // setBackground - - /** - * Set Foreground - * @param fg color - */ - public void setForeground(Color fg) - { - m_text.setForeground(fg); - } // setForeground - - /** - * Request Focus - */ - public void requestFocus () - { - m_text.requestFocus (); - } // requestFocus - - /** - * Set Editor to value - * @param value Integer - */ - public void setValue(Object value) - { - setValue (value, false); - } // setValue - - /** - * Set Value - * @param value value - * @param fire data binding - */ - private void setValue (Object value, boolean fire) - { - if (m_mLocator == null) - { - return ; - } - - if (value != null) - { - m_mLocator.setOnly_Warehouse_ID (getOnly_Warehouse_ID ()); - m_mLocator.setOnly_Product_ID(getOnly_Product_ID()); - if (!m_mLocator.isValid(value)) - value = null; - } - // - m_value = value; - m_text.setText(m_mLocator.getDisplay(value)); // loads value - - // Data Binding - try - { - fireVetoableChange(m_columnName, null, value); - } - catch (PropertyVetoException pve) - { - } - } // setValue - - - /** - * Property Change Listener - * @param evt PropertyChangeEvent - */ - public void propertyChange (PropertyChangeEvent evt) - { - if (evt.getPropertyName().equals(org.compiere.model.GridField.PROPERTY)) - setValue(evt.getNewValue()); - } // propertyChange - - /** - * Return Editor value - * @return value - */ - public Object getValue() - { - if (getM_Locator_ID() == 0) - return null; - return m_value; - } // getValue - - /** - * Get M_Locator_ID - * @return id - */ - public int getM_Locator_ID() - { - if (m_value != null - && m_value instanceof Integer) - return ((Integer)m_value).intValue(); - return 0; - } // getM_Locator_ID - - /** - * Return Display Value - * @return display value - */ - public String getDisplay() - { - return m_text.getText(); - } // getDisplay - - /** - * ActionListener - * @param e ActionEvent - */ - public void actionPerformed(ActionEvent e) - { - // Refresh - if (e.getSource() == mRefresh) - { - m_mLocator.refresh(); - return; - } - - // Zoom to M_Warehouse - if (e.getSource() == mZoom) - { - actionZoom(); - return; - } - - // Warehouse/Product - int only_Warehouse_ID = getOnly_Warehouse_ID(); - int only_Product_ID = getOnly_Product_ID(); - log.config("Only Warehouse_ID=" + only_Warehouse_ID - + ", Product_ID=" + only_Product_ID); - - // Text Entry ok - if (e.getSource() == m_text - && actionText(only_Warehouse_ID, only_Product_ID)) - return; - - // Button - Start Dialog - int M_Locator_ID = 0; - if (m_value instanceof Integer) - M_Locator_ID = ((Integer)m_value).intValue(); - // - m_mLocator.setOnly_Warehouse_ID(only_Warehouse_ID); - m_mLocator.setOnly_Product_ID(getOnly_Product_ID()); - VLocatorDialog ld = new VLocatorDialog(Env.getFrame(this), - Msg.translate(Env.getCtx(), m_columnName), - m_mLocator, M_Locator_ID, isMandatory(), only_Warehouse_ID); - // display - ld.setVisible(true); - m_mLocator.setOnly_Warehouse_ID(0); - - // redisplay - if (!ld.isChanged()) - return; - setValue (ld.getValue(), true); - } // actionPerformed - - /** - * Hit Enter in Text Field - * @param only_Warehouse_ID if not 0 restrict warehouse - * @param only_Product_ID of not 0 restricted product - * @return true if found - */ - private boolean actionText (int only_Warehouse_ID, int only_Product_ID) - { - String text = m_text.getText(); - log.fine(text); - // Null - if (text == null || text.length() == 0) - { - if (isMandatory()) - return false; - else - { - setValue (null, true); - return true; - } - } - if (text.endsWith("%")) - text = text.toUpperCase(); - else - text = text.toUpperCase() + "%"; - - // Look up - see MLocatorLookup.run - StringBuffer sql = new StringBuffer("SELECT M_Locator_ID FROM M_Locator ") - .append(" WHERE IsActive='Y' AND UPPER(Value) LIKE ") - .append(DB.TO_STRING(text)); - if (getOnly_Warehouse_ID() != 0) - sql.append(" AND M_Warehouse_ID=?"); - if (getOnly_Product_ID() != 0) - sql.append(" AND (IsDefault='Y' ") // Default Locator - .append("OR EXISTS (SELECT * FROM M_Product p ") // Product Locator - .append("WHERE p.M_Locator_ID=M_Locator.M_Locator_ID AND p.M_Product_ID=?)") - .append("OR EXISTS (SELECT * FROM M_Storage s ") // Storage Locator - .append("WHERE s.M_Locator_ID=M_Locator.M_Locator_ID AND s.M_Product_ID=?))"); - String finalSql = MRole.getDefault(Env.getCtx(), false).addAccessSQL( - sql.toString(), "M_Locator", MRole.SQL_NOTQUALIFIED, MRole.SQL_RO); - // - int M_Locator_ID = 0; - PreparedStatement pstmt = null; - try - { - pstmt = DB.prepareStatement(finalSql, null); - int index = 1; - if (only_Warehouse_ID != 0) - pstmt.setInt(index++, only_Warehouse_ID); - if (only_Product_ID != 0) - { - pstmt.setInt(index++, only_Product_ID); - pstmt.setInt(index++, only_Product_ID); - } - ResultSet rs = pstmt.executeQuery(); - if (rs.next()) - { - M_Locator_ID = rs.getInt(1); - if (rs.next()) - M_Locator_ID = 0; // more than one - } - rs.close(); - pstmt.close(); - pstmt = null; - } - catch (SQLException ex) - { - log.log(Level.SEVERE, finalSql, ex); - } - try - { - if (pstmt != null) - pstmt.close(); - } - catch (SQLException ex1) - { - } - pstmt = null; - if (M_Locator_ID == 0) - return false; - - setValue (new Integer(M_Locator_ID), true); - return true; - } // actionText - - /** - * Action Listener Interface - * @param listener listener - */ - public void addActionListener(ActionListener listener) - { - m_text.addActionListener(listener); - } // addActionListener - - - /** - * Action - Zoom - */ - private void actionZoom() - { - int AD_Window_ID = MTable.get(Env.getCtx(), MLocator.Table_ID).getAD_Window_ID(); - if (AD_Window_ID <= 0) - AD_Window_ID = 139; // hardcoded window Warehouse & Locators - log.info(""); - // - setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); - AWindow frame = new AWindow(); - - MQuery zoomQuery = new MQuery(); - zoomQuery.addRestriction(MLocator.COLUMNNAME_M_Locator_ID, MQuery.EQUAL, getValue()); - zoomQuery.setRecordCount(1); // guess - - if (!frame.initWindow(AD_Window_ID, zoomQuery)) - return; - AEnv.addToWindowManager(frame); - AEnv.showCenterScreen(frame); - frame = null; - setCursor(Cursor.getDefaultCursor()); - } // actionZoom - - /** - * Set Field/WindowNo for ValuePreference (NOP) - * @param mField Model Field - */ - public void setField (org.compiere.model.GridField mField) - { - } // setField - - - /** - * Get Warehouse restriction if any. - * @return M_Warehouse_ID or 0 - */ - private int getOnly_Warehouse_ID() - { - String only_Warehouse = Env.getContext(Env.getCtx(), m_WindowNo, "M_Warehouse_ID", true); - int only_Warehouse_ID = 0; - try - { - if (only_Warehouse != null && only_Warehouse.length () > 0) - only_Warehouse_ID = Integer.parseInt (only_Warehouse); - } - catch (Exception ex) - { - } - return only_Warehouse_ID; - } // getOnly_Warehouse_ID - - /** - * Get Product restriction if any. - * @return M_Product_ID or 0 - */ - private int getOnly_Product_ID() - { - if (!Env.isSOTrx(Env.getCtx(), m_WindowNo)) - return 0; // No product restrictions for PO - // - String only_Product = Env.getContext(Env.getCtx(), m_WindowNo, "M_Product_ID", true); - int only_Product_ID = 0; - try - { - if (only_Product != null && only_Product.length () > 0) - only_Product_ID = Integer.parseInt (only_Product); - } - catch (Exception ex) - { - } - return only_Product_ID; - } // getOnly_Product_ID - - /** - * Set the default locator if this field is mandatory - * and we have a warehouse restriction. - * - * @since 3.1.4 - */ - private void setDefault_Locator_ID() - { - // teo_sarca, FR [ 1661546 ] Mandatory locator fields should use defaults - if (!isMandatory() || m_mLocator == null) { - return; - } - int M_Warehouse_ID = getOnly_Warehouse_ID(); - if (M_Warehouse_ID <= 0) { - return; - } - MWarehouse wh = MWarehouse.get(Env.getCtx(), M_Warehouse_ID); - if (wh == null || wh.get_ID() <= 0) { - return; - } - MLocator loc = wh.getDefaultLocator(); - if (loc == null || loc.get_ID() <= 0) { - return; - } - setValue(Integer.valueOf(loc.get_ID())); - } - -} // VLocator - -/*****************************************************************************/ - -/** - * Mouse Listener for Popup Menu - */ -final class VLocator_mouseAdapter extends java.awt.event.MouseAdapter -{ - /** - * Constructor - * @param adaptee VLocator - */ - VLocator_mouseAdapter(VLocator adaptee) - { - m_adaptee = adaptee; - } // VLookup_mouseAdapter - - /** Adaptee */ - private VLocator m_adaptee; - - /** - * Mouse Listener - * @param e MouseEvent - */ - public void mouseClicked(MouseEvent e) - { - // popup menu - if (SwingUtilities.isRightMouseButton(e)) - m_adaptee.popupMenu.show((Component)e.getSource(), e.getX(), e.getY()); - } // mouse Clicked - -} // VLocator_mouseAdapter +/****************************************************************************** + * 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.compiere.grid.ed; + +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Component; +import java.awt.Cursor; +import java.awt.Dimension; +import java.awt.Insets; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.MouseEvent; +import java.beans.PropertyChangeEvent; +import java.beans.PropertyVetoException; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.logging.Level; + +import javax.swing.ImageIcon; +import javax.swing.JComponent; +import javax.swing.JPopupMenu; +import javax.swing.JTextField; +import javax.swing.LookAndFeel; +import javax.swing.SwingUtilities; + +import org.adempiere.plaf.AdempierePLAF; +import org.compiere.apps.AEnv; +import org.compiere.apps.AWindow; +import org.compiere.model.MLocator; +import org.compiere.model.MLocatorLookup; +import org.compiere.model.MQuery; +import org.compiere.model.MRole; +import org.compiere.model.MTable; +import org.compiere.model.MWarehouse; +import org.compiere.swing.CButton; +import org.compiere.swing.CMenuItem; +import org.compiere.util.CLogger; +import org.compiere.util.DB; +import org.compiere.util.Env; +import org.compiere.util.Msg; + +/** + * Warehouse Locator Control + * + * @author Jorg Janke + * @version $Id: VLocator.java,v 1.5 2006/07/30 00:51:27 jjanke Exp $ + */ +public class VLocator extends JComponent + implements VEditor, ActionListener +{ + /** + * + */ + private static final long serialVersionUID = 6173109396306219205L; + + /** + * Mouse Listener for Popup Menu + */ + final class VLocator_mouseAdapter extends java.awt.event.MouseAdapter + { + /** + * Constructor + * @param adaptee VLocator + */ + VLocator_mouseAdapter(VLocator adaptee) + { + m_adaptee = adaptee; + } // VLookup_mouseAdapter + + /** Adaptee */ + private VLocator m_adaptee; + + /** + * Mouse Listener + * @param e MouseEvent + */ + public void mouseClicked(MouseEvent e) + { + // popup menu + if (SwingUtilities.isRightMouseButton(e)) + m_adaptee.popupMenu.show((Component)e.getSource(), e.getX(), e.getY()); + } // mouse Clicked + + } // VLocator_mouseAdapter + + /** + * IDE Constructor + */ + public VLocator () + { + this("M_Locator_ID", false, false, true, null, 0); + } // VLocator + + /** + * Constructor + * + * @param columnName ColumnName + * @param mandatory mandatory + * @param isReadOnly read only + * @param isUpdateable updateable + * @param mLocator locator (lookup) model + * @param WindowNo window no + */ + public VLocator(String columnName, boolean mandatory, boolean isReadOnly, boolean isUpdateable, + MLocatorLookup mLocator, int WindowNo) + { + super(); + super.setName(columnName); + m_columnName = columnName; + m_mLocator = mLocator; + m_WindowNo = WindowNo; + // + LookAndFeel.installBorder(this, "TextField.border"); + this.setLayout(new BorderLayout()); + // Size + this.setPreferredSize(m_text.getPreferredSize()); // causes r/o to be the same length + int height = m_text.getPreferredSize().height; + + // *** Button & Text *** + m_text.setBorder(null); + m_text.setEditable(true); + m_text.setFocusable(true); + m_text.addMouseListener(new VLocator_mouseAdapter(this)); // popup + m_text.setFont(AdempierePLAF.getFont_Field()); + m_text.setForeground(AdempierePLAF.getTextColor_Normal()); + m_text.addActionListener(this); + this.add(m_text, BorderLayout.CENTER); + + m_button.setIcon(new ImageIcon(org.compiere.Adempiere.class.getResource("images/Locator10.gif"))); + m_button.setMargin(new Insets(0, 0, 0, 0)); + m_button.setPreferredSize(new Dimension(height, height)); + m_button.addActionListener(this); + this.add(m_button, BorderLayout.EAST); + + // Prefereed Size + this.setPreferredSize(this.getPreferredSize()); // causes r/o to be the same length + + // ReadWrite + if (isReadOnly || !isUpdateable) + setReadWrite (false); + else + setReadWrite (true); + setMandatory (mandatory); + // + mZoom = new CMenuItem(Msg.getMsg(Env.getCtx(), "Zoom"), Env.getImageIcon("Zoom16.gif")); + mZoom.addActionListener(this); + popupMenu.add(mZoom); + mRefresh = new CMenuItem(Msg.getMsg(Env.getCtx(), "Refresh"), Env.getImageIcon("Refresh16.gif")); + mRefresh.addActionListener(this); + popupMenu.add(mRefresh); + setDefault_Locator_ID(); // set default locator, teo_sarca [ 1661546 ] + } // VLocator + + /** + * Dispose + */ + public void dispose() + { + m_text = null; + m_button = null; + m_mLocator = null; + } // dispose + + private JTextField m_text = new JTextField (VLookup.DISPLAY_LENGTH); + private CButton m_button = new CButton(); + private MLocatorLookup m_mLocator; + private Object m_value; + // + private String m_columnName; + private int m_WindowNo; + /** Logger */ + private static CLogger log = CLogger.getCLogger(VLocator.class); + // Popup + JPopupMenu popupMenu = new JPopupMenu(); + private CMenuItem mZoom; + private CMenuItem mRefresh; + + /** + * Enable/disable + * @param value r/w + */ + public void setReadWrite (boolean value) + { + m_button.setReadWrite(value); + if (m_button.isVisible() != value) + m_button.setVisible(value); + setBackground(false); + } // setReadWrite + + /** + * IsReadWrite + * @return true if ReadWrite + */ + public boolean isReadWrite() + { + return m_button.isReadWrite(); + } // isReadWrite + + /** + * Set Mandatory (and back bolor) + * @param mandatory true if mandatory + */ + public void setMandatory (boolean mandatory) + { + m_button.setMandatory(mandatory); + setBackground(false); + } // setMandatory + + /** + * Is it mandatory + * @return true if mandatory + */ + public boolean isMandatory() + { + return m_button.isMandatory(); + } // isMandatory + + /** + * Set Background + * @param color color + */ + public void setBackground (Color color) + { + if (!color.equals(m_text.getBackground())) + m_text.setBackground(color); + } // setBackground + + /** + * Set Background based on editable / mandatory / error + * @param error if true, set background to error color, otherwise mandatory/editable + */ + public void setBackground (boolean error) + { + if (error) + setBackground(AdempierePLAF.getFieldBackground_Error()); + else if (!isReadWrite()) + setBackground(AdempierePLAF.getFieldBackground_Inactive()); + else if (isMandatory()) + setBackground(AdempierePLAF.getFieldBackground_Mandatory()); + else + setBackground(AdempierePLAF.getFieldBackground_Normal()); + } // setBackground + + /** + * Set Foreground + * @param fg color + */ + public void setForeground(Color fg) + { + m_text.setForeground(fg); + } // setForeground + + /** + * Request Focus + */ + public void requestFocus () + { + m_text.requestFocus (); + } // requestFocus + + /** + * Set Editor to value + * @param value Integer + */ + public void setValue(Object value) + { + setValue (value, false); + } // setValue + + /** + * Set Value + * @param value value + * @param fire data binding + */ + private void setValue (Object value, boolean fire) + { + if (m_mLocator == null) + { + return ; + } + + if (value != null) + { + m_mLocator.setOnly_Warehouse_ID (getOnly_Warehouse_ID ()); + m_mLocator.setOnly_Product_ID(getOnly_Product_ID()); + if (!m_mLocator.isValid(value)) + value = null; + } + // + m_value = value; + m_text.setText(m_mLocator.getDisplay(value)); // loads value + + // Data Binding + try + { + fireVetoableChange(m_columnName, null, value); + } + catch (PropertyVetoException pve) + { + } + } // setValue + + + /** + * Property Change Listener + * @param evt PropertyChangeEvent + */ + public void propertyChange (PropertyChangeEvent evt) + { + if (evt.getPropertyName().equals(org.compiere.model.GridField.PROPERTY)) + setValue(evt.getNewValue()); + } // propertyChange + + /** + * Return Editor value + * @return value + */ + public Object getValue() + { + if (getM_Locator_ID() == 0) + return null; + return m_value; + } // getValue + + /** + * Get M_Locator_ID + * @return id + */ + public int getM_Locator_ID() + { + if (m_value != null + && m_value instanceof Integer) + return ((Integer)m_value).intValue(); + return 0; + } // getM_Locator_ID + + /** + * Return Display Value + * @return display value + */ + public String getDisplay() + { + return m_text.getText(); + } // getDisplay + + /** + * ActionListener + * @param e ActionEvent + */ + public void actionPerformed(ActionEvent e) + { + // Refresh + if (e.getSource() == mRefresh) + { + m_mLocator.refresh(); + return; + } + + // Zoom to M_Warehouse + if (e.getSource() == mZoom) + { + actionZoom(); + return; + } + + // Warehouse/Product + int only_Warehouse_ID = getOnly_Warehouse_ID(); + int only_Product_ID = getOnly_Product_ID(); + log.config("Only Warehouse_ID=" + only_Warehouse_ID + + ", Product_ID=" + only_Product_ID); + + // Text Entry ok + if (e.getSource() == m_text + && actionText(only_Warehouse_ID, only_Product_ID)) + return; + + // Button - Start Dialog + int M_Locator_ID = 0; + if (m_value instanceof Integer) + M_Locator_ID = ((Integer)m_value).intValue(); + // + m_mLocator.setOnly_Warehouse_ID(only_Warehouse_ID); + m_mLocator.setOnly_Product_ID(getOnly_Product_ID()); + VLocatorDialog ld = new VLocatorDialog(Env.getFrame(this), + Msg.translate(Env.getCtx(), m_columnName), + m_mLocator, M_Locator_ID, isMandatory(), only_Warehouse_ID); + // display + ld.setVisible(true); + m_mLocator.setOnly_Warehouse_ID(0); + + // redisplay + if (!ld.isChanged()) + return; + setValue (ld.getValue(), true); + } // actionPerformed + + /** + * Hit Enter in Text Field + * @param only_Warehouse_ID if not 0 restrict warehouse + * @param only_Product_ID of not 0 restricted product + * @return true if found + */ + private boolean actionText (int only_Warehouse_ID, int only_Product_ID) + { + String text = m_text.getText(); + log.fine(text); + // Null + if (text == null || text.length() == 0) + { + if (isMandatory()) + return false; + else + { + setValue (null, true); + return true; + } + } + if (text.endsWith("%")) + text = text.toUpperCase(); + else + text = text.toUpperCase() + "%"; + + // Look up - see MLocatorLookup.run + StringBuffer sql = new StringBuffer("SELECT M_Locator_ID FROM M_Locator ") + .append(" WHERE IsActive='Y' AND UPPER(Value) LIKE ") + .append(DB.TO_STRING(text)); + if (getOnly_Warehouse_ID() != 0) + sql.append(" AND M_Warehouse_ID=?"); + if (getOnly_Product_ID() != 0) + sql.append(" AND (IsDefault='Y' ") // Default Locator + .append("OR EXISTS (SELECT * FROM M_Product p ") // Product Locator + .append("WHERE p.M_Locator_ID=M_Locator.M_Locator_ID AND p.M_Product_ID=?)") + .append("OR EXISTS (SELECT * FROM M_Storage s ") // Storage Locator + .append("WHERE s.M_Locator_ID=M_Locator.M_Locator_ID AND s.M_Product_ID=?))"); + String finalSql = MRole.getDefault(Env.getCtx(), false).addAccessSQL( + sql.toString(), "M_Locator", MRole.SQL_NOTQUALIFIED, MRole.SQL_RO); + // + int M_Locator_ID = 0; + PreparedStatement pstmt = null; + try + { + pstmt = DB.prepareStatement(finalSql, null); + int index = 1; + if (only_Warehouse_ID != 0) + pstmt.setInt(index++, only_Warehouse_ID); + if (only_Product_ID != 0) + { + pstmt.setInt(index++, only_Product_ID); + pstmt.setInt(index++, only_Product_ID); + } + ResultSet rs = pstmt.executeQuery(); + if (rs.next()) + { + M_Locator_ID = rs.getInt(1); + if (rs.next()) + M_Locator_ID = 0; // more than one + } + rs.close(); + pstmt.close(); + pstmt = null; + } + catch (SQLException ex) + { + log.log(Level.SEVERE, finalSql, ex); + } + try + { + if (pstmt != null) + pstmt.close(); + } + catch (SQLException ex1) + { + } + pstmt = null; + if (M_Locator_ID == 0) + return false; + + setValue (new Integer(M_Locator_ID), true); + return true; + } // actionText + + /** + * Action Listener Interface + * @param listener listener + */ + public void addActionListener(ActionListener listener) + { + m_text.addActionListener(listener); + } // addActionListener + + + /** + * Action - Zoom + */ + private void actionZoom() + { + int AD_Window_ID = MTable.get(Env.getCtx(), MLocator.Table_ID).getAD_Window_ID(); + if (AD_Window_ID <= 0) + AD_Window_ID = 139; // hardcoded window Warehouse & Locators + log.info(""); + // + setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); + AWindow frame = new AWindow(); + + MQuery zoomQuery = new MQuery(); + zoomQuery.addRestriction(MLocator.COLUMNNAME_M_Locator_ID, MQuery.EQUAL, getValue()); + zoomQuery.setRecordCount(1); // guess + + if (!frame.initWindow(AD_Window_ID, zoomQuery)) + return; + AEnv.addToWindowManager(frame); + AEnv.showCenterScreen(frame); + frame = null; + setCursor(Cursor.getDefaultCursor()); + } // actionZoom + + /** + * Set Field/WindowNo for ValuePreference (NOP) + * @param mField Model Field + */ + public void setField (org.compiere.model.GridField mField) + { + } // setField + + + /** + * Get Warehouse restriction if any. + * @return M_Warehouse_ID or 0 + */ + private int getOnly_Warehouse_ID() + { + String only_Warehouse = Env.getContext(Env.getCtx(), m_WindowNo, "M_Warehouse_ID", true); + int only_Warehouse_ID = 0; + try + { + if (only_Warehouse != null && only_Warehouse.length () > 0) + only_Warehouse_ID = Integer.parseInt (only_Warehouse); + } + catch (Exception ex) + { + } + return only_Warehouse_ID; + } // getOnly_Warehouse_ID + + /** + * Get Product restriction if any. + * @return M_Product_ID or 0 + */ + private int getOnly_Product_ID() + { + if (!Env.isSOTrx(Env.getCtx(), m_WindowNo)) + return 0; // No product restrictions for PO + // + String only_Product = Env.getContext(Env.getCtx(), m_WindowNo, "M_Product_ID", true); + int only_Product_ID = 0; + try + { + if (only_Product != null && only_Product.length () > 0) + only_Product_ID = Integer.parseInt (only_Product); + } + catch (Exception ex) + { + } + return only_Product_ID; + } // getOnly_Product_ID + + /** + * Set the default locator if this field is mandatory + * and we have a warehouse restriction. + * + * @since 3.1.4 + */ + private void setDefault_Locator_ID() + { + // teo_sarca, FR [ 1661546 ] Mandatory locator fields should use defaults + if (!isMandatory() || m_mLocator == null) { + return; + } + int M_Warehouse_ID = getOnly_Warehouse_ID(); + if (M_Warehouse_ID <= 0) { + return; + } + MWarehouse wh = MWarehouse.get(Env.getCtx(), M_Warehouse_ID); + if (wh == null || wh.get_ID() <= 0) { + return; + } + MLocator loc = wh.getDefaultLocator(); + if (loc == null || loc.get_ID() <= 0) { + return; + } + setValue(Integer.valueOf(loc.get_ID())); + } + +} // VLocator + +/*****************************************************************************/ \ No newline at end of file diff --git a/client/src/org/compiere/grid/ed/VLookup.java b/client/src/org/compiere/grid/ed/VLookup.java index ee0f838713..823265cc77 100644 --- a/client/src/org/compiere/grid/ed/VLookup.java +++ b/client/src/org/compiere/grid/ed/VLookup.java @@ -105,6 +105,40 @@ public class VLookup extends JComponent */ private static final long serialVersionUID = -104909868954609498L; + /***************************************************************************** + * Mouse Listener for Popup Menu + */ + final class VLookup_mouseAdapter extends java.awt.event.MouseAdapter + { + /** + * Constructor + * @param adaptee adaptee + */ + VLookup_mouseAdapter(VLookup adaptee) + { + m_adaptee = adaptee; + } // VLookup_mouseAdapter + + private VLookup m_adaptee; + + /** + * Mouse Listener + * @param e MouseEvent + */ + public void mouseClicked(MouseEvent e) + { + // System.out.println("mouseClicked " + e.getID() + " " + e.getSource().getClass().toString()); + // popup menu + if (SwingUtilities.isRightMouseButton(e)) + m_adaptee.popupMenu.show((Component)e.getSource(), e.getX(), e.getY()); + // Hide the popup if not right click - teo_sarca [ 1734802 ] + else + m_adaptee.popupMenu.setVisible(false); + } // mouse Clicked + + } // VLookup_mouseAdapter + + @Override protected boolean processKeyBinding(KeyStroke ks, KeyEvent e, int condition, boolean pressed) { @@ -1579,37 +1613,4 @@ public class VLookup extends JComponent } -} // VLookup - -/***************************************************************************** - * Mouse Listener for Popup Menu - */ -final class VLookup_mouseAdapter extends java.awt.event.MouseAdapter -{ - /** - * Constructor - * @param adaptee adaptee - */ - VLookup_mouseAdapter(VLookup adaptee) - { - m_adaptee = adaptee; - } // VLookup_mouseAdapter - - private VLookup m_adaptee; - - /** - * Mouse Listener - * @param e MouseEvent - */ - public void mouseClicked(MouseEvent e) - { - // System.out.println("mouseClicked " + e.getID() + " " + e.getSource().getClass().toString()); - // popup menu - if (SwingUtilities.isRightMouseButton(e)) - m_adaptee.popupMenu.show((Component)e.getSource(), e.getX(), e.getY()); - // Hide the popup if not right click - teo_sarca [ 1734802 ] - else - m_adaptee.popupMenu.setVisible(false); - } // mouse Clicked - -} // VLookup_mouseAdapter +} // VLookup \ No newline at end of file diff --git a/client/src/org/compiere/grid/ed/VMemo.java b/client/src/org/compiere/grid/ed/VMemo.java index b5166bd289..0c72875002 100644 --- a/client/src/org/compiere/grid/ed/VMemo.java +++ b/client/src/org/compiere/grid/ed/VMemo.java @@ -57,6 +57,40 @@ public class VMemo extends CTextArea */ private static final long serialVersionUID = 9218826231484540367L; + /*****************************************************************************/ + + /** + * Mouse Listener + */ + final class VMemo_mouseAdapter extends MouseAdapter + { + /** + * Constructor + * @param adaptee + */ + VMemo_mouseAdapter(VMemo adaptee) + { + this.adaptee = adaptee; + } // VMemo_mouseAdapter + + private VMemo adaptee; + + /** + * Mouse Listener + * @param e + */ + public void mouseClicked(MouseEvent e) + { + // popup menu + if (SwingUtilities.isRightMouseButton(e)) + adaptee.popupMenu.show((Component)e.getSource(), e.getX(), e.getY()); + } // mouse Clicked + + + + } // VMemo_mouseAdapter + + /** * IDE Baan Constructor */ @@ -291,40 +325,3 @@ private class CInputVerifier extends InputVerifier { } // VMemo - -/*****************************************************************************/ - -/** - * Mouse Listener - */ -final class VMemo_mouseAdapter extends MouseAdapter -{ - /** - * Constructor - * @param adaptee - */ - VMemo_mouseAdapter(VMemo adaptee) - { - this.adaptee = adaptee; - } // VMemo_mouseAdapter - - private VMemo adaptee; - - /** - * Mouse Listener - * @param e - */ - public void mouseClicked(MouseEvent e) - { - // popup menu - if (SwingUtilities.isRightMouseButton(e)) - adaptee.popupMenu.show((Component)e.getSource(), e.getX(), e.getY()); - } // mouse Clicked - - - -} // VMemo_mouseAdapter - - - - diff --git a/client/src/org/compiere/grid/ed/VPAttribute.java b/client/src/org/compiere/grid/ed/VPAttribute.java index d42ac269f5..b8ff630623 100644 --- a/client/src/org/compiere/grid/ed/VPAttribute.java +++ b/client/src/org/compiere/grid/ed/VPAttribute.java @@ -66,6 +66,37 @@ public class VPAttribute extends JComponent */ private static final long serialVersionUID = 108156477716619163L; + /** + * Mouse Listener + */ + final class VPAttribute_mouseAdapter extends MouseAdapter + { + /** + * Constructor + * @param adaptee adaptee + */ + VPAttribute_mouseAdapter(VPAttribute adaptee) + { + m_adaptee = adaptee; + } // VPAttribute_mouseAdapter + + private VPAttribute m_adaptee; + + /** + * Mouse Listener + * @param e event + */ + public void mouseClicked(MouseEvent e) + { + // Double Click + if (e.getClickCount() > 1) + m_adaptee.actionPerformed(new ActionEvent(e.getSource(), e.getID(), "Mouse")); + // popup menu + if (SwingUtilities.isRightMouseButton(e)) + m_adaptee.popupMenu.show((Component)e.getSource(), e.getX(), e.getY()); + } // mouse Clicked + + } // VPAttribute_mouseAdapter /** * IDE Constructor @@ -437,35 +468,3 @@ public class VPAttribute extends JComponent } // propertyChange } // VPAttribute - -/** - * Mouse Listener - */ -final class VPAttribute_mouseAdapter extends MouseAdapter -{ - /** - * Constructor - * @param adaptee adaptee - */ - VPAttribute_mouseAdapter(VPAttribute adaptee) - { - m_adaptee = adaptee; - } // VPAttribute_mouseAdapter - - private VPAttribute m_adaptee; - - /** - * Mouse Listener - * @param e event - */ - public void mouseClicked(MouseEvent e) - { - // Double Click - if (e.getClickCount() > 1) - m_adaptee.actionPerformed(new ActionEvent(e.getSource(), e.getID(), "Mouse")); - // popup menu - if (SwingUtilities.isRightMouseButton(e)) - m_adaptee.popupMenu.show((Component)e.getSource(), e.getX(), e.getY()); - } // mouse Clicked - -} // VPAttribute_mouseAdapter diff --git a/client/src/org/compiere/grid/ed/VPAttributeDialog.java b/client/src/org/compiere/grid/ed/VPAttributeDialog.java index 872cb4597f..f071411009 100644 --- a/client/src/org/compiere/grid/ed/VPAttributeDialog.java +++ b/client/src/org/compiere/grid/ed/VPAttributeDialog.java @@ -86,6 +86,36 @@ public class VPAttributeDialog extends CDialog */ private static final long serialVersionUID = -1062346984681892620L; + /***************************************************************************** + * Mouse Listener for Popup Menu + */ + final class VPAttributeDialog_mouseAdapter extends java.awt.event.MouseAdapter + { + /** + * Constructor + * @param adaptee adaptee + */ + VPAttributeDialog_mouseAdapter(VPAttributeDialog adaptee) + { + m_adaptee = adaptee; + } // VPAttributeDialog_mouseAdapter + + private VPAttributeDialog m_adaptee; + + /** + * Mouse Listener + * @param e MouseEvent + */ + public void mouseClicked(MouseEvent e) + { + // System.out.println("mouseClicked " + e.getID() + " " + e.getSource().getClass().toString()); + // popup menu + if (SwingUtilities.isRightMouseButton(e)) + m_adaptee.popupMenu.show((Component)e.getSource(), e.getX(), e.getY()); + } // mouse Clicked + + } // VPAttributeDialog_mouseAdapter + /** * Product Attribute Instance Dialog * @param frame parent frame @@ -808,33 +838,3 @@ public class VPAttributeDialog extends CDialog } // isChanged } // VPAttributeDialog - -/***************************************************************************** - * Mouse Listener for Popup Menu - */ -final class VPAttributeDialog_mouseAdapter extends java.awt.event.MouseAdapter -{ - /** - * Constructor - * @param adaptee adaptee - */ - VPAttributeDialog_mouseAdapter(VPAttributeDialog adaptee) - { - m_adaptee = adaptee; - } // VPAttributeDialog_mouseAdapter - - private VPAttributeDialog m_adaptee; - - /** - * Mouse Listener - * @param e MouseEvent - */ - public void mouseClicked(MouseEvent e) - { - // System.out.println("mouseClicked " + e.getID() + " " + e.getSource().getClass().toString()); - // popup menu - if (SwingUtilities.isRightMouseButton(e)) - m_adaptee.popupMenu.show((Component)e.getSource(), e.getX(), e.getY()); - } // mouse Clicked - -} // VPAttributeDialog_mouseAdapter \ No newline at end of file diff --git a/client/src/org/compiere/grid/ed/VString.java b/client/src/org/compiere/grid/ed/VString.java index 129f584541..93a0cc22eb 100644 --- a/client/src/org/compiere/grid/ed/VString.java +++ b/client/src/org/compiere/grid/ed/VString.java @@ -63,6 +63,35 @@ public final class VString extends CTextField /** Max Display Length - 60 */ public static final int MAXDISPLAY_LENGTH = org.compiere.model.GridField.MAXDISPLAY_LENGTH; + /****************************************************************************** + * Mouse Listener + */ + final class VString_mouseAdapter extends MouseAdapter + { + /** + * Constructor + * @param adaptee adaptee + */ + VString_mouseAdapter(VString adaptee) + { + m_adaptee = adaptee; + } // VString_mouseAdapter + + private VString m_adaptee; + + /** + * Mouse Listener + * @param e event + */ + public void mouseClicked(MouseEvent e) + { + // popup menu + if (SwingUtilities.isRightMouseButton(e)) + m_adaptee.popupMenu.show((Component)e.getSource(), e.getX(), e.getY()); + } // mouseClicked + + } // VText_mouseAdapter + /** * IDE Bean Constructor for 30 character updateable field */ @@ -382,34 +411,4 @@ public final class VString extends CTextField m_obscureFont = new Font("SansSerif", Font.ITALIC, m_stdFont.getSize()); } -} // VString - - -/****************************************************************************** - * Mouse Listener - */ -final class VString_mouseAdapter extends MouseAdapter -{ - /** - * Constructor - * @param adaptee adaptee - */ - VString_mouseAdapter(VString adaptee) - { - m_adaptee = adaptee; - } // VString_mouseAdapter - - private VString m_adaptee; - - /** - * Mouse Listener - * @param e event - */ - public void mouseClicked(MouseEvent e) - { - // popup menu - if (SwingUtilities.isRightMouseButton(e)) - m_adaptee.popupMenu.show((Component)e.getSource(), e.getX(), e.getY()); - } // mouseClicked - -} // VText_mouseAdapter +} // VString \ No newline at end of file diff --git a/client/src/org/compiere/grid/ed/VText.java b/client/src/org/compiere/grid/ed/VText.java index 4731317016..3d1f9f5ce7 100644 --- a/client/src/org/compiere/grid/ed/VText.java +++ b/client/src/org/compiere/grid/ed/VText.java @@ -52,6 +52,37 @@ public class VText extends CTextArea */ private static final long serialVersionUID = -2479847373606754733L; + /*****************************************************************************/ + + /** + * Mouse Listener + */ + final class VText_mouseAdapter extends MouseAdapter + { + /** + * Constructor + * @param adaptee VText + */ + VText_mouseAdapter(VText adaptee) + { + this.adaptee = adaptee; + } // VText_mouseAdapter + + private VText adaptee; + + /** + * Mouse Listener + * @param e event + */ + public void mouseClicked(MouseEvent e) + { + // popup menu + if (SwingUtilities.isRightMouseButton(e)) + adaptee.popupMenu.show((Component)e.getSource(), e.getX(), e.getY()); + } // mouse Clicked + + } // VText_mouseAdapter + /** * Standard Constructor * @param columnName column name @@ -212,34 +243,3 @@ public class VText extends CTextArea } // setField } // VText - -/*****************************************************************************/ - -/** - * Mouse Listener - */ -final class VText_mouseAdapter extends MouseAdapter -{ - /** - * Constructor - * @param adaptee VText - */ - VText_mouseAdapter(VText adaptee) - { - this.adaptee = adaptee; - } // VText_mouseAdapter - - private VText adaptee; - - /** - * Mouse Listener - * @param e event - */ - public void mouseClicked(MouseEvent e) - { - // popup menu - if (SwingUtilities.isRightMouseButton(e)) - adaptee.popupMenu.show((Component)e.getSource(), e.getX(), e.getY()); - } // mouse Clicked - -} // VText_mouseAdapter diff --git a/client/src/org/compiere/grid/ed/VTextLong.java b/client/src/org/compiere/grid/ed/VTextLong.java index 90425e6828..a6cf6a6e44 100644 --- a/client/src/org/compiere/grid/ed/VTextLong.java +++ b/client/src/org/compiere/grid/ed/VTextLong.java @@ -54,6 +54,37 @@ public class VTextLong extends CTextPane */ private static final long serialVersionUID = 4776186117962407679L; + /*****************************************************************************/ + + /** + * Mouse Listener + */ + final class VTextLong_mouseAdapter extends MouseAdapter + { + /** + * Constructor + * @param adaptee VText + */ + VTextLong_mouseAdapter(VTextLong adaptee) + { + this.adaptee = adaptee; + } // VText_mouseAdapter + + private VTextLong adaptee; + + /** + * Mouse Listener + * @param e event + */ + public void mouseClicked(MouseEvent e) + { + // popup menu + if (SwingUtilities.isRightMouseButton(e)) + adaptee.popupMenu.show((Component)e.getSource(), e.getX(), e.getY()); + } // mouse Clicked + + } // VTextLong_mouseAdapter + /** * Factory: Start Editor * @param jc container to get parent frame @@ -218,35 +249,4 @@ public class VTextLong extends CTextPane } // setField -} // VTextLong - -/*****************************************************************************/ - -/** - * Mouse Listener - */ -final class VTextLong_mouseAdapter extends MouseAdapter -{ - /** - * Constructor - * @param adaptee VText - */ - VTextLong_mouseAdapter(VTextLong adaptee) - { - this.adaptee = adaptee; - } // VText_mouseAdapter - - private VTextLong adaptee; - - /** - * Mouse Listener - * @param e event - */ - public void mouseClicked(MouseEvent e) - { - // popup menu - if (SwingUtilities.isRightMouseButton(e)) - adaptee.popupMenu.show((Component)e.getSource(), e.getX(), e.getY()); - } // mouse Clicked - -} // VTextLong_mouseAdapter +} // VTextLong \ No newline at end of file diff --git a/client/src/org/compiere/grid/ed/VURL.java b/client/src/org/compiere/grid/ed/VURL.java index 435c77050e..1684b8dd36 100644 --- a/client/src/org/compiere/grid/ed/VURL.java +++ b/client/src/org/compiere/grid/ed/VURL.java @@ -63,6 +63,35 @@ public class VURL extends JComponent */ private static final long serialVersionUID = -5090157084793992376L; + /****************************************************************************** + * Mouse Listener + */ + final class VURL_mouseAdapter extends MouseAdapter + { + /** + * Constructor + * @param adaptee adaptee + */ + VURL_mouseAdapter(VURL adaptee) + { + m_adaptee = adaptee; + } // VString_mouseAdapter + + private VURL m_adaptee; + + /** + * Mouse Listener + * @param e event + */ + public void mouseClicked(MouseEvent e) + { + // popup menu + if (SwingUtilities.isRightMouseButton(e)) + m_adaptee.popupMenu.show((Component)e.getSource(), e.getX(), e.getY()); + } // mouseClicked + + } // VURL_mouseAdapter + /** * IDE Constructor */ @@ -457,36 +486,6 @@ public class VURL extends JComponent m_infocus = false; setText(getText()); // obscure } // focus Lost - - - /****************************************************************************** - * Mouse Listener - */ - final class VURL_mouseAdapter extends MouseAdapter - { - /** - * Constructor - * @param adaptee adaptee - */ - VURL_mouseAdapter(VURL adaptee) - { - m_adaptee = adaptee; - } // VString_mouseAdapter - - private VURL m_adaptee; - - /** - * Mouse Listener - * @param e event - */ - public void mouseClicked(MouseEvent e) - { - // popup menu - if (SwingUtilities.isRightMouseButton(e)) - m_adaptee.popupMenu.show((Component)e.getSource(), e.getX(), e.getY()); - } // mouseClicked - - } // VURL_mouseAdapter } // VURL diff --git a/client/src/org/compiere/grid/tree/VTreePanel.java b/client/src/org/compiere/grid/tree/VTreePanel.java index d155d5a4b3..2c46c07d2c 100644 --- a/client/src/org/compiere/grid/tree/VTreePanel.java +++ b/client/src/org/compiere/grid/tree/VTreePanel.java @@ -117,6 +117,63 @@ import de.schaeffer.compiere.tools.DocumentSearch; public final class VTreePanel extends CPanel implements ActionListener, DragGestureListener, DragSourceListener, DropTargetListener { + + /****************************************************************************** + * Mouse Clicked + */ + class VTreePanel_mouseAdapter extends java.awt.event.MouseAdapter + { + VTreePanel m_adaptee; + + /** + * VTreePanel_mouseAdapter + * @param adaptee + */ + VTreePanel_mouseAdapter(VTreePanel adaptee) + { + m_adaptee = adaptee; + } + + /** + * Mouse Clicked + * @param e + */ + public void mouseClicked(MouseEvent e) + { + m_adaptee.mouseClicked(e); + } + + + } // VTreePanel_mouseAdapter + + /** + * Key Pressed + */ + class VTreePanel_keyAdapter extends java.awt.event.KeyAdapter + { + VTreePanel m_adaptee; + + /** + * VTreePanel_keyAdapter + * @param adaptee + */ + VTreePanel_keyAdapter(VTreePanel adaptee) + { + m_adaptee = adaptee; + } + + /** + * Key Pressed + * @param e + */ + public void keyPressed(KeyEvent e) + { + if (e.getKeyCode() == KeyEvent.VK_ENTER) + m_adaptee.keyPressed(e); + } + } // VTreePanel_keyAdapter + + /** * */ @@ -1199,57 +1256,3 @@ public final class VTreePanel extends CPanel } // VTreePanel -/****************************************************************************** - * Mouse Clicked - */ -class VTreePanel_mouseAdapter extends java.awt.event.MouseAdapter -{ - VTreePanel m_adaptee; - - /** - * VTreePanel_mouseAdapter - * @param adaptee - */ - VTreePanel_mouseAdapter(VTreePanel adaptee) - { - m_adaptee = adaptee; - } - - /** - * Mouse Clicked - * @param e - */ - public void mouseClicked(MouseEvent e) - { - m_adaptee.mouseClicked(e); - } - - -} // VTreePanel_mouseAdapter - -/** - * Key Pressed - */ -class VTreePanel_keyAdapter extends java.awt.event.KeyAdapter -{ - VTreePanel m_adaptee; - - /** - * VTreePanel_keyAdapter - * @param adaptee - */ - VTreePanel_keyAdapter(VTreePanel adaptee) - { - m_adaptee = adaptee; - } - - /** - * Key Pressed - * @param e - */ - public void keyPressed(KeyEvent e) - { - if (e.getKeyCode() == KeyEvent.VK_ENTER) - m_adaptee.keyPressed(e); - } -} // VTreePanel_keyAdapter