KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > ant > internal > ui > editor > outline > ToggleLinkWithEditorAction


1 /*******************************************************************************
2  * Copyright (c) 2000, 2005 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11
12 package org.eclipse.ant.internal.ui.editor.outline;
13
14 import org.eclipse.ant.internal.ui.AntUIImages;
15 import org.eclipse.ant.internal.ui.AntUIPlugin;
16 import org.eclipse.ant.internal.ui.IAntUIConstants;
17 import org.eclipse.ant.internal.ui.IAntUIPreferenceConstants;
18 import org.eclipse.ant.internal.ui.editor.AntEditor;
19 import org.eclipse.jface.action.Action;
20
21 /**
22  * This action toggles whether the Ant Outline page links its selection to the
23  * active editor.
24  *
25  * @since 3.0
26  */

27 public class ToggleLinkWithEditorAction extends Action {
28     
29     AntEditor fEditor;
30     
31     public ToggleLinkWithEditorAction(AntEditor editor) {
32         super(AntOutlineMessages.ToggleLinkWithEditorAction_0);
33         boolean isLinkingEnabled = AntUIPlugin.getDefault().getPreferenceStore().getBoolean(IAntUIPreferenceConstants.OUTLINE_LINK_WITH_EDITOR);
34         setChecked(isLinkingEnabled);
35         fEditor = editor;
36         setToolTipText(AntOutlineMessages.ToggleLinkWithEditorAction_1);
37         setDescription(AntOutlineMessages.ToggleLinkWithEditorAction_2);
38         setImageDescriptor(AntUIImages.getImageDescriptor(IAntUIConstants.IMG_LINK_WITH_EDITOR));
39     }
40     
41     public void run() {
42         AntUIPlugin.getDefault().getPreferenceStore().setValue(IAntUIPreferenceConstants.OUTLINE_LINK_WITH_EDITOR, isChecked());
43         if (isChecked())
44             fEditor.synchronizeOutlinePage(false);
45     }
46 }
47
Popular Tags