mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-15 04:55:22 +02:00
PR 50789
First work to add support for "Show in CView" Based on work provided by Thomas Fletcher.
This commit is contained in:
parent
11f6760c10
commit
9678b65711
3 changed files with 101 additions and 1 deletions
|
@ -54,6 +54,9 @@ ActionDefinition.uncomment.description= Uncomment the selected // style comment
|
||||||
ActionDefinition.opendecl.name= Open Declaration
|
ActionDefinition.opendecl.name= Open Declaration
|
||||||
ActionDefinition.opendecl.description= Open an editor on the selected element's declaration(s)
|
ActionDefinition.opendecl.description= Open an editor on the selected element's declaration(s)
|
||||||
|
|
||||||
|
ActionDefinition.opencview.name= Show in C/C++ Project view
|
||||||
|
ActionDefinition.opencview.description= Show the selected resource in the C/C++ Project view
|
||||||
|
|
||||||
CEditor.name=C Editor
|
CEditor.name=C Editor
|
||||||
CPluginPreferencePage.name=C/C++
|
CPluginPreferencePage.name=C/C++
|
||||||
CPluginEditorPreferencePage.name=C/C++ Editor
|
CPluginEditorPreferencePage.name=C/C++ Editor
|
||||||
|
|
|
@ -34,9 +34,9 @@
|
||||||
<extension-point id="CElementFilters" name="%elementFiltersName"/>
|
<extension-point id="CElementFilters" name="%elementFiltersName"/>
|
||||||
<extension-point id="BinaryParserPage" name="Binary Parser Page"/>
|
<extension-point id="BinaryParserPage" name="Binary Parser Page"/>
|
||||||
<!-- =========================================================================== -->
|
<!-- =========================================================================== -->
|
||||||
|
<!-- Extension point: org.eclipse.cdt.ui.textHovers -->
|
||||||
<!-- Extension Implementation: must implement org.eclipse.jface.text.ITextHover -->
|
<!-- Extension Implementation: must implement org.eclipse.jface.text.ITextHover -->
|
||||||
<!-- Purpose: Provide a perspective specific text hovering for CEditor files -->
|
<!-- Purpose: Provide a perspective specific text hovering for CEditor files -->
|
||||||
<!-- Extension point: org.eclipse.cdt.ui.textHovers -->
|
|
||||||
<!-- =========================================================================== -->
|
<!-- =========================================================================== -->
|
||||||
<extension-point id="textHovers" name="%textHoversName"/>
|
<extension-point id="textHovers" name="%textHoversName"/>
|
||||||
|
|
||||||
|
@ -426,7 +426,14 @@
|
||||||
command="org.eclipse.cdt.ui.navigate.opentype"
|
command="org.eclipse.cdt.ui.navigate.opentype"
|
||||||
configuration="org.eclipse.ui.defaultAcceleratorConfiguration">
|
configuration="org.eclipse.ui.defaultAcceleratorConfiguration">
|
||||||
</keyBinding>
|
</keyBinding>
|
||||||
|
<command
|
||||||
|
category="org.eclipse.cdt.ui.category.source"
|
||||||
|
name="%ActionDefinition.opencview.name"
|
||||||
|
description="%ActionDefinition.opencview.description"
|
||||||
|
id="org.eclipse.cdt.ui.edit.opencview">
|
||||||
|
</command>
|
||||||
</extension>
|
</extension>
|
||||||
|
|
||||||
<extension
|
<extension
|
||||||
id="org.eclipse.cdt.ui.CSearchPage"
|
id="org.eclipse.cdt.ui.CSearchPage"
|
||||||
name="CSearchPage"
|
name="CSearchPage"
|
||||||
|
|
|
@ -0,0 +1,90 @@
|
||||||
|
/**********************************************************************
|
||||||
|
* Copyright (c) 2002,2003 QNX Software Systems and others.
|
||||||
|
* All rights reserved. This program and the accompanying materials
|
||||||
|
* are made available under the terms of the Common Public License v1.0
|
||||||
|
* which accompanies this distribution, and is available at
|
||||||
|
* http://www.eclipse.org/legal/cpl-v10.html
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* QNX Software Systems - Initial API and implementation
|
||||||
|
***********************************************************************/
|
||||||
|
|
||||||
|
package org.eclipse.cdt.ui.actions;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.internal.ui.editor.CEditorMessages;
|
||||||
|
import org.eclipse.jface.action.Action;
|
||||||
|
import org.eclipse.ui.IWorkbenchPage;
|
||||||
|
import org.eclipse.ui.IWorkbenchPart;
|
||||||
|
import org.eclipse.ui.part.IShowInSource;
|
||||||
|
import org.eclipse.ui.part.IShowInTarget;
|
||||||
|
import org.eclipse.ui.texteditor.ITextEditor;
|
||||||
|
import org.eclipse.ui.texteditor.IUpdate;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This class will open the C/C++ Projects view and highlight the
|
||||||
|
* selected resource matching the current resouce being edited in
|
||||||
|
* the C/C++ Editor. It uses the IShowInSource/IShowInTarget to
|
||||||
|
* accomplish this task so as to provide some additional portability
|
||||||
|
* and future proofing.
|
||||||
|
*/
|
||||||
|
public class ShowInCViewAction extends Action implements IUpdate {
|
||||||
|
private ITextEditor fEditor;
|
||||||
|
final String CVIEW_ID = "org.eclipse.cdt.ui.CView";
|
||||||
|
|
||||||
|
public ShowInCViewAction() {
|
||||||
|
this(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ShowInCViewAction(ITextEditor editor) {
|
||||||
|
super(CEditorMessages.getString("ShowInCView.label")); //$NON-NLS-1$
|
||||||
|
setToolTipText(CEditorMessages.getString("ShowInCView.tooltip")); //$NON-NLS-1$
|
||||||
|
setDescription(CEditorMessages.getString("ShowInCView.description")); //$NON-NLS-1$
|
||||||
|
|
||||||
|
fEditor= editor;
|
||||||
|
//WorkbenchHelp.setHelp(this, new Object[] { IJavaHelpContextIds.ADD_IMPORT_ON_SELECTION_ACTION });
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see IAction#actionPerformed
|
||||||
|
*/
|
||||||
|
public void run() {
|
||||||
|
if(fEditor == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Locate a source and a target for us to use
|
||||||
|
IShowInTarget showInTarget;
|
||||||
|
IShowInSource showInSource;
|
||||||
|
try {
|
||||||
|
IWorkbenchPage page = fEditor.getEditorSite().getWorkbenchWindow().getActivePage();
|
||||||
|
IWorkbenchPart part = page.showView(CVIEW_ID);
|
||||||
|
if(part instanceof IShowInTarget) {
|
||||||
|
showInTarget = (IShowInTarget)part;
|
||||||
|
} else {
|
||||||
|
showInTarget = (IShowInTarget)part.getAdapter(IShowInTarget.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(fEditor instanceof IShowInSource) {
|
||||||
|
showInSource = (IShowInSource)fEditor;
|
||||||
|
} else {
|
||||||
|
showInSource = (IShowInSource)fEditor.getAdapter(IShowInSource.class);
|
||||||
|
}
|
||||||
|
} catch(Exception ex) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(showInTarget == null || showInSource == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Now go ahead and show it (assuming that you can!)
|
||||||
|
showInTarget.show(showInSource.getShowInContext());
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.ui.texteditor.IUpdate#update()
|
||||||
|
*/
|
||||||
|
public void update() {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue