Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /* 
  Licensed to the Apache Software Foundation (ASF) under one
  or more contributor license agreements.  See the NOTICE file
  distributed with this work for additional information
  regarding copyright ownership.  The ASF licenses this file
  to you under the Apache License, Version 2.0 (the
  "License"); you may not use this file except in compliance
  with the License.  You may obtain a copy of the License at
  
  http://www.apache.org/licenses/LICENSE-2.0
 
 Unless required by applicable law or agreed to in writing,
 software distributed under the License is distributed on an
 "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 KIND, either express or implied.  See the License for the
 specific language governing permissions and limitations
 under the License.
 */
 
 package org.odftoolkit.simple.form;
 
 
This class represents the form control of List Box, provides methods to get/set the form properties and the style formatting of this control.

Since:
0.8
 
 public class ListBox extends FormControl {
 
 	private ArrayList<Stringentries;
 
 		this. = element;
 	}

Get an instance of list box by an instance of FormListboxElement, while searching the document content to make a bind with the DrawControl which already reference to this list box.

Parameters:
element - an instance of FormComboboxElement
Returns:
an instance of list box
 
 	public static ListBox getInstanceOf(FormListboxElement element) {
 		ListBox listbox = new ListBox(element);
 		try {
 			listbox.loadDrawControl(((Document) ((OdfFileDomelement
 		} catch (Exception e) {
 					"Cannot load the drawing shape of this listbox.");
 		}
 		return listbox;
 	}
 
 		if ( == null)
 		return ;
 	}
 
 	public void setControlImplementation(String controlImpl) {
 	}
 
 	public String getId() {
 	}
 
 	public void setId(String id) {
 	}
 
 	public String getName() {
	}
	public void setName(String name) {
	}

Set if the list box support multi-selection

Parameters:
isMultiSelection - specify if the list box supports multi-selection
	public void setFormMultiSelection(boolean isMultiSelection) {
				.setFormMultipleAttribute(isMultiSelection);
	}

Get if the list box support multi-selection

Returns:
true if the list box supports multi-selection; false if not.
	public boolean getFormMultiSelection() {
	}

Set the visibility of the drop-down list

Parameters:
isDropDown - specify if the drop-down list is visible
	public void setFormDropdown(boolean isDropDown) {
	}

Get the visibility of the drop-down list

Returns:
true if the drop-down list is visible; false if not.
	public boolean getFormDropdown() {
	}

Add a list item to this list box.

Parameters:
item - a list item
	public void addItem(String item) {
		if (item == null)
			return;
		if ( == null)
		.add(item);
	}

Get the list entries if they are initiated through a list of string.

Returns:
the list entries
		if ( == null || .size() == 0) {
			NodeList items = .getElementsByTagName("form:option");
			if (items != null && items.getLength() > 0) {
				for (int i = 0; i < items.getLength(); i++) {
					if ( == null)
				}
				return ;
			}
		}
		return null;
	}

Add a group of list items to this list box

Parameters:
items -a group of list items
	public void addItems(String[] items) {
		if (items == null || items.length == 0)
			return;
		for (int i = 0; i < items.lengthi++) {
			addItem(items[i]);
		}
	}

Set the source type of the data list.

Parameters:
type - the source type of this list
	public void setListSourceType(FormListSourceType type) {
	}

Get the source type of the data list.

Returns:
the source type of this list
		return FormListSourceType.enumValueOf(aValue);
	}

Set the source of this data list.

Parameters:
listSource - the source of this data list.
	public void setListSource(String listSource) {
	}

Get the source of this data list.

Returns:
the source of this data list.
	public String getListSource() {
	}

Set the data field referenced by this combo box

Parameters:
dataField - the data field referenced by this combo box
	public void setDataField(String dataField) {
	}

Get the data field referenced by this combo box

Returns:
the data field
	public String getDataField() {
	}

Get a simple iterator for list boxes.

Parameters:
container - an instance of form where to traverse the list boxes
	public static Iterator<FormControlgetSimpleIterator(Form container) {
		return new SimpleListBoxIterator(container);
	}
	private static class SimpleListBoxIterator implements Iterator<FormControl> {
		private ListBox nextElement = null;
		private ListBox tempElement = null;
		private SimpleListBoxIterator(Form container) {
		}
		public boolean hasNext() {
			return ( != null);
		}
		public ListBox next() {
			if ( != null) {
				 = null;
else {
			}
			if ( == null) {
				return null;
else {
				return ;
			}
		}
		public void remove() {
			if ( == null) {
				throw new IllegalStateException("please call next() first.");
			}
		}
		private ListBox findNext(ListBox thisListBox) {
			FormListboxElement nextListBox = null;
			if (thisListBox == null) {
				nextListBox = OdfElement.findFirstChildNode(
else {
				nextListBox = OdfElement.findNextChildNode(
						FormListboxElement.classthisListBox.getOdfElement());
			}
			if (nextListBox != null) {
				return ListBox.getInstanceOf(nextListBox);
			}
			return null;
		}
	}
New to GrepCode? Check out our FAQ X