@Override public void partActivated(IWorkbenchPartReference partRef) { if (isThisPart(partRef)) { fActive = true; IContextService contextService = getSite().getService(IContextService.class); if(contextService != null) { fActivatedContext = contextService.activateContext(IConsoleConstants.ID_CONSOLE_VIEW); activateParticipants(fActiveConsole); } } }
public void consolesRemoved(final IConsole[] consoles) { if (isAvailable()) { Runnable r = new Runnable() { public void run() { for (int i = 0; i < consoles.length; i++) { if (isAvailable()) { IConsole console = consoles[i]; fStack.remove(console); ConsoleWorkbenchPart part = (ConsoleWorkbenchPart)fConsoleToPart.get(console); if (part != null) { partClosed(part); } if (getConsole() == null) { IConsole[] available = getConsoleManager().getConsoles(); if (available.length > 0) { display(available[available.length - 1]); } } } } } }; asyncExec(r); } }
@Override public void partDeactivated(IWorkbenchPartReference partRef) { if (isThisPart(partRef)) { fActive = false; IContextService contextService = getSite().getService(IContextService.class); if(contextService != null) { contextService.deactivateContext(fActivatedContext); deactivateParticipants(fActiveConsole); } } }
public void partActivated(IWorkbenchPartReference partRef) { if (isThisPart(partRef)) { fActive = true; activateParticipants(fActiveConsole); } }
public void partDeactivated(IWorkbenchPartReference partRef) { if (isThisPart(partRef)) { fActive = false; deactivateParticipants(fActiveConsole); } }
protected void showPageRec(PageRec pageRec) { if (fActiveConsole != null && pageRec.page != getDefaultPage() && fPinned && fConsoleToPart.size() > 1) { IConsole console = (IConsole)fPartToConsole.get(pageRec.part); if (!fStack.contains(console)) { deactivateParticipants(tos); activateParticipants(fActiveConsole); updateTitle(); updateHelp(); IPage page = getCurrentPage(); if (page instanceof IOConsolePage) { ((IOConsolePage)page).setAutoScroll(!fScrollLock);
/** * Creates this view's underlying viewer and actions. * Hooks a pop-up menu to the underlying viewer's control, * as well as a key listener. When the delete key is pressed, * the <code>REMOVE_ACTION</code> is invoked. Hooks help to * this view. Subclasses must implement the following methods * which are called in the following order when a view is * created:<ul> * <li><code>createViewer(Composite)</code> - the context * menu is hooked to the viewer's control.</li> * <li><code>createActions()</code></li> * <li><code>configureToolBar(IToolBarManager)</code></li> * <li><code>getHelpContextId()</code></li> * </ul> * @see IWorkbenchPart#createPartControl(Composite) */ @Override public void createPartControl(Composite parent) { super.createPartControl(parent); createActions(); IToolBarManager tbm= getViewSite().getActionBars().getToolBarManager(); configureToolBar(tbm); updateForExistingConsoles(); getViewSite().getActionBars().updateActionBars(); PlatformUI.getWorkbench().getHelpSystem().setHelp(parent, IConsoleHelpContextIds.CONSOLE_VIEW); getViewSite().getPage().addPartListener((IPartListener2)this); initPageSwitcher(); }
/** * Updates the view title based on the active console */ protected void updateTitle() { IConsole console = getConsole(); if (console == null) { setContentDescription(ConsoleMessages.ConsoleView_0); } else { String newName = console.getName(); String oldName = getContentDescription(); if (newName!=null && !(newName.equals(oldName))) { setContentDescription(console.getName()); } } }
public void run() { for (int i = 0; i < consoles.length; i++) { if (isAvailable()) { IConsole console = consoles[i]; fStack.remove(console); ConsoleWorkbenchPart part = (ConsoleWorkbenchPart)fConsoleToPart.get(console); if (part != null) { partClosed(part); } if (getConsole() == null) { IConsole[] available = getConsoleManager().getConsoles(); if (available.length > 0) { display(available[available.length - 1]); } } } } } };
final IConsole console = part.getConsole(); final IPageBookViewPage page = console.createPage(this); initPage(page); page.createControl(getPageBook()); console.addPropertyChangeListener(this); IConsolePageParticipant[] consoleParticipants = ((ConsoleManager)getConsoleManager()).getPageParticipants(console); final ListenerList<IConsolePageParticipant> participants = new ListenerList<>(); for (int i = 0; i < consoleParticipants.length; i++) {
@Override public void propertyChange(PropertyChangeEvent event) { Object source = event.getSource(); if (source instanceof IConsole && event.getProperty().equals(IBasicPropertyConstants.P_TEXT)) { if (source.equals(getConsole())) { updateTitle(); } } }
protected void updateHelp() { IConsole console = getConsole(); String helpContextId = null; if (console instanceof AbstractConsole) { AbstractConsole abs = (AbstractConsole) console; helpContextId = abs.getHelpContextId(); } if (helpContextId == null) { helpContextId = IConsoleHelpContextIds.CONSOLE_VIEW; } PlatformUI.getWorkbench().getHelpSystem().setHelp(getPageBook().getParent(), helpContextId); }
/** * Initialize for existing consoles */ private void updateForExistingConsoles() { IConsoleManager manager = getConsoleManager(); // create pages for consoles IConsole[] consoles = manager.getConsoles(); consolesAdded(consoles); // add as a listener manager.addConsoleListener(this); }
@SuppressWarnings("unchecked") @Override public <T> T getAdapter(Class<T> key) { Object adpater = super.getAdapter(key); if (adpater == null) { IConsole console = getConsole(); if (console != null) { ListenerList<IConsolePageParticipant> listeners = getParticipants(console); // an adapter can be asked for before the console participants are created if (listeners != null) { for (IConsolePageParticipant iConsolePageParticipant : listeners) { IConsolePageParticipant participant = iConsolePageParticipant; adpater = participant.getAdapter(key); if (adpater != null) { return (T) adpater; } } } } } return (T) adpater; }
@Override public IStatus runInUIThread(IProgressMonitor monitor) { synchronized (list) { if (list.isEmpty()) { return Status.OK_STATUS; } IWorkbenchWindow[] workbenchWindows = PlatformUI.getWorkbench().getWorkbenchWindows(); for (int i = 0; i < workbenchWindows.length; i++) { IWorkbenchWindow window = workbenchWindows[i]; if (window != null) { IWorkbenchPage page = window.getActivePage(); if (page != null) { IViewPart part = page.findView(IConsoleConstants.ID_CONSOLE_VIEW); if (part != null && part instanceof IConsoleView) { ConsoleView view = (ConsoleView) part; if (list.contains(view.getConsole())) { Control control = view.getCurrentPage().getControl(); if (!control.isDisposed()) { control.redraw(); } } } } } } list.clear(); } return Status.OK_STATUS; } }
for (Iterator iter = fConsoleViews.iterator(); iter.hasNext();) { ConsoleView consoleView = (ConsoleView) iter.next(); if (consoleView.getSite().getPage().equals(page)) { boolean consoleVisible = page.isPartVisible(consoleView); if (consoleVisible) { page.bringToTop(consoleView); consoleView.display(console);
@Override public int getCurrentPageIndex() { IConsole currentConsole= getConsole(); IConsole[] consoles= getConsoleManager().getConsoles(); for (int i= 0; i < consoles.length; i++) { if (consoles[i].equals(currentConsole)) { return i; } } return super.getCurrentPageIndex(); } };
if (fActiveConsole != null && pageRec.page != getDefaultPage() && fPinned && fConsoleToPart.size() > 1) { IConsole console = fPartToConsole.get(pageRec.part); if (!fStack.contains(console)) { deactivateParticipants(tos); activateParticipants(fActiveConsole); updateTitle(); updateHelp(); IPage page = getCurrentPage(); if (page instanceof IOConsolePage) { ((IOConsolePage) page).setWordWrap(fWordWrap);
/** * Creates this view's underlying viewer and actions. * Hooks a pop-up menu to the underlying viewer's control, * as well as a key listener. When the delete key is pressed, * the <code>REMOVE_ACTION</code> is invoked. Hooks help to * this view. Subclasses must implement the following methods * which are called in the following order when a view is * created:<ul> * <li><code>createViewer(Composite)</code> - the context * menu is hooked to the viewer's control.</li> * <li><code>createActions()</code></li> * <li><code>configureToolBar(IToolBarManager)</code></li> * <li><code>getHelpContextId()</code></li> * </ul> * @see IWorkbenchPart#createPartControl(Composite) */ public void createPartControl(Composite parent) { super.createPartControl(parent); createActions(); IToolBarManager tbm= getViewSite().getActionBars().getToolBarManager(); configureToolBar(tbm); updateForExistingConsoles(); getViewSite().getActionBars().updateActionBars(); PlatformUI.getWorkbench().getHelpSystem().setHelp(parent, IConsoleHelpContextIds.CONSOLE_VIEW); getViewSite().getPage().addPartListener((IPartListener2)this); }