KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > ant > internal > ui > editor > EditorSynchronizer


1 /*******************************************************************************
2  * Copyright (c) 2000, 2006 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 package org.eclipse.ant.internal.ui.editor;
12
13 import org.eclipse.core.runtime.Assert;
14 import org.eclipse.jface.text.link.ILinkedModeListener;
15 import org.eclipse.jface.text.link.LinkedModeModel;
16
17 /**
18  * Synchronizes the Ant editor with the state of its linked mode
19  *
20  * @since 3.1
21  */

22 public class EditorSynchronizer implements ILinkedModeListener {
23     
24     private final AntEditor fEditor;
25     private final boolean fWasOccurrencesOn;
26     
27     /**
28      * Creates a new synchronizer.
29      *
30      * @param editor the Ant editor that will be
31      * synchonized with the linked mode
32      */

33     public EditorSynchronizer(AntEditor editor) {
34         Assert.isLegal(editor != null);
35         fEditor= editor;
36         fWasOccurrencesOn= fEditor.isMarkingOccurrences();
37         fEditor.setInLinkedMode(true, fWasOccurrencesOn);
38     }
39
40     /*
41      * @see org.eclipse.jface.text.link.ILinkedModeListener#left(org.eclipse.jface.text.link.LinkedModeModel, int)
42      */

43     public void left(LinkedModeModel environment, int flags) {
44         fEditor.setInLinkedMode(false, fWasOccurrencesOn);
45     }
46
47     /*
48      * @see org.eclipse.jface.text.link.ILinkedModeListener#suspend(org.eclipse.jface.text.link.LinkedModeModel)
49      */

50     public void suspend(LinkedModeModel environment) {
51     }
52
53     /*
54      * @see org.eclipse.jface.text.link.ILinkedModeListener#resume(org.eclipse.jface.text.link.LinkedModeModel, int)
55      */

56     public void resume(LinkedModeModel environment, int flags) {
57     }
58 }
Popular Tags