KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > pde > internal > ui > editor > plugin > rows > ReferenceAttributeRow


1 /*******************************************************************************
2  * Copyright (c) 2003, 2007 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  * Created on Jan 30, 2004
13  *
14  * To change the template for this generated file go to
15  * Window - Preferences - Java - Code Generation - Code and Comments
16  */

17 package org.eclipse.pde.internal.ui.editor.plugin.rows;
18 import org.eclipse.pde.core.plugin.IPluginModelBase;
19 import org.eclipse.pde.internal.core.ischema.ISchemaAttribute;
20 import org.eclipse.pde.internal.ui.editor.IContextPart;
21 import org.eclipse.pde.internal.ui.editor.text.PDETextHover;
22 import org.eclipse.swt.SWT;
23 import org.eclipse.swt.widgets.Composite;
24 import org.eclipse.swt.widgets.Display;
25 import org.eclipse.ui.forms.events.HyperlinkAdapter;
26 import org.eclipse.ui.forms.events.HyperlinkEvent;
27 import org.eclipse.ui.forms.widgets.FormToolkit;
28 import org.eclipse.ui.forms.widgets.Hyperlink;
29
30 public abstract class ReferenceAttributeRow extends TextAttributeRow {
31
32     public ReferenceAttributeRow(IContextPart part, ISchemaAttribute att) {
33         super(part, att);
34     }
35     
36     /*
37      * (non-Javadoc)
38      *
39      * @see org.eclipse.pde.internal.ui.neweditor.plugin.ExtensionElementEditor#createContents(org.eclipse.swt.widgets.Composite,
40      * org.eclipse.ui.forms.widgets.FormToolkit, int)
41      */

42     protected void createLabel(Composite parent, FormToolkit toolkit) {
43         if(!part.isEditable())
44         { super.createLabel(parent, toolkit);
45             return;
46         }
47
48         Hyperlink link = toolkit.createHyperlink(parent, getPropertyLabel(),
49                 SWT.NULL);
50         link.addHyperlinkListener(new HyperlinkAdapter() {
51             public void linkActivated(HyperlinkEvent e) {
52                 if (!isReferenceModel()) {
53                     openReference();
54                 } else {
55                     Display.getCurrent().beep();
56                 }
57             }
58         });
59         PDETextHover.addHoverListenerToControl(fIC, link, this);
60     }
61     
62     protected boolean isReferenceModel() {
63         return ((IPluginModelBase) part.getPage().getModel())
64                 .getUnderlyingResource() != null;
65     }
66     
67     protected abstract void openReference();
68
69 }
70
Popular Tags