Commit d67cdb62 authored by Florine Boudin's avatar Florine Boudin

Revert "BS-7588 "

This reverts commit 8c21eeb3.
parent fc44d960
......@@ -215,10 +215,9 @@ userDoesntExistAnymore=Organization has not been Published. The default user {0}
updateActorReferences=Updating actor references...
refactoringActorMappings=Refactoring actor mappings...
noActorDefinedAtLaneLevel=(No actor defined at lane level)
importOrganizationCancelledMessage=The organization cannot be imported
importOrganizationCancelledMessage=The import of organization has been cancelled.
importOrganizationCancelledTitle=Import cancelled
importSuccessfulTitle=Import successful
importSuccessfulMsg=Import operation successful
importFailedTitle=Import failed
importFailedMsg=Import has failed.\n{0}
multipleRolesWithSameName=Different roles cannot share the same name \"{0}\"
\ No newline at end of file
importFailedMsg=Import has failed.\n{0}
\ No newline at end of file
......@@ -245,7 +245,6 @@ public class Messages extends NLS {
public static String importSuccessfulMsg;
public static String importFailedTitle;
public static String importFailedMsg;
public static String multipleRolesWithSameName;
......
......@@ -69,7 +69,6 @@ public class ManageOrganizationWizard extends Wizard {
private final OrganizationUserValidator validator = new OrganizationUserValidator() ;
private Organization activeOrganization;
private boolean activeOrganizationHasBeenModified = false;
private ManageOrganizationWizardPage manageOrganizationWizardPage;
String userName;
public ManageOrganizationWizard(){
......@@ -103,14 +102,13 @@ public class ManageOrganizationWizard extends Wizard {
@Override
public void addPages() {
manageOrganizationWizardPage = new ManageOrganizationWizardPage(organizationsWorkingCopy);
addPage(manageOrganizationWizardPage) ;
GroupsWizardPage groupsWizardPage = new GroupsWizardPage() ;
RolesWizardPage rolesWizardPage = new RolesWizardPage() ;
UsersWizardPage usersWizardPage = new UsersWizardPage() ;
addPage(groupsWizardPage) ;
addPage(rolesWizardPage) ;
addPage(usersWizardPage) ;
addPage(new ManageOrganizationWizardPage(organizationsWorkingCopy)) ;
GroupsWizardPage p = new GroupsWizardPage() ;
RolesWizardPage p1 = new RolesWizardPage() ;
UsersWizardPage p2 = new UsersWizardPage() ;
addPage(p) ;
addPage(p1) ;
addPage(p2) ;
}
@Override
......@@ -295,10 +293,5 @@ public class ManageOrganizationWizard extends Wizard {
return null;
}
@Override
public boolean canFinish() {
return (manageOrganizationWizardPage.getSelectedOrganization()!=null && manageOrganizationWizardPage.isValidOrganization());
}
}
......@@ -182,21 +182,11 @@ public class ManageOrganizationWizardPage extends WizardPage implements ISelecti
@Override
public boolean canFlipToNextPage() {
return !viewer.getSelection().isEmpty() ;
}
public Organization getSelectedOrganization() {
return (Organization) ((IStructuredSelection) viewer.getSelection()).getFirstElement();
}
public boolean isValidOrganization(){
OrganizationUserValidator validator = new OrganizationUserValidator() ;
if(validator.validate(getSelectedOrganization()).isOK()){
return true;
}
return false;
}
}
......@@ -104,16 +104,6 @@ public class OrganizationUserValidator implements IValidator {
return ValidationStatus.error(Messages.bind(Messages.missingMembershipForUser,u.getUserName()));
}
}
for(Role role : organization.getRoles().getRole()){
for(Role roleTmp : organization.getRoles().getRole()){
if(!roleTmp.equals(role) && roleTmp.getName().equals(role.getName())){
return ValidationStatus.error(Messages.bind(Messages.multipleRolesWithSameName,roleTmp.getName()));
}
}
}
return ValidationStatus.ok() ;
}
......
......@@ -68,250 +68,250 @@ public class RolesWizardPage extends AbstractOrganizationWizardPage {
private final List<Membership> roleMemberShips = new ArrayList<Membership>();
private Text roleNameText;
private Text displayNamedText;
private Text roleDescriptionText;
private WrappingValidator roleNameValidator;
public RolesWizardPage() {
super(RolesWizardPage.class.getName());
setTitle(Messages.displayRolesPageTitle) ;
setDescription(Messages.displayRolesPageDesc) ;
}
@Override
protected void configureViewer(StructuredViewer viewer) {
TableViewerColumn column = new TableViewerColumn((TableViewer) viewer, SWT.FILL) ;
TableColumn nameColumn = column.getColumn() ;
column.getColumn().setText(Messages.roleName);
column.setLabelProvider(new ColumnLabelProvider(){
@Override
public String getText(Object element) {
return ((Role)element).getName();
}
});
column.getColumn().setWidth(90);
column.getColumn().setMoveable(false);
column.getColumn().setResizable(true);
column = new TableViewerColumn((TableViewer) viewer, SWT.FILL) ;
column.getColumn().setText(Messages.displayName);
column.setLabelProvider(new ColumnLabelProvider(){
@Override
public String getText(Object element) {
return ((Role)element).getDisplayName();
}
});
column.getColumn().setWidth(90);
column.getColumn().setMoveable(false);
column.getColumn().setResizable(true);
column = new TableViewerColumn((TableViewer) viewer, SWT.FILL) ;
column.getColumn().setText(Messages.description);
column.setLabelProvider(new ColumnLabelProvider(){
@Override
public String getText(Object element) {
return ((Role)element).getDescription();
}
});
column.getColumn().setWidth(90);
column.getColumn().setMoveable(false);
column.getColumn().setResizable(true);
TableColumnSorter sorter = new TableColumnSorter((TableViewer) viewer) ;
sorter.setColumn(nameColumn) ;
if(roleList!= null && getViewer() != null){
getViewer().setInput(roleList) ;
}
}
@Override
public void setOrganization(Organization organization) {
super.setOrganization(organization);
if(organization != null && getViewer() != null){
getViewer().setInput(roleList) ;
}
}
@Override
public void selectionChanged(SelectionChangedEvent event) {
refreshBinding((Role) ((IStructuredSelection) event.getSelection()).getFirstElement()) ;
}
private void refreshBinding(final Role selectedRole) {
if(context != null){
context.dispose() ;
}
if(pageSupport != null){
pageSupport.dispose() ;
}
context = new EMFDataBindingContext() ;
roleMemberShips.clear() ;
if(selectedRole != null){
setControlEnabled(getInfoGroup(), true) ;
for(Membership m : membershipList){
if(selectedRole.getName() != null && selectedRole.getName().equals(m.getRoleName())){
roleMemberShips.add(m) ;
}
}
UpdateValueStrategy strategy = new UpdateValueStrategy() ;
roleNameValidator.setValidator(new IValidator() {
@Override
public IStatus validate(Object value) {
if(value.toString().isEmpty()){
return ValidationStatus.error(Messages.nameIsEmpty) ;
}
for(Role r : roleList){
if(!r.equals(selectedRole)){
if(r.getName().equals(value)){
return ValidationStatus.error(Messages.roleNameAlreadyExists) ;
}
}
}
return Status.OK_STATUS;
}
});
strategy.setAfterGetValidator(roleNameValidator);
IObservableValue value = EMFObservables.observeValue(selectedRole, OrganizationPackage.Literals.ROLE__NAME) ;
value.addValueChangeListener(new IValueChangeListener() {
@Override
public void handleValueChange(ValueChangeEvent event) {
Role role = (Role) ((EObjectObservableValue)event.getObservable()).getObserved();
getViewer().refresh(role) ;
for(Membership m : roleMemberShips){
m.setRoleName(role.getName()) ;
}
}
}) ;
IObservableValue descriptionValue = EMFObservables.observeValue(selectedRole, OrganizationPackage.Literals.ROLE__DESCRIPTION) ;
descriptionValue.addValueChangeListener(new IValueChangeListener() {
@Override
public void handleValueChange(ValueChangeEvent event) {
Role role = (Role) ((EObjectObservableValue)event.getObservable()).getObserved();
getViewer().refresh(role) ;
}
}) ;
IObservableValue displayNameValue = EMFObservables.observeValue(selectedRole, OrganizationPackage.Literals.ROLE__DISPLAY_NAME) ;
displayNameValue.addValueChangeListener(new IValueChangeListener() {
@Override
public void handleValueChange(ValueChangeEvent event) {
Role role = (Role) ((EObjectObservableValue)event.getObservable()).getObserved();
getViewer().refresh(role) ;
}
}) ;
context.bindValue(SWTObservables.observeDelayedValue(500,SWTObservables.observeText(roleNameText,SWT.Modify)),value,strategy,new UpdateValueStrategy()) ;
context.bindValue(SWTObservables.observeDelayedValue(500,SWTObservables.observeText(roleDescriptionText,SWT.Modify)),descriptionValue) ;
context.bindValue(SWTObservables.observeText(displayNamedText,SWT.Modify), displayNameValue) ;
}else{
displayNamedText.setText("") ;
roleDescriptionText.setText("") ;
roleNameText.setText("") ;
setControlEnabled(getInfoGroup(), false) ;
}
pageSupport = WizardPageSupportWithoutMessages.create(this, context) ;
}
@Override
protected void configureInfoGroup(Group group) {
group.setText(Messages.roleInfo) ;
group.setLayout(GridLayoutFactory.fillDefaults().numColumns(1).margins(15, 5).spacing(5, 2).create()) ;
Label roleName = new Label(group, SWT.NONE) ;
roleName.setLayoutData(GridDataFactory.fillDefaults().align(SWT.BEGINNING,SWT.CENTER).create()) ;
roleName.setText(Messages.name) ;
roleNameText = new Text(group, SWT.BORDER) ;
roleNameText.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).minSize(130, SWT.DEFAULT).create()) ;
final ControlDecoration decoration = new ControlDecoration(roleNameText,SWT.LEFT);
roleNameValidator = new WrappingValidator(decoration, null,false,true);
Label displayNameLabel = new Label(group, SWT.NONE) ;
displayNameLabel.setLayoutData(GridDataFactory.fillDefaults().align(SWT.BEGINNING,SWT.CENTER).create()) ;
displayNameLabel.setText(Messages.displayName) ;
displayNamedText = new Text(group, SWT.BORDER) ;
displayNamedText.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).create()) ;
Label descriptionLabel = new Label(group, SWT.NONE) ;
descriptionLabel.setLayoutData(GridDataFactory.fillDefaults().align(SWT.BEGINNING,SWT.FILL).create()) ;
descriptionLabel.setText(Messages.description) ;
roleDescriptionText = new Text(group, SWT.BORDER | SWT.MULTI | SWT.WRAP | SWT.V_SCROLL) ;
roleDescriptionText.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).hint(SWT.DEFAULT, 80).create()) ;
roleDescriptionText.setMessage(Messages.descriptionHint) ;
getViewer().setSelection(new StructuredSelection()) ;
refreshBinding(null) ;
}
@Override
protected void addButtonSelected() {
Role role = OrganizationFactory.eINSTANCE.createRole() ;
role.setName(generateRolename()) ;
role.setDisplayName(role.getName()) ;
roleList.add(role) ;
getViewer().setInput(roleList) ;
getViewer().setSelection(new StructuredSelection(role)) ;
}
private String generateRolename() {
Set<String> names = new HashSet<String>() ;
for(Role r : roleList){
names.add(r.getName()) ;
}
return NamingUtils.generateNewName(names, Messages.defaultRoleName);
}
@Override
protected void removeButtonSelected() {
for(Object sel : ((IStructuredSelection) getViewer().getSelection()).toList()){
if(sel instanceof Role){
roleList.remove(sel) ;
}
}
getViewer().setInput(roleList) ;
selectionChanged(new SelectionChangedEvent(getViewer(),new StructuredSelection())) ;
}
@Override
protected boolean viewerSelect(Object element, String searchQuery) {
if(searchQuery == null || searchQuery.isEmpty()
|| (((Role)element).getName() != null && ((Role)element).getName().toLowerCase().contains(searchQuery.toLowerCase()))
|| (((Role)element).getDisplayName() != null && ((Role)element).getDisplayName().toLowerCase().contains(searchQuery.toLowerCase()))
|| (((Role)element).getDescription() != null && ((Role)element).getDescription().toLowerCase().contains(searchQuery.toLowerCase()))){
return true ;
}
return false ;
}
private final List<Membership> roleMemberShips = new ArrayList<Membership>();
private Text roleNameText;
private Text displayNamedText;
private Text roleDescriptionText;
private WrappingValidator roleNameValidator;
public RolesWizardPage() {
super(RolesWizardPage.class.getName());
setTitle(Messages.displayRolesPageTitle) ;
setDescription(Messages.displayRolesPageDesc) ;
}
@Override
protected void configureViewer(StructuredViewer viewer) {
TableViewerColumn column = new TableViewerColumn((TableViewer) viewer, SWT.FILL) ;
TableColumn nameColumn = column.getColumn() ;
column.getColumn().setText(Messages.roleName);
column.setLabelProvider(new ColumnLabelProvider(){
@Override
public String getText(Object element) {
return ((Role)element).getName();
}
});
column.getColumn().setWidth(90);
column.getColumn().setMoveable(false);
column.getColumn().setResizable(true);
column = new TableViewerColumn((TableViewer) viewer, SWT.FILL) ;
column.getColumn().setText(Messages.displayName);
column.setLabelProvider(new ColumnLabelProvider(){
@Override
public String getText(Object element) {
return ((Role)element).getDisplayName();
}
});
column.getColumn().setWidth(90);
column.getColumn().setMoveable(false);
column.getColumn().setResizable(true);
column = new TableViewerColumn((TableViewer) viewer, SWT.FILL) ;
column.getColumn().setText(Messages.description);
column.setLabelProvider(new ColumnLabelProvider(){
@Override
public String getText(Object element) {
return ((Role)element).getDescription();
}
});
column.getColumn().setWidth(90);
column.getColumn().setMoveable(false);
column.getColumn().setResizable(true);
TableColumnSorter sorter = new TableColumnSorter((TableViewer) viewer) ;
sorter.setColumn(nameColumn) ;
if(roleList!= null && getViewer() != null){
getViewer().setInput(roleList) ;
}
}
@Override
public void setOrganization(Organization organization) {
super.setOrganization(organization);
if(organization != null && getViewer() != null){
getViewer().setInput(roleList) ;
}
}
@Override
public void selectionChanged(SelectionChangedEvent event) {
refreshBinding((Role) ((IStructuredSelection) event.getSelection()).getFirstElement()) ;
}
private void refreshBinding(final Role selectedRole) {
if(context != null){
context.dispose() ;
}
if(pageSupport != null){
pageSupport.dispose() ;
}
context = new EMFDataBindingContext() ;
roleMemberShips.clear() ;
if(selectedRole != null){
setControlEnabled(getInfoGroup(), true) ;
for(Membership m : membershipList){
if(selectedRole.getName() != null && selectedRole.getName().equals(m.getRoleName())){
roleMemberShips.add(m) ;
}
}
UpdateValueStrategy strategy = new UpdateValueStrategy() ;
roleNameValidator.setValidator(new IValidator() {
@Override
public IStatus validate(Object value) {
if(value.toString().isEmpty()){
return ValidationStatus.error(Messages.nameIsEmpty) ;
}
for(Role r : roleList){
if(!r.equals(selectedRole)){
if(r.getName().equals(value)){
return ValidationStatus.error(Messages.roleNameAlreadyExists) ;
}
}
}
return Status.OK_STATUS;
}
});
strategy.setAfterGetValidator(roleNameValidator);
IObservableValue value = EMFObservables.observeValue(selectedRole, OrganizationPackage.Literals.ROLE__NAME) ;
value.addValueChangeListener(new IValueChangeListener() {
@Override
public void handleValueChange(ValueChangeEvent event) {
Role role = (Role) ((EObjectObservableValue)event.getObservable()).getObserved();
getViewer().refresh(role) ;
for(Membership m : roleMemberShips){
m.setRoleName(role.getName()) ;
}
}
}) ;
IObservableValue descriptionValue = EMFObservables.observeValue(selectedRole, OrganizationPackage.Literals.ROLE__DESCRIPTION) ;
descriptionValue.addValueChangeListener(new IValueChangeListener() {
@Override
public void handleValueChange(ValueChangeEvent event) {
Role role = (Role) ((EObjectObservableValue)event.getObservable()).getObserved();
getViewer().refresh(role) ;
}
}) ;
IObservableValue displayNameValue = EMFObservables.observeValue(selectedRole, OrganizationPackage.Literals.ROLE__DISPLAY_NAME) ;
displayNameValue.addValueChangeListener(new IValueChangeListener() {
@Override
public void handleValueChange(ValueChangeEvent event) {
Role role = (Role) ((EObjectObservableValue)event.getObservable()).getObserved();
getViewer().refresh(role) ;
}
}) ;
context.bindValue(SWTObservables.observeDelayedValue(500,SWTObservables.observeText(roleNameText,SWT.Modify)),value,strategy,new UpdateValueStrategy()) ;
context.bindValue(SWTObservables.observeDelayedValue(500,SWTObservables.observeText(roleDescriptionText,SWT.Modify)),descriptionValue) ;
context.bindValue(SWTObservables.observeText(displayNamedText,SWT.Modify), displayNameValue) ;
}else{
displayNamedText.setText("") ;
roleDescriptionText.setText("") ;
roleNameText.setText("") ;
setControlEnabled(getInfoGroup(), false) ;
}
pageSupport = WizardPageSupportWithoutMessages.create(this, context) ;
}
@Override
protected void configureInfoGroup(Group group) {
group.setText(Messages.roleInfo) ;
group.setLayout(GridLayoutFactory.fillDefaults().numColumns(1).margins(15, 5).spacing(5, 2).create()) ;
Label roleName = new Label(group, SWT.NONE) ;
roleName.setLayoutData(GridDataFactory.fillDefaults().align(SWT.BEGINNING,SWT.CENTER).create()) ;
roleName.setText(Messages.name) ;
roleNameText = new Text(group, SWT.BORDER) ;
roleNameText.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).minSize(130, SWT.DEFAULT).create()) ;
final ControlDecoration decoration = new ControlDecoration(roleNameText,SWT.LEFT);
roleNameValidator = new WrappingValidator(decoration, null,false,true);