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);
}
}
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);
}
}
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;
}
Aggregations