Search in sources :

Example 6 with GerritCallback

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

the class Dispatcher method projects.

private static void projects(final String token) {
    String rest = skip(token);
    int c = rest.indexOf(DASHBOARDS);
    if (0 <= c) {
        final String project = URL.decodePathSegment(rest.substring(0, c));
        rest = rest.substring(c);
        if (matchPrefix(DASHBOARDS, rest)) {
            final String dashboardId = skip(rest);
            GerritCallback<DashboardInfo> cb = new GerritCallback<DashboardInfo>() {

                @Override
                public void onSuccess(DashboardInfo result) {
                    if (matchPrefix("/dashboard/", result.url())) {
                        String params = skip(result.url()).substring(1);
                        ProjectDashboardScreen dash = new ProjectDashboardScreen(new Project.NameKey(project), params);
                        Gerrit.display(token, dash);
                    }
                }

                @Override
                public void onFailure(Throwable caught) {
                    if ("default".equals(dashboardId) && RestApi.isNotFound(caught)) {
                        Gerrit.display(toChangeQuery(PageLinks.projectQuery(new Project.NameKey(project))));
                    } else {
                        super.onFailure(caught);
                    }
                }
            };
            if ("default".equals(dashboardId)) {
                DashboardList.getDefault(new Project.NameKey(project), cb);
                return;
            }
            c = dashboardId.indexOf(":");
            if (0 <= c) {
                final String ref = URL.decodeQueryString(dashboardId.substring(0, c));
                final String path = URL.decodeQueryString(dashboardId.substring(c + 1));
                DashboardList.get(new Project.NameKey(project), ref + ":" + path, cb);
                return;
            }
        }
    }
    Gerrit.display(token, new NotFoundScreen());
}
Also used : GerritCallback(com.google.gerrit.client.rpc.GerritCallback) Project(com.google.gerrit.reviewdb.client.Project) ProjectDashboardScreen(com.google.gerrit.client.changes.ProjectDashboardScreen) DashboardInfo(com.google.gerrit.client.dashboards.DashboardInfo)

Example 7 with GerritCallback

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

the class AccountGroupInfoScreen method initOwner.

private void initOwner() {
    final VerticalPanel ownerPanel = new VerticalPanel();
    ownerPanel.setStyleName(Gerrit.RESOURCES.css().groupOwnerPanel());
    ownerPanel.add(new SmallHeading(AdminConstants.I.headingOwner()));
    final AccountGroupSuggestOracle accountGroupOracle = new AccountGroupSuggestOracle();
    ownerTxt = new RemoteSuggestBox(accountGroupOracle);
    ownerTxt.setStyleName(Gerrit.RESOURCES.css().groupOwnerTextBox());
    ownerTxt.setVisibleLength(60);
    ownerPanel.add(ownerTxt);
    saveOwner = new Button(AdminConstants.I.buttonChangeGroupOwner());
    saveOwner.setEnabled(false);
    saveOwner.addClickHandler(new ClickHandler() {

        @Override
        public void onClick(final ClickEvent event) {
            final String newOwner = ownerTxt.getText().trim();
            if (newOwner.length() > 0) {
                AccountGroup.UUID ownerUuid = accountGroupOracle.getUUID(newOwner);
                String ownerId = ownerUuid != null ? ownerUuid.get() : newOwner;
                GroupApi.setGroupOwner(getGroupUUID(), ownerId, new GerritCallback<GroupInfo>() {

                    @Override
                    public void onSuccess(final GroupInfo result) {
                        updateOwnerGroup(result);
                        saveOwner.setEnabled(false);
                    }
                });
            }
        }
    });
    ownerPanel.add(saveOwner);
    add(ownerPanel);
}
Also used : AccountGroupSuggestOracle(com.google.gerrit.client.ui.AccountGroupSuggestOracle) 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) Button(com.google.gwt.user.client.ui.Button) GroupInfo(com.google.gerrit.client.info.GroupInfo) ClickEvent(com.google.gwt.event.dom.client.ClickEvent) RemoteSuggestBox(com.google.gerrit.client.ui.RemoteSuggestBox)

Example 8 with GerritCallback

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

the class CreateChangeAction method call.

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

        {
            sendButton.setText(AdminConstants.I.buttonCreate());
            message.setText(AdminConstants.I.buttonCreateDescription());
        }

        @Override
        public void onSend() {
            ChangeApi.createChange(project, getDestinationBranch(), getDestinationTopic(), message.getText(), null, 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) CreateChangeDialog(com.google.gerrit.client.ui.CreateChangeDialog) PopupPanel(com.google.gwt.user.client.ui.PopupPanel)

Example 9 with GerritCallback

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

the class Gerrit method onModuleLoad.

@Override
public void onModuleLoad() {
    if (!canLoadInIFrame()) {
        UserAgent.assertNotInIFrame();
    }
    setXsrfToken();
    KeyUtil.setEncoderImpl(new KeyUtil.Encoder() {

        @Override
        public String encode(String e) {
            e = URL.encodeQueryString(e);
            e = fixPathImpl(e);
            e = fixColonImpl(e);
            e = fixDoubleQuote(e);
            return e;
        }

        @Override
        public String decode(final String e) {
            return URL.decodeQueryString(e);
        }

        private native String fixPathImpl(String path);

        private native String fixColonImpl(String path);

        private native String fixDoubleQuote(String path);
    });
    initHostname();
    Window.setTitle(M.windowTitle1(myHost));
    RpcStatus.INSTANCE = new RpcStatus();
    CallbackGroup cbg = new CallbackGroup();
    getDocIndex(cbg.add(new GerritCallback<DocInfo>() {

        @Override
        public void onSuccess(DocInfo indexInfo) {
            hasDocumentation = indexInfo != null;
            docUrl = selfRedirect("/Documentation/");
        }
    }));
    ConfigServerApi.serverInfo(cbg.add(new GerritCallback<ServerInfo>() {

        @Override
        public void onSuccess(ServerInfo info) {
            myServerInfo = info;
            urlAliasMatcher = new UrlAliasMatcher(info.urlAliases());
            String du = info.gerrit().docUrl();
            if (du != null && !du.isEmpty()) {
                hasDocumentation = true;
                docUrl = du;
            }
            docSearch = info.gerrit().docSearch();
        }
    }));
    HostPageDataService hpd = GWT.create(HostPageDataService.class);
    hpd.load(cbg.addFinal(new GerritCallback<HostPageData>() {

        @Override
        public void onSuccess(final HostPageData result) {
            Document.get().getElementById("gerrit_hostpagedata").removeFromParent();
            myTheme = result.theme;
            isNoteDbEnabled = result.isNoteDbEnabled;
            if (result.accountDiffPref != null) {
                myAccountDiffPref = result.accountDiffPref;
            }
            if (result.accountDiffPref != null) {
                // TODO: Support options on the GetDetail REST endpoint so that it can
                // also return the preferences. Then we can fetch everything with a
                // single request and we don't need the callback group anymore.
                CallbackGroup cbg = new CallbackGroup();
                AccountApi.self().view("detail").get(cbg.add(new GerritCallback<AccountInfo>() {

                    @Override
                    public void onSuccess(AccountInfo result) {
                        myAccount = result;
                    }
                }));
                AccountApi.self().view("preferences").get(cbg.add(new GerritCallback<GeneralPreferences>() {

                    @Override
                    public void onSuccess(GeneralPreferences prefs) {
                        myPrefs = prefs;
                        onModuleLoad2(result);
                    }
                }));
                AccountApi.getEditPreferences(cbg.addFinal(new GerritCallback<EditPreferences>() {

                    @Override
                    public void onSuccess(EditPreferences prefs) {
                        EditPreferencesInfo prefsInfo = new EditPreferencesInfo();
                        prefs.copyTo(prefsInfo);
                        editPrefs = prefsInfo;
                    }
                }));
            } else {
                myAccount = AccountInfo.create(0, null, null, null);
                myPrefs = GeneralPreferences.createDefault();
                editPrefs = null;
                onModuleLoad2(result);
            }
        }
    }));
}
Also used : DocInfo(com.google.gerrit.client.documentation.DocInfo) ServerInfo(com.google.gerrit.client.info.ServerInfo) GeneralPreferences(com.google.gerrit.client.info.GeneralPreferences) CallbackGroup(com.google.gerrit.client.rpc.CallbackGroup) EditPreferences(com.google.gerrit.client.account.EditPreferences) HostPageData(com.google.gerrit.common.data.HostPageData) GerritCallback(com.google.gerrit.client.rpc.GerritCallback) EditPreferencesInfo(com.google.gerrit.extensions.client.EditPreferencesInfo) AccountInfo(com.google.gerrit.client.info.AccountInfo) KeyUtil(com.google.gwtorm.client.KeyUtil)

Example 10 with GerritCallback

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

the class ContactPanelShort method onLoad.

@Override
protected void onLoad() {
    super.onLoad();
    onInitUI();
    body.add(save);
    display(Gerrit.getUserAccount());
    emailPick.clear();
    emailPick.setEnabled(false);
    registerNewEmail.setEnabled(false);
    haveAccount = false;
    haveEmails = false;
    CallbackGroup group = new CallbackGroup();
    AccountApi.getName("self", group.add(new GerritCallback<NativeString>() {

        @Override
        public void onSuccess(NativeString result) {
            nameTxt.setText(result.asString());
            haveAccount = true;
        }

        @Override
        public void onFailure(Throwable caught) {
        }
    }));
    AccountApi.getEmails("self", group.addFinal(new GerritCallback<JsArray<EmailInfo>>() {

        @Override
        public void onSuccess(JsArray<EmailInfo> result) {
            for (EmailInfo i : Natives.asList(result)) {
                emailPick.addItem(i.email());
                if (i.isPreferred()) {
                    currentEmail = i.email();
                }
            }
            haveEmails = true;
            postLoad();
        }
    }));
}
Also used : GerritCallback(com.google.gerrit.client.rpc.GerritCallback) NativeString(com.google.gerrit.client.rpc.NativeString) JsArray(com.google.gwt.core.client.JsArray) CallbackGroup(com.google.gerrit.client.rpc.CallbackGroup)

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