Search in sources :

Example 6 with ToolBarButton

use of org.adempiere.webui.component.ToolBarButton 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);
        }
    }
}
Also used : ToolBarButton(org.adempiere.webui.component.ToolBarButton) Component(org.zkoss.zk.ui.Component) IOException(java.io.IOException)

Example 7 with ToolBarButton

use of org.adempiere.webui.component.ToolBarButton 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();
}
Also used : MDashboardContent(org.compiere.model.MDashboardContent) WPerformanceDetail(org.adempiere.webui.apps.graph.WPerformanceDetail) Portallayout(org.zkoss.zkmax.zul.Portallayout) URL(java.net.URL) DashboardPanel(org.adempiere.webui.dashboard.DashboardPanel) I_AD_Menu(org.compiere.model.I_AD_Menu) ResultSet(java.sql.ResultSet) Toolbarbutton(org.zkoss.zul.Toolbarbutton) EventListener(org.zkoss.zk.ui.event.EventListener) Component(org.zkoss.zk.ui.Component) Tabpanel(org.adempiere.webui.component.Tabpanel) MGoal(org.compiere.model.MGoal) ToolBarButton(org.adempiere.webui.component.ToolBarButton) InputStreamReader(java.io.InputStreamReader) WGraph(org.adempiere.webui.apps.graph.WGraph) Html(org.zkoss.zul.Html) PreparedStatement(java.sql.PreparedStatement) Panelchildren(org.zkoss.zul.Panelchildren) IOException(java.io.IOException) IOException(java.io.IOException) SidePanel(org.adempiere.webui.panel.SidePanel) HeaderPanel(org.adempiere.webui.panel.HeaderPanel) DashboardPanel(org.adempiere.webui.dashboard.DashboardPanel) Panel(org.zkoss.zul.Panel) Portalchildren(org.zkoss.zkmax.zul.Portalchildren) BufferedReader(java.io.BufferedReader) Event(org.zkoss.zk.ui.event.Event) OpenEvent(org.zkoss.zk.ui.event.OpenEvent)

Example 8 with ToolBarButton

use of org.adempiere.webui.component.ToolBarButton in project adempiere by adempiere.

the class NavBarDesktop 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);
        }
    } else if (eventName.equals(Events.ON_DROP)) {
        DropEvent de = (DropEvent) event;
        Component dragged = de.getDragged();
        if (dragged instanceof Treerow) {
            Treerow treerow = (Treerow) dragged;
            Treeitem treeitem = (Treeitem) treerow.getParent();
            favPanel.addItem(treeitem);
        }
    }
}
Also used : DropEvent(org.zkoss.zk.ui.event.DropEvent) Treeitem(org.zkoss.zul.Treeitem) ToolBarButton(org.adempiere.webui.component.ToolBarButton) Component(org.zkoss.zk.ui.Component) IOException(java.io.IOException) Treerow(org.zkoss.zul.Treerow)

Example 9 with ToolBarButton

use of org.adempiere.webui.component.ToolBarButton in project adempiere by adempiere.

the class WSchedule method init.

/**
	 * 	Static init
	 *  <pre>
	 * 	timePanel (West)
	 *  schedlePanel (in schedulePane - Center)
	 *  </pre>
	 * 	@throws Exception
	 */
private void init() throws Exception {
    this.getChildren().clear();
    timeLine = new Timeline();
    timeLine.setHeight("400px");
    timeLine.setWidth("100%");
    timeLine.setId("resoureSchedule");
    this.appendChild(timeLine);
    initBandInfo();
    button = new ToolBarButton();
    button.setLabel("Edit");
    button.setStyle("visibility: hidden; height: 0px; width: 0px");
    button.addEventListener(Events.ON_CLICK, this);
    this.appendChild(button);
}
Also used : Timeline(org.zkforge.timeline.Timeline) ToolBarButton(org.adempiere.webui.component.ToolBarButton)

Example 10 with ToolBarButton

use of org.adempiere.webui.component.ToolBarButton in project adempiere by adempiere.

the class FindWindow method initAdvanced.

/**
     * initialise Advanced Tab
     * @throws IOException 
     *
    **/
private void initAdvanced() throws IOException {
    ToolBarButton btnNew = new ToolBarButton();
    btnNew.setImage("/images/New24.png");
    btnNew.setAttribute("name", "btnNewAdv");
    btnNew.addEventListener(Events.ON_CLICK, this);
    ToolBarButton btnDelete = new ToolBarButton();
    btnDelete.setAttribute("name", "btnDeleteAdv");
    btnDelete.setImage("/images/Delete24.png");
    btnDelete.addEventListener(Events.ON_CLICK, this);
    ToolBarButton btnSave = new ToolBarButton();
    btnSave.setAttribute("name", "btnSaveAdv");
    btnSave.setImage("/images/Save24.png");
    btnSave.addEventListener(Events.ON_CLICK, this);
    fQueryName = new Combobox();
    fQueryName.setTooltiptext(m_sToolTipText);
    fQueryName.setReadonly(false);
    fQueryName.addEventListener(Events.ON_FOCUS, this);
    fQueryName.addEventListener(Events.ON_BLUR, this);
    fQueryName.addEventListener(Events.ON_SELECT, this);
    //	Get from Action
    WAppsAction action = new WAppsAction(ConfirmPanel.A_OK, null, ConfirmPanel.A_OK);
    Button btnOk = action.getButton();
    btnOk.setName("btnOkAdv");
    btnOk.addEventListener(Events.ON_CLICK, this);
    //	
    action = new WAppsAction(ConfirmPanel.A_CANCEL, null, ConfirmPanel.A_CANCEL);
    Button btnCancel = action.getButton();
    btnCancel.setName("btnCancel");
    btnCancel.addEventListener(Events.ON_CLICK, this);
    Panel pnlButtonRight = new Panel();
    //	Change to Standard button order
    pnlButtonRight.appendChild(btnCancel);
    pnlButtonRight.appendChild(btnOk);
    pnlButtonRight.setAlign("right");
    ToolBar toolBar = new ToolBar();
    toolBar.appendChild(btnNew);
    toolBar.appendChild(btnDelete);
    toolBar.appendChild(fQueryName);
    toolBar.appendChild(btnSave);
    toolBar.setWidth("100%");
    fQueryName.setStyle("margin-left: 3px; margin-right: 3px; position: relative; top: 5px;");
    btnSave.setDisabled(m_AD_Tab_ID <= 0);
    Hbox confirmPanel = new Hbox();
    confirmPanel.appendChild(pnlButtonRight);
    confirmPanel.setWidth("100%");
    advancedPanel = new Listbox();
    ListHead listhead = new ListHead();
    listhead.setSizable(true);
    ListHeader lstHAndOr = new ListHeader();
    lstHAndOr.setLabel(Msg.getMsg(Env.getCtx(), "And/Or"));
    lstHAndOr.setWidth("40px");
    ListHeader lstHLeftBracket = new ListHeader();
    lstHLeftBracket.setLabel("(");
    lstHLeftBracket.setWidth("20px");
    ListHeader lstHColumn = new ListHeader();
    lstHColumn.setLabel(Msg.translate(Env.getCtx(), "AD_Column_ID"));
    lstHColumn.setWidth("100px");
    ListHeader lstHOperator = new ListHeader();
    lstHOperator.setLabel(Msg.getMsg(Env.getCtx(), "Operator"));
    ListHeader lstHQueryValue = new ListHeader();
    lstHQueryValue.setLabel(Msg.getMsg(Env.getCtx(), "QueryValue"));
    lstHQueryValue.setWidth("170px");
    ListHeader lstHQueryTo = new ListHeader();
    lstHQueryTo.setLabel(Msg.getMsg(Env.getCtx(), "QueryValue2"));
    lstHQueryTo.setWidth("170px");
    ListHeader lstHRightBracket = new ListHeader();
    lstHRightBracket.setLabel(")");
    lstHRightBracket.setWidth("20px");
    listhead.appendChild(lstHAndOr);
    listhead.appendChild(lstHLeftBracket);
    listhead.appendChild(lstHColumn);
    listhead.appendChild(lstHOperator);
    listhead.appendChild(lstHQueryValue);
    listhead.appendChild(lstHQueryTo);
    listhead.appendChild(lstHRightBracket);
    advancedPanel.appendChild(listhead);
    advancedPanel.setVflex(true);
    Borderlayout layout = new Borderlayout();
    layout.setStyle("height: 100%; width: 99%; position: relative;");
    winAdvanced.appendChild(layout);
    North north = new North();
    layout.appendChild(north);
    north.appendChild(toolBar);
    Center center = new Center();
    layout.appendChild(center);
    center.appendChild(advancedPanel);
    center.setFlex(true);
    South south = new South();
    layout.appendChild(south);
    south.appendChild(confirmPanel);
    winAdvanced.setHeight("100%");
    winAdvanced.setWidth("100%");
    winAdvanced.addEventListener(Events.ON_OK, this);
}
Also used : Hbox(org.zkoss.zul.Hbox) Center(org.zkoss.zkex.zul.Center) ToolBarButton(org.adempiere.webui.component.ToolBarButton) Combobox(org.adempiere.webui.component.Combobox) South(org.zkoss.zkex.zul.South) Borderlayout(org.zkoss.zkex.zul.Borderlayout) WAppsAction(org.adempiere.webui.component.WAppsAction) Panel(org.adempiere.webui.component.Panel) ConfirmPanel(org.adempiere.webui.component.ConfirmPanel) Button(org.adempiere.webui.component.Button) ToolBarButton(org.adempiere.webui.component.ToolBarButton) ListHead(org.adempiere.webui.component.ListHead) ToolBar(org.adempiere.webui.component.ToolBar) ListHeader(org.adempiere.webui.component.ListHeader) North(org.zkoss.zkex.zul.North) Listbox(org.adempiere.webui.component.Listbox)

Aggregations

ToolBarButton (org.adempiere.webui.component.ToolBarButton)12 Component (org.zkoss.zk.ui.Component)7 IOException (java.io.IOException)6 Tabpanel (org.adempiere.webui.component.Tabpanel)5 BufferedReader (java.io.BufferedReader)3 InputStreamReader (java.io.InputStreamReader)3 URL (java.net.URL)3 PreparedStatement (java.sql.PreparedStatement)3 ResultSet (java.sql.ResultSet)3 WGraph (org.adempiere.webui.apps.graph.WGraph)3 DashboardPanel (org.adempiere.webui.dashboard.DashboardPanel)3 HeaderPanel (org.adempiere.webui.panel.HeaderPanel)3 SidePanel (org.adempiere.webui.panel.SidePanel)3 MGoal (org.compiere.model.MGoal)3 Separator (org.zkoss.zul.Separator)3 Button (org.adempiere.webui.component.Button)2 Combobox (org.adempiere.webui.component.Combobox)2 Label (org.adempiere.webui.component.Label)2 Listbox (org.adempiere.webui.component.Listbox)2 ToolBar (org.adempiere.webui.component.ToolBar)2