Search in sources :

Example 6 with ProjectPreferenceSetting

use of nl.tudelft.watchdog.core.ui.preferences.ProjectPreferenceSetting in project watchdog by TestRoots.

the class StartupUIThread method checkWhetherToDisplayUserProjectRegistrationWizard.

/**
 * Checks whether there is a registered WatchDog user
 */
private void checkWhetherToDisplayUserProjectRegistrationWizard() {
    ProjectPreferenceSetting projectSetting = preferences.getOrCreateProjectSetting(workspaceName);
    if (!WatchDogUtils.isEmpty(preferences.getUserId()) || (projectSetting.startupQuestionAsked && !projectSetting.enableWatchdog))
        return;
    UserRegistrationWizardDialogHandler newUserWizardHandler = new UserRegistrationWizardDialogHandler();
    try {
        int statusCode = (int) newUserWizardHandler.execute(new ExecutionEvent());
        savePreferenceStoreIfNeeded();
        if (statusCode == Window.CANCEL) {
            boolean shouldRegisterAnonymously = MessageDialog.openQuestion(null, "WatchDog not active!", WATCHDOG_INACTIVE_WARNING);
            if (shouldRegisterAnonymously) {
                makeSilentRegistration();
            } else {
                userProjectRegistrationCancelled = true;
                preferences.registerProjectUse(WatchDogUtils.getWorkspaceName(), false);
            }
        }
    } catch (ExecutionException exception) {
        // when the new user wizard cannot be displayed, new
        // users cannot register with WatchDog.
        WatchDogLogger.getInstance().logSevere(exception);
    }
}
Also used : ExecutionEvent(org.eclipse.core.commands.ExecutionEvent) ExecutionException(org.eclipse.core.commands.ExecutionException) ProjectPreferenceSetting(nl.tudelft.watchdog.core.ui.preferences.ProjectPreferenceSetting)

Example 7 with ProjectPreferenceSetting

use of nl.tudelft.watchdog.core.ui.preferences.ProjectPreferenceSetting in project watchdog by TestRoots.

the class InfoDialog method createCheckIdsOnServer.

private void createCheckIdsOnServer(Composite container, Preferences preferences) {
    UIUtils.createLabel(" ", container);
    UIUtils.createLabel(" ", container);
    UIUtils.createLabel("User ID: ", container);
    Connection userConnection = NetworkUtils.urlExistsAndReturnsStatus200(NetworkUtils.buildExistingUserURL(preferences.getUserId()));
    reactOnConnectionStatus(container, userConnection, new UserButtonListener());
    Connection projectConnection = Connection.UNSUCCESSFUL;
    ProjectPreferenceSetting workspaceSettings = preferences.getOrCreateProjectSetting(WatchDogUtils.getWorkspaceName());
    boolean projectIdHasProblem = false;
    if (userConnection == Connection.SUCCESSFUL && workspaceSettings.enableWatchdog) {
        UIUtils.createLabel("Project ID: ", container);
        projectConnection = NetworkUtils.urlExistsAndReturnsStatus200(NetworkUtils.buildExistingProjectURL(workspaceSettings.projectId));
        if (projectConnection != Connection.SUCCESSFUL) {
            projectIdHasProblem = true;
        }
        reactOnConnectionStatus(container, projectConnection, new ProjectButtonListener());
    }
    if (userConnection != Connection.SUCCESSFUL || projectIdHasProblem) {
        UIUtils.createLabel(" ", container);
        UIUtils.createLabel("WatchDog cannot transfer its data.", container, colorRed);
    }
}
Also used : Connection(nl.tudelft.watchdog.core.logic.network.NetworkUtils.Connection) ProjectPreferenceSetting(nl.tudelft.watchdog.core.ui.preferences.ProjectPreferenceSetting)

Example 8 with ProjectPreferenceSetting

use of nl.tudelft.watchdog.core.ui.preferences.ProjectPreferenceSetting in project watchdog by TestRoots.

the class PreferencePage method createComponent.

@Nullable
@Override
public JComponent createComponent() {
    main = new JPanel();
    main.setLayout(new BoxLayout(main, BoxLayout.Y_AXIS));
    JPanel localGroup = UIUtils.createGroup(main, "Local Settings", 1);
    UIUtils.createLabel(localGroup, "Here you can define the local WatchDog settings for this project.");
    UIUtils.createLabel(localGroup, "");
    JPanel projectJPanel = UIUtils.createFlowJPanelLeft(localGroup);
    UIUtils.createLabel(projectJPanel, "Project-ID ");
    projectIDInput = UIUtils.createLimitedTextInputField(projectJPanel, ID_LENGTH);
    ProjectPreferenceSetting projectSetting = preferences.getOrCreateProjectSetting(WatchDogUtils.getProjectName());
    projectIDInput.setText(projectSetting.projectId);
    enableWatchdogInput = UIUtils.createCheckBox(localGroup, "Monitor this project with WatchDog ");
    enableWatchdogInput.setSelected(projectSetting.enableWatchdog);
    UIUtils.createLabel(main, "");
    JPanel globalGroup = UIUtils.createGroup(main, "Global Settings", 1);
    UIUtils.createLabel(globalGroup, "Here you can enter settings that will affect WatchDog no matter which project you have opened.  ");
    UIUtils.createLabel(globalGroup, "");
    JPanel userJPanel = UIUtils.createFlowJPanelLeft(globalGroup);
    UIUtils.createLabel(userJPanel, "User-ID ");
    userIDInput = UIUtils.createLimitedTextInputField(userJPanel, ID_LENGTH);
    userIDInput.setText(preferences.getUserId());
    JPanel serverJPanel = UIUtils.createFlowJPanelLeft(globalGroup);
    UIUtils.createLabel(serverJPanel, "Server-URL ");
    serverURLInput = UIUtils.createTextInputField(serverJPanel, WatchDogGlobals.DEFAULT_SERVER_URI.length());
    serverURLInput.setMinimumSize(serverURLInput.getPreferredSize());
    serverURLInput.setMaximumSize(serverURLInput.getPreferredSize());
    serverURLInput.setText(preferences.getServerURI());
    serverURLInput.getDocument().addDocumentListener(new DocumentAdapter() {

        @Override
        protected void textChanged(DocumentEvent e) {
            isModified = true;
        }
    });
    enableAuthentication = UIUtils.createCheckBox(globalGroup, "Enable Authentication");
    enableAuthentication.setSelected(preferences.isAuthenticationEnabled());
    enableLogging = UIUtils.createCheckBox(globalGroup, "Enable Logging");
    enableLogging.setSelected(preferences.isLoggingEnabled());
    addModificationListeners();
    return main;
}
Also used : DocumentAdapter(com.intellij.ui.DocumentAdapter) DocumentEvent(javax.swing.event.DocumentEvent) ProjectPreferenceSetting(nl.tudelft.watchdog.core.ui.preferences.ProjectPreferenceSetting) Nullable(org.jetbrains.annotations.Nullable)

Aggregations

ProjectPreferenceSetting (nl.tudelft.watchdog.core.ui.preferences.ProjectPreferenceSetting)8 UserProjectRegistrationWizard (nl.tudelft.watchdog.intellij.ui.wizards.userregistration.UserProjectRegistrationWizard)2 ViewToolWindowButtonsAction (com.intellij.ide.actions.ViewToolWindowButtonsAction)1 DocumentAdapter (com.intellij.ui.DocumentAdapter)1 DocumentEvent (javax.swing.event.DocumentEvent)1 Connection (nl.tudelft.watchdog.core.logic.network.NetworkUtils.Connection)1 Preferences (nl.tudelft.watchdog.intellij.ui.preferences.Preferences)1 ProjectRegistrationWizard (nl.tudelft.watchdog.intellij.ui.wizards.projectregistration.ProjectRegistrationWizard)1 ExecutionEvent (org.eclipse.core.commands.ExecutionEvent)1 ExecutionException (org.eclipse.core.commands.ExecutionException)1 Color (org.eclipse.swt.graphics.Color)1 Button (org.eclipse.swt.widgets.Button)1 Composite (org.eclipse.swt.widgets.Composite)1 Group (org.eclipse.swt.widgets.Group)1 Nullable (org.jetbrains.annotations.Nullable)1