Search in sources :

Example 26 with HTML

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

the class CreatePassword method createRandomPassword.

/**
	 * Create empty password for the user - random password is generated on KDC side
	 *
	 * @param userId user to set password for
	 * @param login used for validation only
	 * @param namespace defined login in namespace
	 */
public void createRandomPassword(int userId, String login, String namespace) {
    this.userId = userId;
    this.namespace = namespace;
    this.login = login;
    // test arguments
    String errorMsg = "";
    if (userId == 0) {
        errorMsg += "<p>User ID can't be 0.";
    }
    if (namespace.isEmpty()) {
        errorMsg += "<p>Namespace can't be empty.";
    }
    if (login.isEmpty()) {
        errorMsg += "<p>Login to create password for can't be empty.";
    }
    if (errorMsg.length() > 0) {
        Confirm c = new Confirm("Error while creating password.", new HTML(errorMsg), true);
        c.show();
        return;
    }
    // final events
    final JsonCallbackEvents newEvents = new JsonCallbackEvents() {

        @Override
        public void onError(PerunError error) {
            session.getUiElements().setLogErrorText("Creating password failed.");
            // custom events
            events.onError(error);
        }

        ;

        @Override
        public void onFinished(JavaScriptObject jso) {
            session.getUiElements().setLogSuccessText("Password created successfully.");
            events.onFinished(jso);
        }

        ;
    };
    // validate event
    JsonCallbackEvents validateEvent = new JsonCallbackEvents() {

        @Override
        public void onError(PerunError error) {
            session.getUiElements().setLogErrorText("Creating password failed.");
            // custom events
            events.onError(error);
        }

        ;

        @Override
        public void onFinished(JavaScriptObject jso) {
            JsonPostClient jspc = new JsonPostClient(newEvents);
            jspc.sendData(JSON_URL_VALIDATE_AND_SET_USER_EXT_SOURCE, validateCallJSON());
        }

        ;

        @Override
        public void onLoadingStart() {
            events.onLoadingStart();
        }

        ;
    };
    // sending data
    JsonPostClient jspc = new JsonPostClient(validateEvent);
    jspc.sendData(JSON_URL_RESERVE_RANDOM, prepareJSONObject());
}
Also used : JsonCallbackEvents(cz.metacentrum.perun.webgui.json.JsonCallbackEvents) JavaScriptObject(com.google.gwt.core.client.JavaScriptObject) JsonPostClient(cz.metacentrum.perun.webgui.json.JsonPostClient) Confirm(cz.metacentrum.perun.webgui.widgets.Confirm) HTML(com.google.gwt.user.client.ui.HTML) JSONString(com.google.gwt.json.client.JSONString) PerunError(cz.metacentrum.perun.webgui.model.PerunError)

Example 27 with HTML

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

the class RemoveUserExtSource method testRemoving.

/**
	 * Tests the values, if the process can continue
	 *
	 * @return true/false for continue/stop
	 */
private boolean testRemoving() {
    boolean result = true;
    String errorMsg = "";
    if (userId == 0) {
        errorMsg += "Wrong parameter <strong>User ID</strong>. ";
        result = false;
    }
    if (uesId == 0) {
        errorMsg += "Wrong parameter <strong>User Ext Source ID</strong>. ";
        result = false;
    }
    if (errorMsg.length() > 0) {
        Confirm c = new Confirm("Error while adding user external source", new HTML(errorMsg), true);
        c.show();
    }
    return result;
}
Also used : Confirm(cz.metacentrum.perun.webgui.widgets.Confirm) HTML(com.google.gwt.user.client.ui.HTML)

Example 28 with HTML

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

the class AddUserExtSource method testAdding.

/**
	 * Tests the values, if the process can continue
	 *
	 * @return true/false for continue/stop
	 */
private boolean testAdding() {
    boolean result = true;
    String errorMsg = "";
    if (userId == 0) {
        errorMsg += "Wrong parameter <strong>User ID</strong>.\n";
        result = false;
    }
    if (errorMsg.length() > 0) {
        Confirm c = new Confirm("Error while adding user external source", new HTML(errorMsg), true);
        c.show();
    }
    return result;
}
Also used : Confirm(cz.metacentrum.perun.webgui.widgets.Confirm) HTML(com.google.gwt.user.client.ui.HTML) JSONString(com.google.gwt.json.client.JSONString)

Example 29 with HTML

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

the class GroupRelationsTabItem method draw.

@Override
public Widget draw() {
    titleWidget.setText(Utils.getStrippedStringWithEllipsis(group.getName()) + ": unions");
    // main panel
    VerticalPanel vp = new VerticalPanel();
    vp.setSize("100%", "100%");
    // if members group, hide
    if (group.isCoreGroup()) {
        vp.add(new HTML("<h2>Members group cannot have unions.</h2>"));
        this.contentWidget.setWidget(vp);
        return getWidget();
    }
    final GetGroupUnions unions = new GetGroupUnions(group, false);
    // Events for reloading when group is created
    final JsonCallbackEvents events = JsonCallbackEvents.refreshTableEvents(unions);
    // menu
    TabMenu menu = new TabMenu();
    final CheckBox subGroupsCheckBox = new CheckBox("Show sub-groups");
    final ListBox reverseDropdown = new ListBox();
    reverseDropdown.addItem("Normal");
    reverseDropdown.addItem("Reverse");
    reverseDropdown.addChangeHandler(new ChangeHandler() {

        @Override
        public void onChange(ChangeEvent changeEvent) {
            switch(reverseDropdown.getSelectedIndex()) {
                case 1:
                    unions.setReverseAndRefresh(true);
                    subGroupsCheckBox.setVisible(false);
                    break;
                default:
                    unions.setReverseAndRefresh(false);
                    subGroupsCheckBox.setVisible(true);
            }
        }
    });
    menu.addWidget(UiElements.getRefreshButton(this));
    CustomButton createButton = TabMenu.getPredefinedButton(ButtonType.ADD, true, ButtonTranslation.INSTANCE.addGroupUnion(), new ClickHandler() {

        public void onClick(ClickEvent event) {
            // creates a new form
            session.getTabManager().addTabToCurrentTab(new AddGroupUnionTabItem(group), true);
        }
    });
    if (!session.isGroupAdmin(groupId) && !session.isVoAdmin(group.getVoId())) {
        createButton.setEnabled(false);
        unions.setCheckable(false);
    }
    menu.addWidget(createButton);
    final CustomButton removeButton = TabMenu.getPredefinedButton(ButtonType.REMOVE, ButtonTranslation.INSTANCE.removeGroupUnion());
    removeButton.addClickHandler(new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {
            final ArrayList<Group> itemsToRemove = unions.getTableSelectedList();
            String text = "Following group unions will be deleted.";
            UiElements.showDeleteConfirm(itemsToRemove, text, new ClickHandler() {

                @Override
                public void onClick(ClickEvent clickEvent) {
                    RemoveGroupUnions request = new RemoveGroupUnions(JsonCallbackEvents.disableButtonEvents(removeButton, events));
                    if (unions.isReverse()) {
                        request.deleteGroupUnions(itemsToRemove, group);
                    } else {
                        request.deleteGroupUnions(group, itemsToRemove);
                    }
                }
            });
        }
    });
    menu.addWidget(removeButton);
    // filter box
    final ExtendedSuggestBox box = new ExtendedSuggestBox(unions.getOracle());
    menu.addFilterWidget(box, new PerunSearchEvent() {

        public void searchFor(String text) {
            unions.filterTable(text);
        }
    }, ButtonTranslation.INSTANCE.filterGroup());
    subGroupsCheckBox.addValueChangeHandler(new ValueChangeHandler<Boolean>() {

        @Override
        public void onValueChange(ValueChangeEvent<Boolean> valueChangeEvent) {
            unions.setShowSubgroupsAndRefresh(valueChangeEvent.getValue(), box.getSuggestBox().getText());
        }
    });
    menu.addWidget(new HTML("<strong>Direction: </strong>"));
    menu.addWidget(reverseDropdown);
    menu.addWidget(subGroupsCheckBox);
    // add menu to the main panel
    vp.add(menu);
    vp.setCellHeight(menu, "30px");
    CellTable<Group> table = unions.getTable(new FieldUpdater<Group, String>() {

        @Override
        public void update(int arg0, Group group, String arg2) {
            if (session.isGroupAdmin(group.getId()) || session.isVoAdmin(group.getId())) {
                session.getTabManager().addTab(new GroupDetailTabItem(group.getId()));
            } else {
                UiElements.generateInfo("Not privileged", "You are not manager of selected group or its VO.");
            }
        }
    });
    removeButton.setEnabled(false);
    if (session.isGroupAdmin(groupId) || session.isVoAdmin(group.getVoId()))
        JsonUtils.addTableManagedButton(unions, table, removeButton);
    // adds the table into the panel
    table.addStyleName("perun-table");
    ScrollPanel sp = new ScrollPanel(table);
    sp.addStyleName("perun-tableScrollPanel");
    vp.add(sp);
    session.getUiElements().resizePerunTable(sp, 350, this);
    this.contentWidget.setWidget(vp);
    return getWidget();
}
Also used : JsonCallbackEvents(cz.metacentrum.perun.webgui.json.JsonCallbackEvents) Group(cz.metacentrum.perun.webgui.model.Group) ClickEvent(com.google.gwt.event.dom.client.ClickEvent) ArrayList(java.util.ArrayList) HTML(com.google.gwt.user.client.ui.HTML) ValueChangeHandler(com.google.gwt.event.logical.shared.ValueChangeHandler) ChangeHandler(com.google.gwt.event.dom.client.ChangeHandler) CustomButton(cz.metacentrum.perun.webgui.widgets.CustomButton) ExtendedSuggestBox(cz.metacentrum.perun.webgui.widgets.ExtendedSuggestBox) RemoveGroupUnions(cz.metacentrum.perun.webgui.json.groupsManager.RemoveGroupUnions) PerunSearchEvent(cz.metacentrum.perun.webgui.client.resources.PerunSearchEvent) TabMenu(cz.metacentrum.perun.webgui.widgets.TabMenu) VerticalPanel(com.google.gwt.user.client.ui.VerticalPanel) ClickHandler(com.google.gwt.event.dom.client.ClickHandler) ChangeEvent(com.google.gwt.event.dom.client.ChangeEvent) ValueChangeEvent(com.google.gwt.event.logical.shared.ValueChangeEvent) CheckBox(com.google.gwt.user.client.ui.CheckBox) GetGroupUnions(cz.metacentrum.perun.webgui.json.groupsManager.GetGroupUnions) ListBox(com.google.gwt.user.client.ui.ListBox) ScrollPanel(com.google.gwt.user.client.ui.ScrollPanel)

Example 30 with HTML

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

the class FindSimilarPublications method getEmptyTable.

/**
	 * Returns table of users publications
	 * @return table
	 */
public CellTable<Publication> getEmptyTable() {
    // Table data provider.
    dataProvider = new ListDataProvider<Publication>(list);
    // Cell table
    table = new PerunTable<Publication>(list);
    // display row-count for perun admin only
    if (!session.isPerunAdmin()) {
        table.removeRowCountChangeHandler();
    }
    // Connect the table to the data provider.
    dataProvider.addDataDisplay(table);
    // Sorting
    ListHandler<Publication> columnSortHandler = new ListHandler<Publication>(dataProvider.getList());
    table.addColumnSortHandler(columnSortHandler);
    // table selection
    table.setSelectionModel(selectionModel, DefaultSelectionEventManager.<Publication>createCheckboxManager());
    // set empty content & loader
    table.setEmptyTableWidget(loaderImage);
    loaderImage.setEmptyResultMessage("No similar publications found.");
    // show checkbox column
    if (this.checkable) {
        // checkbox column column
        table.addCheckBoxColumn();
    }
    // ID COLUMN
    table.addIdColumn("Publication ID", tableFieldUpdater, 60);
    Column<Publication, ImageResource> lockedColumn = new Column<Publication, ImageResource>(new CustomImageResourceCell("click")) {

        public ImageResource getValue(Publication object) {
            if (object.getLocked() == true) {
                return SmallIcons.INSTANCE.lockIcon();
            } else {
                return SmallIcons.INSTANCE.lockOpenIcon();
            }
        }

        public void onBrowserEvent(final Context context, final Element elem, final Publication object, NativeEvent event) {
            // on click and for perun admin
            if ("click".equals(event.getType()) && session.isPerunAdmin()) {
                final ImageResource value;
                if (object.getLocked() == true) {
                    value = SmallIcons.INSTANCE.lockOpenIcon();
                    object.setLocked(false);
                } else {
                    value = SmallIcons.INSTANCE.lockIcon();
                    object.setLocked(true);
                }
                LockUnlockPublications request = new LockUnlockPublications(new JsonCallbackEvents() {

                    @Override
                    public void onLoadingStart() {
                        getCell().setValue(context, elem, SmallIcons.INSTANCE.updateIcon());
                    }

                    @Override
                    public void onFinished(JavaScriptObject jso) {
                        // change picture (object already changed)
                        getCell().setValue(context, elem, value);
                    }

                    @Override
                    public void onError(PerunError error) {
                        // on error switch object back
                        if (object.getLocked() == true) {
                            object.setLocked(false);
                            getCell().setValue(context, elem, SmallIcons.INSTANCE.lockOpenIcon());
                        } else {
                            object.setLocked(true);
                            getCell().setValue(context, elem, SmallIcons.INSTANCE.lockIcon());
                        }
                    }
                });
                // send request
                ArrayList<Publication> list = new ArrayList<Publication>();
                list.add(object);
                request.lockUnlockPublications(object.getLocked(), list);
            }
        }
    };
    table.addColumn(lockedColumn, "Lock");
    // TITLE COLUMN
    Column<Publication, String> titleColumn = JsonUtils.addColumn(new JsonUtils.GetValue<Publication, String>() {

        public String getValue(Publication object) {
            return object.getTitle();
        }
    }, this.tableFieldUpdater);
    titleColumn.setSortable(true);
    columnSortHandler.setComparator(titleColumn, new PublicationComparator(PublicationComparator.Column.TITLE));
    table.addColumn(titleColumn, "Title");
    // if display authors
    if (ids.containsKey("authors")) {
        if ((Integer) ids.get("authors") == 1) {
            // AUTHORS COLUMN
            Column<Publication, String> authorColumn = JsonUtils.addColumn(new JsonUtils.GetValue<Publication, String>() {

                public String getValue(Publication object) {
                    return object.getAuthorsFormatted();
                }
            }, this.tableFieldUpdater);
            authorColumn.setSortable(true);
            columnSortHandler.setComparator(authorColumn, new PublicationComparator(PublicationComparator.Column.AUTHORS));
            table.addColumn(authorColumn, "Reported by");
        }
    }
    // YEAR COLUMN
    Column<Publication, String> yearColumn = JsonUtils.addColumn(new JsonUtils.GetValue<Publication, String>() {

        public String getValue(Publication object) {
            return String.valueOf(object.getYear());
        }
    }, this.tableFieldUpdater);
    yearColumn.setSortable(true);
    columnSortHandler.setComparator(yearColumn, new PublicationComparator(PublicationComparator.Column.YEAR));
    table.addColumn(yearColumn, "Year");
    // CATEGORY COLUMN
    Column<Publication, String> categoryColumn = JsonUtils.addColumn(new JsonUtils.GetValue<Publication, String>() {

        public String getValue(Publication object) {
            return object.getCategoryName();
        }
    }, this.tableFieldUpdater);
    categoryColumn.setSortable(true);
    columnSortHandler.setComparator(categoryColumn, new PublicationComparator(PublicationComparator.Column.CATEGORY));
    table.addColumn(categoryColumn, "Category");
    // THANKS COLUMN
    Column<Publication, String> thanksColumn = JsonUtils.addColumn(new JsonUtils.GetValue<Publication, String>() {

        public String getValue(Publication object) {
            String result = "";
            JsArray<Thanks> thks = object.getThanks();
            for (int i = 0; i < thks.length(); i++) {
                result += thks.get(i).getOwnerName() + ", ";
            }
            if (result.length() >= 2) {
                result = result.substring(0, result.length() - 2);
            }
            return result;
        }
    }, this.tableFieldUpdater);
    thanksColumn.setSortable(true);
    columnSortHandler.setComparator(thanksColumn, new PublicationComparator(PublicationComparator.Column.THANKS));
    table.addColumn(thanksColumn, "Thanked to");
    // CITE COLUMN
    Column<Publication, String> citaceColumn = JsonUtils.addColumn(new JsonUtils.GetValue<Publication, String>() {

        public String getValue(Publication object) {
            return "Cite";
        }
    }, new FieldUpdater<Publication, String>() {

        public void update(int index, Publication object, String value) {
            SimplePanel sp = new SimplePanel();
            sp.add(new HTML(object.getMain()));
            Confirm cf = new Confirm("Cite publication", sp, true);
            cf.show();
        }

        ;
    });
    table.addColumn(citaceColumn, "Cite");
    return table;
}
Also used : PublicationComparator(cz.metacentrum.perun.webgui.json.comparators.PublicationComparator) Element(com.google.gwt.dom.client.Element) ArrayList(java.util.ArrayList) Confirm(cz.metacentrum.perun.webgui.widgets.Confirm) HTML(com.google.gwt.user.client.ui.HTML) ImageResource(com.google.gwt.resources.client.ImageResource) Column(com.google.gwt.user.cellview.client.Column) Context(com.google.gwt.cell.client.Cell.Context) ListHandler(com.google.gwt.user.cellview.client.ColumnSortEvent.ListHandler) CustomImageResourceCell(cz.metacentrum.perun.webgui.widgets.cells.CustomImageResourceCell) JsArray(com.google.gwt.core.client.JsArray) Publication(cz.metacentrum.perun.webgui.model.Publication) SimplePanel(com.google.gwt.user.client.ui.SimplePanel) JavaScriptObject(com.google.gwt.core.client.JavaScriptObject) PerunError(cz.metacentrum.perun.webgui.model.PerunError) NativeEvent(com.google.gwt.dom.client.NativeEvent)

Aggregations

HTML (com.google.gwt.user.client.ui.HTML)65 Confirm (cz.metacentrum.perun.webgui.widgets.Confirm)24 JSONString (com.google.gwt.json.client.JSONString)15 VerticalPanel (com.google.gwt.user.client.ui.VerticalPanel)12 ClickEvent (com.google.gwt.event.dom.client.ClickEvent)11 ClickHandler (com.google.gwt.event.dom.client.ClickHandler)11 Test (org.junit.Test)8 JavaScriptObject (com.google.gwt.core.client.JavaScriptObject)6 Element (com.google.gwt.dom.client.Element)5 FlowPanel (com.google.gwt.user.client.ui.FlowPanel)5 Image (com.google.gwt.user.client.ui.Image)5 Label (com.google.gwt.user.client.ui.Label)5 SimplePanel (com.google.gwt.user.client.ui.SimplePanel)5 JsonCallbackEvents (cz.metacentrum.perun.webgui.json.JsonCallbackEvents)5 ListHandler (com.google.gwt.user.cellview.client.ColumnSortEvent.ListHandler)4 Widget (com.google.gwt.user.client.ui.Widget)4 JsArray (com.google.gwt.core.client.JsArray)3 Column (com.google.gwt.user.cellview.client.Column)3 CheckBox (com.google.gwt.user.client.ui.CheckBox)3 FlexTable (com.google.gwt.user.client.ui.FlexTable)3