Search in sources :

Example 1 with Html

use of org.zkoss.zul.Html in project adempiere by adempiere.

the class WAlertDialog method init.

private void init() {
    setBorder("normal");
    VerticalBox vbox = new VerticalBox();
    appendChild(vbox);
    Div div = new Div();
    div.setHeight("500px");
    div.setWidth("700px");
    div.setStyle("overflow: auto; border: 1px solid");
    vbox.appendChild(div);
    Html html = new Html();
    div.appendChild(html);
    html.setContent(text);
    vbox.appendChild(new Separator());
    ConfirmPanel confirmPanel = new ConfirmPanel(false);
    vbox.appendChild(confirmPanel);
    confirmPanel.addActionListener(this);
}
Also used : Div(org.zkoss.zul.Div) VerticalBox(org.adempiere.webui.component.VerticalBox) ConfirmPanel(org.adempiere.webui.component.ConfirmPanel) Html(org.zkoss.zul.Html) Separator(org.zkoss.zul.Separator)

Example 2 with Html

use of org.zkoss.zul.Html in project adempiere by adempiere.

the class ProcessPanel method unlockUI.

@Override
public void unlockUI(ProcessInfo pi) {
    isLocked = false;
    if (parent.getParentProcess() != null) {
        hideBusyDialog();
        if (parent.isEmbedded()) {
            dispose();
        }
        parent.getParentProcess().unlockUI(pi);
        return;
    }
    // avoid close dialog when an report is executed
    if ((isReport() && pi.isError()) || !isReport()) {
        if (progressWindow != null) {
            //move message div to center to give more space to display potentially very long log info
            parameterPanel.detach();
            centerPanel.removeChild(parameterPanel);
            centerPanel.setStyle("overflow-y:auto");
            Html message = new Html(getLogInfo(false));
            centerPanel.appendChild(message);
            centerPanel.setAutoscroll(true);
            parent.validateScreen();
        }
    }
    //	
    hideBusyDialog();
    //	Hide
    if (isReport() && !pi.isError()) {
        dispose();
    }
}
Also used : Html(org.zkoss.zul.Html)

Example 3 with Html

use of org.zkoss.zul.Html in project adempiere by adempiere.

the class NavBarDesktop method createHomeTab.

private void createHomeTab() {
    Tabpanel homeTab = new Tabpanel();
    windowContainer.addWindow(homeTab, Msg.getMsg(Env.getCtx(), "Home").replaceAll("&", ""), false);
    Anchorlayout anchorLayout = new Anchorlayout();
    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);
        pstmt.setString(4, VIEWS_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 + "%");
                anchorchildren.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"));
            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();
}
Also used : Anchorchildren(org.zkoss.zul.Anchorchildren) ToolBarButton(org.adempiere.webui.component.ToolBarButton) InputStreamReader(java.io.InputStreamReader) WGraph(org.adempiere.webui.apps.graph.WGraph) Anchorlayout(org.zkoss.zul.Anchorlayout) Html(org.zkoss.zul.Html) PreparedStatement(java.sql.PreparedStatement) Panelchildren(org.zkoss.zul.Panelchildren) IOException(java.io.IOException) MMenu(org.compiere.model.MMenu) URL(java.net.URL) IOException(java.io.IOException) DashboardPanel(org.adempiere.webui.dashboard.DashboardPanel) SidePanel(org.adempiere.webui.panel.SidePanel) HeaderPanel(org.adempiere.webui.panel.HeaderPanel) DashboardPanel(org.adempiere.webui.dashboard.DashboardPanel) Panel(org.zkoss.zul.Panel) ResultSet(java.sql.ResultSet) BufferedReader(java.io.BufferedReader) Component(org.zkoss.zk.ui.Component) Tabpanel(org.adempiere.webui.component.Tabpanel) MGoal(org.compiere.model.MGoal)

Example 4 with Html

use of org.zkoss.zul.Html 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();
}
Also used : Anchorchildren(org.zkoss.zul.Anchorchildren) ToolBarButton(org.adempiere.webui.component.ToolBarButton) InputStreamReader(java.io.InputStreamReader) WGraph(org.adempiere.webui.apps.graph.WGraph) Anchorlayout(org.zkoss.zul.Anchorlayout) Html(org.zkoss.zul.Html) PreparedStatement(java.sql.PreparedStatement) Panelchildren(org.zkoss.zul.Panelchildren) IOException(java.io.IOException) MMenu(org.compiere.model.MMenu) URL(java.net.URL) IOException(java.io.IOException) DashboardPanel(org.adempiere.webui.dashboard.DashboardPanel) SidePanel(org.adempiere.webui.panel.SidePanel) HeaderPanel(org.adempiere.webui.panel.HeaderPanel) DashboardPanel(org.adempiere.webui.dashboard.DashboardPanel) Panel(org.zkoss.zul.Panel) ResultSet(java.sql.ResultSet) BufferedReader(java.io.BufferedReader) Component(org.zkoss.zk.ui.Component) Tabpanel(org.adempiere.webui.component.Tabpanel) MGoal(org.compiere.model.MGoal)

Example 5 with Html

use of org.zkoss.zul.Html in project adempiere by adempiere.

the class WTextEditorDialog method init.

private void init() {
    setBorder("normal");
    VerticalBox vbox = new VerticalBox();
    appendChild(vbox);
    tabbox = new Tabbox();
    vbox.appendChild(tabbox);
    Tabs tabs = new Tabs();
    tabbox.appendChild(tabs);
    Tabpanels tabPanels = new Tabpanels();
    tabbox.appendChild(tabPanels);
    Tab tab = new Tab("Text");
    tabs.appendChild(tab);
    Tabpanel tabPanel = new Tabpanel();
    tabPanels.appendChild(tabPanel);
    textBox = new Textbox(text);
    textBox.setCols(80);
    textBox.setRows(30);
    textBox.setEnabled(editable);
    textBox.setWidth("700px");
    textBox.setHeight("500px");
    tabPanel.appendChild(textBox);
    tab = new Tab("HTML");
    tabs.appendChild(tab);
    tabPanel = new Tabpanel();
    tabPanels.appendChild(tabPanel);
    if (editable) {
        editor = new FCKeditor();
        tabPanel.appendChild(editor);
        editor.setWidth("700px");
        editor.setHeight("500px");
        editor.setValue(text);
    } else {
        Div div = new Div();
        div.setHeight("500px");
        div.setWidth("700px");
        div.setStyle("overflow: auto; border: 1px solid");
        tabPanel.appendChild(div);
        Html html = new Html();
        div.appendChild(html);
        html.setContent(text);
    }
    vbox.appendChild(new Separator());
    ConfirmPanel confirmPanel = new ConfirmPanel(true);
    vbox.appendChild(confirmPanel);
    confirmPanel.addButton(confirmPanel.createButton(ConfirmPanel.A_RESET));
    confirmPanel.addActionListener(this);
    if (maxSize > 0) {
        status = new Label();
        appendChild(status);
        updateStatus(text.length());
        status.setStyle("margin-top:10px;");
        textBox.addEventListener(Events.ON_CHANGE, this);
        editor.addEventListener(Events.ON_CHANGE, this);
    }
    tabbox.addEventListener(Events.ON_SELECT, this);
}
Also used : VerticalBox(org.adempiere.webui.component.VerticalBox) Textbox(org.adempiere.webui.component.Textbox) Label(org.adempiere.webui.component.Label) Html(org.zkoss.zul.Html) Tabbox(org.adempiere.webui.component.Tabbox) Div(org.zkoss.zul.Div) Tab(org.adempiere.webui.component.Tab) ConfirmPanel(org.adempiere.webui.component.ConfirmPanel) Tabpanels(org.adempiere.webui.component.Tabpanels) Tabs(org.adempiere.webui.component.Tabs) Tabpanel(org.adempiere.webui.component.Tabpanel) Separator(org.zkoss.zul.Separator) FCKeditor(org.zkforge.fckez.FCKeditor)

Aggregations

Html (org.zkoss.zul.Html)7 Tabpanel (org.adempiere.webui.component.Tabpanel)4 BufferedReader (java.io.BufferedReader)3 IOException (java.io.IOException)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 ConfirmPanel (org.adempiere.webui.component.ConfirmPanel)3 ToolBarButton (org.adempiere.webui.component.ToolBarButton)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 Component (org.zkoss.zk.ui.Component)3 Div (org.zkoss.zul.Div)3 Label (org.adempiere.webui.component.Label)2 VerticalBox (org.adempiere.webui.component.VerticalBox)2 MMenu (org.compiere.model.MMenu)2