use of org.eclipse.ui.part.IPage in project tdi-studio-se by Talend.
the class FindDialog method getFindTarget.
/**
* Gets the target for find action.
*
* @return The target for find action
*/
private static IFindTarget getFindTarget() {
IWorkbenchPart activePart = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActivePart();
if (activePart instanceof IFindTarget) {
return (IFindTarget) activePart;
}
PropertySheet part = (PropertySheet) activePart;
if (part == null) {
return null;
}
IPage page = part.getCurrentPage();
if (!(page instanceof TabbedPropertySheetPage)) {
return null;
}
TabbedPropertySheetPage propertySheetPage = (TabbedPropertySheetPage) page;
ISection[] sections = propertySheetPage.getCurrentTab().getSections();
if (sections.length != 1) {
return null;
}
ISection section = sections[0];
if (!(section instanceof IFindTarget)) {
return null;
}
return (IFindTarget) section;
}
use of org.eclipse.ui.part.IPage in project eclipse.platform.text by eclipse.
the class SearchView method doDestroyPage.
@Override
protected void doDestroyPage(IWorkbenchPart part, PageRec pageRecord) {
IPage page = pageRecord.page;
page.dispose();
pageRecord.dispose();
// empty cross-reference cache
fPartsToPages.remove(part);
}
use of org.eclipse.ui.part.IPage in project jbosstools-hibernate by jbosstools.
the class HQLEditorTest method testSingleLineCommentsCutOff.
@Test
public void testSingleLineCommentsCutOff() throws PartInitException {
String query = // $NON-NLS-1$
"from pack.Article a\n" + // $NON-NLS-1$
"where a.articleid in (:a, :b) --or a.articleid = :c";
IEditorPart editorPart = HibernateConsolePlugin.getDefault().openScratchHQLEditor(consoleConfiguration.getName(), query);
// $NON-NLS-1$
Assert.assertTrue("Opened editor is not HQLEditor", editorPart instanceof HQLEditor);
HQLEditor editor = (HQLEditor) editorPart;
Assert.assertEquals(editor.getEditorText(), query);
// $NON-NLS-1$ //$NON-NLS-2$
Assert.assertFalse("Comments were not cut off", editor.getQueryString().contains("--"));
QueryInputModel model = editor.getQueryInputModel();
Assert.assertTrue(model.getParameterCount() == 0);
IViewPart view = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().showView(// $NON-NLS-1$
"org.hibernate.eclipse.console.views.QueryParametersView");
// $NON-NLS-1$
Assert.assertNotNull("View was not opened", view);
// $NON-NLS-1$
Assert.assertTrue("Opened view is not QueryParametersView", view instanceof QueryParametersView);
QueryParametersView paramView = (QueryParametersView) view;
IPage ipage = paramView.getCurrentPage();
// $NON-NLS-1$
Assert.assertNotNull("Current Page is NULL", ipage);
// $NON-NLS-1$
Assert.assertTrue("Page is not Query Parameters Page", ipage instanceof QueryParametersPage);
QueryParametersPage page = (QueryParametersPage) ipage;
IToolBarManager manager = page.getSite().getActionBars().getToolBarManager();
IContributionItem[] items = manager.getItems();
ActionContributionItem addParamItem = null;
for (int i = 0; i < items.length; i++) {
ActionContributionItem item = (ActionContributionItem) items[i];
if (item.getAction().getClass().getName().endsWith("NewRowAction")) {
// $NON-NLS-1$
addParamItem = item;
break;
}
}
Assert.assertNotNull(HibernateConsoleMessages.QueryParametersPage_add_query_parameter_tooltip + " item not found", // $NON-NLS-1$
addParamItem);
// add query parameters automatically
addParamItem.getAction().run();
// a and b
Assert.assertTrue(model.getParameterCount() == 2);
}
use of org.eclipse.ui.part.IPage in project egit by eclipse.
the class MultiPageEditorContentOutlinePage method createControl.
@Override
public void createControl(Composite parent) {
book = new PageBook(parent, SWT.NONE);
emptyPage = new MessagePage();
emptyPage.createControl(book);
emptyPage.setMessage(UIText.MultiPageEditorContentOutlinePage_NoOutline);
Object activePage = editorPart.getSelectedPage();
if (activePage instanceof IEditorPart) {
showPage(createOutlinePage((IEditorPart) activePage));
} else {
currentPage = emptyPage;
book.showPage(emptyPage.getControl());
}
pageListener = (event) -> {
Object newPage = event.getSelectedPage();
if (!(newPage instanceof IEditorPart)) {
showPage(emptyPage);
return;
}
IPage newOutlinePage = pages.get(newPage);
if (newOutlinePage == null) {
newOutlinePage = createOutlinePage((IEditorPart) newPage);
}
showPage(newOutlinePage);
};
editorPart.addPageChangedListener(pageListener);
}
use of org.eclipse.ui.part.IPage in project egit by eclipse.
the class MultiPageEditorContentOutlinePage method createOutlinePage.
private IPage createOutlinePage(IEditorPart editor) {
IContentOutlinePage outlinePage = AdapterUtils.adapt(editor, IContentOutlinePage.class);
if (outlinePage == null) {
pages.put(editor, emptyPage);
return emptyPage;
}
pages.put(editor, outlinePage);
if (outlinePage instanceof NestedContentOutlinePage) {
((Page) outlinePage).init(getSite());
}
SubActionBars pageBars = new SubActionBars(getSite().getActionBars());
bars.put(outlinePage, pageBars);
return outlinePage;
}
Aggregations