KickJava   Java API By Example, From Geeks To Geeks.

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


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.plugin.rows;
12 import org.eclipse.pde.internal.core.ischema.ISchemaAttribute;
13 import org.eclipse.pde.internal.ui.editor.IContextPart;
14 import org.eclipse.swt.widgets.Composite;
15 import org.eclipse.ui.forms.widgets.FormToolkit;
16
17 public class BooleanAttributeRow extends ChoiceAttributeRow {
18     /**
19      * @param att
20      */

21     public BooleanAttributeRow(IContextPart part, ISchemaAttribute att) {
22         super(part, att);
23     }
24     /*
25      * (non-Javadoc)
26      *
27      * @see org.eclipse.pde.internal.ui.neweditor.plugin.ExtensionElementEditor#createContents(org.eclipse.swt.widgets.Composite,
28      * org.eclipse.ui.forms.widgets.FormToolkit, int)
29      */

30     public void createContents(Composite parent, FormToolkit toolkit, int span) {
31         super.createContents(parent, toolkit, span);
32         if (getUse()!=ISchemaAttribute.REQUIRED)
33             combo.add(""); //$NON-NLS-1$
34
combo.add("true"); //$NON-NLS-1$
35
combo.add("false"); //$NON-NLS-1$
36
}
37     
38     /* (non-Javadoc)
39      * @see org.eclipse.pde.internal.ui.editor.plugin.rows.ChoiceAttributeRow#isValid(java.lang.String)
40      */

41     protected boolean isValid(String JavaDoc value) {
42     if (getUse() == ISchemaAttribute.REQUIRED)
43         return (value.equals("true") || value.equals("false")); //$NON-NLS-1$ //$NON-NLS-2$
44
return (value.equals("true") || value.equals("false") || value.equals("")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
45
}
46     
47     /* (non-Javadoc)
48      * @see org.eclipse.pde.internal.ui.editor.plugin.rows.ChoiceAttributeRow#getValidValue()
49      */

50     protected String JavaDoc getValidValue() {
51         return "true"; //$NON-NLS-1$
52
}
53 }
54
Popular Tags