KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > pde > internal > ui > editor > FormEntryAdapter


1 /*******************************************************************************
2  * Copyright (c) 2003, 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.pde.internal.ui.editor;
12
13 import org.eclipse.jface.action.IStatusLineManager;
14 import org.eclipse.jface.text.ITextSelection;
15 import org.eclipse.jface.text.TextSelection;
16 import org.eclipse.pde.internal.ui.parts.FormEntry;
17 import org.eclipse.pde.internal.ui.parts.IFormEntryListener;
18 import org.eclipse.ui.IActionBars;
19 import org.eclipse.ui.forms.events.HyperlinkEvent;
20
21 public class FormEntryAdapter implements IFormEntryListener {
22     private IContextPart contextPart;
23     protected IActionBars actionBars;
24
25     public FormEntryAdapter(IContextPart contextPart) {
26         this(contextPart, null);
27     }
28     public FormEntryAdapter(IContextPart contextPart, IActionBars actionBars) {
29         this.contextPart = contextPart;
30         this.actionBars = actionBars;
31     }
32     public void focusGained(FormEntry entry) {
33         ITextSelection selection = new TextSelection(1,1);
34         contextPart.getPage().getPDEEditor().getContributor().updateSelectableActions(selection);
35     }
36     /* (non-Javadoc)
37      * @see org.eclipse.pde.internal.ui.newparts.IFormEntryListener#textDirty(org.eclipse.pde.internal.ui.newparts.FormEntry)
38      */

39     public void textDirty(FormEntry entry) {
40         contextPart.fireSaveNeeded();
41     }
42     /* (non-Javadoc)
43      * @see org.eclipse.pde.internal.ui.newparts.IFormEntryListener#textValueChanged(org.eclipse.pde.internal.ui.newparts.FormEntry)
44      */

45     public void textValueChanged(FormEntry entry) {
46     }
47     /* (non-Javadoc)
48      * @see org.eclipse.pde.internal.ui.newparts.IFormEntryListener#browseButtonSelected(org.eclipse.pde.internal.ui.newparts.FormEntry)
49      */

50     public void browseButtonSelected(FormEntry entry) {
51     }
52     /* (non-Javadoc)
53      * @see org.eclipse.ui.forms.events.HyperlinkListener#linkEntered(org.eclipse.ui.forms.events.HyperlinkEvent)
54      */

55     public void linkEntered(HyperlinkEvent e) {
56         if (actionBars==null) return;
57         IStatusLineManager mng = actionBars.getStatusLineManager();
58         mng.setMessage(e.getLabel());
59     }
60     /* (non-Javadoc)
61      * @see org.eclipse.ui.forms.events.HyperlinkListener#linkExited(org.eclipse.ui.forms.events.HyperlinkEvent)
62      */

63     public void linkExited(HyperlinkEvent e) {
64         if (actionBars==null) return;
65         IStatusLineManager mng = actionBars.getStatusLineManager();
66         mng.setMessage(null);
67     }
68     /* (non-Javadoc)
69      * @see org.eclipse.ui.forms.events.HyperlinkListener#linkActivated(org.eclipse.ui.forms.events.HyperlinkEvent)
70      */

71     public void linkActivated(HyperlinkEvent e) {
72     }
73     public void selectionChanged(FormEntry entry) {
74         ITextSelection selection = new TextSelection(1,1);
75         contextPart.getPage().getPDEEditor().getContributor().updateSelectableActions(selection);
76     }
77 }
78
Popular Tags