mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-15 04:05:38 +02:00
Bugxilla 312098.
This commit is contained in:
parent
bf4c760f6a
commit
3a958f19ca
2 changed files with 95 additions and 21 deletions
|
@ -11,8 +11,14 @@
|
|||
|
||||
package org.eclipse.cdt.debug.ui.memory.memorybrowser;
|
||||
|
||||
import org.eclipse.core.runtime.IStatus;
|
||||
import org.eclipse.jface.dialogs.IDialogConstants;
|
||||
import org.eclipse.jface.fieldassist.ControlDecoration;
|
||||
import org.eclipse.jface.fieldassist.FieldDecoration;
|
||||
import org.eclipse.jface.fieldassist.FieldDecorationRegistry;
|
||||
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.Button;
|
||||
|
@ -24,6 +30,9 @@ import org.eclipse.ui.PlatformUI;
|
|||
public class GoToAddressBarWidget {
|
||||
|
||||
private Text fExpression;
|
||||
private ControlDecoration fEmptyExpression;
|
||||
private ControlDecoration fWrongExpression;
|
||||
|
||||
private Button fOKButton;
|
||||
private Button fOKNewTabButton;
|
||||
private Composite fComposite;
|
||||
|
@ -47,18 +56,63 @@ public class GoToAddressBarWidget {
|
|||
layout.marginLeft = 0;
|
||||
fComposite.setLayout(layout);
|
||||
|
||||
fExpression = new Text(fComposite, SWT.SINGLE | SWT.BORDER);
|
||||
fExpression.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
|
||||
fExpression = createExpressionField(fComposite);
|
||||
|
||||
fOKButton = new Button(fComposite, SWT.NONE);
|
||||
fOKButton.setText(Messages.getString("GoToAddressBarWidget.Go")); //$NON-NLS-1$
|
||||
fOKButton.setEnabled(false);
|
||||
|
||||
fOKNewTabButton = new Button(fComposite, SWT.NONE);
|
||||
fOKNewTabButton.setText(Messages.getString("GoToAddressBarWidget.NewTab")); //$NON-NLS-1$
|
||||
fOKNewTabButton.setEnabled(false);
|
||||
|
||||
return fComposite;
|
||||
}
|
||||
|
||||
|
||||
private Text createExpressionField(Composite parent) {
|
||||
Text expression = new Text(parent, SWT.SINGLE | SWT.BORDER);
|
||||
expression.addModifyListener(new ModifyListener() {
|
||||
public void modifyText(ModifyEvent e) {
|
||||
updateButtons();
|
||||
}
|
||||
});
|
||||
fEmptyExpression = new ControlDecoration(expression, SWT.LEFT | SWT.CENTER);
|
||||
fEmptyExpression.setDescriptionText("Enter an expression to position rendering");
|
||||
FieldDecoration fieldDecoration = FieldDecorationRegistry.getDefault()
|
||||
.getFieldDecoration(FieldDecorationRegistry.DEC_REQUIRED);
|
||||
fEmptyExpression.setImage(fieldDecoration.getImage());
|
||||
|
||||
fWrongExpression = new ControlDecoration(expression, SWT.LEFT | SWT.TOP);
|
||||
fieldDecoration = FieldDecorationRegistry.getDefault()
|
||||
.getFieldDecoration(FieldDecorationRegistry.DEC_ERROR);
|
||||
fWrongExpression.setImage(fieldDecoration.getImage());
|
||||
fWrongExpression.hide();
|
||||
|
||||
// leave enough room for decorators
|
||||
GridData data = new GridData(GridData.FILL_HORIZONTAL);
|
||||
data.horizontalIndent = Math.max(fEmptyExpression.getImage().getBounds().width, fWrongExpression.getImage().getBounds().width);
|
||||
expression.setLayoutData(data);
|
||||
return expression;
|
||||
}
|
||||
|
||||
protected void updateButtons() {
|
||||
boolean empty = fExpression.getText().trim().length() == 0;
|
||||
|
||||
fOKNewTabButton.setEnabled(!empty);
|
||||
fOKButton.setEnabled(!empty);
|
||||
|
||||
if (empty)
|
||||
fEmptyExpression.show();
|
||||
else
|
||||
fEmptyExpression.hide();
|
||||
|
||||
clearError();
|
||||
}
|
||||
|
||||
private void clearError() {
|
||||
fWrongExpression.hide();
|
||||
}
|
||||
|
||||
public int getHeight()
|
||||
{
|
||||
int height = fComposite.computeSize(SWT.DEFAULT, SWT.DEFAULT).y;
|
||||
|
@ -83,4 +137,17 @@ public class GoToAddressBarWidget {
|
|||
{
|
||||
return fExpression;
|
||||
}
|
||||
|
||||
/**
|
||||
* decorate expression field according to the status
|
||||
* @param message
|
||||
*/
|
||||
public void handleExpressionStatus(final IStatus message) {
|
||||
if (message.isOK()) {
|
||||
clearError();
|
||||
} else {
|
||||
fWrongExpression.setDescriptionText(message.getMessage());
|
||||
fWrongExpression.show();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -41,7 +41,6 @@ import org.eclipse.debug.core.model.IMemoryBlockRetrieval;
|
|||
import org.eclipse.debug.core.model.IMemoryBlockRetrievalExtension;
|
||||
import org.eclipse.debug.core.model.MemoryByte;
|
||||
import org.eclipse.debug.internal.ui.memory.MemoryRenderingManager;
|
||||
import org.eclipse.debug.internal.ui.views.memory.MemoryViewUtil;
|
||||
import org.eclipse.debug.ui.DebugUITools;
|
||||
import org.eclipse.debug.ui.contexts.DebugContextEvent;
|
||||
import org.eclipse.debug.ui.contexts.IDebugContextListener;
|
||||
|
@ -388,14 +387,21 @@ public class MemoryBrowser extends ViewPart implements IDebugContextListener, IM
|
|||
final Object context = activeFolder.getData(KEY_CONTEXT);
|
||||
|
||||
CTabItem item = activeFolder.getSelection();
|
||||
if (inNewTab || item == null) {
|
||||
item = createTab(activeFolder, activeFolder.getSelectionIndex() + 1);
|
||||
populateTabWithRendering(item, retrieval, context, memorySpaceId);
|
||||
|
||||
fContextFolders.put(retrieval, activeFolder);
|
||||
activeFolder.setSelection(item);
|
||||
getSite().getSelectionProvider().setSelection(new StructuredSelection(item.getData(KEY_RENDERING)));
|
||||
}
|
||||
if(inNewTab || item == null)
|
||||
{
|
||||
try {
|
||||
IMemoryBlockExtension block = createMemoryBlock(retrieval, expression, context, memorySpaceId); //$NON-NLS-1$
|
||||
item = createTab(activeFolder, activeFolder.getSelectionIndex() + 1);
|
||||
populateTabWithRendering(item, retrieval, context, memorySpaceId, block);
|
||||
fContextFolders.put(retrieval, activeFolder);
|
||||
activeFolder.setSelection(item);
|
||||
getSite().getSelectionProvider().setSelection(new StructuredSelection(item.getData(KEY_RENDERING)));
|
||||
} catch (DebugException e1) {
|
||||
fGotoAddressBar.handleExpressionStatus(new Status(Status.ERROR, MemoryBrowserPlugin.PLUGIN_ID,
|
||||
Messages.getString("MemoryBrowser.FailedToGoToAddressTitle"), e1));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
IRepositionableMemoryRendering rendering = (IRepositionableMemoryRendering) activeFolder.getSelection().getData(KEY_RENDERING);
|
||||
IMemoryRenderingContainer container = (IMemoryRenderingContainer)item.getData(KEY_CONTAINER);
|
||||
|
@ -419,13 +425,20 @@ public class MemoryBrowser extends ViewPart implements IDebugContextListener, IM
|
|||
block.setBaseAddress(newBase);
|
||||
}
|
||||
renderingFinal.goToAddress(newBase);
|
||||
fGotoAddressBar.handleExpressionStatus(Status.OK_STATUS);
|
||||
runOnUIThread(new Runnable(){
|
||||
public void run() {
|
||||
updateLabel(activeFolder.getSelection(), renderingFinal);
|
||||
}
|
||||
});
|
||||
} catch (DebugException e1) {
|
||||
MemoryViewUtil.openError(Messages.getString("MemoryBrowser.FailedToGoToAddressTitle"), "", e1); //$NON-NLS-1$
|
||||
} catch (final DebugException e1) {
|
||||
// widgets update require Display
|
||||
runOnUIThread(new Runnable(){
|
||||
public void run() {
|
||||
fGotoAddressBar.handleExpressionStatus(new Status(Status.ERROR, MemoryBrowserPlugin.PLUGIN_ID,
|
||||
Messages.getString("MemoryBrowser.FailedToGoToAddressTitle"), e1));
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}.start();
|
||||
|
@ -746,8 +759,6 @@ public class MemoryBrowser extends ViewPart implements IDebugContextListener, IM
|
|||
|
||||
tabFolder.setData(KEY_RETRIEVAL, retrieval);
|
||||
|
||||
CTabItem item = createTab(tabFolder, 0);
|
||||
populateTabWithRendering(item, retrieval, context, null);
|
||||
fContextFolders.put(retrieval, tabFolder);
|
||||
fStackLayout.topControl = tabFolder;
|
||||
}
|
||||
|
@ -831,7 +842,7 @@ public class MemoryBrowser extends ViewPart implements IDebugContextListener, IM
|
|||
store.setValue(PREF_DEFAULT_RENDERING, defaultRenderingTypeId);
|
||||
}
|
||||
|
||||
private void populateTabWithRendering(final CTabItem tab, final IMemoryBlockRetrieval retrieval, Object context, String memorySpaceId) {
|
||||
private void populateTabWithRendering(final CTabItem tab, final IMemoryBlockRetrieval retrieval, Object context, String memorySpaceId, IMemoryBlockExtension block) {
|
||||
IMemoryRenderingType type = DebugUITools.getMemoryRenderingManager().getRenderingType(getDefaultRenderingTypeId());
|
||||
try {
|
||||
final IMemoryRendering rendering = type.createRendering();
|
||||
|
@ -863,8 +874,6 @@ public class MemoryBrowser extends ViewPart implements IDebugContextListener, IM
|
|||
|
||||
};
|
||||
|
||||
IMemoryBlockExtension block = createMemoryBlock(retrieval, "0", context, memorySpaceId); //$NON-NLS-1$
|
||||
|
||||
fCurrentContainers.add(container);
|
||||
rendering.init(container, block);
|
||||
rendering.createControl(tab.getParent());
|
||||
|
@ -1077,5 +1086,3 @@ public class MemoryBrowser extends ViewPart implements IDebugContextListener, IM
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue