use of eu.esdihumboldt.hale.io.haleconnect.HaleConnectService in project hale by halestudio.
the class HaleConnectLoginContentProvider method run.
/**
* @see org.eclipse.ui.intro.config.IIntroAction#run(org.eclipse.ui.intro.IIntroSite,
* java.util.Properties)
*/
@Override
public void run(IIntroSite site, Properties params) {
String username = params.getProperty("username", "");
String password = params.getProperty("password", "");
String savecreds = params.getProperty("savecreds", "");
if (username.trim().isEmpty() || password.trim().isEmpty()) {
// Using MessageDialog to prevent this from cluttering up the logs
MessageDialog.openWarning(site.getShell(), "Login to hale connect", "You must provide both user name and password to login to hale connect.");
return;
}
HaleConnectService hcs = HaleUI.getServiceProvider().getService(HaleConnectService.class);
try {
if (hcs.login(username, password)) {
if ("true".equalsIgnoreCase(savecreds)) {
try {
HaleConnectUIPlugin.storeUsername(username);
HaleConnectUIPlugin.storePassword(password);
} catch (StorageException e) {
log.error("hale connect credentials could not be saved.", e);
}
}
log.userInfo("Login to hale connect successful.");
// Close and reopen the intro to update the displayed message
IIntroPart introPart = PlatformUI.getWorkbench().getIntroManager().getIntro();
if (introPart != null) {
PlatformUI.getWorkbench().getIntroManager().closeIntro(introPart);
PlatformUI.getWorkbench().getIntroManager().showIntro(site.getWorkbenchWindow(), false);
}
} else {
log.userWarn("Login to hale connect failed, please check the credentials.");
}
} catch (HaleConnectException e) {
log.userError("An error occurred while trying to login to hale connect", e);
}
}
use of eu.esdihumboldt.hale.io.haleconnect.HaleConnectService in project hale by halestudio.
the class HaleConnectLoginHandler method createLoginDialog.
/**
* Create a hale connect login dialog using the given {@link Shell}.
*
* @param parent parent shell
* @return the login dialog
*/
public static HaleConnectLoginDialog createLoginDialog(Shell parent) {
HaleConnectService hcs = HaleUI.getServiceProvider().getService(HaleConnectService.class);
String username = "";
String password = "";
try {
username = HaleConnectUIPlugin.getStoredUsername();
password = HaleConnectUIPlugin.getStoredPassword();
} catch (StorageException e) {
log.error("Failed to retrieve hale connect credentials from preferences store", e);
}
if (hcs.isLoggedIn()) {
if (!MessageDialog.openQuestion(parent, "Login to hale connect", MessageFormat.format("You are currently logged in as \"{0}\". Do you wish to log in again?", hcs.getSession().getUsername()))) {
return null;
} else if (hcs.getSession().getUsername().equals(username)) {
// Don't fill in from preferences if stored user name was used
// to login before
username = "";
password = "";
}
}
HaleConnectLoginDialog loginDialog = new HaleConnectLoginDialog(parent);
loginDialog.setTitleAreaColor(new RGB(168, 208, 244));
loginDialog.setTitleImage(HaleConnectImages.getImageRegistry().get(HaleConnectImages.IMG_HCLOGO_DIALOG));
loginDialog.setUsername(username);
loginDialog.setPassword(password);
return loginDialog;
}
use of eu.esdihumboldt.hale.io.haleconnect.HaleConnectService in project hale by halestudio.
the class HaleConnectLogoutHandler method execute.
/**
* @see org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands.ExecutionEvent)
*/
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
Shell parent = HandlerUtil.getActiveShell(event);
if (!MessageDialog.openConfirm(parent, "Clear hale connect credentials", "This will invalidate your current hale connect session and remove all stored credentials.")) {
return null;
}
HaleConnectService hcs = HaleUI.getServiceProvider().getService(HaleConnectService.class);
hcs.clearSession();
try {
HaleConnectUIPlugin.storeUsername("");
HaleConnectUIPlugin.storePassword("");
log.userInfo("hale connect credentials cleared");
} catch (StorageException e) {
log.userError("Error clearing credentials", e);
}
return null;
}
use of eu.esdihumboldt.hale.io.haleconnect.HaleConnectService in project hale by halestudio.
the class HaleConnectSourceProvider method dispose.
/**
* @see org.eclipse.ui.ISourceProvider#dispose()
*/
@Override
public void dispose() {
final HaleConnectService hcs = HaleUI.getServiceProvider().getService(HaleConnectService.class);
hcs.removeListener(listener);
}
use of eu.esdihumboldt.hale.io.haleconnect.HaleConnectService in project hale by halestudio.
the class HaleConnectExtendedPreferencePage method updateBasepaths.
private void updateBasepaths() {
HaleConnectService hcs = HaleUI.getServiceProvider().getService(HaleConnectService.class);
if (defaults.getBooleanValue()) {
// Force default values
hcs.getBasePathManager().setBasePath(HaleConnectServices.USER_SERVICE, PreferenceInitializer.HALE_CONNECT_BASEPATH_USERS_DEFAULT);
hcs.getBasePathManager().setBasePath(HaleConnectServices.BUCKET_SERVICE, PreferenceInitializer.HALE_CONNECT_BASEPATH_DATA_DEFAULT);
hcs.getBasePathManager().setBasePath(HaleConnectServices.PROJECT_STORE, PreferenceInitializer.HALE_CONNECT_BASEPATH_PROJECTS_DEFAULT);
hcs.getBasePathManager().setBasePath(HaleConnectServices.WEB_CLIENT, PreferenceInitializer.HALE_CONNECT_BASEPATH_CLIENT_DEFAULT);
} else {
// Use individually configured values
hcs.getBasePathManager().setBasePath(HaleConnectServices.USER_SERVICE, usersBasepath.getStringValue());
hcs.getBasePathManager().setBasePath(HaleConnectServices.BUCKET_SERVICE, dataBasepath.getStringValue());
hcs.getBasePathManager().setBasePath(HaleConnectServices.PROJECT_STORE, projectsBasepath.getStringValue());
hcs.getBasePathManager().setBasePath(HaleConnectServices.WEB_CLIENT, clientBasepath.getStringValue());
}
if (hcs.isLoggedIn()) {
hcs.clearSession();
MessageDialog.openInformation(getShell(), "hale connect preferences", "You have been logged out from hale connect.");
}
}
Aggregations