KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > pde > internal > ui > editor > schema > ReferencePropertySource


1 /*******************************************************************************
2  * Copyright (c) 2000, 2003 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.schema;
12
13 import org.eclipse.pde.internal.core.ischema.*;
14 import org.eclipse.pde.internal.core.schema.SchemaElementReference;
15 import org.eclipse.pde.internal.ui.PDEUIMessages;
16
17 public class ReferencePropertySource extends GrammarPropertySource {
18
19     public ReferencePropertySource(SchemaElementReference obj) {
20         super(obj);
21     }
22
23     protected String JavaDoc isMinOccursValid(int ivalue) {
24         String JavaDoc status = super.isMinOccursValid(ivalue);
25         if (status==null && isInAll()) {
26             if (ivalue!=0 && ivalue!=1) {
27                 return PDEUIMessages.ReferencePropertySource_minOccurs_value; //$NON-NLS-1$
28
}
29         }
30         return status;
31     }
32
33     protected String JavaDoc isMaxOccursValid(int ivalue) {
34         String JavaDoc status = super.isMaxOccursValid(ivalue);
35         if (status==null && isInAll()) {
36             if (ivalue!=1) {
37                 return PDEUIMessages.ReferencePropertySource_maxOccurs_value; //$NON-NLS-1$
38
}
39         }
40         return status;
41     }
42     
43     private boolean isInAll() {
44         ISchemaCompositor compositor = getReference().getCompositor();
45         return (compositor!=null && compositor.getKind()==ISchemaCompositor.ALL);
46     }
47     
48     protected SchemaElementReference getReference() {
49         return (SchemaElementReference)getSourceObject();
50     }
51 }
52
Popular Tags