1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00

The CView was opening the Binaries twice.

This commit is contained in:
Alain Magloire 2004-03-03 20:44:30 +00:00
parent 3f823a9e08
commit f99928d2d4
3 changed files with 33 additions and 20 deletions

View file

@ -1,3 +1,11 @@
2004-03-03 Alain Magloire
Fix to the CView. It was opening the file twice.
This would show when opening a binary.
* src/org/eclipse/cdt/internal/cview/CView.java
* src/org/eclipse/cdt/internal/cview/OpenFileGroup.java
2004-03-03 Hoda Amer
Added a couple of APIs to CUIPlugin + some cleanup

View file

@ -34,7 +34,6 @@ import org.eclipse.cdt.ui.CUIPlugin;
import org.eclipse.cdt.ui.PreferenceConstants;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
import org.eclipse.jface.action.IMenuListener;
@ -242,25 +241,12 @@ public class CView extends ViewPart implements ISetSelectionTarget, IPropertyCha
*/
protected void handleDoubleClick(DoubleClickEvent event) {
IStructuredSelection s = (IStructuredSelection) event.getSelection();
IEditorPart part = null;
Object o = s.getFirstElement();
if (o instanceof IAdaptable) {
IAdaptable element = (IAdaptable) o;
//System.out.println ("Double click on " + element);
try {
part = EditorUtility.openInEditor(element);
if (part != null) {
IWorkbenchPage page = getSite().getPage();
page.bringToTop(part);
if (element instanceof ISourceReference) {
EditorUtility.revealInEditor(part, (ICElement) element);
}
}
} catch (Exception e) {
if (viewer.isExpandable(o)) {
// Do not drill in to translation units of binaries.
if (o instanceof ITranslationUnit || o instanceof IBinary || o instanceof IArchive) {
return;
}
}
if (part == null && viewer.isExpandable(o)) {
viewer.setExpandedState(o, !viewer.getExpandedState(o));
}
}

View file

@ -10,6 +10,9 @@
*******************************************************************************/
package org.eclipse.cdt.internal.ui.cview;
import org.eclipse.cdt.core.model.ICElement;
import org.eclipse.cdt.core.model.ISourceReference;
import org.eclipse.cdt.internal.ui.util.EditorUtility;
import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
@ -19,6 +22,8 @@ import org.eclipse.jface.action.IMenuManager;
import org.eclipse.jface.action.MenuManager;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.ui.IActionBars;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.actions.OpenFileAction;
import org.eclipse.ui.actions.OpenInNewWindowAction;
import org.eclipse.ui.actions.OpenWithMenu;
@ -120,13 +125,27 @@ public class OpenFileGroup extends CViewActionGroup {
*/
public void runDefaultAction(IStructuredSelection selection) {
Object obj = selection.getFirstElement();
if (obj instanceof IAdaptable) {
if (obj instanceof ICElement) {
ICElement celement = (ICElement) obj;
//System.out.println ("Double click on " + element);
try {
IEditorPart part = EditorUtility.openInEditor(celement);
if (part != null) {
IWorkbenchPage page = getCView().getSite().getPage();
page.bringToTop(part);
if (celement instanceof ISourceReference) {
EditorUtility.revealInEditor(part, celement);
}
}
} catch (Exception e) {
}
} else if (obj instanceof IAdaptable) {
IResource element = (IResource)((IAdaptable)obj).getAdapter(IResource.class);
if (element instanceof IFile) {
openFileAction.selectionChanged(selection);
openFileAction.run();
}
}
}
}
}