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.document; 24 25 import com.sun.star.awt.Point; 26 import com.sun.star.awt.Size; 27 import com.sun.star.awt.XControlModel; 28 import com.sun.star.beans.XPropertySet; 29 import com.sun.star.wizards.common.*; 30 import com.sun.star.wizards.db.FieldColumn; 31 import com.sun.star.sdbc.*; 32 import com.sun.star.uno.Exception; 33 import com.sun.star.uno.UnoRuntime; 34 import com.sun.star.container.XNameAccess; 35 import com.sun.star.container.XNameContainer; 36 import com.sun.star.form.XGridColumnFactory; 37 import com.sun.star.lang.XComponent; 38 import com.sun.star.lang.XMultiServiceFactory; 39 40 public class GridControl extends Shape 41 { 42 43 FieldColumn[] fieldcolumns; 44 public XNameContainer xNameContainer; 45 public XGridColumnFactory xGridColumnFactory; 46 public XPropertySet xPropertySet; 47 XNameAccess xNameAccess; 48 final String SODEFAULTNAME = "Grid1"; 49 XControlModel xControlModel; 50 public XComponent xComponent; 51 GridControl(XMultiServiceFactory _xMSF, String _sname, FormHandler _oFormHandler, XNameContainer _xFormName, FieldColumn[] _fieldcolumns, Point _aPoint, Size _aSize)52 public GridControl(XMultiServiceFactory _xMSF, String _sname, FormHandler _oFormHandler, XNameContainer _xFormName, FieldColumn[] _fieldcolumns, Point _aPoint, Size _aSize) 53 { 54 super(_oFormHandler, _aPoint, _aSize); 55 try 56 { 57 fieldcolumns = _fieldcolumns; 58 Object oGridModel = oFormHandler.xMSFDoc.createInstance(oFormHandler.sModelServices[FormHandler.SOGRIDCONTROL]); 59 xNameContainer = UnoRuntime.queryInterface( XNameContainer.class, oGridModel ); 60 xNameAccess = UnoRuntime.queryInterface( XNameAccess.class, oGridModel ); 61 _xFormName.insertByName(_sname, oGridModel); 62 xControlModel = UnoRuntime.queryInterface( XControlModel.class, oGridModel ); 63 xControlShape.setControl(xControlModel); 64 xPropertySet = UnoRuntime.queryInterface( XPropertySet.class, oGridModel ); 65 oFormHandler.xDrawPage.add(xShape); 66 xGridColumnFactory = UnoRuntime.queryInterface( XGridColumnFactory.class, oGridModel ); 67 xComponent = UnoRuntime.queryInterface( XComponent.class, oGridModel ); 68 69 // Helper.setUnoPropertyValue(oGridModel, PropertyNames.PROPERTY_NAME, _sname); 70 for (int i = 0; i < fieldcolumns.length; i++) 71 { 72 FieldColumn curfieldcolumn = fieldcolumns[i]; 73 if (curfieldcolumn.getFieldType() == DataType.TIMESTAMP) 74 { 75 TimeStampControl oControl = new TimeStampControl(new Resource(_xMSF, PropertyNames.EMPTY_STRING, "dbw"), this, curfieldcolumn); 76 } 77 else 78 { 79 Control oControl = new DatabaseControl(this, curfieldcolumn); 80 } 81 } 82 83 } 84 catch (Exception e) 85 { 86 e.printStackTrace(System.out); 87 } 88 } 89 } 90