mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-10 01:35:39 +02:00
Proper handling of subclasses in getAdapter method.
This commit is contained in:
parent
628e0329b2
commit
106afe4e80
1 changed files with 14 additions and 19 deletions
|
@ -1523,7 +1523,7 @@ public class CEditor extends TextEditor implements ICEditor, ISelectionChangedLi
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the outline page of the c-editor.
|
* Returns the outline page of the C/C++ editor.
|
||||||
* @return Outline page.
|
* @return Outline page.
|
||||||
*/
|
*/
|
||||||
public CContentOutlinePage getOutlinePage() {
|
public CContentOutlinePage getOutlinePage() {
|
||||||
|
@ -1535,15 +1535,12 @@ public class CEditor extends TextEditor implements ICEditor, ISelectionChangedLi
|
||||||
return fOutlinePage;
|
return fOutlinePage;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class)
|
|
||||||
*/
|
|
||||||
@SuppressWarnings("rawtypes")
|
|
||||||
@Override
|
@Override
|
||||||
public Object getAdapter(Class required) {
|
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||||
if (IContentOutlinePage.class.equals(required)) {
|
public Object getAdapter(Class adapterClass) {
|
||||||
|
if (adapterClass.isAssignableFrom(IContentOutlinePage.class)) {
|
||||||
return getOutlinePage();
|
return getOutlinePage();
|
||||||
} else if (required == IShowInTargetList.class) {
|
} else if (adapterClass.isAssignableFrom(IShowInTargetList.class)) {
|
||||||
return new IShowInTargetList() {
|
return new IShowInTargetList() {
|
||||||
@Override
|
@Override
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
|
@ -1551,9 +1548,8 @@ public class CEditor extends TextEditor implements ICEditor, ISelectionChangedLi
|
||||||
return new String[] { IPageLayout.ID_PROJECT_EXPLORER, IPageLayout.ID_OUTLINE, IPageLayout.ID_RES_NAV };
|
return new String[] { IPageLayout.ID_PROJECT_EXPLORER, IPageLayout.ID_OUTLINE, IPageLayout.ID_RES_NAV };
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
} else if (required == IShowInSource.class) {
|
} else if (adapterClass.isAssignableFrom(IShowInSource.class)) {
|
||||||
ICElement ce= null;
|
ICElement ce= getElementAt(getSourceViewer().getSelectedRange().x, false);
|
||||||
ce= getElementAt(getSourceViewer().getSelectedRange().x, false);
|
|
||||||
if (ce instanceof ITranslationUnit) {
|
if (ce instanceof ITranslationUnit) {
|
||||||
ce = null;
|
ce = null;
|
||||||
}
|
}
|
||||||
|
@ -1564,24 +1560,23 @@ public class CEditor extends TextEditor implements ICEditor, ISelectionChangedLi
|
||||||
return new ShowInContext(getEditorInput(), selection);
|
return new ShowInContext(getEditorInput(), selection);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
} else if (ProjectionAnnotationModel.class.equals(required)) {
|
} else if (adapterClass.isAssignableFrom(ProjectionAnnotationModel.class)) {
|
||||||
if (fProjectionSupport != null) {
|
if (fProjectionSupport != null) {
|
||||||
Object adapter = fProjectionSupport.getAdapter(getSourceViewer(), required);
|
Object adapter = fProjectionSupport.getAdapter(getSourceViewer(), adapterClass);
|
||||||
if (adapter != null)
|
if (adapter != null)
|
||||||
return adapter;
|
return adapter;
|
||||||
}
|
}
|
||||||
} else if (IContextProvider.class.equals(required)) {
|
} else if (adapterClass.isAssignableFrom(IContextProvider.class)) {
|
||||||
return new CUIHelp.CUIHelpContextProvider(this);
|
return new CUIHelp.CUIHelpContextProvider(this);
|
||||||
} else if (IGotoMarker.class.equals(required)) {
|
} else if (adapterClass.isAssignableFrom(IGotoMarker.class)) {
|
||||||
IGotoMarker gotoMarker= new GotoMarkerAdapter();
|
return new GotoMarkerAdapter();
|
||||||
return gotoMarker;
|
} else if (adapterClass.isAssignableFrom(ITemplatesPage.class)) {
|
||||||
} else if (ITemplatesPage.class.equals(required)) {
|
|
||||||
if (fTemplatesPage == null) {
|
if (fTemplatesPage == null) {
|
||||||
fTemplatesPage = new CTemplatesPage(this);
|
fTemplatesPage = new CTemplatesPage(this);
|
||||||
}
|
}
|
||||||
return fTemplatesPage;
|
return fTemplatesPage;
|
||||||
}
|
}
|
||||||
return super.getAdapter(required);
|
return super.getAdapter(adapterClass);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Add table
Reference in a new issue