added possibility to show / hide uuid column
authorCherian Mathew <c.mathew@bgbm.org>
Fri, 8 Aug 2014 16:37:26 +0000 (16:37 +0000)
committerCherian Mathew <c.mathew@bgbm.org>
Fri, 8 Aug 2014 16:37:26 +0000 (16:37 +0000)
added scrolling to the viewer

eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/group/grantedauthority/CdmAuthorityComposite.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/group/grantedauthority/CdmAuthorityCompositeViewer.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/group/grantedauthority/CdmAuthorityRow.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/group/grantedauthority/CdmAuthorityTableHeader.java

index 08a0faeaabd2a16962599a04abea6d80a5f0202a..850c8b4f44f603fd0d3b49ad93b8f63ce3b3a047 100644 (file)
@@ -11,6 +11,7 @@ package eu.etaxonomy.taxeditor.ui.group.grantedauthority;
 import org.eclipse.nebula.widgets.compositetable.CompositeTable;
 import org.eclipse.nebula.widgets.compositetable.IRowContentProvider;
 import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.ScrolledComposite;
 import org.eclipse.swt.dnd.DND;
 import org.eclipse.swt.dnd.DropTarget;
 import org.eclipse.swt.dnd.Transfer;
@@ -26,6 +27,9 @@ import org.eclipse.ui.forms.widgets.FormToolkit;
 
 import eu.etaxonomy.taxeditor.dnd.CdmAuthorityTableDropTargetListener;
 import eu.etaxonomy.taxeditor.dnd.transfer.TaxonNodeTransfer;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
 
 /**
  * Composite class which consists of a {@link CompositeTable} built specifically
@@ -42,11 +46,11 @@ public class CdmAuthorityComposite extends Composite {
        private CompositeTable table;
        
        private int numOfInitialCdmAuthorities;
-
-       private Label lblDragEntityInto;
        
        private CdmAuthorityCompositeViewer viewer;
        
+       private CdmAuthorityTableHeader cdmAuthorityTableHeader;
+       
 
        /**
         * Creates the composite using the given parent, style and associated viewer.
@@ -56,7 +60,7 @@ public class CdmAuthorityComposite extends Composite {
         * @param viewer viewer representing the model
         */
        public CdmAuthorityComposite(Composite parent, int style, final CdmAuthorityCompositeViewer viewer) {
-               super(parent, style);
+               super(parent, SWT.NONE);
                addDisposeListener(new DisposeListener() {
                        public void widgetDisposed(DisposeEvent e) {
                                toolkit.dispose();
@@ -66,21 +70,31 @@ public class CdmAuthorityComposite extends Composite {
                this.viewer = viewer;
                                
                numOfInitialCdmAuthorities = viewer.getCdmAuthorities().size();
-               setLayout(new GridLayout(1, false));
+               setLayout(new GridLayout(2, false));
+               setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
            Transfer[] transfers = new Transfer[] { TaxonNodeTransfer.getInstance() };     
            
            toolkit.adapt(this);
-               toolkit.paintBordersFor(this);          
-
-               lblDragEntityInto = new Label(this, SWT.NONE);
-               toolkit.adapt(lblDragEntityInto, true, true);
-               lblDragEntityInto.setText("Drag Entity into table to add ...");
-               table = new CompositeTable(this, SWT.BORDER);
-               GridData gd_table = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1);
-               gd_table.widthHint = 750;
+               toolkit.paintBordersFor(this);
+               new Label(this, SWT.NONE);
+               
+               final Button cbShowUUIDheader = new Button(this, SWT.CHECK);
+               cbShowUUIDheader.addSelectionListener(new SelectionAdapter() {
+                       @Override
+                       public void widgetSelected(SelectionEvent e) {
+                               boolean showUUIDHeader = ((Button)e.getSource()).getSelection();
+                               ((CdmAuthorityTableHeader)table.getHeader()).setUuidHeaderVisible(showUUIDHeader);
+                               refresh();
+                       }
+               });
+               toolkit.adapt(cbShowUUIDheader, true, true);
+               cbShowUUIDheader.setText("show uuid");
+               table = new CompositeTable(this, SWT.NONE);
+               GridData gd_table = new GridData(SWT.LEFT, SWT.CENTER, false, false, 2, 1);
+               gd_table.widthHint = 650;
                gd_table.heightHint = 400;
                table.setLayoutData(gd_table);
-               new CdmAuthorityTableHeader(table, SWT.NULL); 
+               cdmAuthorityTableHeader = new CdmAuthorityTableHeader(table, SWT.NULL);
                CdmAuthorityRow cdmAuthorityRow = new CdmAuthorityRow(table, SWT.NULL);
                
                table.setRunTime(true);
@@ -100,11 +114,13 @@ public class CdmAuthorityComposite extends Composite {
                                if(currentObjectOffset < viewer.getNewCdmAuthorities().size()) {                        
                                        row.setRowCdmAuthority(viewer, 
                                                        viewer.getNewCdmAuthorities().get(currentObjectOffset), 
-                                                       true);
+                                                       true,
+                                                       cbShowUUIDheader.getSelection());
                                } else {
                                        row.setRowCdmAuthority(viewer, 
                                                        viewer.getCdmAuthorities().get(currentObjectOffset - viewer.getNewCdmAuthorities().size()), 
-                                                       false);
+                                                       false,
+                                                       cbShowUUIDheader.getSelection());
                                }                                                                               
                        }
                });
index 0ea4dc32ceca4e33f30e2b3110247c8bbcb59052..331b13f348022eeac727bdca9deeec0d7f39f7ea 100644 (file)
@@ -18,6 +18,8 @@ import java.util.Set;
 import org.eclipse.jface.viewers.ContentViewer;
 import org.eclipse.jface.viewers.ISelection;
 import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.ScrolledComposite;
+import org.eclipse.swt.layout.GridData;
 import org.eclipse.swt.widgets.Composite;
 import org.eclipse.swt.widgets.Control;
 import org.springframework.security.core.GrantedAuthority;
@@ -74,7 +76,14 @@ public class CdmAuthorityCompositeViewer extends ContentViewer {
                this.group = group;
                newCdmAuthorities = new ArrayList<GrantedAuthorityImpl>();              
                updateAuthorities();
-               this.cdmAuthorityComposite = new CdmAuthorityComposite(composite, SWT.NONE, this);
+               
+               ScrolledComposite sc = new ScrolledComposite(composite, SWT.H_SCROLL | SWT.V_SCROLL);
+               this.cdmAuthorityComposite = new CdmAuthorityComposite(sc, SWT.H_SCROLL | SWT.V_SCROLL, this);
+               sc.setContent(cdmAuthorityComposite);
+               sc.setExpandHorizontal(true);
+               sc.setExpandVertical(true);
+               sc.setMinWidth(650);
+               sc.setMinHeight(400);
        }
 
        /**
index ecd134a573ae9766f8f5221dc9574f81f1ab1098..716ebd067dac80e984fd78c10d9d37b16f6971ca 100644 (file)
@@ -38,7 +38,7 @@ public class CdmAuthorityRow extends Composite {
 
        private final FormToolkit toolkit = new FormToolkit(Display.getCurrent());
        private Label lblEntity;
-       private Label lblTarget;
+       private Label lblUuid;
        private CRUDOperationChooser operationChooser;
        private Button btnDelete;
        
@@ -46,6 +46,7 @@ public class CdmAuthorityRow extends Composite {
        private Label lblDirtyFlag;
        
        private CdmAuthorityCompositeViewer cdmaModel;
+       private Label lblType;
        
        /**
         * Create the composite, made up of 5 elements :
@@ -67,7 +68,7 @@ public class CdmAuthorityRow extends Composite {
                });
                toolkit.adapt(this);
                toolkit.paintBordersFor(this);
-               setLayout(new GridLayout(5, false));
+               setLayout(new GridLayout(6, false));
                
 
                
@@ -79,7 +80,16 @@ public class CdmAuthorityRow extends Composite {
                toolkit.adapt(lblDirtyFlag, true, true);
                lblDirtyFlag.setText("*");
                
-               lblEntity = new Label(this, SWT.BORDER);
+               lblType = new Label(this, SWT.BORDER);
+               GridData gd_lblType = new GridData(SWT.CENTER, SWT.CENTER, false, false, 1, 1);
+               gd_lblType.heightHint = 30;
+               gd_lblType.widthHint = 200;
+               lblType.setLayoutData(gd_lblType);
+               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;
                gd_lblEntity.widthHint = 200;
@@ -88,14 +98,6 @@ public class CdmAuthorityRow extends Composite {
                toolkit.adapt(lblEntity, true, true);
                lblEntity.setText("Entity");
                
-               lblTarget = new Label(this, SWT.BORDER + SWT.WRAP);
-               GridData gd_lblTarget = new GridData(SWT.CENTER, SWT.CENTER, false, false, 1, 1);
-               gd_lblTarget.heightHint = 30;
-               gd_lblTarget.widthHint = 270;
-               lblTarget.setLayoutData(gd_lblTarget);
-               lblTarget.setAlignment(SWT.LEFT);
-               toolkit.adapt(lblTarget, true, true);
-               lblTarget.setText("Uuid");
                
                operationChooser = new CRUDOperationChooser(this, SWT.BORDER);
                operationChooser.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, false, false, 1, 1));
@@ -139,7 +141,7 @@ public class CdmAuthorityRow extends Composite {
         * @param grantedAuthorityI
         * @param isDirty
         */
-       public void setRowCdmAuthority(CdmAuthorityCompositeViewer cdmaModel, GrantedAuthorityImpl grantedAuthorityI, boolean isDirty) {
+       public void setRowCdmAuthority(CdmAuthorityCompositeViewer cdmaModel, GrantedAuthorityImpl grantedAuthorityI, boolean isDirty, boolean showUuid) {
                this.grantedAuthorityI = grantedAuthorityI;             
                this.cdmaModel = cdmaModel;
                
@@ -149,10 +151,16 @@ public class CdmAuthorityRow extends Composite {
                        setDirty(isDirty);
 
                        String entityStr = (cdmAuthority.getPermissionClass() == null)?"":cdmAuthority.getPermissionClass().toString();
-                       lblEntity.setText(entityStr);
+                       lblType.setText(entityStr);
                        String targetLabelText = GrantedAuthorityLabelTextProvider.getTargetText(cdmAuthority);
-                       lblTarget.setText(targetLabelText);
-
+                       lblEntity.setText(targetLabelText);
+                                               
+                       setUuidCellVisible(showUuid);
+                       if(lblUuid != null) {
+                               String targetUuid = cdmAuthority.getTargetUUID().toString();
+                               lblUuid.setText(targetUuid);
+                       }
+                       
                        operationChooser.setAuthority(cdmaModel, grantedAuthorityI, cdmAuthority);                              
                        
                } catch (Exception e) {
@@ -161,5 +169,31 @@ public class CdmAuthorityRow extends Composite {
                }
 
        }
+       
+       public void setUuidCellVisible(boolean visible) {
+               if(visible) {
+                       if(lblUuid == null) {
+                               createUuidCell();
+                       }
+                       lblUuid.moveAbove(operationChooser);
+                       
+               } else {
+                       if(lblUuid != null) {
+                               lblUuid.dispose();
+                       }
+                       lblUuid = null;
+               }
+               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);
+               gd_lblUuid.heightHint = 30;
+               gd_lblUuid.widthHint = 270;
+               lblUuid.setLayoutData(gd_lblUuid);
+               toolkit.adapt(lblUuid, true, true);
+               lblUuid.setText("Uuid");
+       }
 
 }
index ee844900a0bd91fa556c4a414674a5d0b9c20a9f..17d11526c35860c3a5f2f3837034e4bc7a90e274 100644 (file)
@@ -1,11 +1,11 @@
 /**
-* Copyright (C) 2007 EDIT
-* 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.
-*/
+ * Copyright (C) 2007 EDIT
+ * 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.
+ */
 package eu.etaxonomy.taxeditor.ui.group.grantedauthority;
 
 import org.eclipse.swt.SWT;
@@ -15,9 +15,11 @@ import org.eclipse.swt.events.DisposeListener;
 import org.eclipse.swt.layout.GridData;
 import org.eclipse.swt.layout.GridLayout;
 import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
 import org.eclipse.swt.widgets.Display;
 import org.eclipse.swt.widgets.Label;
 import org.eclipse.ui.forms.widgets.FormToolkit;
+import org.eclipse.wb.swt.SWTResourceManager;
 
 /**
  * Table header widget for {@link CdmAuthorityComposite}
@@ -29,7 +31,8 @@ import org.eclipse.ui.forms.widgets.FormToolkit;
 public class CdmAuthorityTableHeader extends Composite {
 
        private final FormToolkit toolkit = new FormToolkit(Display.getCurrent());
-
+       private CLabel lblUuid;
+       private CLabel lblOperation;
        /**
         * Create the composite, with 5 header fields.
         * 
@@ -45,15 +48,25 @@ public class CdmAuthorityTableHeader extends Composite {
                });
                toolkit.adapt(this);
                toolkit.paintBordersFor(this);
-               setLayout(new GridLayout(4, false));
-               
+               setLayout(new GridLayout(5, false));
+
                Label lblDirtyFlag = new Label(this, SWT.NONE);
                GridData gd_lblDirtyFlag = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1);
                gd_lblDirtyFlag.widthHint = 15;
                lblDirtyFlag.setLayoutData(gd_lblDirtyFlag);
-               
+
                toolkit.adapt(lblDirtyFlag, true, true);
                
+               CLabel lblType = new CLabel(this, SWT.NONE);
+               GridData gd_lblType = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1);
+               gd_lblType.widthHint = 200;
+               lblType.setLayoutData(gd_lblType);
+               lblType.setText("TYPE");
+               lblType.setForeground(SWTResourceManager.getColor(SWT.COLOR_BLUE));
+               lblType.setAlignment(SWT.CENTER);
+               toolkit.adapt(lblType);
+               toolkit.paintBordersFor(lblType);
+
                CLabel lblEntity = new CLabel(this, SWT.NONE);
                lblEntity.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_BLUE));
                lblEntity.setAlignment(SWT.CENTER);
@@ -63,18 +76,10 @@ public class CdmAuthorityTableHeader extends Composite {
                toolkit.adapt(lblEntity);
                toolkit.paintBordersFor(lblEntity);
                lblEntity.setText("ENTITY");
+
+               //createUUIDHeader();
                
-               CLabel lblUuid = new CLabel(this, SWT.NONE);
-               lblUuid.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_BLUE));
-               lblUuid.setAlignment(SWT.CENTER);
-               GridData gd_lblUuid = new GridData(SWT.CENTER, SWT.CENTER, false, false, 1, 1);
-               gd_lblUuid.widthHint = 270;
-               lblUuid.setLayoutData(gd_lblUuid);
-               toolkit.adapt(lblUuid);
-               toolkit.paintBordersFor(lblUuid);
-               lblUuid.setText("UUID");
-               
-               CLabel lblOperation = new CLabel(this, SWT.NONE);
+               lblOperation = new CLabel(this, SWT.NONE);
                lblOperation.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_BLUE));
                lblOperation.setAlignment(SWT.CENTER);
                GridData gd_lblOperation = new GridData(SWT.CENTER, SWT.CENTER, false, false, 1, 1);
@@ -86,4 +91,32 @@ public class CdmAuthorityTableHeader extends Composite {
 
        }
 
+
+       public void setUuidHeaderVisible(boolean visible) {
+               if(visible) {
+                       if(lblUuid == null) {
+                               createUUIDHeader();
+                       }
+                       lblUuid.moveAbove(lblOperation);                        
+               } else {
+                       if(lblUuid != null) {
+                               lblUuid.dispose();
+                       }
+                       lblUuid = null;
+               }
+               layout();
+       }
+       
+       private void createUUIDHeader() {
+               lblUuid = new CLabel(this, SWT.NONE);
+               lblUuid.setForeground(SWTResourceManager.getColor(SWT.COLOR_BLUE));
+               lblUuid.setAlignment(SWT.CENTER);
+               GridData gd_lblUuid = new GridData(SWT.CENTER, SWT.CENTER, false, false, 1, 1);
+               gd_lblUuid.widthHint = 270;
+               lblUuid.setLayoutData(gd_lblUuid);
+               toolkit.adapt(lblUuid);
+               toolkit.paintBordersFor(lblUuid);
+               lblUuid.setText("UUID");
+       }
+
 }