use of org.zkoss.zk.ui.Component in project adempiere by adempiere.
the class NavBar2Desktop method createHomeTab.
private void createHomeTab() {
Tabpanel homeTab = new Tabpanel();
windowContainer.addWindow(homeTab, Util.cleanAmp(Msg.getMsg(Env.getCtx(), "Home")), false);
Anchorlayout anchorLayout = new Anchorlayout();
anchorLayout.setVflex("1");
anchorLayout.setHflex("1");
homeTab.appendChild(anchorLayout);
// Dashboard content
Anchorchildren anchorChildren = 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.*, m.AD_MENU_ID " + "FROM PA_DASHBOARDCONTENT x " + "LEFT OUTER JOIN AD_MENU m ON x.AD_WINDOW_ID=m.AD_WINDOW_ID " + "WHERE (x.AD_CLIENT_ID=0 OR x.AD_CLIENT_ID=?) AND x.ISACTIVE='Y' " + "AND x.zulfilepath not in (?, ?) " + "ORDER BY x.COLUMNNO, x.AD_CLIENT_ID, x.LINE ";
PreparedStatement pstmt = null;
ResultSet rs = null;
try {
pstmt = DB.prepareStatement(sql, null);
pstmt.setInt(1, Env.getAD_Client_ID(Env.getCtx()));
pstmt.setString(2, ACTIVITIES_PATH);
pstmt.setString(3, FAVOURITES_PATH);
rs = pstmt.executeQuery();
while (rs.next()) {
int columnNo = rs.getInt(X_PA_DashboardContent.COLUMNNAME_ColumnNo);
if (anchorChildren == null || currentColumnNo != columnNo) {
anchorChildren = new Anchorchildren();
anchorLayout.appendChild(anchorChildren);
anchorChildren.setWidth(width + "%");
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"));
panel.setBorder("normal");
anchorChildren.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");
// if(description != null)
// result.append("<h2>" + description + "</h2>\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) {
int AD_Menu_ID = rs.getInt(X_AD_Menu.COLUMNNAME_AD_Menu_ID);
ToolBarButton btn = new ToolBarButton(String.valueOf(AD_Menu_ID));
MMenu menu = new MMenu(Env.getCtx(), AD_Menu_ID, null);
btn.setLabel(menu.getName());
btn.addEventListener(Events.ON_CLICK, this);
content.appendChild(btn);
panelEmpty = false;
}
// Goal
int PA_Goal_ID = rs.getInt(X_PA_DashboardContent.COLUMNNAME_PA_Goal_ID);
if (PA_Goal_ID > 0) {
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 {
DB.close(rs, pstmt);
}
//
//register as 0
registerWindow(homeTab);
if (!anchorLayout.getDesktop().isServerPushEnabled())
anchorLayout.getDesktop().enableServerPush(true);
dashboardRunnable.refreshDashboard();
dashboardThread = new Thread(dashboardRunnable, "UpdateInfo");
dashboardThread.setDaemon(true);
dashboardThread.start();
}
use of org.zkoss.zk.ui.Component in project adempiere by adempiere.
the class NavBar2Desktop method onEvent.
public void onEvent(Event event) {
Component comp = event.getTarget();
String eventName = event.getName();
if (eventName.equals(Events.ON_CLICK)) {
if (comp instanceof ToolBarButton) {
ToolBarButton btn = (ToolBarButton) comp;
int menuId = 0;
try {
menuId = Integer.valueOf(btn.getName());
} catch (Exception e) {
}
if (menuId > 0)
onMenuSelected(menuId);
}
}
}
use of org.zkoss.zk.ui.Component in project adempiere by adempiere.
the class WListItemRenderer method renderListHead.
/**
* Render the ListHead for the table with headers for the table columns.
*
* @param head The ListHead component to render.
* @see #addColumn(String)
* @see #WListItemRenderer(List)
*/
public void renderListHead(ListHead head) {
Component header;
WTableColumn column;
for (int columnIndex = 0; columnIndex < m_tableColumns.size(); columnIndex++) {
column = m_tableColumns.get(columnIndex);
header = getListHeaderComponent(column.getHeaderValue(), columnIndex, column.getColumnClass());
head.appendChild(header);
}
head.setSizable(true);
return;
}
use of org.zkoss.zk.ui.Component in project adempiere by adempiere.
the class DPFavourites method onEvent.
public void onEvent(Event event) {
Component comp = event.getTarget();
String eventName = event.getName();
if (eventName.equals(Events.ON_CLICK)) {
if (comp instanceof Button) {
Button btn = (Button) comp;
int menuId = 0;
try {
menuId = Integer.valueOf(btn.getName());
} catch (NumberFormatException e) {
}
if (menuId > 0)
SessionManager.getAppDesktop().onMenuSelected(menuId);
}
} else // Elaine 2008/07/24
if (eventName.equals(Events.ON_DROP)) {
DropEvent de = (DropEvent) event;
Component dragged = de.getDragged();
if (comp instanceof Panelchildren) {
if (dragged instanceof Treerow) {
Treerow treerow = (Treerow) dragged;
Treeitem treeitem = (Treeitem) treerow.getParent();
addItem(treeitem);
}
} else if (comp instanceof Image) {
if (dragged instanceof Button) {
Button btn = (Button) dragged;
removeLink(btn);
}
}
}
//
}
use of org.zkoss.zk.ui.Component in project adempiere by adempiere.
the class DPViews method onEvent.
public void onEvent(Event event) {
Component comp = event.getTarget();
String eventName = event.getName();
if (eventName.equals(Events.ON_CLICK)) {
if (comp instanceof Button) {
Button btn = (Button) comp;
String actionCommand = btn.getName();
int WindowNo = 0;
if (actionCommand.equals("InfoProduct") && AEnv.canAccessInfo("PRODUCT")) {
InfoPanel.showProduct(WindowNo);
} else if (actionCommand.equals("InfoBPartner") && AEnv.canAccessInfo("BPARTNER")) {
InfoPanel.showBPartner(WindowNo);
} else if (actionCommand.equals("InfoAsset") && AEnv.canAccessInfo("ASSET")) {
InfoPanel.showAsset(WindowNo);
} else if (actionCommand.equals("InfoAccount") && MRole.getDefault().isShowAcct() && AEnv.canAccessInfo("ACCOUNT")) {
new org.adempiere.webui.acct.WAcctViewer();
} else if (actionCommand.equals("InfoSchedule") && AEnv.canAccessInfo("SCHEDULE")) {
new InfoSchedule(null, false);
} else if (actionCommand.equals("InfoOrder") && AEnv.canAccessInfo("ORDER")) {
InfoPanel.showOrder(WindowNo, "");
} else if (actionCommand.equals("InfoInvoice") && AEnv.canAccessInfo("INVOICE")) {
InfoPanel.showInvoice(WindowNo, "");
} else if (actionCommand.equals("InfoInOut") && AEnv.canAccessInfo("INOUT")) {
InfoPanel.showInOut(WindowNo, "");
} else if (actionCommand.equals("InfoPayment") && AEnv.canAccessInfo("PAYMENT")) {
InfoPanel.showPayment(WindowNo, "");
} else if (actionCommand.equals("InfoCashLine") && AEnv.canAccessInfo("CASHJOURNAL")) {
InfoPanel.showCashLine(WindowNo, "");
} else if (actionCommand.equals("InfoAssignment") && AEnv.canAccessInfo("RESOURCE")) {
InfoPanel.showAssignment(WindowNo, "");
}
}
}
}
Aggregations