use of de.catma.ui.events.routing.RouteToDashboardEvent in project catma by forTEXT.
the class ConflictedProjectView method showNextConflict.
// TODO: refactor! (consider implementing a state machine)
private void showNextConflict() {
try {
if (// tag/tagset conflict resolution not applied yet
(this.tagManager == null) && // all tagset conflicts resolved by the user
((tagsetConflictsIterator == null) || !this.tagsetConflictsIterator.hasNext()) && ((tagConflictIterator == null) || !this.tagConflictIterator.hasNext())) {
// all tag conflicts resolved by the user
// apply tag/tagset conflict resolutions
conflictedProject.resolveTagsetConflicts(this.tagsetConflicts);
// load tagsets
this.tagManager = new TagManager(new TagLibrary());
conflictedProject.getTagsets().stream().forEach(tagset -> tagManager.addTagsetDefinition(tagset));
}
if ((tagConflictIterator != null) && tagConflictIterator.hasNext()) {
showNextTagConflict();
} else if ((tagsetConflictsIterator != null) && tagsetConflictsIterator.hasNext()) {
showNextTagsetConflict();
} else if (annotationConflictIterator != null && annotationConflictIterator.hasNext()) {
showNextAnnotationConflict();
} else if (collectionConflictIterator != null && collectionConflictIterator.hasNext()) {
showNextCollectionConflict();
} else {
conflictedProject.resolveCollectionConflict(this.collectionConflicts, this.tagManager.getTagLibrary());
// TODO: this may not be the right place to be doing this
conflictedProject.resolveSourceDocumentConflicts(sourceDocumentConflicts);
try {
Collection<DeletedResourceConflict> deletedReourceConflicts = conflictedProject.resolveRootConflicts();
if (!deletedReourceConflicts.isEmpty()) {
showDeletedResourceConflicts(deletedReourceConflicts);
return;
}
} catch (Exception e) {
if (ExceptionUtil.stackTraceContains(CommitMissingException.class.getName(), e)) {
Notification.show("Error", ExceptionUtil.getMessageFor(CommitMissingException.class.getName(), e), Type.ERROR_MESSAGE);
eventBus.post(new RouteToDashboardEvent());
return;
} else {
// rethrow unexpected error
throw new Exception(e);
}
}
// TODO: check if there everything is pushed, remote state might have prevented a push
eventBus.post(new RouteToProjectEvent(conflictedProject.getProjectReference(), true));
}
} catch (Exception e) {
((ErrorHandler) UI.getCurrent()).showAndLogError("Error showing next conflict!", e);
}
}
use of de.catma.ui.events.routing.RouteToDashboardEvent in project catma by forTEXT.
the class CatmaApplication method handleRequestOauth.
private void handleRequestOauth(VaadinRequest request) {
if (request.getParameter("code") != null && VaadinSession.getCurrent().getAttribute("OAUTHTOKEN") != null) {
handleOauth(request);
try {
Component mainView = initService.newEntryPage(eventBus, loginservice, hazelCastService, sqliteService);
UI.getCurrent().setContent(mainView);
eventBus.post(new RouteToDashboardEvent());
getCurrent().getPage().pushState("/catma/");
} catch (IOException e) {
showAndLogError("can't login properly", e);
}
}
}
use of de.catma.ui.events.routing.RouteToDashboardEvent in project catma by forTEXT.
the class CatmaApplication method init.
@Override
protected void init(VaadinRequest request) {
eventBus = new EventBus();
initService = new Vaadin8InitializationService();
loginservice = new GitlabLoginService(new IRemoteGitManagerFactory() {
@Override
public IRemoteGitManagerRestricted createFromUsernameAndPassword(String username, String password) throws IOException {
return new GitlabManagerRestricted(eventBus, initService.acquireBackgroundService(), username, password);
}
@Override
public IRemoteGitManagerRestricted createFromImpersonationToken(String userImpersonationToken) throws IOException {
return new GitlabManagerRestricted(eventBus, initService.acquireBackgroundService(), userImpersonationToken);
}
});
hazelCastService = new HazelCastService();
this.eventBus.register(this);
try {
sqliteService = new SqliteService();
} catch (Exception e) {
showAndLogError("error initialising sqlite service", e);
}
logger.info("Session: " + request.getWrappedSession().getId());
storeParameters(request.getParameterMap());
Page.getCurrent().setTitle("CATMA " + Version.LATEST);
try {
Component component = initService.newEntryPage(eventBus, loginservice, hazelCastService, sqliteService);
setContent(component);
} catch (IOException e) {
showAndLogError("error creating landing page", e);
}
eventBus.post(new RouteToDashboardEvent());
// A fresh UI and session doesn't have a request handler registered yet.
// we need to verify tokens here too.
handleRequestToken(request);
handleRequestOauth(request);
}
use of de.catma.ui.events.routing.RouteToDashboardEvent in project catma by forTEXT.
the class CatmaHeader method initComponents.
private void initComponents(IRemoteGitManagerPrivileged gitManagerPrivileged) {
addStyleName("header");
setWidth("100%");
btHome = new Button("Catma " + Version.LATEST);
btHome.addClickListener((evt) -> eventBus.post(new RouteToDashboardEvent()));
btHome.addStyleNames(ValoTheme.BUTTON_LINK, ValoTheme.LABEL_H3);
btHome.addStyleName("header-home-button");
addComponent(btHome);
setComponentAlignment(btHome, Alignment.MIDDLE_LEFT);
contextInformation.addStyleName("header__context");
addComponent(contextInformation);
setComponentAlignment(contextInformation, Alignment.MIDDLE_CENTER);
setExpandRatio(contextInformation, 1f);
IconButton btnAccount = new IconButton(VaadinIcons.USER);
btnAccount.setDescription(loginService.getAPI().getUser().getName());
ContextMenu ctxAccount = new ContextMenu(btnAccount, true);
ctxAccount.addItem("Edit Account", (item) -> {
EditAccountDialog editAccount = new EditAccountDialog(gitManagerPrivileged, loginService, eventBus);
editAccount.show();
});
ctxAccount.addItem("Get Access Token", (item) -> {
AccessTokenDialog accessTokenDialog = new AccessTokenDialog(gitManagerPrivileged, loginService);
accessTokenDialog.show();
});
ctxAccount.addItem("Sign Out", (item) -> {
loginService.logout();
});
btnAccount.addClickListener((evt) -> ctxAccount.open(evt.getClientX(), evt.getClientY()));
addComponent(btnAccount);
setComponentAlignment(btHome, Alignment.MIDDLE_RIGHT);
}
use of de.catma.ui.events.routing.RouteToDashboardEvent in project catma by forTEXT.
the class AuthenticationDialog method initActions.
private void initActions() {
addActionHandler(this);
btCancel.addClickListener(click -> close());
btLogin.addClickListener(click -> {
try {
if (pfPersonalAccessToken.isVisible()) {
loginservice.login(pfPersonalAccessToken.getValue());
} else {
loginservice.login(tfUsername.getValue(), pfPassword.getValue());
}
Component mainView = initService.newEntryPage(eventBus, loginservice, hazelCastService, sqliteService);
UI.getCurrent().setContent(mainView);
eventBus.post(new RouteToDashboardEvent());
close();
} catch (IOException e) {
Notification.show("Login error", "Username or password wrong!", Notification.Type.ERROR_MESSAGE);
String message = ExceptionUtil.getMessageFor("org.gitlab4j.api.GitLabApiException", e);
if (message != null && !message.equals("invalid_grant")) {
logger.log(Level.SEVERE, "login services", e);
}
}
});
googleLogInLink.addClickListener(event -> {
try {
UI.getCurrent().getPage().setLocation(createLogInClick(CATMAPropertyKey.Google_oauthAuthorizationCodeRequestURL.getValue(), CATMAPropertyKey.Google_oauthClientId.getValue(), CATMAPropertyKey.Google_oauthClientSecret.getValue()));
close();
} catch (Exception e) {
((ErrorHandler) UI.getCurrent()).showAndLogError("Error during authentication!", e);
}
});
}
Aggregations