RESOLVED - bug 308802: [modeling] Let the possibility to add extra options to the Master's TreeViewer
https://bugs.eclipse.org/bugs/show_bug.cgi?id=308802
diff --git a/modeling/plugins/org.eclipse.pde.emfforms/src/org/eclipse/pde/emfforms/editor/EmfMasterDetailBlock.java b/modeling/plugins/org.eclipse.pde.emfforms/src/org/eclipse/pde/emfforms/editor/EmfMasterDetailBlock.java
index f03cf6d..615e325 100644
--- a/modeling/plugins/org.eclipse.pde.emfforms/src/org/eclipse/pde/emfforms/editor/EmfMasterDetailBlock.java
+++ b/modeling/plugins/org.eclipse.pde.emfforms/src/org/eclipse/pde/emfforms/editor/EmfMasterDetailBlock.java
@@ -1,5 +1,5 @@
 /**
- * Copyright (c) 2009 Anyware Technologies and others.
+ * Copyright (c) 2009, 2010 Anyware Technologies and others.
  * All rights reserved. This program and the accompanying materials
  * are made available under the terms of the Eclipse Public License v1.0
  * which accompanies this distribution, and is available at
@@ -7,8 +7,9 @@
  * 
  * Contributors:
  *     Anyware Technologies - initial API and implementation
+ *     Sebastien Moran <SMoran@sierrawireless.com> - bug 308802
  *
- * $Id: EmfMasterDetailBlock.java,v 1.21 2010/01/05 15:45:45 bcabe Exp $
+ * $Id: EmfMasterDetailBlock.java,v 1.22 2010/01/22 16:42:08 bcabe Exp $
  */
 package org.eclipse.pde.emfforms.editor;
 
@@ -39,6 +40,8 @@
 
 public abstract class EmfMasterDetailBlock extends MasterDetailsBlock implements IDetailsPageProvider, IMenuListener {
 
+	public static final int DEFAULT_VIEWER_OPTIONS = SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL;
+
 	protected EmfFormEditor<?> parentEditor;
 
 	/**
@@ -100,7 +103,7 @@
 
 		// deliberate use of the 3.4 API
 		// TODO try to use the new look using a 3.5 fragment
-		FilteredTree ft = new FilteredTree(client, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL, new PatternFilter());
+		FilteredTree ft = new FilteredTree(client, getViewerOptions(), new PatternFilter());
 		treeViewer = ft.getViewer();
 
 		// Prevent scrollbars to be managed by the editor's root composite
@@ -131,7 +134,9 @@
 				toolBarManager.add(addAction);
 			}
 
-			toolBarManager.add(removeAction);
+			if (removeAction != null) {
+				toolBarManager.add(removeAction);
+			}
 			toolBarManager.update(true);
 			section.setTextClient(toolBarManager.getControl());
 		}
@@ -174,7 +179,8 @@
 			//Generic action for remove button
 			getRemoveButton().addSelectionListener(new SelectionAdapter() {
 				public void widgetSelected(SelectionEvent e) {
-					removeAction.run();
+					if (removeAction != null)
+						removeAction.run();
 				}
 			});
 		}
@@ -188,6 +194,15 @@
 	}
 
 	/**
+	 * Default styles : SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL
+	 * 
+	 * @return int, style used to create the TreeViewer
+	 */
+	protected int getViewerOptions() {
+		return DEFAULT_VIEWER_OPTIONS;
+	}
+
+	/**
 	 * Add listeners to manage activation/deactivation of the treeViewer's
 	 * ActionBarContributor's global handlers
 	 */