improved the way the user can customize the add/remove buttons visibility
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 f36cd11..46877e5 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
@@ -8,7 +8,7 @@
* Contributors:
* Anyware Technologies - initial API and implementation
*
- * $Id: EmfMasterDetailBlock.java,v 1.12 2009/08/07 16:25:33 bcabe Exp $
+ * $Id: EmfMasterDetailBlock.java,v 1.13 2009/08/20 17:22:09 bcabe Exp $
*/
package org.eclipse.pde.emfforms.editor;
@@ -45,8 +45,11 @@
public abstract class EmfMasterDetailBlock extends MasterDetailsBlock implements IDetailsPageProvider, IMenuListener {
protected EmfFormEditor<?> parentEditor;
- protected boolean useGenericButton = false;
- protected boolean useGenericSectionToolBar = true;
+
+ public static final int NO_BUTTONS = 0;
+ public static final int USE_GENERIC_TOOLBAR_BUTTONS = 1 << 0;
+ public static final int USE_GENERIC_PUSH_BUTTONS = 1 << 1;
+ protected int buttonOption = USE_GENERIC_TOOLBAR_BUTTONS;
private String title;
private TreeViewer treeViewer;
@@ -61,6 +64,11 @@
this.parentEditor = editor;
}
+ public EmfMasterDetailBlock(EmfFormEditor<?> editor, String title, int buttonOption) {
+ this(editor, title);
+ this.buttonOption = buttonOption;
+ }
+
@Override
protected void createMasterPart(final IManagedForm managedForm, Composite parent) {
FormToolkit toolkit = parentEditor.getToolkit();
@@ -73,13 +81,15 @@
section.marginHeight = 5;
Composite client = toolkit.createComposite(section, SWT.WRAP);
- GridLayoutFactory.fillDefaults().numColumns(useGenericButton ? 2 : 1).applyTo(client);
+ GridLayoutFactory.fillDefaults().numColumns(showPushButtons() ? 2 : 1).applyTo(client);
+ // 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());
treeViewer = ft.getViewer();
//Buttons
- if (useGenericButton) {
+ if (showPushButtons()) {
Composite buttonComposite = new Composite(client, SWT.NONE);
GridLayoutFactory.fillDefaults().numColumns(1).applyTo(buttonComposite);
@@ -96,7 +106,7 @@
removeAction = new RemoveAction(this);
}
- if (useGenericSectionToolBar) {
+ if (showToolbarButtons()) {
toolBarManager = PDEFormToolkit.createSectionToolBarManager(section);
Action addAction = createCustomToolbarAddAction();
if (addAction != null) {
@@ -142,7 +152,7 @@
}
});
- if (useGenericButton) {
+ if (showPushButtons()) {
DataBindingContext bindingContext = new DataBindingContext();
@@ -169,7 +179,7 @@
});
}
- if (useGenericSectionToolBar) {
+ if (showToolbarButtons()) {
//Enable action when the tree selection is not empty
ViewersObservables.observeSingleSelection(getTreeViewer()).addValueChangeListener(new IValueChangeListener() {
@@ -189,6 +199,14 @@
section.setClient(client);
}
+ private boolean showPushButtons() {
+ return (buttonOption & USE_GENERIC_PUSH_BUTTONS) > 0;
+ }
+
+ private boolean showToolbarButtons() {
+ return (buttonOption & USE_GENERIC_TOOLBAR_BUTTONS) > 0;
+ }
+
protected Action createCustomToolbarAddAction() {
// Subclass may override this method
return null;
@@ -285,4 +303,8 @@
return parentEditor;
}
+ public void setButtonOption(int buttonOption) {
+ this.buttonOption = buttonOption;
+ }
+
}