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;
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
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.
* @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();
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);
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());
}
}
});
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;
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);
}
/**
private final FormToolkit toolkit = new FormToolkit(Display.getCurrent());
private Label lblEntity;
- private Label lblTarget;
+ private Label lblUuid;
private CRUDOperationChooser operationChooser;
private Button btnDelete;
private Label lblDirtyFlag;
private CdmAuthorityCompositeViewer cdmaModel;
+ private Label lblType;
/**
* Create the composite, made up of 5 elements :
});
toolkit.adapt(this);
toolkit.paintBordersFor(this);
- setLayout(new GridLayout(5, false));
+ setLayout(new GridLayout(6, false));
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;
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));
* @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;
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) {
}
}
+
+ 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");
+ }
}
/**
-* 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;
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}
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.
*
});
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);
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);
}
+
+ 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");
+ }
+
}