public void main(IWContext iwc) throws Exception { ELUtil.getInstance().autowire(this); String val = iwc.getParameter("submitBtn"); if (!StringUtil.isEmpty(val)) { dao.createDish( iwc.getParameter("dishName"), iwc.getParameter("dishDescription"), iwc.getParameter("dishPrice")); } Layer container = new Layer(); // <div> add(container); IWResourceBundle iwrb = getResourceBundle(iwc); Form form = new Form(); container.add(form); createField(form, "Dish", "dish_name", new TextInput("dishName"), iwrb); createField(form, "Description", "description", new TextArea("dishDescription"), iwrb); createField(form, "Price", "price", new TextInput("dishPrice"), iwrb); SubmitButton submitBtn = new SubmitButton("submitBtn", iwrb.getLocalizedString("submit", "Submit")); form.add(submitBtn); }
private void createField( Form form, String defaultLabel, String locKey, InterfaceObject io, IWResourceBundle iwrb) { Layer container = new Layer(); form.add(container); Label label = new Label(iwrb.getLocalizedString(locKey, defaultLabel), io); container.add(label); container.add(io); }
private Layer getLayer2(int i) { Layer layerInfo = new Layer(Layer.DIV); layerInfo.setOverflow("hidden"); layerInfo.setVisibility("hidden"); layerInfo.setPositionType("relative"); layerInfo.setHeight("25"); layerInfo.setID("lay" + i + "_2"); // layerInfo.setMarkupAttribute("class", "ehealth_div_no_border"); layerInfo.setStyleClass("ehealth_div_top"); Link text1 = new Link(); text1.setNoURL(); text1.setID("text" + i + "_2"); if (age != null && age.getYears() >= 70) { if (i == 1) { text1.setText("Besök 2004-05-05"); } else if (i == 2) { text1.setText("Besök 2004-06-05"); } else text1.setText("Besök 03-01-30 14.00-15.00 Gimo VC"); } else { if (i == 1) { text1.setText("Besök 2004-05-05"); } else if (i == 2) { text1.setText("Inskrivning 2004-06-18"); } else text1.setText("Besök 03-01-30 14.00-15.00 Gimo VC"); } text1.setOnClick("javascript:showHideLayer(" + i + ", 2);return false;"); layerInfo.add(imageCircleU); layerInfo.add(text1); return layerInfo; }
// private Layer getNavigationTree(IWContext iwc) { private Layer getNavigationTree() { Layer layersNav = new Layer(Layer.DIV); layersNav.setOverflow("scroll"); layersNav.setPositionType("relative"); layersNav.setWidth("320"); layersNav.setHeight("400"); layersNav.setStyleClass("ehealth_div_no_border"); // layersNav.setMarkupAttribute("class", "ehealth_div"); layersNav.setBackgroundImage(imageBgVertOut); Table table = new Table(3, 20); table.setNoWrap(); table.setCellpadding(0); table.setCellspacing(0); table.setBorder(0); table.setWidth("280"); table.setHeight("350"); int row = 1; int i = 1; for (i = 1; i <= 4; i++) { table.mergeCells(2, row, 3, row); if (i <= 2) { table.add(getLayer1(i), 2, row); table.setHeight(1, row, "16"); table.setHeight(2, row, "16"); table.setWidth(1, row, "16"); table.setWidth(2, row, "16"); table.setVerticalAlignment(1, row, Table.VERTICAL_ALIGN_TOP); table.add(imageCircleD, 1, row++); } // table.setBackgroundImage(1, row, imageBgVert); table.setHeight(2, row, "16"); table.setVerticalAlignment(1, row, Table.VERTICAL_ALIGN_TOP); table.add(getLayer2(i), 2, row++); table.setBackgroundImage(1, row, imageBgVert); table.setHeight(1, row, "20"); table.setVerticalAlignment(1, row, Table.VERTICAL_ALIGN_TOP); table.add(getLayer3(i), 2, row++); table.setHeight(1, row, "10"); table.setVerticalAlignment(1, row, Table.VERTICAL_ALIGN_TOP); table.setBackgroundImage(1, row++, imageBgVert); /*table.add(getLayer1(i), 2, row); table.add(getLayer2(i), 2, row); table.add(getLayer3(i), 2, row); */ } table.setVerticalAlignment(1, row, Table.VERTICAL_ALIGN_TOP); table.setHeight(1, row, "25"); table.setBackgroundImage(1, row++, imageBgVert); layersNav.add(table); return layersNav; }
private Layer getLayer3(int i) { Layer layerInfo = new Layer(Layer.DIV); layerInfo.setOverflow("hidden"); layerInfo.setVisibility("hidden"); layerInfo.setPositionType("relative"); layerInfo.setHeight("20"); layerInfo.setWidth("260"); layerInfo.setID("lay" + i + "_3"); // layerInfo.setStyleClass("ehealth_div_no_border"); layerInfo.setStyleClass("ehealth_row_outer_div"); // layerInfo.setLeftPosition("10"); layerInfo.setTopPosition("0"); layerInfo.add(getInfoLayer(i)); return layerInfo; }
protected void initializeComponent(FacesContext context) { Layer body = new Layer(Layer.DIV); body.setStyleClass(FORM_CONTAINER_CLASS); body.setId(VIEW_PANEL_ID); Workspace workspace = (Workspace) WFUtil.getBeanInstance(Workspace.BEAN_ID); String view = workspace.getView(); if (PREVIEW_VIEW.equals(view)) { IFrame frame = new IFrame(PREVIEW_IFRAME_NAME, PreviewPage.class); frame.setId(PREVIEW_VIEW_ID); body.add(frame); } else if (SOURCE_VIEW.equals(view)) { FBSourceView sourceView = new FBSourceView(); sourceView.setStyleClass(SOURCE_VIEW_ID); sourceView.setId(SOURCE_VIEW_ID); body.add(sourceView); } else if (DESIGN_VIEW.equals(view)) { FBDesignView designView = new FBDesignView(); designView.setId(DESIGN_VIEW_ID); designView.setStyleClass(DROPBOX_CLASS); designView.setComponentStyleClass(FORM_ELEMENT_CLASS); designView.setSelectedStyleClass( FORM_ELEMENT_CLASS + CoreConstants.SPACE + SELECTED_FORM_ELEMENT_CLASS); body.add(designView); } add(body); }
private Layer getLayer1(int i) { Layer layerInfo = new Layer(Layer.DIV); // layerInfo.setOverflow("hidden"); // layerInfo.setVisibility("visible"); layerInfo.setPositionType("relative"); // layerInfo.setHeight("16"); layerInfo.setWidth("240"); layerInfo.setID("lay" + i + "_1"); // layerInfo.setMarkupAttribute("class", "ehealth_div_top"); layerInfo.setStyleClass("ehealth_div_top"); Link text1 = new Link(); text1.setNoURL(); text1.setID("text" + i + "_1"); if (age != null && age.getYears() >= 70) { if (i == 1) { text1.setText("VÅRDBEGÄRAN 2004-05-05 Läk mott.besök"); } else if (i == 2) { text1.setText("Vårdbegäran 2004-06-05 Läk mott.besök"); } else text1.setText(""); } else { if (i == 1) { text1.setText("Vårdbegäran 2004-05-05 Läk mott.besök"); } else if (i == 2) { text1.setText("Vårdbegäran 2004-06-18 Inskrivning"); } else text1.setText(""); } text1.setOnClick("javascript:showHideLayer(" + i + ", 1);return false;"); layerInfo.add(text1); return layerInfo; }
private void addActions(Layer main) { StringBuilder actions = new StringBuilder("GroupJoinerHelper.FAILURE_MSG = '") .append(iwrb.getLocalizedString("failed", "Failed")) .append(JS_STR_INITIALIZATION_END) .append("GroupJoinerHelper.ADDING_TO_GROUP_MSG = '") .append(iwrb.getLocalizedString("adding_to_group", "Adding to group")) .append(JS_STR_INITIALIZATION_END) .append("GroupJoinerHelper.REMOVING_FROM_GROUP_MSG = '") .append(iwrb.getLocalizedString("removing_from_group", "Removing from group")) .append(JS_STR_INITIALIZATION_END); String actionString = PresentationUtil.getJavaScriptAction(actions.toString()); main.add(actionString); }
@Override protected void initializeComponent(FacesContext context) { super.initializeComponent(context); IWContext iwc = IWContext.getIWContext(context); IWBundle bundle = getBundle(context, IWBundleStarter.IW_BUNDLE_IDENTIFIER); IWResourceBundle iwrb = bundle.getResourceBundle(iwc); Layer container = new Layer(); add(container); PublicEventCreator creator = new PublicEventCreator(); creator.setOnEventCreated( "function() {window.parent.showLoadingMessage('" .concat(iwrb.getLocalizedString("reloading", "Reloading...")) .concat("');window.parent.reloadPage();}")); container.add(creator); Layer events = new Layer(); container.add(events); IFrame frame = new IFrame("eventsViewer", "http://bedework.sidan.is/cal/main/showMain.rdo", 750, 600); events.add(frame); // IWContext iwc = IWContext.getIWContext(context); // if (!iwc.isLoggedOn()) { // return; // } // // HtmlTag div = // (HtmlTag)context.getApplication().createComponent(HtmlTag.COMPONENT_TYPE); // div.setValue(divTag); // div.setStyleClass("calendarEventCreator"); // // IWBundle bundle = getBundle(context, IWBundleStarter.IW_BUNDLE_IDENTIFIER); // IWResourceBundle iwrb = bundle.getResourceBundle(iwc); // // GenericButton gb = new GenericButton(); // div.getChildren().add(gb); // gb.setValue(iwrb.getLocalizedString("show_event", "Show event")); // // PresentationUtil.addStyleSheetToHeader(iwc, // web2Business.getBundleURIToFancyBoxStyleFile()); // // List<String> jsFiles = new ArrayList<String>(); // jsFiles.add(jQuery.getBundleURIToJQueryLib()); // jsFiles.addAll(web2Business.getBundleURIsToFancyBoxScriptFiles()); // // jsFiles.add(bundle.getVirtualPathWithFileNameString("javascript/EventCreationHelper.js")); // PresentationUtil.addJavaScriptSourcesLinesToHeader(iwc, jsFiles); // String action = "EventCreationHelper.initializeHiddenLink();"; // if (!CoreUtil.isSingleComponentRenderingProcess(iwc)) { // action = "jQuery(window).load(function() {" + action + "});"; // } // // PresentationUtil.addJavaScriptActionToBody(iwc, action); // gb.setOnClick("EventCreationHelper.showPublicEventsWindow();"); // // getChildren().add(div); // HtmlTag div = // (HtmlTag)context.getApplication().createComponent(HtmlTag.COMPONENT_TYPE); // div.setValue(divTag); // // IWBundle bundle = getBundle(context, IWBundleStarter.IW_BUNDLE_IDENTIFIER); // FaceletComponent facelet = // (FaceletComponent)context.getApplication().createComponent(FaceletComponent.COMPONENT_TYPE); // facelet.setFaceletURI(bundle.getFaceletURI("EventViewer.xhtml")); // // div.getChildren().add(facelet); // getChildren().add(div); }
private Layer getRaceParticipantList(IWContext iwc) { Layer layer = new Layer(Layer.DIV); layer.setStyleClass("raceParticipantsEvents"); layer.setID("raceParticipantsEvents"); Map participants = getRaceParticipants(iwc); if (participants != null && !participants.isEmpty()) { Iterator it = participants.keySet().iterator(); while (it.hasNext()) { Object key = it.next(); List eventParticipants = (List) participants.get(key); try { RaceEvent raceEvent = ConverterUtility.getInstance().convertGroupToRaceEvent(key); Layer subLayer = new Layer(Layer.DIV); subLayer.setStyleClass("raceParticipantsEvent"); subLayer.setID("raceParticipantsEvent"); layer.add(subLayer); Layer headerLayer = new Layer(Layer.DIV); headerLayer.setStyleClass("raceParticipantsEventHeader"); subLayer.add(headerLayer); Layer headingLayer = new Layer(Layer.DIV); headingLayer.setStyleClass("raceParticipantsEventHeading"); headingLayer.add(new Text(raceEvent.getName())); headerLayer.add(headingLayer); subLayer.add(getRaceParticipantListForEvent(iwc, eventParticipants, raceEvent)); } catch (Exception e) { getLogger().log(Level.WARNING, "Error printing participants for " + key, e); } } } return layer; }
public void main(IWContext iwc) throws Exception { try { if (iwc.isParameterSet(PARAMETER_RACE)) { race = ConverterUtility.getInstance() .convertGroupToRace(new Integer(iwc.getParameter(PARAMETER_RACE))); } } catch (Exception e) { } Layer layer = new Layer(Layer.DIV); layer.setStyleClass("raceElement"); layer.setID("raceParticipants"); Layer headerLayer = new Layer(Layer.DIV); headerLayer.setStyleClass("raceParticipantsHeader"); layer.add(headerLayer); Layer headingLayer = new Layer(Layer.DIV); headingLayer.setStyleClass("raceParticipantHeading"); headingLayer.add(new Text(getHeading())); headerLayer.add(headingLayer); layer.add(getRaceParticipantList(iwc)); add(layer); }
public PresentationObject getChooser(IWContext iwc, IWBundle bundle) { if (useOldLogic) { // Old chooser Table table = new Table(2, 1); table.setCellpadding(0); table.setCellspacing(0); Parameter value = new Parameter(getChooserParameter(), ""); if (this._stringValue != null) { value.setValue(this._stringValue); } table.add(value); PresentationObject object = getPresentationObject(iwc); table.add(new Parameter(VALUE_PARAMETER_NAME, value.getName())); // GenericButton button = new // GenericButton("chooserbutton",bundle.getResourceBundle(iwc).getLocalizedString(chooserText,"Choose")); if (this._addForm) { SubmitButton button = new SubmitButton(this._iwrb.getLocalizedString("choose", "Choose")); table.add(button, 2, 1); this._form.addParameter(CHOOSER_SELECTION_PARAMETER, getChooserParameter()); this._form.addParameter( FORM_ID_PARAMETER, "window.opener.document.getElementById(\"" + this._form.getID() + "\")."); this._form.addParameter(SCRIPT_SUFFIX_PARAMETER, "value"); if (this.filter != null) { if (this.filter.length() > 0) { this._form.addParameter(FILTER_PARAMETER, this.filter); } } addParametersToForm(this._form); } else { getLink(this._iwrb); if (getUsePublicWindowOpener()) { this.link.setPublicWindowToOpen(getChooserWindowClass()); } else { this.link.setWindowToOpen(getChooserWindowClass()); } this.link.addParameter(CHOOSER_SELECTION_PARAMETER, getChooserParameter()); this.link.addParameter(FORM_ID_PARAMETER, getParentFormID()); // TODO Make the javascript work for other objects than form elements, // e.g. a Link /* * if(object instanceof Layer){ * link.addParameter(SCRIPT_SUFFIX_PARAMETER,"title"); } */ this.link.addParameter(SCRIPT_SUFFIX_PARAMETER, "value"); // } // this was object.getID() but the id could change if this object was kept in session but // the form changed // by using getName() the reference is not lost, however we might need to add extra steps // for handling more than one // chooser of the same type in the same form. this.link.addParameter(DISPLAYSTRING_PARAMETER_NAME, object.getName()); this.link.addParameter(VALUE_PARAMETER_NAME, value.getName()); if (this._attributeName != null && this._attributeValue != null) { this.link.addParameter(this._attributeName, this._attributeValue); } if (this.filter != null) { if (this.filter.length() > 0) { this.link.addParameter(FILTER_PARAMETER, this.filter); } } addParametersToLink(this.link); table.add(this.link, 2, 1); } table.add(object, 1, 1); table.add(new Parameter(DISPLAYSTRING_PARAMETER_NAME, "151324213")); return (table); } else { // New chooser Layer container = new Layer(); String chooserObject = getChooserHelperVarName(); if (chooserObject == null) { chooserObject = AbstractChooserBlock.GLOBAL_HELPER_NAME; } else { add( PresentationUtil.getJavaScriptAction( PresentationUtil.getJavaScriptLinesLoadedLazily( CoreUtil.getResourcesForChooser(iwc), new StringBuilder("if (!") .append(chooserObject) .append(") var ") .append(chooserObject) .append(" = new ChooserHelper();") .toString()))); } PresentationObject object = getPresentationObject(iwc); container.add(object); Image chooser = getChooser(bundle); chooser.setStyleClass("chooserStyle"); chooser.setMarkupAttribute("choosername", chooserObject); // OnClick action StringBuffer action = new StringBuffer("addChooserObject('").append(chooser.getId()).append("', '"); action.append(getChooserWindowClass().getName()); if (getHiddenInputAttribute() == null) { action.append("', null, '"); } else { action.append("', '").append(getHiddenInputAttribute()).append("', '"); } action.append(ICBuilderConstants.CHOOSER_VALUE_VIEWER_ID_ATTRIBUTE).append("', '"); action .append(getResourceBundle().getLocalizedString("loading", "Loading...")) .append("', ") .append( _stringValue == null ? "null" : new StringBuilder("'").append(_stringValue).append("'").toString()) .append(", ") .append( _stringDisplay == null ? "null" : new StringBuilder("'").append(_stringDisplay).append("'").toString()) .append(");"); chooser.setOnClick(action.toString()); container.add(chooser); return container; } }
public UIComponent getOverviewForm() { Form myForm = new Form(); myForm.setName(prmForm); Table T = new Table(3, 3); T.setCellpadding(0); T.setCellspacing(0); T.setBorder(0); T.setBorderColor("#000000"); T.setVerticalAlignment(1, 1, Table.VERTICAL_ALIGN_TOP); T.setVerticalAlignment(3, 1, Table.VERTICAL_ALIGN_TOP); // T.setVerticalAlignment(1, 4, Table.VERTICAL_ALIGN_BOTTOM); // T.add(getNavigationTree(iwc), 1, 1); T.add(getNavigationTree(), 1, 1); // T.add(getInfoLayer(), 2, 1); T.add(new Break(3), 3, 1); // T.setHeight(1, 3, "130"); // T.setHeight(1, 4, "90"); T.setWidth(2, 1, "40"); myForm.add(T); Page pVisit = this.getParentPage(); if (pVisit != null) { Script S = pVisit.getAssociatedScript(); // pVisit.setOnLoad("setRowColor(document.getElementById('inf1_1'));"); S.addFunction("setRowColor(obj)", setRowColorScript()); S.addFunction("showHideLayer(obj)", showHideLayerScript()); Script timeScript = myForm.getAssociatedFormScript(); if (timeScript == null) { timeScript = new Script(); myForm.setAssociatedFormScript(timeScript); } } ArrayList texts1 = new ArrayList(); ArrayList texts2 = new ArrayList(); if (age != null && age.getYears() >= 70) { texts1.add(localize(keySet1Text1U1, "Texten")); texts1.add(localize(keySet1Text2U1, "Texten")); texts1.add(localize(keySet1Text3U1, "Texten")); texts1.add(localize(keySet1Text4U1, "Texten")); texts1.add(localize(keySet1Text5U1, "Texten")); texts2.add(localize(keySet2Text1U1, "Texten")); texts2.add(localize(keySet2Text2U1, "Texten")); texts2.add(localize(keySet2Text3U1, "Texten")); texts2.add(localize(keySet2Text4U1, "Texten")); texts2.add(localize(keySet2Text5U1, "Texten")); } else { texts1.add(localize(keySet1Text1U2, "Texten")); texts1.add(localize(keySet1Text2U2, "Texten")); texts1.add(localize(keySet1Text3U2, "Texten")); texts1.add(localize(keySet1Text4U2, "Texten")); texts1.add(localize(keySet1Text5U2, "Texten")); texts2.add(localize(keySet2Text1U2, "Texten")); texts2.add(localize(keySet2Text2U2, "Texten")); texts2.add(localize(keySet2Text3U2, "Texten")); texts2.add(localize(keySet2Text4U2, "Texten")); texts2.add(localize(keySet2Text5U2, "Texten")); } Layer layerOut = new Layer(Layer.DIV); layerOut.setVisibility("visible"); layerOut.setOverflow("scroll"); layerOut.setPositionType("absolute"); layerOut.setWidth("280"); layerOut.setHeight("170"); layerOut.setMarkupAttribute("class", "ehealth_div"); Layer layer = new Layer(Layer.DIV); layer.setVisibility("hidden"); layer.setOverflow("hidden"); layer.setPositionType("absolute"); layer.setWidth("250"); layer.setHeight("145"); layer.setMarkupAttribute("class", "ehealth_div_no_border"); int theRow = 1; int i = 1; Iterator iter1 = texts1.iterator(); Iterator iter2 = texts2.iterator(); while (iter1.hasNext()) { Layer layers = (Layer) layer.clone(); layers.setID("info" + i + "_" + theRow); String text = (String) iter1.next(); layers.add(text); layerOut.add(layers); theRow++; } i++; theRow = 1; while (iter2.hasNext()) { Layer layers = (Layer) layer.clone(); layers.setID("info" + i + "_" + theRow); String text = (String) iter2.next(); layers.add(text); layerOut.add(layers); theRow++; } T.add(layerOut, 3, 1); return myForm; }
private Layer getInfoLayer(int theCase) { Layer layerInfo = new Layer(Layer.DIV); // layerInfo.setOverflow("hidden"); // layerInfo.setVisibility("hidden"); layerInfo.setPositionType("relative"); layerInfo.setWidth("270"); layerInfo.setHeight("100"); layerInfo.setStyleClass("ehealth_row_outer_div"); Table tableInfo = new Table(1, 10); tableInfo.setNoWrap(); tableInfo.setCellpadding(0); tableInfo.setCellspacing(0); tableInfo.setBorder(0); // tableInfo.setWidth(200); int column = 1; tableInfo.setWidth(column, 1, "200"); // tableInfo.setWidth(column++, 1, "70"); Image transpImg = Table.getTransparentCell(_iwc); transpImg.setWidth(15); transpImg.setHeight(16); Layer layer = new Layer(Layer.DIV); layer.setOnMouseOver("setRowColor(this);"); layer.setPositionType("relative"); // layer.setHeight(20); layer.setStyleClass("ehealth_row_div"); Image corners = getBundle(_iwc).getImage("thirdLevel.gif"); corners.setBorder(0); corners.setHeight(16); corners.setWidth(19); layer.setBackgroundImage(corners); int theRow = 1; ArrayList cases = new ArrayList(); if (age != null && age.getYears() >= 70) { if (theCase == 1) { cases.add("Vårdplats:"); cases.add("Journalanteckningar:"); cases.add("Remisser och svar:"); // cases.add("Läkemedel:"); } else if (theCase == 2) { cases.add("Vårdplats:"); cases.add("Journalanteckningar:"); cases.add("Remisser och svar:"); } } else { if (theCase == 1) { cases.add("Vårdplats:"); cases.add("Journalanteckningar:"); // cases.add("Läkemedel:"); } else if (theCase == 2) { cases.add("Vårdplats:"); cases.add("Journalanteckningar:"); // cases.add("Läkemedel:"); } } Iterator iter = cases.iterator(); while (iter.hasNext()) { Layer layers = (Layer) layer.clone(); layers.setID("inf" + theCase + "_" + theRow); String text = (String) iter.next(); layers.add(text); tableInfo.add(layers, column, theRow); theRow++; } layerInfo.add(tableInfo); return layerInfo; }
@SuppressWarnings("unchecked") @Override protected void initializeComponent(FacesContext context) { ELUtil.getInstance().autowire(this); iwc = IWContext.getIWContext(context); if (!iwc.isLoggedOn()) { return; } if (userId == null) { userId = iwc.getCurrentUserId(); } // HtmlTag div = new // HtmlTag();//(HtmlTag)context.getApplication().createComponent(HtmlTag.COMPONENT_TYPE); // getChildren().add(div); // div.setValue(divTag); Layer main = new Layer(); this.add(main); IWBundle bundle = getBundle(context, IWBundleStarter.IW_BUNDLE_IDENTIFIER); iwrb = bundle.getResourceBundle(iwc); if (groupId == null) { Label label = new Label(); main.add(label); label.addText(iwrb.getLocalizedString("no_group_set", "No group set")); return; } Group group = null; Collection<Group> groups = null; try { group = this.getUserBusiness().getGroupBusiness().getGroupByGroupID(Integer.valueOf(groupId)); groups = this.getUserBusiness().getUserGroups(userId); } catch (Exception e) { Logger.getLogger(this.getClass().getName()) .log(Level.WARNING, "failed getting groups by ids", e); } GenericButton joinButton = new GenericButton(); main.add(joinButton); GenericButton leaveButton = new GenericButton(); main.add(leaveButton); StringBuilder parameters = new StringBuilder() .append(this.userId) .append(CoreConstants.JS_STR_PARAM_SEPARATOR) .append(this.groupId) .append("','#") .append(joinButton.getId()) .append("','#") .append(leaveButton.getId()) .append(CoreConstants.JS_STR_PARAM_END); joinButton.setValue(iwrb.getLocalizedString("join", "Join")); String action = new StringBuilder("GroupJoinerHelper.joinGroup('").append(parameters).toString(); joinButton.setOnClick(action); leaveButton.setValue(iwrb.getLocalizedString("leave", "Leave")); action = new StringBuilder("GroupJoinerHelper.leaveGroup('").append(parameters).toString(); leaveButton.setOnClick(action); if (groups.contains(group)) { joinButton.setStyleAttribute("display : none;"); } else { leaveButton.setStyleAttribute("display : none;"); } addActions(main); }
private void listExisting(IWContext iwc) throws FinderException, RemoteException { getApplicationBusiness(iwc).checkApplicationCategoryPriorityConstraint(); Collection categories = getApplicationBusiness(iwc).getApplicationCategoryHome().findAllOrderedByPriority(); Form form = new Form(); form.setID("applicationCategoryCreator"); form.setStyleClass("adminForm"); Table2 table = new Table2(); table.setWidth("100%"); table.setCellpadding(0); table.setCellspacing(0); table.setStyleClass("ruler"); table.setStyleClass("adminTable"); form.add(table); TableRowGroup group = table.createHeaderRowGroup(); TableRow row = group.createRow(); TableCell2 cell = row.createHeaderCell(); cell.setStyleClass("firstColumn"); cell.setStyleClass("category"); cell.add(new Text(this.iwrb.getLocalizedString("category", "Category"))); cell = row.createHeaderCell(); cell.setStyleClass("description"); cell.add(new Text(this.iwrb.getLocalizedString("description", "Description"))); cell = row.createHeaderCell(); cell.setStyleClass("description"); cell.add(new Text(this.iwrb.getLocalizedString("priority", "Priority"))); cell = row.createHeaderCell(); cell.setStyleClass("edit"); cell.add(Text.getNonBrakingSpace()); cell = row.createHeaderCell(); cell.setStyleClass("remove"); cell.setStyleClass("lastColumn"); cell.add(Text.getNonBrakingSpace()); group = table.createBodyRowGroup(); int iRow = 1; Iterator iter = categories.iterator(); while (iter.hasNext()) { ApplicationCategory cat = (ApplicationCategory) iter.next(); row = table.createRow(); Link edit = new Link(this.iwb.getImage("edit.png", this.iwrb.getLocalizedString("edit", "Edit"))); edit.addParameter(PARAMETER_ACTION, ACTION_EDIT); edit.addParameter("id", cat.getPrimaryKey().toString()); Link delete = new Link( this.iwb.getImage("delete.png", this.iwrb.getLocalizedString("remove", "Remove"))); delete.addParameter(PARAMETER_ACTION, ACTION_DELETE); delete.addParameter("id", cat.getPrimaryKey().toString()); if (iRow % 2 == 0) { row.setStyleClass("evenRow"); } else { row.setStyleClass("oddRow"); } cell = row.createCell(); cell.setStyleClass("firstColumn"); cell.setStyleClass("category"); cell.add(new Text(cat.getName())); cell = row.createCell(); cell.setStyleClass("description"); if (cat.getDescription() != null) { String description = cat.getDescription(); if (description.length() > 35) { description = description.substring(0, 35) + "..."; } cell.add(new Text(description)); } else { cell.add(new Text(Text.NON_BREAKING_SPACE)); } cell = row.createCell(); cell.setStyleClass("description"); Link up = new Link( this.iwb.getImage("previous.png", this.iwrb.getLocalizedString("previous", "Up"))); up.addParameter(PARAMETER_ACTION, ACTION_CATEGORY_UP); up.addParameter("id", cat.getPrimaryKey().toString()); up.setStyleClass("flippedImageLink"); cell.add(up); if (iRow <= 1) { up.setStyleAttribute("visibility", "hidden"); } Link down = new Link(this.iwb.getImage("next.png", this.iwrb.getLocalizedString("next", "Down"))); down.addParameter(PARAMETER_ACTION, ACTION_CATEGORY_DOWN); down.addParameter("id", cat.getPrimaryKey().toString()); down.setStyleClass("flippedImageLink"); cell.add(down); if (iRow >= categories.size()) { down.setStyleAttribute("visibility", "hidden"); } cell = row.createCell(); cell.setStyleClass("edit"); cell.add(edit); cell = row.createCell(); cell.setStyleClass("lastColumn"); cell.setStyleClass("remove"); cell.add(delete); iRow++; } Layer buttonLayer = new Layer(Layer.DIV); buttonLayer.setStyleClass("buttonLayer"); form.add(buttonLayer); SubmitButton newLink = new SubmitButton( this.iwrb.getLocalizedString("new_category", "New Category"), PARAMETER_ACTION, ACTION_CREATE); buttonLayer.add(newLink); add(form); }
/** * this method creates the form for creating new categories as well as editing the properties of * existing ones, plus it allows to see all the applications within this category and change their * display ordering * * @throws RemoteException */ private void getCategoryCreationForm( IWContext iwc, ApplicationCategory cat, List<ICLocale> locales) throws RemoteException { if (cat != null) { getApplicationBusiness(iwc).checkApplicationPriorityConstraint(cat); } Form form = new Form(); form.setID("applicationCategoryCreator"); form.setStyleClass("adminForm"); TextInput tName = new TextInput("name"); TextArea tDesc = new TextArea("desc"); if (cat != null) { tName.setContent(cat.getName()); tDesc.setContent(cat.getDescription()); form.addParameter("id", cat.getPrimaryKey().toString()); } Layer layer = new Layer(Layer.DIV); layer.setStyleClass("formSection"); form.add(layer); Layer formItem = new Layer(Layer.DIV); formItem.setStyleClass("formItem"); Label label = new Label(this.iwrb.getLocalizedString("default_name", "Default name"), tName); formItem.add(label); formItem.add(tName); layer.add(formItem); formItem = new Layer(Layer.DIV); formItem.setStyleClass("formItem"); label = new Label( this.iwrb.getLocalizedString("default_description", "Default description"), tDesc); formItem.add(label); formItem.add(tDesc); layer.add(formItem); for (Iterator<ICLocale> it = locales.iterator(); it.hasNext(); ) { ICLocale locale = it.next(); Locale javaLocale = ICLocaleBusiness.getLocaleFromLocaleString(locale.getLocale()); TextInput locInput = new TextInput(locale.getName() + "_locale"); if (cat != null) { LocalizedText text = cat.getLocalizedText(locale.getLocaleID()); locInput.setValue(text == null ? "" : text.getBody()); } formItem = new Layer(Layer.DIV); formItem.setStyleClass("formItem"); label = new Label(javaLocale.getDisplayLanguage(), locInput); formItem.add(label); formItem.add(locInput); layer.add(formItem); } List apps = null; if (cat != null) { try { apps = new ArrayList( getApplicationBusiness(iwc) .getApplicationHome() .findAllByCategoryOrderedByPriority(cat)); } catch (FinderException f) { f.printStackTrace(); } } if (apps != null && !apps.isEmpty()) { Table2 table = new Table2(); table.setWidth("100%"); table.setCellpadding(0); table.setCellspacing(0); table.setStyleClass("ruler"); table.setStyleClass("adminTable"); TableRowGroup group = table.createHeaderRowGroup(); TableRow row = group.createRow(); TableCell2 cell = row.createHeaderCell(); cell.setStyleClass("firstColumn"); cell.setStyleClass("application"); cell.add(new Text(this.iwrb.getLocalizedString("application", "Application"))); cell = row.createHeaderCell(); cell.setStyleClass("description"); cell.add(new Text(this.iwrb.getLocalizedString("priority", "Priority"))); group = table.createBodyRowGroup(); int iRow = 1; Iterator iter = apps.iterator(); while (iter.hasNext()) { Application app = (Application) iter.next(); row = table.createRow(); if (iRow % 2 == 0) { row.setStyleClass("evenRow"); } else { row.setStyleClass("oddRow"); } cell = row.createCell(); cell.setStyleClass("firstColumn"); cell.setStyleClass("application"); cell.add(new Text(app.getName())); cell = row.createCell(); cell.setStyleClass("description"); cell.setStyleClass("lastColumn"); Link up = new Link( this.iwb.getImage("previous.png", this.iwrb.getLocalizedString("previous", "Up"))); up.addParameter(PARAMETER_ACTION, ACTION_APP_UP); up.addParameter("app_id", app.getPrimaryKey().toString()); up.addParameter("id", cat.getPrimaryKey().toString()); up.setStyleClass("flippedImageLink"); cell.add(up); if (iRow <= 1) { up.setStyleAttribute("visibility", "hidden"); } Link down = new Link(this.iwb.getImage("next.png", this.iwrb.getLocalizedString("next", "Down"))); down.addParameter(PARAMETER_ACTION, ACTION_APP_DOWN); down.addParameter("app_id", app.getPrimaryKey().toString()); down.addParameter("id", cat.getPrimaryKey().toString()); down.setStyleClass("flippedImageLink"); cell.add(down); if (iRow >= apps.size()) { down.setStyleAttribute("visibility", "hidden"); } iRow++; } Layer clearLayer = new Layer(Layer.DIV); clearLayer.setStyleClass("Clear"); layer.add(clearLayer); form.add(table); } Layer buttonLayer = new Layer(Layer.DIV); buttonLayer.setStyleClass("buttonLayer"); form.add(buttonLayer); SubmitButton back = new SubmitButton(this.iwrb.getLocalizedString("back", "Back"), PARAMETER_ACTION, "list"); buttonLayer.add(back); SubmitButton save = new SubmitButton(this.iwrb.getLocalizedString("save", "Save"), PARAMETER_ACTION, "save"); buttonLayer.add(save); add(form); }