Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSamantha Chan2008-04-02 13:57:09 -0400
committerSamantha Chan2008-04-02 13:57:09 -0400
commit4ac49a6dec610a2211d46451382d232ca59598c6 (patch)
treeeab5cc70f1c9453ca1838c5185a3429e7e0eb60f /org.eclipse.debug.ui
parent29e8060860d8456b5f1966af38f8ab0475272c46 (diff)
downloadeclipse.platform.debug-4ac49a6dec610a2211d46451382d232ca59598c6.tar.gz
eclipse.platform.debug-4ac49a6dec610a2211d46451382d232ca59598c6.tar.xz
eclipse.platform.debug-4ac49a6dec610a2211d46451382d232ca59598c6.zip
Bug 225385 - [Memory View] Need ability to disable add/remove rendering actions in RenderingViewPane
Diffstat (limited to 'org.eclipse.debug.ui')
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/AddMemoryRenderingContextAction.java40
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/MemoryView.java22
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/RemoveRenderingContextAction.java41
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/RenderingViewPane.java85
4 files changed, 128 insertions, 60 deletions
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/AddMemoryRenderingContextAction.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/AddMemoryRenderingContextAction.java
index 2e002b96e..77393eb3f 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/AddMemoryRenderingContextAction.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/AddMemoryRenderingContextAction.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2004, 2005 IBM Corporation and others.
+ * Copyright (c) 2004, 2008 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
@@ -22,6 +22,7 @@ public class AddMemoryRenderingContextAction implements IViewActionDelegate {
private IMemoryRenderingSite fMemoryView;
+
/* (non-Javadoc)
* @see org.eclipse.ui.IViewActionDelegate#init(org.eclipse.ui.IViewPart)
*/
@@ -29,8 +30,8 @@ public class AddMemoryRenderingContextAction implements IViewActionDelegate {
if (view instanceof IMemoryRenderingSite)
{
- fMemoryView = (IMemoryRenderingSite)view;
- }
+ fMemoryView = (IMemoryRenderingSite)view;
+ }
}
/* (non-Javadoc)
@@ -40,7 +41,21 @@ public class AddMemoryRenderingContextAction implements IViewActionDelegate {
if (fMemoryView == null)
return;
-
+
+ IMemoryRenderingContainer container = getRenderingContainer(action);
+ if (container != null)
+ {
+ AddMemoryRenderingAction addAction = new AddMemoryRenderingAction(container);
+ addAction.run();
+ addAction.dispose();
+ }
+ }
+
+ /**
+ * @param action
+ * @return
+ */
+ private IMemoryRenderingContainer getRenderingContainer(IAction action) {
IMemoryRenderingContainer[] viewPanes = fMemoryView.getMemoryRenderingContainers();
String actionId = action.getId();
IMemoryRenderingContainer selectedPane = null;
@@ -54,20 +69,21 @@ public class AddMemoryRenderingContextAction implements IViewActionDelegate {
}
}
- if (selectedPane == null)
- return;
-
- AddMemoryRenderingAction addAction = new AddMemoryRenderingAction(selectedPane);
- addAction.run();
-
- addAction.dispose();
+ return selectedPane;
}
/* (non-Javadoc)
* @see org.eclipse.ui.IActionDelegate#selectionChanged(org.eclipse.jface.action.IAction, org.eclipse.jface.viewers.ISelection)
*/
public void selectionChanged(IAction action, ISelection selection) {
-
+ IMemoryRenderingContainer container = getRenderingContainer(action);
+ if (container instanceof RenderingViewPane)
+ {
+ if (!((RenderingViewPane)container).canAddRendering())
+ action.setEnabled(false);
+ else
+ action.setEnabled(true);
+ }
}
}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/MemoryView.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/MemoryView.java
index d1f11c339..5e8333be2 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/MemoryView.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/MemoryView.java
@@ -394,10 +394,17 @@ public class MemoryView extends ViewPart implements IMemoryRenderingSite {
throws ExecutionException {
IMemoryRenderingContainer container = getContainer(fActivePaneId);
- IMemoryRendering activeRendering = container.getActiveRendering();
- if (activeRendering != null)
+ if (container != null)
{
- container.removeMemoryRendering(activeRendering);
+ if (container instanceof RenderingViewPane) {
+ if (!((RenderingViewPane) container).canRemoveRendering())
+ return null;
+ }
+ IMemoryRendering activeRendering = container.getActiveRendering();
+ if (activeRendering != null)
+ {
+ container.removeMemoryRendering(activeRendering);
+ }
}
return null;
@@ -410,10 +417,13 @@ public class MemoryView extends ViewPart implements IMemoryRenderingSite {
public Object execute(ExecutionEvent event)
throws ExecutionException {
- IMemoryRenderingContainer container = getContainer(fActivePaneId);
+ IMemoryRenderingContainer container = getContainer(fActivePaneId);
+
if (container != null && container instanceof RenderingViewPane)
{
- ((RenderingViewPane)container).showCreateRenderingTab();
+ RenderingViewPane pane = (RenderingViewPane)container;
+ if (pane.canAddRendering())
+ pane.showCreateRenderingTab();
}
return null;
}
@@ -500,7 +510,7 @@ public class MemoryView extends ViewPart implements IMemoryRenderingSite {
fViewPaneControls.put(paneId, renderingViewForm);
fWeights.add(new Integer(40));
- Control renderingControl = renderingPane.createViewPane(renderingViewForm, paneId, DebugUIMessages.MemoryView_Memory_renderings);
+ Control renderingControl = renderingPane.createViewPane(renderingViewForm, paneId, DebugUIMessages.MemoryView_Memory_renderings, true, true);
PlatformUI.getWorkbench().getHelpSystem().setHelp(renderingControl, IDebugUIConstants.PLUGIN_ID + ".MemoryView_context"); //$NON-NLS-1$
renderingViewForm.setContent(renderingControl);
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/RemoveRenderingContextAction.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/RemoveRenderingContextAction.java
index a514ca3aa..c908ef62b 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/RemoveRenderingContextAction.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/RemoveRenderingContextAction.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2004, 2005 IBM Corporation and others.
+ * Copyright (c) 2004, 2008 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
@@ -42,6 +42,33 @@ public class RemoveRenderingContextAction implements IViewActionDelegate {
if (fMemoryView == null)
return;
+ IMemoryRenderingContainer container = getRenderingContainer(action);
+ if (container != null)
+ {
+ RemoveMemoryRenderingAction removeAction = new RemoveMemoryRenderingAction(container);
+ removeAction.run();
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.IActionDelegate#selectionChanged(org.eclipse.jface.action.IAction, org.eclipse.jface.viewers.ISelection)
+ */
+ public void selectionChanged(IAction action, ISelection selection) {
+ IMemoryRenderingContainer container = getRenderingContainer(action);
+ if (container instanceof RenderingViewPane)
+ {
+ if (!((RenderingViewPane)container).canRemoveRendering())
+ action.setEnabled(false);
+ else
+ action.setEnabled(true);
+ }
+ }
+
+ /**
+ * @param action
+ * @return
+ */
+ private IMemoryRenderingContainer getRenderingContainer(IAction action) {
IMemoryRenderingContainer[] viewPanes = fMemoryView.getMemoryRenderingContainers();
String actionId = action.getId();
IMemoryRenderingContainer selectedPane = null;
@@ -55,17 +82,7 @@ public class RemoveRenderingContextAction implements IViewActionDelegate {
}
}
- if (selectedPane == null)
- return;
-
- RemoveMemoryRenderingAction removeAction = new RemoveMemoryRenderingAction(selectedPane);
- removeAction.run();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.IActionDelegate#selectionChanged(org.eclipse.jface.action.IAction, org.eclipse.jface.viewers.ISelection)
- */
- public void selectionChanged(IAction action, ISelection selection) {
+ return selectedPane;
}
}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/RenderingViewPane.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/RenderingViewPane.java
index 3c049689a..ab2084d3a 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/RenderingViewPane.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/RenderingViewPane.java
@@ -82,6 +82,9 @@ public class RenderingViewPane extends AbstractMemoryViewPane implements IMemory
private IMemoryRenderingSite fRenderingSite;
private Set fAddedRenderings = new HashSet();
private Set fAddedMemoryBlocks = new HashSet();
+
+ private boolean fCanAddRendering = true;
+ private boolean fCanRemoveRendering = true;
private boolean fIsDisposed = false;
@@ -380,7 +383,7 @@ public class RenderingViewPane extends AbstractMemoryViewPane implements IMemory
CTabFolder toDisplay = (CTabFolder) fStackLayout.topControl;
// if only CreateRendering is present, restore renderings
- if (toDisplay.getItemCount() == 1 && getTopMemoryTab().getRendering() instanceof CreateRendering) {
+ if (isRestoreViewTabs(toDisplay)) {
restoreViewTabs(renderings);
}
@@ -409,6 +412,14 @@ public class RenderingViewPane extends AbstractMemoryViewPane implements IMemory
updateToolBarActionsEnablement();
}
+ private boolean isRestoreViewTabs(CTabFolder folder)
+ {
+ if (canAddRendering())
+ return (folder.getItemCount() == 1 && getTopMemoryTab().getRendering() instanceof CreateRendering);
+ else
+ return (folder.getItemCount() == 0);
+ }
+
private int getIndexOfCreateRenderingTab(CTabFolder folder)
{
for(int i = 0; i < folder.getItemCount(); i++)
@@ -452,7 +463,7 @@ public class RenderingViewPane extends AbstractMemoryViewPane implements IMemory
int index = getIndexOfCreateRenderingTab(tabFolder);
if (index < 0)
index = 0;
- CTabItem tab = new CTabItem(tabFolder, SWT.CLOSE, index);
+ CTabItem tab = createTab(tabFolder, index);
MemoryViewTab viewTab = new MemoryViewTab(tab, rendering,getInstance());
tabFolder.setSelection(tabFolder.indexOf(tab));
@@ -556,29 +567,7 @@ public class RenderingViewPane extends AbstractMemoryViewPane implements IMemory
}
});
- }
-
- /**
- * @param memoryBlock
- * @return if this memory block is removed
- */
- private boolean isMemoryBlockRemoved(IMemoryBlock memoryBlock)
- {
- IMemoryBlockRetrieval retrieval = MemoryViewUtil.getMemoryBlockRetrieval(memoryBlock);
- boolean removed = true;
- if (retrieval != null)
- {
- IMemoryBlock[] memoryBlocks = DebugPlugin.getDefault().getMemoryBlockManager().getMemoryBlocks(retrieval);
- for (int i=0; i<memoryBlocks.length; i++)
- {
- if (memoryBlocks[i] == memoryBlock)
- removed = false;
- }
- }
-
- return removed;
- }
-
+ }
/**
* @param viewTab
@@ -891,7 +880,7 @@ public class RenderingViewPane extends AbstractMemoryViewPane implements IMemory
IMemoryRendering[] renderings = fRenderingMgr.getRenderingsFromMemoryBlock(memoryBlock);
// if only CreateRendering is present, restore renderings
- if (toDisplay.getItemCount() == 1 && getTopMemoryTab().getRendering() instanceof CreateRendering)
+ if (isRestoreViewTabs(toDisplay))
{
restoreViewTabs(renderings);
}
@@ -925,8 +914,10 @@ public class RenderingViewPane extends AbstractMemoryViewPane implements IMemory
fAddedRenderings.clear();
}
- public Control createViewPane(Composite parent, String paneId, String label) {
+ public Control createViewPane(Composite parent, String paneId, String label, boolean canAddRendering, boolean canRemoveRendering) {
Control control = super.createViewPane(parent, paneId, label);
+ fCanAddRendering = canAddRendering;
+ fCanRemoveRendering = canRemoveRendering;
fRenderingMgr = new ViewPaneRenderingMgr(this);
PlatformUI.getWorkbench().getHelpSystem().setHelp(parent, IDebugUIConstants.PLUGIN_ID + ".MemoryRenderingView_context"); //$NON-NLS-1$
return control;
@@ -1206,7 +1197,7 @@ public class RenderingViewPane extends AbstractMemoryViewPane implements IMemory
else {
DebugUIPlugin.logErrorMessage("Memory block retrieval for memory block is null"); //$NON-NLS-1$
}
-
+
newCreateRenderingForFolder(memory, folder);
return folder;
@@ -1214,6 +1205,10 @@ public class RenderingViewPane extends AbstractMemoryViewPane implements IMemory
private void newCreateRenderingForFolder(IMemoryBlock memory,
CTabFolder folder) {
+
+ if (!canAddRendering())
+ return;
+
CTabItem newItem = new CTabItem(folder, SWT.NONE);
CreateRendering rendering = new CreateRendering(getInstance());
rendering.init(getInstance(), memory);
@@ -1227,7 +1222,37 @@ public class RenderingViewPane extends AbstractMemoryViewPane implements IMemory
public void debugContextChanged(DebugContextEvent event) {
if ((event.getFlags() & DebugContextEvent.ACTIVATED) > 0) {
contextActivated(event.getContext());
- }
-
+ }
+ }
+
+ /**
+ * @return whether this container allows user to add rendering manually
+ * @since 3.4
+ */
+ public boolean canAddRendering()
+ {
+ return fCanAddRendering;
+ }
+
+ /**
+ * @return whether this container allows user to remove rendering manually
+ * @since 3.4
+ */
+ public boolean canRemoveRendering()
+ {
+ return fCanRemoveRendering;
+ }
+
+ /**
+ * @param tabFolder
+ * @param index
+ * @return
+ */
+ private CTabItem createTab(CTabFolder tabFolder, int index) {
+ int swtStyle = SWT.CLOSE;
+ if (!canRemoveRendering())
+ swtStyle = SWT.NONE;
+ CTabItem tab = new CTabItem(tabFolder, swtStyle, index);
+ return tab;
}
}

Back to the top