[ 1869609 ] Tabs within Collapsed Grid disabled
- refactor the synchronization code - make it work for level 2 include, for e.g, include period control tab into the period tab ( calendar window ) - remark old include tab code - remove hard coded prefer size, need to make the include tab more configurable ( later )
This commit is contained in:
parent
661f0ba5ef
commit
171ff34dfd
|
@ -183,11 +183,16 @@ public final class APanel extends CPanel
|
||||||
// tabPanel
|
// tabPanel
|
||||||
mainLayout.setHgap(2);
|
mainLayout.setHgap(2);
|
||||||
mainLayout.setVgap(2);
|
mainLayout.setVgap(2);
|
||||||
CPanel dummy = new CPanel();
|
if (isNested)
|
||||||
dummy.setLayout(new BorderLayout());
|
this.add(m_curGC, BorderLayout.CENTER);
|
||||||
dummy.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 2));
|
else
|
||||||
dummy.add(tabPanel, BorderLayout.CENTER);
|
{
|
||||||
this.add(dummy, BorderLayout.CENTER);
|
CPanel dummy = new CPanel();
|
||||||
|
dummy.setLayout(new BorderLayout());
|
||||||
|
dummy.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 2));
|
||||||
|
dummy.add(tabPanel, BorderLayout.CENTER);
|
||||||
|
this.add(dummy, BorderLayout.CENTER);
|
||||||
|
}
|
||||||
// southPanel
|
// southPanel
|
||||||
this.add(statusBar, BorderLayout.SOUTH);
|
this.add(statusBar, BorderLayout.SOUTH);
|
||||||
// northPanel
|
// northPanel
|
||||||
|
@ -697,13 +702,10 @@ public final class APanel extends CPanel
|
||||||
{
|
{
|
||||||
// FR [ 1757088 ]
|
// FR [ 1757088 ]
|
||||||
gc.removeDataStatusListener(this);
|
gc.removeDataStatusListener(this);
|
||||||
//gc.initGrid(gTab, false, m_curWindowNo, this, mWindow, false); // will set color on Tab level
|
GridSynchronizer synchronizer = new GridSynchronizer(mWindow, parent, gc);
|
||||||
m_mWorkbench.getMWindow(0).initTab(tab);
|
if (parent == m_curGC)
|
||||||
gc.activate();
|
synchronizer.activateChild();
|
||||||
included = parent.includeTab(gc,this);
|
included = parent.includeTab(gc,this,synchronizer);
|
||||||
|
|
||||||
if (!included)
|
|
||||||
log.log(Level.SEVERE, "Not Included = " + gc);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
initSwitchLineAction();
|
initSwitchLineAction();
|
||||||
|
|
|
@ -143,7 +143,8 @@ public class GridController extends CPanel
|
||||||
private BorderLayout graphLayout = new BorderLayout();
|
private BorderLayout graphLayout = new BorderLayout();
|
||||||
private CPanel cardPanel = new CPanel();
|
private CPanel cardPanel = new CPanel();
|
||||||
private CardLayout cardLayout = new CardLayout();
|
private CardLayout cardLayout = new CardLayout();
|
||||||
private JSplitPane srPane = new JSplitPane();
|
//private JSplitPane srPane = new JSplitPane();
|
||||||
|
|
||||||
private JScrollPane vPane = new JScrollPane();
|
private JScrollPane vPane = new JScrollPane();
|
||||||
private CScrollPane mrPane = new CScrollPane();
|
private CScrollPane mrPane = new CScrollPane();
|
||||||
private CPanel xPanel = new CPanel();
|
private CPanel xPanel = new CPanel();
|
||||||
|
@ -170,17 +171,19 @@ public class GridController extends CPanel
|
||||||
splitPane.setName("gc_splitPane");
|
splitPane.setName("gc_splitPane");
|
||||||
//
|
//
|
||||||
cardPanel.setLayout(cardLayout);
|
cardPanel.setLayout(cardLayout);
|
||||||
cardPanel.add(srPane, "srPane"); // Sequence Important!
|
cardPanel.add(vPane, "vPane"); // Sequence Important!
|
||||||
cardPanel.add(mrPane, "mrPane");
|
cardPanel.add(mrPane, "mrPane");
|
||||||
cardPanel.setBorder(null);
|
cardPanel.setBorder(null);
|
||||||
cardPanel.setName("gc_cardPanel");
|
cardPanel.setName("gc_cardPanel");
|
||||||
// single row (w/o xPane it would be centered)
|
// single row (w/o xPane it would be centered)
|
||||||
|
/*
|
||||||
srPane.setBorder(null);
|
srPane.setBorder(null);
|
||||||
srPane.setName("gc_srPane");
|
srPane.setName("gc_srPane");
|
||||||
srPane.setOrientation(JSplitPane.VERTICAL_SPLIT);
|
srPane.setOrientation(JSplitPane.VERTICAL_SPLIT);
|
||||||
srPane.add(vPane, JSplitPane.TOP);
|
srPane.add(vPane, JSplitPane.TOP);
|
||||||
srPane.setTopComponent(vPane);
|
srPane.setTopComponent(vPane);
|
||||||
srPane.setBottomComponent(null); // otherwise a button is created/displayed
|
srPane.setBottomComponent(null); // otherwise a button is created/displayed
|
||||||
|
*/
|
||||||
//FR [ 1757088 ] vPane.getViewport().add(xPanel, null);
|
//FR [ 1757088 ] vPane.getViewport().add(xPanel, null);
|
||||||
//FR [ 1757088 ] xPanel.add(vPanel);
|
//FR [ 1757088 ] xPanel.add(vPanel);
|
||||||
xPanel.setLayout(xLayout);
|
xPanel.setLayout(xLayout);
|
||||||
|
@ -196,7 +199,7 @@ public class GridController extends CPanel
|
||||||
//
|
//
|
||||||
graphPanel.setBorder(null);
|
graphPanel.setBorder(null);
|
||||||
graphPanel.setName("gc_graphPanel");
|
graphPanel.setName("gc_graphPanel");
|
||||||
srPane.setDividerLocation(200);
|
//srPane.setDividerLocation(200);
|
||||||
|
|
||||||
vPane.setBorder(BorderFactory.createEmptyBorder());
|
vPane.setBorder(BorderFactory.createEmptyBorder());
|
||||||
} // jbInit
|
} // jbInit
|
||||||
|
@ -247,8 +250,8 @@ public class GridController extends CPanel
|
||||||
vTable = null;
|
vTable = null;
|
||||||
vPanel.removeAll();
|
vPanel.removeAll();
|
||||||
vPanel = null;
|
vPanel = null;
|
||||||
srPane.removeAll();
|
//srPane.removeAll();
|
||||||
srPane = null;
|
//srPane = null;
|
||||||
splitPane.removeAll();
|
splitPane.removeAll();
|
||||||
splitPane = null;
|
splitPane = null;
|
||||||
m_mTab = null;
|
m_mTab = null;
|
||||||
|
@ -273,6 +276,8 @@ public class GridController extends CPanel
|
||||||
|
|
||||||
private boolean init;
|
private boolean init;
|
||||||
|
|
||||||
|
private ArrayList<GridSynchronizer> synchronizerList = new ArrayList<GridSynchronizer>();
|
||||||
|
|
||||||
public boolean initGrid (GridTab mTab, boolean onlyMultiRow,
|
public boolean initGrid (GridTab mTab, boolean onlyMultiRow,
|
||||||
int WindowNo, APanel aPanel, GridWindow mWindow)
|
int WindowNo, APanel aPanel, GridWindow mWindow)
|
||||||
{
|
{
|
||||||
|
@ -304,7 +309,7 @@ public class GridController extends CPanel
|
||||||
m_aPanel = aPanel;
|
m_aPanel = aPanel;
|
||||||
setName("GC-" + mTab);
|
setName("GC-" + mTab);
|
||||||
//FR [ 1757088 ]
|
//FR [ 1757088 ]
|
||||||
vPanel = new VPanel(mTab.getName());
|
vPanel = new VPanel(mTab.getName(), m_WindowNo);
|
||||||
vPanel.putClientProperty(AdempiereLookAndFeel.HIDE_IF_ONE_TAB, Boolean.TRUE);
|
vPanel.putClientProperty(AdempiereLookAndFeel.HIDE_IF_ONE_TAB, Boolean.TRUE);
|
||||||
vPane.getViewport().add(xPanel, null);
|
vPane.getViewport().add(xPanel, null);
|
||||||
xPanel.add(vPanel, BorderLayout.CENTER);
|
xPanel.add(vPanel, BorderLayout.CENTER);
|
||||||
|
@ -315,8 +320,8 @@ public class GridController extends CPanel
|
||||||
init();
|
init();
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (Ini.isPropertyBool(Ini.P_LOAD_TAB_META_DATA_BG))
|
//Load tab meta data, needed for includeTab to work
|
||||||
m_mTab.initTab(true);
|
m_mTab.initTab(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -371,10 +376,11 @@ public class GridController extends CPanel
|
||||||
} // for all fields
|
} // for all fields
|
||||||
|
|
||||||
// No Included Grid Controller
|
// No Included Grid Controller
|
||||||
|
/*
|
||||||
srPane.setResizeWeight(1); // top part gets all
|
srPane.setResizeWeight(1); // top part gets all
|
||||||
srPane.setDividerSize (0);
|
srPane.setDividerSize (0);
|
||||||
srPane.setDividerLocation (9999);
|
srPane.setDividerLocation (9999);
|
||||||
|
*/
|
||||||
// Use SR to size MR
|
// Use SR to size MR
|
||||||
mrPane.setPreferredSize(vPanel.getPreferredSize());
|
mrPane.setPreferredSize(vPanel.getPreferredSize());
|
||||||
} // Single-Row
|
} // Single-Row
|
||||||
|
@ -421,52 +427,37 @@ public class GridController extends CPanel
|
||||||
|
|
||||||
init = true;
|
init = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @return boolean
|
||||||
|
*/
|
||||||
|
public boolean isInit()
|
||||||
|
{
|
||||||
|
return init;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Include Tab
|
* Include Tab
|
||||||
* @param gc grod controller to add
|
* @param gc grid controller to add
|
||||||
* @return true if included
|
* @return GridSynchronizer
|
||||||
*/
|
*/
|
||||||
//FR [ 1757088 ]
|
//FR [ 1757088 ]
|
||||||
public boolean includeTab (GridController gc , APanel aPanel)
|
public boolean includeTab (GridController gc , APanel aPanel, GridSynchronizer sync)
|
||||||
{
|
{
|
||||||
GridController detail = gc;
|
GridController detail = gc;
|
||||||
int screenWidth = (int) Toolkit.getDefaultToolkit().getScreenSize().getWidth() - 630;
|
int screenWidth = (int) Toolkit.getDefaultToolkit().getScreenSize().getWidth() - 630;
|
||||||
// Set screen dimension
|
// Set screen dimension
|
||||||
detail.setPreferredSize(new Dimension(screenWidth, 250));
|
//detail.setPreferredSize(new Dimension(screenWidth, 250));
|
||||||
/*
|
detail.setDetailGrid(true);
|
||||||
ArrayList parents = detail.getMTab().getParentColumnNames();
|
|
||||||
// No Parent - no link
|
|
||||||
if (parents.size() == 0)
|
|
||||||
;
|
|
||||||
// Standard case
|
|
||||||
else if (parents.size() == 1)
|
|
||||||
detail.getMTab().setLinkColumnName((String)parents.get(0));
|
|
||||||
detail.getMTab().query(false, 0, 0);*/
|
|
||||||
/*
|
|
||||||
int c = VTable.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT;
|
|
||||||
vTable.getInputMap(c).put(KeyStroke.getKeyStroke(KeyEvent.VK_F4, 0), aPanel.aSave.getName());
|
|
||||||
vTable.getActionMap().put(aPanel.aSave.getName(), aPanel.aSave);*/
|
|
||||||
CollapsiblePanel section = vPanel.getIncludedSection(detail.getMTab().getAD_Tab_ID());
|
|
||||||
gc.setDetailGrid(true);
|
|
||||||
|
|
||||||
if(section != null)
|
|
||||||
{
|
|
||||||
APanel panel = new APanel(gc, m_WindowNo);
|
|
||||||
String name = detail.getMTab().getName() + "";
|
|
||||||
section.setTitle(name);
|
|
||||||
panel.add(detail);
|
|
||||||
section.getCollapsiblePane().getContentPane().setLayout(new BorderLayout());
|
|
||||||
section.getCollapsiblePane().getContentPane().add(panel, BorderLayout.CENTER);
|
|
||||||
}
|
|
||||||
|
|
||||||
detail.addMouseListener(detail);
|
detail.addMouseListener(detail);
|
||||||
detail.enableEvents(AWTEvent.HIERARCHY_EVENT_MASK + AWTEvent.MOUSE_EVENT_MASK);
|
detail.enableEvents(AWTEvent.HIERARCHY_EVENT_MASK + AWTEvent.MOUSE_EVENT_MASK);
|
||||||
detail.activate();
|
|
||||||
|
|
||||||
new GridSynchronizer(this, detail);
|
|
||||||
|
|
||||||
|
vPanel.includeTab(detail);
|
||||||
|
|
||||||
|
synchronizerList.add(sync);
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
} // IncludeTab
|
} // IncludeTab
|
||||||
|
|
||||||
//FR [ 1757088 ]
|
//FR [ 1757088 ]
|
||||||
|
@ -510,7 +501,18 @@ public class GridController extends CPanel
|
||||||
//
|
//
|
||||||
if (mField.getColumnName().equals(tc.getIdentifier().toString()))
|
if (mField.getColumnName().equals(tc.getIdentifier().toString()))
|
||||||
{
|
{
|
||||||
if (mField.getDisplayType () == DisplayType.RowID)
|
//don't show included tab field in grid
|
||||||
|
if (mField.getIncluded_Tab_ID() > 0)
|
||||||
|
{
|
||||||
|
TableCellNone tcn = new TableCellNone(mField.getColumnName());
|
||||||
|
tc.setCellRenderer (tcn);
|
||||||
|
tc.setCellEditor (tcn);
|
||||||
|
tc.setHeaderValue (null);
|
||||||
|
tc.setMinWidth (0);
|
||||||
|
tc.setMaxWidth (0);
|
||||||
|
tc.setPreferredWidth (0);
|
||||||
|
}
|
||||||
|
else if (mField.getDisplayType () == DisplayType.RowID)
|
||||||
{
|
{
|
||||||
tc.setCellRenderer (new VRowIDRenderer (false));
|
tc.setCellRenderer (new VRowIDRenderer (false));
|
||||||
tc.setCellEditor (new VRowIDEditor (false));
|
tc.setCellEditor (new VRowIDEditor (false));
|
||||||
|
@ -593,8 +595,20 @@ public class GridController extends CPanel
|
||||||
if (m_tree != null)
|
if (m_tree != null)
|
||||||
m_tree.initTree (AD_Tree_ID);
|
m_tree.initTree (AD_Tree_ID);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
activateChilds();
|
||||||
} // activate
|
} // activate
|
||||||
|
|
||||||
|
/**
|
||||||
|
* activate child grid controller ( included tab )
|
||||||
|
*/
|
||||||
|
private void activateChilds()
|
||||||
|
{
|
||||||
|
for (GridSynchronizer s : synchronizerList )
|
||||||
|
{
|
||||||
|
s.activateChild();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Register ESC Actions
|
* Register ESC Actions
|
||||||
|
|
|
@ -16,6 +16,7 @@ package org.compiere.grid;
|
||||||
import java.beans.PropertyChangeEvent;
|
import java.beans.PropertyChangeEvent;
|
||||||
import java.beans.PropertyChangeListener;
|
import java.beans.PropertyChangeListener;
|
||||||
|
|
||||||
|
import org.compiere.model.GridWindow;
|
||||||
import org.compiere.model.StateChangeEvent;
|
import org.compiere.model.StateChangeEvent;
|
||||||
import org.compiere.model.StateChangeListener;
|
import org.compiere.model.StateChangeListener;
|
||||||
import org.compiere.model.GridTab;
|
import org.compiere.model.GridTab;
|
||||||
|
@ -30,13 +31,16 @@ public class GridSynchronizer implements PropertyChangeListener, StateChangeList
|
||||||
|
|
||||||
private GridController parent;
|
private GridController parent;
|
||||||
private GridController child;
|
private GridController child;
|
||||||
|
private GridWindow window;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
* @param window
|
||||||
* @param parent
|
* @param parent
|
||||||
* @param child
|
* @param child
|
||||||
*/
|
*/
|
||||||
public GridSynchronizer(GridController parent, GridController child) {
|
public GridSynchronizer(GridWindow window, GridController parent, GridController child) {
|
||||||
|
this.window = window;
|
||||||
this.parent = parent;
|
this.parent = parent;
|
||||||
this.child = child;
|
this.child = child;
|
||||||
|
|
||||||
|
@ -70,4 +74,12 @@ public class GridSynchronizer implements PropertyChangeListener, StateChangeList
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* trigger when parent gc activate
|
||||||
|
*/
|
||||||
|
public void activateChild() {
|
||||||
|
window.initTab(window.getTabIndex(child.getMTab()));
|
||||||
|
child.activate();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,6 +26,7 @@ import java.util.*;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
//
|
//
|
||||||
import org.adempiere.plaf.AdempierePLAF;
|
import org.adempiere.plaf.AdempierePLAF;
|
||||||
|
import org.compiere.apps.APanel;
|
||||||
import org.compiere.grid.ed.*;
|
import org.compiere.grid.ed.*;
|
||||||
import org.compiere.model.*;
|
import org.compiere.model.*;
|
||||||
import org.compiere.swing.*;
|
import org.compiere.swing.*;
|
||||||
|
@ -63,11 +64,22 @@ import org.jdesktop.swingx.border.DropShadowBorder;
|
||||||
public final class VPanel extends CTabbedPane
|
public final class VPanel extends CTabbedPane
|
||||||
{
|
{
|
||||||
|
|
||||||
/**
|
private int m_WindowNo;
|
||||||
* Constructor
|
|
||||||
*/
|
public VPanel(String Name)
|
||||||
public VPanel(String Name)
|
|
||||||
{
|
{
|
||||||
|
this(Name, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param Name
|
||||||
|
* @param WindowNo
|
||||||
|
*/
|
||||||
|
public VPanel(String Name, int WindowNo)
|
||||||
|
{
|
||||||
|
m_WindowNo = WindowNo;
|
||||||
|
|
||||||
//set up map used for label and field alignment
|
//set up map used for label and field alignment
|
||||||
labels.put(0, new ArrayList<CLabel>());
|
labels.put(0, new ArrayList<CLabel>());
|
||||||
labels.put(2, new ArrayList<CLabel>());
|
labels.put(2, new ArrayList<CLabel>());
|
||||||
|
@ -196,11 +208,17 @@ public final class VPanel extends CTabbedPane
|
||||||
m_gbc.gridy = m_line++;
|
m_gbc.gridy = m_line++;
|
||||||
m_gbc.gridwidth = 5;
|
m_gbc.gridwidth = 5;
|
||||||
m_gbc.fill = GridBagConstraints.HORIZONTAL;
|
m_gbc.fill = GridBagConstraints.HORIZONTAL;
|
||||||
m_gbc.weightx = 1;
|
m_gbc.weightx = 1;
|
||||||
m_gbc.ipadx = 0;
|
m_gbc.ipadx = 0;
|
||||||
m_main.add(m_tab,m_gbc);
|
m_main.add(m_tab,m_gbc);
|
||||||
|
|
||||||
|
if (includedTabList.containsKey(AD_Tab_ID))
|
||||||
|
{
|
||||||
|
includeTab(includedTabList.get(AD_Tab_ID));
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
CLabel label = VEditorFactory.getLabel(mField);
|
CLabel label = VEditorFactory.getLabel(mField);
|
||||||
if (label == null && editor == null)
|
if (label == null && editor == null)
|
||||||
return;
|
return;
|
||||||
|
@ -742,6 +760,8 @@ public final class VPanel extends CTabbedPane
|
||||||
private ArrayList<Character> m_mnemonics = new ArrayList<Character>(30);
|
private ArrayList<Character> m_mnemonics = new ArrayList<Character>(30);
|
||||||
/** Mnemonic Fields */
|
/** Mnemonic Fields */
|
||||||
private ArrayList<Component> m_fields = new ArrayList<Component>(30);
|
private ArrayList<Component> m_fields = new ArrayList<Component>(30);
|
||||||
|
|
||||||
|
private HashMap<Integer, GridController> includedTabList = new HashMap<Integer, GridController>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set Window level Mnemonics
|
* Set Window level Mnemonics
|
||||||
|
@ -788,11 +808,6 @@ public final class VPanel extends CTabbedPane
|
||||||
{
|
{
|
||||||
} // setBackground
|
} // setBackground
|
||||||
|
|
||||||
//[ 1757088 ]
|
|
||||||
public CollapsiblePanel getIncludedSection(int AD_Tab_ID)
|
|
||||||
{
|
|
||||||
return (CollapsiblePanel)m_tabincludelist.get(AD_Tab_ID);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void findChildComponents(CPanel container, List list)
|
private void findChildComponents(CPanel container, List list)
|
||||||
{
|
{
|
||||||
|
@ -971,5 +986,25 @@ public final class VPanel extends CTabbedPane
|
||||||
super.doLayout();
|
super.doLayout();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param detail
|
||||||
|
*/
|
||||||
|
public void includeTab(GridController detail) {
|
||||||
|
CollapsiblePanel section = (CollapsiblePanel)m_tabincludelist.get(detail.getMTab().getAD_Tab_ID());
|
||||||
|
if(section != null)
|
||||||
|
{
|
||||||
|
APanel panel = new APanel(detail, m_WindowNo);
|
||||||
|
String name = detail.getMTab().getName() + "";
|
||||||
|
section.setTitle(name);
|
||||||
|
section.getCollapsiblePane().getContentPane().setLayout(new BorderLayout());
|
||||||
|
section.getCollapsiblePane().getContentPane().add(panel, BorderLayout.CENTER);
|
||||||
|
}
|
||||||
|
|
||||||
|
//this can be call before addField
|
||||||
|
if (!includedTabList.containsKey(detail.getMTab().getAD_Tab_ID()))
|
||||||
|
includedTabList.put(detail.getMTab().getAD_Tab_ID(), detail);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
} // VPanel
|
} // VPanel
|
Loading…
Reference in New Issue