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 implements the interface of Form according to the implementation of OpenOffice.org.

Since:
0.8
 
 public class OOForm extends Component implements Form {
 
 	private int controlCount;
 
 	private OOForm(FormFormElement element) {
 		 = element;
 	}
 
 	static OOForm createForm(String nameOfficeFormsElement parent) {
 		OOForm form = null;
 		if (parent != null) {
 			FormFormElement element = parent.newFormFormElement();
 			form = new OOForm(element);
 			form.setFormName(name);
 			form
 			Component.registerComponent(formelement);
 		}
 		return form;
 	}
 
 	public Document getOwnerDocument() {
 		return ;
 	}

Get a form instance by an instance of FormFormElement.

Parameters:
element
Returns:
 
 	public static Form getInstance(FormFormElement element) {
 		OOForm form = null;
 		form = (OOForm) Component.getComponentByElement(element);
 		if (form == null) {
 			form = new OOForm(element);
 			Component.registerComponent(formelement);
 		}
 		return form;
 	}
 
 
			FrameRectangle rectangleString nameString label) {
		// set default control properties
		Button btnForm = new Button(btnElement);
		Component.registerComponent(btnFormbtnElement);
		btnForm.setId(btnElement.getXmlIdAttribute());
		btnForm.setName(name);
		btnForm
		btnForm.setLabel(label);
				nullnullnull);
		// bond to drawing shape
		btnForm.createDrawControl(parent);
		// set default shape properties
		if (parent instanceof TextDocument) {
else {
		}
		btnForm.setRectangle(rectangle);
		return btnForm;
	}
			FrameRectangle rectangleString nameString text) {
		FormFixedTextElement fixedTElement = 
		// set default control properties
		Label labelForm = new Label(fixedTElement);
		Component.registerComponent(labelFormfixedTElement);
		labelForm.setId(fixedTElement.getXmlIdAttribute());
		labelForm
		labelForm.setName(name);
		labelForm.setLabel(text);
		// bond to drawing shape
		labelForm.createDrawControl(parent);
		// set default shape properties
		if (parent instanceof TextDocument) {
else {
		}
		labelForm.setRectangle(rectangle);
		return labelForm;
	}
			FrameRectangle rectangleString nameString defaultText,
			boolean isMultipleLine) {
		OdfElement textBoxElement;
		String formId = generateFormId();
		if (isMultipleLine) {
			textBoxElement = .newFormTextareaElement(formId);
else {
			textBoxElement = .newFormTextElement(formId);
		}
		// set default control properties
		TextBox textBoxForm = new TextBox(textBoxElement);
		Component.registerComponent(textBoxFormtextBoxElement);
		textBoxForm.setId(formId);
		textBoxForm.setName(name);
		textBoxForm
		textBoxForm.setValue(defaultText);
		textBoxForm.setCurrentValue(defaultText);
		textBoxForm.setFormProperty(
				nullnull);
		if (isMultipleLine)
			textBoxForm.setFormProperty(
					nulltruenullnullnullnull);
		textBoxForm.setFormProperty(
				nullnullnull, 0.0, null);
		// bond to drawing shape
		textBoxForm.createDrawControl(parent);
		// set default shape properties
		if (parent instanceof TextDocument) {
else {
		}
		textBoxForm.setRectangle(rectangle);
		return textBoxForm;
	}
			FrameRectangle rectangleString nameboolean isMultiSelection,
			boolean isDropDown) {
		String formId = generateFormId();
		FormListboxElement listBoxElement = 
		// set default control properties
		ListBox listBoxForm = new ListBox(listBoxElement);
		Component.registerComponent(listBoxFormlistBoxElement);
		listBoxForm.setId(formId);
		listBoxForm.setName(name);
		listBoxForm
		listBoxForm.setFormMultiSelection(isMultiSelection);
		if (isDropDown) {
			listBoxForm.setFormDropdown(true);
		}
		listBoxForm.setFormProperty(
				"float"nullnullnullnullnullnull);
		listBoxForm.setFormProperty(
				nullnull);
		listBoxForm.setFormProperty(
				nullnullnullnull, 0.0, null);
		listBoxForm.setFormProperty(
				nullnullnull, 0.0, null);
		listBoxForm.setFormProperty(
				nullnullnullnull, 0.0, null);
		listBoxForm.setFormProperty(
				nullnullnull, 0.0, null);
		// bond to drawing shape
		listBoxForm.createDrawControl(parent);
		// set default shape properties
		if (parent instanceof TextDocument) {
else {
		}
		listBoxForm.setRectangle(rectangle);
		return listBoxForm;
	}
			FrameRectangle rectangleString nameString defaultText,
			boolean isDropDown) {
		String formId = generateFormId();
		FormComboboxElement comboElement = 
		// set default control properties
		ComboBox comboBoxForm = new ComboBox(comboElement);
		Component.registerComponent(comboBoxFormcomboElement);
		comboBoxForm.setId(formId);
		comboBoxForm
		comboBoxForm.setName(name);
		if (defaultText != null) {
			comboBoxForm.setCurrentValue(defaultText);
			comboBoxForm.setValue(defaultText);
		}
		if (isDropDown) {
			comboBoxForm.setFormDropdown(true);
		}
		comboBoxForm.setFormProperty(
				"float"nullnullnullnullnullnull);
		comboBoxForm.setFormProperty(
				nullnull);
		comboBoxForm.setFormProperty(
				nullnullnullnull, 0.0, null);
		comboBoxForm.setFormProperty(
				nullnullnull, 0.0, null);
		// bond to drawing shape
		comboBoxForm.createDrawControl(parent);
		// set default shape properties
		if (parent instanceof TextDocument) {
else {
		}
		comboBoxForm.setRectangle(rectangle);
		return comboBoxForm;
	}
			FrameRectangle rectangleString nameString labelString value) {
		String formId = generateFormId();
		FormRadioElement radioElement = .newFormRadioElement("center",
				formId);
		// set default control properties
		RadioButton radioBtnForm = new RadioButton(radioElement);
		Component.registerComponent(radioBtnFormradioElement);
		radioBtnForm.setId(formId);
		radioBtnForm
		radioBtnForm.setLabel(label);
		radioBtnForm.setName(name);
		radioBtnForm.setValue(value);
		radioBtnForm.setFormProperty(
				nullnullnullnull, 0.0, null);
		radioBtnForm.setFormProperty(
				nullnullnull);
		// bond to drawing shape
		radioBtnForm.createDrawControl(parent);
		// set default shape properties
		if (parent instanceof TextDocument) {
else {
		}
		radioBtnForm.setRectangle(rectangle);
		return radioBtnForm;
	}
			FrameRectangle rectangleString nameString labelString value) {
		String formId = generateFormId();
				"center"formId);
		// set default control properties
		CheckBox checkboxForm = new CheckBox(checkboxElement);
		Component.registerComponent(checkboxFormcheckboxElement);
		checkboxForm.setId(formId);
		checkboxForm.setName(name);
		checkboxForm
		checkboxForm.setLabel(label);
		checkboxForm.setValue(value);
		checkboxForm.setFormProperty(
				nullnullnullnull, 0.0, null);
		checkboxForm.setFormProperty(
				nullnull);
		// bond to drawing shape
		checkboxForm.createDrawControl(parent);
		// set default shape properties
		if (parent instanceof TextDocument) {
else {
		}
		checkboxForm.setRectangle(rectangle);
		return checkboxForm;
	}

Create a time field in this form.

Parameters:
parent - the element that contains this form control
rectangle - the bounding rectangle used by this button
name - the name of the control
defaultValue - the default value of this input field. It's a 6 digits number, e.g. 20121015 represents 2012-10-15.
Returns:
an instance of time field
			FrameRectangle rectangleString nameString defaultValue) {
		return createField(.parentrectanglename,
				defaultValue);
	}

Create a time field in this form.

Parameters:
parent - the element that contains this form control
rectangle - the bounding rectangle used by this button
name - the name of the control
defaultValue - the default value of this input field. It's a 6 digits number, e.g. 15304000 represents 15:30:40.
Returns:
an instance of time field
			FrameRectangle rectangleString nameString defaultValue) {
		return createField(.parentrectanglename,
				defaultValue);
	}
			FrameRectangle rectangleString nameString defaultValue) {
		return createField(.parentrectanglename,
				defaultValue);
	}
			FrameRectangle rectangleString nameString defaultValue) {
		return createField(.parentrectanglename,
				defaultValue);
	}
			FrameRectangle rectangleString nameString defaultValue) {
		return createField(.parentrectanglename,
				defaultValue);
	}
			FrameRectangle rectangleString nameString defaultValue) {
		String formId = generateFormId();
		FormFormattedTextElement formattedTextElement = 
		// create control according to the field type
		Field fieldForm = null;
		String defaultControl = null;
		String controlImpl = null;
		switch (type) {
			fieldForm = new DateField(formattedTextElement);
			break;
			fieldForm = new TimeField(formattedTextElement);
			break;
			fieldForm = new NumericField(formattedTextElement);
			break;
			fieldForm = new PatternField(formattedTextElement);
			break;
			fieldForm = new CurrencyField(formattedTextElement);
			break;
		}
		if (fieldForm == null)
			throw new RuntimeException("Fail to create a field.");
		Component.registerComponent(fieldFormformattedTextElement);
		// set control properties
		fieldForm.setName(name);
		fieldForm.setId(formId);
		fieldForm.setControlImplementation(controlImpl);
		fieldForm.setValue(defaultValue);
		fieldForm.setCurrentValue(defaultValue);
		fieldForm.setFormProperty(
				nullnullnullnull, 0.0, null);
		fieldForm.setFormProperty(
				defaultControlnullnullnullnullnull);
		// bond to drawing shape
		fieldForm.createDrawControl(parent);
		// set default shape properties
		if (parent instanceof TextDocument) {
else {
		}
		fieldForm.setRectangle(rectangle);
		return fieldForm;
	}
	private String generateFormId() {
		return getFormName() + (++);
	}
	public void setControlImplementation(String controlImpl) {
	}
	public void setFormName(String name) {
	}
	public void setCommand(String command) {
	}
	public void setCommandType(FormCommandType commandType) {
	}
	public void setDataSource(String dataSource) {
	}
		return ;
	}
	public String getFormName() {
	}
	public String getCommand() {
	}
		return FormCommandType.enumValueOf(
	}
	}
	public String getDataSource() {
	}
New to GrepCode? Check out our FAQ X