[183725] Allow header resizing
diff --git a/plugins/org.eclipse.wst.internet.monitor.ui/monitorui/org/eclipse/wst/internet/monitor/ui/internal/custom/MonitorStackLayout.java b/plugins/org.eclipse.wst.internet.monitor.ui/monitorui/org/eclipse/wst/internet/monitor/ui/internal/custom/MonitorStackLayout.java
new file mode 100644
index 0000000..3ce0785
--- /dev/null
+++ b/plugins/org.eclipse.wst.internet.monitor.ui/monitorui/org/eclipse/wst/internet/monitor/ui/internal/custom/MonitorStackLayout.java
@@ -0,0 +1,70 @@
+/*******************************************************************************
+ * Copyright (c) 2007 IBM Corporation 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.internet.monitor.ui.internal.custom;
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.widgets.*;
+/**
+ * This Layout stacks all the controls one on top of the other and resizes all controls
+ * to have the same size and location.
+ * The control specified in topControl is visible and all other controls are not visible.
+ * Users must set the topControl value to flip between the visible items and then call
+ * layout() on the composite which has the MonitorStackLayout.
+ */
+public class MonitorStackLayout extends Layout {
+ /**
+ * topControl the Control that is displayed at the top of the stack.
+ * All other controls that are children of the parent composite will not be visible.
+ */
+ public Control topControl;
+
+ protected Point computeSize(Composite composite, int wHint, int hHint, boolean flushCache) {
+ Control children[] = composite.getChildren();
+ int maxWidth = 0;
+ int maxHeight = 0;
+ for (int i = 0; i < children.length; i++) {
+ if (children[i] == topControl) {
+ Point size = children[i].computeSize(wHint, hHint, flushCache);
+ maxWidth = Math.max(size.x, maxWidth);
+ maxHeight = Math.max(size.y, maxHeight);
+ }
+ }
+ int width = maxWidth;
+ int height = maxHeight;
+ if (wHint != SWT.DEFAULT)
+ width = wHint;
+ if (hHint != SWT.DEFAULT)
+ height = hHint;
+ return new Point(width, height);
+ }
+
+ protected boolean flushCache(Control control) {
+ return true;
+ }
+
+ protected void layout(Composite composite, boolean flushCache) {
+ Control children[] = composite.getChildren();
+ Rectangle rect = composite.getClientArea();
+ for (int i = 0; i < children.length; i++) {
+ if (children[i] instanceof Label) {
+ Rectangle r = new Rectangle(rect.x+2, rect.y, rect.width-2, rect.height);
+ children[i].setBounds(r);
+ } else
+ children[i].setBounds(rect);
+ children[i].setVisible(children[i] == topControl);
+ }
+ }
+
+ public String toString() {
+ return "MonitorStackLayout";
+ }
+}
\ No newline at end of file
diff --git a/plugins/org.eclipse.wst.internet.monitor.ui/monitorui/org/eclipse/wst/internet/monitor/ui/internal/custom/SashForm.java b/plugins/org.eclipse.wst.internet.monitor.ui/monitorui/org/eclipse/wst/internet/monitor/ui/internal/custom/SashForm.java
new file mode 100644
index 0000000..74829e6
--- /dev/null
+++ b/plugins/org.eclipse.wst.internet.monitor.ui/monitorui/org/eclipse/wst/internet/monitor/ui/internal/custom/SashForm.java
@@ -0,0 +1,411 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2007 IBM Corporation 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.internet.monitor.ui.internal.custom;
+
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.widgets.*;
+import org.eclipse.swt.graphics.*;
+
+/**
+ * The SashForm is a composite control that lays out its children in a
+ * row or column arrangement (as specified by the orientation) and places
+ * a Sash between each child. One child may be maximized to occupy the
+ * entire size of the SashForm. The relative sizes of the children may
+ * be specified using weights.
+ * <p>
+ * <dl>
+ * <dt><b>Styles:</b></dt>
+ * <dd>HORIZONTAL, VERTICAL, SMOOTH</dd>
+ * </dl>
+ * </p>
+ */
+public class SashForm extends Composite {
+ public int SASH_WIDTH = 3;
+
+ int sashStyle;
+ Sash[] sashes = new Sash[0];
+ // Remember background and foreground
+ // colors to determine whether to set
+ // sashes to the default color (null) or
+ // a specific color
+ Color background = null;
+ Color foreground = null;
+ Control[] controls = new Control[0];
+ Control maxControl = null;
+ Listener sashListener;
+ static final int DRAG_MINIMUM = 20;
+
+ protected boolean enableSash = false;
+ protected boolean resize;
+
+/**
+ * Constructs a new instance of this class given its parent
+ * and a style value describing its behavior and appearance.
+ * <p>
+ * The style value is either one of the style constants defined in
+ * class <code>SWT</code> which is applicable to instances of this
+ * class, or must be built by <em>bitwise OR</em>'ing together
+ * (that is, using the <code>int</code> "|" operator) two or more
+ * of those <code>SWT</code> style constants. The class description
+ * lists the style constants that are applicable to the class.
+ * Style bits are also inherited from superclasses.
+ * </p>
+ *
+ * @param parent a widget which will be the parent of the new instance (cannot be null)
+ * @param style the style of widget to construct
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ * </ul>
+ *
+ * @see SWT#HORIZONTAL
+ * @see SWT#VERTICAL
+ * @see #getStyle()
+ */
+public SashForm(Composite parent, int style) {
+ super(parent, checkStyle(style));
+ super.setLayout(new SashFormLayout());
+ sashStyle = ((style & SWT.VERTICAL) != 0) ? SWT.HORIZONTAL : SWT.VERTICAL;
+ if ((style & SWT.BORDER) != 0) sashStyle |= SWT.BORDER;
+ if ((style & SWT.SMOOTH) != 0) sashStyle |= SWT.SMOOTH;
+ sashListener = new Listener() {
+ public void handleEvent(Event e) {
+ onDragSash(e);
+ }
+ };
+}
+static int checkStyle (int style) {
+ int mask = SWT.BORDER | SWT.LEFT_TO_RIGHT | SWT.RIGHT_TO_LEFT;
+ return style & mask;
+}
+/**
+ * Returns SWT.HORIZONTAL if the controls in the SashForm are laid out side by side
+ * or SWT.VERTICAL if the controls in the SashForm are laid out top to bottom.
+ *
+ * @return SWT.HORIZONTAL or SWT.VERTICAL
+ */
+public int getOrientation() {
+ //checkWidget();
+ return (sashStyle & SWT.VERTICAL) != 0 ? SWT.HORIZONTAL : SWT.VERTICAL;
+}
+public int getStyle() {
+ int style = super.getStyle();
+ style |= getOrientation() == SWT.VERTICAL ? SWT.VERTICAL : SWT.HORIZONTAL;
+ if ((sashStyle & SWT.SMOOTH) != 0) style |= SWT.SMOOTH;
+ return style;
+}
+/**
+ * Answer the control that currently is maximized in the SashForm.
+ * This value may be null.
+ *
+ * @return the control that currently is maximized or null
+ */
+public Control getMaximizedControl(){
+ //checkWidget();
+ return this.maxControl;
+}
+/**
+ * Answer the relative weight of each child in the SashForm. The weight represents the
+ * percent of the total width (if SashForm has Horizontal orientation) or
+ * total height (if SashForm has Vertical orientation) each control occupies.
+ * The weights are returned in order of the creation of the widgets (weight[0]
+ * corresponds to the weight of the first child created).
+ *
+ * @return the relative weight of each child
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+
+public int[] getWeights() {
+ checkWidget();
+ Control[] cArray = getControls(false);
+ int[] ratios = new int[cArray.length];
+ for (int i = 0; i < cArray.length; i++) {
+ Object data = cArray[i].getLayoutData();
+ if (data != null && data instanceof SashFormData) {
+ ratios[i] = (int)(((SashFormData)data).weight * 1000 >> 16);
+ } else {
+ ratios[i] = 200;
+ }
+ }
+ return ratios;
+}
+Control[] getControls(boolean onlyVisible) {
+ Control[] children = getChildren();
+ Control[] result = new Control[0];
+ for (int i = 0; i < children.length; i++) {
+ if (children[i] instanceof Sash) continue;
+ if (onlyVisible && !children[i].getVisible()) continue;
+
+ Control[] newResult = new Control[result.length + 1];
+ System.arraycopy(result, 0, newResult, 0, result.length);
+ newResult[result.length] = children[i];
+ result = newResult;
+ }
+ return result;
+}
+void onDragSash(Event event) {
+ if (!enableSash)
+ return;
+
+ Sash sash = (Sash)event.widget;
+ int sashIndex = -1;
+ for (int i= 0; i < sashes.length; i++) {
+ if (sashes[i] == sash) {
+ sashIndex = i;
+ break;
+ }
+ }
+ if (sashIndex == -1) return;
+
+ Control c1 = controls[sashIndex];
+ Control c2 = controls[sashIndex + 1];
+ Rectangle b1 = c1.getBounds();
+ Rectangle b2 = c2.getBounds();
+
+ Rectangle sashBounds = sash.getBounds();
+ Rectangle area = getClientArea();
+ boolean correction = false;
+ if (getOrientation() == SWT.HORIZONTAL) {
+ correction = b1.width < DRAG_MINIMUM || b2.width < DRAG_MINIMUM;
+ int totalWidth = b2.x + b2.width - b1.x;
+ int shift = event.x - sashBounds.x;
+ b1.width += shift;
+ b2.x += shift;
+ b2.width -= shift;
+ if (b1.width < DRAG_MINIMUM) {
+ b1.width = DRAG_MINIMUM;
+ b2.x = b1.x + b1.width + sashBounds.width;
+ b2.width = totalWidth - b2.x;
+ event.x = b1.x + b1.width;
+ event.doit = false;
+ }
+ if (b2.width < DRAG_MINIMUM) {
+ b1.width = totalWidth - DRAG_MINIMUM - sashBounds.width;
+ b2.x = b1.x + b1.width + sashBounds.width;
+ b2.width = DRAG_MINIMUM;
+ event.x = b1.x + b1.width;
+ event.doit = false;
+ }
+ Object data1 = c1.getLayoutData();
+ if (data1 == null || !(data1 instanceof SashFormData)) {
+ data1 = new SashFormData();
+ c1.setLayoutData(data1);
+ }
+ Object data2 = c2.getLayoutData();
+ if (data2 == null || !(data2 instanceof SashFormData)) {
+ data2 = new SashFormData();
+ c2.setLayoutData(data2);
+ }
+ ((SashFormData)data1).weight = (((long)b1.width << 16) + area.width - 1) / area.width;
+ ((SashFormData)data2).weight = (((long)b2.width << 16) + area.width - 1) / area.width;
+ } else {
+ correction = b1.height < DRAG_MINIMUM || b2.height < DRAG_MINIMUM;
+ int totalHeight = b2.y + b2.height - b1.y;
+ int shift = event.y - sashBounds.y;
+ b1.height += shift;
+ b2.y += shift;
+ b2.height -= shift;
+ if (b1.height < DRAG_MINIMUM) {
+ b1.height = DRAG_MINIMUM;
+ b2.y = b1.y + b1.height + sashBounds.height;
+ b2.height = totalHeight - b2.y;
+ event.y = b1.y + b1.height;
+ event.doit = false;
+ }
+ if (b2.height < DRAG_MINIMUM) {
+ b1.height = totalHeight - DRAG_MINIMUM - sashBounds.height;
+ b2.y = b1.y + b1.height + sashBounds.height;
+ b2.height = DRAG_MINIMUM;
+ event.y = b1.y + b1.height;
+ event.doit = false;
+ }
+ Object data1 = c1.getLayoutData();
+ if (data1 == null || !(data1 instanceof SashFormData)) {
+ data1 = new SashFormData();
+ c1.setLayoutData(data1);
+ }
+ Object data2 = c2.getLayoutData();
+ if (data2 == null || !(data2 instanceof SashFormData)) {
+ data2 = new SashFormData();
+ c2.setLayoutData(data2);
+ }
+ //((SashFormData)data1).weight = (((long)b1.height << 16) + area.height - 1) / area.height;
+ //((SashFormData)data2).weight = (((long)b2.height << 16) + area.height - 1) / area.height;
+ ((SashFormData)data1).weight = ((200 << 16) + 999) / 1000 * b1.height / b2.height;
+ ((SashFormData)data2).weight = ((200 << 16) + 999) / 1000;
+ }
+ if (correction || (event.doit && event.detail != SWT.DRAG)) {
+ c1.setBounds(b1);
+ sash.setBounds(event.x, event.y, event.width, event.height);
+ c2.setBounds(b2);
+ }
+}
+/**
+ * If orientation is SWT.HORIZONTAL, lay the controls in the SashForm
+ * out side by side. If orientation is SWT.VERTICAL, lay the
+ * controls in the SashForm out top to bottom.
+ *
+ * @param orientation SWT.HORIZONTAL or SWT.VERTICAL
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * <li>ERROR_INVALID_ARGUMENT - if the value of orientation is not SWT.HORIZONTAL or SWT.VERTICAL
+ * </ul>
+ */
+public void setOrientation(int orientation) {
+ checkWidget();
+ if (getOrientation() == orientation) return;
+ if (orientation != SWT.HORIZONTAL && orientation != SWT.VERTICAL) {
+ SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ }
+ sashStyle &= ~(SWT.HORIZONTAL | SWT.VERTICAL);
+ sashStyle |= orientation == SWT.VERTICAL ? SWT.HORIZONTAL : SWT.VERTICAL;
+ for (int i = 0; i < sashes.length; i++) {
+ sashes[i].dispose();
+ sashes[i] = new Sash(this, sashStyle);
+ sashes[i].setBackground(background);
+ sashes[i].setForeground(foreground);
+ sashes[i].addListener(SWT.Selection, sashListener);
+ }
+ layout(false);
+}
+public void setBackground (Color color) {
+ super.setBackground(color);
+ background = color;
+ for (int i = 0; i < sashes.length; i++) {
+ sashes[i].setBackground(background);
+ }
+}
+public void setForeground (Color color) {
+ super.setForeground(color);
+ foreground = color;
+ for (int i = 0; i < sashes.length; i++) {
+ sashes[i].setForeground(foreground);
+ }
+}
+/**
+ * Sets the layout which is associated with the receiver to be
+ * the argument which may be null.
+ * <p>
+ * Note: No Layout can be set on this Control because it already
+ * manages the size and position of its children.
+ * </p>
+ *
+ * @param layout the receiver's new layout or null
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setLayout (Layout layout) {
+ checkWidget();
+ return;
+}
+/**
+ * Specify the control that should take up the entire client area of the SashForm.
+ * If one control has been maximized, and this method is called with a different control,
+ * the previous control will be minimized and the new control will be maximized.
+ * If the value of control is null, the SashForm will minimize all controls and return to
+ * the default layout where all controls are laid out separated by sashes.
+ *
+ * @param control the control to be maximized or null
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setMaximizedControl(Control control){
+ checkWidget();
+ if (control == null) {
+ if (maxControl != null) {
+ this.maxControl = null;
+ layout(false);
+ for (int i= 0; i < sashes.length; i++){
+ sashes[i].setVisible(true);
+ }
+ }
+ return;
+ }
+
+ for (int i= 0; i < sashes.length; i++){
+ sashes[i].setVisible(false);
+ }
+ maxControl = control;
+ layout(false);
+}
+
+/**
+ * Specify the relative weight of each child in the SashForm. This will determine
+ * what percent of the total width (if SashForm has Horizontal orientation) or
+ * total height (if SashForm has Vertical orientation) each control will occupy.
+ * The weights must be positive values and there must be an entry for each
+ * non-sash child of the SashForm.
+ *
+ * @param weights the relative weight of each child
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * <li>ERROR_INVALID_ARGUMENT - if the weights value is null or of incorrect length (must match the number of children)</li>
+ * </ul>
+ */
+public void setWeights(int[] weights) {
+ checkWidget();
+ Control[] cArray = getControls(false);
+ if (weights == null || weights.length != cArray.length) {
+ SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ }
+
+ int total = 0;
+ for (int i = 0; i < weights.length; i++) {
+ if (weights[i] < 0) {
+ SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ }
+ total += weights[i];
+ }
+ if (total == 0) {
+ SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ }
+ for (int i = 0; i < cArray.length; i++) {
+ Object data = cArray[i].getLayoutData();
+ if (data == null || !(data instanceof SashFormData)) {
+ data = new SashFormData();
+ cArray[i].setLayoutData(data);
+ }
+ ((SashFormData)data).weight = (((long)weights[i] << 16) + total - 1) / total;
+ }
+
+ layout(false);
+}
+
+public void setSimpleLayout(boolean b) {
+ Control[] cArray = getControls(false);
+ if (cArray == null || cArray.length != 2)
+ return;
+ enableSash = b;
+ SashFormLayout layout = (SashFormLayout) getLayout();
+ layout.simple = !enableSash;
+
+ if (enableSash)
+ resize = true;
+}
+}
\ No newline at end of file
diff --git a/plugins/org.eclipse.wst.internet.monitor.ui/monitorui/org/eclipse/wst/internet/monitor/ui/internal/custom/SashFormData.java b/plugins/org.eclipse.wst.internet.monitor.ui/monitorui/org/eclipse/wst/internet/monitor/ui/internal/custom/SashFormData.java
new file mode 100644
index 0000000..48ba237
--- /dev/null
+++ b/plugins/org.eclipse.wst.internet.monitor.ui/monitorui/org/eclipse/wst/internet/monitor/ui/internal/custom/SashFormData.java
@@ -0,0 +1,33 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2007 IBM Corporation 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.internet.monitor.ui.internal.custom;
+
+class SashFormData {
+
+ long weight;
+
+String getName () {
+ String string = getClass ().getName ();
+ int index = string.lastIndexOf ('.');
+ if (index == -1) return string;
+ return string.substring (index + 1, string.length ());
+}
+
+/**
+ * Returns a string containing a concise, human-readable
+ * description of the receiver.
+ *
+ * @return a string representation of the event
+ */
+public String toString () {
+ return getName()+" {weight="+weight+"}"; //$NON-NLS-2$
+}
+}
diff --git a/plugins/org.eclipse.wst.internet.monitor.ui/monitorui/org/eclipse/wst/internet/monitor/ui/internal/custom/SashFormLayout.java b/plugins/org.eclipse.wst.internet.monitor.ui/monitorui/org/eclipse/wst/internet/monitor/ui/internal/custom/SashFormLayout.java
new file mode 100644
index 0000000..201b876
--- /dev/null
+++ b/plugins/org.eclipse.wst.internet.monitor.ui/monitorui/org/eclipse/wst/internet/monitor/ui/internal/custom/SashFormLayout.java
@@ -0,0 +1,243 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2007 IBM Corporation 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.internet.monitor.ui.internal.custom;
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.widgets.*;
+
+/**
+ * This class provides the layout for SashForm
+ *
+ * @see SashForm
+ */
+class SashFormLayout extends Layout {
+ protected boolean simple;
+
+protected Point computeSize(Composite composite, int wHint, int hHint, boolean flushCache) {
+ SashForm sashForm = (SashForm)composite;
+ Control[] cArray = sashForm.getControls(true);
+ int width = 0;
+ int height = 0;
+ if (cArray.length == 0) {
+ if (wHint != SWT.DEFAULT) width = wHint;
+ if (hHint != SWT.DEFAULT) height = hHint;
+ return new Point(width, height);
+ }
+ // determine control sizes
+ boolean vertical = sashForm.getOrientation() == SWT.VERTICAL;
+ int maxIndex = 0;
+ int maxValue = 0;
+ Point[] sizes = new Point[cArray.length];
+ for (int i = 0; i < cArray.length; i++) {
+ if (vertical) {
+ sizes[i] = cArray[i].computeSize(wHint, SWT.DEFAULT, flushCache);
+ if (sizes[i].y > maxValue) {
+ maxIndex = i;
+ maxValue = sizes[i].y;
+ }
+ width = Math.max(width, sizes[i].x);
+ } else {
+ sizes[i] = cArray[i].computeSize(SWT.DEFAULT, hHint, flushCache);
+ if (sizes[i].x > maxValue) {
+ maxIndex = i;
+ maxValue = sizes[i].x;
+ }
+ height = Math.max(height, sizes[i].y);
+ }
+ }
+ // get the ratios
+ long[] ratios = new long[cArray.length];
+ long total = 0;
+ for (int i = 0; i < cArray.length; i++) {
+ Object data = cArray[i].getLayoutData();
+ if (data != null && data instanceof SashFormData) {
+ ratios[i] = ((SashFormData)data).weight;
+ } else {
+ data = new SashFormData();
+ cArray[i].setLayoutData(data);
+ ((SashFormData)data).weight = ratios[i] = ((200 << 16) + 999) / 1000;
+
+ }
+ total += ratios[i];
+ }
+ if (ratios[maxIndex] > 0) {
+ int sashwidth = sashForm.sashes.length > 0 ? sashForm.SASH_WIDTH + sashForm.sashes [0].getBorderWidth() * 2 : sashForm.SASH_WIDTH;
+ if (vertical) {
+ height += (int)(total * maxValue / ratios[maxIndex]) + (cArray.length - 1) * sashwidth;
+ } else {
+ width += (int)(total * maxValue / ratios[maxIndex]) + (cArray.length - 1) * sashwidth;
+ }
+ }
+ width += sashForm.getBorderWidth()*2;
+ height += sashForm.getBorderWidth()*2;
+ if (wHint != SWT.DEFAULT) width = wHint;
+ if (hHint != SWT.DEFAULT) height = hHint;
+ return new Point(width, height);
+}
+
+protected boolean flushCache(Control control) {
+ return true;
+}
+
+protected void layout(Composite composite, boolean flushCache) {
+ SashForm sashForm = (SashForm)composite;
+ Rectangle area = sashForm.getClientArea();
+ if (area.width <= 1 || area.height <= 1) return;
+
+ Control[] newControls = sashForm.getControls(true);
+ if (sashForm.controls.length == 0 && newControls.length == 0)
+ return;
+ sashForm.controls = newControls;
+
+ Control[] controls = sashForm.controls;
+
+ if (sashForm.maxControl != null && !sashForm.maxControl.isDisposed()) {
+ for (int i= 0; i < controls.length; i++){
+ if (controls[i] != sashForm.maxControl) {
+ controls[i].setBounds(-200, -200, 0, 0);
+ } else {
+ controls[i].setBounds(area);
+ }
+ }
+ return;
+ }
+
+ // simple layout
+ if (simple) {
+ // hide sashes
+ for (int i = 0; i < sashForm.sashes.length; i++) {
+ sashForm.sashes[i].setEnabled(false);
+ sashForm.sashes[i].setVisible(false);
+ }
+
+ Point p = controls[0].computeSize(SWT.DEFAULT, SWT.DEFAULT, true);
+ controls[0].setBounds(0, 0, area.width, p.y);
+ controls[1].setBounds(0, p.y + 2, area.width, area.height - p.y - 2);
+
+ return;
+ }
+
+ // keep just the right number of sashes
+ if (sashForm.sashes.length < controls.length - 1) {
+ Sash[] newSashes = new Sash[controls.length - 1];
+ System.arraycopy(sashForm.sashes, 0, newSashes, 0, sashForm.sashes.length);
+ for (int i = sashForm.sashes.length; i < newSashes.length; i++) {
+ newSashes[i] = new Sash(sashForm, sashForm.sashStyle);
+ newSashes[i].setBackground(sashForm.background);
+ newSashes[i].setForeground(sashForm.foreground);
+ newSashes[i].addListener(SWT.Selection, sashForm.sashListener);
+ }
+ sashForm.sashes = newSashes;
+ }
+ if (sashForm.sashes.length > controls.length - 1) {
+ if (controls.length == 0) {
+ for (int i = 0; i < sashForm.sashes.length; i++) {
+ sashForm.sashes[i].dispose();
+ }
+ sashForm.sashes = new Sash[0];
+ } else {
+ Sash[] newSashes = new Sash[controls.length - 1];
+ System.arraycopy(sashForm.sashes, 0, newSashes, 0, newSashes.length);
+ for (int i = controls.length - 1; i < sashForm.sashes.length; i++) {
+ sashForm.sashes[i].dispose();
+ }
+ sashForm.sashes = newSashes;
+ }
+ }
+ if (controls.length == 0) return;
+ Sash[] sashes = sashForm.sashes;
+
+ for (int i = 0; i < sashForm.sashes.length; i++) {
+ sashes[i].setEnabled(true);
+ sashes[i].setVisible(true);
+ }
+
+ if (sashForm.resize) {
+ Control c1 = controls[0];
+ Control c2 = controls[1];
+
+ int h1 = c1.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).y * 2;
+ int h2 = area.height - h1 - sashes[0].getBounds().height;
+
+ Object data1 = c1.getLayoutData();
+ if (data1 == null || !(data1 instanceof SashFormData)) {
+ data1 = new SashFormData();
+ c1.setLayoutData(data1);
+ }
+ Object data2 = c2.getLayoutData();
+ if (data2 == null || !(data2 instanceof SashFormData)) {
+ data2 = new SashFormData();
+ c2.setLayoutData(data2);
+ }
+ //((SashFormData)data1).weight = (((long)h1 << 16) + area.height - 1) / area.height;
+ //((SashFormData)data2).weight = (((long)h2 << 16) + area.height - 1) / area.height;
+ ((SashFormData)data1).weight = ((200 << 16) + 999) / 1000 * h1 / h2;
+ ((SashFormData)data2).weight = ((200 << 16) + 999) / 1000;
+ sashForm.resize = false;
+ }
+
+ // get the ratios
+ long[] ratios = new long[controls.length];
+ long total = 0;
+ for (int i = 0; i < controls.length; i++) {
+ Object data = controls[i].getLayoutData();
+ if (data != null && data instanceof SashFormData) {
+ ratios[i] = ((SashFormData)data).weight;
+ } else {
+ data = new SashFormData();
+ controls[i].setLayoutData(data);
+ ((SashFormData)data).weight = ratios[i] = ((200 << 16) + 999) / 1000;
+ }
+ total += ratios[i];
+ }
+
+ int sashwidth = sashes.length > 0 ? sashForm.SASH_WIDTH + sashes [0].getBorderWidth() * 2 : sashForm.SASH_WIDTH;
+ if (sashForm.getOrientation() == SWT.HORIZONTAL) {
+ int width = (int)(ratios[0] * (area.width - sashes.length * sashwidth) / total);
+ int x = area.x;
+ controls[0].setBounds(x, area.y, width, area.height);
+ x += width;
+ for (int i = 1; i < controls.length - 1; i++) {
+ sashes[i - 1].setBounds(x, area.y, sashwidth, area.height);
+ x += sashwidth;
+ width = (int)(ratios[i] * (area.width - sashes.length * sashwidth) / total);
+ controls[i].setBounds(x, area.y, width, area.height);
+ x += width;
+ }
+ if (controls.length > 1) {
+ sashes[sashes.length - 1].setBounds(x, area.y, sashwidth, area.height);
+ x += sashwidth;
+ width = area.width - x;
+ controls[controls.length - 1].setBounds(x, area.y, width, area.height);
+ }
+ } else {
+ int height = (int)(ratios[0] * (area.height - sashes.length * sashwidth) / total);
+ int y = area.y;
+ controls[0].setBounds(area.x, y, area.width, height);
+ y += height;
+ for (int i = 1; i < controls.length - 1; i++) {
+ sashes[i - 1].setBounds(area.x, y, area.width, sashwidth);
+ y += sashwidth;
+ height = (int)(ratios[i] * (area.height - sashes.length * sashwidth) / total);
+ controls[i].setBounds(area.x, y, area.width, height);
+ y += height;
+ }
+ if (controls.length > 1) {
+ sashes[sashes.length - 1].setBounds(area.x, y, area.width, sashwidth);
+ y += sashwidth;
+ height = area.height - y;
+ controls[controls.length - 1].setBounds(area.x, y, area.width, height);
+ }
+
+ }
+}
+}
\ No newline at end of file
diff --git a/plugins/org.eclipse.wst.internet.monitor.ui/monitorui/org/eclipse/wst/internet/monitor/ui/internal/view/MonitorView.java b/plugins/org.eclipse.wst.internet.monitor.ui/monitorui/org/eclipse/wst/internet/monitor/ui/internal/view/MonitorView.java
index 078e699..e24ed55 100644
--- a/plugins/org.eclipse.wst.internet.monitor.ui/monitorui/org/eclipse/wst/internet/monitor/ui/internal/view/MonitorView.java
+++ b/plugins/org.eclipse.wst.internet.monitor.ui/monitorui/org/eclipse/wst/internet/monitor/ui/internal/view/MonitorView.java
@@ -180,39 +180,40 @@
final Label label2 = new Label(detailsPanel, SWT.NONE);
label2.setText(NLS.bind(Messages.viewResponseTime, ""));
label2.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_BEGINNING));
-
+
final Label label3 = new Label(detailsPanel, SWT.NONE);
label3.setText(NLS.bind(Messages.viewType, ""));
label3.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_BEGINNING));
-
+
// create center and right panels
- SashForm sashFchild = new SashForm(sashFparent, SWT.NONE);
+ SashForm sashFchild = new SashForm(sashFparent, SWT.HORIZONTAL);
layout = new GridLayout();
layout.numColumns = 2;
layout.horizontalSpacing = 2;
layout.verticalSpacing = 4;
sashFchild.setLayout(layout);
sashFparent.setWeights(new int[] { 30, 70 });
-
+
// request panel
Composite request = new Composite(sashFchild, SWT.NONE);
layout = new GridLayout();
layout.verticalSpacing = 3;
- layout.marginHeight = 2;
+ layout.marginHeight = 0;
layout.marginWidth = 0;
request.setLayout(layout);
request.setLayoutData(new GridData(GridData.FILL_BOTH));
-
+
Composite requestHeader = new Composite(request, SWT.NONE);
layout = new GridLayout();
layout.verticalSpacing = 1;
layout.numColumns = 2;
layout.marginHeight = 0;
- layout.marginWidth = 2;
+ layout.marginWidth = 0;
+ layout.marginLeft = 2;
data = new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_BEGINNING);
requestHeader.setLayout(layout);
requestHeader.setLayoutData(data);
-
+
final Label requestLabel = new Label(requestHeader, SWT.NONE);
requestLabel.setText(NLS.bind(Messages.viewRequest, ""));
requestLabel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
@@ -221,16 +222,16 @@
data = new GridData(GridData.HORIZONTAL_ALIGN_END);
data.verticalSpan = 2;
requestViewerCombo.setLayoutData(data);
-
+
final Label requestSizeLabel = new Label(requestHeader, SWT.NONE);
requestSizeLabel.setText(NLS.bind(Messages.viewSize, ""));
requestSizeLabel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
-
+
// response panel
Composite response = new Composite(sashFchild, SWT.NONE);
layout = new GridLayout();
layout.verticalSpacing = 3;
- layout.marginHeight = 2;
+ layout.marginHeight = 0;
layout.marginWidth = 0;
response.setLayout(layout);
response.setLayoutData(new GridData(GridData.FILL_BOTH));
@@ -240,11 +241,12 @@
layout.verticalSpacing = 1;
layout.numColumns = 2;
layout.marginHeight = 0;
- layout.marginWidth = 2;
+ layout.marginWidth = 0;
+ layout.marginLeft = 2;
data = new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_BEGINNING);
responseHeader.setLayout(layout);
responseHeader.setLayoutData(data);
-
+
final Label responseLabel = new Label(responseHeader, SWT.NONE);
responseLabel.setText(NLS.bind(Messages.viewResponse, ""));
responseLabel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
@@ -253,16 +255,16 @@
data = new GridData(GridData.HORIZONTAL_ALIGN_END);
data.verticalSpan = 2;
responseViewerCombo.setLayoutData(data);
-
+
final Label responseSizeLabel = new Label(responseHeader, SWT.NONE);
responseSizeLabel.setText(NLS.bind(Messages.viewSize, ""));
responseSizeLabel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
-
+
// viewer manager
- vm = new ViewerManager(request, request, response, response);
+ vm = new ViewerManager(request, response);
requestViewers = vm.getRequestViewers();
responseViewers = vm.getResponseViewers();
-
+
// set up the viewer combo boxes
Iterator iterator = requestViewers.iterator();
int ctr = 0;
diff --git a/plugins/org.eclipse.wst.internet.monitor.ui/monitorui/org/eclipse/wst/internet/monitor/ui/internal/view/ViewerManager.java b/plugins/org.eclipse.wst.internet.monitor.ui/monitorui/org/eclipse/wst/internet/monitor/ui/internal/view/ViewerManager.java
index 5e5fa0d..49f5bf2 100644
--- a/plugins/org.eclipse.wst.internet.monitor.ui/monitorui/org/eclipse/wst/internet/monitor/ui/internal/view/ViewerManager.java
+++ b/plugins/org.eclipse.wst.internet.monitor.ui/monitorui/org/eclipse/wst/internet/monitor/ui/internal/view/ViewerManager.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2003, 2005 IBM Corporation and others.
+ * Copyright (c) 2003, 2007 IBM Corporation 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
@@ -14,12 +14,16 @@
import java.util.Iterator;
import java.util.List;
import org.eclipse.core.runtime.*;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.wst.internet.monitor.core.internal.IContentFilter;
import org.eclipse.wst.internet.monitor.core.internal.http.ResendHTTPRequest;
import org.eclipse.wst.internet.monitor.core.internal.provisional.Request;
import org.eclipse.wst.internet.monitor.ui.internal.MonitorUIPlugin;
import org.eclipse.wst.internet.monitor.ui.internal.Trace;
+import org.eclipse.wst.internet.monitor.ui.internal.custom.SashForm;
import org.eclipse.wst.internet.monitor.ui.internal.provisional.ContentViewer;
import org.eclipse.wst.internet.monitor.ui.internal.viewers.ByteViewer;
import org.eclipse.wst.internet.monitor.ui.internal.viewers.HeaderViewer;
@@ -37,33 +41,54 @@
protected HeaderViewer reqHeader;
protected HeaderViewer respHeader;
- protected Composite reqHComp;
- protected Composite reqVComp;
-
- protected Composite respHComp;
- protected Composite respVComp;
+ protected Composite reqComp;
+ protected Composite respComp;
protected List viewers;
protected Request request;
+ protected SashForm reqSash;
+ protected SashForm respSash;
+
protected List filters = new ArrayList();
- public ViewerManager(Composite reqHeadParent, Composite reqViewParent, Composite respHeadParent, Composite respViewParent) {
- reqHComp = reqHeadParent;
- respHComp = respHeadParent;
- reqVComp = reqViewParent;
- respVComp = respViewParent;
- reqHeader = new HeaderViewer(reqHComp, HeaderViewer.REQUEST_HEADER);
- respHeader = new HeaderViewer(respHComp, HeaderViewer.RESPONSE_HEADER);
+ public ViewerManager(Composite reqParent, Composite respParent) {
+ reqSash = new SashForm(reqParent, SWT.VERTICAL);
+ GridLayout layout = new GridLayout();
+ layout.numColumns = 1;
+ layout.horizontalSpacing = 0;
+ layout.verticalSpacing = 0;
+ layout.marginWidth = 0;
+ reqSash.setLayout(layout);
+ reqSash.setLayoutData(new GridData(GridData.FILL_BOTH));
+
+ respSash = new SashForm(respParent, SWT.VERTICAL);
+ layout = new GridLayout();
+ layout.numColumns = 1;
+ layout.horizontalSpacing = 0;
+ layout.verticalSpacing = 0;
+ layout.marginWidth = 0;
+ respSash.setLayout(layout);
+ respSash.setLayoutData(new GridData(GridData.FILL_BOTH));
+
+ reqComp = reqSash;
+ respComp = respSash;
+
+ reqHeader = new HeaderViewer(reqSash, HeaderViewer.REQUEST_HEADER);
+ respHeader = new HeaderViewer(respSash, HeaderViewer.RESPONSE_HEADER);
reqViewer = new ByteViewer();
- reqViewer.init(reqVComp);
+ reqViewer.init(reqSash);
respViewer = new ByteViewer();
- respViewer.init(respVComp);
+ respViewer.init(respSash);
+
+ reqSash.setWeights(new int[] { 10, 90 });
+ respSash.setWeights(new int[] { 10, 90 });
+
setDisplayHeaderInfo(MonitorUIPlugin.getShowHeaderPreference());
loadAvailableViewers();
}
-
+
protected Viewer getDefaultViewer(String name) {
if (name == null)
return null;
@@ -110,6 +135,11 @@
displayHeaderInf = b;
reqHeader.setDisplayHeader(b);
respHeader.setDisplayHeader(b);
+ reqSash.setSimpleLayout(b);
+ respSash.setSimpleLayout(b);
+ reqSash.layout(true);
+ respSash.layout(true);
+
MonitorUIPlugin.setShowHeaderPreference(b);
if (b) {
reqHeader.setEditable(false);
@@ -228,7 +258,7 @@
public void setRequestViewer(Viewer viewer) {
if (viewer != null && viewer.equals(requestViewer))
return;
-
+
// call set request to save and reset the request
setRequest(request);
reqViewer.dispose();
@@ -238,7 +268,7 @@
if (reqViewer == null)
return;
- reqViewer.init(reqVComp);
+ reqViewer.init(reqComp);
//reqViewer.setRequestResponse(rr);
byte[] b = null;
if (request != null) {
@@ -252,7 +282,7 @@
}
}
reqViewer.setContent(b);
- reqVComp.layout(true);
+ reqComp.layout(true);
}
/* (non-Javadoc)
@@ -267,13 +297,13 @@
respViewer = viewer.createViewer();
if (respViewer == null)
return;
- respViewer.init(respVComp);
+ respViewer.init(respComp);
//respViewer.setRequestResponse(rr);
byte[] b = null;
if (request != null)
b = filter(request.getResponse(Request.CONTENT));
respViewer.setContent(b);
- respVComp.layout(true);
+ respComp.layout(true);
}
/* (non-Javadoc)
diff --git a/plugins/org.eclipse.wst.internet.monitor.ui/monitorui/org/eclipse/wst/internet/monitor/ui/internal/viewers/BrowserViewer.java b/plugins/org.eclipse.wst.internet.monitor.ui/monitorui/org/eclipse/wst/internet/monitor/ui/internal/viewers/BrowserViewer.java
index e6dcfb5..08f1d4f 100644
--- a/plugins/org.eclipse.wst.internet.monitor.ui/monitorui/org/eclipse/wst/internet/monitor/ui/internal/viewers/BrowserViewer.java
+++ b/plugins/org.eclipse.wst.internet.monitor.ui/monitorui/org/eclipse/wst/internet/monitor/ui/internal/viewers/BrowserViewer.java
@@ -12,7 +12,6 @@
import org.eclipse.swt.SWT;
import org.eclipse.swt.browser.Browser;
-import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.wst.internet.monitor.ui.internal.Messages;
import org.eclipse.wst.internet.monitor.ui.internal.MonitorUIPlugin;
@@ -33,7 +32,6 @@
*/
public void init(Composite parent) {
browser = new Browser(parent, SWT.BORDER);
- browser.setLayoutData(new GridData(GridData.FILL_BOTH));
}
/** (non-Javadoc)
diff --git a/plugins/org.eclipse.wst.internet.monitor.ui/monitorui/org/eclipse/wst/internet/monitor/ui/internal/viewers/ByteViewer.java b/plugins/org.eclipse.wst.internet.monitor.ui/monitorui/org/eclipse/wst/internet/monitor/ui/internal/viewers/ByteViewer.java
index 46f25a4..7ee3193 100644
--- a/plugins/org.eclipse.wst.internet.monitor.ui/monitorui/org/eclipse/wst/internet/monitor/ui/internal/viewers/ByteViewer.java
+++ b/plugins/org.eclipse.wst.internet.monitor.ui/monitorui/org/eclipse/wst/internet/monitor/ui/internal/viewers/ByteViewer.java
@@ -12,7 +12,6 @@
import org.eclipse.jface.resource.JFaceResources;
import org.eclipse.swt.SWT;
-import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Text;
@@ -34,7 +33,6 @@
Display display = parent.getDisplay();
text.setBackground(display.getSystemColor(SWT.COLOR_LIST_BACKGROUND));
text.setForeground(display.getSystemColor(SWT.COLOR_LIST_FOREGROUND));
- text.setLayoutData(new GridData(GridData.FILL_BOTH));
text.setFont(JFaceResources.getTextFont());
PlatformUI.getWorkbench().getHelpSystem().setHelp(text, ContextIds.VIEW_RESPONSE);
}
diff --git a/plugins/org.eclipse.wst.internet.monitor.ui/monitorui/org/eclipse/wst/internet/monitor/ui/internal/viewers/HeaderViewer.java b/plugins/org.eclipse.wst.internet.monitor.ui/monitorui/org/eclipse/wst/internet/monitor/ui/internal/viewers/HeaderViewer.java
index 9edfbc1..ec4f4cf 100644
--- a/plugins/org.eclipse.wst.internet.monitor.ui/monitorui/org/eclipse/wst/internet/monitor/ui/internal/viewers/HeaderViewer.java
+++ b/plugins/org.eclipse.wst.internet.monitor.ui/monitorui/org/eclipse/wst/internet/monitor/ui/internal/viewers/HeaderViewer.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2003, 2005 IBM Corporation and others.
+ * Copyright (c) 2003, 2007 IBM Corporation 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
@@ -13,8 +13,6 @@
import org.eclipse.jface.resource.JFaceResources;
import org.eclipse.osgi.util.NLS;
import org.eclipse.swt.SWT;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Label;
@@ -24,26 +22,23 @@
import org.eclipse.wst.internet.monitor.ui.internal.ContextIds;
import org.eclipse.wst.internet.monitor.ui.internal.Messages;
import org.eclipse.wst.internet.monitor.ui.internal.MonitorUIPlugin;
+import org.eclipse.wst.internet.monitor.ui.internal.custom.MonitorStackLayout;
/**
* An transport (header) viewer.
*/
public class HeaderViewer {
- private static final int HEADER_TEXT_SIZE = 110;
-
protected boolean displayHeader;
protected Composite headerComp;
- protected Composite innerComp;
+ protected MonitorStackLayout layout;
protected Label headerLabel;
protected Text headerText;
protected Request rr;
protected byte msg;
- protected GridLayout layout;
- protected GridData data;
protected boolean hidden;
-
+
/**
* Request header constant.
*/
@@ -65,29 +60,26 @@
hidden = false;
headerComp = new Composite(parent, SWT.NONE);
- layout = new GridLayout();
- layout.numColumns = 1;
- layout.marginHeight = 0;
- layout.marginWidth = 0;
+ layout = new MonitorStackLayout();
headerComp.setLayout(layout);
- data = new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_BEGINNING);
- headerComp.setLayoutData(data);
-
- innerComp = new Composite(headerComp, SWT.NONE);
- layout = new GridLayout();
- layout.numColumns = 1;
- layout.marginHeight = 0;
- layout.marginWidth = 2;
- innerComp.setLayout(layout);
- data = new GridData(GridData.FILL_BOTH);
- innerComp.setLayoutData(data);
-
+
+ headerText = new Text(headerComp, SWT.BORDER | SWT.MULTI | SWT.READ_ONLY | SWT.H_SCROLL | SWT.V_SCROLL);
+ Display display = headerComp.getDisplay();
+ headerText.setBackground(display.getSystemColor(SWT.COLOR_LIST_BACKGROUND));
+ headerText.setForeground(display.getSystemColor(SWT.COLOR_LIST_FOREGROUND));
+ headerText.setFont(JFaceResources.getTextFont());
+ PlatformUI.getWorkbench().getHelpSystem().setHelp(headerText, ContextIds.VIEW_RESPONSE);
+
+ headerLabel = new Label(headerComp, SWT.NONE);
+
+ layout.topControl = headerText;
+
rr = null;
msg = message;
setDisplayHeader(false);
}
-
+
/**
*
* @param request
@@ -105,54 +97,15 @@
public void setDisplayHeader(boolean b) {
if (displayHeader != b) {
displayHeader = b;
- if (displayHeader) {
- innerComp.dispose();
-
- data = new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_BEGINNING);
- data.heightHint = HEADER_TEXT_SIZE;
- headerComp.setLayoutData(data);
-
- innerComp = new Composite(headerComp, SWT.NONE);
- layout = new GridLayout();
- layout.numColumns = 1;
- layout.marginHeight = 0;
- layout.marginWidth = 0;
- innerComp.setLayout(layout);
- data = new GridData(GridData.FILL_BOTH);
- data.heightHint = HEADER_TEXT_SIZE;
- innerComp.setLayoutData(data);
-
- headerText = new Text(innerComp, SWT.BORDER | SWT.MULTI | SWT.READ_ONLY | SWT.H_SCROLL | SWT.V_SCROLL);
- Display display = innerComp.getDisplay();
- headerText.setBackground(display.getSystemColor(SWT.COLOR_LIST_BACKGROUND));
- headerText.setForeground(display.getSystemColor(SWT.COLOR_LIST_FOREGROUND));
- headerText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.FILL_VERTICAL));
- headerText.setFont(JFaceResources.getTextFont());
- PlatformUI.getWorkbench().getHelpSystem().setHelp(headerText, ContextIds.VIEW_RESPONSE);
-
- headerComp.getParent().layout(true);
- } else {
- innerComp.dispose();
-
- data = new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_BEGINNING);
- headerComp.setLayoutData(data);
-
- innerComp = new Composite(headerComp, SWT.NONE);
- layout = new GridLayout();
- layout.numColumns = 1;
- layout.marginHeight = 0;
- layout.marginWidth = 2;
- innerComp.setLayout(layout);
- data = new GridData(GridData.FILL_BOTH);
- innerComp.setLayoutData(data);
-
- headerLabel = new Label(innerComp, SWT.NONE);
- headerLabel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_BEGINNING));
-
- headerComp.getParent().layout(true);
- }
+
+ if (displayHeader)
+ layout.topControl = headerText;
+ else
+ layout.topControl = headerLabel;
+
+ headerComp.layout(true);
+ getView();
}
- getView();
}
private void getView() {