KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*******************************************************************************
2  * Copyright (c) 2006, 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 package org.eclipse.pde.internal.ui.editor.plugin.rows;
13
14 import org.eclipse.pde.internal.core.ischema.ISchemaAttribute;
15 import org.eclipse.pde.internal.ui.PDEUIMessages;
16 import org.eclipse.pde.internal.ui.editor.FormLayoutFactory;
17 import org.eclipse.pde.internal.ui.editor.IContextPart;
18 import org.eclipse.swt.SWT;
19 import org.eclipse.swt.events.SelectionAdapter;
20 import org.eclipse.swt.events.SelectionEvent;
21 import org.eclipse.swt.layout.GridData;
22 import org.eclipse.swt.widgets.Button;
23 import org.eclipse.swt.widgets.Composite;
24 import org.eclipse.ui.forms.widgets.FormToolkit;
25
26 /**
27  * ButtonAttributeRow
28  *
29  */

30 public abstract class ButtonAttributeRow extends ReferenceAttributeRow {
31
32     /**
33      * @param part
34      * @param att
35      */

36     public ButtonAttributeRow(IContextPart part, ISchemaAttribute att) {
37         super(part, att);
38     }
39
40     public void createContents(Composite parent, FormToolkit toolkit, int span) {
41         super.createContents(parent, toolkit, span);
42         if(part.isEditable())
43         { Button button = toolkit.createButton(parent, PDEUIMessages.ReferenceAttributeRow_browse, SWT.PUSH);
44             button.addSelectionListener(new SelectionAdapter() {
45                 public void widgetSelected(SelectionEvent e) {
46                     if (!isReferenceModel())
47                         browse();
48                 }
49             });
50             //button.setEnabled(part.isEditable());
51
}
52     }
53
54     protected GridData createGridData(int span) {
55         GridData gd = new GridData(GridData.FILL_HORIZONTAL);
56         gd.widthHint = 20;
57         gd.horizontalIndent = FormLayoutFactory.CONTROL_HORIZONTAL_INDENT;
58         return gd;
59     }
60     
61     protected abstract void browse();
62
63 }
64
Popular Tags