/**
* 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.
*/
* @version 1.0
*/
public abstract class AbstractGroup implements IDropTargetable{
-
+
private Composite control;
-
- private List<AbstractGroupedContainer> groupedContainers = new ArrayList<AbstractGroupedContainer>();
-
+
+ private final List<AbstractGroupedContainer> groupedContainers = new ArrayList<AbstractGroupedContainer>();
+
protected TaxonNameEditor editor;
-
+
private DropTarget target;
private DropTargetListener dropListener;
public AbstractGroup(TaxonNameEditor editor){
this.editor = editor;
}
-
+
protected void createContent(){
createControl();
-
+
createContainers();
-
+
// Drop functionality
this.setDroppable(true);
-
+
editor.getManagedForm().reflow(true);
}
*/
protected void createControl() {
control = editor.getToolkit().createComposite(editor.getControl());
-
+
control.setLayoutData(new TableWrapData(TableWrapData.FILL_GRAB));
TableWrapLayout layout = new TableWrapLayout();
-
+
layout.topMargin = 0;
layout.rightMargin = 0;
layout.bottomMargin = 1;
layout.leftMargin = 0;
-
+
layout.verticalSpacing = 0;
layout.horizontalSpacing = 0;
control.setLayout(layout);
-
+
control.setBackground(Display.getDefault().getSystemColor(SWT.COLOR_GRAY));
}
-
+
/**
* <p>add</p>
*
groupedContainers.add(groupedContainer);
groupedContainer.setGroup(this);
}
-
+
/**
* <p>remove</p>
*
public void remove(AbstractGroupedContainer groupedContainer){
groupedContainer.dispose();
groupedContainers.remove(groupedContainer);
-
+
if(!(this instanceof AcceptedGroup) && groupedContainers.isEmpty()){
getEditor().removeGroup(this);
}
- }
-
+ }
+
/**
* <p>Getter for the field <code>groupedContainers</code>.</p>
*
public List<AbstractGroupedContainer> getGroupedContainers(){
return groupedContainers;
}
-
-
+
+
/**
* <p>setDroppable</p>
*
*/
public void setDroppable(boolean droppable) {
if (droppable) {
- Transfer[] types = new Transfer[] {CdmDataTransfer.getInstance()};
+ Transfer[] types = new Transfer[] {CdmDataTransfer.getInstance()};
int operations = DND.DROP_MOVE;
target = new DropTarget(control, operations);
target.setTransfer(types);
dropListener = new NameEditorDropTargetListener(this);
target.addDropListener(dropListener);
-
+
target.setDropTargetEffect(new NameEditorDropTargetEffect(control));
-
+
} else {
if (dropListener != null) {
target.removeDropListener(dropListener);
*
* @return a {@link eu.etaxonomy.taxeditor.editor.name.TaxonNameEditor} object.
*/
- public TaxonNameEditor getEditor() {
+ @Override
+ public TaxonNameEditor getEditor() {
return editor;
}
/**
* <p>dragEntered</p>
*/
- public void dragEntered() {
+ @Override
+ public void dragEntered() {
Color color = EditorUtil.getColor(Resources.COLOR_DRAG_ENTER);
-
+
for(AbstractGroupedContainer container : groupedContainers){
container.setBackground(color);
- }
+ }
}
/**
* <p>dragLeft</p>
*/
- public void dragLeft() {
+ @Override
+ public void dragLeft() {
for(AbstractGroupedContainer container : groupedContainers){
container.restoreColor();
}
}
-
+
/** {@inheritDoc} */
- public boolean postOperation(CdmBase objectAffectedByOperation) {
- editor.getMultiPageTaxonEditor().changed(null);
+ @Override
+ public boolean postOperation(CdmBase objectAffectedByOperation) {
+ editor.getMultiPageTaxonEditor().changed(objectAffectedByOperation);
redraw();
return true;
}
emptyGroup();
createContainers();
}
-
+
protected abstract void createContainers();
-
+
/* (non-Javadoc)
* @see eu.etaxonomy.taxeditor.editor.IDropTargetable#getControl()
*/
public boolean onComplete() {
return true;
}
-
+
public void dispose(){
if(getControl() != null){
for(AbstractGroupedContainer container : getGroupedContainers()){
getControl().dispose();
}
}
-
+
/**
* @param object
*/
for(AbstractGroupedContainer container : getGroupedContainers()){
container.setMenu(menu);
}
-
+
}
protected void emptyGroup(){