Package edu.stanford.bmir.protege.web.shared.user

Examples of edu.stanford.bmir.protege.web.shared.user.UserId


        editProfileTable.getFlexCellFormatter().setHeight(6, 0, "25px");
        editProfileTable.getFlexCellFormatter().setHeight(7, 0, "50px");

        editProfileFormPanel.add(editProfileTable);

        final UserId userId = Application.get().getUserId();
        final TextBox userNameTextBox = new TextBox();
        userNameTextBox.setWidth("250px");
        userNameTextBox.setEnabled(false);
        Label userNameLabel = new Label("User name:");
        userNameLabel.setStyleName("label");

        editProfileTable.setWidget(2, 0, userNameLabel);
        editProfileTable.setWidget(2, 1, userNameTextBox);

        if (!userId.isGuest()) {
            userNameTextBox.setText(userId.getUserName());
        }

        final HTML changePasswordHTML = new HTML(
                "&nbsp<b><span style='font-size:100%;text-decoration:underline;'>Click here to change your password</span></b>");
        changePasswordHTML.setStyleName("links-blue");
        //if else https
//        addChangePasswordHTMLClickHandler(changePasswordHTML);

        editProfileTable.setWidget(3, 1, changePasswordHTML);

        final TextBox userEmailTextBox = new TextBox();
        userEmailTextBox.setWidth("250px");
        Label emailIdLabel = new Label("Email:");
        emailIdLabel.setStyleName("label");
        editProfileTable.setWidget(4, 0, emailIdLabel);
        editProfileTable.setWidget(4, 1, userEmailTextBox);


        Label ontologyNotificationIdLabel = new Label("Notify me of ont. changes:");
        ontologyNotificationIdLabel.setStyleName("label");
        final ListBox ontologyNotificationListBox = new ListBox(false);
        ontologyNotificationListBox.setWidth("250px");
        ontologyNotificationListBox.addItem(NotificationInterval.NEVER.getValue());
        ontologyNotificationListBox.addItem(NotificationInterval.IMMEDIATELY.getValue());
        ontologyNotificationListBox.addItem(NotificationInterval.HOURLY.getValue());
        ontologyNotificationListBox.addItem(NotificationInterval.DAILY.getValue());
        ontologyNotificationListBox.setSelectedIndex(1);
        editProfileTable.setWidget(5, 0, ontologyNotificationIdLabel);
        editProfileTable.setWidget(5, 1, ontologyNotificationListBox);

        Label commentsNotificationIdLabel = new Label("Notify me of discussions:");
        commentsNotificationIdLabel.setStyleName("label");
        final ListBox commentsNotificationListBox = new ListBox(false);
        commentsNotificationListBox .setWidth("250px");
        commentsNotificationListBox.addItem(NotificationInterval.NEVER.getValue());
        commentsNotificationListBox.addItem(NotificationInterval.IMMEDIATELY.getValue());
        commentsNotificationListBox.addItem(NotificationInterval.HOURLY.getValue());
        commentsNotificationListBox.addItem(NotificationInterval.DAILY.getValue());
        commentsNotificationListBox.setSelectedIndex(1);
        editProfileTable.setWidget(6, 0, commentsNotificationIdLabel );
        editProfileTable.setWidget(6, 1, commentsNotificationListBox );

        Button okButton = new Button("Ok", new OkButtonListenerAdapter(win, userEmailTextBox, userNameTextBox, commentsNotificationListBox, ontologyNotificationListBox));

        Button cancelButton = new Button("Cancel", new ButtonListenerAdapter() {
            @Override
            public void onClick(Button button, EventObject e) {
                win.close();
            }
        });

        HorizontalPanel buttonPanel = new HorizontalPanel();
        buttonPanel.setSpacing(20);
        buttonPanel.add(okButton);
        buttonPanel.add(cancelButton);

        editProfileTable.setWidget(7, 1, buttonPanel);
        editProfileTable.getFlexCellFormatter()
                .setAlignment(7, 1, HasAlignment.ALIGN_CENTER, HasAlignment.ALIGN_MIDDLE);

        FlexTable topEditProfileTable = new FlexTable();
        topEditProfileTable.setWidget(0, 0, editProfileFormPanel);
        topEditProfileTable.getFlexCellFormatter().setAlignment(0, 0, HasAlignment.ALIGN_CENTER,
                HasAlignment.ALIGN_MIDDLE);
        Panel panel = new Panel();
        panel.setBorder(false);
        panel.setPaddings(15);
        panel.setCls("loginpanel");
        panel.setLayout(new FitLayout());
        win.setLayout(new FitLayout());

        panel.add(topEditProfileTable, new AnchorLayoutData("-100 30%"));

        win.setTitle("Edit Profile");
        win.setClosable(true);
        win.setWidth(408);
        win.setHeight(400);
        win.setClosable(true);
        win.setPaddings(7);
        win.setCloseAction(Window.HIDE);
        win.add(panel);
        if (!userId.isGuest()) {
            win.show();

            win.getEl().mask("Retrieving user email...");
            AdminServiceManager.getInstance().getUserEmail(userId, new RetrieveUserEmailHandler(win, userEmailTextBox));

            NotificationServiceManager.getInstance().getNotificationDelay(userId, new AsyncCallback<Map<NotificationType, NotificationInterval>>() {

                public void onSuccess(Map<NotificationType, NotificationInterval> notificationPreferences) {
                    win.getEl().unmask();
                    for (NotificationType type : notificationPreferences.keySet()) {
                        if (type.equals(NotificationType.ONTOLOGY)){
                            int i = 0;
                            while (i < ontologyNotificationListBox.getItemCount()){
                                final String s = ontologyNotificationListBox.getItemText(i);
                                if (notificationPreferences.get(type).getValue().equals(s)){
                                    ontologyNotificationListBox.setItemSelected(i, true);
                                }
                                i ++;
                            }
                        }
                        if (type.equals(NotificationType.COMMENT)){
                            int i = 0;
                            while (i < commentsNotificationListBox.getItemCount()){
                                final String s = commentsNotificationListBox.getItemText(i);
                                if (notificationPreferences.get(type).getValue().equals(s)){
                                    commentsNotificationListBox.setItemSelected(i, true);
                                }
                                i ++;
                            }
                        }
                    }
                }

                public void onFailure(Throwable caught) {
                    GWT.log("Error at Getting User Notification Preferences:", caught);
                    win.getEl().unmask();
                    MessageBox.alert("failed. Please try again. Message: " + caught.getMessage());
                    win.close();
                }
            });

//            final FlexTable editProfTable = editProfileTable;
            OpenIdServiceManager.getInstance().getUsersOpenId(userId.getUserName(), new GetUsersOpenIdHandler(win, editProfileTable));
        } else {
            MessageBox.alert("Error at Getting User Name, Please try again");
        }
    }
View Full Code Here


            isEmailValid = isValidEmail(userEmailTextBox.getText().trim());
            if (userEmailTextBox.getText().trim().isEmpty() || isEmailValid) {
                win.getEl().mask("Saving email ...");
                final EditProfileHandler callback = new EditProfileHandler(win);
                final String userName = userNameTextBox.getText().trim();
                final UserId userId = UserId.getUserId(userName);
                DispatchServiceManager.get().execute(new SetEmailAddressAction(userId, userEmailTextBox.getText().trim()), new EmptySuccessWebProtegeCallback<SetEmailAddressResult>());
                NotificationServiceManager.getInstance().setNotificationDelay(userId,
                            NotificationType.COMMENT, NotificationInterval.fromString(commentsNotification.getItemText(commentsNotification.getSelectedIndex())), callback);
                    NotificationServiceManager.getInstance().setNotificationDelay(userId,
                            NotificationType.ONTOLOGY, NotificationInterval.fromString(ontologyNotification.getItemText(ontologyNotification.getSelectedIndex())), callback);
View Full Code Here

    }


    public void pollForProjectEvents() {
        GWT.log("[Event Polling Manager] Polling for project events for " + projectId + " from " + nextTag);
        UserId userId = Application.get().getUserId();
        DispatchServiceManager.get().execute(new GetProjectEventsAction(nextTag, projectId, userId), new AsyncCallback<GetProjectEventsResult>() {
            @Override
            public void onFailure(Throwable caught) {
            }
View Full Code Here

            return UserId.getGuest();
        }
        AuthenticationUtil authenticatinUtil = new AuthenticationUtil();
        boolean isverified = authenticatinUtil.verifyChallengedHash(user.getDigestedPassword(), response, challenge);
        if (isverified) {
            UserId userId = UserId.getUserId(user.getName());
            SessionConstants.setAttribute(SessionConstants.USER_ID, userId, session);
            return userId;
        }
        else {
            return UserId.getGuest();
View Full Code Here

     *
     * @return The {@link UserId} of the signed in user associated with the thread local request.
     * @throws NotSignedInException if there is not a signed in user associated with the thread local request.
     */
    public UserId getUserInSessionAndEnsureSignedIn() throws NotSignedInException {
        UserId userId = getUserInSession();
        if (userId.isGuest()) {
            throw new NotSignedInException();
        } else {
            return userId;
        }
    }
View Full Code Here

     * @param projectId The project id
     * @return <code>true</code> if the project exists AND there is a user signed in AND the signed in user is the
     *         owner of the project, otherwise <code>false</code>.
     */
    protected boolean isSignedInUserProjectOwner(ProjectId projectId) {
        UserId userId = getUserInSession();
        if (userId.isGuest()) {
            return false;
        }
        MetaProjectManager mpm = getMetaProjectManager();
        MetaProject metaProject = mpm.getMetaProject();
        ProjectInstance project = metaProject.getProject(projectId.getId());
        if (project == null) {
            return false;
        }
        User owner = project.getOwner();
        return owner != null && userId.getUserName().equals(owner.getName());
    }
View Full Code Here

     *
     * @return <code>true</code> if there is a user signed in AND the signed in user corresponds to a user which exists
     *         where that user is an admin, otherwise <code>false</code>
     */
    protected boolean isSignedInUserAdmin() {
        UserId userId = getUserInSession();
        if (userId.isGuest()) {
            return false;
        }
        MetaProjectManager mpm = getMetaProjectManager();
        MetaProject metaProject = mpm.getMetaProject();
        User user = metaProject.getUser(userId.getUserName());
        if (user == null) {
            return false;
        }
        for (Group group : user.getGroups()) {
            if (OntologyShareAccessConstants.ADMIN_GROUP.equals(group.getName())) {
View Full Code Here

        }
        return result;
    }

    public synchronized List<String> getOwnedProjectNames() {
        UserId userId = getUserInSession();
        if(userId.isGuest()) {
            return Collections.emptyList();
        }
        List<String> result = new ArrayList<String>();
        MetaProjectManager mpm = getMetaProjectManager();
        MetaProject mp = mpm.getMetaProject();
        for (ProjectInstance instance : mp.getProjects()) {
            User owner = instance.getOwner();
            if(owner != null && userId.getUserName().equals(owner.getName())) {
                String projectName = instance.getName();
                result.add(projectName);
            }
        }
        return result;
View Full Code Here

     * but the signed in user is an editor.
     * @param projectId The project id that identifies the project to apply sharing settings to.
     */
    private void applyDefaultSharingSettings(ProjectId projectId) {
        List<UserSharingSetting> userSharingSettings = new ArrayList<UserSharingSetting>();
        UserId userInSession = getUserInSession();
        if (!userInSession.isGuest()) {
            userSharingSettings.add(new UserSharingSetting(userInSession, SharingSetting.EDIT));
        }
        SharingSettingsManager.getManager().updateSharingSettings(getThreadLocalRequest(), new ProjectSharingSettings(projectId, SharingSetting.NONE, userSharingSettings));
    }
View Full Code Here

            }

            @Override
            public void onSuccess() {
                final LoginUtil loginUtil = new LoginUtil();
                UserId userId = Application.get().getUserId();
                if (userId.isGuest()) {
                    Boolean isLoginWithHttps = Application.get().getClientApplicationProperty(WebProtegePropertyName.HTTPS_ENABLED, false);
                    if (isLoginWithHttps) {
                        String httpsPort = Application.get().getClientApplicationProperty(WebProtegePropertyName.HTTPS_PORT).orNull();
                        String authenUrl = loginUtil.getAuthenticateWindowUrl(AuthenticationConstants.AUTHEN_TYPE_LOGIN, httpsPort);
                        authenUrl = authenUrl + "&" + AuthenticationConstants.PROTOCOL + "=" + com.google.gwt.user.client.Window.Location.getProtocol();
View Full Code Here

TOP

Related Classes of edu.stanford.bmir.protege.web.shared.user.UserId

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.