Search in sources :

Example 11 with GerritCallback

use of com.google.gerrit.client.rpc.GerritCallback in project gerrit by GerritCodeReview.

the class AccountGroupInfoScreen method initGroupOptions.

private void initGroupOptions() {
    final VerticalPanel groupOptionsPanel = new VerticalPanel();
    final VerticalPanel vp = new VerticalPanel();
    vp.setStyleName(Gerrit.RESOURCES.css().groupOptionsPanel());
    vp.add(new SmallHeading(AdminConstants.I.headingGroupOptions()));
    visibleToAllCheckBox = new CheckBox(AdminConstants.I.isVisibleToAll());
    vp.add(visibleToAllCheckBox);
    groupOptionsPanel.add(vp);
    saveGroupOptions = new Button(AdminConstants.I.buttonSaveGroupOptions());
    saveGroupOptions.setEnabled(false);
    saveGroupOptions.addClickHandler(new ClickHandler() {

        @Override
        public void onClick(final ClickEvent event) {
            GroupApi.setGroupOptions(getGroupUUID(), visibleToAllCheckBox.getValue(), new GerritCallback<VoidResult>() {

                @Override
                public void onSuccess(final VoidResult result) {
                    saveGroupOptions.setEnabled(false);
                }
            });
        }
    });
    groupOptionsPanel.add(saveGroupOptions);
    add(groupOptionsPanel);
    final OnEditEnabler enabler = new OnEditEnabler(saveGroupOptions);
    enabler.listenTo(visibleToAllCheckBox);
}
Also used : SmallHeading(com.google.gerrit.client.ui.SmallHeading) GerritCallback(com.google.gerrit.client.rpc.GerritCallback) VerticalPanel(com.google.gwt.user.client.ui.VerticalPanel) ClickHandler(com.google.gwt.event.dom.client.ClickHandler) VoidResult(com.google.gerrit.client.VoidResult) Button(com.google.gwt.user.client.ui.Button) CheckBox(com.google.gwt.user.client.ui.CheckBox) ClickEvent(com.google.gwt.event.dom.client.ClickEvent) OnEditEnabler(com.google.gerrit.client.ui.OnEditEnabler)

Example 12 with GerritCallback

use of com.google.gerrit.client.rpc.GerritCallback in project gerrit by GerritCodeReview.

the class CherryPickAction method call.

static void call(final Button b, final ChangeInfo info, final String revision, String project, final String commitMessage) {
    // TODO Replace CherryPickDialog with a nicer looking display.
    b.setEnabled(false);
    new CherryPickDialog(new Project.NameKey(project)) {

        {
            sendButton.setText(Util.C.buttonCherryPickChangeSend());
            if (info.status() == Change.Status.MERGED) {
                message.setText(Util.M.cherryPickedChangeDefaultMessage(commitMessage.trim(), revision));
            } else {
                message.setText(commitMessage.trim());
            }
        }

        @Override
        public void onSend() {
            ChangeApi.cherrypick(info.legacyId().get(), revision, getDestinationBranch(), getMessageText(), new GerritCallback<ChangeInfo>() {

                @Override
                public void onSuccess(ChangeInfo result) {
                    sent = true;
                    hide();
                    Gerrit.display(PageLinks.toChange(result.legacyId()));
                }

                @Override
                public void onFailure(Throwable caught) {
                    enableButtons(true);
                    super.onFailure(caught);
                }
            });
        }

        @Override
        public void onClose(CloseEvent<PopupPanel> event) {
            super.onClose(event);
            b.setEnabled(true);
        }
    }.center();
}
Also used : GerritCallback(com.google.gerrit.client.rpc.GerritCallback) CherryPickDialog(com.google.gerrit.client.ui.CherryPickDialog) ChangeInfo(com.google.gerrit.client.info.ChangeInfo) PopupPanel(com.google.gwt.user.client.ui.PopupPanel)

Example 13 with GerritCallback

use of com.google.gerrit.client.rpc.GerritCallback in project gerrit by GerritCodeReview.

the class QueryScreen method loadCallback.

@Override
protected AsyncCallback<ChangeList> loadCallback() {
    return new GerritCallback<ChangeList>() {

        @Override
        public void onSuccess(ChangeList result) {
            if (isAttached()) {
                if (result.length() == 1 && isSingleQuery(query)) {
                    ChangeInfo c = result.get(0);
                    Change.Id id = c.legacyId();
                    Gerrit.display(PageLinks.toChange(id));
                } else {
                    display(result);
                    QueryScreen.this.display();
                }
            }
        }
    };
}
Also used : GerritCallback(com.google.gerrit.client.rpc.GerritCallback) ChangeInfo(com.google.gerrit.client.info.ChangeInfo) Change(com.google.gerrit.reviewdb.client.Change)

Example 14 with GerritCallback

use of com.google.gerrit.client.rpc.GerritCallback in project gerrit by GerritCodeReview.

the class DraftBox method save.

void save(CallbackGroup group) {
    if (pendingGroup != null) {
        pendingGroup.addListener(group);
        return;
    }
    String message = editArea.getValue().trim();
    if (message.length() == 0) {
        return;
    }
    CommentInfo input = CommentInfo.copy(comment);
    input.message(message);
    enableEdit(false);
    pendingGroup = group;
    final LocalComments lc = new LocalComments(psId);
    GerritCallback<CommentInfo> cb = new GerritCallback<CommentInfo>() {

        @Override
        public void onSuccess(CommentInfo result) {
            enableEdit(true);
            pendingGroup = null;
            set(result);
            setEdit(false);
            if (autoClosed) {
                setOpen(false);
            }
            getCommentManager().setUnsaved(DraftBox.this, false);
        }

        @Override
        public void onFailure(Throwable e) {
            enableEdit(true);
            pendingGroup = null;
            if (RestApi.isNotSignedIn(e)) {
                CommentInfo saved = CommentInfo.copy(comment);
                saved.message(editArea.getValue().trim());
                lc.setInlineComment(saved);
            }
            super.onFailure(e);
        }
    };
    if (input.id() == null) {
        CommentApi.createDraft(psId, input, group.add(cb));
    } else {
        CommentApi.updateDraft(psId, input.id(), input, group.add(cb));
    }
    CodeMirror cm = getCm();
    cm.vim().handleKey("<Esc>");
    cm.focus();
}
Also used : GerritCallback(com.google.gerrit.client.rpc.GerritCallback) CommentInfo(com.google.gerrit.client.changes.CommentInfo) LocalComments(com.google.gerrit.client.change.LocalComments) CodeMirror(net.codemirror.lib.CodeMirror)

Example 15 with GerritCallback

use of com.google.gerrit.client.rpc.GerritCallback in project gerrit by GerritCodeReview.

the class ContactPanelShort method doSave.

void doSave() {
    final String newName;
    String name = canEditFullName() ? nameTxt.getText() : null;
    if (name != null && name.trim().isEmpty()) {
        newName = null;
    } else {
        newName = name;
    }
    final String newEmail;
    if (emailPick.isEnabled() && emailPick.getSelectedIndex() >= 0) {
        final String v = emailPick.getValue(emailPick.getSelectedIndex());
        if (Util.C.buttonOpenRegisterNewEmail().equals(v)) {
            newEmail = currentEmail;
        } else {
            newEmail = v;
        }
    } else {
        newEmail = currentEmail;
    }
    save.setEnabled(false);
    registerNewEmail.setEnabled(false);
    CallbackGroup group = new CallbackGroup();
    if (currentEmail != null && !newEmail.equals(currentEmail)) {
        AccountApi.setPreferredEmail("self", newEmail, group.add(new GerritCallback<NativeString>() {

            @Override
            public void onSuccess(NativeString result) {
            }
        }));
    }
    AccountApi.setName("self", newName, group.add(new GerritCallback<NativeString>() {

        @Override
        public void onSuccess(NativeString result) {
        }

        @Override
        public void onFailure(Throwable caught) {
            save.setEnabled(true);
            registerNewEmail.setEnabled(true);
            super.onFailure(caught);
        }
    }));
    group.done();
    group.addListener(new GerritCallback<Void>() {

        @Override
        public void onSuccess(Void result) {
            currentEmail = newEmail;
            AccountInfo me = Gerrit.getUserAccount();
            me.email(currentEmail);
            me.name(newName);
            onSaveSuccess(me);
            registerNewEmail.setEnabled(true);
        }
    });
}
Also used : GerritCallback(com.google.gerrit.client.rpc.GerritCallback) NativeString(com.google.gerrit.client.rpc.NativeString) CallbackGroup(com.google.gerrit.client.rpc.CallbackGroup) NativeString(com.google.gerrit.client.rpc.NativeString) AccountInfo(com.google.gerrit.client.info.AccountInfo)

Aggregations

GerritCallback (com.google.gerrit.client.rpc.GerritCallback)25 CallbackGroup (com.google.gerrit.client.rpc.CallbackGroup)8 ChangeInfo (com.google.gerrit.client.info.ChangeInfo)7 ClickEvent (com.google.gwt.event.dom.client.ClickEvent)7 ClickHandler (com.google.gwt.event.dom.client.ClickHandler)7 Button (com.google.gwt.user.client.ui.Button)5 VerticalPanel (com.google.gwt.user.client.ui.VerticalPanel)5 JsArray (com.google.gwt.core.client.JsArray)4 VoidResult (com.google.gerrit.client.VoidResult)3 NativeString (com.google.gerrit.client.rpc.NativeString)3 SmallHeading (com.google.gerrit.client.ui.SmallHeading)3 PopupPanel (com.google.gwt.user.client.ui.PopupPanel)3 ChangeScreen (com.google.gerrit.client.change.ChangeScreen)2 ProjectDashboardScreen (com.google.gerrit.client.changes.ProjectDashboardScreen)2 AccountInfo (com.google.gerrit.client.info.AccountInfo)2 GroupInfo (com.google.gerrit.client.info.GroupInfo)2 NpTextBox (com.google.gwtexpui.globalkey.client.NpTextBox)2 ErrorDialog (com.google.gerrit.client.ErrorDialog)1 ProjectAccessInfo (com.google.gerrit.client.access.ProjectAccessInfo)1 EditPreferences (com.google.gerrit.client.account.EditPreferences)1