createCheckButton.setText("C");
readCheckButton = new Button(this, SWT.CHECK);
+ readCheckButton.setEnabled(false);
readCheckButton.addMouseTrackListener(new MouseTrackAdapter() {
@Override
public void mouseHover(MouseEvent arg0) {
*/
private void updateView() {
createCheckButton.setSelection(false);
- readCheckButton.setSelection(false);
+ readCheckButton.setSelection(true);
deleteCheckButton.setSelection(false);
updateCheckButton.setSelection(false);
*/
-/**
- * @author cmathew
- * @date Apr 5, 2013
- *
- */
-
//FIXME:move warning dialogs to the table class
public class CdmAuthorityCompositeViewer extends ContentViewer {
private IDirtyMarkableSelectionProvider dirtyMarkerEditor;
private CdmAuthorityComposite cdmAuthorityComposite;
private Group group;
+ private boolean isDirty = false;
/**
* List which contains already existing authority objects.
*/
return cdmAuthorities;
}
+ public boolean isDirty() {
+ return isDirty;
+ }
/**
* Adds a new {@link CdmAuthority} to the group attached to this viewer
* based on the input {@link CdmBase} object.
defaultOperation.add(CRUD.READ);
CdmAuthority cdma = new CdmAuthority(cb, defaultOperation, cb.getUuid());
GrantedAuthorityImpl gai;
+
try {
// create a granted authrity from a cdm authority
gai = cdma.asNewGrantedAuthority();
}
//FIXME : this contains call will allow users to add authorities which differ only in CRUD operation choice.
// need to have a comparator which only checks permission class and uuid
- if(cdmAuthorities.contains(gai)) {
+ if(cdmAuthorities.contains(gai) || newCdmAuthorities.contains(gai)) {
StoreUtil.warningDialog("Duplicate CDM Authority", this, "Chosen CDM Authority is already attached to current group");
} else {
group.addGrantedAuthority(gai);
- newCdmAuthorities.add(gai);
+ newCdmAuthorities.add(gai);
+ isDirty = true;
dirtyMarkerEditor.changed(group);
cdmAuthorityComposite.refresh();
}
* @param gai {@link GrantedAuthorityImpl} object to remove
*/
public void removeCdmAuthority(GrantedAuthorityImpl gai) {
- if(cdmAuthorities.contains(gai)) {
- group.removeGrantedAuthority(gai);
+
+ if(cdmAuthorities.contains(gai)) {
+ cdmAuthorities.remove(gai);
+ isDirty = true;
+ } else {
newCdmAuthorities.remove(gai);
- cdmAuthorities.remove(gai);
- dirtyMarkerEditor.changed(group);
- cdmAuthorityComposite.refresh();
- } else {
- StoreUtil.warningDialog("Unknown CDM Authority", this, "Chosen CDM Authority does not exist in current group");
+ if(newCdmAuthorities.isEmpty() && !isDirty) {
+ isDirty = false;
+ }
}
+ group.removeGrantedAuthority(gai);
+ dirtyMarkerEditor.changed(group);
+ cdmAuthorityComposite.refresh();
}
/**
GrantedAuthorityImpl gai = cdmAuthority.asNewGrantedAuthority();
group.addGrantedAuthority(gai);
group.removeGrantedAuthority(grantedAuthorityI);
+ isDirty = true;
dirtyMarkerEditor.changed(grantedAuthorityI);
return gai;
} catch(Exception e) {