Commit 0791047d authored by Romain Bioteau's avatar Romain Bioteau
Browse files

Refactor paletter label provider + add unit tests

parent adf93e9a
......@@ -75,6 +75,7 @@ Export-Package: org.bonitasoft.studio.common,
org.bonitasoft.studio.common.jface.databinding.validator,
org.bonitasoft.studio.common.jface.dialog,
org.bonitasoft.studio.common.log,
org.bonitasoft.studio.common.palette,
org.bonitasoft.studio.common.perspectives,
org.bonitasoft.studio.common.platform.tools,
org.bonitasoft.studio.common.properties,
......
/**
* Copyright (C) 2014 BonitaSoft S.A.
* BonitaSoft, 32 rue Gustave Eiffel - 38000 Grenoble
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2.0 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.bonitasoft.studio.common.palette;
import static org.assertj.core.api.Assertions.assertThat;
import org.bonitasoft.studio.common.Messages;
import org.bonitasoft.studio.common.NamingUtils;
import org.bonitasoft.studio.model.form.builders.FileWidgetBuilder;
import org.bonitasoft.studio.model.process.FlowElement;
import org.bonitasoft.studio.model.process.ProcessFactory;
import org.bonitasoft.studio.model.process.builders.ActivityBuilder;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
/**
* @author Romain Bioteau
*
*/
public class DefaultElementNameProviderTest {
private DefaultElementNameProvider defaultElementNameProvider;
/**
* @throws java.lang.Exception
*/
@Before
public void setUp() throws Exception {
defaultElementNameProvider = new DefaultElementNameProvider();
}
/**
* @throws java.lang.Exception
*/
@After
public void tearDown() throws Exception {
}
@Test
public void should_getNameFor_a_process_element() throws Exception {
assertThat(defaultElementNameProvider.getNameFor(ActivityBuilder.createActivityBuilder().build())).isEqualTo(Messages.StepDefaultName);
final FlowElement flowElement = ProcessFactory.eINSTANCE.createFlowElement();
assertThat(defaultElementNameProvider.getNameFor(flowElement)).isEqualTo(flowElement.eClass().getName());
}
@Test
public void should_getNameFor_a_widget() throws Exception {
assertThat(defaultElementNameProvider.getNameFor(FileWidgetBuilder.createFileWidgetBuilder().build())).isEqualTo(
NamingUtils.toJavaIdentifier(Messages.File_title, true));
}
}
/**
* Copyright (C) 2014 BonitaSoft S.A.
* BonitaSoft, 32 rue Gustave Eiffel - 38000 Grenoble
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2.0 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.bonitasoft.studio.common.palette;
import static org.assertj.core.api.Assertions.assertThat;
import org.bonitasoft.studio.model.form.FormPackage;
import org.bonitasoft.studio.model.process.ProcessPackage;
import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.EClassifier;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
/**
* @author Romain Bioteau
*
*/
public class FormPaletteLabelProviderTest {
private FormPaletteLabelProvider labelProvider;
/**
* @throws java.lang.Exception
*/
@Before
public void setUp() throws Exception {
labelProvider = new FormPaletteLabelProvider();
}
/**
* @throws java.lang.Exception
*/
@After
public void tearDown() throws Exception {
}
@Test(expected = IllegalArgumentException.class)
public void should_getFormPaletteText_throw_IllegalArgumentException_for_null_argument() throws Exception {
labelProvider.getFormPaletteText(null);
}
@Test(expected = IllegalArgumentException.class)
public void should_getFormPaletteText_throw_IllegalArgumentException_for_eClass_not_representing_a_widget() throws Exception {
labelProvider.getFormPaletteText(ProcessPackage.Literals.FLOW_ELEMENT);
}
@Test(expected = IllegalArgumentException.class)
public void should_getFormPaletteDescription_throw_IllegalArgumentException_for_null_argument() throws Exception {
labelProvider.getFormPaletteDescription(null);
}
@Test(expected = IllegalArgumentException.class)
public void should_getFormPaletteDescription_throw_IllegalArgumentException_for_eClass_not_representing_a_widget() throws Exception {
labelProvider.getFormPaletteDescription(ProcessPackage.Literals.FLOW_ELEMENT);
}
@Test(expected = IllegalArgumentException.class)
public void should_getFormPaletteDescription_throw_IllegalArgumentException_for_combo_eClass() throws Exception {
labelProvider.getFormPaletteDescription(FormPackage.Literals.COMBO_FORM_FIELD);
}
@Test(expected = IllegalArgumentException.class)
public void should_getFormPaletteText_throw_IllegalArgumentException_for_combo_eClass() throws Exception {
labelProvider.getFormPaletteText(FormPackage.Literals.COMBO_FORM_FIELD);
}
@Test
public void should_all_widget_classifiers_supported() throws Exception {
final EClass widgetEclass = FormPackage.Literals.WIDGET;
for (final EClassifier eClass : FormPackage.eINSTANCE.getEClassifiers()) {
if (eClass instanceof EClass
&& widgetEclass.isSuperTypeOf((EClass) eClass)
&& !((EClass) eClass).isAbstract()
//Unused widget
&& !eClass.equals(FormPackage.Literals.COMBO_FORM_FIELD)
&& !eClass.equals(FormPackage.Literals.INFO)) {
assertThat(labelProvider.getFormPaletteText((EClass) eClass)).isNotNull();
assertThat(labelProvider.getFormPaletteDescription((EClass) eClass)).isNotNull();
}
}
}
}
/**
* Copyright (C) 2014 BonitaSoft S.A.
* BonitaSoft, 32 rue Gustave Eiffel - 38000 Grenoble
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2.0 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.bonitasoft.studio.common.palette;
import static org.assertj.core.api.Assertions.assertThat;
import org.bonitasoft.studio.model.form.FormPackage;
import org.bonitasoft.studio.model.process.ProcessPackage;
import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.EClassifier;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
/**
* @author Romain Bioteau
*
*/
public class ProcessPaletteLabelProviderTest {
private ProcessPaletteLabelProvider labelProvider;
/**
* @throws java.lang.Exception
*/
@Before
public void setUp() throws Exception {
labelProvider = new ProcessPaletteLabelProvider();
}
/**
* @throws java.lang.Exception
*/
@After
public void tearDown() throws Exception {
}
@Test(expected = IllegalArgumentException.class)
public void should_getProcessPaletteText_throw_IllegalArgumentException_for_null_argument() throws Exception {
labelProvider.getProcessPaletteText(null);
}
@Test(expected = IllegalArgumentException.class)
public void should_getProcessPaletteDescription_throw_IllegalArgumentException_for_null_argument() throws Exception {
labelProvider.getProcessPaletteDescription(null);
}
@Test(expected = IllegalArgumentException.class)
public void should_getProcessPaletteText_throw_IllegalArgumentException_for_eClass_not_representing_a_process_element() throws Exception {
labelProvider.getProcessPaletteText(FormPackage.Literals.TEXT_FORM_FIELD);
}
@Test(expected = IllegalArgumentException.class)
public void should_getProcessPaletteDescription_throw_IllegalArgumentException_for_eClass_not_representing_a_process_element() throws Exception {
labelProvider.getProcessPaletteDescription(FormPackage.Literals.TEXT_FORM_FIELD);
}
@Test
public void should_getProcessPaletteText_return_eClass_name_if_eClass_not_supported() throws Exception {
assertThat(labelProvider.getProcessPaletteText(ProcessPackage.Literals.MESSAGE_FLOW)).isEqualTo(ProcessPackage.Literals.MESSAGE_FLOW.getName());
}
@Test
public void should_all_flow_element_classifiers_supported() throws Exception {
final EClass flowElementEClass = ProcessPackage.Literals.FLOW_ELEMENT;
for (final EClassifier eClass : ProcessPackage.eINSTANCE.getEClassifiers()) {
if (eClass instanceof EClass
&& flowElementEClass.isSuperTypeOf((EClass) eClass)
&& !((EClass) eClass).isAbstract()
&& !eClass.equals(flowElementEClass)
//Should below eClasses be abstract ?
&& !eClass.equals(ProcessPackage.Literals.GATEWAY)
&& !eClass.equals(ProcessPackage.Literals.MESSAGE_EVENT)
&& !eClass.equals(ProcessPackage.Literals.THROW_MESSAGE_EVENT)
&& !eClass.equals(ProcessPackage.Literals.LINK_EVENT)) {
assertThat(labelProvider.getProcessPaletteText((EClass) eClass)).isNotNull();
assertThat(labelProvider.getProcessPaletteDescription((EClass) eClass)).isNotNull();
}
}
}
}
/**
* Copyright (C) 2014 BonitaSoft S.A.
* BonitaSoft, 32 rue Gustave Eiffel - 38000 Grenoble
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2.0 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.bonitasoft.studio.common.palette;
import java.util.HashMap;
import java.util.Map;
import org.bonitasoft.studio.common.Messages;
import org.bonitasoft.studio.common.NamingUtils;
import org.bonitasoft.studio.model.form.Widget;
import org.bonitasoft.studio.model.process.Element;
import org.bonitasoft.studio.model.process.ProcessPackage;
/**
* @author Romain Bioteau
*
*/
public class DefaultElementNameProvider {
private static final String BOUNDARY_PREFIX = "Boundary ";
private static Map<Integer, String> classifierIDToDefaultName;
static {
classifierIDToDefaultName = new HashMap<Integer, String>();
classifierIDToDefaultName.put(ProcessPackage.SUB_PROCESS_EVENT, Messages.SubprocessEventDefaultName);
classifierIDToDefaultName.put(ProcessPackage.AND_GATEWAY, Messages.GatewayDefaultName);
classifierIDToDefaultName.put(ProcessPackage.XOR_GATEWAY, Messages.GatewayDefaultName);
classifierIDToDefaultName.put(ProcessPackage.INCLUSIVE_GATEWAY, Messages.GatewayDefaultName);
classifierIDToDefaultName.put(ProcessPackage.ACTIVITY, Messages.StepDefaultName);
classifierIDToDefaultName.put(ProcessPackage.TASK, Messages.StepDefaultName);
classifierIDToDefaultName.put(ProcessPackage.SERVICE_TASK, Messages.StepDefaultName);
classifierIDToDefaultName.put(ProcessPackage.SCRIPT_TASK, Messages.StepDefaultName);
classifierIDToDefaultName.put(ProcessPackage.SEND_TASK, Messages.StepDefaultName);
classifierIDToDefaultName.put(ProcessPackage.RECEIVE_TASK, Messages.StepDefaultName);
classifierIDToDefaultName.put(ProcessPackage.POOL, Messages.PoolDefaultName);
classifierIDToDefaultName.put(ProcessPackage.SEQUENCE_FLOW, Messages.SequenceFlowDefaultName);
classifierIDToDefaultName.put(ProcessPackage.MESSAGE_FLOW, Messages.MessageFlowDefaultName);
classifierIDToDefaultName.put(ProcessPackage.START_ERROR_EVENT, Messages.startEventDefaultName);
classifierIDToDefaultName.put(ProcessPackage.START_EVENT, Messages.startEventDefaultName);
classifierIDToDefaultName.put(ProcessPackage.START_MESSAGE_EVENT, Messages.startEventDefaultName);
classifierIDToDefaultName.put(ProcessPackage.START_TIMER_EVENT, Messages.startEventDefaultName);
classifierIDToDefaultName.put(ProcessPackage.START_SIGNAL_EVENT, Messages.startEventDefaultName);
classifierIDToDefaultName.put(ProcessPackage.END_ERROR_EVENT, Messages.endEventDefaultName);
classifierIDToDefaultName.put(ProcessPackage.END_EVENT, Messages.endEventDefaultName);
classifierIDToDefaultName.put(ProcessPackage.END_MESSAGE_EVENT, Messages.endEventDefaultName);
classifierIDToDefaultName.put(ProcessPackage.END_TERMINATED_EVENT, Messages.endEventDefaultName);
classifierIDToDefaultName.put(ProcessPackage.END_SIGNAL_EVENT, Messages.endEventDefaultName);
classifierIDToDefaultName.put(ProcessPackage.INTERMEDIATE_ERROR_CATCH_EVENT, Messages.IntermediateErrorCatchEventLabel);
classifierIDToDefaultName.put(ProcessPackage.INTERMEDIATE_CATCH_SIGNAL_EVENT, Messages.signalEventDefaultName);
classifierIDToDefaultName.put(ProcessPackage.INTERMEDIATE_THROW_SIGNAL_EVENT, Messages.signalEventDefaultName);
classifierIDToDefaultName.put(ProcessPackage.BOUNDARY_SIGNAL_EVENT, BOUNDARY_PREFIX + Messages.signalEventDefaultName);
classifierIDToDefaultName.put(ProcessPackage.INTERMEDIATE_CATCH_MESSAGE_EVENT, Messages.intermediateMessageEventDefaultName);
classifierIDToDefaultName.put(ProcessPackage.INTERMEDIATE_THROW_MESSAGE_EVENT, Messages.intermediateMessageEventDefaultName);
classifierIDToDefaultName.put(ProcessPackage.BOUNDARY_MESSAGE_EVENT, BOUNDARY_PREFIX + Messages.intermediateMessageEventDefaultName);
classifierIDToDefaultName.put(ProcessPackage.INTERMEDIATE_CATCH_TIMER_EVENT, Messages.intermeiateTimerEventDefaultName);
classifierIDToDefaultName.put(ProcessPackage.TIMER_EVENT, Messages.intermeiateTimerEventDefaultName);
classifierIDToDefaultName.put(ProcessPackage.BOUNDARY_TIMER_EVENT, BOUNDARY_PREFIX + Messages.intermeiateTimerEventDefaultName);
classifierIDToDefaultName.put(ProcessPackage.THROW_LINK_EVENT, Messages.linkEventDefaultName);
classifierIDToDefaultName.put(ProcessPackage.CATCH_LINK_EVENT, Messages.linkEventDefaultName);
}
private final ProcessPaletteLabelProvider processPaletteLabelProvider;
private final FormPaletteLabelProvider formPaletteLabelProvider;
public DefaultElementNameProvider() {
processPaletteLabelProvider = new ProcessPaletteLabelProvider();
formPaletteLabelProvider = new FormPaletteLabelProvider();
}
public String getNameFor(final Element element) {
if (element instanceof Widget) {
return NamingUtils.toJavaIdentifier(formPaletteLabelProvider.getFormPaletteText(element.eClass()), true);
} else {
String name = classifierIDToDefaultName.get(element.eClass().getClassifierID());
if (name == null) {
name = processPaletteLabelProvider.getProcessPaletteText(element.eClass());
}
return name;
}
}
}
/**
* Copyright (C) 2014 BonitaSoft S.A.
* BonitaSoft, 32 rue Gustave Eiffel - 38000 Grenoble
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2.0 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.bonitasoft.studio.common.palette;
import java.util.HashMap;
import java.util.Map;
import org.bonitasoft.studio.common.Messages;
import org.bonitasoft.studio.model.form.FormPackage;
import org.eclipse.core.runtime.Assert;
import org.eclipse.emf.ecore.EClass;
/**
* @author Romain Bioteau
*
*/
public class FormPaletteLabelProvider {
private static Map<Integer, String> classifierIDToTitle;
private static Map<Integer, String> classifierIDToDescription;
static {
classifierIDToTitle = new HashMap<Integer, String>();
classifierIDToDescription = new HashMap<Integer, String>();
classifierIDToTitle.put(FormPackage.CHECK_BOX_SINGLE_FORM_FIELD, Messages.Checkbox_title);
classifierIDToDescription.put(FormPackage.CHECK_BOX_SINGLE_FORM_FIELD, Messages.Checkbox_desc);
classifierIDToTitle.put(FormPackage.CHECK_BOX_MULTIPLE_FORM_FIELD, Messages.CheckboxList_title);
classifierIDToDescription.put(FormPackage.CHECK_BOX_MULTIPLE_FORM_FIELD, Messages.CheckboxList_desc);
classifierIDToTitle.put(FormPackage.DATE_FORM_FIELD, Messages.Date_title);
classifierIDToDescription.put(FormPackage.DATE_FORM_FIELD, Messages.Date_desc);
classifierIDToTitle.put(FormPackage.PASSWORD_FORM_FIELD, Messages.Password_title);
classifierIDToDescription.put(FormPackage.PASSWORD_FORM_FIELD, Messages.Password_desc);
classifierIDToTitle.put(FormPackage.DURATION_FORM_FIELD, Messages.Duration_title);
classifierIDToDescription.put(FormPackage.DURATION_FORM_FIELD, Messages.Duration_desc);
classifierIDToTitle.put(FormPackage.LIST_FORM_FIELD, Messages.List_title);
classifierIDToDescription.put(FormPackage.LIST_FORM_FIELD, Messages.List_desc);
classifierIDToTitle.put(FormPackage.RADIO_FORM_FIELD, Messages.Radio_title);
classifierIDToDescription.put(FormPackage.RADIO_FORM_FIELD, Messages.Radio_desc);
classifierIDToTitle.put(FormPackage.SELECT_FORM_FIELD, Messages.Select_title);
classifierIDToDescription.put(FormPackage.SELECT_FORM_FIELD, Messages.Select_desc);
classifierIDToTitle.put(FormPackage.SUGGEST_BOX, Messages.Submit_title);
classifierIDToDescription.put(FormPackage.SUGGEST_BOX, Messages.SuggestBox_desc);
classifierIDToTitle.put(FormPackage.TEXT_INFO, Messages.Text_title);
classifierIDToDescription.put(FormPackage.TEXT_INFO, Messages.Text_desc);
classifierIDToTitle.put(FormPackage.TEXT_FORM_FIELD, Messages.TextBox_title);
classifierIDToDescription.put(FormPackage.TEXT_FORM_FIELD, Messages.TextBox_desc);
classifierIDToTitle.put(FormPackage.TEXT_AREA_FORM_FIELD, Messages.TextArea_title);
classifierIDToDescription.put(FormPackage.TEXT_AREA_FORM_FIELD, Messages.TextArea_desc);
classifierIDToTitle.put(FormPackage.RICH_TEXT_AREA_FORM_FIELD, Messages.RichTextArea_title);
classifierIDToDescription.put(FormPackage.RICH_TEXT_AREA_FORM_FIELD, Messages.RichTextArea_desc);
classifierIDToTitle.put(FormPackage.MESSAGE_INFO, Messages.Message_title);
classifierIDToDescription.put(FormPackage.MESSAGE_INFO, Messages.Message_desc);
classifierIDToTitle.put(FormPackage.SUBMIT_FORM_BUTTON, Messages.Submit_title);
classifierIDToDescription.put(FormPackage.SUBMIT_FORM_BUTTON, Messages.Submit_desc);
classifierIDToTitle.put(FormPackage.PREVIOUS_FORM_BUTTON, Messages.Previous_title);
classifierIDToDescription.put(FormPackage.PREVIOUS_FORM_BUTTON, Messages.Previous_desc);
classifierIDToTitle.put(FormPackage.NEXT_FORM_BUTTON, Messages.Next_title);
classifierIDToDescription.put(FormPackage.NEXT_FORM_BUTTON, Messages.Next_title);
classifierIDToTitle.put(FormPackage.FORM_BUTTON, Messages.SimpleButton_title);
classifierIDToDescription.put(FormPackage.FORM_BUTTON, Messages.SimpleButton_desc);
classifierIDToTitle.put(FormPackage.FILE_WIDGET, Messages.File_title);
classifierIDToDescription.put(FormPackage.FILE_WIDGET, Messages.File_desc);
classifierIDToTitle.put(FormPackage.IMAGE_WIDGET, Messages.Image_title);
classifierIDToDescription.put(FormPackage.IMAGE_WIDGET, Messages.IFrame_desc);
classifierIDToTitle.put(FormPackage.TABLE, Messages.Table_title);
classifierIDToDescription.put(FormPackage.TABLE, Messages.Table_desc);
classifierIDToTitle.put(FormPackage.DYNAMIC_TABLE, Messages.EditableGrid_title);
classifierIDToDescription.put(FormPackage.DYNAMIC_TABLE, Messages.EditableGrid_desc);
classifierIDToTitle.put(FormPackage.HIDDEN_WIDGET, Messages.Hidden_title);
classifierIDToDescription.put(FormPackage.HIDDEN_WIDGET, Messages.Hidden_desc);
classifierIDToTitle.put(FormPackage.IFRAME_WIDGET, Messages.IFrame_title);
classifierIDToDescription.put(FormPackage.IFRAME_WIDGET, Messages.IFrame_desc);
classifierIDToTitle.put(FormPackage.HTML_WIDGET, Messages.HTML_title);
classifierIDToDescription.put(FormPackage.HTML_WIDGET, Messages.HTML_desc);
classifierIDToTitle.put(FormPackage.GROUP, Messages.Group_title);
classifierIDToDescription.put(FormPackage.GROUP, Messages.Group_desc);
}
public String getFormPaletteDescription(final EClass eClass) {
Assert.isLegal(eClass != null);
Assert.isLegal(FormPackage.Literals.WIDGET.isSuperTypeOf(eClass), "EClass " + eClass.getName() + " is not supported.");
final int id = eClass.getClassifierID();
final String label = classifierIDToDescription.get(id);
Assert.isLegal(label != null, "EClass " + eClass.getName() + " is not supported.");
return label;
}
public String getFormPaletteText(final EClass eClass) {
Assert.isLegal(eClass != null);
Assert.isLegal(FormPackage.Literals.WIDGET.isSuperTypeOf(eClass), "EClass " + eClass.getName() + " is not supported.");
final int id = eClass.getClassifierID();
final String label = classifierIDToTitle.get(id);
Assert.isLegal(label != null, "EClass " + eClass.getName() + " is not supported.");
return label;
}
}
/**
* Copyright (C) 2014 BonitaSoft S.A.
* BonitaSoft, 32 rue Gustave Eiffel - 38000 Grenoble
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2.0 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.