1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 package com.sun.star.wizards.form; 24 25 import com.sun.star.awt.XCheckBox; 26 import com.sun.star.awt.XRadioButton; 27 import com.sun.star.beans.PropertyValue; 28 import com.sun.star.wizards.common.Helper; 29 import com.sun.star.wizards.common.Properties; 30 import com.sun.star.wizards.ui.UnoDialog; 31 import com.sun.star.wizards.ui.WizardDialog; 32 import com.sun.star.wizards.ui.UIConsts; 33 import com.sun.star.wizards.common.PropertyNames; 34 35 public class DataEntrySetter 36 { 37 38 private WizardDialog CurUnoDialog; 39 private short curtabindex; 40 private XRadioButton optNewDataOnly; 41 private XRadioButton optDisplayAllData; 42 private XCheckBox chknomodification; 43 private XCheckBox chknodeletion; 44 private XCheckBox chknoaddition; 45 DataEntrySetter(WizardDialog _CurUnoDialog)46 public DataEntrySetter(WizardDialog _CurUnoDialog) 47 { 48 this.CurUnoDialog = _CurUnoDialog; 49 curtabindex = (short) (FormWizard.SODATA_PAGE * 100); 50 Integer IDataStep = new Integer(FormWizard.SODATA_PAGE); 51 String sNewDataOnly = CurUnoDialog.m_oResource.getResText(UIConsts.RID_FORM + 44); // 52 String sDisplayAllData = CurUnoDialog.m_oResource.getResText(UIConsts.RID_FORM + 46); // 53 String sNoModification = CurUnoDialog.m_oResource.getResText(UIConsts.RID_FORM + 47); // AllowUpdates 54 String sNoDeletion = CurUnoDialog.m_oResource.getResText(UIConsts.RID_FORM + 48); // AllowDeletes 55 String sNoAddition = CurUnoDialog.m_oResource.getResText(UIConsts.RID_FORM + 49); // AlowInserts 56 String sdontdisplayExistingData = CurUnoDialog.m_oResource.getResText(UIConsts.RID_FORM + 45); 57 58 optNewDataOnly = CurUnoDialog.insertRadioButton("optNewDataOnly", "toggleCheckBoxes", this, 59 new String[] 60 { 61 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 62 }, 63 new Object[] 64 { 65 UIConsts.INTEGERS[8], "HID:WIZARDS_HID_DLGFORM_OPTNEWDATAONLY", sNewDataOnly, 98, 25, IDataStep, new Short(curtabindex++), 195 66 }); 67 68 optDisplayAllData = CurUnoDialog.insertRadioButton("optDisplayAllData", "toggleCheckBoxes", this, 69 new String[] 70 { 71 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 72 }, 73 new Object[] 74 { 75 UIConsts.INTEGERS[8], "HID:WIZARDS_HID_DLGFORM_OPTDISPLAYALLDATA", sDisplayAllData, 98, 50, new Short((short) 1), IDataStep, new Short(curtabindex++), 197 76 }); 77 chknomodification = CurUnoDialog.insertCheckBox("chknomodification", null, 78 new String[] 79 { 80 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 81 }, 82 new Object[] 83 { 84 UIConsts.INTEGERS[8], "HID:WIZARDS_HID_DLGFORM_CHKNOMODIFICATION", sNoModification, 108, 62, new Short((short) 0), IDataStep, new Short(curtabindex++), 189 85 }); 86 chknodeletion = CurUnoDialog.insertCheckBox("chknodeletion", null, 87 new String[] 88 { 89 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 90 }, 91 new Object[] 92 { 93 UIConsts.INTEGERS[8], "HID:WIZARDS_HID_DLGFORM_CHKNODELETION", sNoDeletion, 108, 74, new Short((short) 0), IDataStep, new Short(curtabindex++), 189 94 }); 95 chknoaddition = CurUnoDialog.insertCheckBox("chknoaddition", null, 96 new String[] 97 { 98 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 99 }, 100 new Object[] 101 { 102 UIConsts.INTEGERS[8], "HID:WIZARDS_HID_DLGFORM_CHKNOADDITION", sNoAddition, 108, 86, new Short((short) 0), IDataStep, new Short(curtabindex++), 191 103 }); 104 CurUnoDialog.insertLabel("lbldontdisplayExistingData", 105 new String[] 106 { 107 PropertyNames.PROPERTY_HEIGHT, PropertyNames.PROPERTY_LABEL, PropertyNames.PROPERTY_POSITION_X, PropertyNames.PROPERTY_POSITION_Y, PropertyNames.PROPERTY_STEP, PropertyNames.PROPERTY_TABINDEX, PropertyNames.PROPERTY_WIDTH 108 }, 109 new Object[] 110 { 111 8, sdontdisplayExistingData, 108, 33, IDataStep, new Short(curtabindex++), 134 112 }); 113 } 114 getFormProperties()115 public PropertyValue[] getFormProperties() 116 { 117 PropertyValue[] retProperties; 118 if (optDisplayAllData.getState()) 119 { 120 retProperties = new PropertyValue[3]; 121 boolean bAllowUpdates = (((Short) Helper.getUnoPropertyValue(UnoDialog.getModel(chknomodification), PropertyNames.PROPERTY_STATE)).shortValue()) != 1; 122 boolean bAllowDeletes = (((Short) Helper.getUnoPropertyValue(UnoDialog.getModel(chknodeletion), PropertyNames.PROPERTY_STATE)).shortValue()) != 1; 123 boolean bAllowInserts = (((Short) Helper.getUnoPropertyValue(UnoDialog.getModel(chknoaddition), PropertyNames.PROPERTY_STATE)).shortValue()) != 1; 124 retProperties[0] = Properties.createProperty("AllowUpdates", Boolean.valueOf(bAllowUpdates)); 125 retProperties[1] = Properties.createProperty("AllowDeletes", Boolean.valueOf(bAllowDeletes)); 126 retProperties[2] = Properties.createProperty("AllowInserts", Boolean.valueOf(bAllowInserts)); 127 } 128 else 129 { 130 retProperties = new PropertyValue[1]; 131 retProperties[0] = Properties.createProperty("IgnoreResult", Boolean.TRUE); 132 } 133 return retProperties; 134 135 } 136 toggleCheckBoxes()137 public void toggleCheckBoxes() 138 { 139 boolean bdisplayalldata = optDisplayAllData.getState(); 140 Helper.setUnoPropertyValue(UnoDialog.getModel(chknomodification), PropertyNames.PROPERTY_ENABLED, Boolean.valueOf(bdisplayalldata)); 141 Helper.setUnoPropertyValue(UnoDialog.getModel(chknodeletion), PropertyNames.PROPERTY_ENABLED, Boolean.valueOf(bdisplayalldata)); 142 Helper.setUnoPropertyValue(UnoDialog.getModel(chknoaddition), PropertyNames.PROPERTY_ENABLED, Boolean.valueOf(bdisplayalldata)); 143 } 144 } 145