|
1 | 1 | /******************************************************************************* |
2 | | - * Copyright (c) 2000, 2018 IBM Corporation and others. |
| 2 | + * Copyright (c) 2000, 2026 IBM Corporation and others. |
3 | 3 | * |
4 | 4 | * This program and the accompanying materials |
5 | 5 | * are made available under the terms of the Eclipse Public License 2.0 |
|
29 | 29 | import org.eclipse.jface.action.Separator; |
30 | 30 | import org.eclipse.jface.action.ToolBarManager; |
31 | 31 | import org.eclipse.jface.resource.ImageDescriptor; |
| 32 | +import org.eclipse.jface.resource.JFaceResources; |
| 33 | +import org.eclipse.jface.resource.LocalResourceManager; |
32 | 34 | import org.eclipse.jface.util.IPropertyChangeListener; |
33 | 35 | import org.eclipse.jface.util.PropertyChangeEvent; |
34 | 36 | import org.eclipse.jface.viewers.IBasicPropertyConstants; |
35 | 37 | import org.eclipse.swt.custom.StyledText; |
36 | 38 | import org.eclipse.swt.events.MouseAdapter; |
37 | 39 | import org.eclipse.swt.events.MouseEvent; |
| 40 | +import org.eclipse.swt.graphics.Image; |
38 | 41 | import org.eclipse.swt.graphics.Point; |
39 | 42 | import org.eclipse.swt.widgets.Composite; |
40 | 43 | import org.eclipse.swt.widgets.Control; |
@@ -123,6 +126,9 @@ public class ConsoleView extends PageBookView implements IConsoleView, IConsoleL |
123 | 126 | private boolean fScrollLock; |
124 | 127 | private boolean fWordWrap; |
125 | 128 |
|
| 129 | + private Image currentIcon, defaultIcon; |
| 130 | + private LocalResourceManager localResManager; |
| 131 | + |
126 | 132 | private boolean isAvailable() { |
127 | 133 | return getPageBook() != null && !getPageBook().isDisposed(); |
128 | 134 | } |
@@ -184,6 +190,7 @@ protected void showPageRec(PageRec pageRec) { |
184 | 190 | } |
185 | 191 | updateTitle(); |
186 | 192 | updateHelp(); |
| 193 | + updateIcon(); |
187 | 194 | // update console actions |
188 | 195 | if (fPinAction != null) { |
189 | 196 | fPinAction.update(); |
@@ -269,6 +276,30 @@ protected void updateHelp() { |
269 | 276 | PlatformUI.getWorkbench().getHelpSystem().setHelp(getPageBook().getParent(), helpContextId); |
270 | 277 | } |
271 | 278 |
|
| 279 | + protected void updateIcon() { |
| 280 | + IConsole console = getConsole(); |
| 281 | + if (console == null) { |
| 282 | + return; |
| 283 | + } |
| 284 | + Image newImage = null; |
| 285 | + |
| 286 | + if (console != null) { |
| 287 | + ImageDescriptor desc = console.getImageDescriptor(); |
| 288 | + if (desc != null) { |
| 289 | + newImage = localResManager.create(desc); |
| 290 | + } |
| 291 | + } |
| 292 | + |
| 293 | + if (newImage == null) { |
| 294 | + newImage = defaultIcon; |
| 295 | + } |
| 296 | + |
| 297 | + if (!newImage.equals(currentIcon)) { |
| 298 | + currentIcon = newImage; |
| 299 | + setTitleImage(currentIcon); |
| 300 | + } |
| 301 | + } |
| 302 | + |
272 | 303 | @Override |
273 | 304 | protected void doDestroyPage(IWorkbenchPart part, PageRec pageRecord) { |
274 | 305 | IConsole console = fPartToConsole.get(part); |
@@ -376,6 +407,10 @@ public void dispose() { |
376 | 407 | fOpenConsoleAction.dispose(); |
377 | 408 | fOpenConsoleAction = null; |
378 | 409 | } |
| 410 | + if (localResManager != null) { |
| 411 | + localResManager.dispose(); |
| 412 | + localResManager = null; |
| 413 | + } |
379 | 414 | } |
380 | 415 |
|
381 | 416 | /** |
@@ -575,6 +610,9 @@ public void createPartControl(Composite parent) { |
575 | 610 | PlatformUI.getWorkbench().getHelpSystem().setHelp(parent, IConsoleHelpContextIds.CONSOLE_VIEW); |
576 | 611 | getViewSite().getPage().addPartListener((IPartListener2)this); |
577 | 612 | initPageSwitcher(); |
| 613 | + localResManager = new LocalResourceManager(JFaceResources.getResources(), parent); |
| 614 | + defaultIcon = ConsolePluginImages.getImage(IConsoleConstants.IMG_VIEW_CONSOLE); |
| 615 | + currentIcon = defaultIcon; |
578 | 616 | } |
579 | 617 |
|
580 | 618 | /** |
|
0 commit comments