01: /*******************************************************************************
02: * Copyright (c) 2000, 2007 IBM Corporation and others.
03: * All rights reserved. This program and the accompanying materials
04: * are made available under the terms of the Eclipse Public License v1.0
05: * which accompanies this distribution, and is available at
06: * http://www.eclipse.org/legal/epl-v10.html
07: *
08: * Contributors:
09: * IBM Corporation - initial API and implementation
10: *******************************************************************************/package org.eclipse.ui.internal.console;
11:
12: import org.eclipse.jface.action.Action;
13: import org.eclipse.ui.console.IConsole;
14: import org.eclipse.ui.console.IConsoleView;
15:
16: /**
17: * Shows a specific console in the console view
18: */
19: public class ShowConsoleAction extends Action {
20:
21: private IConsole fConsole;
22: private IConsoleView fView;
23:
24: /* (non-Javadoc)
25: * @see org.eclipse.jface.action.IAction#run()
26: */
27: public void run() {
28: if (!fConsole.equals(fView.getConsole())) {
29: boolean pinned = fView.isPinned();
30: if (pinned) {
31: fView.setPinned(false);
32: }
33: fView.display(fConsole);
34: if (pinned) {
35: fView.setPinned(true);
36: }
37: }
38: }
39:
40: /**
41: * Constructs an action to display the given console.
42: *
43: * @param view the console view in which the given console is contained
44: * @param console the console
45: */
46: public ShowConsoleAction(IConsoleView view, IConsole console) {
47: super(console.getName(), AS_RADIO_BUTTON);
48: fConsole = console;
49: fView = view;
50: setImageDescriptor(console.getImageDescriptor());
51: }
52: }
|