use of org.compiere.swing.CFrame in project adempiere by adempiere.
the class Env method hideWindow.
/**
* Hide Window
* @param window window
* @return true if window is hidden, otherwise close it
*/
public static boolean hideWindow(CFrame window) {
if (!Ini.isCacheWindow() || s_closingWindows)
return false;
for (int i = 0; i < s_hiddenWindows.size(); i++) {
CFrame hidden = s_hiddenWindows.get(i);
s_log.info(i + ": " + hidden);
if (hidden.getAD_Window_ID() == window.getAD_Window_ID())
// already there
return false;
}
if (// workbench
window.getAD_Window_ID() != 0) {
if (s_hiddenWindows.add(window)) {
window.setVisible(false);
s_log.info(window.toString());
// window.dispatchEvent(new WindowEvent(window, WindowEvent.WINDOW_ICONIFIED));
if (s_hiddenWindows.size() > 10) {
// sort of lru
CFrame toClose = s_hiddenWindows.remove(0);
try {
s_closingWindows = true;
toClose.dispose();
} finally {
s_closingWindows = false;
}
}
return true;
}
}
return false;
}
use of org.compiere.swing.CFrame in project adempiere by adempiere.
the class Env method showWindow.
// hideWindow
/**
* Show Window
* @param AD_Window_ID window
* @return true if window re-displayed
*/
public static CFrame showWindow(int AD_Window_ID) {
for (int i = 0; i < s_hiddenWindows.size(); i++) {
CFrame hidden = s_hiddenWindows.get(i);
if (hidden.getAD_Window_ID() == AD_Window_ID) {
s_hiddenWindows.remove(i);
s_log.info(hidden.toString());
hidden.setVisible(true);
// De-iconify window - teo_sarca [ 1707221 ]
int state = hidden.getExtendedState();
if ((state & CFrame.ICONIFIED) > 0)
hidden.setExtendedState(state & ~CFrame.ICONIFIED);
//
hidden.toFront();
return hidden;
}
}
return null;
}
use of org.compiere.swing.CFrame in project adempiere by adempiere.
the class WindowEventListener method close.
/**
* Close all windows managed by this window manager.
*/
public void close() {
for (CFrame w : windows) {
w.removeComponentListener(eventListener);
w.removeWindowListener(eventListener);
w.dispose();
}
windows = new ArrayList<CFrame>();
}
use of org.compiere.swing.CFrame in project adempiere by adempiere.
the class AEnv method actionPerformed.
// addMenuItem
/**
* Perform action command for common menu items.
* Created in AMenu.createMenu(), APanel.createMenu(), FormFrame.createMenu()
* @param actionCommand known action command
* @param WindowNo window no
* @param c Container parent
* @return true if actionCommand was found and performed
*/
public static boolean actionPerformed(String actionCommand, int WindowNo, Container c) {
MRole role = MRole.getDefault();
// File Menu ------------------------
if (actionCommand.equals("PrintScreen")) {
PrintScreenPainter.printScreen(Env.getFrame(c));
} else if (actionCommand.equals("ScreenShot")) {
ScreenShot.createJPEG(Env.getFrame(c), null);
} else // }
if (actionCommand.equals("Exit")) {
if (ADialog.ask(WindowNo, c, "ExitApplication?")) {
AMenu aMenu = (AMenu) Env.getWindow(0);
aMenu.dispose();
}
} else if (actionCommand.equals("Logout")) {
AMenu aMenu = (AMenu) Env.getWindow(0);
aMenu.logout();
} else // View Menu ------------------------
if (actionCommand.equals("InfoProduct") && AEnv.canAccessInfo("PRODUCT")) {
org.compiere.apps.search.Info.showProduct(Env.getFrame(c), WindowNo);
} else if (actionCommand.equals("InfoBPartner") && AEnv.canAccessInfo("BPARTNER")) {
org.compiere.apps.search.Info.showBPartner(Env.getFrame(c), WindowNo);
} else if (actionCommand.equals("InfoAsset") && AEnv.canAccessInfo("ASSET")) {
org.compiere.apps.search.Info.showAsset(Env.getFrame(c), WindowNo);
} else if (actionCommand.equals("InfoAccount") && MRole.getDefault().isShowAcct() && AEnv.canAccessInfo("ACCOUNT")) {
new org.compiere.acct.AcctViewer();
} else if (actionCommand.equals("InfoSchedule") && AEnv.canAccessInfo("SCHEDULE")) {
new org.compiere.apps.search.InfoSchedule(Env.getFrame(c), null, false);
} else //FR [ 1966328 ]
if (actionCommand.equals("InfoMRP") && AEnv.canAccessInfo("MRP")) {
CFrame frame = (CFrame) Env.getFrame(c);
int m_menu_id = MMenu.getMenu_ID("MRP Info");
AMenu menu = AEnv.getAMenu(frame);
// async load
AMenuStartItem form = new AMenuStartItem(m_menu_id, true, Msg.translate(Env.getCtx(), "MRP Info"), menu);
form.start();
} else if (actionCommand.equals("InfoCRP") && AEnv.canAccessInfo("CRP")) {
CFrame frame = (CFrame) Env.getFrame(c);
int m_menu_id = MMenu.getMenu_ID("CRP Info");
AMenu menu = AEnv.getAMenu(frame);
// async load
AMenuStartItem form = new AMenuStartItem(m_menu_id, true, Msg.translate(Env.getCtx(), "CRP Info"), menu);
form.start();
} else if (actionCommand.equals("InfoOrder") && AEnv.canAccessInfo("ORDER")) {
org.compiere.apps.search.Info.showOrder(Env.getFrame(c), WindowNo, "");
} else if (actionCommand.equals("InfoInvoice") && AEnv.canAccessInfo("INVOICE")) {
org.compiere.apps.search.Info.showInvoice(Env.getFrame(c), WindowNo, "");
} else if (actionCommand.equals("InfoInOut") && AEnv.canAccessInfo("INOUT")) {
org.compiere.apps.search.Info.showInOut(Env.getFrame(c), WindowNo, "");
} else if (actionCommand.equals("InfoPayment") && AEnv.canAccessInfo("PAYMENT")) {
org.compiere.apps.search.Info.showPayment(Env.getFrame(c), WindowNo, "");
} else if (actionCommand.equals("InfoCashLine") && AEnv.canAccessInfo("CASHJOURNAL")) {
org.compiere.apps.search.Info.showCashLine(Env.getFrame(c), WindowNo, "");
} else if (actionCommand.equals("InfoAssignment") && AEnv.canAccessInfo("RESOURCE")) {
org.compiere.apps.search.Info.showAssignment(Env.getFrame(c), WindowNo, "");
} else // Go Menu ------------------------
if (actionCommand.equals("WorkFlow")) {
startWorkflowProcess(0, 0);
} else if (actionCommand.equals("Home")) {
showWindow(Env.getWindow(0));
} else // Tools Menu ------------------------
if (actionCommand.equals("Calculator")) {
Calculator calc = new org.compiere.grid.ed.Calculator(Env.getFrame(c));
calc.setDisposeOnEqual(false);
AEnv.showCenterScreen(calc);
} else if (actionCommand.equals("Calendar")) {
AEnv.showCenterScreen(new org.compiere.grid.ed.Calendar(Env.getFrame(c)));
} else if (actionCommand.equals("Editor")) {
AEnv.showCenterScreen(new org.compiere.grid.ed.Editor(Env.getFrame(c)));
} else if (actionCommand.equals("Script")) {
new BeanShellEditor(Env.getFrame(c));
} else if (actionCommand.equals("Preference")) {
if (role.isShowPreference()) {
AEnv.showCenterScreen(new Preference(Env.getFrame(c), WindowNo));
}
} else // Help Menu ------------------------
if (actionCommand.equals("Online")) {
Env.startBrowser(org.compiere.Adempiere.getOnlineHelpURL());
} else if (actionCommand.equals("EMailSupport")) {
ADialog.createSupportEMail(Env.getFrame(c), Env.getFrame(c).getTitle(), "\n\n");
} else if (actionCommand.equals("About")) {
AEnv.showCenterScreen(new AboutBox(Env.getFrame(c)));
} else
return false;
//
return true;
}
use of org.compiere.swing.CFrame in project adempiere by adempiere.
the class AEnv method updateUI.
// cacheReset
/**
* Update all windows after look and feel changes.
* @since 2006-11-27
*/
public static void updateUI() {
Set<Window> updated = Env.updateUI();
JFrame top = Env.getWindow(0);
if (top instanceof AMenu) {
CFrame[] frames = ((AMenu) top).getWindowManager().getWindows();
for (CFrame f : frames) {
if (updated.contains(f))
continue;
SwingUtilities.updateComponentTreeUI(f);
f.validate();
RepaintManager mgr = RepaintManager.currentManager(f);
Component[] childs = f.getComponents();
for (Component c : childs) {
if (c instanceof JComponent)
mgr.markCompletelyDirty((JComponent) c);
}
f.repaint();
updated.add(f);
}
}
}
Aggregations