Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[cdt-patch] Patch for PR 44892

In my continuing quest for parity at the platform level with all of the
features we have missed during the last few busy months of activity, here
is a patch which addresses the fact that the CDT has no support for the
ShowIn navigation hook.

This patch hits three files:
CEditor: To add support to provide a ShowInContext
CView: To add support for receiving an IShowInContext
CPerspectiveFactory: To add support for adding the show in binding
                     to the CView and the Navigator.

The patch is _totally_ trivial and was taken against CDT 1.2 branch.

For the ChangeLog:
 Add missing support for the Nagivate > ShowIn hook into the 
 C/C++ Editor, C/C++ Project View and add the hooks into the
 perspective.

Index: src/org/eclipse/cdt/internal/ui/CPerspectiveFactory.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CPerspectiveFactory.java,v
retrieving revision 1.5
diff -u -r1.5 CPerspectiveFactory.java
--- src/org/eclipse/cdt/internal/ui/CPerspectiveFactory.java	25 Sep 2003 13:45:28 -0000	1.5
+++ src/org/eclipse/cdt/internal/ui/CPerspectiveFactory.java	15 Oct 2003 12:44:50 -0000
@@ -27,10 +27,10 @@
  		String editorArea = layout.getEditorArea();
 		
 		IFolderLayout folder1= layout.createFolder("topLeft", IPageLayout.LEFT, (float)0.25, editorArea);
-		folder1.addView(CUIPlugin.CVIEW_ID);
 		folder1.addView(IPageLayout.ID_RES_NAV);
 		folder1.addPlaceholder(IPageLayout.ID_BOOKMARKS);
-
+		folder1.addView(CUIPlugin.CVIEW_ID);
+		
 		IFolderLayout folder2= layout.createFolder("bottom", IPageLayout.BOTTOM, (float)0.75, editorArea);
 		folder2.addView(IPageLayout.ID_TASK_LIST);
 		folder2.addView(CUIPlugin.CONSOLE_ID);
@@ -54,6 +54,10 @@
 		layout.addShowViewShortcut(CUIPlugin.CVIEW_ID);
 		layout.addShowViewShortcut(IPageLayout.ID_RES_NAV);
 		layout.addShowViewShortcut(IPageLayout.ID_PROP_SHEET);
+
+		// link - things we should do
+		layout.addShowInPart(CUIPlugin.CVIEW_ID);
+		layout.addShowInPart(IPageLayout.ID_RES_NAV);
 
 		// new actions - C project creation wizard
 		layout.addNewWizardShortcut(CUIPlugin.CLASS_WIZARD_ID);
Index: src/org/eclipse/cdt/internal/ui/cview/CView.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/CView.java,v
retrieving revision 1.33
diff -u -r1.33 CView.java
--- src/org/eclipse/cdt/internal/ui/cview/CView.java	23 Sep 2003 19:50:48 -0000	1.33
+++ src/org/eclipse/cdt/internal/ui/cview/CView.java	15 Oct 2003 12:44:51 -0000
@@ -37,8 +37,8 @@
 import org.eclipse.cdt.internal.ui.util.EditorUtility;
 import org.eclipse.cdt.internal.ui.util.ProblemTreeViewer;
 import org.eclipse.cdt.ui.CElementContentProvider;
-import org.eclipse.cdt.ui.CUIPlugin;
 import org.eclipse.cdt.ui.CLocalSelectionTransfer;
+import org.eclipse.cdt.ui.CUIPlugin;
 import org.eclipse.cdt.ui.PreferenceConstants;
 import org.eclipse.core.resources.ICommand;
 import org.eclipse.core.resources.IContainer;
@@ -121,8 +121,10 @@
 import org.eclipse.ui.actions.WorkingSetFilterActionGroup;
 import org.eclipse.ui.dialogs.PropertyDialogAction;
 import org.eclipse.ui.part.ISetSelectionTarget;
+import org.eclipse.ui.part.IShowInTarget;
 import org.eclipse.ui.part.PluginTransfer;
 import org.eclipse.ui.part.ResourceTransfer;
+import org.eclipse.ui.part.ShowInContext;
 import org.eclipse.ui.part.ViewPart;
 import org.eclipse.ui.views.framelist.BackAction;
 import org.eclipse.ui.views.framelist.ForwardAction;
@@ -135,7 +137,7 @@
 
 
 public class CView extends ViewPart implements IMenuListener, ISetSelectionTarget,
-	IPropertyChangeListener {
+	IPropertyChangeListener, IShowInTarget {
 
 	ProblemTreeViewer viewer;
 	IMemento memento;
@@ -1348,4 +1350,24 @@
 		menu.add(search);
 	}
 	
+	/* (non-Javadoc)
+	 * @see org.eclipse.ui.part.IShowInTarget#show(org.eclipse.ui.part.ShowInContext)
+	 */
+	public boolean show(ShowInContext context) {
+		//@@@ Do something with the selection later?
+		//ISelection selection = context.getSelection();
+		try {
+			IEditorInput input = (IEditorInput)context.getInput();
+			if(input != null) {
+				IResource res = (IResource)input.getAdapter(IResource.class);
+				if(res != null) {
+					selectReveal(new StructuredSelection(res));
+				}
+			}
+		} catch(Exception ex) {
+			/* Ignore */
+		}
+		return false;
+	}
+
 }
Index: src/org/eclipse/cdt/internal/ui/editor/CEditor.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CEditor.java,v
retrieving revision 1.32
diff -u -r1.32 CEditor.java
--- src/org/eclipse/cdt/internal/ui/editor/CEditor.java	1 Oct 2003 13:33:39 -0000	1.32
+++ src/org/eclipse/cdt/internal/ui/editor/CEditor.java	15 Oct 2003 12:44:53 -0000
@@ -77,6 +77,8 @@
 import org.eclipse.ui.editors.text.TextEditorPreferenceConstants;
 import org.eclipse.ui.internal.editors.text.EditorsPlugin;
 import org.eclipse.ui.part.EditorActionBarContributor;
+import org.eclipse.ui.part.IShowInSource;
+import org.eclipse.ui.part.ShowInContext;
 import org.eclipse.ui.texteditor.AnnotationPreference;
 import org.eclipse.ui.texteditor.ContentAssistAction;
 import org.eclipse.ui.texteditor.DefaultMarkerAnnotationAccess;
@@ -94,7 +96,7 @@
 /**
  * C specific text editor.
  */
-public class CEditor extends TextEditor implements ISelectionChangedListener {
+public class CEditor extends TextEditor implements ISelectionChangedListener, IShowInSource {
 
 	/** The outline page */
 	protected CContentOutlinePage fOutlinePage;
@@ -890,4 +892,15 @@
                 sourceViewer.invalidateTextPresentation();
         }
     }
+    
+	/* (non-Javadoc)
+	 * @see org.eclipse.ui.part.IShowInSource#getShowInContext()
+	 * 
+	 * This is required by the IShowInSource interface for the "ShowIn" 
+	 * navigation menu generalized in Eclipse.
+	 */
+	public ShowInContext getShowInContext() {
+		return new ShowInContext( getEditorInput(), null );
+	}
+
 }

Back to the top