/**
* Copyright (C) 2007 EDIT
-* European Distributed Institute of Taxonomy
+* European Distributed Institute of Taxonomy
* http://www.e-taxonomy.eu
-*
+*
* The contents of this file are subject to the Mozilla Public License Version 1.1
* See LICENSE.TXT at the top of this package for the full license terms.
*/
/**
* Row widget for editing a single CDM Authority
- *
+ *
* @author cmathew
* @created Mar 28, 2013
*
private Label lblUuid;
private CRUDOperationChooser operationChooser;
private Button btnDelete;
-
+
private GrantedAuthorityImpl grantedAuthorityI;
private Label lblDirtyFlag;
-
+
private CdmAuthorityCompositeViewer cdmaModel;
private Label lblType;
-
+
/**
* Create the composite, made up of 5 elements :
- * 1. '*' or depending on whether the row is being edited
- * 2. Classname of entity (e.g. TAXONNODE)
- * 3. Uuid of entity
- * 4. CRUD operations edit widget (this is essentially 4 checkboxes to select the 4 possible operations)
- * 5. Delete button (to delete the row)
- *
+ * 1. '*' or depending on whether the row is being edited
+ * 2. Classname of entity (e.g. TAXONNODE)
+ * 3. Uuid of entity
+ * 4. CRUD operations edit widget (this is essentially 4 checkboxes to select the 4 possible operations)
+ * 5. Delete button (to delete the row)
+ *
* @param parent
* @param style
*/
public CdmAuthorityRow(Composite parent, int style) {
super(parent, SWT.NONE);
addDisposeListener(new DisposeListener() {
- public void widgetDisposed(DisposeEvent e) {
+ @Override
+ public void widgetDisposed(DisposeEvent e) {
toolkit.dispose();
}
});
toolkit.adapt(this);
toolkit.paintBordersFor(this);
setLayout(new GridLayout(6, false));
-
-
+
+
lblDirtyFlag = new Label(this, SWT.NONE);
lblDirtyFlag.setAlignment(SWT.CENTER);
GridData gd_lblDirtyFlag = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1);
lblDirtyFlag.setLayoutData(gd_lblDirtyFlag);
toolkit.adapt(lblDirtyFlag, true, true);
lblDirtyFlag.setText("*");
-
+
lblType = new Label(this, SWT.BORDER);
GridData gd_lblType = new GridData(SWT.CENTER, SWT.CENTER, false, false, 1, 1);
gd_lblType.heightHint = 30;
lblType.setText("Type");
lblType.setAlignment(SWT.CENTER);
toolkit.adapt(lblType, true, true);
-
+
lblEntity = new Label(this, SWT.BORDER | SWT.WRAP | SWT.CENTER);
GridData gd_lblEntity = new GridData(SWT.CENTER, SWT.CENTER, false, false, 1, 1);
gd_lblEntity.heightHint = 30;
lblEntity.setLayoutData(gd_lblEntity);
lblEntity.setAlignment(SWT.CENTER);
toolkit.adapt(lblEntity, true, true);
- lblEntity.setText("Entity");
-
-
+ lblEntity.setText("Entity/Feature");
+
+
operationChooser = new CRUDOperationChooser(this, SWT.BORDER);
operationChooser.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, false, false, 1, 1));
toolkit.adapt(operationChooser);
toolkit.paintBordersFor(operationChooser);
-
+
btnDelete = new Button(this, SWT.NONE);
btnDelete.setImage(ImageResources.getImage(ImageResources.TRASH_ICON));
cdmaModel.removeCdmAuthority(grantedAuthorityI);
}
}
- });
-
+ });
+
toolkit.adapt(btnDelete, true, true);
}
/**
* Sets the dirty flag for this row
- *
+ *
* @param isDirty
*/
public void setDirty(boolean isDirty) {
lblDirtyFlag.setText(" ");
}
}
-
+
/**
* Create a {@link CdmAuthority} from a {@link GrantedAuthorityImpl} and create a row from it.
- *
+ *
* @param cdmaModel
* @param grantedAuthorityI
* @param isDirty
*/
public void setRowCdmAuthority(CdmAuthorityCompositeViewer cdmaModel, GrantedAuthorityImpl grantedAuthorityI, boolean isDirty, boolean showUuid) {
- this.grantedAuthorityI = grantedAuthorityI;
+ this.grantedAuthorityI = grantedAuthorityI;
this.cdmaModel = cdmaModel;
-
+
try {
CdmAuthority cdmAuthority = CdmAuthority.fromGrantedAuthority(grantedAuthorityI);
lblType.setText(entityStr);
String targetLabelText = GrantedAuthorityLabelTextProvider.getTargetText(cdmAuthority);
lblEntity.setText(targetLabelText);
-
+
setUuidCellVisible(showUuid);
if(lblUuid != null) {
String targetUuid = cdmAuthority.getTargetUUID().toString();
lblUuid.setText(targetUuid);
}
-
- operationChooser.setAuthority(cdmaModel, grantedAuthorityI, cdmAuthority);
-
+
+ operationChooser.setAuthority(cdmaModel, grantedAuthorityI, cdmAuthority);
+
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
-
+
public void setUuidCellVisible(boolean visible) {
if(visible) {
if(lblUuid == null) {
createUuidCell();
}
lblUuid.moveAbove(operationChooser);
-
+
} else {
if(lblUuid != null) {
lblUuid.dispose();
}
layout();
}
-
+
private void createUuidCell() {
lblUuid = new Label(this, SWT.BORDER | SWT.CENTER);
GridData gd_lblUuid = new GridData(SWT.CENTER, SWT.CENTER, false, false, 1, 1);