* Added shadowborder from jgoodies demo

* Facelift for AMenu and VTreePanel
* Facelift for Preference dialog
- Pending messages and rework of theme selection.
- Please email me or post in SF if you don't like the changes.
This commit is contained in:
Heng Sin Low 2006-11-24 08:05:36 +00:00
parent 87ac3d85ba
commit ac6ce4b999
3 changed files with 149 additions and 63 deletions

View File

@ -35,7 +35,6 @@ import org.compiere.grid.tree.*;
import org.compiere.model.*;
import org.compiere.swing.*;
import org.compiere.util.*;
/**
* Application Menu Controller
*
@ -272,6 +271,7 @@ public final class AMenu extends CFrame
m_tabActivities++;
m_tabWorkflow++;
}
treePanel.setBorder(BorderFactory.createEmptyBorder(2,3,2,3));
centerPane.add(treePanel, Msg.getMsg(m_ctx, "Menu"));
centerPane.add(new CScrollPane(wfActivity), Msg.getMsg (m_ctx, "WorkflowActivities") + ": 0");
centerPane.add(new CScrollPane(wfPanel), Msg.getMsg (m_ctx, "WorkflowPanel"));

View File

@ -22,6 +22,7 @@ import java.io.*;
import java.util.*;
import java.util.logging.*;
import javax.swing.*;
import javax.swing.border.Border;
import javax.swing.event.*;
import javax.swing.table.*;
//
@ -126,6 +127,8 @@ public final class Preference extends CDialog
private CButton bErrorSave = new CButton(Msg.getMsg(Env.getCtx(), "SaveFile"));
private CButton bRoleInfo = new CButton(Msg.translate(Env.getCtx(), "AD_Role_ID"));
private CPanel configPanel = new CPanel();
/**
* Static Init.
* <pre>
@ -193,64 +196,96 @@ public final class Preference extends CDialog
// tabPane.add(customizePane, Msg.getMsg(Env.getCtx(), "Preference"));
tabPane.add(customizePane, Msg.getMsg(Env.getCtx(), "Preference"));
customizePane.setLayout(customizeLayout);
customizePane.add(infoArea, new GridBagConstraints(0, 0, 3, 1, 0.0, 0.0
,GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(5, 5, 5, 5), 0, 0));
customizePane.add(uiTheme, new GridBagConstraints(1, 1, 1, 1, 0.0, 0.0
,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0));
customizePane.add(bRoleInfo, new GridBagConstraints(2, 1, 1, 1, 0.0, 0.0
,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0));
customizePane.add(autoCommit, new GridBagConstraints(1, 2, 1, 1, 0.0, 0.0
,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0));
customizePane.add(adempiereSys, new GridBagConstraints(2, 2, 1, 1, 0.0, 0.0
,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0));
customizePane.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
customizePane.add(autoLogin, new GridBagConstraints(1, 3, 1, 1, 0.0, 0.0
,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0));
customizePane.add(storePassword, new GridBagConstraints(2, 3, 1, 1, 0.0, 0.0
,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0));
Border insetBorder = BorderFactory.createEmptyBorder(2, 2, 2, 0);
CPanel loginPanel = new CPanel();
loginPanel.setBorder(BorderFactory.createTitledBorder("Login"));
loginPanel.setLayout(new GridLayout(1, 2));
autoLogin.setBorder(insetBorder);
storePassword.setBorder(insetBorder);
loginPanel.add(autoLogin);
loginPanel.add(storePassword);
customizePane.add(loginPanel, new GridBagConstraints(0, 0, 1, 1, 1.0, 0.0
,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(2, 0, 2, 0), 0, 0));
customizePane.add(showAcct, new GridBagConstraints(1, 4, 1, 1, 0.0, 0.0
,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0));
customizePane.add(showTrl, new GridBagConstraints(2, 4, 1, 1, 0.0, 0.0
,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0));
CPanel windowPanel = new CPanel();
windowPanel.setBorder(BorderFactory.createTitledBorder("Window"));
windowPanel.setLayout(new GridLayout(4, 2));
windowPanel.add(showAcct);showAcct.setBorder(insetBorder);
windowPanel.add(showTrl);showTrl.setBorder(insetBorder);
windowPanel.add(showAdvanced);showAdvanced.setBorder(insetBorder);
windowPanel.add(autoCommit);autoCommit.setBorder(insetBorder);
windowPanel.add(autoNew);autoNew.setBorder(insetBorder);
windowPanel.add(cacheWindow);cacheWindow.setBorder(insetBorder);
windowPanel.add(openWindowMaximized);openWindowMaximized.setBorder(insetBorder);
windowPanel.add(singleInstancePerWindow);singleInstancePerWindow.setBorder(insetBorder);
customizePane.add(windowPanel, new GridBagConstraints(0, 1, 1, 1, 1.0, 0.0
,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(2, 0, 2, 0), 0, 0));
customizePane.add(showAdvanced, new GridBagConstraints(1, 5, 1, 1, 0.0, 0.0
,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0));
customizePane.add(autoNew, new GridBagConstraints(2, 5, 1, 1, 0.0, 0.0
,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0));
CPanel connPanel = new CPanel();
connPanel.setBorder(BorderFactory.createTitledBorder("Connection"));
connPanel.setLayout(new GridBagLayout());
connPanel.add(connectionProfileLabel, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0
,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(2, 2, 2, 0), 0, 0));
connPanel.add(connectionProfile, new GridBagConstraints(1, 0, 1, 1, 1.0, 0.0
,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(2, 2, 2, 0), 0, 0));
connPanel.add(validateConnectionOnStartup, new GridBagConstraints(0, 1, 2, 1, 1.0, 0.0
,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(2, 2, 2, 0), 0, 0));
customizePane.add(connPanel, new GridBagConstraints(0, 2, 1, 1, 1.0, 0.0
,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(2, 0, 2, 0), 0, 0));
customizePane.add(connectionProfileLabel, new GridBagConstraints(0, 6, 1, 1, 0.0, 0.0
,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0));
customizePane.add(connectionProfile, new GridBagConstraints(1, 6, 1, 1, 0.0, 0.0
,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0));
customizePane.add(cacheWindow, new GridBagConstraints(2, 6, 1, 1, 0.0, 0.0
,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0));
customizePane.add(traceLabel, new GridBagConstraints(0, 7, 1, 1, 0.0, 0.0
,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 5, 5), 0, 0));
customizePane.add(traceLevel, new GridBagConstraints(1, 7, 1, 1, 0.0, 0.0
,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0));
customizePane.add(traceFile, new GridBagConstraints(2, 7, 1, 1, 0.0, 0.0
,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0));
CPanel tracePanel = new CPanel();
tracePanel.setBorder(BorderFactory.createTitledBorder("Trace"));
tracePanel.setLayout(new GridBagLayout());
tracePanel.add(traceLabel, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0
,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(2, 2, 2, 0), 0, 0));
tracePanel.add(traceLevel, new GridBagConstraints(1, 0, 1, 1, 1.0, 0.0
,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(2, 2, 2, 0), 0, 0));
tracePanel.add(traceFile, new GridBagConstraints(0, 1, 2, 1, 1.0, 0.0
,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(2, 2, 2, 0), 0, 0));
customizePane.add(tracePanel, new GridBagConstraints(0, 3, 1, 1, 1.0, 0.0
,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(2, 0, 2, 0), 0, 0));
customizePane.add(lPrinter, new GridBagConstraints(0, 8, 1, 1, 0.0, 0.0
,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0));
customizePane.add(fPrinter, new GridBagConstraints(1, 8, 2, 1, 0.0, 0.0
,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0));
CPanel printPanel = new CPanel();
printPanel.setBorder(BorderFactory.createTitledBorder("Printing"));
printPanel.setLayout(new GridBagLayout());
printPanel.add(lPrinter, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0
,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(2, 2, 2, 0), 0, 0));
printPanel.add(fPrinter, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0
,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(2, 2, 2, 0), 0, 0));
printPanel.add(printPreview, new GridBagConstraints(0, 1, 2, 1, 1.0, 0.0
,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(2, 2, 2, 0), 0, 0));
customizePane.add(printPanel, new GridBagConstraints(0, 4, 1, 1, 1.0, 0.0
,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(2, 0, 2, 0), 0, 0));
CPanel otherPanel = new CPanel();
otherPanel.setBorder(BorderFactory.createEmptyBorder());
otherPanel.setLayout(new GridLayout());
CPanel datePanel = new CPanel();
datePanel.setLayout(new FlowLayout());
((FlowLayout)datePanel.getLayout()).setAlignment(FlowLayout.LEFT);
datePanel.add(lDate);
datePanel.add(fDate);
otherPanel.add(datePanel);datePanel.setBorder(insetBorder);
otherPanel.add(adempiereSys);adempiereSys.setBorder(insetBorder);
customizePane.add(otherPanel, new GridBagConstraints(0, 5, 1, 1, 1.0, 0.0
,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(2, 0, 2, 0), 0, 0));
CPanel themePanel = new CPanel();
themePanel.add(uiTheme);
//TODO
tabPane.add(themePanel, uiTheme.getText());
configPanel.setLayout(new BorderLayout());
configPanel.add(infoArea, BorderLayout.CENTER);
CPanel configSouth = new CPanel();
configSouth.setLayout(new FlowLayout());
((FlowLayout)configSouth.getLayout()).setAlignment(FlowLayout.RIGHT);
configSouth.add(bRoleInfo);
configPanel.add(configSouth, BorderLayout.SOUTH);
tabPane.add(configPanel, "Info");
customizePane.add(lDate, new GridBagConstraints(0, 9, 1, 1, 0.0, 0.0
,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0));
customizePane.add(fDate, new GridBagConstraints(1, 9, 2, 1, 0.0, 0.0
,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0));
customizePane.add(printPreview, new GridBagConstraints(2, 9, 1, 1, 0.0, 0.0
,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0));
customizePane.add(validateConnectionOnStartup, new GridBagConstraints(1, 10, 1, 1, 0.0, 0.0
,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0));
customizePane.add(singleInstancePerWindow, new GridBagConstraints(2, 10, 1, 1, 0.0, 0.0
,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0));
customizePane.add(openWindowMaximized, new GridBagConstraints(1, 11, 1, 1, 0.0, 0.0
,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0));
// Info
// tabPane.add(contextPane, Msg.getMsg(Env.getCtx(), "Context"));
tabPane.add(contextPane, Msg.getMsg(Env.getCtx(), "Context"));
@ -519,9 +554,9 @@ public final class Preference extends CDialog
errorTable.setModel(model);
//
if (bErrorsOnly.isSelected())
tabPane.setTitleAt(2, Msg.getMsg(Env.getCtx(), "Errors") + " (" + data.size() + ")");
tabPane.setTitleAt(4, Msg.getMsg(Env.getCtx(), "Errors") + " (" + data.size() + ")");
else
tabPane.setTitleAt(2, Msg.getMsg(Env.getCtx(), "TraceInfo") + " (" + data.size() + ")");
tabPane.setTitleAt(4, Msg.getMsg(Env.getCtx(), "TraceInfo") + " (" + data.size() + ")");
errorTable.autoSize();
} // cmd_errorsOnly

View File

@ -16,14 +16,19 @@
*****************************************************************************/
package org.compiere.grid.tree;
import java.awt.*;
import java.awt.datatransfer.*;
import java.awt.dnd.*;
import java.awt.event.*;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.sql.*;
import java.util.*;
import java.util.logging.*;
import javax.swing.*;
import javax.swing.plaf.SplitPaneUI;
import javax.swing.plaf.basic.BasicSplitPaneUI;
import javax.swing.tree.*;
import org.compiere.apps.*;
import org.compiere.model.*;
@ -49,6 +54,8 @@ import org.compiere.util.*;
public final class VTreePanel extends CPanel
implements ActionListener, DragGestureListener, DragSourceListener, DropTargetListener
{
protected boolean m_lookAndFeelChanged = false;
/**
* Tree Panel for browsing and editing of a tree.
* Need to call initTree
@ -73,8 +80,16 @@ public final class VTreePanel extends CPanel
centerSplitPane.setDividerSize(0);
popMenuTree.remove(mBarAdd);
}
else
else {
centerSplitPane.setDividerLocation(80);
UIManager.addPropertyChangeListener(new PropertyChangeListener() {
public void propertyChange(PropertyChangeEvent evt) {
if ("lookAndFeel".equals(evt.getPropertyName()))
m_lookAndFeelChanged = true;
}
});
}
// base settings
if (editable)
tree.setDropTarget(dropTarget);
@ -108,7 +123,7 @@ public final class VTreePanel extends CPanel
// Shortcut Bar
if (m_hasBar)
{
bar.removeAll(); // remove all existing buttons
toolbar.removeAll(); // remove all existing buttons
Enumeration en = m_root.preorderEnumeration();
while (en.hasMoreElements())
{
@ -137,6 +152,7 @@ public final class VTreePanel extends CPanel
private CMenuItem mFrom = new CMenuItem();
private CMenuItem mTo = new CMenuItem();
private CPanel bar = new CPanel();
private JToolBar toolbar = new JToolBar(JToolBar.VERTICAL);
private CMenuItem mBarAdd = new CMenuItem();
private CMenuItem mBarRemove = new CMenuItem();
private BorderLayout southLayout = new BorderLayout();
@ -192,6 +208,8 @@ public final class VTreePanel extends CPanel
tree.addKeyListener(keyListener);
tree.setCellRenderer(new VTreeCellRenderer());
treePane.getViewport().add(tree, null);
treePane.setBorder(new ShadowBorder());
tree.setBorder(BorderFactory.createEmptyBorder());
// treePane.setPreferredSize(new Dimension(50,200));
// tree.setPreferredSize(new Dimension(100,150));
//
@ -214,6 +232,9 @@ public final class VTreePanel extends CPanel
//
centerSplitPane.add(treePane, JSplitPane.RIGHT);
centerSplitPane.add(bar, JSplitPane.LEFT);
centerSplitPane.setBorder(BorderFactory.createEmptyBorder());
removeSplitPaneBorder();
this.add(centerSplitPane, BorderLayout.CENTER);
//
mFrom.setText(Msg.getMsg(Env.getCtx(), "ItemMove"));
@ -224,8 +245,15 @@ public final class VTreePanel extends CPanel
mTo.setActionCommand("To");
mTo.addActionListener(this);
//
bar.setLayout(new BoxLayout(bar, BoxLayout.Y_AXIS));
bar.setMinimumSize(new Dimension (50,50));
bar.setBorder(new ShadowBorder());
bar.setLayout(new FlowLayout());
((FlowLayout)bar.getLayout()).setAlignment(FlowLayout.LEFT);
bar.add(toolbar);
toolbar.setLayout(new GridBagLayout());
toolbar.setFloatable(false);
toolbar.setRollover(true);
toolbar.setBorder(BorderFactory.createEmptyBorder());
mBarAdd.setText(Msg.getMsg(Env.getCtx(), "BarAdd"));
mBarAdd.setActionCommand("BarAdd");
@ -244,6 +272,16 @@ public final class VTreePanel extends CPanel
} // jbInit
private void removeSplitPaneBorder() {
if (centerSplitPane != null) {
SplitPaneUI splitPaneUI = centerSplitPane.getUI();
if (splitPaneUI instanceof BasicSplitPaneUI) {
BasicSplitPaneUI basicUI = (BasicSplitPaneUI) splitPaneUI;
basicUI.getDivider().setBorder(BorderFactory.createEmptyBorder());
}
}
}
/**
* Set Divider Location
* @param location location (80 default)
@ -832,21 +870,25 @@ public final class VTreePanel extends CPanel
// if (space != -1)
// label = label.substring(0, space);
CButton button = new CButton(label); // Create the button
CButton button = new CButton(label);
button.setHorizontalAlignment(JButton.LEFT);
button.setToolTipText(nd.getDescription());
button.setActionCommand(String.valueOf(nd.getNode_ID()));
//
button.setMargin(new Insets(0, 0, 0, 0));
button.setIcon(nd.getIcon());
button.setBorderPainted(false);
// button.setFocusPainted(false);
//button.setBorderPainted(false);
button.setRequestFocusEnabled(false);
//
button.addActionListener(this);
button.addMouseListener(mouseListener);
//
bar.add(button);
toolbar.add(button,
new GridBagConstraints(0, GridBagConstraints.RELATIVE,
1, 1, 1.0, 0.0, GridBagConstraints.NORTHWEST,
GridBagConstraints.HORIZONTAL, new Insets(1,0,1,0), 4,2));
bar.validate();
if (centerSplitPane.getDividerLocation() == -1)
centerSplitPane.setDividerLocation(button.getPreferredSize().width);
bar.repaint();
@ -857,7 +899,7 @@ public final class VTreePanel extends CPanel
*/
private void barRemove()
{
bar.remove(m_buttonSelected);
toolbar.remove(m_buttonSelected);
bar.validate();
bar.repaint();
barDBupdate(false, Integer.parseInt(m_buttonSelected.getActionCommand()));
@ -910,6 +952,15 @@ public final class VTreePanel extends CPanel
}
} // expandTree
@Override
public void paint(Graphics g) {
if (m_lookAndFeelChanged) {
m_lookAndFeelChanged = false;
if (m_hasBar) removeSplitPaneBorder();
}
super.paint(g);
}
} // VTreePanel