use of java.awt.Container in project adempiere by adempiere.
the class Env method reset.
/**
* Reset Cache
* @param finalCall everything otherwise login data remains
*/
public static void reset(boolean finalCall) {
s_log.info("finalCall=" + finalCall);
if (Ini.isClient()) {
closeWindows();
//bug [ 1574630 ]
if (s_windows.size() > 0) {
if (!finalCall) {
Container c = s_windows.get(0);
s_windows.clear();
createWindowNo(c);
} else {
s_windows.clear();
}
}
}
// Clear all Context
if (finalCall)
getCtx().clear();
else // clear window context only
{
Object[] keys = getCtx().keySet().toArray();
for (int i = 0; i < keys.length; i++) {
String tag = keys[i].toString();
if (Character.isDigit(tag.charAt(0)))
getCtx().remove(keys[i]);
}
}
// Cache
CacheMgt.get().reset();
if (Ini.isClient())
DB.closeTarget();
// Reset Role Access
if (!finalCall) {
if (Ini.isClient())
DB.setDBTarget(CConnection.get());
MRole defaultRole = MRole.getDefault(getCtx(), false);
if (defaultRole != null)
// Reload
defaultRole.loadAccess(true);
}
}
use of java.awt.Container in project adempiere by adempiere.
the class Env method updateUI.
// sleep
/**
* Update all windows after look and feel changes.
* @since 2006-11-27
*/
public static Set<Window> updateUI() {
Set<Window> updated = new HashSet<Window>();
for (Container c : s_windows) {
Window w = getFrame(c);
if (w == null)
continue;
if (updated.contains(w))
continue;
SwingUtilities.updateComponentTreeUI(w);
w.validate();
RepaintManager mgr = RepaintManager.currentManager(w);
Component[] childs = w.getComponents();
for (Component child : childs) {
if (child instanceof JComponent)
mgr.markCompletelyDirty((JComponent) child);
}
w.repaint();
updated.add(w);
}
for (Window w : s_hiddenWindows) {
if (updated.contains(w))
continue;
SwingUtilities.updateComponentTreeUI(w);
w.validate();
RepaintManager mgr = RepaintManager.currentManager(w);
Component[] childs = w.getComponents();
for (Component child : childs) {
if (child instanceof JComponent)
mgr.markCompletelyDirty((JComponent) child);
}
w.repaint();
updated.add(w);
}
return updated;
}
use of java.awt.Container in project adempiere by adempiere.
the class Env method getGraphics.
// getFrame
/**
* Get Graphics of container or its parent.
* The element may not have a Graphic if not displayed yet,
* but the parent might have.
* @param container Container
* @return Graphics of container or null
*/
public static Graphics getGraphics(Container container) {
Container element = container;
while (element != null) {
Graphics g = element.getGraphics();
if (g != null)
return g;
element = element.getParent();
}
return null;
}
use of java.awt.Container in project adempiere by adempiere.
the class HelpAbout method createAndShowGui.
// METHODS
// =======
/**
* Create the GUI and show it
* @param component the calling component
*/
@SuppressWarnings("unchecked")
public void createAndShowGui(Component component) {
// title
setTitle(s_logger.localizeMessage("guiAboutTitle"));
// load icons
ArrayList<Image> images = new ArrayList<Image>();
images.add(getImage("AD16.png"));
images.add(getImage("AD32.png"));
setIconImages(images);
// content pane
Container pane = getContentPane();
Locale locale = Locale.getDefault();
pane.setComponentOrientation(ComponentOrientation.getOrientation(locale));
pane.setLayout(new GridBagLayout());
m_rowCounter = 0;
// logo
JLabel logo = new JLabel(new ImageIcon(getImage("ADempiere.png")));
// heading
JLabel label = new JLabel(s_logger.localizeMessage("guiAboutHeading"));
label.setFont(new Font("Dialog", Font.BOLD, 14));
pane.add(label, getHeadingConstraints());
// display additional information if we are running in an Adempiere environment
try {
Class ademp = Class.forName("org.compiere.Adempiere", false, this.getClass().getClassLoader());
// Adempiere Logo image & subtitle
logo.setIcon(new ImageIcon(getImage("AD10030.png")));
Field subtitle = ademp.getField("SUB_TITLE");
logo.setText(subtitle.get(null).toString());
logo.setHorizontalTextPosition(SwingConstants.CENTER);
logo.setVerticalTextPosition(SwingConstants.BOTTOM);
logo.setFont(new Font("Serif", Font.ITALIC, 10));
logo.setForeground(Color.BLUE);
// Adempiere version
Field mainVersion = ademp.getField("MAIN_VERSION");
Field dateVersion = ademp.getField("DATE_VERSION");
String versionString = new StringBuffer(mainVersion.get(null).toString()).append(" @ ").append(dateVersion.get(null).toString()).toString();
label = new JLabel(versionString);
pane.add(label, getVersionConstraints());
// Adempiere Copyright
Field copyright = ademp.getField("COPYRIGHT");
label = new JLabel(copyright.get(null).toString());
pane.add(label, getAdempCprConstraints());
// Adempiere URL
Field url = ademp.getField("URL");
label = new JLabel(url.get(null).toString());
label.setForeground(Color.BLUE);
pane.add(label, getUrlConstraints());
} catch (Exception e) {
// do nothing if any error occurs trying to access Adempiere class
}
// add logo to pane
// (constraints depend on how many rows were added by above Adempiere information)
pane.add(logo, getLogoConstraints());
// program title
label = new JLabel(s_logger.localizeMessage("guiWindowTitle"));
label.setFont(new Font("DIALOG", Font.BOLD, 18));
label.setForeground(Color.RED);
pane.add(label, getTitleConstraints());
// program description
label = new JLabel(s_logger.localizeMessage("guiWindowDescription"));
label.setFont(new Font("Dialog", Font.ITALIC, 12));
pane.add(label, getDescrConstraints());
//copyright
JTextArea text = new JTextArea(s_logger.localizeMessage("copyright"));
text.setFont(new Font("Dialog", Font.PLAIN, 10));
text.setBackground(label.getBackground());
pane.add(text, getCopyrConstraints());
// close button
m_buttonClose = new JButton(s_logger.localizeMessage("guiButtonClose"));
m_buttonClose.setMnemonic(new Integer(s_logger.localizeMessage("guiButtonCloseMnemonic")));
m_buttonClose.setIcon(new ImageIcon(getImage("Cancel16.png")));
m_buttonClose.addActionListener(this);
pane.add(m_buttonClose, getCloseConstraints());
// show dialog
pack();
validate();
m_buttonClose.requestFocusInWindow();
setLocationRelativeTo(component);
setVisible(true);
}
use of java.awt.Container in project adempiere by adempiere.
the class HelpInfo method createAndShowGui.
// METHODS
// =======
/**
* Create the GUI and show it
* @param component the calling component
*/
public void createAndShowGui(Component component) {
// title
setTitle(s_logger.localizeMessage("guiHelpTitle"));
// load icons
ArrayList<Image> images = new ArrayList<Image>();
images.add(getImage("AD16.png"));
images.add(getImage("AD32.png"));
setIconImages(images);
// content pane
Container pane = getContentPane();
Locale locale = Locale.getDefault();
pane.setComponentOrientation(ComponentOrientation.getOrientation(locale));
pane.setLayout(new GridBagLayout());
// help text
JEditorPane info = new JEditorPane();
info.setEditable(false);
info.setContentType("text/html");
HTMLDocument htmlDoc = (HTMLDocument) info.getEditorKit().createDefaultDocument();
info.setDocument(htmlDoc);
info.setText(getHelpText());
info.setCaretPosition(0);
// scrollable pane for help text
JScrollPane infoPane = new JScrollPane();
infoPane.setBorder(BorderFactory.createLoweredBevelBorder());
infoPane.setPreferredSize(new Dimension(500, 400));
infoPane.getViewport().add(info, null);
pane.add(infoPane, getInfoPaneConstraints());
// close button
m_buttonClose = new JButton(s_logger.localizeMessage("guiButtonClose"));
m_buttonClose.setMnemonic(new Integer(s_logger.localizeMessage("guiButtonCloseMnemonic")));
m_buttonClose.setIcon(new ImageIcon(getImage("Cancel16.png")));
m_buttonClose.addActionListener(this);
pane.add(m_buttonClose, getCloseConstraints());
// show dialog
pack();
validate();
m_buttonClose.requestFocusInWindow();
setLocationRelativeTo(component);
setVisible(true);
}
Aggregations