Search in sources :

Example 11 with HTML

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

the class GetAllRichSubGroups method getTable.

/**
	 * Returns the table with subgroups.
	 * @return
	 */
public CellTable<RichGroup> getTable() {
    // retrieve data
    retrieveData();
    // Table data provider.
    dataProvider = new ListDataProvider<RichGroup>(list);
    // Cell table
    table = new PerunTable<RichGroup>(list);
    table.setHyperlinksAllowed(false);
    // Connect the table to the data provider.
    dataProvider.addDataDisplay(table);
    // Sorting
    ListHandler<RichGroup> columnSortHandler = new ListHandler<RichGroup>(dataProvider.getList());
    table.addColumnSortHandler(columnSortHandler);
    // table selection
    table.setSelectionModel(selectionModel, DefaultSelectionEventManager.<RichGroup>createCheckboxManager());
    // set empty content & loader
    table.setEmptyTableWidget(loaderImage);
    loaderImage.setEmptyResultMessage("Group has no sub-groups.");
    // checkbox column column
    table.addCheckBoxColumn();
    table.addIdColumn("Group ID", tableFieldUpdater);
    // Add a synchronization clicable icon column.
    Column<RichGroup, RichGroup> syncColumn = new Column<RichGroup, RichGroup>(new CustomClickableInfoCellWithImageResource("click")) {

        @Override
        public RichGroup getValue(RichGroup object) {
            return object;
        }

        @Override
        public String getCellStyleNames(Cell.Context context, RichGroup object) {
            if (tableFieldUpdater != null) {
                return super.getCellStyleNames(context, object) + " pointer image-hover";
            } else {
                return super.getCellStyleNames(context, object);
            }
        }
    };
    syncColumn.setFieldUpdater(new FieldUpdater<RichGroup, RichGroup>() {

        @Override
        public void update(int index, final RichGroup object, RichGroup value) {
            GetEntityById get = new GetEntityById(PerunEntity.RICH_GROUP, object.getId(), new JsonCallbackEvents() {

                @Override
                public void onFinished(JavaScriptObject jso) {
                    final RichGroup object = jso.cast();
                    String name, syncEnabled, syncInterval, syncTimestamp, syncSuccessTimestamp, syncState, authGroup;
                    name = object.getName();
                    if (object.isSyncEnabled()) {
                        syncEnabled = "enabled";
                    } else {
                        syncEnabled = "disabled";
                    }
                    if (object.getSynchronizationInterval() == null) {
                        syncInterval = "N/A";
                    } else {
                        if (JsonUtils.checkParseInt(object.getSynchronizationInterval())) {
                            int time = Integer.parseInt(object.getSynchronizationInterval()) * 5 / 60;
                            if (time == 0) {
                                time = Integer.parseInt(object.getSynchronizationInterval()) * 5;
                                syncInterval = time + " minute(s)";
                            } else {
                                syncInterval = time + " hour(s)";
                            }
                        } else {
                            syncInterval = object.getSynchronizationInterval();
                        }
                    }
                    if (object.getLastSynchronizationState() == null) {
                        if (object.getLastSuccessSynchronizationTimestamp() != null) {
                            syncState = "OK";
                        } else {
                            syncState = "Not synced yet";
                        }
                    } else {
                        if (session.isPerunAdmin()) {
                            syncState = object.getLastSynchronizationState();
                        } else {
                            syncState = "Internal Error";
                        }
                    }
                    if (object.getLastSynchronizationTimestamp() == null) {
                        syncTimestamp = "N/A";
                    } else {
                        syncTimestamp = object.getLastSynchronizationTimestamp().split("\\.")[0];
                    }
                    if (object.getLastSuccessSynchronizationTimestamp() == null) {
                        syncSuccessTimestamp = "N/A";
                    } else {
                        syncSuccessTimestamp = object.getLastSuccessSynchronizationTimestamp().split("\\.")[0];
                    }
                    if (object.getAuthoritativeGroup() != null && object.getAuthoritativeGroup().equals("1")) {
                        authGroup = "Yes";
                    } else {
                        authGroup = "No";
                    }
                    String html = "Group name: <b>" + name + "</b><br>";
                    html += "Synchronization: <b>" + syncEnabled + "</b><br>";
                    if (object.isSyncEnabled()) {
                        html += "Last sync. state: <b>" + syncState + "</b><br>";
                        html += "Last sync. timestamp: <b>" + syncTimestamp + "</b><br>";
                        html += "Last successful sync. timestamp: <b>" + syncSuccessTimestamp + "</b><br>";
                        html += "Sync. Interval: <b>" + syncInterval + "</b><br>";
                        html += "Authoritative group: <b>" + authGroup + "</b><br>";
                    }
                    FlexTable layout = new FlexTable();
                    layout.setWidget(0, 0, new HTML("<p>" + new Image(LargeIcons.INSTANCE.informationIcon())));
                    layout.setHTML(0, 1, "<p style=\"line-height: 1.2;\">" + html);
                    layout.getFlexCellFormatter().setAlignment(0, 0, HasHorizontalAlignment.ALIGN_LEFT, HasVerticalAlignment.ALIGN_TOP);
                    layout.getFlexCellFormatter().setAlignment(0, 1, HasHorizontalAlignment.ALIGN_LEFT, HasVerticalAlignment.ALIGN_TOP);
                    layout.getFlexCellFormatter().setStyleName(0, 0, "alert-box-image");
                    final CustomButton okButton = new CustomButton("Force synchronization", SmallIcons.INSTANCE.arrowRefreshIcon());
                    okButton.addClickHandler(new ClickHandler() {

                        @Override
                        public void onClick(ClickEvent event) {
                            ForceGroupSynchronization call = new ForceGroupSynchronization(JsonCallbackEvents.disableButtonEvents(okButton));
                            call.synchronizeGroup(object.getId());
                        }
                    });
                    if (!session.isVoAdmin(object.getVoId()) && !session.isGroupAdmin(object.getId()))
                        okButton.setEnabled(false);
                    okButton.setVisible(object.isSyncEnabled());
                    final Confirm c = new Confirm("Group synchronization info", layout, okButton, null, true);
                    c.setHideOnButtonClick(false);
                    c.setCancelIcon(SmallIcons.INSTANCE.acceptIcon());
                    c.setCancelButtonText("OK");
                    c.setCancelClickHandler(new ClickHandler() {

                        @Override
                        public void onClick(ClickEvent event) {
                            c.hide();
                        }
                    });
                    c.show();
                }
            });
            get.retrieveData();
        }

        ;
    });
    syncColumn.setSortable(true);
    columnSortHandler.setComparator(syncColumn, new Comparator<RichGroup>() {

        @Override
        public int compare(RichGroup o1, RichGroup o2) {
            if (o1 != null && o2 != null) {
                int o1val = 0;
                int o2val = 0;
                if (o1.isSyncEnabled())
                    o1val = 5;
                if (o2.isSyncEnabled())
                    o2val = 5;
                if (o1.getAuthoritativeGroup() != null && o1.getAuthoritativeGroup().equalsIgnoreCase("1"))
                    o1val = o1val + 3;
                if (o2.getAuthoritativeGroup() != null && o2.getAuthoritativeGroup().equalsIgnoreCase("1"))
                    o2val = o2val + 3;
                return o1val - o2val;
            }
            return 0;
        }
    });
    table.addColumn(syncColumn, "Sync");
    table.setColumnWidth(syncColumn, "70px");
    table.addNameColumn(tableFieldUpdater);
    table.addDescriptionColumn(tableFieldUpdater);
    return table;
}
Also used : JsonCallbackEvents(cz.metacentrum.perun.webgui.json.JsonCallbackEvents) RichGroup(cz.metacentrum.perun.webgui.model.RichGroup) ClickEvent(com.google.gwt.event.dom.client.ClickEvent) Confirm(cz.metacentrum.perun.webgui.widgets.Confirm) HTML(com.google.gwt.user.client.ui.HTML) Image(com.google.gwt.user.client.ui.Image) AjaxLoaderImage(cz.metacentrum.perun.webgui.widgets.AjaxLoaderImage) Column(com.google.gwt.user.cellview.client.Column) CustomButton(cz.metacentrum.perun.webgui.widgets.CustomButton) GetEntityById(cz.metacentrum.perun.webgui.json.GetEntityById) ListHandler(com.google.gwt.user.cellview.client.ColumnSortEvent.ListHandler) FlexTable(com.google.gwt.user.client.ui.FlexTable) ClickHandler(com.google.gwt.event.dom.client.ClickHandler) JavaScriptObject(com.google.gwt.core.client.JavaScriptObject) CustomClickableInfoCellWithImageResource(cz.metacentrum.perun.webgui.widgets.cells.CustomClickableInfoCellWithImageResource)

Example 12 with HTML

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

the class UpdateSecurityTeam method testCreating.

/**
	 * Tests the values, if the process can continue
	 *
	 * @return
	 */
private boolean testCreating() {
    boolean result = true;
    String errorMsg = "";
    if (team == null) {
        errorMsg += "Can't update NULL SecurityTeam.<br />";
        result = false;
    }
    if (team.getName().length() == 0) {
        errorMsg += "Security Team must have parameter <strong>Name</strong>.<br />";
        result = false;
    }
    if (errorMsg.length() > 0) {
        Confirm c = new Confirm("Error while updating SecurityTeam", 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 13 with HTML

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

the class CreateSecurityTeam method testCreating.

/**
	 * Tests the values, if the process can continue
	 *
	 * @return
	 */
private boolean testCreating() {
    boolean result = true;
    String errorMsg = "";
    if (name.length() == 0) {
        errorMsg += "You must fill in the parameter <strong>Name</strong>.<br />";
        result = false;
    }
    if (errorMsg.length() > 0) {
        Confirm c = new Confirm("Error while creating SecurityTeam", 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 14 with HTML

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

the class DeleteSecurityTeam method testDeleting.

/**
	 * Tests the values, if the process can continue
	 *
	 * @return true/false for continue/stop
	 */
private boolean testDeleting() {
    boolean result = true;
    String errorMsg = "";
    if (securityTeamId == 0) {
        errorMsg += "Wrong parameter <strong>SECURITY TEAM ID</strong>.\n";
        result = false;
    }
    if (errorMsg.length() > 0) {
        Confirm c = new Confirm("Error while deleting Security Team", 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 15 with HTML

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

the class CreatePassword method validateAndSetUserExtSources.

/**
	 * Validates password and sets user ext sources
	 *
	 * @param userId user to set password for
	 * @param login used for validation only
	 * @param namespace defined login in namespace
	 */
public void validateAndSetUserExtSources(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;
    }
    JsonPostClient jspc = new JsonPostClient(events);
    jspc.sendData(JSON_URL_VALIDATE_AND_SET_USER_EXT_SOURCE, validateCallJSON());
}
Also used : 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)

Aggregations

HTML (com.google.gwt.user.client.ui.HTML)91 ClickEvent (com.google.gwt.event.dom.client.ClickEvent)26 ClickHandler (com.google.gwt.event.dom.client.ClickHandler)26 Confirm (cz.metacentrum.perun.webgui.widgets.Confirm)24 JSONString (com.google.gwt.json.client.JSONString)15 VerticalPanel (com.google.gwt.user.client.ui.VerticalPanel)14 FlexTable (com.google.gwt.user.client.ui.FlexTable)13 Image (com.google.gwt.user.client.ui.Image)10 Button (org.gwtbootstrap3.client.ui.Button)10 HorizontalPanel (com.google.gwt.user.client.ui.HorizontalPanel)8 Test (org.junit.Test)8 SmallLabel (org.uberfire.ext.widgets.common.client.common.SmallLabel)8 ChangeEvent (com.google.gwt.event.dom.client.ChangeEvent)7 ChangeHandler (com.google.gwt.event.dom.client.ChangeHandler)7 SimplePanel (com.google.gwt.user.client.ui.SimplePanel)7 Widget (com.google.gwt.user.client.ui.Widget)7 Label (com.google.gwt.user.client.ui.Label)6 JavaScriptObject (com.google.gwt.core.client.JavaScriptObject)5 Command (com.google.gwt.user.client.Command)5 FlowPanel (com.google.gwt.user.client.ui.FlowPanel)5