Search in sources :

Example 36 with FlexCellFormatter

use of com.google.gwt.user.client.ui.FlexTable.FlexCellFormatter in project perun by CESNET.

the class EditFacilityDetailsTabItem method draw.

public Widget draw() {
    titleWidget = new Label("Edit facility");
    VerticalPanel vp = new VerticalPanel();
    // textboxes which set the class data when updated
    final ExtendedTextBox nameTextBox = new ExtendedTextBox();
    nameTextBox.getTextBox().setText(facility.getName());
    final TextBox descriptionTextBox = new TextBox();
    descriptionTextBox.setText(facility.getDescription());
    final ExtendedTextBox.TextBoxValidator validator = new ExtendedTextBox.TextBoxValidator() {

        @Override
        public boolean validateTextBox() {
            if (nameTextBox.getTextBox().getText().trim().isEmpty()) {
                nameTextBox.setError("Name can't be empty.");
                return false;
            } else if (!nameTextBox.getTextBox().getText().trim().matches(Utils.FACILITY_NAME_MATCHER)) {
                nameTextBox.setError("Name can contain only letters, numbers, dash, dot and underscore.");
                return false;
            } else {
                nameTextBox.setOk();
                return true;
            }
        }
    };
    nameTextBox.setValidator(validator);
    // prepares layout
    FlexTable layout = new FlexTable();
    layout.setStyleName("inputFormFlexTable");
    FlexCellFormatter cellFormatter = layout.getFlexCellFormatter();
    // close tab events
    final TabItem tab = this;
    TabMenu menu = new TabMenu();
    // send button
    final CustomButton saveButton = TabMenu.getPredefinedButton(ButtonType.SAVE, buttonTranslation.saveFacilityDetails());
    saveButton.addClickHandler(new ClickHandler() {

        public void onClick(ClickEvent event) {
            if (validator.validateTextBox()) {
                Facility fac = JsonUtils.clone(facility).cast();
                fac.setName(nameTextBox.getTextBox().getText().trim());
                fac.setDescription(descriptionTextBox.getText().trim());
                UpdateFacility request = new UpdateFacility(JsonCallbackEvents.closeTabDisableButtonEvents(saveButton, tab, events));
                request.updateFacility(fac);
            }
        }
    });
    // cancel button
    final CustomButton cancelButton = TabMenu.getPredefinedButton(ButtonType.CANCEL, "");
    cancelButton.addClickHandler(new ClickHandler() {

        @Override
        public void onClick(ClickEvent clickEvent) {
            session.getTabManager().closeTab(tab, false);
        }
    });
    // Add some standard form options
    layout.setHTML(0, 0, "Name:");
    layout.setWidget(0, 1, nameTextBox);
    layout.setHTML(1, 0, "Description:");
    layout.setWidget(1, 1, descriptionTextBox);
    for (int i = 0; i < layout.getRowCount(); i++) {
        cellFormatter.addStyleName(i, 0, "itemName");
    }
    menu.addWidget(saveButton);
    menu.addWidget(cancelButton);
    vp.add(layout);
    vp.add(menu);
    vp.setCellHorizontalAlignment(menu, HasHorizontalAlignment.ALIGN_RIGHT);
    this.contentWidget.setWidget(vp);
    return getWidget();
}
Also used : FlexCellFormatter(com.google.gwt.user.client.ui.FlexTable.FlexCellFormatter) ClickEvent(com.google.gwt.event.dom.client.ClickEvent) ExtendedTextBox(cz.metacentrum.perun.webgui.widgets.ExtendedTextBox) ExtendedTextBox(cz.metacentrum.perun.webgui.widgets.ExtendedTextBox) UpdateFacility(cz.metacentrum.perun.webgui.json.facilitiesManager.UpdateFacility) TabMenu(cz.metacentrum.perun.webgui.widgets.TabMenu) TabItem(cz.metacentrum.perun.webgui.tabs.TabItem) ClickHandler(com.google.gwt.event.dom.client.ClickHandler) CustomButton(cz.metacentrum.perun.webgui.widgets.CustomButton) UpdateFacility(cz.metacentrum.perun.webgui.json.facilitiesManager.UpdateFacility) Facility(cz.metacentrum.perun.webgui.model.Facility)

Example 37 with FlexCellFormatter

use of com.google.gwt.user.client.ui.FlexTable.FlexCellFormatter in project perun by CESNET.

the class FormInputStatusWidget method build.

private void build() {
    ft.clear();
    FlexCellFormatter ftf = ft.getFlexCellFormatter();
    Image img;
    String classname = "";
    if (status == Status.OK) {
        img = new Image(SmallIcons.INSTANCE.acceptIcon());
        classname = "input-status-ok";
    } else if (status == Status.ERROR) {
        img = new Image(SmallIcons.INSTANCE.exclamationIcon());
        classname = "input-status-error";
    } else {
        img = new Image(AjaxLoaderImage.SMALL_IMAGE_URL);
        classname = "input-status-loading";
    }
    Label label = new Label(message);
    label.addStyleName(classname);
    label.getElement().setId(classname);
    ft.setWidget(0, 0, img);
    ft.setWidget(0, 1, label);
    ftf.setWidth(0, 0, "25px");
    ftf.setHeight(0, 0, "25px");
    ftf.setVerticalAlignment(0, 0, HasVerticalAlignment.ALIGN_MIDDLE);
    ftf.setVerticalAlignment(0, 1, HasVerticalAlignment.ALIGN_MIDDLE);
}
Also used : FlexCellFormatter(com.google.gwt.user.client.ui.FlexTable.FlexCellFormatter) AjaxLoaderImage(cz.metacentrum.perun.webgui.widgets.AjaxLoaderImage)

Example 38 with FlexCellFormatter

use of com.google.gwt.user.client.ui.FlexTable.FlexCellFormatter in project perun by CESNET.

the class ApplicationFormPage method similarUsersFound.

/**
	 * When similar users found, display a message
	 *
	 * @param users
	 */
protected void similarUsersFound(ArrayList<Identity> users) {
    boolean foundNew = false;
    for (Identity u : users) {
        boolean foundOld = false;
        for (Identity user : foundUsers) {
            if (user.getId() == u.getId()) {
                // was already found
                foundOld = true;
                break;
            }
        }
        // user was not found in old ones
        if (!foundOld) {
            foundNew = true;
            break;
        }
    }
    if (!foundNew)
        return;
    foundUsers = users;
    FlexTable ft = new FlexTable();
    ft.setWidth("600px");
    FlexCellFormatter ftf = ft.getFlexCellFormatter();
    ft.setHTML(0, 0, ApplicationMessages.INSTANCE.similarUsersFoundIsItYou() + "<br /><br />");
    ftf.setColSpan(0, 0, 3);
    ft.setHTML(1, 0, "<strong>" + ApplicationMessages.INSTANCE.name() + "</strong>");
    ft.setHTML(1, 1, "<strong>" + ApplicationMessages.INSTANCE.email() + "</strong>");
    ft.setHTML(1, 2, "<strong>" + ApplicationMessages.INSTANCE.organization() + "</strong>");
    //ft.setHTML(1, 1, "<strong>" + ApplicationMessages.INSTANCE.identities() +"</strong>");
    int i = 2;
    for (Identity user : users) {
        ft.setHTML(i, 0, user.getName());
        ft.setHTML(i, 1, (user.getEmail() != null && !user.getEmail().isEmpty()) ? user.getEmail() : "N/A");
        ft.setHTML(i, 2, (user.getOrganization() != null && !user.getOrganization().isEmpty()) ? user.getOrganization() : "N/A");
        /*

			ft.setHTML(i, 0, "<strong>"+user.getName()+"</strong><br/>"+user.getOrganization()+"<br/><i>"+user.getEmail()+"</i>");

			//ft.setHTML(i, 1, user.getEmail());
			//ft.setHTML(i, 2, user.getOrganization());

			FlowPanel idents = new FlowPanel();
			ft.setWidget(i, 1, idents);
			idents.setStyleName("identsTable");

			boolean certFound = false;
			for (int n=0; n<user.getExternalIdentities().length(); n++) {

				ExtSource source = user.getExternalIdentities().get(n);

				if (source.getType().equals("cz.metacentrum.perun.core.impl.ExtSourceX509") && !certFound) {
					certFound = true;

					String name[] = source.getName().split("\\/");
					for (String cn : name) {
						if (cn.startsWith("CN=")) {
							idents.insert(new CustomButton(cn.substring(3), SmallIcons.INSTANCE.documentSignatureIcon(), new ClickHandler(){
								@Override
								public void onClick(ClickEvent event) {
									// TODO - get safe hash of own for non-authz
									Window.Location.replace(Utils.getIdentityConsolidatorLink("cert", true));
								}
							}), 0);
							break;
						}
					}
				} else if (source.getType().equals("cz.metacentrum.perun.core.impl.ExtSourceIdp")) {

					idents.add(new CustomButton(translateIdp(source.getName()), SmallIcons.INSTANCE.userGreenIcon(), new ClickHandler(){
						@Override
						public void onClick(ClickEvent event) {
							// TODO - get safe hash of own for non-authz
							Window.Location.replace(Utils.getIdentityConsolidatorLink("fed", true));
						}
					}));

				}

			}

			if (idents.getWidgetCount() == 0) {
				idents.add(new HTML(ApplicationMessages.INSTANCE.noIdentsFound()));
			}

			*/
        i++;
    }
    // confirm element
    final Confirm confirm = new Confirm(ApplicationMessages.INSTANCE.similarUsersFound(), ft, new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {
            Window.Location.replace(Utils.getIdentityConsolidatorLink(true));
        }
    }, true);
    confirm.setOkButtonText(ApplicationMessages.INSTANCE.joinIdentity());
    confirm.setOkIcon(SmallIcons.INSTANCE.userGreenIcon());
    confirm.setCancelButtonText(ApplicationMessages.INSTANCE.notJoinIdentity());
    //confirm.setOkIcon(SmallIcons.INSTANCE.stopIcon());
    confirm.show();
}
Also used : ClickHandler(com.google.gwt.event.dom.client.ClickHandler) FlexCellFormatter(com.google.gwt.user.client.ui.FlexTable.FlexCellFormatter) ClickEvent(com.google.gwt.event.dom.client.ClickEvent) Confirm(cz.metacentrum.perun.webgui.widgets.Confirm)

Example 39 with FlexCellFormatter

use of com.google.gwt.user.client.ui.FlexTable.FlexCellFormatter in project gerrit by GerritCodeReview.

the class ChangeTable method addSection.

public void addSection(final Section s) {
    assert s.parent == null;
    s.parent = this;
    s.titleRow = table.getRowCount();
    if (s.displayTitle()) {
        final FlexCellFormatter fmt = table.getFlexCellFormatter();
        fmt.setColSpan(s.titleRow, 0, columns);
        fmt.addStyleName(s.titleRow, 0, Gerrit.RESOURCES.css().sectionHeader());
    } else {
        s.titleRow = -1;
    }
    s.dataBegin = table.getRowCount();
    insertNoneRow(s.dataBegin);
    sections.add(s);
}
Also used : FlexCellFormatter(com.google.gwt.user.client.ui.FlexTable.FlexCellFormatter)

Example 40 with FlexCellFormatter

use of com.google.gwt.user.client.ui.FlexTable.FlexCellFormatter in project gerrit by GerritCodeReview.

the class DashboardsTable method insertTitleRow.

protected void insertTitleRow(final int row, String section) {
    table.insertRow(row);
    table.setText(row, 0, section);
    final FlexCellFormatter fmt = table.getFlexCellFormatter();
    fmt.setColSpan(row, 0, 6);
    fmt.addStyleName(row, 0, Gerrit.RESOURCES.css().sectionHeader());
}
Also used : FlexCellFormatter(com.google.gwt.user.client.ui.FlexTable.FlexCellFormatter)

Aggregations

FlexCellFormatter (com.google.gwt.user.client.ui.FlexTable.FlexCellFormatter)48 ClickEvent (com.google.gwt.event.dom.client.ClickEvent)25 ClickHandler (com.google.gwt.event.dom.client.ClickHandler)25 TabItem (cz.metacentrum.perun.webgui.tabs.TabItem)19 CustomButton (cz.metacentrum.perun.webgui.widgets.CustomButton)19 TabMenu (cz.metacentrum.perun.webgui.widgets.TabMenu)17 ExtendedTextBox (cz.metacentrum.perun.webgui.widgets.ExtendedTextBox)14 JavaScriptObject (com.google.gwt.core.client.JavaScriptObject)10 JsonCallbackEvents (cz.metacentrum.perun.webgui.json.JsonCallbackEvents)10 RegistrarFormItemGenerator (cz.metacentrum.perun.webgui.client.applicationresources.RegistrarFormItemGenerator)6 PerunError (cz.metacentrum.perun.webgui.model.PerunError)5 JSONString (com.google.gwt.json.client.JSONString)3 VirtualOrganization (cz.metacentrum.perun.webgui.model.VirtualOrganization)3 ListBoxWithObjects (cz.metacentrum.perun.webgui.widgets.ListBoxWithObjects)3 ArrayList (java.util.ArrayList)3 ChangeEvent (com.google.gwt.event.dom.client.ChangeEvent)2 ChangeHandler (com.google.gwt.event.dom.client.ChangeHandler)2 ImageResource (com.google.gwt.resources.client.ImageResource)2 Anchor (com.google.gwt.user.client.ui.Anchor)2 Image (com.google.gwt.user.client.ui.Image)2