use of com.google.gwt.user.client.ui.FlexTable.FlexCellFormatter in project perun by CESNET.
the class EditFormItemTabItem method basicInformationTab.
/**
* Returns flex table with basic information and textboxes
*
* @return
*/
private Widget basicInformationTab() {
// item application types
ArrayList<String> itemApplicationTypes = JsonUtils.listFromJsArrayString(item.getApplicationTypes());
// federation attributes to select from
federationAttributes.addItem("No item selected (empty value)", "");
federationAttributes.addItem("Display name", "displayName");
federationAttributes.addItem("Common name", "cn");
federationAttributes.addItem("Mail", "mail");
federationAttributes.addItem("Organization", "o");
federationAttributes.addItem("Level of Assurance (LoA)", "loa");
federationAttributes.addItem("First name", "givenName");
federationAttributes.addItem("Sure name", "sn");
federationAttributes.addItem("EPPN", "eppn");
federationAttributes.addItem("IdP Category", "md_entityCategory");
federationAttributes.addItem("IdP Affiliation", "affiliation");
federationAttributes.addItem("EduPersonScopedAffiliation", "eduPersonScopedAffiliation");
federationAttributes.addItem("schacHomeOrganization", "schacHomeOrganization");
// application types
GetAttributesDefinition attrDef = new GetAttributesDefinition(new JsonCallbackEvents() {
@Override
public void onError(PerunError error) {
perunDestinationAttributeListBox.clear();
perunDestinationAttributeListBox.addItem("No item selected (empty value)", "");
if (item.getPerunDestinationAttribute() != null && !item.getPerunDestinationAttribute().isEmpty()) {
// add and select returned perun dest attr
perunDestinationAttributeListBox.addItem(item.getPerunDestinationAttribute(), item.getPerunDestinationAttribute());
perunDestinationAttributeListBox.setSelectedIndex(1);
}
}
@Override
public void onFinished(JavaScriptObject jso) {
// clear
perunDestinationAttributeListBox.clear();
// set empty possibility
perunDestinationAttributeListBox.addItem("No item selected (empty value)", "");
ArrayList<AttributeDefinition> list = JsonUtils.jsoAsList(jso);
if (list != null && !list.isEmpty()) {
// sort
list = new TableSorter<AttributeDefinition>().sortByFriendlyName(list);
for (AttributeDefinition def : list) {
// add only member and user attributes
if (def.getEntity().equalsIgnoreCase("user") || def.getEntity().equalsIgnoreCase("member")) {
perunDestinationAttributeListBox.addItem(def.getFriendlyName() + " (" + def.getEntity() + " / " + def.getDefinition() + ")", def.getName());
}
}
} else {
// no attr def loaded, keep as it is set
if (item.getPerunDestinationAttribute() != null && !item.getPerunDestinationAttribute().isEmpty()) {
perunDestinationAttributeListBox.addItem(item.getPerunDestinationAttribute(), item.getPerunDestinationAttribute());
}
}
// set selected
for (int i = 0; i < perunDestinationAttributeListBox.getItemCount(); i++) {
// set proper value as "selected"
if (perunDestinationAttributeListBox.getValue(i).equalsIgnoreCase(item.getPerunDestinationAttribute())) {
perunDestinationAttributeListBox.setSelectedIndex(i);
break;
}
}
}
@Override
public void onLoadingStart() {
perunDestinationAttributeListBox.addItem("Loading...");
}
});
// layout
FlexTable ft = new FlexTable();
ft.setStyleName("inputFormFlexTable");
FlexCellFormatter ftf = ft.getFlexCellFormatter();
// fill values
shortNameTextBox.setText(item.getShortname());
for (int i = 0; i < federationAttributes.getItemCount(); i++) {
if (federationAttributes.getValue(i).equals(item.getFederationAttribute())) {
federationAttributes.setSelectedIndex(i);
break;
}
}
requiredCheckBox.setValue(item.isRequired());
regexTextBox.setText(item.getRegex());
for (Application.ApplicationType type : Application.ApplicationType.values()) {
CheckBox cb = new CheckBox();
boolean checked = itemApplicationTypes.contains(type.toString());
cb.setValue(checked);
applicationTypesCheckBoxes.add(cb);
}
// sizes
shortNameTextBox.setWidth("200px");
federationAttributes.setWidth("200px");
perunDestinationAttributeListBox.setWidth("300px");
regexTextBox.setWidth("200px");
// basic info
int row = 0;
Label shortNameLabel = new Label("Short name:");
ft.setWidget(row, 0, shortNameLabel);
ft.setWidget(row, 1, shortNameTextBox);
row++;
ft.setHTML(row, 1, "Internal item identification (used as fallback when you forgot to set \"Label\" for some language).");
ftf.setStyleName(row, 1, "inputFormInlineComment");
row++;
Label inputLabel = new Label("Input widget:");
ft.setWidget(row, 0, inputLabel);
ft.setHTML(row, 1, CreateFormItemTabItem.inputTypes.get(item.getType()));
row++;
ft.setHTML(row, 1, "Specify what input widget is used for this item.");
ftf.setStyleName(row, 1, "inputFormInlineComment");
// set colspan for tops
for (int i = 0; i < ft.getRowCount(); i++) {
ftf.setColSpan(i, 1, 2);
}
row++;
Label l = new Label("Display on application:");
l.setTitle("");
ft.setWidget(row, 0, l);
ftf.setWidth(row, 0, "160px");
Application.ApplicationType.values();
int i = 0;
for (Application.ApplicationType type : Application.ApplicationType.values()) {
CheckBox cb = applicationTypesCheckBoxes.get(i);
cb.setText(Application.getTranslatedType(type.toString()));
if (type.equals(Application.ApplicationType.INITIAL)) {
cb.setTitle("If checked, display form item on INITIAL application");
} else {
cb.setTitle("If checked, display form item on EXTENSION application");
}
ft.setWidget(row, i + 1, cb);
i++;
}
row++;
ft.setHTML(row, 1, "Define on which application types is this item displayed.");
ftf.setStyleName(row, 1, "inputFormInlineComment");
ftf.setColSpan(row, 1, 2);
row++;
// IF BUTTON OR COMMENT, don't show these
if (!item.getType().equals("SUBMIT_BUTTON") && !item.getType().equals("AUTO_SUBMIT_BUTTON") && !item.getType().equals("HTML_COMMENT") && !item.getType().equals("HEADING")) {
// load attr defs only when showed
attrDef.retrieveData();
Label requiredLabel = new Label("Required:");
ft.setWidget(row, 0, requiredLabel);
ft.setWidget(row, 1, requiredCheckBox);
ftf.setColSpan(row, 1, 2);
row++;
ft.setHTML(row, 1, "If checked, user can`t submit empty value (doesn't apply to non-editable fields).");
ftf.setStyleName(row, 1, "inputFormInlineComment");
ftf.setColSpan(row, 1, 2);
row++;
Label destAttrLabel = new Label("Destination attribute:");
ft.setWidget(row, 0, destAttrLabel);
ft.setWidget(row, 1, perunDestinationAttributeListBox);
ftf.setColSpan(row, 1, 2);
row++;
ft.setHTML(row, 1, "Select attribute, where will be submitted value stored after accepting user`s application and where is taken to pre-fill the form.");
ftf.setStyleName(row, 1, "inputFormInlineComment");
ftf.setColSpan(row, 1, 2);
row++;
Label fedAttrLabel = new Label("Federation attribute:");
ft.setWidget(row, 0, fedAttrLabel);
ft.setWidget(row, 1, federationAttributes);
ftf.setColSpan(row, 1, 2);
row++;
ft.setHTML(row, 1, "Select federation attribute to get pre-filed value from.");
ftf.setStyleName(row, 1, "inputFormInlineComment");
ftf.setColSpan(row, 1, 2);
if (!item.getType().equals("VALIDATED_EMAIL") && !item.getType().equals("TIMEZONE")) {
row++;
Label regexLabel = new Label("Regular expression:");
ft.setWidget(row, 0, regexLabel);
ft.setWidget(row, 1, regexTextBox);
ftf.setColSpan(row, 1, 2);
row++;
ft.setHTML(row, 1, "Regular expression used for item value validation (before submitting by user).");
ftf.setStyleName(row, 1, "inputFormInlineComment");
ftf.setColSpan(row, 1, 2);
}
}
// set styles
for (int n = 0; n < ft.getRowCount(); n++) {
ftf.setStyleName(n, 0, "itemName");
}
// scroll panel
ScrollPanel sp = new ScrollPanel(ft);
sp.addStyleName("perun-tableScrollPanel");
sp.setSize("560px", "320px");
sp.scrollToTop();
return sp;
}
use of com.google.gwt.user.client.ui.FlexTable.FlexCellFormatter in project perun by CESNET.
the class EditMailTabItem method basicInformationTab.
/**
* Returns flex table with basic information
*
* @return
*/
private Widget basicInformationTab() {
VerticalPanel vp = new VerticalPanel();
vp.setSize("500px", "350px");
vp.setSpacing(10);
// layout
FlexTable ft = new FlexTable();
ft.setStyleName("inputFormFlexTable");
FlexCellFormatter ftf = ft.getFlexCellFormatter();
vp.add(ft);
vp.add(new HTML(" "));
// basic info
int row = 0;
ft.setHTML(row, 0, "E-mail type:");
ft.setHTML(row, 1, ApplicationMail.getTranslatedMailType(appMail.getMailType()));
ftf.setStyleName(row, 0, "itemName");
row++;
ft.setHTML(row, 1, "Type of notification (action which trigger sending and who is notified).");
ftf.setStyleName(row, 1, "inputFormInlineComment");
row++;
ft.setHTML(row, 0, "Application type: ");
ft.setHTML(row, 1, Application.getTranslatedType(appMail.getAppType()));
ftf.setStyleName(row, 0, "itemName");
ftf.setWidth(row, 0, "120px");
row++;
ft.setHTML(row, 1, "Application type which will trigger sending.");
ftf.setStyleName(row, 1, "inputFormInlineComment");
row++;
sendingEnabledCheckBox.setValue(appMail.isSend());
ft.setHTML(row, 0, "Sending enabled:");
ft.setWidget(row, 1, sendingEnabledCheckBox);
ftf.setStyleName(row, 0, "itemName");
row++;
ft.setHTML(row, 1, "If checked, notification will be sent. Un-check it to temporary disable sending.");
ftf.setStyleName(row, 1, "inputFormInlineComment");
return vp;
}
use of com.google.gwt.user.client.ui.FlexTable.FlexCellFormatter in project perun by CESNET.
the class EditMailTabItem method availableTagsTab.
/**
* Returns flex table with available tags
*
* @return
*/
private Widget availableTagsTab() {
VerticalPanel vp = new VerticalPanel();
vp.setSize("500px", "350px");
vp.setSpacing(10);
// layout
FlexTable ft = new FlexTable();
ft.setStyleName("inputFormFlexTable");
FlexCellFormatter ftf = ft.getFlexCellFormatter();
ScrollPanel sp = new ScrollPanel(ft);
sp.addStyleName("perun-tableScrollPanel");
sp.setSize("100%", "300px");
vp.add(sp);
vp.add(new HTML(" "));
ft.setHTML(0, 0, "Following tags can be used in mail's subject and text and are replaced by actual data on sending. Just copy/paste tags from here to input form. When no data for tag is found, it's replaced by whitespace.");
ftf.addStyleName(0, 0, "inputFormInlineComment");
HTML text = new HTML("<strong><u>Application related:</u></strong>" + "<p><strong>{appId}</strong> - application ID" + "<br/><strong>{actor}</strong> - user's login used when submitting application" + "<br/><strong>{extSource}</strong> - user's identity provider when submitting application" + "<br/><strong>{voName}</strong> - name of VO of application form" + "<br/><strong>{groupName}</strong> - name of group, if application form is for group membership" + "<br/><strong>{mailFooter}</strong> - common mail footer defined by VO" + "<br/><strong>{errors}</strong> - errors description, what happened while processing new application. Useful for VO administrators." + "<br/><strong>{customMessage}</strong> - optional message passed by administrators when rejecting an application" + "<p><strong><u>User related:</u></strong>" + "<p><strong>{firstName}</strong> - users first name taken from application form or Perun" + "<br/><strong>{lastName}</strong> - users last name taken from application form or Perun" + "<br/><strong>{displayName}</strong> - users display name taken from application form or Perun" + "<br/><strong>{mail}</strong> - users preferred mail from application form or Perun" + "<br/><strong>{login-<i>namespace</i>}</strong> - user's login in selected namespace, taken from registration form or Perun. You MUST specify the namespace, e.g. <i>{login-einfra}</i> will print user's login in einfra namespace." + "<br/><strong>{membershipExpiration}</strong> - membership expiration date decided after membership creation or extension." + "<p><strong><u>Validation links for users:</u></strong>" + "<p><span class=\"inputFormInlineComment\">Works only for \"Mail validation / user \" mail type! Used to verify email address provided by users => verify application.</span>" + "<p><strong>{validationLink}</strong> - link for email address verification. Please make sure you set \"Registrar URL\" setting of your VO/group. " + "If you don't specify authorization in \"Registrar URL\", you can use following options: " + "<p><strong>{validationLink-krb}</strong> - link for Kerberos authentication" + "<br/><strong>{validationLink-fed}</strong> - link for Shibboleth IdP (federation) authentication" + "<br/><strong>{validationLink-cert}</strong> - link for personal certificate authentication" + "<br/><strong>{validationLink-non}</strong> - link without any authentication" + "<p><strong><u>Application GUI links for users:</u></strong>" + "<p><span class=\"inputFormInlineComment\">Used to navigate users to the list of theirs applications.</span>" + "<p><strong>{appGuiUrl}</strong> - link to overview of submitted registrations for users. Please make sure you set \"Registrar URL\" setting of your VO/group. " + "If you don't specify authorization in \"Registrar URL\", you can use following options: " + "<p><strong>{appGuiUrl-krb}</strong> - link for Kerberos authentication" + "<br/><strong>{appGuiUrl-fed}</strong> - link for Shibboleth IdP (federation) authentication" + "<br/><strong>{appGuiUrl-cert}</strong> - link for personal certificate authentication" + "<br/><strong>{appGuiUrl-non}</strong> - link without any authentication" + "<p><strong><u>Application GUI links for administrators:</u></strong>" + "<p><span class=\"inputFormInlineComment\">Used to navigate administrators to the registration detail, where they can check and approve or reject the application.</span>" + "<p><strong>{appDetailUrl}</strong> - link to registration detail in administrative GUI. Please make sure you set \"Registrar URL\" setting of your VO/group. " + "If you don't specify authorization in \"Registrar URL\", you can use following options: " + "<p><strong>{appDetailUrl-krb}</strong> - link for Kerberos authentication" + "<br/><strong>{appDetailUrl-fed}</strong> - link for Shibboleth IdP (federation) authentication" + "<br/><strong>{appDetailUrl-cert}</strong> - link for personal certificate authentication" + "<p><strong><u>Perun GUI links for administrators:</u></strong>" + "<p><span class=\"inputFormInlineComment\">Used to navigate administrators to the administrative GUI of Perun. Can be used for users to locate user detail too.</span>" + "<p><strong>{perunGuiUrl}</strong> - link to administrative GUI. Please make sure you set \"Registrar URL\" setting of your VO/group. " + "If you don't specify authorization in \"Registrar URL\", you can use following options: " + "<p><strong>{perunGuiUrl-krb}</strong> - link for Kerberos authentication" + "<br/><strong>{perunGuiUrl-fed}</strong> - link for Shibboleth IdP (federation) authentication" + "<br/><strong>{perunGuiUrl-cert}</strong> - link for personal certificate authentication" + "<p><strong><u>User invitations:</u></strong>" + "<p><span class=\"inputFormInlineComment\">Following tags can be used on user invitation template</span>" + "<p><strong>{voName}</strong> - name of VO to invite user into" + "<br/><strong>{groupName}</strong> - name of Group to invite user into" + "<br/><strong>{displayName}</strong> - invited user's name" + "<br/><strong>{mailFooter}</strong> - common mail footer defined by VO" + "<p><strong>{invitationLink}</strong> - link to registration form. Please make sure you set \"Registrar URL\" setting of your VO/group. " + "If you don't specify authorization in \"Registrar URL\", you can use following options: " + "<p><strong>{invitationLink-krb}</strong> - link for Kerberos authentication" + "<br/><strong>{invitationLink-fed}</strong> - link for Shibboleth IdP (federation) authentication" + "<br/><strong>{invitationLink-cert}</strong> - link for personal certificate authentication" + "<br/><strong>{invitationLink-non}</strong> - link without any authentication");
text.getElement().setAttribute("style", "line-height: 1.5em !important;");
ft.setWidget(1, 0, text);
return vp;
}
use of com.google.gwt.user.client.ui.FlexTable.FlexCellFormatter in project perun by CESNET.
the class EditMailTabItem method messageTab.
/**
* Returns message texarea
*
* @param locale
* @return
*/
private Widget messageTab(String locale) {
VerticalPanel vp = new VerticalPanel();
vp.setSize("500px", "350px");
vp.setSpacing(10);
// layout
FlexTable ft = new FlexTable();
ft.setStyleName("inputFormFlexTable");
FlexCellFormatter ftf = ft.getFlexCellFormatter();
// inputs
TextBox tb = new TextBox();
tb.setWidth("385px");
messagesSubjects.put(locale, tb);
TextArea ta = new TextArea();
ta.setSize("450px", "190px");
messagesTextAreas.put(locale, ta);
// adds inputs to the flex table
ft.setHTML(0, 0, "Subject:");
ftf.setStyleName(0, 0, "itemName");
ft.setWidget(0, 1, tb);
ftf.setHorizontalAlignment(0, 1, HasHorizontalAlignment.ALIGN_RIGHT);
ft.setHTML(1, 0, "Text:");
ftf.setStyleName(1, 0, "itemName");
//ftf.setColSpan(1, 0, 2);
Anchor a = new Anchor("see available tags >>");
a.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent clickEvent) {
// select last tab
tabPanel.selectTab(tabPanel.getWidgetCount() - 1);
}
});
ft.setWidget(1, 1, a);
ft.setWidget(2, 0, ta);
ftf.setColSpan(2, 0, 2);
vp.add(ft);
vp.add(new HTML(" "));
// fill values
MailText message = appMail.getMessage(locale);
if (message != null) {
ta.setText(message.getText());
tb.setText(message.getSubject());
}
return vp;
}
use of com.google.gwt.user.client.ui.FlexTable.FlexCellFormatter in project perun by CESNET.
the class PreviewFormTabItem method prepareApplicationForm.
/**
* Prepares the widgets from the items as A DISPLAY FOR THE USER
*
* @param sp scroll panel
*/
public void prepareApplicationForm(ScrollPanel sp) {
FlexTable ft = new FlexTable();
ft.setSize("100%", "100%");
ft.setCellPadding(10);
FlexCellFormatter fcf = ft.getFlexCellFormatter();
int i = 0;
for (final ApplicationFormItem item : formItems) {
// skip items not from correct app type
ArrayList<String> itemApplicationTypes = JsonUtils.listFromJsArrayString(item.getApplicationTypes());
if (!itemApplicationTypes.contains(appType))
continue;
// generate correct items
RegistrarFormItemGenerator gen = new RegistrarFormItemGenerator(item, locale);
this.applFormGenerators.add(gen);
gen.addValidationTrigger(new FormValidator() {
public void triggerValidation() {
validateFormValues(false);
}
});
// if button, add onclick
if (item.getType().equals("SUBMIT_BUTTON")) {
this.sendButton = (Button) gen.getWidget();
sendButton.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
// revalidate again, with force validation
if (!validateFormValues(true)) {
return;
}
// sending is disabled
Confirm c = new Confirm("Sending disabled", new Label("Sending form is disabled in preview mode, but form items value validation works."), true);
c.show();
}
});
}
// get localized texts
ItemTexts itemTexts = item.getItemTexts(locale);
if (!gen.isVisible()) {
continue;
}
// WITH LABEL (input box ...)
if (gen.isLabelShown()) {
// 0 = label
if (item.isRequired() == true) {
// required
ft.setHTML(i, 0, "<strong>" + gen.getLabelOrShortname() + "*</strong>");
} else {
// optional
ft.setHTML(i, 0, "<strong>" + gen.getLabelOrShortname() + "</strong>");
}
// 1 = widget
Widget w = gen.getWidget();
w.setTitle(itemTexts.getHelp());
ft.setWidget(i, 1, w);
// 2 = status
ft.setWidget(i, 2, gen.getStatusWidget());
// 3 = HELP
if (itemTexts.getHelp() != null && itemTexts.getHelp().length() > 0) {
Label help = new Label(itemTexts.getHelp());
ft.setWidget(i, 3, help);
}
// format
fcf.setStyleName(i, 0, "applicationFormLabel");
fcf.setStyleName(i, 1, "applicationFormWidget");
fcf.setStyleName(i, 2, "applicationFormCheck");
fcf.setStyleName(i, 3, "applicationFormHelp");
ft.setWidth("100%");
// ELSE HTML COMMENT
} else {
ft.setWidget(i, 0, gen.getWidget());
// colspan = 2
fcf.setColSpan(i, 0, 4);
fcf.setHorizontalAlignment(i, 0, HasHorizontalAlignment.ALIGN_LEFT);
fcf.setVerticalAlignment(i, 0, HasVerticalAlignment.ALIGN_MIDDLE);
}
i++;
}
sp.setWidget(ft);
}
Aggregations