Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/SWTUtil.java63
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/MonitorMemoryBlockDialog.java86
2 files changed, 90 insertions, 59 deletions
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/SWTUtil.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/SWTUtil.java
index 480ad4552..fcf120094 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/SWTUtil.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/SWTUtil.java
@@ -20,6 +20,7 @@ import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Group;
import org.eclipse.swt.widgets.Label;
@@ -143,6 +144,26 @@ public class SWTUtil {
}
/**
+ * Creates a wrapping label
+ * @param parent the parent composite to add this label to
+ * @param text the text to be displayed in the label
+ * @param hspan the horozontal span that label should take up in the parent composite
+ * @param wrapwidth the width hint that the label should wrap at
+ * @return a new label that wraps at a specified width
+ * @since 3.3
+ */
+ public static Label createWrapLabel(Composite parent, String text, int hspan, int wrapwidth) {
+ Label l = new Label(parent, SWT.NONE | SWT.WRAP);
+ l.setFont(parent.getFont());
+ l.setText(text);
+ GridData gd = new GridData(GridData.FILL_HORIZONTAL);
+ gd.horizontalSpan = hspan;
+ gd.widthHint = wrapwidth;
+ l.setLayoutData(gd);
+ return l;
+ }
+
+ /**
* Creates a new text widget
* @param parent the parent composite to add this text widget to
* @param hspan the horizontal span to take up on the parent composite
@@ -276,6 +297,48 @@ public class SWTUtil {
}
/**
+ * This method is used to make a combo box
+ * @param parent the parent composite to add the new combo to
+ * @param style the style for the Combo
+ * @param hspan the horizontal span to take up on the parent composite
+ * @param fill how the combo will fill into the composite
+ * Can be one of <code>GridData.FILL_HORIZONAL</code>, <code>GridData.FILL_BOTH</code> or <code>GridData.FILL_VERTICAL</code>
+ * @param items the item to put into the combo
+ * @return a new Combo instance
+ * @since 3.3
+ */
+ public static Combo createCombo(Composite parent, int style, int hspan, int fill, String[] items) {
+ Combo c = new Combo(parent, style);
+ c.setFont(parent.getFont());
+ GridData gd = new GridData(fill);
+ gd.horizontalSpan = hspan;
+ c.setLayoutData(gd);
+ c.setItems(items);
+ c.select(0);
+ return c;
+ }
+
+ /**
+ * This method is used to make a combo box with a default fill style of GridData.FILL_HORIZONTAL
+ * @param parent the parent composite to add the new combo to
+ * @param style the style for the Combo
+ * @param hspan the horizontal span to take up on the parent composite
+ * @param items the item to put into the combo
+ * @return a new Combo instance
+ * @since 3.3
+ */
+ public static Combo createCombo(Composite parent, int style, int hspan, String[] items) {
+ Combo c = new Combo(parent, style);
+ c.setFont(parent.getFont());
+ GridData gd = new GridData(GridData.FILL_HORIZONTAL);
+ gd.horizontalSpan = hspan;
+ c.setLayoutData(gd);
+ c.setItems(items);
+ c.select(0);
+ return c;
+ }
+
+ /**
* This method allows us to open the preference dialog on the specific page, in this case the perspective page
* @param id the id of pref page to show
* @param page the actual page to show
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/MonitorMemoryBlockDialog.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/MonitorMemoryBlockDialog.java
index c1e2816c1..13034cfc4 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/MonitorMemoryBlockDialog.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/MonitorMemoryBlockDialog.java
@@ -15,18 +15,16 @@ package org.eclipse.debug.internal.ui.views.memory;
import org.eclipse.debug.core.model.IMemoryBlockRetrieval;
import org.eclipse.debug.core.model.IMemoryBlockRetrievalExtension;
import org.eclipse.debug.internal.ui.DebugUIMessages;
+import org.eclipse.debug.internal.ui.SWTUtil;
import org.eclipse.debug.ui.IDebugUIConstants;
import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.jface.dialogs.TrayDialog;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.ModifyEvent;
import org.eclipse.swt.events.ModifyListener;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;
import org.eclipse.ui.PlatformUI;
@@ -45,6 +43,12 @@ public class MonitorMemoryBlockDialog extends TrayDialog implements ModifyListen
private String fPrefillLength = null;
/**
+ * the predefined width of the wrapping label for the expression to enter combo
+ * @since 3.3
+ */
+ private static final int LABEL_WIDTH = 210;
+
+ /**
* @param parentShell
*/
public MonitorMemoryBlockDialog(Shell parentShell, IMemoryBlockRetrieval memRetrieval, String prefillExp, String prefillLength) {
@@ -62,64 +66,24 @@ public class MonitorMemoryBlockDialog extends TrayDialog implements ModifyListen
* @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite)
*/
protected Control createDialogArea(Composite parent) {
- PlatformUI.getWorkbench().getHelpSystem().setHelp(parent, IDebugUIConstants.PLUGIN_ID + ".MonitorMemoryBlockDialog_context"); //$NON-NLS-1$
- parent.setLayout(new GridLayout());
- GridData spec2= new GridData();
- spec2.grabExcessVerticalSpace= true;
- spec2.grabExcessHorizontalSpace= true;
- spec2.horizontalAlignment= GridData.FILL;
- spec2.verticalAlignment= GridData.CENTER;
- parent.setLayoutData(spec2);
-
- Label textLabel = new Label(parent, SWT.NONE);
- textLabel.setText(DebugUIMessages.MonitorMemoryBlockDialog_EnterExpressionToMonitor);
- GridData textLayout = new GridData();
- textLabel.setLayoutData(textLayout);
-
- expressionInput = new Combo(parent, SWT.BORDER);
- GridData spec= new GridData();
- spec.grabExcessVerticalSpace= false;
- spec.grabExcessHorizontalSpace= true;
- spec.horizontalAlignment= GridData.FILL;
- spec.verticalAlignment= GridData.BEGINNING;
- expressionInput.setLayoutData(spec);
-
- // add HISTORY
- String[] historyExpression = MemoryViewUtil.getHistory();
- for (int i=0; i<historyExpression.length; i++)
- {
- expressionInput.add(historyExpression[i]);
- }
-
- // must be done before the listener is added
- // otherwise, will get into exception when trying to validate
- // input
- // This will be validated when the OK & Cancel button is added.
- if (fPrefillExp != null)
+ Composite comp = (Composite) super.createDialogArea(parent);
+ SWTUtil.createWrapLabel(comp, DebugUIMessages.MonitorMemoryBlockDialog_EnterExpressionToMonitor, 1, LABEL_WIDTH);
+ expressionInput = SWTUtil.createCombo(comp, SWT.BORDER, 1, MemoryViewUtil.getHistory());
+ if (fPrefillExp != null) {
expressionInput.setText(fPrefillExp);
-
+ }
expressionInput.addModifyListener(this);
- if (needLength)
- {
- Label lengthLabel = new Label(parent, SWT.NONE);
- lengthLabel.setText(DebugUIMessages.MonitorMemoryBlockDialog_NumberOfBytes);
- GridData lengthLayout = new GridData();
- lengthLabel.setLayoutData(lengthLayout);
-
- lengthInput = new Text(parent, SWT.BORDER);
- GridData lengthSpec= new GridData();
- lengthSpec.grabExcessVerticalSpace= false;
- lengthSpec.grabExcessHorizontalSpace= true;
- lengthSpec.horizontalAlignment= GridData.FILL;
- lengthInput.setLayoutData(lengthSpec);
-
- if (fPrefillLength != null)
+ if (needLength) {
+ SWTUtil.createLabel(comp, DebugUIMessages.MonitorMemoryBlockDialog_NumberOfBytes, 1);
+ lengthInput = SWTUtil.createSingleText(comp, 1);
+ if (fPrefillLength != null) {
lengthInput.setText(fPrefillLength);
-
+ }
lengthInput.addModifyListener(this);
}
- return parent;
+ PlatformUI.getWorkbench().getHelpSystem().setHelp(comp, IDebugUIConstants.PLUGIN_ID + ".MonitorMemoryBlockDialog_context"); //$NON-NLS-1$
+ return comp;
}
/* (non-Javadoc)
* @see org.eclipse.jface.window.Window#configureShell(org.eclipse.swt.widgets.Shell)
@@ -130,13 +94,17 @@ public class MonitorMemoryBlockDialog extends TrayDialog implements ModifyListen
newShell.setText(DebugUIMessages.MonitorMemoryBlockDialog_MonitorMemory);
}
- public String getExpression()
- {
+ /**
+ * @return the entered expression
+ */
+ public String getExpression() {
return expression;
}
- public String getLength()
- {
+ /**
+ * @return the entered length
+ */
+ public String getLength() {
return length;
}

Back to the top