Search in sources :

Example 6 with ISearchResultPage

use of org.eclipse.search.ui.ISearchResultPage in project eclipse.platform.text by eclipse.

the class TextSearchPage method performReplace.

@Override
public boolean performReplace() {
    try {
        IStatus status = NewSearchUI.runQueryInForeground(getContainer().getRunnableContext(), newQuery());
        if (status.matches(IStatus.CANCEL)) {
            return false;
        }
        if (!status.isOK()) {
            ErrorDialog.openError(getShell(), SearchMessages.TextSearchPage_replace_searchproblems_title, SearchMessages.TextSearchPage_replace_runproblem_message, status);
        }
        Display.getCurrent().asyncExec(() -> {
            ISearchResultViewPart view = NewSearchUI.activateSearchResultView();
            if (view != null) {
                ISearchResultPage page = view.getActivePage();
                if (page instanceof FileSearchPage) {
                    FileSearchPage filePage = (FileSearchPage) page;
                    new ReplaceAction(filePage.getSite().getShell(), (FileSearchResult) filePage.getInput(), null).run();
                }
            }
        });
        return true;
    } catch (CoreException e) {
        ErrorDialog.openError(getShell(), SearchMessages.TextSearchPage_replace_searchproblems_title, SearchMessages.TextSearchPage_replace_querycreationproblem_message, e.getStatus());
        return false;
    }
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) CoreException(org.eclipse.core.runtime.CoreException) ISearchResultViewPart(org.eclipse.search.ui.ISearchResultViewPart) ISearchResultPage(org.eclipse.search.ui.ISearchResultPage)

Example 7 with ISearchResultPage

use of org.eclipse.search.ui.ISearchResultPage in project eclipse.platform.text by eclipse.

the class SearchView method updateLabel.

@Override
public void updateLabel() {
    ISearchResultPage page = getActivePage();
    // $NON-NLS-1$
    String label = "";
    if (page != null) {
        label = LegacyActionTools.escapeMnemonics(page.getLabel());
    }
    if (!fPageContent.isDisposed()) {
        if (label.length() == 0) {
            if (fDescriptionComposite != null) {
                fDescriptionComposite.dispose();
                fDescriptionComposite = null;
                fPageContent.layout();
            }
        } else {
            if (fDescriptionComposite == null) {
                fDescriptionComposite = new Composite(fPageContent, SWT.NONE);
                fDescriptionComposite.moveAbove(null);
                GridLayout layout = new GridLayout();
                layout.marginHeight = 0;
                layout.marginWidth = 0;
                layout.verticalSpacing = 0;
                fDescriptionComposite.setLayout(layout);
                fDescriptionComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
                fDescription = new Link(fDescriptionComposite, SWT.NONE);
                GridData gridData = new GridData(SWT.FILL, SWT.CENTER, true, false);
                gridData.horizontalIndent = 5;
                fDescription.setLayoutData(gridData);
                fDescription.setText(label);
                Label separator = new Label(fDescriptionComposite, SWT.SEPARATOR | SWT.HORIZONTAL);
                separator.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
                fPageContent.layout();
            } else {
                fDescription.setText(label);
            }
        }
    }
}
Also used : GridLayout(org.eclipse.swt.layout.GridLayout) Composite(org.eclipse.swt.widgets.Composite) GridData(org.eclipse.swt.layout.GridData) Label(org.eclipse.swt.widgets.Label) ISearchResultPage(org.eclipse.search.ui.ISearchResultPage) Link(org.eclipse.swt.widgets.Link)

Example 8 with ISearchResultPage

use of org.eclipse.search.ui.ISearchResultPage in project eclipse.platform.text by eclipse.

the class SearchView method initPage.

@Override
protected void initPage(IPageBookViewPage page) {
    super.initPage(page);
    IActionBars actionBars = page.getSite().getActionBars();
    actionBars.setGlobalActionHandler(ActionFactory.REFRESH.getId(), fSearchAgainAction);
    actionBars.updateActionBars();
    fUndoRedoActionGroup.fillActionBars(actionBars);
    ISearchResultPage srPage = (ISearchResultPage) page;
    IMemento memento = null;
    if (fPageState != null) {
        IMemento[] mementos = fPageState.getChildren(MEMENTO_TYPE);
        for (IMemento memento2 : mementos) {
            if (memento2.getID().equals(srPage.getID())) {
                memento = memento2;
                break;
            }
        }
    }
    srPage.restoreState(memento);
}
Also used : ISearchResultPage(org.eclipse.search.ui.ISearchResultPage) IActionBars(org.eclipse.ui.IActionBars) IMemento(org.eclipse.ui.IMemento)

Example 9 with ISearchResultPage

use of org.eclipse.search.ui.ISearchResultPage in project eclipse.platform.text by eclipse.

the class SearchView method createDefaultPage.

@Override
protected IPage createDefaultPage(PageBook book) {
    ISearchResultPage page = new EmptySearchView();
    page.createControl(book);
    initPage(page);
    DummyPart part = new DummyPart(getSite());
    fPartsToPages.put(part, page);
    fPagesToParts.put(page, part);
    fDefaultPart = part;
    return page;
}
Also used : ISearchResultPage(org.eclipse.search.ui.ISearchResultPage)

Aggregations

ISearchResultPage (org.eclipse.search.ui.ISearchResultPage)9 IStatus (org.eclipse.core.runtime.IStatus)2 IMemento (org.eclipse.ui.IMemento)2 CoreException (org.eclipse.core.runtime.CoreException)1 ISafeRunnable (org.eclipse.core.runtime.ISafeRunnable)1 Status (org.eclipse.core.runtime.Status)1 SafeRunnable (org.eclipse.jface.util.SafeRunnable)1 ISearchResultViewPart (org.eclipse.search.ui.ISearchResultViewPart)1 GridData (org.eclipse.swt.layout.GridData)1 GridLayout (org.eclipse.swt.layout.GridLayout)1 Composite (org.eclipse.swt.widgets.Composite)1 Label (org.eclipse.swt.widgets.Label)1 Link (org.eclipse.swt.widgets.Link)1 IActionBars (org.eclipse.ui.IActionBars)1