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.jface.action.IAction;
14: import org.eclipse.ui.PlatformUI;
15: import org.eclipse.ui.console.IConsoleView;
16: import org.eclipse.ui.texteditor.IUpdate;
17:
18: /**
19: * Pins the currently visible console in a console view.
20: */
21: public class PinConsoleAction extends Action implements IUpdate {
22:
23: private IConsoleView fView = null;
24:
25: /**
26: * Constructs a 'pin console' action
27: */
28: public PinConsoleAction(IConsoleView view) {
29: super (ConsoleMessages.PinConsoleAction_0, IAction.AS_CHECK_BOX);
30: setToolTipText(ConsoleMessages.PinConsoleAction_1);
31: setImageDescriptor(ConsolePluginImages
32: .getImageDescriptor(IInternalConsoleConstants.IMG_ELCL_PIN));
33: setDisabledImageDescriptor(ConsolePluginImages
34: .getImageDescriptor(IInternalConsoleConstants.IMG_DLCL_PIN));
35: setHoverImageDescriptor(ConsolePluginImages
36: .getImageDescriptor(IInternalConsoleConstants.IMG_LCL_PIN));
37: PlatformUI.getWorkbench().getHelpSystem().setHelp(this ,
38: IConsoleHelpContextIds.CONSOLE_PIN_CONSOLE_ACITON);
39: fView = view;
40: update();
41: }
42:
43: /* (non-Javadoc)
44: * @see org.eclipse.jface.action.IAction#run()
45: */
46: public void run() {
47: fView.setPinned(isChecked());
48: }
49:
50: /* (non-Javadoc)
51: * @see org.eclipse.ui.texteditor.IUpdate#update()
52: */
53: public void update() {
54: setEnabled(fView.getConsole() != null);
55: setChecked(fView.isPinned());
56: }
57: }
|