private FlexTable getFooter() { ft = new FlexTable(); ft.addStyleName("perunFooter"); FlexTable.FlexCellFormatter ftf = ft.getFlexCellFormatter(); if (!voContact.getHTML().isEmpty()) { // show only if any contact is present voContact.setHTML( "<strong>" + ApplicationMessages.INSTANCE.supportContact() + "</strong> " + voContact.getHTML()); } ft.setWidget(0, 0, voContact); ft.setWidget( 0, 1, new HTML( PerunWebConstants.INSTANCE.footerPerunCopyright() + " " + JsonUtils.getCurrentYear())); ftf.setHorizontalAlignment(0, 0, HasHorizontalAlignment.ALIGN_LEFT); ftf.setVerticalAlignment(0, 0, HasVerticalAlignment.ALIGN_MIDDLE); ftf.getElement(0, 1).setAttribute("style", "text-wrap: avoid;"); ftf.setHorizontalAlignment(0, 1, HasHorizontalAlignment.ALIGN_RIGHT); ftf.setVerticalAlignment(0, 1, HasVerticalAlignment.ALIGN_MIDDLE); return ft; }
private FlexTable getCustomErrorWidget(PerunError error, String customText) { FlexTable ft = new FlexTable(); ft.setSize("100%", "300px"); ft.setHTML(0, 0, new Image(LargeIcons.INSTANCE.errorIcon()) + "<h2>Error: </h2>" + customText); ft.getFlexCellFormatter().setHorizontalAlignment(0, 0, HasHorizontalAlignment.ALIGN_CENTER); ft.getFlexCellFormatter().setVerticalAlignment(0, 0, HasVerticalAlignment.ALIGN_MIDDLE); return ft; }
/** * Method to set proper CSS styles to menu widget. Should be called after any widget content * change */ private void setStyles() { // set proper last item tag for (int i = 0; i < cellCount; i++) { if (i == 0) menu.getFlexCellFormatter().addStyleName(0, i, "tabMenu-first"); menu.getFlexCellFormatter().addStyleName(0, i, "tabMenu"); menu.getFlexCellFormatter().removeStyleName(0, i, "tabMenu-last"); if (i == cellCount - 1) { menu.getFlexCellFormatter().addStyleName(0, i, "tabMenu-last"); } } }
/** * Method which adds any kind of widget into TabMenu on specific position (replace any content on * this position) * * @param position position in menu starting from 0 * @param widget widget to put in menu */ public void addWidget(int position, Widget widget) { if (position <= cellCount) { menu.setWidget(0, position, widget); if (position == cellCount) { cellCount++; // if new setStyles(); } } else { // TODO not allowed } }
private FlexTable getErrorWidget(PerunError error) { String text = "Request timeout exceeded."; String errorInfo = ""; if (error != null) { if (error.getName().equalsIgnoreCase("VoNotExistsException")) { text = "Virtual organization with such name doesn't exists. Please check URL and try again."; } else if (error.getName().equalsIgnoreCase("GroupNotExistsException")) { text = "Group with such name doesn't exists. Please check URL and try again."; } else { text = "Error: " + error.getName(); } errorInfo = error.getErrorInfo(); } FlexTable ft = new FlexTable(); ft.setSize("100%", "300px"); ft.setHTML(0, 0, new Image(LargeIcons.INSTANCE.errorIcon()) + "<h2>" + text + "</h2>"); ft.getFlexCellFormatter().setHorizontalAlignment(0, 0, HasHorizontalAlignment.ALIGN_CENTER); ft.getFlexCellFormatter().setVerticalAlignment(0, 0, HasVerticalAlignment.ALIGN_BOTTOM); ft.setHTML(1, 0, "<p>" + errorInfo); ft.getFlexCellFormatter().setHorizontalAlignment(1, 0, HasHorizontalAlignment.ALIGN_CENTER); ft.getFlexCellFormatter().setVerticalAlignment(1, 0, HasVerticalAlignment.ALIGN_TOP); return ft; }
public void onModuleLoad() { // Create table for stock data. stocksFlexTable.setText(0, 0, "Symbol"); stocksFlexTable.setText(0, 1, "Price"); stocksFlexTable.setText(0, 2, "Change"); stocksFlexTable.setText(0, 3, "Remove"); // Assemble Add Stock panel. addPanel.add(newSymbolTextBox); addPanel.add(addStockButton); // Assemble Main panel. mainPanel.add(stocksFlexTable); mainPanel.add(addPanel); mainPanel.add(lastUpdateLabel); // Associate the Main panel with the HTML host page. RootPanel.get("stockList").add(mainPanel); // Move cursor focus to the input box. newSymbolTextBox.setFocus(true); initHandlers(); }
/** Clear all menu content (discard all widgets) !! */ public void clear() { menu.clear(); }
/** * Prepares the GUI * * @param entity PerunEntity GROUP or VO * @param applicationType INITIAL | EXTENSION */ protected void prepareGui(PerunEntity entity, String applicationType) { // trigger email verification as first if present in URL if (Location.getParameterMap().keySet().contains("m") && Location.getParameterMap().keySet().contains("i")) { String verifyI = Location.getParameter("i"); String verifyM = Location.getParameter("m"); if (verifyI != null && !verifyI.isEmpty() && verifyM != null && !verifyM.isEmpty()) { final SimplePanel verifContent = new SimplePanel(); Anchor a = leftMenu.addItem( ApplicationMessages.INSTANCE.emailValidationMenuItem(), SmallIcons.INSTANCE.emailIcon(), verifContent); a.fireEvent(new ClickEvent() {}); ValidateEmail request = new ValidateEmail( verifyI, verifyM, new JsonCallbackEvents() { @Override public void onLoadingStart() { verifContent.clear(); verifContent.add(new AjaxLoaderImage()); } @Override public void onFinished(JavaScriptObject jso) { BasicOverlayType obj = jso.cast(); if (obj.getBoolean() == true) { verifContent.clear(); FlexTable ft = new FlexTable(); ft.setSize("100%", "300px"); ft.setHTML( 0, 0, new Image(LargeIcons.INSTANCE.acceptIcon()) + "<h2>" + ApplicationMessages.INSTANCE.emailValidationSuccess() + "</h2>"); ft.getFlexCellFormatter() .setHorizontalAlignment(0, 0, HasHorizontalAlignment.ALIGN_CENTER); ft.getFlexCellFormatter() .setVerticalAlignment(0, 0, HasVerticalAlignment.ALIGN_MIDDLE); verifContent.add(ft); } else { verifContent.clear(); FlexTable ft = new FlexTable(); ft.setSize("100%", "300px"); ft.setHTML( 0, 0, new Image(LargeIcons.INSTANCE.deleteIcon()) + "<h2>" + ApplicationMessages.INSTANCE.emailValidationFail() + "</h2>"); ft.getFlexCellFormatter() .setHorizontalAlignment(0, 0, HasHorizontalAlignment.ALIGN_CENTER); ft.getFlexCellFormatter() .setVerticalAlignment(0, 0, HasVerticalAlignment.ALIGN_MIDDLE); verifContent.add(ft); } } @Override public void onError(PerunError error) { ((AjaxLoaderImage) verifContent.getWidget()).loadingError(error); } }); request.retrieveData(); leftMenu.addLogoutItem(); return; } } // group and extension is not allowed if (group != null && applicationType.equalsIgnoreCase("EXTENSION")) { RootLayoutPanel panel = RootLayoutPanel.get(); panel.clear(); FlexTable ft = new FlexTable(); ft.setSize("100%", "300px"); ft.setHTML( 0, 0, new Image(LargeIcons.INSTANCE.errorIcon()) + "<h2>Error: " + ApplicationMessages.INSTANCE.groupMembershipCantBeExtended( group.getName(), vo.getName()) + "</h2>"); ft.getFlexCellFormatter().setHorizontalAlignment(0, 0, HasHorizontalAlignment.ALIGN_CENTER); ft.getFlexCellFormatter().setVerticalAlignment(0, 0, HasVerticalAlignment.ALIGN_MIDDLE); panel.add(ft); return; } // application form page ApplicationFormPage formPage = new ApplicationFormPage(vo, group, applicationType); // even user "not yet in perun" can have some applications sent (therefore display by session // info) UsersApplicationsPage appsPage = new UsersApplicationsPage(); // if rt test if ("true".equals(Location.getParameter("rttest"))) { TestRtReportingTabItem tabItem = new TestRtReportingTabItem(); Widget rtTab = tabItem.draw(); leftMenu.addItem("RT test", SmallIcons.INSTANCE.settingToolsIcon(), rtTab); } // proper menu text String appMenuText = ApplicationMessages.INSTANCE.applicationFormForVo(vo.getName()); if (group != null) { appMenuText = ApplicationMessages.INSTANCE.applicationFormForGroup(group.getName()); } if (applicationType.equalsIgnoreCase("EXTENSION")) { appMenuText = ApplicationMessages.INSTANCE.membershipExtensionForVo(vo.getName()); if (group != null) { appMenuText = ApplicationMessages.INSTANCE.membershipExtensionForGroup(group.getName()); } } // load list of applications first if param in session if ("apps".equals(Location.getParameter("page"))) { Anchor a = leftMenu.addItem( ApplicationMessages.INSTANCE.applications(), SmallIcons.INSTANCE.applicationFromStorageIcon(), appsPage); leftMenu.addItem(appMenuText, SmallIcons.INSTANCE.applicationFormIcon(), formPage); a.fireEvent(new ClickEvent() {}); // appsPage.menuClick(); // load list of apps } else { Anchor a = leftMenu.addItem(appMenuText, SmallIcons.INSTANCE.applicationFormIcon(), formPage); leftMenu.addItem( ApplicationMessages.INSTANCE.applications(), SmallIcons.INSTANCE.applicationFromStorageIcon(), appsPage); a.fireEvent(new ClickEvent() {}); // formPage.menuClick(); // load application form } leftMenu.addLogoutItem(); }