1 /**
2  *
3  * Copyright (C) Azureus Software, Inc, All Rights Reserved.
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
18  */
19 
20 package com.aelitis.azureus.ui.swt.views.skin;
21 
22 import java.util.*;
23 
24 import org.eclipse.swt.SWT;
25 import org.eclipse.swt.layout.FormAttachment;
26 import org.eclipse.swt.layout.FormData;
27 import org.eclipse.swt.widgets.Control;
28 
29 import org.gudy.azureus2.core3.config.COConfigurationManager;
30 import org.gudy.azureus2.core3.disk.DiskManagerFileInfo;
31 import org.gudy.azureus2.core3.download.DownloadManager;
32 import org.gudy.azureus2.core3.download.DownloadManagerListener;
33 import org.gudy.azureus2.core3.global.GlobalManager;
34 import org.gudy.azureus2.core3.util.AERunnable;
35 import org.gudy.azureus2.core3.util.Debug;
36 import org.gudy.azureus2.core3.util.FrequencyLimitedDispatcher;
37 import org.gudy.azureus2.plugins.ui.UIPluginViewToolBarListener;
38 import org.gudy.azureus2.plugins.ui.toolbar.*;
39 import org.gudy.azureus2.ui.swt.TorrentUtil;
40 import org.gudy.azureus2.ui.swt.Utils;
41 import org.gudy.azureus2.ui.swt.pluginsimpl.UIToolBarItemImpl;
42 import org.gudy.azureus2.ui.swt.pluginsimpl.UIToolBarManagerCore;
43 import org.gudy.azureus2.ui.swt.pluginsimpl.UIToolBarManagerImpl;
44 import org.gudy.azureus2.ui.swt.pluginsimpl.UIToolBarManagerImpl.ToolBarManagerListener;
45 
46 import com.aelitis.azureus.core.AzureusCoreFactory;
47 import com.aelitis.azureus.ui.common.ToolBarItem;
48 import com.aelitis.azureus.ui.common.table.TableView;
49 import com.aelitis.azureus.ui.selectedcontent.*;
50 import com.aelitis.azureus.ui.swt.UIFunctionsManagerSWT;
51 import com.aelitis.azureus.ui.swt.mdi.MdiEntrySWT;
52 import com.aelitis.azureus.ui.swt.mdi.MultipleDocumentInterfaceSWT;
53 import com.aelitis.azureus.ui.swt.skin.*;
54 import com.aelitis.azureus.ui.swt.skin.SWTSkinButtonUtility.ButtonListenerAdapter;
55 import com.aelitis.azureus.ui.swt.toolbar.ToolBarItemSO;
56 import com.aelitis.azureus.util.DLReferals;
57 import com.aelitis.azureus.util.PlayUtils;
58 
59 /**
60  * @author TuxPaper
61  * @created Jul 20, 2008
62  */
63 public class ToolBarView
64 	extends SkinView
65 	implements SelectedContentListener, ToolBarManagerListener,
66 	ToolBarItem.ToolBarItemListener
67 {
68 	private static boolean DEBUG = false;
69 
70 	private static toolbarButtonListener buttonListener;
71 
72 	private Map<UIToolBarItem, ToolBarItemSO> mapToolBarItemToSO = new HashMap<UIToolBarItem, ToolBarItemSO>();
73 
74 	private boolean showText = true;
75 
76 	private boolean initComplete = false;
77 
78 	private boolean showCalled = false;
79 
80 	private ArrayList<ToolBarViewListener> listeners = new ArrayList<ToolBarViewListener>(
81 			1);
82 
83 	private UIToolBarManagerCore tbm;
84 
85 	private boolean firstTimeEver = true;
86 
ToolBarView()87 	public ToolBarView() {
88 		tbm = (UIToolBarManagerCore) UIToolBarManagerImpl.getInstance();
89 	}
90 
createItem(ToolBarView tbv, String id, String imageid, String textID)91 	private ToolBarItem createItem(ToolBarView tbv, String id, String imageid,
92 			String textID) {
93 		UIToolBarItemImpl base = new UIToolBarItemImpl(id);
94 		base.setImageID(imageid);
95 		base.setTextID(textID);
96 		return base;
97 	}
98 
99 	// @see com.aelitis.azureus.ui.swt.views.skin.SkinView#showSupport(com.aelitis.azureus.ui.swt.skin.SWTSkinObject, java.lang.Object)
skinObjectInitialShow(SWTSkinObject skinObject, Object params)100 	public Object skinObjectInitialShow(SWTSkinObject skinObject, Object params) {
101 		boolean uiClassic = COConfigurationManager.getStringParameter("ui").equals(
102 				"az2");
103 
104 		if (uiClassic && !"global-toolbar".equals(skinObject.getViewID())) {
105 			skinObject.setVisible(false);
106 			return null;
107 		}
108 
109 			// walk up skins to see if toolbar explicitly disabled (for pop-out views for example)
110 
111 		SWTSkinObject temp = skinObject;
112 
113 		while( temp != null ){
114 
115 			int visible = temp.getSkin().getSkinProperties().getIntValue( "mdientry.toolbar.visible", 1 );
116 
117 			if ( visible == 0 ){
118 
119 				skinObject.setVisible(false);
120 
121 				return null;
122 			}
123 
124 			temp = temp.getParent();
125 		}
126 
127 		buttonListener = new toolbarButtonListener();
128 
129 
130 		if (firstTimeEver) {
131 			firstTimeEver = false;
132 			setupToolBarItems(uiClassic);
133 		}
134 		tbm.addListener(this);
135 
136 		if (uiClassic) {
137 			bulkSetupItems("classic", "toolbar.area.sitem");
138 		}
139 		bulkSetupItems(UIToolBarManager.GROUP_MAIN, "toolbar.area.sitem");
140 		bulkSetupItems("views", "toolbar.area.vitem");
141 
142 		String[] groupIDs = tbm.getGroupIDs();
143 		for (String groupID : groupIDs) {
144 			if ("classic".equals(groupID)
145 					|| UIToolBarManager.GROUP_MAIN.equals(groupID)
146 					|| "views".equals(groupID)) {
147 				continue;
148 			}
149 			bulkSetupItems(groupID, "toolbar.area.sitem");
150 		}
151 
152 		initComplete = true;
153 
154 		synchronized (listeners) {
155 			for (ToolBarViewListener l : listeners) {
156 				try {
157 					l.toolbarViewInitialized(this);
158 				} catch (Exception e) {
159 					Debug.out(e);
160 				}
161 			}
162 		}
163 
164 		return null;
165 	}
166 
setupToolBarItems(boolean uiClassic)167 	private void setupToolBarItems(boolean uiClassic) {
168 		ToolBarItem item;
169 
170 		if (uiClassic) {
171 			// ==OPEN
172 			item = createItem(this, "open", "image.toolbar.open", "Button.add");
173 			item.setDefaultActivationListener(new UIToolBarActivationListener() {
174 				public boolean toolBarItemActivated(ToolBarItem item,
175 						long activationType, Object datasource) {
176 					if (activationType != ACTIVATIONTYPE_NORMAL) {
177 						return false;
178 					}
179 					UIFunctionsManagerSWT.getUIFunctionsSWT().openTorrentWindow();
180 					return true;
181 				}
182 			});
183 			item.setAlwaysAvailable(true);
184 			item.setGroupID("classic");
185 			tbm.addToolBarItem(item, false);
186 
187 			// ==SEARCH
188 			item = createItem(this, "search", "search", "Button.search");
189 			item.setDefaultActivationListener(new UIToolBarActivationListener() {
190 				public boolean toolBarItemActivated(ToolBarItem item,
191 						long activationType, Object datasource) {
192 					if (activationType != ACTIVATIONTYPE_NORMAL) {
193 						return false;
194 					}
195 					UIFunctionsManagerSWT.getUIFunctionsSWT().promptForSearch();
196 					return true;
197 				}
198 			});
199 			item.setAlwaysAvailable(true);
200 			item.setGroupID("classic");
201 			tbm.addToolBarItem(item, false);
202 		}
203 
204 		if (!uiClassic) {
205 			// ==play
206 			item = createItem(this, "play", "image.button.play", "iconBar.play");
207 			item.setDefaultActivationListener(new UIToolBarActivationListener() {
208 				public boolean toolBarItemActivated(ToolBarItem item,
209 						long activationType, Object datasource) {
210 					if (activationType != ACTIVATIONTYPE_NORMAL) {
211 						return false;
212 					}
213 					ISelectedContent[] sc = SelectedContentManager.getCurrentlySelectedContent();
214 					if (sc != null && sc.length > 0) {
215 
216 						if (PlayUtils.canStreamDS(sc[0], sc[0].getFileIndex(),true)) {
217 							TorrentListViewsUtils.playOrStreamDataSource(sc[0],
218 									DLReferals.DL_REFERAL_TOOLBAR, true, false);
219 						} else {
220 							TorrentListViewsUtils.playOrStreamDataSource(sc[0],
221 									DLReferals.DL_REFERAL_TOOLBAR, false, true);
222 						}
223 					}
224 					return false;
225 				}
226 			});
227 			tbm.addToolBarItem(item, false);
228 		}
229 
230 		// ==run
231 		item = createItem(this, "run", "image.toolbar.run", "iconBar.run");
232 		item.setDefaultActivationListener(new UIToolBarActivationListener() {
233 			public boolean toolBarItemActivated(ToolBarItem item,
234 					long activationType, Object datasource) {
235 				if (activationType != ACTIVATIONTYPE_NORMAL) {
236 					return false;
237 				}
238 				TableView tv = SelectedContentManager.getCurrentlySelectedTableView();
239 				Object[] ds;
240 				if (tv != null) {
241 					ds = tv.getSelectedDataSources().toArray();
242 				} else {
243 					ds = SelectedContentManager.getDMSFromSelectedContent();
244 				}
245 				if (ds != null) {
246 					TorrentUtil.runDataSources(ds);
247 					return true;
248 				}
249 				return false;
250 			}
251 		});
252 		tbm.addToolBarItem(item, false);
253 		//addToolBarItem(item, "toolbar.area.sitem", so2nd);
254 
255 		if (uiClassic) {
256 			// ==TOP
257 			item = createItem(this, "top", "image.toolbar.top", "iconBar.top");
258 			item.setDefaultActivationListener(new UIToolBarActivationListener() {
259 				public boolean toolBarItemActivated(ToolBarItem item,
260 						long activationType, Object datasource) {
261 					if (activationType == ACTIVATIONTYPE_NORMAL) {
262 						return moveTop();
263 					}
264 
265 					return false;
266 				}
267 			});
268 			tbm.addToolBarItem(item, false);
269 		}
270 
271 		// ==UP
272 		item = createItem(this, "up", "image.toolbar.up", "v3.iconBar.up");
273 		item.setDefaultActivationListener(new UIToolBarActivationListener() {
274 			public boolean toolBarItemActivated(ToolBarItem item,
275 					long activationType, Object datasource) {
276 				if (activationType == ACTIVATIONTYPE_NORMAL) {
277 					if (!AzureusCoreFactory.isCoreRunning()) {
278 						return false;
279 					}
280 					DownloadManager[] dms = SelectedContentManager.getDMSFromSelectedContent();
281 					if (dms != null) {
282 						Arrays.sort(dms, new Comparator<DownloadManager>() {
283 							public int compare(DownloadManager a, DownloadManager b) {
284 								return a.getPosition() - b.getPosition();
285 							}
286 						});
287 						GlobalManager gm = AzureusCoreFactory.getSingleton().getGlobalManager();
288 						for (int i = 0; i < dms.length; i++) {
289 							DownloadManager dm = dms[i];
290 							if (gm.isMoveableUp(dm)) {
291 								gm.moveUp(dm);
292 							}
293 						}
294 					}
295 				} else if (activationType == ACTIVATIONTYPE_HELD) {
296 					return moveTop();
297 				}
298 				return false;
299 			}
300 		});
301 		tbm.addToolBarItem(item, false);
302 
303 		// ==down
304 		item = createItem(this, "down", "image.toolbar.down", "v3.iconBar.down");
305 		item.setDefaultActivationListener(new UIToolBarActivationListener() {
306 			public boolean toolBarItemActivated(ToolBarItem item,
307 					long activationType, Object datasource) {
308 				if (activationType == ACTIVATIONTYPE_NORMAL) {
309 					if (!AzureusCoreFactory.isCoreRunning()) {
310 						return false;
311 					}
312 
313 					GlobalManager gm = AzureusCoreFactory.getSingleton().getGlobalManager();
314 					DownloadManager[] dms = SelectedContentManager.getDMSFromSelectedContent();
315 					if (dms != null) {
316 						Arrays.sort(dms, new Comparator<DownloadManager>() {
317 							public int compare(DownloadManager a, DownloadManager b) {
318 								return b.getPosition() - a.getPosition();
319 							}
320 						});
321 						for (int i = 0; i < dms.length; i++) {
322 							DownloadManager dm = dms[i];
323 							if (gm.isMoveableDown(dm)) {
324 								gm.moveDown(dm);
325 							}
326 						}
327 						return true;
328 					}
329 				} else if (activationType == ACTIVATIONTYPE_HELD) {
330 					return moveBottom();
331 				}
332 				return false;
333 			}
334 		});
335 		tbm.addToolBarItem(item, false);
336 
337 		if (uiClassic) {
338 			// ==BOTTOM
339 			item = createItem(this, "bottom", "image.toolbar.bottom",
340 					"iconBar.bottom");
341 			item.setDefaultActivationListener(new UIToolBarActivationListener() {
342 				public boolean toolBarItemActivated(ToolBarItem item,
343 						long activationType, Object datasource) {
344 					if (activationType != ACTIVATIONTYPE_NORMAL) {
345 						return false;
346 					}
347 					return moveBottom();
348 				}
349 			});
350 			tbm.addToolBarItem(item, false);
351 		}
352 		/*
353 				// ==start
354 				item = createItemSO(this, "start", "image.toolbar.start", "iconBar.start");
355 				item.setDefaultActivation(new UIToolBarActivationListener() {
356 					public boolean toolBarItemActivated(ToolBarItem item, long activationType) {
357 						if (activationType != ACTIVATIONTYPE_NORMAL) {
358 							return false;
359 						}
360 						DownloadManager[] dms = SelectedContentManager.getDMSFromSelectedContent();
361 						if (dms != null) {
362 							TorrentUtil.queueDataSources(dms, true);
363 							return true;
364 						}
365 						return false;
366 					}
367 				});
368 				addToolBarItem(item, "toolbar.area.sitem", so2nd);
369 				//SWTSkinObjectContainer so = (SWTSkinObjectContainer) item.getSkinButton().getSkinObject();
370 				//so.setDebugAndChildren(true);
371 				addSeperator(so2nd);
372 
373 				// ==stop
374 				item = createItemSO(this, "stop", "image.toolbar.stop", "iconBar.stop");
375 				item.setDefaultActivation(new UIToolBarActivationListener() {
376 					public boolean toolBarItemActivated(ToolBarItem item, long activationType) {
377 						if (activationType != ACTIVATIONTYPE_NORMAL) {
378 							return false;
379 						}
380 		 				ISelectedContent[] currentContent = SelectedContentManager.getCurrentlySelectedContent();
381 						TorrentUtil.stopDataSources(currentContent);
382 						return true;
383 					}
384 				});
385 				addToolBarItem(item, "toolbar.area.sitem", so2nd);
386 				addSeperator(so2nd);
387 		*/
388 		// ==startstop
389 		item = createItem(this, "startstop", "image.toolbar.startstop.start",
390 				"iconBar.startstop");
391 		item.setDefaultActivationListener(new UIToolBarActivationListener_OffSWT(
392 				UIToolBarActivationListener.ACTIVATIONTYPE_NORMAL) {
393 			@Override
394 			public void toolBarItemActivated_OffSWT(ToolBarItem item,
395 					long activationType, Object datasource) {
396 				ISelectedContent[] selected = SelectedContentManager.getCurrentlySelectedContent();
397 				TorrentUtil.stopOrStartDataSources(selected);
398 			}
399 		});
400 		tbm.addToolBarItem(item, false);
401 
402 		// ==remove
403 		item = createItem(this, "remove", "image.toolbar.remove", "iconBar.remove");
404 		item.setDefaultActivationListener(new UIToolBarActivationListener_OffSWT(
405 				UIToolBarActivationListener.ACTIVATIONTYPE_NORMAL) {
406 			@Override
407 			public void toolBarItemActivated_OffSWT(ToolBarItem item,
408 					long activationType, Object datasource) {
409 				ISelectedContent[] selected = SelectedContentManager.getCurrentlySelectedContent();
410 				TorrentUtil.removeDataSources(selected);
411 			}
412 		});
413 		tbm.addToolBarItem(item, false);
414 
415 		///////////////////////
416 
417 		if ( COConfigurationManager.getBooleanParameter( "Library.EnableSimpleView" )){
418 
419 			// == mode big
420 			item = createItem(this, "modeBig", "image.toolbar.table_large",
421 					"v3.iconBar.view.big");
422 			item.setGroupID("views");
423 			tbm.addToolBarItem(item, false);
424 
425 			// == mode small
426 			item = createItem(this, "modeSmall", "image.toolbar.table_normal",
427 					"v3.iconBar.view.small");
428 			item.setGroupID("views");
429 			tbm.addToolBarItem(item, false);
430 		}
431 	}
432 
currentlySelectedContentChanged( ISelectedContent[] currentContent, String viewID)433 	public void currentlySelectedContentChanged(
434 			ISelectedContent[] currentContent, String viewID) {
435 		//System.err.println("currentlySelectedContentChanged " + viewID + ";" + currentContent + ";" + getMainSkinObject() + this + " via " + Debug.getCompressedStackTrace());
436 		refreshCoreToolBarItems();
437 		UIFunctionsManagerSWT.getUIFunctionsSWT().refreshTorrentMenu();
438 	}
439 
440 	// @see com.aelitis.azureus.ui.swt.views.skin.SkinView#skinObjectShown(com.aelitis.azureus.ui.swt.skin.SWTSkinObject, java.lang.Object)
skinObjectShown(SWTSkinObject skinObject, Object params)441 	public Object skinObjectShown(SWTSkinObject skinObject, Object params) {
442 
443 		if (showCalled) {
444 			return null;
445 		}
446 		showCalled = true;
447 
448 		Object object = super.skinObjectShown(skinObject, params);
449 
450   	ToolBarItem[] allToolBarItems = tbm.getAllSWTToolBarItems();
451   	for (int i = 0; i < allToolBarItems.length; i++) {
452   		ToolBarItem toolBarItem = allToolBarItems[i];
453   		toolBarItem.addToolBarItemListener(this);
454   		uiFieldChanged(toolBarItem);
455   	}
456 
457 
458 		SelectedContentManager.addCurrentlySelectedContentListener(this);
459 		return object;
460 	}
461 
462 	// @see com.aelitis.azureus.ui.swt.views.skin.SkinView#skinObjectHidden(com.aelitis.azureus.ui.swt.skin.SWTSkinObject, java.lang.Object)
skinObjectHidden(SWTSkinObject skinObject, Object params)463 	public Object skinObjectHidden(SWTSkinObject skinObject, Object params) {
464 		showCalled = false;
465 		SelectedContentManager.removeCurrentlySelectedContentListener(this);
466 
467   	ToolBarItem[] allToolBarItems = tbm.getAllSWTToolBarItems();
468   	for (int i = 0; i < allToolBarItems.length; i++) {
469   		ToolBarItem toolBarItem = allToolBarItems[i];
470   		toolBarItem.removeToolBarItemListener(this);
471   	}
472 
473 		return super.skinObjectHidden(skinObject, params);
474 	}
475 
476 	// @see com.aelitis.azureus.ui.swt.views.skin.SkinView#skinObjectDestroyed(com.aelitis.azureus.ui.swt.skin.SWTSkinObject, java.lang.Object)
skinObjectDestroyed(SWTSkinObject skinObject, Object params)477 	public Object skinObjectDestroyed(SWTSkinObject skinObject, Object params) {
478 		tbm.removeListener(this);
479 
480 		return super.skinObjectDestroyed(skinObject, params);
481 	}
482 
triggerToolBarItem(ToolBarItem item, long activationType, Object datasource)483 	public boolean triggerToolBarItem(ToolBarItem item, long activationType,
484 			Object datasource) {
485 		if (!isVisible()) {
486 			if (DEBUG) {
487 				Debug.out("Trying to triggerToolBarItem when toolbar is not visible");
488 			}
489 			return false;
490 		}
491 		if (triggerViewToolBar(item, activationType, datasource)) {
492 			return true;
493 		}
494 
495 		UIToolBarActivationListener defaultActivation = item.getDefaultActivationListener();
496 		if (defaultActivation != null) {
497 			return defaultActivation.toolBarItemActivated(item, activationType,
498 					datasource);
499 		}
500 
501 		if (DEBUG) {
502 			String viewID = SelectedContentManager.getCurrentySelectedViewID();
503 			System.out.println("Warning: Fallback of toolbar button " + item.getID()
504 					+ " via " + viewID + " view");
505 		}
506 
507 		return false;
508 	}
509 
moveBottom()510 	protected boolean moveBottom() {
511 		if (!AzureusCoreFactory.isCoreRunning()) {
512 			return false;
513 		}
514 
515 		GlobalManager gm = AzureusCoreFactory.getSingleton().getGlobalManager();
516 		DownloadManager[] dms = SelectedContentManager.getDMSFromSelectedContent();
517 		if (dms != null) {
518 			gm.moveEnd(dms);
519 		}
520 		return true;
521 	}
522 
moveTop()523 	protected boolean moveTop() {
524 		if (!AzureusCoreFactory.isCoreRunning()) {
525 			return false;
526 		}
527 		GlobalManager gm = AzureusCoreFactory.getSingleton().getGlobalManager();
528 		DownloadManager[] dms = SelectedContentManager.getDMSFromSelectedContent();
529 		if (dms != null) {
530 			gm.moveTop(dms);
531 		}
532 		return true;
533 	}
534 
535 	private FrequencyLimitedDispatcher refresh_limiter = new FrequencyLimitedDispatcher(
536 			new AERunnable() {
537 				private AERunnable lock = this;
538 
539 				private boolean refresh_pending;
540 
541 				public void runSupport() {
542 					synchronized (lock) {
543 
544 						if (refresh_pending) {
545 
546 							return;
547 						}
548 						refresh_pending = true;
549 					}
550 
551 					if (DEBUG) {
552 						System.out.println("refreshCoreItems via "
553 								+ Debug.getCompressedStackTrace());
554 					}
555 
556 					Utils.execSWTThread(new AERunnable() {
557 						public void runSupport() {
558 
559 							synchronized (lock) {
560 
561 								refresh_pending = false;
562 							}
563 
564 							_refreshCoreToolBarItems();
565 						}
566 					});
567 				}
568 			}, 250);
569 
570 	private IdentityHashMap<DownloadManager, DownloadManagerListener> dm_listener_map = new IdentityHashMap<DownloadManager, DownloadManagerListener>();
571 
572 	private SWTSkinObject soLastGroup;
573 
refreshCoreToolBarItems()574 	public void refreshCoreToolBarItems() {
575 		if (DEBUG) {
576 			System.out.println("refreshCoreItems Start via "
577 					+ Debug.getCompressedStackTrace());
578 		}
579 		refresh_limiter.dispatch();
580 	}
581 
_refreshCoreToolBarItems()582 	public void _refreshCoreToolBarItems() {
583 		if (DEBUG && !isVisible()) {
584 			Debug.out("Trying to refresh core toolbar items when toolbar is not visible "
585 					+ this + getMainSkinObject());
586 		}
587 
588 		MultipleDocumentInterfaceSWT mdi = UIFunctionsManagerSWT.getUIFunctionsSWT().getMDISWT();
589 
590 		if (mdi != null) {
591 			UIToolBarItem[] allToolBarItems = tbm.getAllToolBarItems();
592 			MdiEntrySWT entry = mdi.getCurrentEntrySWT();
593 			Map<String, Long> mapStates = new HashMap<String, Long>();
594 			if (entry != null) {
595 				UIToolBarEnablerBase[] enablers = entry.getToolbarEnablers();
596 				for (UIToolBarEnablerBase enabler : enablers) {
597 					if (enabler instanceof UIPluginViewToolBarListener) {
598 						try {
599 							((UIPluginViewToolBarListener) enabler).refreshToolBarItems(mapStates);
600 						} catch (Throwable e) {
601 							Debug.out(e); // don't trust them plugins
602 						}
603 					}
604 				}
605 			}
606 
607 			ISelectedContent[] currentContent = SelectedContentManager.getCurrentlySelectedContent();
608 			//System.out.println("_refreshCoreToolBarItems(" + currentContent.length + ", " + entry + " via " + Debug.getCompressedStackTrace());
609 
610 			synchronized (dm_listener_map) {
611 
612 				Map<DownloadManager, DownloadManagerListener> copy = new IdentityHashMap<DownloadManager, DownloadManagerListener>(
613 						dm_listener_map);
614 
615 				for (ISelectedContent content : currentContent) {
616 
617 					DownloadManager dm = content.getDownloadManager();
618 
619 					if (dm != null) {
620 
621 						copy.remove(dm);
622 
623 						// so in files view we can have multiple selections that map onto the SAME download manager
624 						// - ensure that we only add the listener once!
625 
626 						if (!dm_listener_map.containsKey(dm)) {
627 
628 							DownloadManagerListener l = new DownloadManagerListener() {
629 								public void stateChanged(DownloadManager manager, int state) {
630 									refreshCoreToolBarItems();
631 								}
632 
633 								public void downloadComplete(DownloadManager manager) {
634 									refreshCoreToolBarItems();
635 								}
636 
637 								public void completionChanged(DownloadManager manager,
638 										boolean bCompleted) {
639 									refreshCoreToolBarItems();
640 								}
641 
642 								public void positionChanged(DownloadManager download,
643 										int oldPosition, int newPosition) {
644 									refreshCoreToolBarItems();
645 								}
646 
647 								public void filePriorityChanged(DownloadManager download,
648 										DiskManagerFileInfo file) {
649 									refreshCoreToolBarItems();
650 								}
651 							};
652 
653 							dm.addListener(l, false);
654 
655 							dm_listener_map.put(dm, l);
656 
657 							//System.out.println( "Added " + dm.getDisplayName() + " - size=" + dm_listener_map.size());
658 						}
659 					}
660 				}
661 
662 				for (Map.Entry<DownloadManager, DownloadManagerListener> e : copy.entrySet()) {
663 
664 					DownloadManager dm = e.getKey();
665 
666 					dm.removeListener(e.getValue());
667 
668 					dm_listener_map.remove(dm);
669 
670 					//System.out.println( "Removed " + dm.getDisplayName() + " - size=" + dm_listener_map.size());
671 				}
672 			}
673 
674 			boolean has1Selection = currentContent.length == 1;
675 
676 			boolean can_play = false;
677 			boolean can_stream = false;
678 
679 			boolean stream_permitted = false;
680 
681 			if (has1Selection) {
682 
683 				if (!(currentContent[0] instanceof ISelectedVuzeFileContent)) {
684 
685 					can_play = PlayUtils.canPlayDS(currentContent[0],
686 							currentContent[0].getFileIndex(),false);
687 					can_stream = PlayUtils.canStreamDS(currentContent[0],
688 							currentContent[0].getFileIndex(),false);
689 
690 					if (can_stream) {
691 
692 						stream_permitted = PlayUtils.isStreamPermitted();
693 					}
694 				}
695 			}
696 
697 			// allow a tool-bar enabler to manually handle play/stream events
698 
699 			if (mapStates.containsKey("play")) {
700 				can_play |= (mapStates.get("play") & UIToolBarItem.STATE_ENABLED) > 0;
701 			}
702 			if (mapStates.containsKey("stream")) {
703 				can_stream |= (mapStates.get("stream") & UIToolBarItem.STATE_ENABLED) > 0;
704 			}
705 
706 			mapStates.put("play", can_play | can_stream ? UIToolBarItem.STATE_ENABLED
707 					: 0);
708 
709 			UIToolBarItem pitem = tbm.getToolBarItem("play");
710 
711 			if (pitem != null) {
712 
713 				if (can_stream) {
714 
715 					pitem.setImageID(stream_permitted ? "image.button.stream"
716 							: "image.button.pstream");
717 					pitem.setTextID(stream_permitted ? "iconBar.stream"
718 							: "iconBar.pstream");
719 
720 				} else {
721 
722 					pitem.setImageID("image.button.play");
723 					pitem.setTextID("iconBar.play");
724 				}
725 			}
726 
727 			UIToolBarItem ssItem = tbm.getToolBarItem("startstop");
728 			if (ssItem != null){
729 
730 				boolean shouldStopGroup;
731 
732 					// if no selected content set then use the 'start' key to determine the start/stop
733 					// toolbar state (required for archived downloads)
734 					// alternative solution would be for the view to start updating the current selected
735 					// content which is a little painful
736 
737 				if ( 	currentContent.length == 0 &&
738 						mapStates.containsKey( "start" ) &&
739 						(!mapStates.containsKey( "stop" ) || (mapStates.get("stop") & UIToolBarItem.STATE_ENABLED) == 0) &&
740 						( mapStates.get("start") & UIToolBarItem.STATE_ENABLED) > 0 ){
741 
742 					shouldStopGroup = false;
743 
744 				}else{
745 					shouldStopGroup = TorrentUtil.shouldStopGroup(currentContent);
746 				}
747 
748 				ssItem.setTextID(shouldStopGroup ? "iconBar.stop" : "iconBar.start");
749 				ssItem.setImageID("image.toolbar.startstop."
750 						+ (shouldStopGroup ? "stop" : "start"));
751 
752 				// fallback to handle start/stop settings when no explicit selected content (e.g. for devices transcode view)
753 
754 				if (currentContent.length == 0 && !mapStates.containsKey("startstop")) {
755 
756 					boolean can_stop = mapStates.containsKey("stop")
757 							&& (mapStates.get("stop") & UIToolBarItem.STATE_ENABLED) > 0;
758 					boolean can_start = mapStates.containsKey("start")
759 							&& (mapStates.get("start") & UIToolBarItem.STATE_ENABLED) > 0;
760 
761 					if (can_start && can_stop) {
762 
763 						can_stop = false;
764 					}
765 
766 					if (can_start || can_stop) {
767 						ssItem.setTextID(can_stop ? "iconBar.stop" : "iconBar.start");
768 						ssItem.setImageID("image.toolbar.startstop."
769 								+ (can_stop ? "stop" : "start"));
770 
771 						mapStates.put("startstop", UIToolBarItem.STATE_ENABLED);
772 					}
773 				}
774 			}
775 
776 			Map<String, Long> fallBackStates = TorrentUtil.calculateToolbarStates(currentContent, null);
777 			for (String key : fallBackStates.keySet()) {
778 				if (!mapStates.containsKey(key)) {
779 					mapStates.put(key, fallBackStates.get(key));
780 				}
781 			}
782 
783 			final String[] TBKEYS = new String[] {
784 				"play",
785 				"run",
786 				"top",
787 				"up",
788 				"down",
789 				"bottom",
790 				"start",
791 				"stop",
792 				"startstop",
793 				"remove"
794 			};
795 			for (String key : TBKEYS) {
796 				if (!mapStates.containsKey(key)) {
797 					mapStates.put(key, 0L);
798 				}
799 			}
800 
801 			for (int i = 0; i < allToolBarItems.length; i++) {
802 				UIToolBarItem toolBarItem = allToolBarItems[i];
803 				Long state = mapStates.get(toolBarItem.getID());
804 				if (state != null) {
805 					toolBarItem.setState(state);
806 				}
807 			}
808 		}
809 
810 	}
811 
triggerViewToolBar(ToolBarItem item, long activationType, Object datasource)812 	private boolean triggerViewToolBar(ToolBarItem item, long activationType,
813 			Object datasource) {
814 		if (DEBUG && !isVisible()) {
815 			Debug.out("Trying to triggerViewToolBar when toolbar is not visible");
816 			return false;
817 		}
818 		MultipleDocumentInterfaceSWT mdi = UIFunctionsManagerSWT.getUIFunctionsSWT().getMDISWT();
819 		if (mdi != null) {
820 			MdiEntrySWT entry = mdi.getCurrentEntrySWT();
821 			UIToolBarEnablerBase[] enablers = entry.getToolbarEnablers();
822 			for (UIToolBarEnablerBase enabler : enablers) {
823 				if (enabler instanceof UIPluginViewToolBarListener) {
824 					if (((UIPluginViewToolBarListener) enabler).toolBarItemActivated(
825 							item, activationType, datasource)) {
826 						return true;
827 					}
828 				}
829 			}
830 		}
831 
832 		return false;
833 	}
834 
bulkSetupItems(String groupID, String templatePrefix)835 	private void bulkSetupItems(String groupID, String templatePrefix) {
836 		String[] idsByGroup = tbm.getToolBarIDsByGroup(groupID);
837 		SWTSkinObjectContainer groupSO = getGroupSO(groupID);
838 		SWTSkinObject[] children = groupSO.getChildren();
839 		for (SWTSkinObject so : children) {
840 			so.dispose();
841 		}
842 
843 		for (int i = 0; i < idsByGroup.length; i++) {
844 			String itemID = idsByGroup[i];
845 			UIToolBarItem item = tbm.getToolBarItem(itemID);
846 			if (item instanceof ToolBarItem) {
847 
848 
849 				int position = 0;
850 				int size = idsByGroup.length;
851 				if (size == 1) {
852 					position = SWT.SINGLE;
853 				} else if (i == 0) {
854 					position = SWT.LEFT;
855 				} else if (i == size - 1) {
856 					addSeperator(groupID);
857 					position = SWT.RIGHT;
858 				} else {
859 					addSeperator(groupID);
860 				}
861 				createItemSO((ToolBarItem) item, templatePrefix, position);
862 			}
863 		}
864 
865 		addNonToolBar("toolbar.area.sitem.left2", groupID);
866 	}
867 
getLastControl(String groupID)868 	private Control getLastControl(String groupID) {
869 		SWTSkinObjectContainer groupSO = getGroupSO(groupID);
870 		SWTSkinObject[] children = groupSO.getChildren();
871 		if (children == null || children.length == 0) {
872 			return null;
873 		}
874 		return children[children.length - 1].getControl();
875 	}
876 
createItemSO(ToolBarItem item, String templatePrefix, int position)877 	private void createItemSO(ToolBarItem item, String templatePrefix,
878 			 int position) {
879 
880 		ToolBarItemSO existingItemSO = mapToolBarItemToSO.get(item);
881 		if (existingItemSO != null) {
882 			SWTSkinObject so = existingItemSO.getSO();
883 			if (so != null) {
884 				so.dispose();
885 			}
886 		}
887 
888 		String templateID = templatePrefix;
889 		if (position == SWT.RIGHT) {
890 			templateID += ".right";
891 		} else if (position == SWT.LEFT) {
892 			templateID += ".left";
893 		} else if (position == SWT.SINGLE) {
894 			templateID += ".lr";
895 		}
896 
897 		Control attachToControl = getLastControl(item.getGroupID());
898 		String id = "toolbar:" + item.getID();
899 		SWTSkinObject so = skin.createSkinObject(id, templateID, getGroupSO(item.getGroupID()));
900 		if (so != null) {
901 			ToolBarItemSO itemSO;
902 			itemSO = new ToolBarItemSO((UIToolBarItemImpl) item, so);
903 
904 			if (attachToControl != null) {
905 				FormData fd = (FormData) so.getControl().getLayoutData();
906 				fd.left = new FormAttachment(attachToControl);
907 			}
908 
909 			initSO(so, itemSO);
910 
911 			if (initComplete) {
912 				Utils.relayout(so.getControl().getParent());
913 			}
914 		}
915 	}
916 
getGroupSO(String groupID)917 	private SWTSkinObjectContainer getGroupSO(String groupID) {
918 		String soID = "toolbar-group-" + groupID;
919 		SWTSkinObjectContainer soGroup = (SWTSkinObjectContainer) skin.getSkinObjectByID(
920 				soID, soMain);
921 
922 		if (soGroup == null) {
923 			soGroup = (SWTSkinObjectContainer) skin.createSkinObject(soID,
924 					"toolbar.group", soMain);
925 			FormData fd = (FormData) soGroup.getControl().getLayoutData();
926 			if (soLastGroup != null) {
927 				fd.left = new FormAttachment(soLastGroup.getControl(), 0, SWT.RIGHT);
928 			} else {
929 				fd.left = new FormAttachment(0, 2);
930 			}
931 		}
932 
933 		soLastGroup = soGroup;
934 
935 		return soGroup;
936 	}
937 
initSO(SWTSkinObject so, ToolBarItemSO itemSO)938 	private void initSO(SWTSkinObject so, ToolBarItemSO itemSO) {
939 		ToolBarItem item = itemSO.getBase();
940 		itemSO.setSO(so);
941 		String toolTip = item.getToolTip();
942 		if (toolTip != null) {
943 			so.setTooltipID("!" + toolTip + "!");
944 		} else {
945 			so.setTooltipID(item.getTooltipID());
946 		}
947 		so.setData("toolbaritem", item);
948 		SWTSkinButtonUtility btn = (SWTSkinButtonUtility) so.getData("btn");
949 		if (btn == null) {
950 			btn = new SWTSkinButtonUtility(so, "toolbar-item-image");
951 			so.setData("btn", btn);
952 		}
953 		btn.setImage(item.getImageID());
954 		btn.addSelectionListener(buttonListener);
955 		itemSO.setSkinButton(btn);
956 
957 		SWTSkinObject soTitle = skin.getSkinObject("toolbar-item-title", so);
958 		if (soTitle instanceof SWTSkinObjectText) {
959 			((SWTSkinObjectText) soTitle).setTextID(item.getTextID());
960 			itemSO.setSkinTitle((SWTSkinObjectText) soTitle);
961 		}
962 		mapToolBarItemToSO.put(item, itemSO);
963 	}
964 
965 	// @see com.aelitis.azureus.ui.common.ToolBarItem.ToolBarItemListener#uiFieldChanged(com.aelitis.azureus.ui.common.ToolBarItem)
uiFieldChanged(ToolBarItem item)966 	public void uiFieldChanged(ToolBarItem item) {
967 		ToolBarItemSO itemSO = mapToolBarItemToSO.get(item);
968 		if (itemSO != null) {
969 			itemSO.updateUI();
970 		}
971 	}
972 
addSeperator(String groupID)973 	private void addSeperator(String groupID) {
974 		addSeperator("toolbar.area.sitem.sep", groupID);
975 	}
976 
addSeperator(String id, String groupID)977 	private void addSeperator(String id, String groupID) {
978 		SWTSkinObjectContainer soGroup = getGroupSO(groupID);
979 		Control lastControl = getLastControl(groupID);
980 		SWTSkinObject so = skin.createSkinObject("toolbar_sep" + Math.random(), id,
981 				soGroup);
982 		if (so != null) {
983 			if (lastControl != null) {
984 				FormData fd = (FormData) so.getControl().getLayoutData();
985 				fd.left = new FormAttachment(lastControl, fd.left == null ? 0
986 						: fd.left.offset);
987 			}
988 		}
989 	}
990 
addNonToolBar(String skinid, String groupID)991 	private void addNonToolBar(String skinid, String groupID) {
992 		SWTSkinObjectContainer soGroup = getGroupSO(groupID);
993 		Control lastControl = getLastControl(groupID);
994 		SWTSkinObject so = skin.createSkinObject("toolbar_d" + Math.random(),
995 				skinid, soGroup);
996 		if (so != null) {
997 			if (lastControl != null) {
998 				FormData fd = (FormData) so.getControl().getLayoutData();
999 				fd.left = new FormAttachment(lastControl, fd.left == null ? 0
1000 						: fd.left.offset);
1001 			}
1002 		}
1003 	}
1004 
1005 	/**
1006 	 * @param showText the showText to set
1007 	 */
setShowText(boolean showText)1008 	public void setShowText(boolean showText) {
1009 		this.showText = showText;
1010 		UIToolBarItem[] allToolBarItems = tbm.getAllToolBarItems();
1011 		for (int i = 0; i < allToolBarItems.length; i++) {
1012 			UIToolBarItem tbi = allToolBarItems[i];
1013 			SWTSkinObject so = ((ToolBarItemSO) tbi).getSkinButton().getSkinObject();
1014 			SWTSkinObject soTitle = skin.getSkinObject("toolbar-item-title", so);
1015 			if (soTitle != null) {
1016 				soTitle.setVisible(showText);
1017 			}
1018 		}
1019 	}
1020 
1021 	/**
1022 	 * @return the showText
1023 	 */
getShowText()1024 	public boolean getShowText() {
1025 		return showText;
1026 	}
1027 
1028 	private static class toolbarButtonListener
1029 		extends ButtonListenerAdapter
1030 	{
pressed(SWTSkinButtonUtility buttonUtility, SWTSkinObject skinObject, int stateMask)1031 		public void pressed(SWTSkinButtonUtility buttonUtility,
1032 				SWTSkinObject skinObject, int stateMask) {
1033 			ToolBarItem item = (ToolBarItem) buttonUtility.getSkinObject().getData(
1034 					"toolbaritem");
1035 			boolean rightClick = (stateMask & (SWT.BUTTON3 | SWT.MOD4)) > 0;
1036 			Object o = SelectedContentManager.convertSelectedContentToObject(null);
1037 			item.triggerToolBarItem(rightClick
1038 					? UIToolBarActivationListener.ACTIVATIONTYPE_RIGHTCLICK
1039 					: UIToolBarActivationListener.ACTIVATIONTYPE_NORMAL, o);
1040 		}
1041 
held(SWTSkinButtonUtility buttonUtility)1042 		public boolean held(SWTSkinButtonUtility buttonUtility) {
1043 			ToolBarItem item = (ToolBarItem) buttonUtility.getSkinObject().getData(
1044 					"toolbaritem");
1045 			buttonUtility.getSkinObject().switchSuffix("", 0, false, true);
1046 
1047 			Object o = SelectedContentManager.convertSelectedContentToObject(null);
1048 			boolean triggerToolBarItemHold = item.triggerToolBarItem(
1049 					UIToolBarActivationListener.ACTIVATIONTYPE_HELD, o);
1050 			return triggerToolBarItemHold;
1051 		}
1052 	}
1053 
addListener(ToolBarViewListener l)1054 	public void addListener(ToolBarViewListener l) {
1055 		synchronized (listeners) {
1056 			listeners.add(l);
1057 
1058 			if (initComplete) {
1059 				try {
1060 					l.toolbarViewInitialized(this);
1061 				} catch (Exception e) {
1062 					Debug.out(e);
1063 				}
1064 			}
1065 		}
1066 	}
1067 
removeListener(ToolBarViewListener l)1068 	public void removeListener(ToolBarViewListener l) {
1069 		synchronized (listeners) {
1070 			listeners.remove(l);
1071 		}
1072 	}
1073 
1074 	public interface ToolBarViewListener
1075 	{
toolbarViewInitialized(ToolBarView tbv)1076 		public void toolbarViewInitialized(ToolBarView tbv);
1077 	}
1078 
1079 	// @see org.gudy.azureus2.ui.swt.pluginsimpl.UIToolBarManagerImpl.ToolBarManagerListener#toolbarItemRemoved(org.gudy.azureus2.plugins.ui.toolbar.UIToolBarItem)
toolbarItemRemoved(final UIToolBarItem toolBarItem)1080 	public void toolbarItemRemoved(final UIToolBarItem toolBarItem) {
1081 		ToolBarItemSO itemSO = mapToolBarItemToSO.get(toolBarItem);
1082 		if (itemSO == null) {
1083 			return;
1084 		}
1085 
1086 		itemSO.dispose();
1087 		final SWTSkinObject so = itemSO.getSO();
1088 		if (so != null) {
1089 			Utils.execSWTThread(new AERunnable() {
1090 				public void runSupport() {
1091 
1092 					String groupID = toolBarItem.getGroupID();
1093 
1094 					final String[] idsByGroup = tbm.getToolBarIDsByGroup(groupID);
1095 
1096 					if (idsByGroup.length <= 1) {
1097 						boolean b = initComplete;
1098 						initComplete = false;
1099 						bulkSetupItems(groupID, "toolbar.area.sitem");
1100 						initComplete = b;
1101 						so.getParent().relayout();
1102 						return;
1103 					}
1104 
1105 					int posToolBarItem = -1;
1106 					String id = toolBarItem.getID();
1107 
1108 
1109 					Control soControl = so.getControl();
1110 
1111 
1112 					SWTSkinObject middleSO = mapToolBarItemToSO.get(
1113 							tbm.getToolBarItem(idsByGroup[idsByGroup.length / 2])).getSO();
1114 
1115 
1116 					SWTSkinObject[] children = ((SWTSkinObjectContainer) so.getParent()).getChildren();
1117 					int middle = -1;
1118 					for (int i = 0; i < children.length; i++) {
1119 						if (children[i] == middleSO) {
1120 							middle = i;
1121 							break;
1122 						}
1123 					}
1124 
1125 					if (middle == -1) {
1126 						return;
1127 					}
1128 
1129 
1130 					children[middle].dispose();
1131 					children[middle + 1].dispose();
1132 
1133 					Control controlLeft = children[middle - 1].getControl();
1134 					FormData fd = (FormData) children[middle + 2].getControl().getLayoutData();
1135 					fd.left.control = controlLeft;
1136 					Utils.relayout(children[middle + 2].getControl());
1137 
1138 					int positionInGroup = 0;
1139 					UIToolBarItem curItem = tbm.getToolBarItem(idsByGroup[positionInGroup]);
1140 
1141 					children = ((SWTSkinObjectContainer) so.getParent()).getChildren();
1142 					for (int i = 0; i < children.length; i++) {
1143 						SWTSkinObject child = children[i];
1144 
1145 						ToolBarItem item = (ToolBarItem) child.getData("toolbaritem");
1146 						if (item != null && item.getGroupID().equals(groupID)) {
1147 
1148 							ToolBarItemSO toolBarItemSO = mapToolBarItemToSO.get(curItem);
1149 							initSO(child, toolBarItemSO);
1150 							positionInGroup++;
1151 							if (positionInGroup >= idsByGroup.length) {
1152 								break;
1153 							}
1154 							curItem = tbm.getToolBarItem(idsByGroup[positionInGroup]);
1155 						}
1156 					}
1157 
1158 					so.getParent().relayout();
1159 				}
1160 			});
1161 		}
1162 		mapToolBarItemToSO.remove(toolBarItem);
1163 	}
1164 
1165 	// @see org.gudy.azureus2.ui.swt.pluginsimpl.UIToolBarManagerImpl.ToolBarManagerListener#toolbarItemAdded(org.gudy.azureus2.plugins.ui.toolbar.UIToolBarItem)
toolbarItemAdded(final UIToolBarItem item)1166 	public void toolbarItemAdded(final UIToolBarItem item) {
1167 		if (isVisible()) {
1168   		if (item instanceof ToolBarItem) {
1169   			ToolBarItem toolBarItem = (ToolBarItem) item;
1170   			toolBarItem.addToolBarItemListener(this);
1171   		}
1172 		}
1173 
1174 		Utils.execSWTThread(new AERunnable() {
1175 			public void runSupport() {
1176 				boolean b = initComplete;
1177 				initComplete = false;
1178 				bulkSetupItems(item.getGroupID(), "toolbar.area.sitem");
1179 				initComplete = b;
1180 
1181 				Utils.execSWTThreadLater(0, new Runnable() {
1182 					public void run() {
1183 						Utils.relayout(soMain.getControl());
1184 					}
1185 				});
1186 			}
1187 		});
1188 	}
1189 
1190 	public abstract class UIToolBarActivationListener_OffSWT
1191 		implements UIToolBarActivationListener
1192 	{
1193 		private long onlyOnActivationType;
1194 
UIToolBarActivationListener_OffSWT(long onlyOnActivationType)1195 		public UIToolBarActivationListener_OffSWT(long onlyOnActivationType) {
1196 			this.onlyOnActivationType = onlyOnActivationType;
1197 		}
1198 
UIToolBarActivationListener_OffSWT()1199 		public UIToolBarActivationListener_OffSWT() {
1200 			onlyOnActivationType = -1;
1201 		}
1202 
toolBarItemActivated(final ToolBarItem item, final long activationType, final Object datasource)1203 		public final boolean toolBarItemActivated(final ToolBarItem item,
1204 				final long activationType, final Object datasource) {
1205 			if (onlyOnActivationType >= 0 && activationType != onlyOnActivationType) {
1206 				return false;
1207 			}
1208 			Utils.getOffOfSWTThread(new AERunnable() {
1209 				@Override
1210 				public void runSupport() {
1211 					toolBarItemActivated_OffSWT(item, activationType, datasource);
1212 				}
1213 			});
1214 			return true;
1215 		}
1216 
toolBarItemActivated_OffSWT(ToolBarItem item, long activationType, Object datasource)1217 		public abstract void toolBarItemActivated_OffSWT(ToolBarItem item,
1218 				long activationType, Object datasource);
1219 	}
1220 }
1221