Search in sources :

Example 21 with UiHandler

use of com.google.gwt.uibinder.client.UiHandler in project gerrit by GerritCodeReview.

the class ChangeScreen method onCollapseAll.

@UiHandler("collapseAll")
void onCollapseAll(@SuppressWarnings("unused") ClickEvent e) {
    int n = history.getWidgetCount();
    for (int i = 0; i < n; i++) {
        ((Message) history.getWidget(i)).setOpen(false);
    }
    expandAll.setVisible(true);
    collapseAll.setVisible(false);
}
Also used : GerritUiExtensionPoint(com.google.gerrit.client.GerritUiExtensionPoint) UiHandler(com.google.gwt.uibinder.client.UiHandler)

Example 22 with UiHandler

use of com.google.gwt.uibinder.client.UiHandler in project gerrit by GerritCodeReview.

the class ProjectAccessEditor method onAddSection.

@UiHandler("addSection")
void onAddSection(@SuppressWarnings("unused") ClickEvent event) {
    int index = local.getList().size();
    local.getList().add(new AccessSection("refs/heads/*"));
    AccessSectionEditor editor = local.getEditors().get(index);
    editor.enableEditing();
    editor.editRefPattern();
}
Also used : AccessSection(com.google.gerrit.common.data.AccessSection) UiHandler(com.google.gwt.uibinder.client.UiHandler)

Example 23 with UiHandler

use of com.google.gwt.uibinder.client.UiHandler in project gerrit by GerritCodeReview.

the class ProjectAccessScreen method onReview.

@UiHandler("review")
void onReview(@SuppressWarnings("unused") ClickEvent event) {
    final ProjectAccess access = driver.flush();
    if (driver.hasErrors()) {
        Window.alert(AdminConstants.I.errorsMustBeFixed());
        return;
    }
    String message = commitMessage.getText().trim();
    if ("".equals(message)) {
        message = null;
    }
    enable(false);
    //
    Util.PROJECT_SVC.reviewProjectAccess(//
    getProjectKey(), //
    access.getRevision(), //
    message, //
    access.getLocal(), //
    access.getInheritsFrom(), new GerritCallback<Change.Id>() {

        @Override
        public void onSuccess(Change.Id changeId) {
            enable(true);
            commitMessage.setText("");
            error.clear();
            if (changeId != null) {
                Gerrit.display(PageLinks.toChange(changeId));
            } else {
                displayReadOnly(access);
            }
        }

        @Override
        public void onFailure(Throwable caught) {
            error.clear();
            enable(true);
            super.onFailure(caught);
        }
    });
}
Also used : Change(com.google.gerrit.reviewdb.client.Change) ProjectAccess(com.google.gerrit.common.data.ProjectAccess) UiHandler(com.google.gwt.uibinder.client.UiHandler)

Example 24 with UiHandler

use of com.google.gwt.uibinder.client.UiHandler in project gerrit by GerritCodeReview.

the class ProjectAccessScreen method onCommit.

@UiHandler("commit")
void onCommit(@SuppressWarnings("unused") ClickEvent event) {
    final ProjectAccess access = driver.flush();
    if (driver.hasErrors()) {
        Window.alert(AdminConstants.I.errorsMustBeFixed());
        return;
    }
    String message = commitMessage.getText().trim();
    if ("".equals(message)) {
        message = null;
    }
    enable(false);
    //
    Util.PROJECT_SVC.changeProjectAccess(//
    getProjectKey(), //
    access.getRevision(), //
    message, //
    access.getLocal(), //
    access.getInheritsFrom(), new GerritCallback<ProjectAccess>() {

        @Override
        public void onSuccess(ProjectAccess newAccess) {
            enable(true);
            commitMessage.setText("");
            error.clear();
            final Set<String> diffs = getDiffs(access, newAccess);
            if (diffs.isEmpty()) {
                displayReadOnly(newAccess);
            } else {
                error.add(new Label(Gerrit.C.projectAccessError()));
                for (final String diff : diffs) {
                    error.add(new Label(diff));
                }
                if (access.canUpload()) {
                    error.add(new Label(Gerrit.C.projectAccessProposeForReviewHint()));
                }
            }
        }

        private Set<String> getDiffs(ProjectAccess wantedAccess, ProjectAccess newAccess) {
            List<AccessSection> wantedSections = mergeSections(removeEmptyPermissionsAndSections(wantedAccess.getLocal()));
            List<AccessSection> newSections = removeEmptyPermissionsAndSections(newAccess.getLocal());
            HashSet<AccessSection> same = new HashSet<>(wantedSections);
            HashSet<AccessSection> different = new HashSet<>(wantedSections.size() + newSections.size());
            different.addAll(wantedSections);
            different.addAll(newSections);
            same.retainAll(newSections);
            different.removeAll(same);
            Set<String> differentNames = new HashSet<>();
            for (AccessSection s : different) {
                differentNames.add(s.getName());
            }
            return differentNames;
        }

        @Override
        public void onFailure(Throwable caught) {
            error.clear();
            enable(true);
            if (caught instanceof RemoteJsonException && caught.getMessage().startsWith(UpdateParentFailedException.MESSAGE)) {
                new ErrorDialog(Gerrit.M.parentUpdateFailed(caught.getMessage().substring(UpdateParentFailedException.MESSAGE.length() + 1))).center();
            } else {
                super.onFailure(caught);
            }
        }
    });
}
Also used : HashSet(java.util.HashSet) Set(java.util.Set) Label(com.google.gwt.user.client.ui.Label) RemoteJsonException(com.google.gwtjsonrpc.client.RemoteJsonException) ErrorDialog(com.google.gerrit.client.ErrorDialog) ProjectAccess(com.google.gerrit.common.data.ProjectAccess) AccessSection(com.google.gerrit.common.data.AccessSection) List(java.util.List) HashSet(java.util.HashSet) UiHandler(com.google.gwt.uibinder.client.UiHandler)

Example 25 with UiHandler

use of com.google.gwt.uibinder.client.UiHandler in project gerrit by GerritCodeReview.

the class Reviewers method onAddMe.

@UiHandler("addMe")
void onAddMe(@SuppressWarnings("unused") ClickEvent e) {
    String accountId = String.valueOf(Gerrit.getUserAccount()._accountId());
    addReviewer(accountId, false);
}
Also used : NativeString(com.google.gerrit.client.rpc.NativeString) UiHandler(com.google.gwt.uibinder.client.UiHandler)

Aggregations

UiHandler (com.google.gwt.uibinder.client.UiHandler)30 GerritUiExtensionPoint (com.google.gerrit.client.GerritUiExtensionPoint)5 CallbackGroup (com.google.gerrit.client.rpc.CallbackGroup)3 Command (com.google.gwt.user.client.Command)3 AccessSection (com.google.gerrit.common.data.AccessSection)2 ProjectAccess (com.google.gerrit.common.data.ProjectAccess)2 Theme (com.google.gerrit.extensions.client.Theme)2 CheckBox (com.gwtmobile.ui.client.widgets.CheckBox)2 RadioButton (com.gwtmobile.ui.client.widgets.RadioButton)2 ErrorDialog (com.google.gerrit.client.ErrorDialog)1 EditPreferences (com.google.gerrit.client.account.EditPreferences)1 GerritCallback (com.google.gerrit.client.rpc.GerritCallback)1 NativeString (com.google.gerrit.client.rpc.NativeString)1 EditPreferencesInfo (com.google.gerrit.extensions.client.EditPreferencesInfo)1 KeyMapType (com.google.gerrit.extensions.client.KeyMapType)1 Change (com.google.gerrit.reviewdb.client.Change)1 JavaScriptObject (com.google.gwt.core.client.JavaScriptObject)1 JsArrayString (com.google.gwt.core.client.JsArrayString)1 DomEvent (com.google.gwt.event.dom.client.DomEvent)1 HasValueChangeHandlers (com.google.gwt.event.logical.shared.HasValueChangeHandlers)1