forked from eclipse-cdt/cdt
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve property tester to check the selection on Debug View and decide
the visibility of commands. Basically we need to have Debug View for an application under debug. So asking the selection from Debug View and checking it against an active DSF session should give the most accurate visibility condition. Along with this we plan to show the commands in all views if any of the view is pinned.
- Loading branch information
1 parent
cc045d1
commit d502e84
Showing
4 changed files
with
86 additions
and
105 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
82 changes: 0 additions & 82 deletions
82
...dt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/PinCommandEnablementTester.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 59 additions & 0 deletions
59
...rc/org/eclipse/cdt/dsf/debug/internal/ui/debugview/layout/PinCommandEnablementTester.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
package org.eclipse.cdt.dsf.debug.internal.ui.debugview.layout; | ||
|
||
import org.eclipse.cdt.debug.internal.ui.actions.PinViewHandler; | ||
import org.eclipse.cdt.dsf.ui.viewmodel.datamodel.IDMVMContext; | ||
import org.eclipse.debug.ui.DebugUITools; | ||
import org.eclipse.debug.ui.IDebugUIConstants; | ||
import org.eclipse.jface.viewers.ISelection; | ||
import org.eclipse.jface.viewers.IStructuredSelection; | ||
import org.eclipse.ui.IViewPart; | ||
import org.eclipse.ui.IWorkbenchPage; | ||
import org.eclipse.ui.IWorkbenchWindow; | ||
import org.eclipse.ui.PlatformUI; | ||
|
||
/** | ||
* Tests if Pin View Command can be enabled. This is tested in 2 steps. | ||
* <p> | ||
* 1. If a view is already pinned(which will be passes as argument) then command | ||
* must be enabled until it is unpinned. 2. A valid CDT Debug Launch is active | ||
* within Debug Launch Manager. | ||
* </p> | ||
* | ||
* @author Raghunandana Murthappa | ||
*/ | ||
public class PinCommandEnablementTester extends DebugViewLayoutTester { | ||
|
||
private static final String PIN_VIEW_COMMAND_PROP_TEST_NAME = "canPinViewEnabled"; //$NON-NLS-1$ | ||
|
||
@Override | ||
public boolean test(Object receiver, String property, Object[] args, Object expectedValue) { | ||
|
||
if (PIN_VIEW_COMMAND_PROP_TEST_NAME.equals(property)) { | ||
|
||
// We enable Pin Command on all views if it is pinned in any View. | ||
if (!PinViewHandler.getPinnedViews().isEmpty()) { | ||
return true; | ||
} | ||
|
||
//Check if 'Debug View' is present and there is a valid selection. | ||
IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); | ||
if (window != null) { | ||
IWorkbenchPage page = window.getActivePage(); | ||
if (page != null) { | ||
IViewPart debugPart = page.findView(IDebugUIConstants.ID_DEBUG_VIEW); | ||
if (debugPart != null) { | ||
ISelection debugContext = DebugUITools.getDebugContextForPart(debugPart); | ||
if (debugContext instanceof IStructuredSelection structSel) { | ||
Object firstEle = structSel.getFirstElement(); | ||
if (firstEle instanceof IDMVMContext) { | ||
return super.test(firstEle, IS_GROUP_VISIBLE, args, expectedValue); | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
return false; | ||
} | ||
|
||
} |