01: /*******************************************************************************
02: * Copyright (c) 2003, 2006 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.pde.internal.ui.editor;
11:
12: import org.eclipse.jface.action.IStatusLineManager;
13: import org.eclipse.jface.text.ITextSelection;
14: import org.eclipse.jface.text.TextSelection;
15: import org.eclipse.pde.internal.ui.parts.FormEntry;
16: import org.eclipse.pde.internal.ui.parts.IFormEntryListener;
17: import org.eclipse.ui.IActionBars;
18: import org.eclipse.ui.forms.events.HyperlinkEvent;
19:
20: public class FormEntryAdapter implements IFormEntryListener {
21: private IContextPart contextPart;
22: protected IActionBars actionBars;
23:
24: public FormEntryAdapter(IContextPart contextPart) {
25: this (contextPart, null);
26: }
27:
28: public FormEntryAdapter(IContextPart contextPart,
29: IActionBars actionBars) {
30: this .contextPart = contextPart;
31: this .actionBars = actionBars;
32: }
33:
34: public void focusGained(FormEntry entry) {
35: ITextSelection selection = new TextSelection(1, 1);
36: contextPart.getPage().getPDEEditor().getContributor()
37: .updateSelectableActions(selection);
38: }
39:
40: /* (non-Javadoc)
41: * @see org.eclipse.pde.internal.ui.newparts.IFormEntryListener#textDirty(org.eclipse.pde.internal.ui.newparts.FormEntry)
42: */
43: public void textDirty(FormEntry entry) {
44: contextPart.fireSaveNeeded();
45: }
46:
47: /* (non-Javadoc)
48: * @see org.eclipse.pde.internal.ui.newparts.IFormEntryListener#textValueChanged(org.eclipse.pde.internal.ui.newparts.FormEntry)
49: */
50: public void textValueChanged(FormEntry entry) {
51: }
52:
53: /* (non-Javadoc)
54: * @see org.eclipse.pde.internal.ui.newparts.IFormEntryListener#browseButtonSelected(org.eclipse.pde.internal.ui.newparts.FormEntry)
55: */
56: public void browseButtonSelected(FormEntry entry) {
57: }
58:
59: /* (non-Javadoc)
60: * @see org.eclipse.ui.forms.events.HyperlinkListener#linkEntered(org.eclipse.ui.forms.events.HyperlinkEvent)
61: */
62: public void linkEntered(HyperlinkEvent e) {
63: if (actionBars == null)
64: return;
65: IStatusLineManager mng = actionBars.getStatusLineManager();
66: mng.setMessage(e.getLabel());
67: }
68:
69: /* (non-Javadoc)
70: * @see org.eclipse.ui.forms.events.HyperlinkListener#linkExited(org.eclipse.ui.forms.events.HyperlinkEvent)
71: */
72: public void linkExited(HyperlinkEvent e) {
73: if (actionBars == null)
74: return;
75: IStatusLineManager mng = actionBars.getStatusLineManager();
76: mng.setMessage(null);
77: }
78:
79: /* (non-Javadoc)
80: * @see org.eclipse.ui.forms.events.HyperlinkListener#linkActivated(org.eclipse.ui.forms.events.HyperlinkEvent)
81: */
82: public void linkActivated(HyperlinkEvent e) {
83: }
84:
85: public void selectionChanged(FormEntry entry) {
86: ITextSelection selection = new TextSelection(1, 1);
87: contextPart.getPage().getPDEEditor().getContributor()
88: .updateSelectableActions(selection);
89: }
90: }
|