private void internalShowSearchPage(ISearchResultPage page, ISearchResult search) { // detach the previous page. ISearchResultPage currentPage = (ISearchResultPage) getCurrentPage(); if (fCurrentSearch != null && currentPage != null) { fSearchViewStates.put(fCurrentSearch, currentPage.getUIState()); currentPage.setInput(null, null); } fCurrentSearch = search; if (page != null) { if (page != currentPage) { DummyPart part = fPagesToParts.get(page); if (part == null) { part = new DummyPart(); fPagesToParts.put(page, part); fPartsToPages.put(part, page); page.setViewPart(this); } part.setLastActivation(++fActivationCount); partActivated(part); } // connect to the new pages Object uiState = search != null ? fSearchViewStates.get(search) : null; page.setInput(search, uiState); } updatePartName(); updateLabel(); updateCancelAction(); updateHelpContextID(page); }
@Override public void saveState(IMemento memento) { for (Iterator<Entry<IPageBookViewPage, DummyPart>> iter = fPagesToParts.entrySet().iterator(); iter.hasNext(); ) { Entry<IPageBookViewPage, DummyPart> entry = iter.next(); ISearchResultPage page = (ISearchResultPage) entry.getKey(); DummyPart part = entry.getValue(); IMemento child = memento.createChild(MEMENTO_TYPE, page.getID()); page.saveState(child); child.putInteger(MEMENTO_KEY_LAST_ACTIVATION, part.getLastActivation()); } }
@Override public void updateLabel() { ISearchResultPage page = getActivePage(); String label = ""; // $NON-NLS-1$ 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); } } } }
@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 (int i = 0; i < mementos.length; i++) { if (mementos[i].getID().equals(srPage.getID())) { memento = mementos[i]; break; } } } srPage.restoreState(memento); }
private void updateHelpContextID(ISearchResultPage page) { String helpContextId = null; String pageId = null; if (page != null) { pageId = page.getID(); } if (pageId != null) { helpContextId = fSearchViewPageService.getHelpContextId(pageId); } if (helpContextId == null) { helpContextId = ISearchHelpContextIds.New_SEARCH_VIEW; } PlatformUI.getWorkbench().getHelpSystem().setHelp(fPageContent.getParent(), helpContextId); }