diff options
Diffstat (limited to 'wizards/com/sun/star/wizards/form/FormConfiguration.java')
-rw-r--r-- | wizards/com/sun/star/wizards/form/FormConfiguration.java | 242 |
1 files changed, 242 insertions, 0 deletions
diff --git a/wizards/com/sun/star/wizards/form/FormConfiguration.java b/wizards/com/sun/star/wizards/form/FormConfiguration.java new file mode 100644 index 000000000000..f8cc43a1833b --- /dev/null +++ b/wizards/com/sun/star/wizards/form/FormConfiguration.java @@ -0,0 +1,242 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org 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 Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +package com.sun.star.wizards.form; + +import com.sun.star.awt.XCheckBox; +import com.sun.star.awt.XFixedText; +import com.sun.star.awt.XListBox; +import com.sun.star.awt.XRadioButton; +import com.sun.star.wizards.common.Helper; +import com.sun.star.wizards.common.PropertyNames; +import com.sun.star.wizards.ui.CommandFieldSelection; +import com.sun.star.wizards.ui.UIConsts; +import com.sun.star.wizards.ui.UnoDialog; +import com.sun.star.wizards.ui.WizardDialog; +import com.sun.star.wizards.db.RelationController; + +/** + * @author Administrator + * + * To change the template for this generated type comment go to + * Window>Preferences>Java>Code Generation>Code and Comments + */ +public class FormConfiguration +{ + + WizardDialog CurUnoDialog; + short curtabindex; + XRadioButton optOnExistingRelation; + XCheckBox chkcreateSubForm; + XRadioButton optSelectManually; + XFixedText lblSubFormDescription; + XFixedText lblRelations; + XListBox lstRelations; + String[] sreferencedTables; + // Integer ISubFormStep; + CommandFieldSelection CurSubFormFieldSelection; + String SSUBFORMMODE = "toggleSubFormMode"; + String STOGGLESTEPS = "toggleSteps"; + String SONEXISTINGRELATIONSELECTION = "onexistingRelationSelection"; + boolean bsupportsRelations; + RelationController oRelationController = null; + + public FormConfiguration(WizardDialog _CurUnoDialog) + { + this.CurUnoDialog = _CurUnoDialog; + curtabindex = (short) (FormWizard.SOSUBFORM_PAGE * 100); + Integer ISubFormStep = new Integer(FormWizard.SOSUBFORM_PAGE); + String sOnExistingRelation = CurUnoDialog.m_oResource.getResText(UIConsts.RID_FORM + 5); + String sOnManualRelation = CurUnoDialog.m_oResource.getResText(UIConsts.RID_FORM + 7); + String sSelectManually = CurUnoDialog.m_oResource.getResText(UIConsts.RID_FORM + 4); + String sSelectRelation = CurUnoDialog.m_oResource.getResText(UIConsts.RID_FORM + 8); + String sSubFormDescription = CurUnoDialog.m_oResource.getResText(UIConsts.RID_FORM + 3); + + // CheckBox 'Add sub form' + chkcreateSubForm = CurUnoDialog.insertCheckBox("chkcreateSubForm", SSUBFORMMODE, this, + new String[] + { + PropertyNames.PROPERTY_HEIGHT, PropertyNames.PROPERTY_HELPURL, PropertyNames.PROPERTY_LABEL, PropertyNames.PROPERTY_POSITION_X, PropertyNames.PROPERTY_POSITION_Y, PropertyNames.PROPERTY_STEP, PropertyNames.PROPERTY_TABINDEX, PropertyNames.PROPERTY_WIDTH + }, + new Object[] + { + UIConsts.INTEGERS[8], "HID:WIZARDS_HID_DLGFORM_CHKCREATESUBFORM", sSelectManually, 97, 26, ISubFormStep, new Short(curtabindex++), 160 + }); + optOnExistingRelation = CurUnoDialog.insertRadioButton("optOnExistingRelation", STOGGLESTEPS, this, + new String[] + { + PropertyNames.PROPERTY_ENABLED, PropertyNames.PROPERTY_HEIGHT, PropertyNames.PROPERTY_HELPURL, PropertyNames.PROPERTY_LABEL, PropertyNames.PROPERTY_POSITION_X, PropertyNames.PROPERTY_POSITION_Y, PropertyNames.PROPERTY_STEP, PropertyNames.PROPERTY_TABINDEX, PropertyNames.PROPERTY_WIDTH + }, + new Object[] + { + Boolean.FALSE, UIConsts.INTEGERS[8], "HID:WIZARDS_HID_DLGFORM_OPTONEXISTINGRELATION", sOnExistingRelation, 107, 43, ISubFormStep, new Short(curtabindex++), 160 + }); + optSelectManually = CurUnoDialog.insertRadioButton("optSelectManually", STOGGLESTEPS, this, + new String[] + { + PropertyNames.PROPERTY_ENABLED, PropertyNames.PROPERTY_HEIGHT, PropertyNames.PROPERTY_HELPURL, PropertyNames.PROPERTY_LABEL, PropertyNames.PROPERTY_POSITION_X, PropertyNames.PROPERTY_POSITION_Y, PropertyNames.PROPERTY_STATE, PropertyNames.PROPERTY_STEP, PropertyNames.PROPERTY_TABINDEX, PropertyNames.PROPERTY_WIDTH + }, + new Object[] + { + Boolean.FALSE, UIConsts.INTEGERS[8], "HID:WIZARDS_HID_DLGFORM_OPTSELECTMANUALLY", sOnManualRelation, 107, 99, new Short((short) 1), ISubFormStep, new Short(curtabindex++), 160 + }); + lblRelations = CurUnoDialog.insertLabel("lblSelectRelation", + new String[] + { + PropertyNames.PROPERTY_ENABLED, PropertyNames.PROPERTY_HEIGHT, PropertyNames.PROPERTY_LABEL, PropertyNames.PROPERTY_MULTILINE, PropertyNames.PROPERTY_POSITION_X, PropertyNames.PROPERTY_POSITION_Y, PropertyNames.PROPERTY_STEP, PropertyNames.PROPERTY_TABINDEX, PropertyNames.PROPERTY_WIDTH + }, + new Object[] + { + Boolean.FALSE, 19, sSelectRelation, Boolean.TRUE, 119, 56, ISubFormStep, new Short(curtabindex++), 80 + }); + lstRelations = CurUnoDialog.insertListBox("lstrelations", SONEXISTINGRELATIONSELECTION, SONEXISTINGRELATIONSELECTION, this, + new String[] + { + PropertyNames.PROPERTY_ENABLED, PropertyNames.PROPERTY_HEIGHT, PropertyNames.PROPERTY_HELPURL, PropertyNames.PROPERTY_POSITION_X, PropertyNames.PROPERTY_POSITION_Y, PropertyNames.PROPERTY_STEP, PropertyNames.PROPERTY_TABINDEX, PropertyNames.PROPERTY_WIDTH + }, + new Object[] + { + Boolean.FALSE, 37, "HID:WIZARDS_HID_DLGFORM_lstRELATIONS", 201, 55, ISubFormStep, new Short(curtabindex++), 103 + }); + lblSubFormDescription = CurUnoDialog.insertLabel("lblSubFormDescription", + new String[] + { + PropertyNames.PROPERTY_HEIGHT, PropertyNames.PROPERTY_LABEL, PropertyNames.PROPERTY_MULTILINE, PropertyNames.PROPERTY_POSITION_X, PropertyNames.PROPERTY_POSITION_Y, PropertyNames.PROPERTY_STEP, PropertyNames.PROPERTY_TABINDEX, PropertyNames.PROPERTY_WIDTH + }, + new Object[] + { + 59, sSubFormDescription, Boolean.TRUE, 110, 120, ISubFormStep, new Short(curtabindex++), 190 + }); + CurUnoDialog.insertInfoImage(97, 120, ISubFormStep.intValue()); + } + + // public void disableSubFormCheckBox() + // { + // Helper.setUnoPropertyValue(UnoDialog.getModel(chkcreateSubForm), PropertyNames.PROPERTY_ENABLED, Boolean.FALSE); + // } + + public RelationController getRelationController() + { + return oRelationController; + } + + public boolean areexistingRelationsdefined() + { + return ((chkcreateSubForm.getState() == 1) && (optOnExistingRelation.getState())); + } + + public void toggleSubFormMode() + { + boolean bdoEnable = (this.chkcreateSubForm.getState() == 1); + Helper.setUnoPropertyValue(UnoDialog.getModel(optOnExistingRelation), PropertyNames.PROPERTY_ENABLED, new Boolean(bdoEnable && bsupportsRelations)); + Helper.setUnoPropertyValue(UnoDialog.getModel(optSelectManually), PropertyNames.PROPERTY_ENABLED, new Boolean(bdoEnable)); + toggleSteps(); + } + + public void initialize(CommandFieldSelection _CurSubFormFieldSelection, RelationController _oRelationController) + { + oRelationController = _oRelationController; + sreferencedTables = oRelationController.getExportedKeys(); + bsupportsRelations = (sreferencedTables.length > 0); + Helper.setUnoPropertyValue(UnoDialog.getModel(lstRelations), "StringItemList", sreferencedTables); + this.CurSubFormFieldSelection = _CurSubFormFieldSelection; + toggleRelationsListbox(); + Helper.setUnoPropertyValue(UnoDialog.getModel(optOnExistingRelation), PropertyNames.PROPERTY_ENABLED, new Boolean(bsupportsRelations && (chkcreateSubForm.getState() == 1))); + } + + public void toggleSteps() + { + boolean bDoEnableFollowingSteps; + if (chkcreateSubForm.getState() == 1) + { + if (optOnExistingRelation.getState()) + { + onexistingRelationSelection(); + } + else if (optSelectManually.getState()) + { + CurUnoDialog.enablefromStep(FormWizard.SOFIELDLINKER_PAGE, (CurSubFormFieldSelection.getSelectedFieldNames().length > 0)); + CurUnoDialog.setStepEnabled(FormWizard.SOSUBFORMFIELDS_PAGE, true); + } + } + else + { + CurUnoDialog.setStepEnabled(FormWizard.SOSUBFORMFIELDS_PAGE, false); + CurUnoDialog.setStepEnabled(FormWizard.SOFIELDLINKER_PAGE, false); + CurUnoDialog.enablefromStep(FormWizard.SOCONTROL_PAGE, true); + } + toggleRelationsListbox(); + } + + public String getreferencedTableName() + { + if (areexistingRelationsdefined()) + { + short[] iselected = (short[]) Helper.getUnoArrayPropertyValue(UnoDialog.getModel(lstRelations), "SelectedItems"); + if (iselected != null) + { + if (iselected.length > 0) + { + return sreferencedTables[iselected[0]]; + } + } + } + return ""; + } + + public void onexistingRelationSelection() + { + String scurreferencedTableName = getreferencedTableName(); + if (scurreferencedTableName.length() > 0) + { + if (CurSubFormFieldSelection.getSelectedCommandName().equals(scurreferencedTableName)) + { + CurUnoDialog.enablefromStep(FormWizard.SOSUBFORMFIELDS_PAGE, true); + CurUnoDialog.setStepEnabled(FormWizard.SOFIELDLINKER_PAGE, false); + return; + } + else + { + CurUnoDialog.setStepEnabled(FormWizard.SOSUBFORMFIELDS_PAGE, true); + CurUnoDialog.enablefromStep(FormWizard.SOFIELDLINKER_PAGE, false); + return; + } + } + CurUnoDialog.enablefromStep(FormWizard.SOSUBFORMFIELDS_PAGE, false); + } + + private void toggleRelationsListbox() + { + boolean bdoenable = bsupportsRelations && this.optOnExistingRelation.getState() && (chkcreateSubForm.getState() == 1); + Helper.setUnoPropertyValue(UnoDialog.getModel(lblRelations), PropertyNames.PROPERTY_ENABLED, new Boolean(bdoenable)); + Helper.setUnoPropertyValue(UnoDialog.getModel(lstRelations), PropertyNames.PROPERTY_ENABLED, new Boolean(bdoenable)); + } + + public boolean hasSubForm() + { + return (this.chkcreateSubForm.getState() == 1); + } +} |