Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 312098 | Differences between
and this patch

Collapse All | Expand All

(-)src/org/eclipse/cdt/debug/ui/memory/memorybrowser/GoToAddressBarWidget.java (-3 / +70 lines)
Lines 11-18 Link Here
11
11
12
package org.eclipse.cdt.debug.ui.memory.memorybrowser;
12
package org.eclipse.cdt.debug.ui.memory.memorybrowser;
13
13
14
import org.eclipse.core.runtime.IStatus;
14
import org.eclipse.jface.dialogs.IDialogConstants;
15
import org.eclipse.jface.dialogs.IDialogConstants;
16
import org.eclipse.jface.fieldassist.ControlDecoration;
17
import org.eclipse.jface.fieldassist.FieldDecoration;
18
import org.eclipse.jface.fieldassist.FieldDecorationRegistry;
15
import org.eclipse.swt.SWT;
19
import org.eclipse.swt.SWT;
20
import org.eclipse.swt.events.ModifyEvent;
21
import org.eclipse.swt.events.ModifyListener;
16
import org.eclipse.swt.layout.GridData;
22
import org.eclipse.swt.layout.GridData;
17
import org.eclipse.swt.layout.GridLayout;
23
import org.eclipse.swt.layout.GridLayout;
18
import org.eclipse.swt.widgets.Button;
24
import org.eclipse.swt.widgets.Button;
Lines 24-29 Link Here
24
public class GoToAddressBarWidget {
30
public class GoToAddressBarWidget {
25
	
31
	
26
	private Text fExpression;
32
	private Text fExpression;
33
	private ControlDecoration fEmptyExpression;
34
	private ControlDecoration fWrongExpression;
35
	
27
	private Button fOKButton;
36
	private Button fOKButton;
28
	private Button fOKNewTabButton;
37
	private Button fOKNewTabButton;
29
	private Composite fComposite;
38
	private Composite fComposite;
Lines 47-64 Link Here
47
		layout.marginLeft = 0;
56
		layout.marginLeft = 0;
48
		fComposite.setLayout(layout);
57
		fComposite.setLayout(layout);
49
	
58
	
50
		fExpression = new Text(fComposite, SWT.SINGLE | SWT.BORDER);
59
		fExpression = createExpressionField(fComposite);
51
		fExpression.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
52
		
60
		
53
		fOKButton = new Button(fComposite, SWT.NONE);
61
		fOKButton = new Button(fComposite, SWT.NONE);
54
		fOKButton.setText(Messages.getString("GoToAddressBarWidget.Go")); //$NON-NLS-1$
62
		fOKButton.setText(Messages.getString("GoToAddressBarWidget.Go")); //$NON-NLS-1$
63
		fOKButton.setEnabled(false);
55
		
64
		
56
		fOKNewTabButton = new Button(fComposite, SWT.NONE);
65
		fOKNewTabButton = new Button(fComposite, SWT.NONE);
57
		fOKNewTabButton.setText(Messages.getString("GoToAddressBarWidget.NewTab")); //$NON-NLS-1$
66
		fOKNewTabButton.setText(Messages.getString("GoToAddressBarWidget.NewTab")); //$NON-NLS-1$
67
		fOKNewTabButton.setEnabled(false);
58
		
68
		
59
		return fComposite;
69
		return fComposite;
60
	}
70
	}
61
	
71
72
	private Text createExpressionField(Composite parent) {
73
		Text expression = new Text(parent, SWT.SINGLE | SWT.BORDER);
74
		expression.addModifyListener(new ModifyListener() {
75
			public void modifyText(ModifyEvent e) {
76
				updateButtons();
77
			}
78
		});
79
		fEmptyExpression = new ControlDecoration(expression, SWT.LEFT | SWT.CENTER);
80
		fEmptyExpression.setDescriptionText("Enter an expression to position rendering");
81
		FieldDecoration fieldDecoration = FieldDecorationRegistry.getDefault()
82
		.getFieldDecoration(FieldDecorationRegistry.DEC_REQUIRED);
83
		fEmptyExpression.setImage(fieldDecoration.getImage());
84
85
		fWrongExpression = new ControlDecoration(expression, SWT.LEFT | SWT.TOP);
86
		fieldDecoration = FieldDecorationRegistry.getDefault()
87
		.getFieldDecoration(FieldDecorationRegistry.DEC_ERROR);
88
		fWrongExpression.setImage(fieldDecoration.getImage());
89
		fWrongExpression.hide();
90
		
91
		// leave enough room for decorators
92
		GridData data = new GridData(GridData.FILL_HORIZONTAL);
93
		data.horizontalIndent = Math.max(fEmptyExpression.getImage().getBounds().width, fWrongExpression.getImage().getBounds().width);
94
		expression.setLayoutData(data);
95
		return expression;
96
	}
97
		
98
	protected void updateButtons() {
99
		boolean empty = fExpression.getText().trim().length() == 0;
100
		
101
		fOKNewTabButton.setEnabled(!empty);
102
		fOKButton.setEnabled(!empty);
103
		
104
		if (empty) 
105
			fEmptyExpression.show();
106
		else 
107
			fEmptyExpression.hide();
108
109
		clearError();
110
	}
111
112
	private void clearError() {
113
		fWrongExpression.hide();
114
	}
115
62
	public int getHeight()
116
	public int getHeight()
63
	{
117
	{
64
		int height = fComposite.computeSize(SWT.DEFAULT, SWT.DEFAULT).y;
118
		int height = fComposite.computeSize(SWT.DEFAULT, SWT.DEFAULT).y;
Lines 83-86 Link Here
83
	{
137
	{
84
		return fExpression;
138
		return fExpression;
85
	}
139
	}
140
	
141
	/**
142
	 * decorate expression field according to the status
143
	 * @param message
144
	 */
145
	public void handleExpressionStatus(final IStatus message) {
146
		if (message.isOK()) {
147
			clearError();
148
		} else {
149
			fWrongExpression.setDescriptionText(message.getMessage());
150
			fWrongExpression.show();
151
		}
152
	}
86
}
153
}
(-)src/org/eclipse/cdt/debug/ui/memory/memorybrowser/MemoryBrowser.java (-18 / +25 lines)
Lines 41-47 Link Here
41
import org.eclipse.debug.core.model.IMemoryBlockRetrievalExtension;
41
import org.eclipse.debug.core.model.IMemoryBlockRetrievalExtension;
42
import org.eclipse.debug.core.model.MemoryByte;
42
import org.eclipse.debug.core.model.MemoryByte;
43
import org.eclipse.debug.internal.ui.memory.MemoryRenderingManager;
43
import org.eclipse.debug.internal.ui.memory.MemoryRenderingManager;
44
import org.eclipse.debug.internal.ui.views.memory.MemoryViewUtil;
45
import org.eclipse.debug.ui.DebugUITools;
44
import org.eclipse.debug.ui.DebugUITools;
46
import org.eclipse.debug.ui.contexts.DebugContextEvent;
45
import org.eclipse.debug.ui.contexts.DebugContextEvent;
47
import org.eclipse.debug.ui.contexts.IDebugContextListener;
46
import org.eclipse.debug.ui.contexts.IDebugContextListener;
Lines 388-401 Link Here
388
			final Object context = activeFolder.getData(KEY_CONTEXT);
387
			final Object context = activeFolder.getData(KEY_CONTEXT);
389
			
388
			
390
			CTabItem item = activeFolder.getSelection();
389
			CTabItem item = activeFolder.getSelection();
391
			if (inNewTab || item == null) {
390
			if(inNewTab || item == null)
392
				item = createTab(activeFolder, activeFolder.getSelectionIndex() + 1);
391
			{
393
				populateTabWithRendering(item, retrieval, context,  memorySpaceId);
392
				try {
394
393
					IMemoryBlockExtension block = createMemoryBlock(retrieval, expression, context, memorySpaceId); //$NON-NLS-1$
395
				fContextFolders.put(retrieval, activeFolder);
394
					item = createTab(activeFolder, activeFolder.getSelectionIndex() + 1);
396
				activeFolder.setSelection(item);
395
					populateTabWithRendering(item, retrieval, context, memorySpaceId, block);
397
				getSite().getSelectionProvider().setSelection(new StructuredSelection(item.getData(KEY_RENDERING)));
396
					fContextFolders.put(retrieval, activeFolder);
398
			}
397
					activeFolder.setSelection(item);
398
					getSite().getSelectionProvider().setSelection(new StructuredSelection(item.getData(KEY_RENDERING)));
399
				} catch (DebugException e1) {
400
					fGotoAddressBar.handleExpressionStatus(new Status(Status.ERROR, MemoryBrowserPlugin.PLUGIN_ID, 
401
							Messages.getString("MemoryBrowser.FailedToGoToAddressTitle"), e1));
402
					return;
403
				} 
404
			} 
399
			
405
			
400
			IRepositionableMemoryRendering rendering = (IRepositionableMemoryRendering) activeFolder.getSelection().getData(KEY_RENDERING);
406
			IRepositionableMemoryRendering rendering = (IRepositionableMemoryRendering) activeFolder.getSelection().getData(KEY_RENDERING);
401
			IMemoryRenderingContainer container = (IMemoryRenderingContainer)item.getData(KEY_CONTAINER);
407
			IMemoryRenderingContainer container = (IMemoryRenderingContainer)item.getData(KEY_CONTAINER);
Lines 419-431 Link Here
419
								block.setBaseAddress(newBase);
425
								block.setBaseAddress(newBase);
420
							}
426
							}
421
							renderingFinal.goToAddress(newBase);
427
							renderingFinal.goToAddress(newBase);
428
							fGotoAddressBar.handleExpressionStatus(Status.OK_STATUS);
422
							runOnUIThread(new Runnable(){
429
							runOnUIThread(new Runnable(){
423
								public void run() {
430
								public void run() {
424
									updateLabel(activeFolder.getSelection(), renderingFinal);
431
									updateLabel(activeFolder.getSelection(), renderingFinal);
425
								}
432
								}
426
							});
433
							});
427
						} catch (DebugException e1) {
434
						} catch (final DebugException e1) {
428
							MemoryViewUtil.openError(Messages.getString("MemoryBrowser.FailedToGoToAddressTitle"), "", e1);  //$NON-NLS-1$
435
							// widgets update require Display 
436
							runOnUIThread(new Runnable(){
437
								public void run() {
438
									fGotoAddressBar.handleExpressionStatus(new Status(Status.ERROR, MemoryBrowserPlugin.PLUGIN_ID, 
439
											Messages.getString("MemoryBrowser.FailedToGoToAddressTitle"), e1));
440
								}
441
							});
429
						}
442
						}
430
					}
443
					}
431
				}.start();
444
				}.start();
Lines 746-753 Link Here
746
					
759
					
747
					tabFolder.setData(KEY_RETRIEVAL, retrieval);
760
					tabFolder.setData(KEY_RETRIEVAL, retrieval);
748
					
761
					
749
					CTabItem item = createTab(tabFolder, 0);
750
					populateTabWithRendering(item, retrieval, context, null);
751
					fContextFolders.put(retrieval, tabFolder);
762
					fContextFolders.put(retrieval, tabFolder);
752
					fStackLayout.topControl = tabFolder;
763
					fStackLayout.topControl = tabFolder;
753
				}
764
				}
Lines 831-837 Link Here
831
		store.setValue(PREF_DEFAULT_RENDERING, defaultRenderingTypeId);
842
		store.setValue(PREF_DEFAULT_RENDERING, defaultRenderingTypeId);
832
	}
843
	}
833
	
844
	
834
	private void populateTabWithRendering(final CTabItem tab, final IMemoryBlockRetrieval retrieval, Object context, String memorySpaceId) {
845
	private void populateTabWithRendering(final CTabItem tab, final IMemoryBlockRetrieval retrieval, Object context, String memorySpaceId, IMemoryBlockExtension block) {
835
		IMemoryRenderingType type = DebugUITools.getMemoryRenderingManager().getRenderingType(getDefaultRenderingTypeId());
846
		IMemoryRenderingType type = DebugUITools.getMemoryRenderingManager().getRenderingType(getDefaultRenderingTypeId());
836
		try {
847
		try {
837
			final IMemoryRendering rendering = type.createRendering();
848
			final IMemoryRendering rendering = type.createRendering();
Lines 863-870 Link Here
863
				
874
				
864
			};
875
			};
865
			
876
			
866
			IMemoryBlockExtension block = createMemoryBlock(retrieval, "0", context, memorySpaceId); //$NON-NLS-1$
867
			
868
			fCurrentContainers.add(container);
877
			fCurrentContainers.add(container);
869
			rendering.init(container, block);
878
			rendering.init(container, block);
870
			rendering.createControl(tab.getParent());
879
			rendering.createControl(tab.getParent());
Lines 1077-1081 Link Here
1077
		}
1086
		}
1078
	}
1087
	}
1079
}
1088
}
1080
1081

Return to bug 312098