Search in sources :

Example 21 with GerritCallback

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

the class AccountGroupInfoScreen method initDescription.

private void initDescription() {
    final VerticalPanel vp = new VerticalPanel();
    vp.setStyleName(Gerrit.RESOURCES.css().groupDescriptionPanel());
    vp.add(new SmallHeading(AdminConstants.I.headingDescription()));
    descTxt = new NpTextArea();
    descTxt.setVisibleLines(6);
    descTxt.setCharacterWidth(60);
    vp.add(descTxt);
    saveDesc = new Button(AdminConstants.I.buttonSaveDescription());
    saveDesc.setEnabled(false);
    saveDesc.addClickHandler(new ClickHandler() {

        @Override
        public void onClick(final ClickEvent event) {
            final String txt = descTxt.getText().trim();
            GroupApi.setGroupDescription(getGroupUUID(), txt, new GerritCallback<VoidResult>() {

                @Override
                public void onSuccess(final VoidResult result) {
                    saveDesc.setEnabled(false);
                }
            });
        }
    });
    vp.add(saveDesc);
    add(vp);
}
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) ClickEvent(com.google.gwt.event.dom.client.ClickEvent) NpTextArea(com.google.gwtexpui.globalkey.client.NpTextArea)

Example 22 with GerritCallback

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

the class AccountGroupInfoScreen method initName.

private void initName() {
    final VerticalPanel groupNamePanel = new VerticalPanel();
    groupNamePanel.setStyleName(Gerrit.RESOURCES.css().groupNamePanel());
    groupNameTxt = new NpTextBox();
    groupNameTxt.setStyleName(Gerrit.RESOURCES.css().groupNameTextBox());
    groupNameTxt.setVisibleLength(60);
    groupNamePanel.add(groupNameTxt);
    saveName = new Button(AdminConstants.I.buttonRenameGroup());
    saveName.setEnabled(false);
    saveName.addClickHandler(new ClickHandler() {

        @Override
        public void onClick(final ClickEvent event) {
            final String newName = groupNameTxt.getText().trim();
            GroupApi.renameGroup(getGroupUUID(), newName, new GerritCallback<com.google.gerrit.client.VoidResult>() {

                @Override
                public void onSuccess(final com.google.gerrit.client.VoidResult result) {
                    saveName.setEnabled(false);
                    setPageTitle(AdminMessages.I.group(newName));
                    groupNameTxt.setText(newName);
                    if (getGroupUUID().equals(getOwnerGroupUUID())) {
                        ownerTxt.setText(newName);
                    }
                }
            });
        }
    });
    groupNamePanel.add(saveName);
    add(groupNamePanel);
}
Also used : VoidResult(com.google.gerrit.client.VoidResult) ClickEvent(com.google.gwt.event.dom.client.ClickEvent) NpTextBox(com.google.gwtexpui.globalkey.client.NpTextBox) GerritCallback(com.google.gerrit.client.rpc.GerritCallback) VerticalPanel(com.google.gwt.user.client.ui.VerticalPanel) ClickHandler(com.google.gwt.event.dom.client.ClickHandler) Button(com.google.gwt.user.client.ui.Button)

Example 23 with GerritCallback

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

the class ActionContext method wrap.

private static GerritCallback<JavaScriptObject> wrap(final JavaScriptObject cb) {
    return new GerritCallback<JavaScriptObject>() {

        @Override
        public void onSuccess(JavaScriptObject result) {
            if (NativeString.is(result)) {
                NativeString s = result.cast();
                ApiGlue.invoke(cb, s.asString());
            } else {
                ApiGlue.invoke(cb, result);
            }
        }
    };
}
Also used : GerritCallback(com.google.gerrit.client.rpc.GerritCallback) NativeString(com.google.gerrit.client.rpc.NativeString) JavaScriptObject(com.google.gwt.core.client.JavaScriptObject)

Example 24 with GerritCallback

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

the class RevertAction method call.

static void call(final Button b, final Change.Id id, final String revision, final String commitSubject) {
    // TODO Replace ActionDialog with a nicer looking display.
    b.setEnabled(false);
    new TextAreaActionDialog(Util.C.revertChangeTitle(), Util.C.headingRevertMessage()) {

        {
            sendButton.setText(Util.C.buttonRevertChangeSend());
            message.setText(Util.M.revertChangeDefaultMessage(commitSubject, revision));
        }

        @Override
        public void onSend() {
            ChangeApi.revert(id.get(), 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) ChangeInfo(com.google.gerrit.client.info.ChangeInfo) PopupPanel(com.google.gwt.user.client.ui.PopupPanel) TextAreaActionDialog(com.google.gerrit.client.ui.TextAreaActionDialog)

Example 25 with GerritCallback

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

the class RebaseAction method call.

static void call(final Button b, final String project, final String branch, final Change.Id id, final String revision, final boolean enabled) {
    b.setEnabled(false);
    new RebaseDialog(project, branch, id, enabled) {

        @Override
        public void onSend() {
            ChangeApi.rebase(id.get(), revision, getBase(), new GerritCallback<ChangeInfo>() {

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

                @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) RebaseDialog(com.google.gerrit.client.ui.RebaseDialog) ChangeInfo(com.google.gerrit.client.info.ChangeInfo) PopupPanel(com.google.gwt.user.client.ui.PopupPanel)

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