From 8ede88a39550e635f018613e6380e0093c190df5 Mon Sep 17 00:00:00 2001 From: Heng Sin Low Date: Thu, 23 Nov 2006 02:18:47 +0000 Subject: [PATCH] * Add window menu to FormFrame * Turn off focus border when cell editor is combobox * Ensure cell editor and renderer use the same font * Table header should use default look and feel renderer if possble * VString - Update standard font and obscure font when setfount is called --- .../src/org/compiere/apps/form/FormFrame.java | 5 +++ .../src/org/compiere/grid/ed/VCellEditor.java | 11 +++++- .../org/compiere/grid/ed/VCellRenderer.java | 3 +- .../org/compiere/grid/ed/VHeaderRenderer.java | 37 ++++++++++++++++--- client/src/org/compiere/grid/ed/VString.java | 7 ++++ 5 files changed, 56 insertions(+), 7 deletions(-) diff --git a/client/src/org/compiere/apps/form/FormFrame.java b/client/src/org/compiere/apps/form/FormFrame.java index 194015ac4f..6189a37846 100644 --- a/client/src/org/compiere/apps/form/FormFrame.java +++ b/client/src/org/compiere/apps/form/FormFrame.java @@ -136,6 +136,11 @@ public class FormFrame extends CFrame mTools.addSeparator(); AEnv.addMenuItem("Preference", null, null, mTools, this); } + + // Window + AMenu aMenu = (AMenu)Env.getWindow(0); + JMenu mWindow = new WindowMenu(aMenu.getWindowManager(), this); + menuBar.add(mWindow); // Help JMenu mHelp = AEnv.getMenu("Help"); diff --git a/client/src/org/compiere/grid/ed/VCellEditor.java b/client/src/org/compiere/grid/ed/VCellEditor.java index 4c7ee54ad9..c2c25221b8 100644 --- a/client/src/org/compiere/grid/ed/VCellEditor.java +++ b/client/src/org/compiere/grid/ed/VCellEditor.java @@ -130,7 +130,16 @@ public final class VCellEditor extends AbstractCellEditor // Other UI m_editor.setFont(table.getFont()); - m_editor.setBorder(UIManager.getBorder("Table.focusCellHighlightBorder")); + if ( m_editor instanceof VLookup) { + VLookup lookup = (VLookup)m_editor; + if (lookup.getComponents()[0] instanceof JComboBox) { + lookup.setBorder(BorderFactory.createEmptyBorder()); + } else { + lookup.setBorder(UIManager.getBorder("Table.focusCellHighlightBorder")); + } + } else { + m_editor.setBorder(UIManager.getBorder("Table.focusCellHighlightBorder")); + } // return (Component)m_editor; } // getTableCellEditorComponent diff --git a/client/src/org/compiere/grid/ed/VCellRenderer.java b/client/src/org/compiere/grid/ed/VCellRenderer.java index 95821bdd01..1cde9d477e 100644 --- a/client/src/org/compiere/grid/ed/VCellRenderer.java +++ b/client/src/org/compiere/grid/ed/VCellRenderer.java @@ -109,7 +109,8 @@ public final class VCellRenderer extends DefaultTableCellRenderer else { // returns JLabel c = super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, col); - c.setFont(AdempierePLAF.getFont_Field()); + //c.setFont(AdempierePLAF.getFont_Field()); + c.setFont(table.getFont()); } // Background & Foreground diff --git a/client/src/org/compiere/grid/ed/VHeaderRenderer.java b/client/src/org/compiere/grid/ed/VHeaderRenderer.java index 0431279dea..37fa918c2e 100644 --- a/client/src/org/compiere/grid/ed/VHeaderRenderer.java +++ b/client/src/org/compiere/grid/ed/VHeaderRenderer.java @@ -30,6 +30,13 @@ import org.compiere.util.*; */ public final class VHeaderRenderer implements TableCellRenderer { + public VHeaderRenderer() + { + m_button = new CButton(); + m_button.setMargin(new Insets(0,0,0,0)); + m_button.putClientProperty("Plastic.is3D", Boolean.FALSE); + } + /** * Constructor * @param displayType @@ -39,16 +46,17 @@ public final class VHeaderRenderer implements TableCellRenderer super(); // Alignment if (DisplayType.isNumeric(displayType)) - m_button.setHorizontalAlignment(JLabel.RIGHT); + m_alignment = JLabel.RIGHT; else if (displayType == DisplayType.YesNo) - m_button.setHorizontalAlignment(JLabel.CENTER); + m_alignment = JLabel.CENTER; else - m_button.setHorizontalAlignment(JLabel.LEFT); - m_button.setMargin(new Insets(0,0,0,0)); + m_alignment = JLabel.LEFT; } // VHeaderRenderer // for 3D effect in Windows - private CButton m_button = new CButton(); + private CButton m_button; + + private int m_alignment; /** * Get TableCell RendererComponent @@ -65,6 +73,25 @@ public final class VHeaderRenderer implements TableCellRenderer { // Log.trace(this,10, "VHeaderRenderer.getTableCellRendererComponent", value==null ? "null" : value.toString()); // indicator for invisible column + + TableCellRenderer headerRenderer = table.getTableHeader().getDefaultRenderer(); + Component headerComponent = headerRenderer == null ? null : + headerRenderer.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column); + if (headerComponent != null && headerComponent instanceof JComponent) { + if (headerComponent instanceof JLabel ) { + JLabel label = (JLabel)headerComponent; + label.setHorizontalAlignment(m_alignment); + if (value == null) + label.setPreferredSize(new Dimension(0,0)); + else + label.setText(value.toString()); + return label; + } + m_button.setBorder(((JComponent)headerComponent).getBorder()); + } else { + m_button.setBorder(UIManager.getBorder("TableHeader.cellBorder")); + } + if (value == null) { m_button.setPreferredSize(new Dimension(0,0)); diff --git a/client/src/org/compiere/grid/ed/VString.java b/client/src/org/compiere/grid/ed/VString.java index 0a87a09074..195d17c842 100644 --- a/client/src/org/compiere/grid/ed/VString.java +++ b/client/src/org/compiere/grid/ed/VString.java @@ -317,6 +317,13 @@ public final class VString extends CTextField m_infocus = false; setText(getText()); // obscure } // focus Lost + + @Override + public void setFont(Font f) { + super.setFont(f); + m_stdFont = f; + m_obscureFont = new Font("SansSerif", Font.ITALIC, m_stdFont.getSize()); + } } // VString