Project

General

Profile

« Previous | Next » 

Revision be785417

Added by Katja Luther about 8 years ago

minor

View differences:

eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/container/AbstractGroup.java
1 1
/**
2 2
* Copyright (C) 2007 EDIT
3
* European Distributed Institute of Taxonomy 
3
* European Distributed Institute of Taxonomy
4 4
* http://www.e-taxonomy.eu
5
* 
5
*
6 6
* The contents of this file are subject to the Mozilla Public License Version 1.1
7 7
* See LICENSE.TXT at the top of this package for the full license terms.
8 8
*/
......
42 42
 * @version 1.0
43 43
 */
44 44
public abstract class AbstractGroup implements IDropTargetable{
45
	
45

  
46 46
	private Composite control;
47
	
48
	private List<AbstractGroupedContainer> groupedContainers = new ArrayList<AbstractGroupedContainer>(); 
49
	
47

  
48
	private final List<AbstractGroupedContainer> groupedContainers = new ArrayList<AbstractGroupedContainer>();
49

  
50 50
	protected TaxonNameEditor editor;
51
	
51

  
52 52
	private DropTarget target;
53 53
	private DropTargetListener dropListener;
54 54

  
......
61 61
	public AbstractGroup(TaxonNameEditor editor){
62 62
		this.editor = editor;
63 63
	}
64
	
64

  
65 65
	protected void createContent(){
66 66
		createControl();
67
		
67

  
68 68
		createContainers();
69
		
69

  
70 70
		// Drop functionality
71 71
		this.setDroppable(true);
72
		
72

  
73 73
		editor.getManagedForm().reflow(true);
74 74
	}
75 75

  
......
78 78
	 */
79 79
	protected void createControl() {
80 80
		control = editor.getToolkit().createComposite(editor.getControl());
81
		
81

  
82 82
		control.setLayoutData(new TableWrapData(TableWrapData.FILL_GRAB));
83 83
		TableWrapLayout layout = new TableWrapLayout();
84
		
84

  
85 85
		layout.topMargin = 0;
86 86
		layout.rightMargin = 0;
87 87
		layout.bottomMargin = 1;
88 88
		layout.leftMargin = 0;
89
		
89

  
90 90
		layout.verticalSpacing = 0;
91 91
		layout.horizontalSpacing = 0;
92 92
		control.setLayout(layout);
93
		
93

  
94 94
		control.setBackground(Display.getDefault().getSystemColor(SWT.COLOR_GRAY));
95 95
	}
96
	
96

  
97 97
	/**
98 98
	 * <p>add</p>
99 99
	 *
......
103 103
		groupedContainers.add(groupedContainer);
104 104
		groupedContainer.setGroup(this);
105 105
	}
106
	
106

  
107 107
	/**
108 108
	 * <p>remove</p>
109 109
	 *
......
112 112
	public void remove(AbstractGroupedContainer groupedContainer){
113 113
		groupedContainer.dispose();
114 114
		groupedContainers.remove(groupedContainer);
115
		
115

  
116 116
		if(!(this instanceof AcceptedGroup) && groupedContainers.isEmpty()){
117 117
			getEditor().removeGroup(this);
118 118
		}
119
	}	
120
	
119
	}
120

  
121 121
	/**
122 122
	 * <p>Getter for the field <code>groupedContainers</code>.</p>
123 123
	 *
......
126 126
	public List<AbstractGroupedContainer> getGroupedContainers(){
127 127
		return groupedContainers;
128 128
	}
129
	
130
	
129

  
130

  
131 131
	/**
132 132
	 * <p>setDroppable</p>
133 133
	 *
......
135 135
	 */
136 136
	public void setDroppable(boolean droppable) {
137 137
		if (droppable) {
138
			Transfer[] types = new Transfer[] {CdmDataTransfer.getInstance()};	
138
			Transfer[] types = new Transfer[] {CdmDataTransfer.getInstance()};
139 139
			int operations = DND.DROP_MOVE;
140 140
			target = new DropTarget(control, operations);
141 141
			target.setTransfer(types);
142 142
			dropListener = new NameEditorDropTargetListener(this);
143 143
			target.addDropListener(dropListener);
144
			
144

  
145 145
			target.setDropTargetEffect(new NameEditorDropTargetEffect(control));
146
			
146

  
147 147
		} else {
148 148
			if (dropListener != null) {
149 149
				target.removeDropListener(dropListener);
......
156 156
	 *
157 157
	 * @return a {@link eu.etaxonomy.taxeditor.editor.name.TaxonNameEditor} object.
158 158
	 */
159
	public TaxonNameEditor getEditor() {
159
	@Override
160
    public TaxonNameEditor getEditor() {
160 161
		return editor;
161 162
	}
162 163

  
163 164
	/**
164 165
	 * <p>dragEntered</p>
165 166
	 */
166
	public void dragEntered() {
167
	@Override
168
    public void dragEntered() {
167 169
		Color color = EditorUtil.getColor(Resources.COLOR_DRAG_ENTER);
168
				
170

  
169 171
		for(AbstractGroupedContainer container : groupedContainers){
170 172
			container.setBackground(color);
171
		}		
173
		}
172 174
	}
173 175

  
174 176
	/**
175 177
	 * <p>dragLeft</p>
176 178
	 */
177
	public void dragLeft() {
179
	@Override
180
    public void dragLeft() {
178 181
		for(AbstractGroupedContainer container : groupedContainers){
179 182
			container.restoreColor();
180 183
		}
181 184
	}
182
	
185

  
183 186
	/** {@inheritDoc} */
184
	public boolean postOperation(CdmBase objectAffectedByOperation) {
185
		editor.getMultiPageTaxonEditor().changed(null);
187
	@Override
188
    public boolean postOperation(CdmBase objectAffectedByOperation) {
189
		editor.getMultiPageTaxonEditor().changed(objectAffectedByOperation);
186 190
		redraw();
187 191
		return true;
188 192
	}
......
194 198
		emptyGroup();
195 199
		createContainers();
196 200
	}
197
	
201

  
198 202
	protected abstract void createContainers();
199
	
203

  
200 204
	/* (non-Javadoc)
201 205
	 * @see eu.etaxonomy.taxeditor.editor.IDropTargetable#getControl()
202 206
	 */
......
212 216
	public boolean onComplete() {
213 217
		return true;
214 218
	}
215
	
219

  
216 220
	public void dispose(){
217 221
		if(getControl() != null){
218 222
			for(AbstractGroupedContainer container : getGroupedContainers()){
......
222 226
			getControl().dispose();
223 227
		}
224 228
	}
225
	
229

  
226 230
	/**
227 231
	 * @param object
228 232
	 */
......
231 235
		for(AbstractGroupedContainer container : getGroupedContainers()){
232 236
			container.setMenu(menu);
233 237
		}
234
		
238

  
235 239
	}
236 240

  
237 241
	protected void emptyGroup(){

Also available in: Unified diff