Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Rennie2008-04-15 15:58:55 +0000
committerMichael Rennie2008-04-15 15:58:55 +0000
commit7511f3410eff5f52fad5feaf8bd5a92464ea2954 (patch)
treec2653524847d5651609de0763b61070da3621c49 /org.eclipse.ui.console
parent1cc0c4ea83f3ddcb49efcda6b5dbe201c5aa92db (diff)
downloadeclipse.platform.debug-7511f3410eff5f52fad5feaf8bd5a92464ea2954.tar.gz
eclipse.platform.debug-7511f3410eff5f52fad5feaf8bd5a92464ea2954.tar.xz
eclipse.platform.debug-7511f3410eff5f52fad5feaf8bd5a92464ea2954.zip
Bug 220611 Add PageSwitcher command to the Console View
Diffstat (limited to 'org.eclipse.ui.console')
-rw-r--r--org.eclipse.ui.console/src/org/eclipse/ui/internal/console/ConsoleView.java43
-rw-r--r--org.eclipse.ui.console/src/org/eclipse/ui/internal/console/ShowConsoleAction.java23
2 files changed, 58 insertions, 8 deletions
diff --git a/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/ConsoleView.java b/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/ConsoleView.java
index 0d2a38278..139ab6968 100644
--- a/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/ConsoleView.java
+++ b/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/ConsoleView.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -18,12 +18,16 @@ import java.util.Map;
import org.eclipse.core.runtime.ISafeRunnable;
import org.eclipse.core.runtime.ListenerList;
import org.eclipse.core.runtime.SafeRunner;
+
+import org.eclipse.swt.widgets.Composite;
+
import org.eclipse.jface.action.IToolBarManager;
import org.eclipse.jface.action.Separator;
+import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.util.IPropertyChangeListener;
import org.eclipse.jface.util.PropertyChangeEvent;
import org.eclipse.jface.viewers.IBasicPropertyConstants;
-import org.eclipse.swt.widgets.Composite;
+
import org.eclipse.ui.IPartListener2;
import org.eclipse.ui.IViewReference;
import org.eclipse.ui.IViewSite;
@@ -43,6 +47,7 @@ import org.eclipse.ui.part.IPageBookViewPage;
import org.eclipse.ui.part.MessagePage;
import org.eclipse.ui.part.PageBook;
import org.eclipse.ui.part.PageBookView;
+import org.eclipse.ui.part.PageSwitcher;
import org.eclipse.ui.progress.IWorkbenchSiteProgressService;
/**
@@ -529,9 +534,43 @@ public class ConsoleView extends PageBookView implements IConsoleView, IConsoleL
getViewSite().getActionBars().updateActionBars();
PlatformUI.getWorkbench().getHelpSystem().setHelp(parent, IConsoleHelpContextIds.CONSOLE_VIEW);
getViewSite().getPage().addPartListener((IPartListener2)this);
+ initPageSwitcher();
}
/**
+ * Initialize the PageSwitcher.
+ */
+ private void initPageSwitcher() {
+ new PageSwitcher(this) {
+ public void activatePage(Object page) {
+ ShowConsoleAction.showConsole((IConsole) page, ConsoleView.this);
+ }
+
+ public ImageDescriptor getImageDescriptor(Object page) {
+ return ((IConsole) page).getImageDescriptor();
+ }
+
+ public String getName(Object page) {
+ return ((IConsole) page).getName();
+ }
+
+ public Object[] getPages() {
+ return getConsoleManager().getConsoles();
+ }
+
+ 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();
+ }
+ };
+ }
+
+ /**
* Initialize for existing consoles
*/
private void updateForExistingConsoles() {
diff --git a/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/ShowConsoleAction.java b/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/ShowConsoleAction.java
index 54e00142d..ed846b0cf 100644
--- a/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/ShowConsoleAction.java
+++ b/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/ShowConsoleAction.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -11,6 +11,7 @@
package org.eclipse.ui.internal.console;
import org.eclipse.jface.action.Action;
+
import org.eclipse.ui.console.IConsole;
import org.eclipse.ui.console.IConsoleView;
@@ -26,14 +27,24 @@ public class ShowConsoleAction extends Action {
* @see org.eclipse.jface.action.IAction#run()
*/
public void run() {
- if (!fConsole.equals(fView.getConsole())) {
- boolean pinned = fView.isPinned();
+ showConsole(fConsole, fView);
+ }
+
+ /**
+ * Shows the given console in the given console view.
+ *
+ * @param console the console to show
+ * @param consoleView the console view
+ */
+ public static void showConsole(IConsole console, IConsoleView consoleView) {
+ if (!console.equals(consoleView.getConsole())) {
+ boolean pinned = consoleView.isPinned();
if (pinned) {
- fView.setPinned(false);
+ consoleView.setPinned(false);
}
- fView.display(fConsole);
+ consoleView.display(console);
if (pinned) {
- fView.setPinned(true);
+ consoleView.setPinned(true);
}
}
}

Back to the top