use of org.zkoss.zk.ui.event.EventListener in project adempiere by adempiere.
the class WSearch method fillPopup.
/**
* Find the search targets and load the pop-up menu. If there are no saved
* searches, the FindWindow will open.
*/
private void fillPopup() {
MUserQuery[] search = MUserQuery.get(Env.getCtx(), m_AD_Tab_ID);
if (search.length == 0) {
// No queries to add to the popup. Just return;
return;
}
// There are saved queries, so create the pop-up menu.
// The first item is "Search" which will open the FindWindow
Menuitem menuItem = new Menuitem(Msg.getMsg(Env.getCtx(), "Search"));
menuItem.addEventListener(Events.ON_CLICK, new EventListener() {
@Override
public void onEvent(Event event) throws Exception {
// Just open the find window
find();
}
});
m_popup.appendChild(menuItem);
for (final MUserQuery query : search) {
menuItem = new Menuitem(query.getName());
menuItem.addEventListener(Events.ON_CLICK, new EventListener() {
@Override
public void onEvent(Event event) throws Exception {
// Set the query
m_query = query.getQuery(m_AD_Table_ID, m_targetWindowNo, m_findFields);
m_panel.onFindCallback(m_query);
}
});
m_popup.appendChild(menuItem);
}
}
use of org.zkoss.zk.ui.event.EventListener in project adempiere by adempiere.
the class WBrowser method initComponents.
/**
* Initialize View Components
*/
private void initComponents() {
toolsBar = new ToolBar();
bZoom = new Button();
bExport = new Button();
bDelete = new Button();
tabsPanel = new Tabbox();
searchTab = new Borderlayout();
collapsibleSeach = new North();
topPanel = new Hbox();
searchGrid = new WBrowserSearch(getWindowNo(), getAD_Browse_ID(), BrowserSearch.COLUMNS_2);
detail = new WBrowserTable(this);
detail.addEventListener(Events.ON_SELECT, this);
bCancel = new Button();
bOk = new Button();
detailPanel = new Borderlayout();
Borderlayout mainLayout = new Borderlayout();
setupToolBar();
bSelectAll.setLabel(Msg.getMsg(Env.getCtx(), "SelectAll").replaceAll("[&]", ""));
bSelectAll.setEnabled(false);
bSelectAll.addActionListener(new EventListener() {
public void onEvent(Event evt) {
selectedRows();
}
});
toolsBar.appendChild(bSelectAll);
//TODO: victor.perez@e-evolution.com pending print functionality
/*bPrint.setLabel("Print");
bPrint.addActionListener(new EventListener() {
@Override
public void onEvent(Event event) throws Exception {
bPrintActionPerformed(event);
}
});
toolsBar.appendChild(bPrint);*/
bZoom.setLabel(Msg.getMsg(Env.getCtx(), "Zoom").replaceAll("[&]", ""));
bZoom.setEnabled(false);
bZoom.addActionListener(new EventListener() {
public void onEvent(Event evt) {
cmd_Zoom();
}
});
//Only enable if exist a reference
if (AD_Window_ID > 0)
toolsBar.appendChild(bZoom);
bExport.setLabel(Msg.getMsg(Env.getCtx(), "Export"));
bExport.setEnabled(false);
bExport.addActionListener(new EventListener() {
public void onEvent(Event evt) {
cmd_Export();
}
});
toolsBar.appendChild(bExport);
bDelete.setLabel(Msg.getMsg(Env.getCtx(), "Delete").replaceAll("[&]", ""));
bDelete.setEnabled(false);
bDelete.addActionListener(new EventListener() {
public void onEvent(Event evt) {
cmd_deleteSelection();
}
});
if (isDeleteable())
toolsBar.appendChild(bDelete);
m_frame.setWidth("100%");
m_frame.setHeight("100%");
m_frame.setStyle("position: absolute; padding: 0; margin: 0");
m_frame.appendChild(mainLayout);
mainLayout.setWidth("100%");
mainLayout.setHeight("100%");
mainLayout.setStyle("position: absolute");
North north = new North();
north.appendChild(toolsBar);
mainLayout.appendChild(north);
searchTab = new Borderlayout();
searchTab.setWidth("99.4%");
searchTab.setHeight("99.4%");
searchTab.setStyle("background-color: transparent");
topPanel = new Hbox();
topPanel.setStyle("background-color: transparent");
bSearch.setLabel(Msg.getMsg(Env.getCtx(), "StartSearch"));
bSearch.addActionListener(new EventListener() {
public void onEvent(Event evt) {
cmd_Search();
}
});
Vbox vbox = new Vbox();
vbox.appendChild(topPanel);
vbox.appendChild(bSearch);
vbox.setAlign("center");
vbox.setWidth("100%");
vbox.setStyle("background-color: transparent");
Div div = new Div();
div.appendChild(vbox);
div.setWidth("100%");
div.setHeight("100%");
collapsibleSeach.setTitle(Msg.getMsg(Env.getCtx(), ("SearchCriteria")));
collapsibleSeach.setCollapsible(true);
collapsibleSeach.setAutoscroll(true);
collapsibleSeach.appendChild(div);
collapsibleSeach.setStyle("overflow-y:auto");
collapsibleSeach.setStyle("background-color: transparent");
collapsibleSeach.setStyle("border: none");
searchTab.appendChild(collapsibleSeach);
detail.setWidth("100%");
//detail.setHeight("100%");
Center dCenter = new Center();
dCenter.appendChild(detail);
dCenter.setBorder("none");
detail.setVflex(true);
detail.setFixedLayout(true);
dCenter.setHflex("true");
dCenter.setVflex("true");
dCenter.setAutoscroll(true);
detailPanel.setHeight("100%");
detailPanel.setWidth("100%");
detailPanel.appendCenter(detail);
// Div dv = new Div();
div.appendChild(detailPanel);
div.setHeight("100%");
div.setWidth("100%");
searchTab.appendCenter(detailPanel);
Hbox hbox = new Hbox();
// bCancel.setLabel(Msg.getMsg(Env.getCtx(), "Cancel").replaceAll("[&]",""));
bCancel.addActionListener(new EventListener() {
public void onEvent(Event evt) {
cmd_Cancel();
}
});
// bOk.setLabel(Msg.getMsg(Env.getCtx(), "Ok").replaceAll("[&]",""));
bOk.addActionListener(new EventListener() {
public void onEvent(Event evt) {
cmd_Ok();
}
});
Div confirmDiv = new Div();
confirmDiv.setAlign("center");
hbox.appendChild(bCancel);
hbox.appendChild(bOk);
hbox.setAlign("center");
confirmDiv.appendChild(hbox);
Separator separator = new Separator();
separator.setBar(true);
confirmDiv.appendChild(separator);
confirmDiv.appendChild(statusBar);
searchTab.appendSouth(confirmDiv);
searchTab.getSouth().setBorder("none");
Tabpanel search = new Tabpanel();
search.setWidth("100%");
search.appendChild(searchTab);
Tab tabSearch = new Tab();
tabSearch.addEventListener(Events.ON_SELECT, this);
tabSearch.setLabel(Msg.getMsg(Env.getCtx(), "Search").replaceAll("[&]", ""));
Tabs tabs = new Tabs();
tabs.appendChild(tabSearch);
Tabpanels tabPanels = new Tabpanels();
tabPanels.setWidth("100%");
tabPanels.appendChild(search);
//graphPanel = new Borderlayout();
//TODO victor.perez@e-evolution.com implement Graph Functionality
//Tabpanel graph = new Tabpanel();
//graph.setWidth("100%");
//graph.appendChild(graphPanel);
//Tab tabGraph = new Tab();
//tabGraph.addEventListener(Events.ON_SELECT, this);
//tabGraph.setLabel(Msg.getMsg(Env.getCtx(), "Graph").replaceAll("[&]",
// ""));
//tabs.appendChild(tabGraph);
//tabPanels.appendChild(graph);
tabsPanel.setWidth("100%");
tabsPanel.setHeight("100%");
tabsPanel.appendChild(tabs);
tabsPanel.appendChild(tabPanels);
mainLayout.appendCenter(tabsPanel);
}
use of org.zkoss.zk.ui.event.EventListener in project adempiere by adempiere.
the class DefaultDesktop method createHomeTab.
private void createHomeTab() {
Tabpanel homeTab = new Tabpanel();
windowContainer.addWindow(homeTab, Msg.getMsg(Env.getCtx(), "Home").replaceAll("&", ""), false);
Portallayout portalLayout = new Portallayout();
portalLayout.setWidth("100%");
portalLayout.setHeight("100%");
portalLayout.setStyle("position: absolute; overflow: auto");
homeTab.appendChild(portalLayout);
// Dashboard content
Portalchildren portalchildren = null;
int currentColumnNo = 0;
String sql = "SELECT COUNT(DISTINCT COLUMNNO) " + "FROM PA_DASHBOARDCONTENT " + "WHERE (AD_CLIENT_ID=0 OR AD_CLIENT_ID=?) AND ISACTIVE='Y'";
int noOfCols = DB.getSQLValue(null, sql, Env.getAD_Client_ID(Env.getCtx()));
int width = noOfCols <= 0 ? 100 : 100 / noOfCols;
/* sql = "SELECT x.* "
+ "FROM PA_DASHBOARDCONTENT x "
+ "WHERE (x.AD_CLIENT_ID=0 OR x.AD_CLIENT_ID=?) AND x.ISACTIVE='Y' "
+ "ORDER BY x.COLUMNNO, x.AD_CLIENT_ID, x.LINE ";*/
StringBuffer sqlContent = new StringBuffer();
sqlContent.append("SELECT x.PA_DASHBOARDCONTENT_ID, x.AD_CLIENT_ID, x.AD_ORG_ID, x.ISACTIVE ,");
sqlContent.append(" COALESCE(XTRL.NAME,x.NAME) AS NAME ,");
sqlContent.append(" x.AD_WINDOW_ID ,");
sqlContent.append(" x.DESCRIPTION ,");
sqlContent.append(" x.HTML ,");
sqlContent.append(" x.LINE ,");
sqlContent.append(" x.PA_GOAL_ID ,");
sqlContent.append(" x.COLUMNNO ,");
sqlContent.append(" x.ZULFILEPATH ,");
sqlContent.append(" x.ISCOLLAPSIBLE ,");
sqlContent.append(" x.GOALDISPLAY ,");
sqlContent.append(" x.ISOPENBYDEFAULT ,");
sqlContent.append(" x.ISEVENTREQUIRED ,");
sqlContent.append(" x.ZOOM_WINDOW_ID ,");
sqlContent.append(" x.ZOOM_TAB_ID ,");
sqlContent.append(" x.PAGESIZE ,");
sqlContent.append(" x.ONEVENT ,");
sqlContent.append(" x.AD_BROWSE_ID ,");
sqlContent.append(" x.ZOOM_FIELD_ID ");
sqlContent.append(" FROM PA_DASHBOARDCONTENT x ");
sqlContent.append(" LEFT JOIN PA_DASHBOARDCONTENT_TRL xtrl on x.PA_DASHBOARDCONTENT_ID = xtrl.PA_DASHBOARDCONTENT_ID " + "AND xtrl.AD_LANGUAGE = ?");
sqlContent.append(" WHERE (x.AD_CLIENT_ID=0 OR x.AD_CLIENT_ID=?) AND x.ISACTIVE='Y' ");
sqlContent.append(" ORDER BY x.COLUMNNO, x.AD_CLIENT_ID, x.LINE ");
PreparedStatement pstmt = null;
ResultSet rs = null;
try {
pstmt = DB.prepareStatement(sqlContent.toString(), null);
pstmt.setString(1, Env.getAD_Language(Env.getCtx()));
pstmt.setInt(2, Env.getAD_Client_ID(Env.getCtx()));
rs = pstmt.executeQuery();
while (rs.next()) {
int columnNo = rs.getInt(X_PA_DashboardContent.COLUMNNAME_ColumnNo);
if (portalchildren == null || currentColumnNo != columnNo) {
portalchildren = new Portalchildren();
portalLayout.appendChild(portalchildren);
portalchildren.setWidth(width + "%");
portalchildren.setStyle("padding: 5px");
currentColumnNo = columnNo;
}
Panel panel = new Panel();
panel.setStyle("margin-bottom:10px");
panel.setTitle(rs.getString(X_PA_DashboardContent.COLUMNNAME_Name));
String description = rs.getString(X_PA_DashboardContent.COLUMNNAME_Description);
if (description != null)
panel.setTooltiptext(description);
String collapsible = rs.getString(X_PA_DashboardContent.COLUMNNAME_IsCollapsible);
panel.setCollapsible(collapsible.equals("Y"));
String isOpenByDefault = rs.getString(X_PA_DashboardContent.COLUMNNAME_IsOpenByDefault);
panel.setOpen(isOpenByDefault.equals("Y"));
panel.setBorder("normal");
portalchildren.appendChild(panel);
Panelchildren content = new Panelchildren();
panel.appendChild(content);
boolean panelEmpty = true;
// HTML content
String htmlContent = rs.getString(X_PA_DashboardContent.COLUMNNAME_HTML);
if (htmlContent != null) {
StringBuffer result = new StringBuffer("<html><head>");
URL url = getClass().getClassLoader().getResource("org/compiere/images/PAPanel.css");
InputStreamReader ins;
try {
ins = new InputStreamReader(url.openStream());
BufferedReader bufferedReader = new BufferedReader(ins);
String cssLine;
while ((cssLine = bufferedReader.readLine()) != null) result.append(cssLine + "\n");
} catch (IOException e1) {
logger.log(Level.SEVERE, e1.getLocalizedMessage(), e1);
}
result.append("</head><body><div class=\"content\">\n");
result.append(stripHtml(htmlContent, false) + "<br>\n");
result.append("</div>\n</body>\n</html>\n</html>");
Html html = new Html();
html.setContent(result.toString());
content.appendChild(html);
panelEmpty = false;
}
// Window
int AD_Window_ID = rs.getInt(X_PA_DashboardContent.COLUMNNAME_AD_Window_ID);
if (AD_Window_ID > 0) {
MDashboardContent dashboardContent = new MDashboardContent(Env.getCtx(), rs.getInt(X_PA_DashboardContent.COLUMNNAME_PA_DashboardContent_ID), null);
int AD_Menu_ID = dashboardContent.getAD_Menu_ID();
ToolBarButton btn = new ToolBarButton(String.valueOf(AD_Menu_ID));
I_AD_Menu menu = dashboardContent.getAD_Menu();
btn.setLabel(menu.getName());
btn.addEventListener(Events.ON_CLICK, this);
content.appendChild(btn);
panelEmpty = false;
}
//SmartBrowse
int AD_Browse_ID = rs.getInt(X_PA_DashboardContent.COLUMNNAME_AD_Browse_ID);
if (AD_Browse_ID > 0) {
try {
//setting Tab ID to context
Env.setContext(Env.getCtx(), "#AD_Browse_ID", rs.getInt(X_PA_DashboardContent.COLUMNNAME_AD_Browse_ID));
Env.setContext(Env.getCtx(), "#PageSize", rs.getInt(X_PA_DashboardContent.COLUMNNAME_PageSize));
Env.setContext(Env.getCtx(), "#Zoom_Tab_ID", rs.getInt(X_PA_DashboardContent.COLUMNNAME_Zoom_Tab_ID));
Env.setContext(Env.getCtx(), "#Zoom_Window_ID", rs.getInt(X_PA_DashboardContent.COLUMNNAME_Zoom_Window_ID));
Env.setContext(Env.getCtx(), "#Zoom_Field_ID", rs.getInt(X_PA_DashboardContent.COLUMNNAME_Zoom_Field_ID));
Env.setContext(Env.getCtx(), "#OnEvent", rs.getString(X_PA_DashboardContent.COLUMNNAME_onevent));
Component component = Executions.createComponents(dynamic_Dashboard_zulFilepath, content, null);
if (component != null) {
if (component instanceof DashboardPanel) {
DashboardPanel dashboardPanel = (DashboardPanel) component;
if (!dashboardPanel.getChildren().isEmpty()) {
content.appendChild(dashboardPanel);
dashboardRunnable.add(dashboardPanel);
panelEmpty = false;
}
} else {
content.appendChild(component);
panelEmpty = false;
}
}
} catch (Exception e) {
logger.log(Level.WARNING, "Failed to create components. zul=" + dynamic_Dashboard_zulFilepath, e);
}
}
// Goal
int PA_Goal_ID = rs.getInt(X_PA_DashboardContent.COLUMNNAME_PA_Goal_ID);
if (PA_Goal_ID > 0) {
//link to open performance detail
Toolbarbutton link = new Toolbarbutton();
link.setImage("/images/Zoom16.png");
link.setAttribute("PA_Goal_ID", PA_Goal_ID);
link.addEventListener(Events.ON_CLICK, new EventListener() {
public void onEvent(Event event) throws Exception {
int PA_Goal_ID = (Integer) event.getTarget().getAttribute("PA_Goal_ID");
MGoal goal = new MGoal(Env.getCtx(), PA_Goal_ID, null);
new WPerformanceDetail(goal);
}
});
content.appendChild(link);
String goalDisplay = rs.getString(X_PA_DashboardContent.COLUMNNAME_GoalDisplay);
MGoal goal = new MGoal(Env.getCtx(), PA_Goal_ID, null);
WGraph graph = new WGraph(goal, 55, false, true, !(X_PA_DashboardContent.GOALDISPLAY_Chart.equals(goalDisplay)), X_PA_DashboardContent.GOALDISPLAY_Chart.equals(goalDisplay));
content.appendChild(graph);
panelEmpty = false;
}
// ZUL file url
String url = rs.getString(X_PA_DashboardContent.COLUMNNAME_ZulFilePath);
if (url != null) {
try {
Component component = Executions.createComponents(url, content, null);
if (component != null) {
if (component instanceof DashboardPanel) {
DashboardPanel dashboardPanel = (DashboardPanel) component;
if (!dashboardPanel.getChildren().isEmpty()) {
content.appendChild(dashboardPanel);
dashboardRunnable.add(dashboardPanel);
panelEmpty = false;
}
} else {
content.appendChild(component);
panelEmpty = false;
}
}
} catch (Exception e) {
logger.log(Level.WARNING, "Failed to create components. zul=" + url, e);
}
}
if (panelEmpty)
panel.detach();
}
} catch (Exception e) {
logger.log(Level.WARNING, "Failed to create dashboard content", e);
} finally {
}
//
//register as 0
registerWindow(homeTab);
if (!portalLayout.getDesktop().isServerPushEnabled())
portalLayout.getDesktop().enableServerPush(true);
dashboardRunnable.refreshDashboard();
dashboardThread = new Thread(dashboardRunnable, "UpdateInfo");
dashboardThread.setDaemon(true);
dashboardThread.start();
}
use of org.zkoss.zk.ui.event.EventListener in project adempiere by adempiere.
the class NavBarDesktop method doCreatePart.
protected Component doCreatePart(Component parent) {
SidePanel pnlSide = new SidePanel();
HeaderPanel pnlHead = new HeaderPanel();
pnlSide.getMenuPanel().addMenuListener(this);
layout = new Borderlayout();
if (parent != null) {
layout.setParent(parent);
layout.setWidth("100%");
layout.setHeight("100%");
layout.setStyle("position: absolute");
} else
layout.setPage(page);
dashboardRunnable = new DashboardRunnable(layout.getDesktop(), this);
North n = new North();
n.setSplittable(true);
n.setCollapsible(false);
layout.appendChild(n);
pnlHead.setParent(n);
leftRegion = new West();
layout.appendChild(leftRegion);
leftRegion.setWidth("300px");
leftRegion.setCollapsible(true);
leftRegion.setSplittable(true);
leftRegion.setTitle("Navigation");
//leftRegion.setHflex("true");
leftRegion.setVflex("true");
leftRegion.addEventListener(Events.ON_OPEN, new EventListener() {
@Override
public void onEvent(Event event) throws Exception {
OpenEvent oe = (OpenEvent) event;
UserPreference pref = SessionManager.getSessionApplication().getUserPreference();
pref.setProperty(UserPreference.P_MENU_COLLAPSED, !oe.isOpen());
pref.savePreference();
}
});
UserPreference pref = SessionManager.getSessionApplication().getUserPreference();
boolean menuCollapsed = pref.isPropertyBool(UserPreference.P_MENU_COLLAPSED);
leftRegion.setOpen(!menuCollapsed);
navigationPanel = new Accordion();
navigationPanel.setParent(leftRegion);
navigationPanel.setWidth("100%");
navigationPanel.setHeight("100%");
navigationPanel.add(pnlSide, "Application Menu");
Div div = new Div();
favPanel = (DPFavourites) Executions.createComponents(FAVOURITES_PATH, div, null);
navigationPanel.add(div, "Favourites");
//setup drag and drop for favourites
div = navigationPanel.getHeader(1);
div.setDroppable(DPFavourites.FAVOURITE_DROPPABLE);
div.addEventListener(Events.ON_DROP, this);
div = new Div();
Component component = Executions.createComponents(ACTIVITIES_PATH, div, null);
if (component instanceof DashboardPanel) {
DashboardPanel dashboardPanel = (DashboardPanel) component;
dashboardRunnable.add(dashboardPanel);
}
navigationPanel.add(div, "Activities");
div = new Div();
Executions.createComponents(VIEWS_PATH, div, null);
navigationPanel.add(div, Msg.getMsg(Env.getCtx(), "View").replaceAll("&", ""));
navigationPanel.setSelectedIndex(0);
windowArea = new Center();
windowArea.setParent(layout);
windowArea.setHflex("true");
windowArea.setVflex("true");
windowContainer.createPart(windowArea);
createHomeTab();
return layout;
}
use of org.zkoss.zk.ui.event.EventListener in project adempiere by adempiere.
the class NavBar2Desktop method doCreatePart.
protected Component doCreatePart(Component parent) {
SidePanel pnlSide = new SidePanel();
HeaderPanel pnlHead = new HeaderPanel();
pnlSide.getMenuPanel().addMenuListener(this);
layout = new Borderlayout();
if (parent != null) {
layout.setParent(parent);
layout.setWidth("100%");
layout.setHeight("100%");
layout.setStyle("position: absolute");
} else
layout.setPage(page);
dashboardRunnable = new DashboardRunnable(layout.getDesktop(), this);
North n = new North();
n.setSplittable(true);
n.setCollapsible(false);
layout.appendChild(n);
pnlHead.setParent(n);
West w = new West();
layout.appendChild(w);
w.setWidth("300px");
w.setCollapsible(true);
w.setSplittable(true);
w.setTitle(Util.cleanAmp(Msg.getMsg(Env.getCtx(), "Menu")));
//w.setHflex("true");
w.setVflex("true");
w.addEventListener(Events.ON_OPEN, new EventListener() {
@Override
public void onEvent(Event event) throws Exception {
OpenEvent oe = (OpenEvent) event;
UserPreference pref = SessionManager.getSessionApplication().getUserPreference();
pref.setProperty(UserPreference.P_MENU_COLLAPSED, !oe.isOpen());
pref.savePreference();
}
});
UserPreference pref = SessionManager.getSessionApplication().getUserPreference();
boolean menuCollapsed = pref.isPropertyBool(UserPreference.P_MENU_COLLAPSED);
w.setOpen(!menuCollapsed);
pnlSide.setParent(w);
Center center = new Center();
center.setParent(layout);
center.setHflex("true");
center.setVflex("true");
Borderlayout innerLayout = new Borderlayout();
innerLayout.setHeight("100%");
innerLayout.setWidth("100%");
innerLayout.setParent(center);
West innerW = new West();
innerW.setWidth("200px");
innerW.setCollapsible(true);
innerW.setTitle("Navigation");
innerW.setSplittable(true);
innerW.setCollapsible(true);
innerW.setParent(innerLayout);
shortcutPanel = new Accordion();
shortcutPanel.setWidth("100%");
shortcutPanel.setHeight("100%");
innerW.appendChild(shortcutPanel);
Div div = new Div();
Executions.createComponents(FAVOURITES_PATH, div, null);
shortcutPanel.add(div, "Favourites");
div = new Div();
Component component = Executions.createComponents(ACTIVITIES_PATH, div, null);
if (component instanceof DashboardPanel) {
DashboardPanel dashboardPanel = (DashboardPanel) component;
dashboardRunnable.add(dashboardPanel);
}
shortcutPanel.add(div, "Activities");
shortcutPanel.setSelectedIndex(0);
windowArea = new Center();
windowArea.setParent(innerLayout);
windowArea.setHflex("true");
windowArea.setVflex("true");
windowContainer.createPart(windowArea);
createHomeTab();
return layout;
}
Aggregations