Search in sources :

Example 1 with IPage

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;
}
Also used : ISection(org.eclipse.ui.views.properties.tabbed.ISection) IFindTarget(org.talend.designer.runtime.visualization.internal.ui.properties.cpu.actions.FindAction.IFindTarget) IPage(org.eclipse.ui.part.IPage) PropertySheet(org.eclipse.ui.views.properties.PropertySheet) IWorkbenchPart(org.eclipse.ui.IWorkbenchPart) TabbedPropertySheetPage(org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetPage)

Example 2 with IPage

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);
}
Also used : IPage(org.eclipse.ui.part.IPage)

Example 3 with IPage

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);
}
Also used : QueryParametersPage(org.hibernate.eclipse.console.views.QueryParametersPage) IViewPart(org.eclipse.ui.IViewPart) IContributionItem(org.eclipse.jface.action.IContributionItem) IEditorPart(org.eclipse.ui.IEditorPart) QueryInputModel(org.hibernate.console.QueryInputModel) IPage(org.eclipse.ui.part.IPage) ActionContributionItem(org.eclipse.jface.action.ActionContributionItem) QueryParametersView(org.hibernate.eclipse.console.views.QueryParametersView) IToolBarManager(org.eclipse.jface.action.IToolBarManager) HQLEditor(org.hibernate.eclipse.hqleditor.HQLEditor) Test(org.junit.Test)

Example 4 with IPage

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);
}
Also used : IPage(org.eclipse.ui.part.IPage) PageBook(org.eclipse.ui.part.PageBook) MessagePage(org.eclipse.ui.part.MessagePage) IEditorPart(org.eclipse.ui.IEditorPart)

Example 5 with IPage

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;
}
Also used : SubActionBars(org.eclipse.ui.SubActionBars) ContentOutlinePage(org.eclipse.ui.views.contentoutline.ContentOutlinePage) Page(org.eclipse.ui.part.Page) IContentOutlinePage(org.eclipse.ui.views.contentoutline.IContentOutlinePage) IPage(org.eclipse.ui.part.IPage) MessagePage(org.eclipse.ui.part.MessagePage) IContentOutlinePage(org.eclipse.ui.views.contentoutline.IContentOutlinePage)

Aggregations

IPage (org.eclipse.ui.part.IPage)6 IEditorPart (org.eclipse.ui.IEditorPart)2 MessagePage (org.eclipse.ui.part.MessagePage)2 TabbedPropertySheetPage (org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetPage)2 ActionContributionItem (org.eclipse.jface.action.ActionContributionItem)1 IContributionItem (org.eclipse.jface.action.IContributionItem)1 IToolBarManager (org.eclipse.jface.action.IToolBarManager)1 IViewPart (org.eclipse.ui.IViewPart)1 IWorkbenchPart (org.eclipse.ui.IWorkbenchPart)1 SubActionBars (org.eclipse.ui.SubActionBars)1 Page (org.eclipse.ui.part.Page)1 PageBook (org.eclipse.ui.part.PageBook)1 ContentOutlinePage (org.eclipse.ui.views.contentoutline.ContentOutlinePage)1 IContentOutlinePage (org.eclipse.ui.views.contentoutline.IContentOutlinePage)1 PropertySheet (org.eclipse.ui.views.properties.PropertySheet)1 PropertySheetPage (org.eclipse.ui.views.properties.PropertySheetPage)1 ISection (org.eclipse.ui.views.properties.tabbed.ISection)1 QueryInputModel (org.hibernate.console.QueryInputModel)1 QueryParametersPage (org.hibernate.eclipse.console.views.QueryParametersPage)1 QueryParametersView (org.hibernate.eclipse.console.views.QueryParametersView)1