230813: [picasso] - Add .options for controling tooltips and composite padding
https://bugs.eclipse.org/bugs/show_bug.cgi?id=230813
diff --git a/picasso/plugins/org.eclipse.pde.picasso/.options b/picasso/plugins/org.eclipse.pde.picasso/.options
index 424eb5f..f6f4767 100644
--- a/picasso/plugins/org.eclipse.pde.picasso/.options
+++ b/picasso/plugins/org.eclipse.pde.picasso/.options
@@ -1 +1,3 @@
-org.eclipse.pde.picasso/paint=true
\ No newline at end of file
+org.eclipse.pde.picasso/paint=true
+org.eclipse.pde.picasso/paint/extraCompositeMargin=0
+org.eclipse.pde.picasso/paint/toolTip=true
diff --git a/picasso/plugins/org.eclipse.pde.picasso/META-INF/MANIFEST.MF b/picasso/plugins/org.eclipse.pde.picasso/META-INF/MANIFEST.MF
index 8248de5..db66e57 100644
--- a/picasso/plugins/org.eclipse.pde.picasso/META-INF/MANIFEST.MF
+++ b/picasso/plugins/org.eclipse.pde.picasso/META-INF/MANIFEST.MF
@@ -2,6 +2,7 @@
 Bundle-ManifestVersion: 2
 Bundle-Name: %bundleName
 Bundle-SymbolicName: org.eclipse.pde.picasso;singleton:=true
+Bundle-Vendor: %bundleVendor
 Bundle-Version: 1.0.0.qualifier
 Bundle-Activator: org.eclipse.pde.internal.picasso.Activator
 Require-Bundle: org.eclipse.ui;bundle-version="[3.3.0,4.0.0)",
diff --git a/picasso/plugins/org.eclipse.pde.picasso/plugin.properties b/picasso/plugins/org.eclipse.pde.picasso/plugin.properties
index 05ef8d6..4debfd0 100644
--- a/picasso/plugins/org.eclipse.pde.picasso/plugin.properties
+++ b/picasso/plugins/org.eclipse.pde.picasso/plugin.properties
@@ -1,2 +1,3 @@
 #Properties file for org.eclipse.pde.picasso
-bundleName = PDE Picasso
\ No newline at end of file
+bundleName = PDE Picasso (Incubation)
+bundleVendor = Eclipse.org
\ No newline at end of file
diff --git a/picasso/plugins/org.eclipse.pde.picasso/src/org/eclipse/pde/internal/picasso/Activator.java b/picasso/plugins/org.eclipse.pde.picasso/src/org/eclipse/pde/internal/picasso/Activator.java
index 484bb67..9107fc3 100644
--- a/picasso/plugins/org.eclipse.pde.picasso/src/org/eclipse/pde/internal/picasso/Activator.java
+++ b/picasso/plugins/org.eclipse.pde.picasso/src/org/eclipse/pde/internal/picasso/Activator.java
@@ -21,8 +21,10 @@
 public class Activator extends AbstractUIPlugin {
 
 	// The plug-in ID
-	public static final String PLUGIN_ID = "org.eclipse.pde.picasso";
-	public static final String OPTION_ID_PAINT = "paint";
+	public static final String PLUGIN_ID = "org.eclipse.pde.picasso"; //$NON-NLS-1$
+	public static final String OPTION_ID_PAINT = "paint"; //$NON-NLS-1$
+	public static final String OPTION_ID_PAINT_EXTRA_COMPOSITE_MARGIN = "paint/extraCompositeMargin"; //$NON-NLS-1$
+	public static final String OPTION_ID_PAINT_TOOL_TIP = "paint/toolTip"; //$NON-NLS-1$
 
 	// The shared instance
 	private static Activator plugin;
@@ -41,11 +43,18 @@
 		super.start(context);
 		plugin = this;
 		
-		String option = Platform.getDebugOption(PLUGIN_ID + '/' + OPTION_ID_PAINT);
-		if(option != null && option.equalsIgnoreCase("true")) {
-			UIJob job = new ListenerJob(Messages.ListenerJob_name);
-			job.schedule();
-		}
+		String paintOption = getDebugOption(OPTION_ID_PAINT);
+		if (Boolean.parseBoolean(paintOption) == false) return;
+		String paintToolTipOption = getDebugOption(OPTION_ID_PAINT_TOOL_TIP);
+		boolean toolTip = Boolean.parseBoolean(paintToolTipOption);
+		String paintExtraCompositeMarginOption = getDebugOption(OPTION_ID_PAINT_EXTRA_COMPOSITE_MARGIN);
+		int extraCompositeMargin = Integer.parseInt(paintExtraCompositeMarginOption);
+		UIJob job = new ListenerJob(Messages.ListenerJob_name, extraCompositeMargin, toolTip);
+		job.schedule();
+	}
+
+	private String getDebugOption(String option) {
+		return Platform.getDebugOption(PLUGIN_ID + '/' + option);
 	}
 
 	/*
@@ -67,5 +76,4 @@
 	public static Activator getDefault() {
 		return plugin;
 	}
-
 }
diff --git a/picasso/plugins/org.eclipse.pde.picasso/src/org/eclipse/pde/internal/picasso/DebugFilter.java b/picasso/plugins/org.eclipse.pde.picasso/src/org/eclipse/pde/internal/picasso/DebugFilter.java
index 9721062..066465b 100644
--- a/picasso/plugins/org.eclipse.pde.picasso/src/org/eclipse/pde/internal/picasso/DebugFilter.java
+++ b/picasso/plugins/org.eclipse.pde.picasso/src/org/eclipse/pde/internal/picasso/DebugFilter.java
@@ -16,12 +16,19 @@
 import org.eclipse.swt.widgets.Widget;
 
 public class DebugFilter implements Listener {
-
+	private int extraCompositeMargin;
+	private boolean toolTip;
+	
+	public DebugFilter(int extraCompositeMargin, boolean toolTip) {
+		super();
+		this.extraCompositeMargin = extraCompositeMargin;
+		this.toolTip = toolTip;
+	}
+	
 	public void handleEvent(Event event) {
 		Widget widget = event.widget;
-		if(widget instanceof Control) {
-			Painter.decorate((Control) widget);
+		if (widget instanceof Control) {
+			Painter.decorate((Control) widget, extraCompositeMargin, toolTip);
 		}
 	}
-
 }
diff --git a/picasso/plugins/org.eclipse.pde.picasso/src/org/eclipse/pde/internal/picasso/ListenerJob.java b/picasso/plugins/org.eclipse.pde.picasso/src/org/eclipse/pde/internal/picasso/ListenerJob.java
index 0391966..21170d2 100644
--- a/picasso/plugins/org.eclipse.pde.picasso/src/org/eclipse/pde/internal/picasso/ListenerJob.java
+++ b/picasso/plugins/org.eclipse.pde.picasso/src/org/eclipse/pde/internal/picasso/ListenerJob.java
@@ -17,14 +17,17 @@
 import org.eclipse.ui.progress.UIJob;
 
 public class ListenerJob extends UIJob {
-
-	public ListenerJob(String name) {
+	private int extraCompositeMargin;
+	private boolean toolTip;
+	
+	public ListenerJob(String name, int extraCompositeMargin, boolean toolTip) {
 		super(name);
+		this.extraCompositeMargin = extraCompositeMargin;
+		this.toolTip = toolTip;
 	}
 
 	public IStatus runInUIThread(IProgressMonitor monitor) {
-		getDisplay().addFilter(SWT.Show, new DebugFilter());
+		getDisplay().addFilter(SWT.Show, new DebugFilter(extraCompositeMargin, toolTip));
 		return Status.OK_STATUS;
 	}
-
 }
diff --git a/picasso/plugins/org.eclipse.pde.picasso/src/org/eclipse/pde/internal/picasso/Painter.java b/picasso/plugins/org.eclipse.pde.picasso/src/org/eclipse/pde/internal/picasso/Painter.java
index 3f89c19..01de648 100644
--- a/picasso/plugins/org.eclipse.pde.picasso/src/org/eclipse/pde/internal/picasso/Painter.java
+++ b/picasso/plugins/org.eclipse.pde.picasso/src/org/eclipse/pde/internal/picasso/Painter.java
@@ -28,7 +28,7 @@
 import org.eclipse.swt.widgets.Layout;
 
 /**
- * SwtDebugUtility.java
+ * Painter.java
  */
 public final class Painter extends Object {
 	//
@@ -63,16 +63,16 @@
 		buffer.append(Painter.LINE_SEPARATOR);
 		buffer.append("  layout=");  //$NON-NLS-1$
 
-		if (layout instanceof GridLayout) { // $codepro.audit.disable disallowInstanceof
+		if (layout instanceof GridLayout) {
 			GridLayout gridLayout = (GridLayout) layout;
 			Painter.createGridLayoutToolTip(buffer, gridLayout);
-		} else if (layout instanceof FormLayout) { // $codepro.audit.disable disallowInstanceof
+		} else if (layout instanceof FormLayout) {
 			FormLayout formLayout = (FormLayout) layout;
 			Painter.createFormLayoutToolTip(buffer, formLayout);
-		} else if (layout instanceof FillLayout) { // $codepro.audit.disable disallowInstanceof
+		} else if (layout instanceof FillLayout) {
 			FillLayout fillLayout = (FillLayout) layout;
 			Painter.createFillLayoutToolTip(buffer, fillLayout);
-		} else if (layout instanceof RowLayout) { // $codepro.audit.disable disallowInstanceof
+		} else if (layout instanceof RowLayout) {
 			RowLayout rowLayout = (RowLayout) layout;
 			Painter.createRowLayoutToolTip(buffer, rowLayout);
 		} else {
@@ -347,7 +347,10 @@
 		buffer.append("  parent=");  //$NON-NLS-1$
 		Control parent = control.getParent();
 		buffer.append(parent);
-		buffer.append(Painter.getHashCodeText(parent));
+		
+		if (parent != null) {
+			buffer.append(Painter.getHashCodeText(parent));
+		}
 
 		buffer.append(Painter.LINE_SEPARATOR);
 		buffer.append("  border width=");  //$NON-NLS-1$
@@ -367,7 +370,7 @@
 		FontData[] fontData = font.getFontData();
 		buffer.append(fontData [ 0 ]);  // Always just one on Windows.
 
-		if (control instanceof Composite) { // $codepro.audit.disable disallowInstanceof
+		if (control instanceof Composite) {
 			Composite composite = (Composite) control;
 			Painter.createCompositeToolTip(buffer, composite);
 		}
@@ -376,13 +379,13 @@
 		buffer.append(Painter.LINE_SEPARATOR);
 		buffer.append("  layout data=");  //$NON-NLS-1$
 
-		if (layoutData instanceof GridData) { // $codepro.audit.disable disallowInstanceof
+		if (layoutData instanceof GridData) {
 			GridData gridData = (GridData) layoutData;
 			Painter.createGridDataToolTip(buffer, gridData);
-		} else if (layoutData instanceof FormData) { // $codepro.audit.disable disallowInstanceof
+		} else if (layoutData instanceof FormData) {
 			FormData formData = (FormData) layoutData;
 			Painter.createFormDataToolTip(buffer, formData);
-		} else if (layoutData instanceof RowData) { // $codepro.audit.disable disallowInstanceof
+		} else if (layoutData instanceof RowData) {
 			RowData rowData = (RowData) layoutData;
 			Painter.createRowDataToolTip(buffer, rowData);
 		} else {
@@ -402,37 +405,43 @@
 		buffer.append(control.getStyle());
 	}
 
+	
 	public static void decorate(Control control) {
-		Painter.decorate(control, 0);
+		Painter.decorate(control, true);
+	}
+	
+	public static void decorate(Control control, boolean toolTip) {
+		Painter.decorate(control, 0, toolTip);
 	}
 
-	public static void decorate(Control control, int marginWidth) {
+	public static void decorate(Control control, int extraCompositeMargin, boolean toolTip) {
 		if (control == null) throw new IllegalArgumentException("The argument 'control' must not be null");  //$NON-NLS-1$
 		StringBuffer buffer = new StringBuffer(Painter.BUFFER_SIZE);
-		Painter.decorate(buffer, control, marginWidth, 0, 0);
+		Painter.decorate(buffer, control, extraCompositeMargin, 0, 0, toolTip);
 	}
 
-	private static void decorate(StringBuffer buffer, Control control, int marginWidth, int colorIndex, int childIndex) {
+	private static void decorate(StringBuffer buffer, Control control, int extraCompositeMargin, int colorIndex, int childIndex, boolean toolTip) {
 		int count = Painter.COLORS.length;
 		int index = colorIndex == count ? 0 : colorIndex;
 
 		Color color = Painter.COLORS [ index ];
 		control.setBackground(color);
 
-		Painter.createToolTip(buffer, control, childIndex);
-		String tip = Painter.getBufferValue(buffer);
+		if (toolTip == true) {
+			Painter.createToolTip(buffer, control, childIndex);
+			String tip = Painter.getBufferValue(buffer);
+			control.setToolTipText(tip);
+		}
 
-		control.setToolTipText(tip);
-
-		if (control instanceof Composite) { // $codepro.audit.disable disallowInstanceof
+		if (control instanceof Composite) {
 			Composite composite = (Composite) control;
-			Painter.padComposite(composite, marginWidth);
+			Painter.padComposite(composite, extraCompositeMargin);
 			Control[] children = composite.getChildren();
 			Control child;
 
 			for (int i = 0; i < children.length; i++) {
 				child = children [ i ];
-				Painter.decorate(buffer, child, marginWidth, index + 1, i + 1);
+				Painter.decorate(buffer, child, extraCompositeMargin, index + 1, i + 1, toolTip);
 			}
 		}
 	}
@@ -522,26 +531,28 @@
 		return color;
 	}
 
-	private static void padComposite(Composite composite, int marginWidth) {
+	private static void padComposite(Composite composite, int extraCompositeMargin) {
 		Layout compositeLayout = composite.getLayout();
 		if (compositeLayout == null) return;  // Early return.
 
+		if (extraCompositeMargin < 0) return; // Early return.
+		
 		if (compositeLayout instanceof GridLayout) {
 			GridLayout layout = (GridLayout) compositeLayout;
-			layout.marginWidth += marginWidth;
-			layout.marginHeight += marginWidth;
+			layout.marginWidth += extraCompositeMargin;
+			layout.marginHeight += extraCompositeMargin;
 		} else if (compositeLayout instanceof RowLayout) {
 			RowLayout layout = (RowLayout) compositeLayout;
-			layout.marginWidth += marginWidth;
-			layout.marginHeight += marginWidth;
+			layout.marginWidth += extraCompositeMargin;
+			layout.marginHeight += extraCompositeMargin;
 		} else if (compositeLayout instanceof FillLayout) {
 			FillLayout layout = (FillLayout) compositeLayout;
-			layout.marginWidth += marginWidth;
-			layout.marginHeight += marginWidth;
+			layout.marginWidth += extraCompositeMargin;
+			layout.marginHeight += extraCompositeMargin;
 		} else if (compositeLayout instanceof FormLayout) {
 			FormLayout layout = (FormLayout) compositeLayout;
-			layout.marginWidth += marginWidth;
-			layout.marginHeight += marginWidth;
+			layout.marginWidth += extraCompositeMargin;
+			layout.marginHeight += extraCompositeMargin;
 		}
 	}