Search in sources :

Example 1 with Preferences

use of nl.tudelft.watchdog.intellij.ui.preferences.Preferences in project watchdog by TestRoots.

the class WatchDogStartUp method checkWhetherToDisplayUserProjectRegistrationWizard.

/**
 * Checks whether there is a registered WatchDog user
 */
private void checkWhetherToDisplayUserProjectRegistrationWizard() {
    Preferences preferences = Preferences.getInstance();
    ProjectPreferenceSetting projectSetting = preferences.getOrCreateProjectSetting(project.getName());
    if (!WatchDogUtils.isEmpty(WatchDogGlobals.getPreferences().getUserId()) || (projectSetting.startupQuestionAsked && !projectSetting.enableWatchdog)) {
        return;
    }
    UserProjectRegistrationWizard wizard = new UserProjectRegistrationWizard("User and Project Registration", project);
    wizard.show();
    if (wizard.getExitCode() == DialogWrapper.CANCEL_EXIT_CODE) {
        if (Messages.YES == Messages.showYesNoDialog(WATCHDOG_UNREGISTERED_WARNING, "WatchDog is not registered!", Messages.getQuestionIcon())) {
            makeSilentRegistration();
        } else {
            userProjectRegistrationCancelled = true;
            preferences.registerProjectUse(project.getName(), false);
        }
    }
}
Also used : Preferences(nl.tudelft.watchdog.intellij.ui.preferences.Preferences) ProjectPreferenceSetting(nl.tudelft.watchdog.core.ui.preferences.ProjectPreferenceSetting) UserProjectRegistrationWizard(nl.tudelft.watchdog.intellij.ui.wizards.userregistration.UserProjectRegistrationWizard)

Example 2 with Preferences

use of nl.tudelft.watchdog.intellij.ui.preferences.Preferences in project watchdog by TestRoots.

the class WatchDogStartUp method makeSilentRegistration.

private void makeSilentRegistration() {
    String userId = "";
    Preferences preferences = Preferences.getInstance();
    if (preferences.getUserId() == null || preferences.getUserId().isEmpty()) {
        User user = new User();
        user.programmingExperience = "NA";
        try {
            userId = new JsonTransferer().registerNewUser(user);
        } catch (ServerCommunicationException exception) {
            WatchDogLogger.getInstance().logSevere(exception);
        }
        if (WatchDogUtils.isEmptyOrHasOnlyWhitespaces(userId)) {
            return;
        }
        preferences.setUserId(userId);
        preferences.registerProjectId(WatchDogUtils.getProjectName(), "");
    }
    registerAnonymousProject(preferences.getUserId());
}
Also used : JsonTransferer(nl.tudelft.watchdog.core.logic.network.JsonTransferer) ServerCommunicationException(nl.tudelft.watchdog.core.logic.network.ServerCommunicationException) User(nl.tudelft.watchdog.core.ui.wizards.User) Preferences(nl.tudelft.watchdog.intellij.ui.preferences.Preferences)

Example 3 with Preferences

use of nl.tudelft.watchdog.intellij.ui.preferences.Preferences in project watchdog by TestRoots.

the class WatchDogStartUp method registerAnonymousProject.

private void registerAnonymousProject(String userId) {
    String projectId = "";
    Preferences preferences = Preferences.getInstance();
    try {
        projectId = new JsonTransferer().registerNewProject(new nl.tudelft.watchdog.core.ui.wizards.Project(userId));
    } catch (ServerCommunicationException exception) {
        WatchDogLogger.getInstance().logSevere(exception);
    }
    if (WatchDogUtils.isEmptyOrHasOnlyWhitespaces(projectId)) {
        return;
    }
    preferences.registerProjectId(WatchDogUtils.getProjectName(), projectId);
    preferences.registerProjectUse(WatchDogUtils.getProjectName(), true);
}
Also used : JsonTransferer(nl.tudelft.watchdog.core.logic.network.JsonTransferer) ServerCommunicationException(nl.tudelft.watchdog.core.logic.network.ServerCommunicationException) Project(com.intellij.openapi.project.Project) Preferences(nl.tudelft.watchdog.intellij.ui.preferences.Preferences)

Example 4 with Preferences

use of nl.tudelft.watchdog.intellij.ui.preferences.Preferences in project watchdog by TestRoots.

the class UserRegistrationStep method makeRegistration.

protected void makeRegistration() {
    User user = new User();
    user.email = getEmailInput().getText();
    user.organization = getOrganizationInput().getText();
    user.mayContactUser = getMayContactUser();
    user.programmingExperience = getProgrammingExperience();
    user.operatingSystem = System.getProperty("os.name");
    try {
        id = new JsonTransferer().registerNewUser(user);
    } catch (ServerCommunicationException exception) {
        successfulRegistration = false;
        messageTitle = "Problem creating new user!";
        messageBody = "<html>" + WordUtils.wrap(exception.getMessage(), 100, "<br>", true);
        messageBody += "<br>Are you connected to the internet, and is port 80 open?";
        messageBody += "<br>Please contact us via www.testroots.org. <br>We'll troubleshoot the issue!</html>";
        return;
    }
    successfulRegistration = true;
    ((UserProjectRegistrationWizard) getWizard()).userid = id;
    messageTitle = "New user registered!";
    messageBody = "Your new user id is registered: ";
    Preferences preferences = Preferences.getInstance();
    preferences.setUserId(id);
    preferences.registerProjectId(WatchDogUtils.getProjectName(), "");
    preferences.setProgrammingExperience(user.programmingExperience);
}
Also used : JsonTransferer(nl.tudelft.watchdog.core.logic.network.JsonTransferer) ServerCommunicationException(nl.tudelft.watchdog.core.logic.network.ServerCommunicationException) User(nl.tudelft.watchdog.core.ui.wizards.User) Preferences(nl.tudelft.watchdog.intellij.ui.preferences.Preferences)

Example 5 with Preferences

use of nl.tudelft.watchdog.intellij.ui.preferences.Preferences in project watchdog by TestRoots.

the class RegistrationWizardBase method performFinish.

public void performFinish() {
    Preferences preferences = Preferences.getInstance();
    preferences.registerProjectId(WatchDogUtils.getProjectName(), projectId);
    preferences.registerProjectUse(WatchDogUtils.getProjectName(), true);
    return;
}
Also used : Preferences(nl.tudelft.watchdog.intellij.ui.preferences.Preferences)

Aggregations

Preferences (nl.tudelft.watchdog.intellij.ui.preferences.Preferences)5 JsonTransferer (nl.tudelft.watchdog.core.logic.network.JsonTransferer)3 ServerCommunicationException (nl.tudelft.watchdog.core.logic.network.ServerCommunicationException)3 User (nl.tudelft.watchdog.core.ui.wizards.User)2 Project (com.intellij.openapi.project.Project)1 ProjectPreferenceSetting (nl.tudelft.watchdog.core.ui.preferences.ProjectPreferenceSetting)1 UserProjectRegistrationWizard (nl.tudelft.watchdog.intellij.ui.wizards.userregistration.UserProjectRegistrationWizard)1