use of org.adempiere.webui.component.Tabpanel in project adempiere by adempiere.
the class ADTabPanel method setTabPanels.
private Tabbox setTabPanels(HorizontalEmbeddedPanel ep, Panel panel) {
// For One Tab We created only one TabBox
if (null == tabBox && null == tabPanels) {
tabBox = new Tabbox();
tabBox.setHeight("100%");
//tabBox.setStyle("height: 100%; width: 100%; position: relative;");
tabPanels = new Tabpanels();
tabPanels.setHeight("600px");
tabBox.appendChild(tabPanels);
tabs = new Tabs();
tabBox.appendChild(tabs);
}
// Setting Name For Tab
Tab tab = new Tab(ep.gridWindow.getTab(ep.tabIndex).getName());
tab.addEventListener(Events.ON_CLICK, this);
tab.addEventListener(Events.ON_FOCUS, this);
// Appending Tab to Tabs
tabs.appendChild(tab);
//Creating a TabPanel For every Tab
Tabpanel tabPanel = new Tabpanel();
embeddedTabPanel.put(ep.adTabId, tabPanel);
tabPanel.setStyle("margin:0; padding:0; border: none; height:600px;");
//Setting Embedded Panel to tabPanel
tabPanel.appendChild(panel);
//Appending Tab Panel To TabPanels
tabPanels.appendChild(tabPanel);
//By Default first Tab should populated
tabBox.setSelectedIndex(0);
// Returning the tabbox
return tabBox;
}
use of org.adempiere.webui.component.Tabpanel in project adempiere by adempiere.
the class ADWindowPanel method doCreatePart.
protected Component doCreatePart(Component parent) {
layout = new Borderlayout();
if (parent != null) {
layout.setParent(parent);
layout.setStyle("position:absolute");
layout.setHeight("100%");
layout.setWidth("100%");
} else {
layout.setPage(page);
}
if (!isEmbedded()) {
North n = new North();
n.setParent(layout);
n.setCollapsible(false);
n.setFlex(true);
Vbox box = new Vbox();
box.setWidth("100%");
toolbar.setParent(box);
box.setParent(n);
toolbar.setWindowNo(getWindowNo());
// FR [ 588 ]
South s = new South();
layout.appendChild(s);
s.setCollapsible(false);
statusBar.setParent(s);
} else {
South s = new South();
layout.appendChild(s);
s.setCollapsible(false);
statusBar.setParent(s);
}
LayoutUtils.addSclass("adwindow-status", statusBar);
if (!isEmbedded() && adTab.isUseExternalSelection()) {
String tabPlacement = SessionManager.getSessionApplication().getUserPreference().getProperty(UserPreference.P_WINDOW_TAB_PLACEMENT);
if (tabPlacement == null || "left".equalsIgnoreCase(tabPlacement)) {
west = new West();
layout.appendChild(west);
west.setSplittable(false);
west.setAutoscroll(true);
west.setFlex(true);
LayoutUtils.addSclass("adwindow-nav adwindow-left-nav", west);
adTab.setTabplacement(IADTab.LEFT);
adTab.getTabSelectionComponent().setParent(west);
if (SessionManager.getSessionApplication().getUserPreference().isPropertyBool(UserPreference.P_WINDOW_TAB_COLLAPSIBLE)) {
west.setTitle(Msg.getElement(Env.getCtx(), "AD_Tab_ID"));
west.setCollapsible(true);
}
} else {
east = new East();
layout.appendChild(east);
east.setSplittable(false);
east.setAutoscroll(true);
east.setFlex(true);
LayoutUtils.addSclass("adwindow-nav adwindow-right-nav", east);
adTab.setTabplacement(IADTab.RIGHT);
adTab.getTabSelectionComponent().setParent(east);
if (SessionManager.getSessionApplication().getUserPreference().isPropertyBool(UserPreference.P_WINDOW_TAB_COLLAPSIBLE)) {
east.setTitle(Msg.getElement(Env.getCtx(), "AD_Tab_ID"));
east.setCollapsible(true);
}
}
LayoutUtils.addSclass("adwindow-nav-content", (HtmlBasedComponent) adTab.getTabSelectionComponent());
}
contentArea = new Center();
contentArea.setParent(layout);
contentArea.setAutoscroll(true);
contentArea.setFlex(true);
adTab.createPart(contentArea);
if (parent instanceof Tabpanel) {
TabOnCloseHanlder handler = new TabOnCloseHanlder();
((Tabpanel) parent).setOnCloseHandler(handler);
}
if (!isEmbedded()) {
if (keyListener != null)
keyListener.detach();
keyListener = new Keylistener();
statusBar.appendChild(keyListener);
keyListener.setCtrlKeys("#f1#f2#f3#f4#f5#f6#f7#f8#f9#f10#f11#f12^f^i^n^s^d@#left@#right@#up@#down@#pgup@#pgdn@p^p@z@x#enter");
keyListener.addEventListener(Events.ON_CTRL_KEY, toolbar);
keyListener.addEventListener(Events.ON_CTRL_KEY, this);
keyListener.setAutoBlur(false);
}
layout.setAttribute(ITabOnSelectHandler.ATTRIBUTE_KEY, new ITabOnSelectHandler() {
public void onSelect() {
IADTab adTab = getADTab();
if (adTab != null) {
IADTabPanel iadTabpanel = adTab.getSelectedTabpanel();
if (iadTabpanel != null && iadTabpanel instanceof ADTabPanel) {
ADTabPanel adTabpanel = (ADTabPanel) iadTabpanel;
if (adTabpanel.isGridView()) {
adTabpanel.getGridView().scrollToCurrentRow();
}
}
}
}
});
return layout;
}
use of org.adempiere.webui.component.Tabpanel 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();
}
use of org.adempiere.webui.component.Tabpanel in project adempiere by adempiere.
the class TabbedDesktop method addWin.
/**
*
* @param fr
* @param title
* @param closeable
*/
private void addWin(Iframe fr, String title, boolean closeable) {
fr.setWidth("100%");
fr.setHeight("100%");
fr.setStyle("padding: 0; margin: 0; border: none; position: absolute");
Window window = new Window();
window.setWidth("100%");
window.setHeight("100%");
window.setStyle("padding: 0; margin: 0; border: none");
window.appendChild(fr);
window.setStyle("position: absolute");
Tabpanel tabPanel = new Tabpanel();
window.setParent(tabPanel);
preOpenNewTab();
windowContainer.addWindow(tabPanel, title, closeable);
}
use of org.adempiere.webui.component.Tabpanel 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();
}
Aggregations