📄 compiereplafeditor.java
字号:
jPanel1.add(jToggleButton1, new GridBagConstraints(2, 1, 1, 1, 0.0, 0.1
,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0));
jPanel1.add(jTextArea1, new GridBagConstraints(0, 3, 1, 1, 0.0, 0.2
,GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(5, 5, 5, 5), 0, 0));
jPanel1.add(jComboBox1, new GridBagConstraints(0, 2, 1, 1, 0.0, 0.0
,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0));
jPanel1.add(jPasswordField1, new GridBagConstraints(2, 2, 1, 1, 0.0, 0.0
,GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5), 0, 0));
example.add(jPanel2, "JPanel");
jPanel2.add(jSplitPane1, BorderLayout.CENTER);
jSplitPane1.add(jScrollPane1, JSplitPane.LEFT);
jSplitPane1.add(jScrollPane2, JSplitPane.RIGHT);
jPanelFlat.setName("FlatP");
jPanelGradient.setName("GradientP");
jPanelTexture.setName("TextureP");
jPanelLines.setName("LineP");
example.add(jPanelFlat, "jPanel Flat");
jPanelFlat.add(jButtonFlat, null);
jPanelFlat.add(jComboBoxFlat, null);
example.add(jPanelGradient, "jPanel Gradient 1");
jPanelGradient.add(jButtonGardient, null);
jPanelGradient.add(jComboBoxGradient, null);
jPanelGradient.add(jLabelGradient, null);
jPanelGradient.add(jTextFieldGradient, null);
example.add(jPanelTexture, "jPanel Texture 2");
jPanelTexture.add(jButtonTexture, null);
jPanelTexture.add(jComboBoxTexture, null);
jPanelTexture.add(jLabelTexture, null);
jPanelTexture.add(jTextFieldTexture, null);
example.add(jPanelLines, "jPanel Lines 1");
jPanelLines.add(jButtonLines, null);
jPanelLines.add(jComboBoxLines, null);
jPanelLines.add(jLabelLines, null);
jPanelLines.add(jTextFieldLines, null);
jScrollPane2.getViewport().add(jTable1, null);
jScrollPane1.getViewport().add(jTree1, null);
jPanelFlat.add(jLabelFlat, null);
jPanelFlat.add(jTextFieldFlat, null);
jPanelLines.add(jCheckBoxLines, null);
jPanelTexture.add(jCheckBoxTexture, null);
jPanelGradient.add(jCheckBoxGradient, null);
jPanelFlat.add(jCheckBoxFlat, null);
} // jbInit
/**
* Dynamic Init
*/
private void dynInit()
{
setLFSelection();
//
jPanelGradient.setTabLevel(1);
jPanelTexture.setTabLevel(2);
jPanelLines.setTabLevel(1);
//
jComboBoxFlat.addActionListener(this);
jComboBoxGradient.addActionListener(this);
jComboBoxTexture.addActionListener(this);
jComboBoxLines.addActionListener(this);
//
jButton1.addActionListener(this);
jButtonFlat.addActionListener(this);
jButtonGardient.addActionListener(this);
jButtonTexture.addActionListener(this);
jButtonLines.addActionListener(this);
//
CompierePLAF.setPLAF(this);
} // dynInit
/**
* Set Picks From Environment
*/
private void setLFSelection()
{
m_setting = true;
// Search for PLAF
ValueNamePair plaf = null;
LookAndFeel lookFeel = UIManager.getLookAndFeel();
String look = lookFeel.getClass().getName();
for (int i = 0; i < CompierePLAF.getPLAFs().length; i++)
{
ValueNamePair vp = CompierePLAF.getPLAFs()[i];
if (vp.getValue().equals(look))
{
plaf = vp;
break;
}
}
if (plaf != null)
lfField.setSelectedItem(plaf);
// Search for Theme
MetalTheme t = null;
ValueNamePair theme = null;
boolean metal = UIManager.getLookAndFeel() instanceof MetalLookAndFeel;
themeField.setModel(new DefaultComboBoxModel(CompierePLAF.getThemes()));
if (metal)
{
theme = null;
AppContext context = AppContext.getAppContext();
t = (MetalTheme)context.get("currentMetalTheme");
if (t != null)
{
String lookTheme = t.getName();
for (int i = 0; i < CompierePLAF.getThemes().length; i++)
{
ValueNamePair vp = CompierePLAF.getThemes()[i];
if (vp.getName().equals(lookTheme))
{
theme = vp;
break;
}
}
}
if (theme != null)
themeField.setSelectedItem(theme);
else
themeField.setSelectedIndex(0);
}
m_setting = false;
// System.out.println("CompierePLAFEditor.setLFSelection - " + lookFeel.getName() + "=" + plaf + " - " + t.getName() + "=" + theme);
} // setLFSelection
/*************************************************************************/
/**
* ActionListener
* @param e
*/
public void actionPerformed(ActionEvent e)
{
setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
// OK - Save & Finish
if (e.getSource() == bOK)
{
Ini.saveProperties(true);
dispose();
}
// Cancel - Finish
else if (e.getSource() == bCancel)
{
dispose();
}
else if (e.getSource() == bHelp)
{
new MiniBrowser("http://www.compiere.org/looks/help.html");
}
// Look & Feel changed
else if (e.getSource() == lfField && !m_setting)
{
m_setting = true; // disable Theme setting
// set new theme
CompierePLAF.setPLAF((ValueNamePair)lfField.getSelectedItem(), null, this);
setLFSelection();
setBackgroundToTheme();
CompierePLAF.setPLAF(this); // twice ??
m_setting = false; // enable Theme setting
}
// Theme Field Changed
else if (e.getSource() == themeField && !m_setting)
{
Ini.setProperty(Ini.P_UI_THEME, themeField.getSelectedItem().toString());
CompierePLAF.setPLAF((ValueNamePair)lfField.getSelectedItem(), (ValueNamePair)themeField.getSelectedItem(), this);
CompiereTheme.setTheme(); // copy Theme
setBackgroundToTheme();
CompierePLAF.setPLAF(this); // twice (??)
}
// Start Compiere Theme Editor
else if (e.getSource() == cButton)
{
new CompiereThemeEditor(this);
setBackgroundToTheme();
}
// Reset PLAFs
else if (e.getSource() == rButton)
{
CompierePLAF.reset(this);
setLFSelection();
ColorBlind.setColorType(ColorBlind.NORMAL);
CompierePLAF.setPLAF(this); // twice ??
}
// Set Default Background Color
else if (e.getSource() == bSetColor)
{
CompiereColor cc = CompiereColorEditor.showDialog(this, CompierePanelUI.getDefaultBackground());
CompierePanelUI.setDefaultBackground(cc);
CompierePLAF.updateUI(this);
Ini.setProperty(CompiereTheme.P_CompiereColor, cc.toString());
}
// Set Background as Default
else if (e.getSource() == cDefault)
{
CompierePanelUI.setSetDefault(cDefault.isSelected());
CompierePLAF.updateUI(this);
}
// ColorBlind
else if (e.getSource() == blindField)
{
int sel = blindField.getSelectedIndex();
if (sel != ColorBlind.getColorType())
{
// Test for True color
if (!m_colorTest)
{
m_colorTest = true;
int size = Toolkit.getDefaultToolkit().getColorModel().getPixelSize();
if (size < 24)
JOptionPane.showMessageDialog(this,
"Your environment has only a pixel size of " + size
+ ".\nTo see the effect, you need to have a pixel size of 24 (true color)",
"Insufficient Color Capabilities",
JOptionPane.ERROR_MESSAGE);
}
ColorBlind.setColorType(sel);
CompierePLAF.updateUI(this);
CompierePLAF.setPLAF(this); // twice (??)
}
}
// Change Tab Pacement
else if (e.getSource() == jComboBoxFlat || e.getSource() == jComboBoxGradient
|| e.getSource() == jComboBoxTexture || e.getSource() == jComboBoxLines)
{
if (!m_setting)
{
m_setting = true;
int index = ((JComboBox)e.getSource()).getSelectedIndex();
example.setTabPlacement(index+1);
jComboBoxFlat.setSelectedIndex(index);
jComboBoxGradient.setSelectedIndex(index);
jComboBoxTexture.setSelectedIndex(index);
jComboBoxLines.setSelectedIndex(index);
m_setting = false;
}
}
// Display Options
else if (e.getSource() == jButtonFlat)
JOptionPane.showConfirmDialog(this, "Confirm Dialog");
else if (e.getSource() == jButtonGardient)
JOptionPane.showInputDialog(this, "Input Dialog");
else if (e.getSource() == jButtonTexture)
JOptionPane.showMessageDialog(this, "Message Dialog");
else if (e.getSource() == jButtonLines)
JOptionPane.showMessageDialog(this, "Message Dialog - Error", "Error", JOptionPane.ERROR_MESSAGE);
// Test
else if (e.getSource() == jButton1)
{
}
/********************/
// Metal
boolean metal = UIManager.getLookAndFeel() instanceof MetalLookAndFeel;
themeField.setEnabled(metal);
themeLabel.setEnabled(metal);
// ColorBlind - only with Compiere L&F & Theme
boolean enable = metal
&& CompiereLookAndFeel.NAME.equals(lfField.getSelectedItem().toString())
&& themeField.getSelectedItem() != null
&& CompiereTheme.NAME.equals(themeField.getSelectedItem().toString());
blindField.setEnabled(enable);
blindLabel.setEnabled(enable);
if (e.getSource() != blindField && !enable)
blindField.setSelectedIndex(0);
// done
setCursor(Cursor.getDefaultCursor());
} // actionPerformed
/**
* Set CompiereColor Background to Theme Background
*/
private void setBackgroundToTheme()
{
// Not flat for Compiere L&F & Theme
boolean notFlat = UIManager.getLookAndFeel() instanceof MetalLookAndFeel
&& CompiereLookAndFeel.NAME.equals(lfField.getSelectedItem().toString())
&& themeField.getSelectedItem() != null
&& CompiereTheme.NAME.equals(themeField.getSelectedItem().toString());
CompiereColor cc = new CompiereColor(CompiereTheme.secondary3, !notFlat);
CompierePanelUI.setDefaultBackground(cc);
Ini.setProperty(CompiereTheme.P_CompiereColor, cc.toString());
CompierePLAF.updateUI(this);
} // setBackgroundToTheme
/**
* Dispose
* Exit, if there is no real owning parent (not modal) - shortcut
*/
public void dispose()
{
super.dispose();
if (!isModal())
System.exit(0);
} // dispose
} // CompierePLAFEditor
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -