summaryrefslogtreecommitdiff
path: root/wizards/com/sun/star/wizards/table
diff options
context:
space:
mode:
Diffstat (limited to 'wizards/com/sun/star/wizards/table')
-rw-r--r--wizards/com/sun/star/wizards/table/CGCategory.java88
-rw-r--r--wizards/com/sun/star/wizards/table/CGTable.java96
-rw-r--r--wizards/com/sun/star/wizards/table/CallTableWizard.java213
-rw-r--r--wizards/com/sun/star/wizards/table/FieldDescription.java177
-rw-r--r--wizards/com/sun/star/wizards/table/FieldFormatter.java434
-rw-r--r--wizards/com/sun/star/wizards/table/Finalizer.java365
-rw-r--r--wizards/com/sun/star/wizards/table/MANIFEST.MF2
-rw-r--r--wizards/com/sun/star/wizards/table/PrimaryKeyHandler.java461
-rw-r--r--wizards/com/sun/star/wizards/table/ScenarioSelector.java386
-rw-r--r--wizards/com/sun/star/wizards/table/TableWizard.java438
-rw-r--r--wizards/com/sun/star/wizards/table/makefile.mk73
-rw-r--r--wizards/com/sun/star/wizards/table/table.component35
12 files changed, 2768 insertions, 0 deletions
diff --git a/wizards/com/sun/star/wizards/table/CGCategory.java b/wizards/com/sun/star/wizards/table/CGCategory.java
new file mode 100644
index 000000000000..ea74b33f09ad
--- /dev/null
+++ b/wizards/com/sun/star/wizards/table/CGCategory.java
@@ -0,0 +1,88 @@
+/*************************************************************************
+ *
+ * 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.table;
+
+import com.sun.star.container.XNameAccess;
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.uno.Exception;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.wizards.common.Configuration;
+
+/**
+ * @author Administrator
+ *
+ * To change the template for this generated type comment go to
+ * Window&gt;Preferences&gt;Java&gt;Code Generation&gt;Code and Comments
+ */
+// import com.sun.star.wizards.common.ConfigGroup;
+public class CGCategory
+{
+
+ public String Name;
+ public int Index;
+ private String[] Tables;
+ private final String CGROOTPATH = "/org.openoffice.Office.TableWizard/TableWizard/";
+ XMultiServiceFactory xMSF;
+ XNameAccess xNameAccessTablesNode;
+ XNameAccess xNameAccessCurBusinessNode;
+ Object oconfigView;
+
+ public CGCategory(XMultiServiceFactory _xMSF)
+ {
+ xMSF = _xMSF;
+ }
+
+ public void initialize(String category)
+ {
+ try
+ {
+ oconfigView = Configuration.getConfigurationRoot(xMSF, CGROOTPATH, false); //business/Tables
+ xNameAccessCurBusinessNode = Configuration.getChildNodebyName(
+ UnoRuntime.queryInterface(XNameAccess.class, oconfigView),
+ category);
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace(System.out);
+ }
+ }
+
+ public String[] getTableNames()
+ {
+ try
+ {
+ xNameAccessTablesNode = (XNameAccess) UnoRuntime.queryInterface(XNameAccess.class, xNameAccessCurBusinessNode.getByName("Tables"));
+ String[] sTableNames = Configuration.getNodeDisplayNames(xNameAccessTablesNode);
+ return sTableNames;
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace(System.out);
+ return null;
+ }
+ }
+}
diff --git a/wizards/com/sun/star/wizards/table/CGTable.java b/wizards/com/sun/star/wizards/table/CGTable.java
new file mode 100644
index 000000000000..b3e509b5b0c1
--- /dev/null
+++ b/wizards/com/sun/star/wizards/table/CGTable.java
@@ -0,0 +1,96 @@
+/*************************************************************************
+ *
+ * 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.table;
+
+import com.sun.star.container.XNameAccess;
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.wizards.common.Configuration;
+import com.sun.star.wizards.common.Desktop;
+import com.sun.star.wizards.common.PropertyNames;
+
+public class CGTable
+{
+
+ XMultiServiceFactory xMSF;
+ XNameAccess xNameAccessFieldsNode;
+ XNameAccess xNameAccessTableNode;
+ public String Index;
+ public String Name;
+ private Object oconfigView;
+ private final String CGROOTPATH = "/org.openoffice.Office.TableWizard/TableWizard/";
+
+ public CGTable(XMultiServiceFactory _xMSF)
+ {
+ xMSF = _xMSF;
+ }
+
+ public void initialize(XNameAccess _xNameAccessParentNode, int _index)
+ {
+ try
+ {
+ xNameAccessTableNode = Configuration.getChildNodebyIndex(_xNameAccessParentNode, _index);
+ xNameAccessFieldsNode = Configuration.getChildNodebyName(xNameAccessTableNode, "Fields");
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace(System.out);
+ }
+ }
+
+ public String[] getFieldNames(boolean _bgetbyShortName, int _imaxcolumnchars)
+ {
+ try
+ {
+ String[] fieldnames = null;
+ if (_bgetbyShortName)
+ {
+ fieldnames = Configuration.getNodeChildNames(xNameAccessFieldsNode, "ShortName");
+ for (int i = 0; i < fieldnames.length; i++)
+ {
+ if (fieldnames[i].length() > _imaxcolumnchars)
+ {
+ fieldnames[i] = fieldnames[i].substring(0, _imaxcolumnchars);
+ }
+ }
+ }
+ else
+ {
+ fieldnames = Configuration.getNodeChildNames(xNameAccessFieldsNode, PropertyNames.PROPERTY_NAME);
+ }
+ for (int i = 0; i < fieldnames.length; i++)
+ {
+ fieldnames[i] = Desktop.removeSpecialCharacters(xMSF, Configuration.getOfficeLocale(xMSF), fieldnames[i]);
+ }
+ return fieldnames;
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace(System.out);
+ return null;
+ }
+ }
+}
diff --git a/wizards/com/sun/star/wizards/table/CallTableWizard.java b/wizards/com/sun/star/wizards/table/CallTableWizard.java
new file mode 100644
index 000000000000..af685eadf343
--- /dev/null
+++ b/wizards/com/sun/star/wizards/table/CallTableWizard.java
@@ -0,0 +1,213 @@
+/*************************************************************************
+ *
+ * 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.table;
+
+import com.sun.star.beans.PropertyAttribute;
+import com.sun.star.beans.PropertyValue;
+import com.sun.star.uno.Type;
+import com.sun.star.wizards.common.Properties;
+
+/** This class capsulates the class, that implements the minimal component, a
+ * factory for creating the service (<CODE>__getServiceFactory</CODE>).
+ * @author Bertram Nolte
+ */
+public class CallTableWizard
+{
+
+ /** Gives a factory for creating the service.
+ * This method is called by the <code>JavaLoader</code>
+ * <p>
+ * @return Returns a <code>XSingleServiceFactory</code> for creating the
+ * component.
+ * @see com.sun.star.comp.loader.JavaLoader#
+ * @param stringImplementationName The implementation name of the component.
+ * @param xmultiservicefactory The service manager, who gives access to every
+ * known service.
+ * @param xregistrykey Makes structural information (except regarding tree
+ * structures) of a single
+ * registry key accessible.
+ */
+ public static com.sun.star.lang.XSingleServiceFactory __getServiceFactory(String stringImplementationName, com.sun.star.lang.XMultiServiceFactory xMSF, com.sun.star.registry.XRegistryKey xregistrykey)
+ {
+ com.sun.star.lang.XSingleServiceFactory xsingleservicefactory = null;
+ if (stringImplementationName.equals(TableWizardImplementation.class.getName()))
+ {
+ xsingleservicefactory = com.sun.star.comp.loader.FactoryHelper.getServiceFactory(TableWizardImplementation.class, TableWizardImplementation.__serviceName, xMSF, xregistrykey);
+ }
+ return xsingleservicefactory;
+ }
+
+ /** This class implements the component. At least the interfaces XServiceInfo,
+ * XTypeProvider, and XInitialization should be provided by the service.
+ */
+ public static class TableWizardImplementation extends com.sun.star.lib.uno.helper.PropertySet implements com.sun.star.lang.XInitialization, com.sun.star.lang.XServiceInfo, com.sun.star.lang.XTypeProvider, com.sun.star.task.XJobExecutor
+ {
+
+ private PropertyValue[] m_wizardContext;
+ // <properties>
+ public String Command;
+ public final Integer CommandType = com.sun.star.sdb.CommandType.TABLE;
+ // </properties>
+
+ /** The constructor of the inner class has a XMultiServiceFactory parameter.
+ * @param i_serviceFactory
+ */
+ public TableWizardImplementation(com.sun.star.lang.XMultiServiceFactory i_serviceFactory)
+ {
+ super();
+ m_serviceFactory = i_serviceFactory;
+ registerProperty( "Command", (short)( PropertyAttribute.READONLY | PropertyAttribute.MAYBEVOID ) );
+ registerProperty( "CommandType", PropertyAttribute.READONLY );
+ }
+
+ public void trigger( String sEvent )
+ {
+ try
+ {
+ if ( sEvent.compareTo("start") == 0 )
+ {
+ TableWizard CurTableWizard = new TableWizard( m_serviceFactory, m_wizardContext );
+ Command = CurTableWizard.startTableWizard();
+ }
+ }
+ catch (Exception exception)
+ {
+ System.err.println(exception);
+ }
+ System.gc();
+ }
+ /** The service name, that must be used to get an instance of this service.
+ */
+ private static final String __serviceName = "com.sun.star.wizards.table.CallTableWizard";
+ /** The service manager, that gives access to all registered services.
+ */
+ private com.sun.star.lang.XMultiServiceFactory m_serviceFactory;
+
+ /** This method is a member of the interface for initializing an object
+ * directly after its creation.
+ * @param object This array of arbitrary objects will be passed to the
+ * component after its creation.
+ * @throws Exception Every exception will not be handled, but will be
+ * passed to the caller.
+ */
+ public void initialize(Object[] object) throws com.sun.star.uno.Exception
+ {
+ m_wizardContext = Properties.convertToPropertyValueArray(object);
+ }
+
+ /** This method returns an array of all supported service names.
+ * @return Array of supported service names.
+ */
+ public java.lang.String[] getSupportedServiceNames()
+ {
+ String[] stringSupportedServiceNames = new String[1];
+
+ stringSupportedServiceNames[0] = __serviceName;
+
+ return (stringSupportedServiceNames);
+ }
+
+ /** This method returns true, if the given service will be
+ * supported by the component.
+ * @param stringService Service name.
+ * @return True, if the given service name will be supported.
+ */
+ public boolean supportsService(String stringService)
+ {
+ boolean booleanSupportsService = false;
+
+ if (stringService.equals(__serviceName))
+ {
+ booleanSupportsService = true;
+ }
+ return (booleanSupportsService);
+ }
+
+ /** This method returns an array of bytes, that can be used to
+ * unambiguously distinguish between two sets of types, e.g.
+ * to realise hashing functionality when the object is introspected.
+ * Two objects that return the same ID also have to return
+ * the same set of types in getTypes(). If an unique
+ * implementation Id cannot be provided this method has to
+ * return an empty sequence. Important: If the object
+ * aggregates other objects the ID has to be unique for the
+ * whole combination of objects.
+ * @return Array of bytes, in order to distinguish between two sets.
+ */
+ public byte[] getImplementationId()
+ {
+ byte[] byteReturn =
+ {
+ };
+
+ try
+ {
+ byteReturn = new String("" + this.hashCode()).getBytes();
+ }
+ catch (Exception exception)
+ {
+ System.err.println(exception);
+ }
+
+ return (byteReturn);
+ }
+
+ /** Return the class name of the component.
+ * @return Class name of the component.
+ */
+ public java.lang.String getImplementationName()
+ {
+ return (TableWizardImplementation.class.getName());
+ }
+
+ /** Provides a sequence of all types (usually interface types)
+ * provided by the object.
+ * @return Sequence of all types (usually interface types) provided by the
+ * service.
+ */
+ public Type[] getTypes()
+ {
+ Type[] typeReturn =
+ {
+ };
+
+ try
+ {
+ typeReturn = new Type[]
+ {
+ new Type(com.sun.star.task.XJobExecutor.class), new Type(com.sun.star.lang.XTypeProvider.class), new Type(com.sun.star.lang.XServiceInfo.class), new Type(com.sun.star.lang.XInitialization.class)
+ };
+ }
+ catch (Exception exception)
+ {
+ System.err.println(exception);
+ }
+
+ return (typeReturn);
+ }
+ }
+}
diff --git a/wizards/com/sun/star/wizards/table/FieldDescription.java b/wizards/com/sun/star/wizards/table/FieldDescription.java
new file mode 100644
index 000000000000..cf00c86f90d4
--- /dev/null
+++ b/wizards/com/sun/star/wizards/table/FieldDescription.java
@@ -0,0 +1,177 @@
+/*************************************************************************
+ *
+ * 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.table;
+
+import java.util.Vector;
+
+import com.sun.star.beans.PropertyValue;
+import com.sun.star.beans.XPropertySet;
+import com.sun.star.container.XNameAccess;
+import com.sun.star.lang.Locale;
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.wizards.common.Configuration;
+import com.sun.star.wizards.common.Properties;
+import com.sun.star.wizards.common.PropertyNames;
+
+public class FieldDescription
+{
+ private String tablename = "";
+// String fieldname;
+ private String keyname;
+ private XNameAccess xNameAccessTableNode;
+ private XPropertySet xPropertySet;
+ private Vector aPropertyValues;
+// PropertyValue[] aPropertyValues;
+ private Integer Type;
+ private Integer Scale;
+ private Integer Precision;
+ private Boolean DefaultValue;
+ private String Name;
+ private XMultiServiceFactory xMSF;
+ private Locale aLocale;
+
+ public FieldDescription(XMultiServiceFactory _xMSF, Locale _aLocale, ScenarioSelector _curscenarioselector, String _fieldname, String _keyname, int _nmaxcharCount)
+ {
+ xMSF = _xMSF;
+ aLocale = _aLocale;
+ tablename = _curscenarioselector.getTableName();
+ Name = _fieldname;
+ keyname = _keyname;
+ aPropertyValues = new Vector();
+ xNameAccessTableNode = _curscenarioselector.oCGTable.xNameAccessFieldsNode;
+ XNameAccess xNameAccessFieldNode;
+ if (_curscenarioselector.bcolumnnameislimited)
+ {
+ xNameAccessFieldNode = Configuration.getChildNodebyDisplayName(xMSF, aLocale, xNameAccessTableNode, keyname, "ShortName", _nmaxcharCount);
+ }
+ else
+ {
+ xNameAccessFieldNode = Configuration.getChildNodebyDisplayName(xMSF, aLocale, xNameAccessTableNode, keyname, PropertyNames.PROPERTY_NAME, _nmaxcharCount);
+ }
+ setFieldProperties(xNameAccessFieldNode);
+ }
+
+ public FieldDescription(String _fieldname)
+ {
+ Name = _fieldname;
+ aPropertyValues = new Vector();
+ Type = new Integer(com.sun.star.sdbc.DataType.VARCHAR);
+ aPropertyValues.addElement(Properties.createProperty(PropertyNames.PROPERTY_NAME, _fieldname));
+ aPropertyValues.addElement(Properties.createProperty("Type", Type));
+ }
+
+ public void setName(String _newfieldname)
+ {
+ for (int i = 0; i < aPropertyValues.size(); i++)
+ {
+ PropertyValue aPropertyValue = (PropertyValue) aPropertyValues.get(i);
+ if (aPropertyValue.Name.equals(PropertyNames.PROPERTY_NAME))
+ {
+ aPropertyValue.Value = _newfieldname;
+ aPropertyValues.set(i, aPropertyValue);
+ Name = _newfieldname;
+ return;
+ }
+ }
+ }
+
+ public String getName()
+ {
+ return Name;
+ }
+
+ public String gettablename()
+ {
+ return tablename;
+ }
+
+ private boolean propertyexists(String _propertyname)
+ {
+ boolean bexists = false;
+ try
+ {
+ if (xPropertySet.getPropertySetInfo().hasPropertyByName(_propertyname))
+ {
+ Object oValue = xPropertySet.getPropertyValue(_propertyname);
+ bexists = (!com.sun.star.uno.AnyConverter.isVoid(oValue));
+ }
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace(System.out);
+ }
+ return bexists;
+ }
+
+ public void setFieldProperties(XNameAccess _xNameAccessFieldNode)
+ {
+ try
+ {
+ xPropertySet = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, _xNameAccessFieldNode);
+// Integer Index = (Integer) xPropertySet.getPropertyValue("Index");
+ if (propertyexists(PropertyNames.PROPERTY_NAME))
+ {
+ aPropertyValues.addElement(Properties.createProperty(PropertyNames.PROPERTY_NAME, Name));
+ }
+ if (propertyexists("Type"))
+ {
+ aPropertyValues.addElement(Properties.createProperty("Type", (Integer) xPropertySet.getPropertyValue("Type")));
+ }
+ if (propertyexists("Scale"))
+ {
+ aPropertyValues.addElement(Properties.createProperty("Scale", (Integer) xPropertySet.getPropertyValue("Scale")));
+// Scale =
+ }
+ if (propertyexists("Precision"))
+ {
+ aPropertyValues.addElement(Properties.createProperty("Precision", (Integer) xPropertySet.getPropertyValue("Precision")));
+// Precision = (Integer) xPropertySet.getPropertyValue("Precision");
+ }
+ if (propertyexists("DefaultValue"))
+ {
+ aPropertyValues.addElement(Properties.createProperty("DefaultValue", (Boolean) xPropertySet.getPropertyValue("DefaultValue")));// DefaultValue = (Boolean) xPropertySet.getPropertyValue("DefaultValue");
+ //Type = 4; // TODO wo ist der Fehler?(Integer) xPropertySet.getPropertyValue("Type");
+ }
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace(System.out);
+ }
+ }
+
+ public PropertyValue[] getPropertyValues()
+ {
+ if (aPropertyValues != null)
+ {
+ PropertyValue[] aProperties = new PropertyValue[aPropertyValues.size()];
+ aPropertyValues.toArray(aProperties);
+ return aProperties;
+ }
+ return null;
+ }
+}
diff --git a/wizards/com/sun/star/wizards/table/FieldFormatter.java b/wizards/com/sun/star/wizards/table/FieldFormatter.java
new file mode 100644
index 000000000000..5c5111e273b1
--- /dev/null
+++ b/wizards/com/sun/star/wizards/table/FieldFormatter.java
@@ -0,0 +1,434 @@
+/*************************************************************************
+ *
+ * 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.table;
+
+import com.sun.star.awt.FontDescriptor;
+import com.sun.star.awt.ItemEvent;
+import com.sun.star.awt.XButton;
+import com.sun.star.awt.XItemListener;
+import com.sun.star.awt.XListBox;
+import com.sun.star.awt.XTextComponent;
+import com.sun.star.beans.XPropertySet;
+import com.sun.star.lang.EventObject;
+import com.sun.star.uno.Exception;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.wizards.common.Desktop;
+import com.sun.star.wizards.common.Helper;
+import com.sun.star.wizards.common.PropertyNames;
+import com.sun.star.wizards.db.TableDescriptor;
+import com.sun.star.wizards.ui.UIConsts;
+import com.sun.star.wizards.ui.UnoDialog;
+
+public class FieldFormatter implements XItemListener
+{
+
+ TableWizard CurUnoDialog;
+ TableDescriptor curTableDescriptor;
+ Object oColumnDescriptorModel;
+ XTextComponent txtfieldname;
+ XListBox xlstFieldNames;
+ XButton btnplus;
+ XButton btnminus;
+ XButton btnShiftUp;
+ XButton btnShiftDown;
+ short curtabindex;
+ String TOGGLEBUTTONS = "toggleButtons";
+ String ADDFIELDNAME = "addFieldName";
+ String REMOVEFIELDNAME = "removeFieldName";
+ String MODIFYFIELDNAME = "modifyFieldName";
+ String[] fieldnames;
+ String suntitled;
+ Integer IFieldFormatStep;
+
+ public FieldFormatter(TableWizard _CurUnoDialog, TableDescriptor _curTableDescriptor)
+ {
+ this.CurUnoDialog = _CurUnoDialog;
+ curtabindex = (short) (TableWizard.SOFIELDSFORMATPAGE * 100);
+ IFieldFormatStep = new Integer(TableWizard.SOFIELDSFORMATPAGE);
+ String sFieldName = CurUnoDialog.m_oResource.getResText(UIConsts.RID_TABLE + 23);
+ String sFieldNames = CurUnoDialog.m_oResource.getResText(UIConsts.RID_TABLE + 25);
+ String sfieldinfo = CurUnoDialog.m_oResource.getResText(UIConsts.RID_TABLE + 20);
+ String sbtnplushelptext = CurUnoDialog.m_oResource.getResText(UIConsts.RID_TABLE + 45);
+ String sbtnminushelptext = CurUnoDialog.m_oResource.getResText(UIConsts.RID_TABLE + 46);
+
+ suntitled = CurUnoDialog.m_oResource.getResText(UIConsts.RID_TABLE + 43);
+
+ CurUnoDialog.insertLabel("lblFieldNames",
+ new String[]
+ {
+ PropertyNames.PROPERTY_HEIGHT, 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], sFieldNames, 91, 27, IFieldFormatStep, new Short(curtabindex++), 90
+ });
+
+ try
+ {
+ xlstFieldNames = CurUnoDialog.insertListBox("lstfieldnames", 3, null, this,
+ new String[]
+ {
+ 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[]
+ {
+ 133, "HID:WIZARDS_HID_DLGTABLE_LB_SELFIELDNAMES", 92, 37, IFieldFormatStep, new Short(curtabindex++), 62
+ });
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace(System.out);
+ }
+
+ FontDescriptor oFontDesc = new FontDescriptor();
+ oFontDesc.Name = "StarSymbol";
+
+ btnShiftUp = CurUnoDialog.insertButton("btnShiftUp", "shiftFieldNameUp", this,
+ new String[]
+ {
+ PropertyNames.PROPERTY_ENABLED, "FontDescriptor", 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, oFontDesc, 14, "HID:WIZARDS_HID_DLGTABLE_CMDMOVEFIELDUP", String.valueOf((char) 8743), 158, 139, IFieldFormatStep, new Short(curtabindex++), 14
+ });
+
+ btnShiftDown = CurUnoDialog.insertButton("btnShiftDown", "shiftFieldNameDown", this,
+ new String[]
+ {
+ PropertyNames.PROPERTY_ENABLED, "FontDescriptor", 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, oFontDesc, 14, "HID:WIZARDS_HID_DLGTABLE_CMDMOVEFIELDDOWN", String.valueOf((char) 8744), 158, 156, IFieldFormatStep, new Short(curtabindex++), 14
+ });
+ oFontDesc = new FontDescriptor();
+ oFontDesc.Weight = com.sun.star.awt.FontWeight.BOLD;
+ oFontDesc.Height = (short) 13;
+ btnminus = CurUnoDialog.insertButton("btnminus", "removeFieldName", this,
+ new String[]
+ {
+ "FontDescriptor", 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[]
+ {
+ oFontDesc, 14, "HID:WIZARDS_HID_DLGTABLE_CMDMINUS", "-", 118, 175, IFieldFormatStep, new Short(curtabindex++), 14
+ });
+
+ btnplus = CurUnoDialog.insertButton("btnplus", "addFieldName", this,
+ new String[]
+ {
+ "FontDescriptor", 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[]
+ {
+ oFontDesc, 14, "HID:WIZARDS_HID_DLGTABLE_CMDPLUS", "+", 137, 175, IFieldFormatStep, new Short(curtabindex++), 14
+ });
+
+ CurUnoDialog.insertControlModel("com.sun.star.awt.UnoControlFixedLineModel", "ColDescriptorHeader",
+ new String[]
+ {
+ PropertyNames.PROPERTY_HEIGHT, PropertyNames.PROPERTY_LABEL, "Orientation", PropertyNames.PROPERTY_POSITION_X, PropertyNames.PROPERTY_POSITION_Y, PropertyNames.PROPERTY_STEP, PropertyNames.PROPERTY_TABINDEX, PropertyNames.PROPERTY_WIDTH
+ },
+ new Object[]
+ {
+ 8, sfieldinfo, 0, 158, 27, IFieldFormatStep, new Short(curtabindex++), 165
+ });
+
+
+ CurUnoDialog.insertLabel("lblFieldName",
+ new String[]
+ {
+ PropertyNames.PROPERTY_HEIGHT, 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], sFieldName, 158, 39, IFieldFormatStep, new Short(curtabindex++), 94
+ });
+
+ txtfieldname = CurUnoDialog.insertTextField("txtfieldname", MODIFYFIELDNAME, this,
+ new String[]
+ {
+ PropertyNames.PROPERTY_HEIGHT, PropertyNames.PROPERTY_HELPURL, PropertyNames.PROPERTY_POSITION_X, PropertyNames.PROPERTY_POSITION_Y, PropertyNames.PROPERTY_STEP, PropertyNames.PROPERTY_TABINDEX, "Text", PropertyNames.PROPERTY_WIDTH
+ },
+ new Object[]
+ {
+ UIConsts.INTEGER_12, "HID:WIZARDS_HID_DLGTABLE_COLNAME", 274, 37, IFieldFormatStep, new Short(curtabindex++), "", 50
+ });
+ txtfieldname.addTextListener(CurUnoDialog);
+ CurUnoDialog.getPeerConfiguration().setAccessibleName(btnplus, sbtnplushelptext);
+ CurUnoDialog.getPeerConfiguration().setAccessibleName(btnminus, sbtnminushelptext);
+ }
+
+ public void initialize(TableDescriptor _curTableDescriptor, String[] _fieldnames)
+ {
+ if (oColumnDescriptorModel == null)
+ {
+ oColumnDescriptorModel = CurUnoDialog.insertControlModel("com.sun.star.sdb.ColumnDescriptorControlModel", "oColumnDescriptor",
+ new String[]
+ {
+ PropertyNames.PROPERTY_HEIGHT, PropertyNames.PROPERTY_POSITION_X, PropertyNames.PROPERTY_POSITION_Y, PropertyNames.PROPERTY_STEP, PropertyNames.PROPERTY_TABINDEX, PropertyNames.PROPERTY_WIDTH, "EditWidth"
+ }, // PropertyNames.PROPERTY_HELPURL
+ new Object[]
+ {
+ 85, 158, 49, IFieldFormatStep, new Short(curtabindex++), 166, 50
+ }); //, "HID:WIZARDS_HID_DLGTABLE_COLMODIFIER"
+ curTableDescriptor = _curTableDescriptor;
+ Helper.setUnoPropertyValue(oColumnDescriptorModel, "ActiveConnection", _curTableDescriptor.DBConnection);
+ txtfieldname.setMaxTextLen((short) this.curTableDescriptor.getMaxColumnNameLength());
+ }
+ else
+ {
+ int nStep = ((Integer) Helper.getUnoPropertyValue(oColumnDescriptorModel, PropertyNames.PROPERTY_STEP)).intValue();
+ if (nStep > IFieldFormatStep.intValue())
+ {
+ Helper.setUnoPropertyValue(oColumnDescriptorModel, PropertyNames.PROPERTY_STEP, IFieldFormatStep);
+ CurUnoDialog.repaintDialogStep();
+ }
+ }
+ Helper.setUnoPropertyValue(UnoDialog.getModel(xlstFieldNames), "StringItemList", _fieldnames);
+ Helper.setUnoPropertyValue(UnoDialog.getModel(xlstFieldNames), "SelectedItems", new short[]
+ {
+ 0
+ });
+ updateColumnDescriptor(_fieldnames[0], curTableDescriptor.getByName(_fieldnames[0]));
+ toggleButtons();
+ CurUnoDialog.setFocus("lstfieldnames");
+ }
+
+ public void toggleButtons()
+ {
+ boolean benableShiftUpButton = false;
+ boolean benableShiftDownButton = false;
+ boolean bfieldnameisselected = Helper.getUnoArrayPropertyValue(UnoDialog.getModel(xlstFieldNames), "SelectedItems") != null;
+ int ilistcount = /* xlstFieldNames.getItemCount();*/ UnoDialog.getListBoxItemCount(xlstFieldNames);
+ boolean blistispopulated = (ilistcount > 0);
+ if (bfieldnameisselected)
+ {
+ int iselpos = xlstFieldNames.getSelectedItemPos();
+ benableShiftUpButton = (iselpos != 0);
+ benableShiftDownButton = (iselpos != ilistcount - 1);
+ }
+ Helper.setUnoPropertyValue(UnoDialog.getModel(btnShiftUp), PropertyNames.PROPERTY_ENABLED, new Boolean(benableShiftUpButton));
+ Helper.setUnoPropertyValue(UnoDialog.getModel(btnShiftDown), PropertyNames.PROPERTY_ENABLED, new Boolean(benableShiftDownButton));
+ Helper.setUnoPropertyValue(UnoDialog.getModel(btnminus), PropertyNames.PROPERTY_ENABLED, new Boolean(blistispopulated));
+ CurUnoDialog.setcompleted(TableWizard.SOFIELDSFORMATPAGE, blistispopulated);
+ }
+
+ public void addFieldName()
+ {
+ String snewfieldname = Desktop.getUniqueName(xlstFieldNames.getItems(), suntitled, "");
+ short icount = xlstFieldNames.getItemCount();
+ if (CurUnoDialog.verifyfieldcount(icount))
+ {
+ xlstFieldNames.addItem(snewfieldname, icount);
+ Helper.setUnoPropertyValue(UnoDialog.getModel(xlstFieldNames), "SelectedItems", new short[]
+ {
+ icount
+ });
+ toggleButtons();
+ FieldDescription curfielddescription = new FieldDescription(snewfieldname);
+ CurUnoDialog.fielditems.put(snewfieldname, curfielddescription);
+ curTableDescriptor.addColumn(curfielddescription.getPropertyValues());
+ updateColumnDescriptor(snewfieldname, curTableDescriptor.getByName(snewfieldname));
+ CurUnoDialog.setControlVisible("oColumnDescriptor", true);
+ CurUnoDialog.repaintDialogStep();
+ }
+ }
+
+ public void removeFieldName()
+ {
+ String[] fieldnames = (String[]) Helper.getUnoPropertyValue(UnoDialog.getModel(xlstFieldNames), "StringItemList");
+ short ipos = UnoDialog.getSelectedItemPos(xlstFieldNames);
+ String fieldname = fieldnames[ipos];
+ xlstFieldNames.removeItems(ipos, (short) 1);
+ CurUnoDialog.fielditems.remove(fieldname);
+ int ilistcount = /* xlstFieldNames.getItemCount();*/ UnoDialog.getListBoxItemCount(xlstFieldNames);
+ if ((ipos) < ilistcount)
+ {
+ Helper.setUnoPropertyValue(UnoDialog.getModel(xlstFieldNames), "SelectedItems", new short[]
+ {
+ ipos
+ });
+ }
+ else
+ {
+ if (ilistcount > -1)
+ {
+ ipos = (short) ((short) ilistcount - (short) 1);
+ Helper.setUnoPropertyValue(UnoDialog.getModel(xlstFieldNames), "SelectedItems", new short[]
+ {
+ ipos
+ });
+ }
+ }
+ curTableDescriptor.dropColumnbyName(fieldname);
+ fieldnames = (String[]) Helper.getUnoPropertyValue(UnoDialog.getModel(xlstFieldNames), "StringItemList");
+ boolean benable = ((ipos > -1) && (ipos < fieldnames.length));
+ if (benable)
+ {
+ String snewfieldname = fieldnames[ipos];
+ updateColumnDescriptor(snewfieldname, curTableDescriptor.getByName(snewfieldname));
+ toggleButtons();
+ }
+ else
+ {
+ Helper.setUnoPropertyValue(UnoDialog.getModel(txtfieldname), "Text", "");
+ Helper.setUnoPropertyValue(UnoDialog.getModel(btnminus), PropertyNames.PROPERTY_ENABLED, new Boolean(benable));
+ CurUnoDialog.setcompleted(TableWizard.SOFIELDSFORMATPAGE, benable);
+ }
+ Helper.setUnoPropertyValue(UnoDialog.getModel(btnminus), PropertyNames.PROPERTY_ENABLED, new Boolean(benable));
+ CurUnoDialog.setControlVisible("oColumnDescriptor", benable);
+ CurUnoDialog.repaintDialogStep();
+ }
+
+ public void modifyFieldName()
+ {
+ String newfieldname = txtfieldname.getText();
+ String oldfieldname = xlstFieldNames.getSelectedItem();
+ if (!newfieldname.equals(oldfieldname))
+ {
+ if (curTableDescriptor.modifyColumnName(oldfieldname, newfieldname))
+ {
+ Object oColumn = Helper.getUnoPropertyValue(oColumnDescriptorModel, "Column");
+ Helper.setUnoPropertyValue(oColumn, PropertyNames.PROPERTY_NAME, newfieldname);
+ FieldDescription curfielddescription = (FieldDescription) CurUnoDialog.fielditems.get(oldfieldname);
+ CurUnoDialog.fielditems.remove(oldfieldname);
+ curfielddescription.setName(newfieldname);
+ CurUnoDialog.fielditems.put(newfieldname, curfielddescription);
+ String[] fieldnames = xlstFieldNames.getItems();
+ short ipos = xlstFieldNames.getSelectedItemPos();
+ fieldnames[ipos] = newfieldname;
+ Helper.setUnoPropertyValue(UnoDialog.getModel(xlstFieldNames), "StringItemList", fieldnames);
+ Helper.setUnoPropertyValue(UnoDialog.getModel(xlstFieldNames), "SelectedItems", new short[]
+ {
+ ipos
+ });
+ }
+ }
+ }
+
+ public void shiftFieldNameUp()
+ {
+ short ipos = xlstFieldNames.getSelectedItemPos();
+ String[] snewlist = shiftArrayItem(xlstFieldNames.getItems(), ipos, -1);
+ Helper.setUnoPropertyValue(UnoDialog.getModel(xlstFieldNames), "StringItemList", snewlist);
+ if ((ipos - 1) > -1)
+ {
+ Helper.setUnoPropertyValue(UnoDialog.getModel(xlstFieldNames), "SelectedItems", new short[]
+ {
+ (short) (ipos - 1)
+ });
+ curTableDescriptor.moveColumn(ipos, ipos - 1);
+ }
+ toggleButtons();
+ }
+
+ public void shiftFieldNameDown()
+ {
+ short ipos = xlstFieldNames.getSelectedItemPos();
+ String[] snewlist = shiftArrayItem(xlstFieldNames.getItems(), ipos, 1);
+ Helper.setUnoPropertyValue(UnoDialog.getModel(xlstFieldNames), "StringItemList", snewlist);
+ if ((ipos + 1) < xlstFieldNames.getItemCount())
+ {
+ Helper.setUnoPropertyValue(UnoDialog.getModel(xlstFieldNames), "SelectedItems", new short[]
+ {
+ (short) (ipos + 1)
+ });
+ curTableDescriptor.moveColumn(ipos, ipos + 1);
+ }
+ toggleButtons();
+ }
+
+ public String[] shiftArrayItem(String[] _slist, int _oldindex, int _shiftcount)
+ {
+ int newindex = _oldindex + _shiftcount;
+ if ((newindex >= 0) && (newindex < _slist.length))
+ {
+ String buffer = _slist[newindex];
+ _slist[newindex] = _slist[_oldindex];
+ _slist[_oldindex] = buffer;
+ }
+ return _slist;
+ }
+
+ public boolean updateColumnofColumnDescriptor()
+ {
+ Object oColumn = Helper.getUnoPropertyValue(oColumnDescriptorModel, "Column");
+ XPropertySet xColPropertySet = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, oColumn);
+ if (xColPropertySet != null)
+ {
+ curTableDescriptor.modifyColumn(txtfieldname.getText(), xColPropertySet);
+ return true;
+ }
+ return false;
+ }
+
+ private void updateColumnDescriptor(String _ColumnName, XPropertySet _xColumn)
+ {
+ updateColumnofColumnDescriptor();
+ XPropertySet xNewPropertySet = curTableDescriptor.clonePropertySet(_ColumnName, _xColumn);
+ if (xNewPropertySet != null)
+ {
+ Helper.setUnoPropertyValue(oColumnDescriptorModel, "Column", xNewPropertySet);
+ }
+ txtfieldname.setText(_ColumnName);
+ }
+
+ public XPropertySet clonePropertySet(XPropertySet _xPropertySet)
+ {
+ XPropertySet xlocpropertyset = null;
+ return xlocpropertyset;
+ }
+
+ public void itemStateChanged(ItemEvent arg0)
+ {
+ String fieldname = xlstFieldNames.getSelectedItem();
+ XPropertySet xColumn = curTableDescriptor.getByName(fieldname);
+ updateColumnDescriptor(fieldname, xColumn);
+ toggleButtons();
+ }
+
+ public boolean iscompleted()
+ {
+ String[] sfieldnames = (String[]) Helper.getUnoPropertyValue(UnoDialog.getModel(xlstFieldNames), "StringItemList");
+ return sfieldnames.length > 0;
+ }
+
+ public String[] getFieldNames()
+ {
+ return (String[]) Helper.getUnoPropertyValue(UnoDialog.getModel(xlstFieldNames), "StringItemList");
+ }
+
+ /* (non-Javadoc)
+ * @see com.sun.star.lang.XEventListener#disposing(com.sun.star.lang.EventObject)
+ */
+ public void disposing(EventObject arg0)
+ {
+ // TODO Auto-generated method stub
+ }
+}
diff --git a/wizards/com/sun/star/wizards/table/Finalizer.java b/wizards/com/sun/star/wizards/table/Finalizer.java
new file mode 100644
index 000000000000..83c92aeb731f
--- /dev/null
+++ b/wizards/com/sun/star/wizards/table/Finalizer.java
@@ -0,0 +1,365 @@
+/*************************************************************************
+ *
+ * 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.table;
+
+import com.sun.star.awt.XListBox;
+import com.sun.star.awt.XRadioButton;
+import com.sun.star.awt.XTextComponent;
+import com.sun.star.sdbc.SQLException;
+import com.sun.star.wizards.common.Desktop;
+import com.sun.star.wizards.common.JavaTools;
+import com.sun.star.wizards.common.PropertyNames;
+import com.sun.star.wizards.db.TableDescriptor;
+import com.sun.star.wizards.ui.*;
+
+public class Finalizer
+{
+
+ TableWizard CurUnoDialog;
+ short curtabindex;
+ XRadioButton optModifyTable;
+ XRadioButton optWorkWithTable;
+ XRadioButton optStartFormWizard;
+ XTextComponent txtTableName;
+ XListBox xCatalogListBox;
+ XListBox xSchemaListBox;
+ TableDescriptor curtabledescriptor;
+ public String SETCOMPLETIONFLAG = "setCompletionFlag";
+ public static int WORKWITHTABLEMODE = 0;
+ public static int MODIFYTABLEMODE = 1;
+ public static int STARTFORMWIZARDMODE = 2;
+
+ public Finalizer(TableWizard _CurUnoDialog, TableDescriptor _curtabledescriptor)
+ {
+ try
+ {
+ this.CurUnoDialog = _CurUnoDialog;
+ this.curtabledescriptor = _curtabledescriptor;
+ curtabindex = (short) (TableWizard.SOFINALPAGE * 100);
+ Integer IFINALSTEP = new Integer(TableWizard.SOFINALPAGE);
+ String slblTableName = CurUnoDialog.m_oResource.getResText(UIConsts.RID_TABLE + 34);
+ String slblProceed = CurUnoDialog.m_oResource.getResText(UIConsts.RID_TABLE + 36);
+ String sWorkWithTable = CurUnoDialog.m_oResource.getResText(UIConsts.RID_TABLE + 38);
+ String sStartFormWizard = CurUnoDialog.m_oResource.getResText(UIConsts.RID_TABLE + 39);
+ String sModifyTable = CurUnoDialog.m_oResource.getResText(UIConsts.RID_TABLE + 37);
+ String sCongratulations = CurUnoDialog.m_oResource.getResText(UIConsts.RID_TABLE + 35);
+ String slblCatalog = CurUnoDialog.m_oResource.getResText(UIConsts.RID_TABLE + 49);
+ String slblSchema = CurUnoDialog.m_oResource.getResText(UIConsts.RID_TABLE + 50);
+ String[] sCatalogNames = curtabledescriptor.getCatalogNames();
+ String[] sSchemaNames = curtabledescriptor.getSchemaNames();
+ int nListBoxPosX = 97;
+ int ndiffPosY = 0;
+ boolean bsupportsSchemata = false;
+ boolean bsupportsCatalogs = false;
+
+ CurUnoDialog.insertLabel("lblTableName",
+ new String[]
+ {
+ PropertyNames.PROPERTY_HEIGHT, PropertyNames.PROPERTY_LABEL, PropertyNames.PROPERTY_POSITION_X, PropertyNames.PROPERTY_POSITION_Y, PropertyNames.PROPERTY_STEP, PropertyNames.PROPERTY_WIDTH
+ },
+ new Object[]
+ {
+ UIConsts.INTEGERS[8], slblTableName, 97, 25, IFINALSTEP, 220
+ });
+ txtTableName = CurUnoDialog.insertTextField("txtTableName", SETCOMPLETIONFLAG, this,
+ new String[]
+ {
+ PropertyNames.PROPERTY_HEIGHT, PropertyNames.PROPERTY_HELPURL, PropertyNames.PROPERTY_POSITION_X, PropertyNames.PROPERTY_POSITION_Y, PropertyNames.PROPERTY_STEP, PropertyNames.PROPERTY_TABINDEX, "Text", PropertyNames.PROPERTY_WIDTH
+ },
+ new Object[]
+ {
+ UIConsts.INTEGER_12, "HID:WIZARDS_HID_DLGTABLE_TXT_NAME", 97, 35, IFINALSTEP, new Short(curtabindex++), "", 223
+ });
+ txtTableName.addTextListener(CurUnoDialog);
+ txtTableName.setMaxTextLen((short) this.curtabledescriptor.getMaxTableNameLength());
+ if (this.curtabledescriptor.xDBMetaData.supportsCatalogsInTableDefinitions())
+ {
+ if (sCatalogNames != null)
+ {
+ if (sCatalogNames.length > 0)
+ {
+ bsupportsCatalogs = true;
+ String sCatalog = "";
+ try
+ {
+ sCatalog = curtabledescriptor.DBConnection.getCatalog();
+ }
+ catch (SQLException e1)
+ {
+ e1.printStackTrace(System.out);
+ }
+ CurUnoDialog.insertLabel("lblCatalog",
+ new String[]
+ {
+ PropertyNames.PROPERTY_HEIGHT, PropertyNames.PROPERTY_LABEL, PropertyNames.PROPERTY_POSITION_X, PropertyNames.PROPERTY_POSITION_Y, PropertyNames.PROPERTY_STEP, PropertyNames.PROPERTY_TABINDEX, PropertyNames.PROPERTY_WIDTH
+ },
+ new Object[]
+ {
+ 8, slblCatalog, new Integer(nListBoxPosX), 52, IFINALSTEP, new Short(curtabindex++), 120
+ });
+
+ try
+ {
+ xCatalogListBox = CurUnoDialog.insertListBox("lstCatalog", null, null,
+ new String[]
+ {
+ "Dropdown", PropertyNames.PROPERTY_HEIGHT, PropertyNames.PROPERTY_HELPURL, "LineCount", PropertyNames.PROPERTY_POSITION_X, PropertyNames.PROPERTY_POSITION_Y, PropertyNames.PROPERTY_STEP, "StringItemList", PropertyNames.PROPERTY_TABINDEX, PropertyNames.PROPERTY_WIDTH
+ },
+ new Object[]
+ {
+ Boolean.TRUE, 12, "HID:WIZARDS_HID_DLGTABLE_LST_CATALOG", new Short(UnoDialog.getListBoxLineCount()), new Integer(nListBoxPosX), 62, IFINALSTEP, sCatalogNames, new Short(curtabindex++), 80
+ });
+ int isel = JavaTools.FieldInList(sCatalogNames, sCatalog);
+ if (isel < 0)
+ {
+ isel = 0;
+ }
+ CurUnoDialog.setControlProperty("lstCatalog", "SelectedItems", new short[]
+ {
+ (short) isel
+ });
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace(System.out);
+ }
+ nListBoxPosX = 200;
+ }
+ }
+ }
+ if (this.curtabledescriptor.xDBMetaData.supportsSchemasInTableDefinitions())
+ {
+ if (sSchemaNames != null)
+ {
+ if (sSchemaNames.length > 0)
+ {
+ bsupportsSchemata = true;
+ String sSchema = "";
+ try
+ {
+ sSchema = (String) curtabledescriptor.getDataSourcePropertySet().getPropertyValue("User");
+ }
+ catch (Exception e1)
+ {
+ e1.printStackTrace(System.out);
+ }
+ CurUnoDialog.insertLabel("lblSchema",
+ new String[]
+ {
+ PropertyNames.PROPERTY_HEIGHT, PropertyNames.PROPERTY_LABEL, PropertyNames.PROPERTY_POSITION_X, PropertyNames.PROPERTY_POSITION_Y, PropertyNames.PROPERTY_STEP, PropertyNames.PROPERTY_TABINDEX, PropertyNames.PROPERTY_WIDTH
+ },
+ new Object[]
+ {
+ 8, slblSchema, new Integer(nListBoxPosX), 52, IFINALSTEP, new Short(curtabindex++), 80
+ });
+
+ try
+ {
+ xSchemaListBox = CurUnoDialog.insertListBox("lstSchema", null, null,
+ new String[]
+ {
+ "Dropdown", PropertyNames.PROPERTY_HEIGHT, PropertyNames.PROPERTY_HELPURL, "LineCount", PropertyNames.PROPERTY_POSITION_X, PropertyNames.PROPERTY_POSITION_Y, PropertyNames.PROPERTY_STEP, "StringItemList", PropertyNames.PROPERTY_TABINDEX, PropertyNames.PROPERTY_WIDTH
+ },
+ new Object[]
+ {
+ Boolean.TRUE, 12, "HID:WIZARDS_HID_DLGTABLE_LST_SCHEMA", new Short(UnoDialog.getListBoxLineCount()), new Integer(nListBoxPosX), 62, IFINALSTEP, sSchemaNames, new Short(curtabindex++), 80
+ });
+ int isel = JavaTools.FieldInList(sSchemaNames, sSchema);
+ if (isel < 0)
+ {
+ isel = 0;
+ }
+ CurUnoDialog.setControlProperty("lstSchema", "SelectedItems", new short[]
+ {
+ (short) isel
+ });
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace(System.out);
+ }
+ }
+ }
+ }
+ if ((!bsupportsCatalogs) && (!bsupportsSchemata))
+ {
+ CurUnoDialog.insertLabel("lblcongratulations",
+ 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[]
+ {
+ 16, sCongratulations, Boolean.TRUE, 97, 62, IFINALSTEP, new Short(curtabindex++), 226
+ });
+ }
+ else
+ {
+ ndiffPosY = 10;
+ }
+ CurUnoDialog.insertLabel("lblProceed",
+ new String[]
+ {
+ PropertyNames.PROPERTY_HEIGHT, 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], slblProceed, 97, new Integer(82 + ndiffPosY), IFINALSTEP, new Short(curtabindex++), 227
+ });
+ optWorkWithTable = CurUnoDialog.insertRadioButton("optWorkWithTable", null,
+ new String[]
+ {
+ 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[]
+ {
+ UIConsts.INTEGERS[8], "HID:WIZARDS_HID_DLGTABLE_OPT_WORKWITHTABLE", sWorkWithTable, 101, new Integer(97 + ndiffPosY), new Short((short) 1), IFINALSTEP, new Short(curtabindex++), 177
+ });
+ optModifyTable = CurUnoDialog.insertRadioButton("optModifyTable", null,
+ 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_DLGTABLE_OPT_MODIFYTABLE", sModifyTable, 101, new Integer(109 + ndiffPosY), IFINALSTEP, new Short(curtabindex++), 177
+ });
+ optStartFormWizard = CurUnoDialog.insertRadioButton("optStartFormWizard", null,
+ 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_DLGTABLE_OPT_STARTFORMWIZARD", sStartFormWizard, 101, new Integer(121 + ndiffPosY), IFINALSTEP, new Short(curtabindex++), 177
+ });
+ }
+ catch (SQLException e)
+ {
+ e.printStackTrace(System.out);
+ }
+ }
+
+ public void initialize(String _firsttablename)
+ {
+ setTableName(_firsttablename);
+ }
+
+ public int finish()
+ {
+ if (optWorkWithTable.getState())
+ {
+ return WORKWITHTABLEMODE;
+ }
+ else if (optModifyTable.getState())
+ {
+ return MODIFYTABLEMODE;
+ }
+ else
+ {
+ return STARTFORMWIZARDMODE;
+ }
+ }
+
+ public String getComposedTableName(String _stablename)
+ {
+ String scatalogname = null;
+ String sschemaname = null;
+ if (xCatalogListBox != null)
+ {
+ scatalogname = xCatalogListBox.getSelectedItem();
+ }
+ if (xSchemaListBox != null)
+ {
+ sschemaname = xSchemaListBox.getSelectedItem();
+ }
+ return curtabledescriptor.getComposedTableName(scatalogname, sschemaname, _stablename);
+ }
+
+ public void setTableName(String _tablename)
+ {
+ if (txtTableName.getText().equals(""))
+ {
+ String ssuffix = Desktop.getIncrementSuffix(curtabledescriptor.getTableNamesAsNameAccess(), getComposedTableName(_tablename));
+ txtTableName.setText(_tablename + ssuffix);
+ setCompletionFlag();
+ }
+ }
+
+ public String getTableName()
+ {
+ return txtTableName.getText();
+ }
+
+ public String getTableName(String _firsttablename)
+ {
+ if (txtTableName.getText().equals(""))
+ {
+ setTableName(_firsttablename);
+ }
+ return txtTableName.getText();
+ }
+
+ public String getSchemaName()
+ {
+ if (xSchemaListBox != null)
+ {
+ return this.xSchemaListBox.getSelectedItem();
+ }
+ else
+ {
+ return "";
+ }
+ }
+
+ public String getCatalogName()
+ {
+ if (xCatalogListBox != null)
+ {
+ return this.xCatalogListBox.getSelectedItem();
+ }
+ else
+ {
+ return "";
+ }
+ }
+
+ public boolean iscompleted()
+ {
+ return (txtTableName.getText().length() > 0);
+ }
+
+ public void setCompletionFlag()
+ {
+ CurUnoDialog.setcompleted(TableWizard.SOFINALPAGE, iscompleted());
+ }
+
+ public void setFocusToTableNameControl()
+ {
+ CurUnoDialog.setFocus("txtTableName");
+ }
+}
diff --git a/wizards/com/sun/star/wizards/table/MANIFEST.MF b/wizards/com/sun/star/wizards/table/MANIFEST.MF
new file mode 100644
index 000000000000..0fcfe1d3e8f1
--- /dev/null
+++ b/wizards/com/sun/star/wizards/table/MANIFEST.MF
@@ -0,0 +1,2 @@
+RegistrationClassName: com.sun.star.wizards.table.CallTableWizard
+UNO-Type-Path:
diff --git a/wizards/com/sun/star/wizards/table/PrimaryKeyHandler.java b/wizards/com/sun/star/wizards/table/PrimaryKeyHandler.java
new file mode 100644
index 000000000000..aec63204f64a
--- /dev/null
+++ b/wizards/com/sun/star/wizards/table/PrimaryKeyHandler.java
@@ -0,0 +1,461 @@
+/*************************************************************************
+ *
+ * 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.table;
+
+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.beans.XPropertySet;
+import com.sun.star.lang.IllegalArgumentException;
+import com.sun.star.uno.AnyConverter;
+import com.sun.star.wizards.common.Helper;
+import com.sun.star.wizards.common.JavaTools;
+import com.sun.star.wizards.common.PropertyNames;
+import com.sun.star.wizards.db.TableDescriptor;
+import com.sun.star.wizards.db.TypeInspector;
+import com.sun.star.wizards.ui.FieldSelection;
+import com.sun.star.wizards.ui.UIConsts;
+import com.sun.star.wizards.ui.UnoDialog;
+import com.sun.star.wizards.ui.XFieldSelectionListener;
+
+public class PrimaryKeyHandler implements XFieldSelectionListener
+{
+
+ private TableWizard CurUnoDialog;
+ private short curtabindex;
+ private final static String SPRIMEKEYMODE = "togglePrimeKeyFields";
+ private final static String SSINGLEKEYMODE = "toggleSinglePrimeKeyFields";
+ private final static String SSEVERALKEYMODE = "toggleSeveralPrimeKeyFields";
+ private XRadioButton optAddAutomatically;
+ private XRadioButton optUseExisting;
+ private XRadioButton optUseSeveral;
+ private XCheckBox chkUsePrimaryKey;
+ private XCheckBox chkcreatePrimaryKey;
+ private XCheckBox chkApplyAutoValueExisting;
+ private XCheckBox chkApplyAutoValueAutomatic;
+ private XListBox lstSinglePrimeKey;
+ private XFixedText lblPrimeFieldName;
+ private FieldSelection curPrimaryKeySelection;
+ private String[] fieldnames;
+ private TableDescriptor curTableDescriptor;
+ private int nAutoPrimeKeyDataType;
+ private boolean bAutoPrimaryKeysupportsAutoIncrmentation;
+ private final static String SAUTOMATICKEYFIELDNAME = "ID";
+
+ public PrimaryKeyHandler(TableWizard _CurUnoDialog, TableDescriptor _curTableDescriptor)
+ {
+ this.CurUnoDialog = _CurUnoDialog;
+ curTableDescriptor = _curTableDescriptor;
+ bAutoPrimaryKeysupportsAutoIncrmentation = isAutoPrimeKeyAutoIncrementationsupported();
+ curtabindex = (short) ((TableWizard.SOPRIMARYKEYPAGE * 100) - 20);
+ Integer IPRIMEKEYSTEP = new Integer(TableWizard.SOPRIMARYKEYPAGE);
+ final String sExplanations = CurUnoDialog.m_oResource.getResText(UIConsts.RID_TABLE + 26);
+ final String screatePrimaryKey = CurUnoDialog.m_oResource.getResText(UIConsts.RID_TABLE + 27);
+ final String slblPrimeFieldName = CurUnoDialog.m_oResource.getResText(UIConsts.RID_TABLE + 31);
+ final String sApplyAutoValue = CurUnoDialog.m_oResource.getResText(UIConsts.RID_TABLE + 33);
+ final String sAddAutomatically = CurUnoDialog.m_oResource.getResText(UIConsts.RID_TABLE + 28);
+ final String sUseExisting = CurUnoDialog.m_oResource.getResText(UIConsts.RID_TABLE + 29);
+ final String sUseSeveral = CurUnoDialog.m_oResource.getResText(UIConsts.RID_TABLE + 30);
+ final String slblAvailableFields = CurUnoDialog.m_oResource.getResText(UIConsts.RID_QUERY + 4);
+ final String slblSelPrimaryFields = CurUnoDialog.m_oResource.getResText(UIConsts.RID_TABLE + 32);
+ CurUnoDialog.insertLabel("lblExplanation",
+ 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[]
+ {
+ 40, sExplanations, Boolean.TRUE, 91, 27, IPRIMEKEYSTEP, new Short(curtabindex++), 233
+ });
+
+ chkcreatePrimaryKey = CurUnoDialog.insertCheckBox("chkcreatePrimaryKey", SPRIMEKEYMODE, this,
+ new String[]
+ {
+ 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[]
+ {
+ UIConsts.INTEGERS[8], "HID:WIZARDS_HID_DLGTABLE_CHK_USEPRIMEKEY", screatePrimaryKey, 97, 70, new Short((short) 1), IPRIMEKEYSTEP, new Short(curtabindex++), 160
+ });
+
+ optAddAutomatically = CurUnoDialog.insertRadioButton("optAddAutomatically", SPRIMEKEYMODE, this,
+ new String[]
+ {
+ 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[]
+ {
+ UIConsts.INTEGERS[8], "HID:WIZARDS_HID_DLGTABLE_OPT_PK_AUTOMATIC", sAddAutomatically, 106, 82, new Short((short) 1), IPRIMEKEYSTEP, new Short(curtabindex++), 200
+ });
+
+ optUseExisting = CurUnoDialog.insertRadioButton("optUseExisting", SPRIMEKEYMODE, 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
+ }, //94
+ new Object[]
+ {
+ UIConsts.INTEGERS[8], "HID:WIZARDS_HID_DLGTABLE_OPT_PK_SINGLE", sUseExisting, 106, 104, IPRIMEKEYSTEP, new Short(curtabindex++), 200
+ });
+
+ optUseSeveral = CurUnoDialog.insertRadioButton("optUseSeveral", SPRIMEKEYMODE, 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_DLGTABLE_OPT_PK_SEVERAL", sUseSeveral, 106, 132, IPRIMEKEYSTEP, new Short(curtabindex++), 200
+ });
+
+ chkApplyAutoValueAutomatic = CurUnoDialog.insertCheckBox("chkApplyAutoValueAutomatic", SPRIMEKEYMODE, 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
+ }, //107
+ new Object[]
+ {
+ UIConsts.INTEGERS[8], "HID:WIZARDS_HID_DLGTABLE_CK_PK_AUTOVALUE_AUTOMATIC", sApplyAutoValue, 116, 92, IPRIMEKEYSTEP, new Short(curtabindex++), 68
+ });
+
+ lblPrimeFieldName = CurUnoDialog.insertLabel("lblPrimeFieldName",
+ new String[]
+ {
+ PropertyNames.PROPERTY_ENABLED, PropertyNames.PROPERTY_HEIGHT, 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], slblPrimeFieldName, 116, 117, IPRIMEKEYSTEP, new Short(curtabindex++), 46
+ });
+
+ lstSinglePrimeKey = CurUnoDialog.insertListBox("lstSinglePrimeKey", "onPrimeKeySelected", null, this,
+ new String[]
+ {
+ "Dropdown",
+ PropertyNames.PROPERTY_ENABLED,
+ PropertyNames.PROPERTY_HEIGHT,
+ PropertyNames.PROPERTY_HELPURL,
+ "LineCount",
+ PropertyNames.PROPERTY_POSITION_X,
+ PropertyNames.PROPERTY_POSITION_Y,
+ PropertyNames.PROPERTY_STEP,
+ PropertyNames.PROPERTY_TABINDEX,
+ PropertyNames.PROPERTY_WIDTH
+ },
+ new Object[]
+ {
+ Boolean.TRUE,
+ Boolean.FALSE,
+ 12,
+ "HID:WIZARDS_HID_DLGTABLE_LB_PK_FIELDNAME",
+ Short.valueOf(UnoDialog.getListBoxLineCount()),
+ 162,
+ 115,
+ IPRIMEKEYSTEP,
+ new Short(curtabindex++),
+ 80
+ });
+
+ chkApplyAutoValueExisting = CurUnoDialog.insertCheckBox("chkApplyAutoValueExisting", SPRIMEKEYMODE, 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
+ }, //107
+ new Object[]
+ {
+ UIConsts.INTEGERS[8], "HID:WIZARDS_HID_DLGTABLE_CK_PK_AUTOVALUE", sApplyAutoValue, 248, 117, IPRIMEKEYSTEP, new Short(curtabindex++), 66
+ });
+ curPrimaryKeySelection = new FieldSelection(CurUnoDialog, IPRIMEKEYSTEP.intValue(), 116, 142, 208, 47, slblAvailableFields, slblSelPrimaryFields, 41234, false);
+ curPrimaryKeySelection.addFieldSelectionListener(this);
+
+ }
+
+ public void initialize()
+ {
+ // boolean breselect;
+ fieldnames = curTableDescriptor.getNonBinaryFieldNames();
+ String[] skeyfieldnames = curPrimaryKeySelection.getSelectedFieldNames();
+ curPrimaryKeySelection.initialize(fieldnames, false);
+ if (skeyfieldnames != null)
+ {
+ if (skeyfieldnames.length > 0)
+ {
+ String[] snewkeyfieldnames = JavaTools.removeOutdatedFields(skeyfieldnames, fieldnames);
+ curPrimaryKeySelection.setSelectedFieldNames(snewkeyfieldnames);
+ }
+ }
+ String selfield = lstSinglePrimeKey.getSelectedItem();
+ Helper.setUnoPropertyValue(UnoDialog.getModel(lstSinglePrimeKey), "StringItemList", fieldnames);
+ if (selfield != null)
+ {
+ if (JavaTools.FieldInList(fieldnames, selfield) > -1)
+ {
+ lstSinglePrimeKey.selectItem(selfield, true);
+ }
+ }
+ togglePrimeKeyFields();
+ }
+
+ private boolean isAutoPrimeKeyAutoIncrementationsupported()
+ {
+ TypeInspector.TypeInfo aAutoPrimeTypeInfo;
+ aAutoPrimeTypeInfo = curTableDescriptor.oTypeInspector.findAutomaticPrimaryKeyType();
+ return aAutoPrimeTypeInfo.bisAutoIncrementable;
+ }
+
+ public boolean iscompleted()
+ {
+ if (chkcreatePrimaryKey.getState() == 0)
+ {
+ return true;
+ }
+ if (this.optAddAutomatically.getState())
+ {
+ return true;
+ }
+ if (optUseExisting.getState())
+ {
+ fieldnames = curTableDescriptor.getNonBinaryFieldNames();
+ String selfield = lstSinglePrimeKey.getSelectedItem();
+ if (selfield != null)
+ {
+ return (JavaTools.FieldInList(fieldnames, selfield) > -1);
+ }
+ }
+ if (optUseSeveral.getState())
+ {
+ fieldnames = curTableDescriptor.getNonBinaryFieldNames();
+ String[] skeyfieldnames = curPrimaryKeySelection.getSelectedFieldNames();
+ String[] snewkeyfieldnames = JavaTools.removeOutdatedFields(skeyfieldnames, fieldnames);
+ return (snewkeyfieldnames.length > 0);
+ }
+ return false;
+ }
+
+ public void togglePrimeKeyFields()
+ {
+ boolean bdoEnable = (this.chkcreatePrimaryKey.getState() == 1);
+ Helper.setUnoPropertyValue(UnoDialog.getModel(optAddAutomatically), PropertyNames.PROPERTY_ENABLED, new Boolean(bdoEnable));
+ Helper.setUnoPropertyValue(UnoDialog.getModel(chkApplyAutoValueAutomatic), PropertyNames.PROPERTY_ENABLED, new Boolean(bAutoPrimaryKeysupportsAutoIncrmentation && bdoEnable));
+ Helper.setUnoPropertyValue(UnoDialog.getModel(optUseExisting), PropertyNames.PROPERTY_ENABLED, new Boolean(bdoEnable));
+ Helper.setUnoPropertyValue(UnoDialog.getModel(optUseSeveral), PropertyNames.PROPERTY_ENABLED, new Boolean(bdoEnable));
+ //toggle subcontrols of the radiobuttons...
+ toggleAutomaticAutoValueCheckBox();
+ boolean benableSinglePrimekeyControls = bdoEnable && optUseExisting.getState();
+ toggleSinglePrimeKeyFields(benableSinglePrimekeyControls);
+ boolean benableSeveralPrimekeyControls = bdoEnable && optUseSeveral.getState();
+ curPrimaryKeySelection.toggleListboxControls(new Boolean(benableSeveralPrimekeyControls));
+ // toggle the following steps of the dialog...
+ if (!bdoEnable)
+ {
+ CurUnoDialog.setcompleted(TableWizard.SOPRIMARYKEYPAGE, true);
+ }
+ else
+ {
+ if (benableSeveralPrimekeyControls)
+ {
+ CurUnoDialog.setcompleted(TableWizard.SOPRIMARYKEYPAGE, (curPrimaryKeySelection.getSelectedFieldNames().length > 0));
+ }
+ else if (benableSinglePrimekeyControls)
+ {
+ CurUnoDialog.setcompleted(TableWizard.SOPRIMARYKEYPAGE, UnoDialog.isListBoxSelected(lstSinglePrimeKey)); //.getSelectedItemPos() != -1);
+ }
+ else if (optAddAutomatically.getState())
+ {
+ CurUnoDialog.setcompleted(TableWizard.SOPRIMARYKEYPAGE, true);
+ }
+ }
+ }
+
+ private boolean isAutoIncrementatable(String _fieldname)
+ {
+ boolean bisAutoIncrementable = false;
+ try
+ {
+ XPropertySet xColPropertySet = curTableDescriptor.getByName(_fieldname);
+ if (xColPropertySet != null)
+ {
+ if (curTableDescriptor.getDBDataTypeInspector() != null)
+ {
+ return curTableDescriptor.getDBDataTypeInspector().isAutoIncrementable(xColPropertySet);
+ }
+ }
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace(System.out);
+ }
+ return false;
+ }
+
+ public boolean isAutomaticMode()
+ {
+ boolean bisAutomaticMode = false;
+ if (chkcreatePrimaryKey.getState() == 1)
+ {
+ bisAutomaticMode = ((Short) Helper.getUnoPropertyValue(UnoDialog.getModel(optAddAutomatically), PropertyNames.PROPERTY_STATE)).shortValue() == (short) 1;
+ }
+ return bisAutomaticMode;
+ }
+
+ public String getAutomaticFieldName()
+ {
+ return SAUTOMATICKEYFIELDNAME;
+ }
+
+ public boolean isAutoIncremented()
+ {
+ boolean bischecked = false;
+ if (chkcreatePrimaryKey.getState() == 1)
+ {
+ boolean bisAutomaticMode = ((Short) Helper.getUnoPropertyValue(UnoDialog.getModel(optAddAutomatically), PropertyNames.PROPERTY_STATE)).shortValue() == (short) 1;
+ boolean bisExistingMode = ((Short) Helper.getUnoPropertyValue(UnoDialog.getModel(optUseExisting), PropertyNames.PROPERTY_STATE)).shortValue() == (short) 1;
+ if (bisAutomaticMode)
+ {
+ bischecked = chkApplyAutoValueAutomatic.getState() == (short) 1;
+ }
+ else if (bisExistingMode)
+ {
+ bischecked = chkApplyAutoValueExisting.getState() == (short) 1;
+ }
+ }
+ return bischecked;
+ }
+
+ public void onPrimeKeySelected()
+ {
+ try
+ {
+ String selfieldname = lstSinglePrimeKey.getSelectedItem();
+ boolean bdoenable = isAutoIncrementatable(selfieldname);
+ CurUnoDialog.setcompleted(TableWizard.SOPRIMARYKEYPAGE, lstSinglePrimeKey.getSelectedItemPos() != -1);
+ Helper.setUnoPropertyValue(UnoDialog.getModel(chkApplyAutoValueExisting), PropertyNames.PROPERTY_ENABLED, new Boolean(bdoenable));
+ XPropertySet xColPropertySet = curTableDescriptor.getByName(selfieldname);
+ boolean bIsAutoIncremented = ((Boolean) xColPropertySet.getPropertyValue("IsAutoIncrement")).booleanValue();
+ if (bIsAutoIncremented)
+ {
+ Helper.setUnoPropertyValue(UnoDialog.getModel(chkApplyAutoValueExisting), PropertyNames.PROPERTY_STATE, new Short((short) 1));
+ }
+ else
+ {
+ Helper.setUnoPropertyValue(UnoDialog.getModel(chkApplyAutoValueExisting), PropertyNames.PROPERTY_STATE, new Short((short) 0));
+ }
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace(System.out);
+ }
+ }
+
+ private void toggleAutomaticAutoValueCheckBox()
+ {
+ try
+ {
+ boolean bisAutomaticMode = AnyConverter.toBoolean(Helper.getUnoPropertyValue(UnoDialog.getModel(optAddAutomatically), PropertyNames.PROPERTY_ENABLED));
+ boolean bdoenable = bAutoPrimaryKeysupportsAutoIncrmentation && optAddAutomatically.getState() && bisAutomaticMode;
+ Helper.setUnoPropertyValue(UnoDialog.getModel(chkApplyAutoValueAutomatic), PropertyNames.PROPERTY_ENABLED, new Boolean(bdoenable));
+ }
+ catch (IllegalArgumentException e)
+ {
+ e.printStackTrace(System.out);
+ }
+ }
+
+ private void toggleSinglePrimeKeyFields(boolean _bdoenable)
+ {
+ Helper.setUnoPropertyValue(UnoDialog.getModel(lblPrimeFieldName), PropertyNames.PROPERTY_ENABLED, new Boolean(_bdoenable));
+ Helper.setUnoPropertyValue(UnoDialog.getModel(lstSinglePrimeKey), PropertyNames.PROPERTY_ENABLED, new Boolean(_bdoenable));
+ Helper.setUnoPropertyValue(UnoDialog.getModel(chkApplyAutoValueExisting), PropertyNames.PROPERTY_ENABLED, new Boolean(_bdoenable));
+ boolean bdoenableAutoValueCheckBox = (isAutoIncrementatable(lstSinglePrimeKey.getSelectedItem()) && _bdoenable);
+ Helper.setUnoPropertyValue(UnoDialog.getModel(chkApplyAutoValueExisting), PropertyNames.PROPERTY_ENABLED, new Boolean(bdoenableAutoValueCheckBox));
+ }
+
+ private void toggleSeveralPrimeKeyFields()
+ {
+ boolean bdoEnable = (this.optUseSeveral.getState());
+ curPrimaryKeySelection.toggleListboxControls(new Boolean(bdoEnable));
+ }
+
+ public String[] getPrimaryKeyFields(TableDescriptor _curtabledescriptor)
+ {
+ if (chkcreatePrimaryKey.getState() == 0)
+ {
+ return null;
+ }
+ if (fieldnames == null)
+ {
+ initialize();
+ }
+ if (optUseSeveral.getState())
+ {
+ return curPrimaryKeySelection.getSelectedFieldNames();
+ }
+ else if (optUseExisting.getState())
+ {
+ return (new String[]
+ {
+ lstSinglePrimeKey.getSelectedItem()
+ });
+ }
+ else if (optAddAutomatically.getState())
+ {
+ return (new String[]
+ {
+ SAUTOMATICKEYFIELDNAME
+ });
+ }
+ return null;
+ }
+
+ public int getID()
+ {
+ return 0;
+ }
+
+ public void moveItemDown(String Selitem)
+ {
+ }
+
+ public void moveItemUp(String Selitem)
+ {
+ }
+
+ public void setID(String sIncSuffix)
+ {
+ }
+
+ public void shiftFromLeftToRight(String[] SelItems, String[] NewItems)
+ {
+ CurUnoDialog.setcompleted(TableWizard.SOPRIMARYKEYPAGE, (curPrimaryKeySelection.getSelectedFieldNames().length > 0));
+ }
+
+ public void shiftFromRightToLeft(String[] OldSelItems, String[] NewItems)
+ {
+ CurUnoDialog.setcompleted(TableWizard.SOPRIMARYKEYPAGE, (curPrimaryKeySelection.getSelectedFieldNames().length > 0));
+ }
+}
diff --git a/wizards/com/sun/star/wizards/table/ScenarioSelector.java b/wizards/com/sun/star/wizards/table/ScenarioSelector.java
new file mode 100644
index 000000000000..e7b94596a90a
--- /dev/null
+++ b/wizards/com/sun/star/wizards/table/ScenarioSelector.java
@@ -0,0 +1,386 @@
+/*************************************************************************
+ *
+ * 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.table;
+
+import java.util.Vector;
+
+import com.sun.star.awt.ItemEvent;
+import com.sun.star.awt.XFixedText;
+import com.sun.star.awt.XItemListener;
+import com.sun.star.awt.XListBox;
+import com.sun.star.awt.XRadioButton;
+import com.sun.star.beans.PropertyValue;
+import com.sun.star.container.XNameAccess;
+import com.sun.star.lang.EventObject;
+import com.sun.star.lang.Locale;
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.wizards.common.Configuration;
+import com.sun.star.wizards.common.Desktop;
+import com.sun.star.wizards.common.Helper;
+import com.sun.star.wizards.common.JavaTools;
+import com.sun.star.wizards.common.PropertyNames;
+import com.sun.star.wizards.db.TableDescriptor;
+import com.sun.star.wizards.ui.FieldSelection;
+import com.sun.star.wizards.ui.UIConsts;
+import com.sun.star.wizards.ui.UnoDialog;
+import com.sun.star.wizards.ui.XFieldSelectionListener;
+
+/**
+ * @author Administrator
+ *
+ * To change the template for this generated type comment go to
+ * Window&gt;Preferences&gt;Java&gt;Code Generation&gt;Code and Comments
+ */
+public class ScenarioSelector extends FieldSelection implements XItemListener, XFieldSelectionListener
+{
+ final static int PRIVATE = 0;
+ final static int BUSINESS = 1;
+
+ private XFixedText lblExplanation;
+ private XFixedText lblCategories;
+ private XRadioButton optBusiness;
+ private XRadioButton optPrivate;
+ private XListBox xTableListBox;
+ private TableWizard CurTableWizardUnoDialog;
+ private TableDescriptor curtabledescriptor;
+ private CGCategory oCGCategory;
+ protected CGTable oCGTable;
+ private String SELECTCATEGORY = "selectCategory";
+ private int curcategory;
+ protected boolean bcolumnnameislimited;
+ private int imaxcolumnchars;
+ private String smytable;
+ private Locale aLocale;
+ private XMultiServiceFactory xMSF;
+
+ public ScenarioSelector(TableWizard _CurUnoDialog, TableDescriptor _curtabledescriptor, String _reslblFields, String _reslblSelFields)
+ {
+ super(_CurUnoDialog, TableWizard.SOMAINPAGE, 91, 108, 230, 80, _reslblFields, _reslblSelFields, 41209, true);
+ CurTableWizardUnoDialog = _CurUnoDialog;
+ xMSF = CurUnoDialog.xMSF;
+ aLocale = Configuration.getOfficeLocale(xMSF);
+ curtabledescriptor = _curtabledescriptor;
+ imaxcolumnchars = this.curtabledescriptor.getMaxColumnNameLength();
+ bcolumnnameislimited = (imaxcolumnchars > 0) && (imaxcolumnchars < 16);
+ addFieldSelectionListener(this);
+ short pretabindex = (short) (50);
+ String sExplanation = CurUnoDialog.m_oResource.getResText(UIConsts.RID_TABLE + 14);
+ String sCategories = CurUnoDialog.m_oResource.getResText(UIConsts.RID_TABLE + 15);
+ String sBusiness = CurUnoDialog.m_oResource.getResText(UIConsts.RID_TABLE + 16);
+ String sPrivate = CurUnoDialog.m_oResource.getResText(UIConsts.RID_TABLE + 17);
+ String sTableNames = CurUnoDialog.m_oResource.getResText(UIConsts.RID_TABLE + 18);
+ smytable = CurUnoDialog.m_oResource.getResText(UIConsts.RID_TABLE + 44);
+ Integer IMAINSTEP = new Integer(TableWizard.SOMAINPAGE);
+ oCGCategory = new CGCategory(CurUnoDialog.xMSF);
+ oCGTable = new CGTable(CurUnoDialog.xMSF);
+ lblExplanation = CurUnoDialog.insertLabel("lblScenarioExplanation",
+ 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[]
+ {
+ 32, sExplanation, Boolean.TRUE, 91, 27, IMAINSTEP, new Short(pretabindex++), 233
+ });
+
+ lblCategories = CurUnoDialog.insertLabel("lblCategories",
+ new String[]
+ {
+ PropertyNames.PROPERTY_HEIGHT, PropertyNames.PROPERTY_LABEL, PropertyNames.PROPERTY_POSITION_X, PropertyNames.PROPERTY_POSITION_Y, PropertyNames.PROPERTY_STEP, PropertyNames.PROPERTY_TABINDEX, PropertyNames.PROPERTY_WIDTH
+ },
+ new Object[]
+ {
+ 8, sCategories, 91, 60, IMAINSTEP, new Short(pretabindex++), 100
+ });
+
+ optBusiness = CurTableWizardUnoDialog.insertRadioButton("optBusiness", SELECTCATEGORY, this,
+ new String[]
+ {
+ 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[]
+ {
+ UIConsts.INTEGERS[8], "HID:WIZARDS_HID_DLGTABLE_OPTBUSINESS", sBusiness, 98, 70, new Short((short) 1), IMAINSTEP, new Short(pretabindex++), 78
+ });
+
+ optPrivate = CurTableWizardUnoDialog.insertRadioButton("optPrivate", SELECTCATEGORY, 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_DLGTABLE_OPTPRIVATE", sPrivate, 182, 70, IMAINSTEP, new Short(pretabindex++), 90
+ });
+
+ CurUnoDialog.insertLabel("lblTableNames",
+ new String[]
+ {
+ PropertyNames.PROPERTY_HEIGHT, PropertyNames.PROPERTY_LABEL, PropertyNames.PROPERTY_POSITION_X, PropertyNames.PROPERTY_POSITION_Y, PropertyNames.PROPERTY_STEP, PropertyNames.PROPERTY_TABINDEX, PropertyNames.PROPERTY_WIDTH
+ },
+ new Object[]
+ {
+ 8, sTableNames, 91, 82, IMAINSTEP, new Short(pretabindex++), 80
+ });
+
+ try
+ {
+ xTableListBox = CurUnoDialog.insertListBox("lstTableNames", 3, null, this,
+ new String[]
+ {
+ "Dropdown", PropertyNames.PROPERTY_HEIGHT, PropertyNames.PROPERTY_HELPURL, "LineCount", PropertyNames.PROPERTY_POSITION_X, PropertyNames.PROPERTY_POSITION_Y, PropertyNames.PROPERTY_STEP, PropertyNames.PROPERTY_TABINDEX, PropertyNames.PROPERTY_WIDTH
+ },
+ new Object[]
+ {
+ Boolean.TRUE, 12, "HID:WIZARDS_HID_DLGTABLE_LBTABLES", new Short(UnoDialog.getListBoxLineCount()), 91, 92, IMAINSTEP, new Short(pretabindex++), getListboxWidth()
+ });
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace(System.out);
+ }
+ initializeCategory(BUSINESS);
+ }
+
+ public void selectCategory()
+ {
+ if (optBusiness.getState())
+ {
+ initializeCategory(BUSINESS);
+ }
+ else
+ {
+ initializeCategory(PRIVATE);
+ }
+ }
+
+ public void initializeCategory(int _iCategory)
+ {
+ try
+ {
+ oCGCategory.initialize(
+ _iCategory == PRIVATE ? "private" : "business");
+ xTableListBox.removeItems((short) 0, xTableListBox.getItemCount());
+ xTableListBox.addItems(oCGCategory.getTableNames(), (short) _iCategory);
+ initializeTable(0);
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace(System.out);
+ }
+ }
+
+ public void initializeTable(int _iTable)
+ {
+ Helper.setUnoPropertyValue(UnoDialog.getModel(xTableListBox), "SelectedItems", new short[]
+ {
+ (short) _iTable
+ });
+ oCGTable.initialize(oCGCategory.xNameAccessTablesNode, _iTable);
+ super.initialize(oCGTable.getFieldNames(bcolumnnameislimited, imaxcolumnchars), true);
+ }
+
+ public String[] getSelectedFieldNames()
+ {
+ String[] displayfieldnames = super.getSelectedFieldNames();
+ Vector<String> afieldnameVector = new Vector<String>();
+ int a = 0;
+ for (int i = 0; i < displayfieldnames.length; i++)
+ {
+ try
+ {
+ FieldDescription ofielddescription = (FieldDescription) CurTableWizardUnoDialog.fielditems.get(displayfieldnames[i]);
+ if (ofielddescription != null)
+ {
+ afieldnameVector.addElement(ofielddescription.getName());
+ a++;
+ }
+ }
+ catch (RuntimeException e)
+ {
+ e.printStackTrace(System.out);
+ }
+ }
+ String[] fieldnames = new String[a];
+ afieldnameVector.toArray(fieldnames);
+ return fieldnames;
+ }
+
+ public boolean iscompleted()
+ {
+ return getSelectedFieldNames().length > 0;
+ }
+
+ public void addColumnsToDescriptor()
+ {
+ XNameAccess xNameAccessFieldNode;
+ String[] fieldnames = getSelectedFieldNames();
+ for (int i = 0; i < fieldnames.length; i++)
+ {
+ try
+ {
+ FieldDescription curfielddescription = (FieldDescription) CurTableWizardUnoDialog.fielditems.get(fieldnames[i]);
+ PropertyValue[] aProperties = curfielddescription.getPropertyValues();
+ this.curtabledescriptor.addColumn(aProperties);
+ }
+ catch (RuntimeException e)
+ {
+ e.printStackTrace(System.out);
+ }
+ }
+ }
+
+ public String getTableName()
+ {
+ return xTableListBox.getSelectedItem();
+ }
+
+ public String getFirstTableName()
+ {
+ String[] fieldnames = super.getSelectedFieldNames();
+ if ((fieldnames.length) > 0)
+ {
+ for (int i = 0; i < CurTableWizardUnoDialog.fielditems.size(); i++)
+ {
+ String stablename = "";
+ try
+ {
+ FieldDescription ofielddescription = (FieldDescription) CurTableWizardUnoDialog.fielditems.get(fieldnames[i]);
+ stablename = ofielddescription.gettablename();
+ }
+ catch (RuntimeException e)
+ {
+ e.printStackTrace(System.out);
+ }
+ if (!stablename.equals(""))
+ {
+ return stablename;
+ }
+ }
+ }
+ return smytable;
+ }
+
+ public void fillupTables()
+ {
+// if (optBusiness.getState())
+// else
+ }
+
+ public void fillupFieldsListbox()
+ {
+ super.emptyFieldsListBoxes();
+ }
+
+
+ /* (non-Javadoc)
+ * @see com.sun.star.awt.XItemListener#itemStateChanged(com.sun.star.awt.ItemEvent)
+ */
+ public void itemStateChanged(ItemEvent arg0)
+ {
+ initializeTable((int) xTableListBox.getSelectedItemPos());
+ }
+
+ /* (non-Javadoc)
+ * @see com.sun.star.lang.XEventListener#disposing(com.sun.star.lang.EventObject)
+ */
+ public void disposing(EventObject arg0)
+ {
+ }
+ protected int ID;
+
+ public int getID()
+ {
+ return ID;
+ }
+
+ public void setID(String sIncSuffix)
+ {
+ }
+
+ public void shiftFromLeftToRight(String[] SelItems, String[] NewItems)
+ {
+ if (!CurTableWizardUnoDialog.verifyfieldcount(NewItems.length))
+ {
+ for (int i = 0; i < SelItems.length; i++)
+ {
+ int selindex = JavaTools.FieldInList(NewItems, SelItems[i]);
+ super.xSelectedFieldsListBox.removeItems((short) selindex, (short) 1);
+ /**TODO In this context the items should be better placed at their original position.
+ * but how is this position retrieved?
+ */
+ super.xFieldsListBox.addItem(SelItems[i], xFieldsListBox.getItemCount());
+ }
+ }
+ else
+ {
+ for (int i = 0; i < NewItems.length; i++)
+ {
+ int iduplicate;
+ if (CurTableWizardUnoDialog.fielditems.containsKey(NewItems[i]))
+ {
+ iduplicate = JavaTools.getDuplicateFieldIndex(NewItems, NewItems[i]);
+ if (iduplicate != -1)
+ {
+ XNameAccess xNameAccessFieldNode;
+ String sdisplayname = Desktop.getUniqueName(NewItems, NewItems[iduplicate], "");
+ FieldDescription curfielddescription = new FieldDescription(xMSF, aLocale, this, sdisplayname, NewItems[iduplicate], imaxcolumnchars);
+ CurTableWizardUnoDialog.fielditems.put(sdisplayname, curfielddescription);
+ NewItems[iduplicate] = sdisplayname;
+ setSelectedFieldNames(NewItems);
+ }
+ }
+ else
+ {
+ CurTableWizardUnoDialog.fielditems.put(NewItems[i], new FieldDescription(xMSF, aLocale, this, NewItems[i], NewItems[i], imaxcolumnchars));
+ }
+ }
+ }
+ CurTableWizardUnoDialog.setcompleted(TableWizard.SOMAINPAGE, NewItems.length > 0);
+ }
+
+ public void shiftFromRightToLeft(String[] SelItems, String[] NewItems)
+ {
+ for (int i = 0; i < SelItems.length; i++)
+ {
+ if (CurTableWizardUnoDialog.fielditems.containsKey(SelItems[i]))
+ {
+ CurTableWizardUnoDialog.fielditems.remove(SelItems[i]);
+ this.curtabledescriptor.dropColumnbyName(SelItems[i]);
+ }
+ }
+ CurTableWizardUnoDialog.setcompleted(TableWizard.SOMAINPAGE, NewItems.length > 0);
+ }
+
+ public void moveItemDown(String item)
+ {
+ }
+
+ public void moveItemUp(String item)
+ {
+ }
+}
diff --git a/wizards/com/sun/star/wizards/table/TableWizard.java b/wizards/com/sun/star/wizards/table/TableWizard.java
new file mode 100644
index 000000000000..79ddb8ae1039
--- /dev/null
+++ b/wizards/com/sun/star/wizards/table/TableWizard.java
@@ -0,0 +1,438 @@
+/*************************************************************************
+ *
+ * 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.table;
+
+import java.util.Hashtable;
+
+import com.sun.star.awt.TextEvent;
+import com.sun.star.awt.VclWindowPeerAttribute;
+import com.sun.star.awt.XTextListener;
+import com.sun.star.beans.PropertyValue;
+import com.sun.star.lang.XInitialization;
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.sdb.CommandType;
+import com.sun.star.sdb.application.DatabaseObject;
+import com.sun.star.sdbc.SQLException;
+import com.sun.star.task.XJobExecutor;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.wizards.common.*;
+import com.sun.star.wizards.db.DatabaseObjectWizard;
+import com.sun.star.wizards.db.TableDescriptor;
+import com.sun.star.wizards.ui.*;
+
+public class TableWizard extends DatabaseObjectWizard implements XTextListener, XCompletion
+{
+
+ static String slblFields;
+ static String slblSelFields;
+ Finalizer curFinalizer;
+ ScenarioSelector curScenarioSelector;
+ FieldFormatter curFieldFormatter;
+ PrimaryKeyHandler curPrimaryKeyHandler;
+ String sMsgWizardName = "";
+ public Hashtable fielditems;
+ int wizardmode;
+ String tablename;
+ String serrToManyFields;
+ String serrTableNameexists;
+ String scomposedtablename;
+ TableDescriptor curTableDescriptor;
+ public static final int SONULLPAGE = 0;
+ public static final int SOMAINPAGE = 1;
+ public static final int SOFIELDSFORMATPAGE = 2;
+ public static final int SOPRIMARYKEYPAGE = 3;
+ public static final int SOFINALPAGE = 4;
+ private String sMsgColumnAlreadyExists = "";
+ String WizardHeaderText[] = new String[8];
+
+ private String m_tableName;
+
+ public TableWizard( XMultiServiceFactory xMSF, PropertyValue[] i_wizardContext )
+ {
+ super( xMSF, 41200, i_wizardContext );
+ super.addResourceHandler("TableWizard", "dbw");
+ String sTitle = m_oResource.getResText(UIConsts.RID_TABLE + 1);
+ Helper.setUnoPropertyValues(xDialogModel,
+ new String[]
+ {
+ PropertyNames.PROPERTY_HEIGHT, PropertyNames.PROPERTY_MOVEABLE, PropertyNames.PROPERTY_NAME, PropertyNames.PROPERTY_POSITION_X, PropertyNames.PROPERTY_POSITION_Y, PropertyNames.PROPERTY_STEP, PropertyNames.PROPERTY_TABINDEX, PropertyNames.PROPERTY_TITLE, PropertyNames.PROPERTY_WIDTH
+ },
+ new Object[]
+ {
+ 218, Boolean.TRUE, "DialogTable", 102, 41, 1, new Short((short) 0), sTitle, 330
+ });
+ drawNaviBar();
+ fielditems = new Hashtable();
+ //TODO if reportResouces cannot be gotten dispose officedocument
+ if (getTableResources() == true)
+ {
+ setRightPaneHeaders(m_oResource, UIConsts.RID_TABLE + 8, 4);
+ }
+ }
+
+ protected void leaveStep(int nOldStep, int nNewStep)
+ {
+ switch (nOldStep)
+ {
+ case SOMAINPAGE:
+ curScenarioSelector.addColumnsToDescriptor();
+ break;
+ case SOFIELDSFORMATPAGE:
+ curFieldFormatter.updateColumnofColumnDescriptor();
+ String[] sfieldnames = curFieldFormatter.getFieldNames();
+ super.setStepEnabled(SOFIELDSFORMATPAGE, sfieldnames.length > 0);
+ curScenarioSelector.setSelectedFieldNames(sfieldnames);
+ break;
+ case SOPRIMARYKEYPAGE:
+ break;
+ case SOFINALPAGE:
+ break;
+ default:
+ break;
+ }
+ }
+
+ protected void enterStep(int nOldStep, int nNewStep)
+ {
+ switch (nNewStep)
+ {
+ case SOMAINPAGE:
+ break;
+ case SOFIELDSFORMATPAGE:
+ curFieldFormatter.initialize(curTableDescriptor, this.curScenarioSelector.getSelectedFieldNames());
+ break;
+ case SOPRIMARYKEYPAGE:
+ curPrimaryKeyHandler.initialize();
+ break;
+ case SOFINALPAGE:
+ curFinalizer.initialize(curScenarioSelector.getFirstTableName());
+ break;
+ default:
+ break;
+ }
+ }
+
+
+ /* (non-Javadoc)
+ * @see com.sun.star.wizards.ui.XCompletion#iscompleted(int)
+ */
+ public boolean iscompleted(int _ndialogpage)
+ {
+ switch (_ndialogpage)
+ {
+ case SOMAINPAGE:
+ return curScenarioSelector.iscompleted();
+ case SOFIELDSFORMATPAGE:
+ return this.curFieldFormatter.iscompleted();
+ case SOPRIMARYKEYPAGE:
+ if (curPrimaryKeyHandler != null)
+ {
+ return this.curPrimaryKeyHandler.iscompleted();
+ }
+ case SOFINALPAGE:
+ return this.curFinalizer.iscompleted();
+ default:
+ return false;
+ }
+ }
+
+
+ /* (non-Javadoc)
+ * @see com.sun.star.wizards.ui.XCompletion#setcompleted(int, boolean)
+ */
+ public void setcompleted(int _ndialogpage, boolean _biscompleted)
+ {
+ boolean bScenarioiscompleted = _biscompleted;
+ boolean bFieldFormatsiscompleted = _biscompleted;
+ boolean bPrimaryKeysiscompleted = _biscompleted;
+ boolean bFinalPageiscompleted = _biscompleted;
+ if (_ndialogpage == SOMAINPAGE)
+ {
+ curFinalizer.initialize(curScenarioSelector.getFirstTableName());
+ }
+ else
+ {
+ bScenarioiscompleted = iscompleted(SOMAINPAGE);
+ }
+ if (_ndialogpage != TableWizard.SOFIELDSFORMATPAGE)
+ {
+ bFieldFormatsiscompleted = iscompleted(SOFIELDSFORMATPAGE);
+ if (!bFieldFormatsiscompleted) // it might be that the Fieldformatter has not yet been initialized
+ {
+ bFieldFormatsiscompleted = bScenarioiscompleted; // in this case query the scenarioselector
+ }
+ }
+ if (_ndialogpage != TableWizard.SOPRIMARYKEYPAGE && (this.curPrimaryKeyHandler != null))
+ {
+ bPrimaryKeysiscompleted = iscompleted(SOPRIMARYKEYPAGE);
+ }
+ if (_ndialogpage != TableWizard.SOFINALPAGE)
+ {
+ bFinalPageiscompleted = iscompleted(SOFINALPAGE); // Basically the finalpage is always enabled
+ }
+ if (bScenarioiscompleted)
+ {
+ super.setStepEnabled(SOFIELDSFORMATPAGE, true);
+ super.setStepEnabled(SOPRIMARYKEYPAGE, true);
+ if (bPrimaryKeysiscompleted)
+ {
+ super.enablefromStep(SOFINALPAGE, true);
+ super.enableFinishButton(bFinalPageiscompleted);
+ }
+ else
+ {
+ super.enablefromStep(SOFINALPAGE, false);
+ enableNextButton(false);
+ }
+ }
+ else if (_ndialogpage == SOFIELDSFORMATPAGE)
+ {
+ super.enablefromStep(super.getCurrentStep() + 1, iscompleted(SOFIELDSFORMATPAGE));
+ }
+ else
+ {
+ super.enablefromStep(super.getCurrentStep() + 1, false);
+ }
+ }
+
+/*
+ public static void main(String args[])
+ {
+ String ConnectStr = "uno:socket,host=localhost,port=8100;urp,negotiate=0,forcesynchronous=1;StarOffice.NamingService";
+ PropertyValue[] curproperties = null;
+ try
+ {
+ XMultiServiceFactory xLocMSF = com.sun.star.wizards.common.Desktop.connect(ConnectStr);
+ TableWizard CurTableWizard = new TableWizard(xLocMSF);
+ if (xLocMSF != null)
+ {
+ System.out.println("Connected to " + ConnectStr);
+ curproperties = new PropertyValue[1];
+ curproperties[0] = Properties.createProperty("DataSourceName", "Bibliography");
+ //curproperties[0] = Properties.createProperty("DatabaseLocation", "file:///path/to/database.odb");
+ CurTableWizard.startTableWizard(xLocMSF, curproperties);
+ }
+ }
+ catch (Exception exception)
+ {
+ exception.printStackTrace(System.out);
+ }
+ }
+*/
+ public void buildSteps()
+ {
+ curScenarioSelector = new ScenarioSelector(this, this.curTableDescriptor, slblFields, slblSelFields);
+ curFieldFormatter = new FieldFormatter(this, curTableDescriptor);
+ if ( this.curTableDescriptor.supportsPrimaryKeys() )
+ {
+ curPrimaryKeyHandler = new PrimaryKeyHandler(this, curTableDescriptor);
+ }
+ curFinalizer = new Finalizer(this, curTableDescriptor);
+ enableNavigationButtons(false, false, false);
+ }
+
+ public boolean createTable()
+ {
+ boolean bIsSuccessfull = true;
+ boolean bTableCreated = false;
+ String schemaname = curFinalizer.getSchemaName();
+ String catalogname = curFinalizer.getCatalogName();
+ if (curTableDescriptor.supportsPrimaryKeys())
+ {
+ String[] keyfieldnames = curPrimaryKeyHandler.getPrimaryKeyFields(curTableDescriptor);
+ if (keyfieldnames != null)
+ {
+ if (keyfieldnames.length > 0)
+ {
+ boolean bIsAutoIncrement = curPrimaryKeyHandler.isAutoIncremented();
+ bIsSuccessfull = curTableDescriptor.createTable(catalogname, schemaname, tablename, keyfieldnames, bIsAutoIncrement, curScenarioSelector.getSelectedFieldNames());
+ bTableCreated = true;
+ }
+ }
+ }
+ if (!bTableCreated)
+ {
+ bIsSuccessfull = curTableDescriptor.createTable(catalogname, schemaname, tablename, curScenarioSelector.getSelectedFieldNames());
+ }
+ if ((!bIsSuccessfull) && (curPrimaryKeyHandler.isAutomaticMode()))
+ {
+ curTableDescriptor.dropColumnbyName(curPrimaryKeyHandler.getAutomaticFieldName());
+ }
+ return bIsSuccessfull;
+ }
+
+ public boolean finishWizard()
+ {
+ super.switchToStep(super.getCurrentStep(), SOFINALPAGE);
+ tablename = curFinalizer.getTableName(curScenarioSelector.getFirstTableName());
+ scomposedtablename = curFinalizer.getComposedTableName(tablename);
+ if (this.curTableDescriptor.isSQL92CheckEnabled())
+ {
+ Desktop.removeSpecialCharacters(curTableDescriptor.xMSF, Configuration.getOfficeLocale(this.curTableDescriptor.xMSF), tablename);
+ }
+ if ( tablename.length() > 0 )
+ {
+ if (!curTableDescriptor.hasTableByName(scomposedtablename))
+ {
+ wizardmode = curFinalizer.finish();
+ if (createTable())
+ {
+ final boolean editTableDesign = (wizardmode == Finalizer.MODIFYTABLEMODE );
+ loadSubComponent( DatabaseObject.TABLE, curTableDescriptor.getComposedTableName(), editTableDesign );
+ m_tableName = curTableDescriptor.getComposedTableName();
+ super.xDialog.endExecute();
+ return true;
+ }
+ }
+ else
+ {
+ String smessage = JavaTools.replaceSubString(serrTableNameexists, tablename, "%TABLENAME");
+ super.showMessageBox("WarningBox", com.sun.star.awt.VclWindowPeerAttribute.OK, smessage);
+ curFinalizer.setFocusToTableNameControl();
+ }
+ }
+ return false;
+ }
+
+ private void callFormWizard()
+ {
+ try
+ {
+ Object oFormWizard = this.xMSF.createInstance("com.sun.star.wizards.form.CallFormWizard");
+
+ NamedValueCollection wizardContext = new NamedValueCollection();
+ wizardContext.put( "ActiveConnection", curTableDescriptor.DBConnection );
+ wizardContext.put( "DataSource", curTableDescriptor.getDataSource() );
+ wizardContext.put( "CommandType", CommandType.TABLE );
+ wizardContext.put( "Command", scomposedtablename );
+ wizardContext.put( "DocumentUI", m_docUI );
+ XInitialization xInitialization = UnoRuntime.queryInterface( XInitialization.class, oFormWizard );
+ xInitialization.initialize( wizardContext.getPropertyValues() );
+ XJobExecutor xJobExecutor = UnoRuntime.queryInterface( XJobExecutor.class, oFormWizard );
+ xJobExecutor.trigger("start");
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace(System.out);
+ }
+ }
+
+ public void cancelWizard()
+ {
+ xDialog.endExecute();
+ }
+
+ public void insertFormRelatedSteps()
+ {
+ addRoadmap();
+ int i = 0;
+ i = insertRoadmapItem(0, true, m_oResource.getResText(UIConsts.RID_TABLE + 2), SOMAINPAGE);
+ i = insertRoadmapItem(i, false, m_oResource.getResText(UIConsts.RID_TABLE + 3), SOFIELDSFORMATPAGE);
+ if (this.curTableDescriptor.supportsPrimaryKeys())
+ {
+ i = insertRoadmapItem(i, false, m_oResource.getResText(UIConsts.RID_TABLE + 4), SOPRIMARYKEYPAGE);
+ }
+ i = insertRoadmapItem(i, false, m_oResource.getResText(UIConsts.RID_TABLE + 5), SOFINALPAGE); // Orderby is always supported
+ setRoadmapInteractive(true);
+ setRoadmapComplete(true);
+ setCurrentRoadmapItemID((short) 1);
+ }
+
+ public String startTableWizard( )
+ {
+ try
+ {
+ curTableDescriptor = new TableDescriptor(xMSF, super.xWindow, this.sMsgColumnAlreadyExists);
+ if ( curTableDescriptor.getConnection( m_wizardContext ) )
+ {
+ buildSteps();
+ createWindowPeer();
+ curTableDescriptor.setWindowPeer(this.xControl.getPeer());
+ insertFormRelatedSteps();
+ short RetValue = executeDialog();
+ xComponent.dispose();
+ if ( RetValue == 0 )
+ {
+ if ( wizardmode == Finalizer.STARTFORMWIZARDMODE )
+ callFormWizard();
+ return m_tableName;
+ }
+ }
+ }
+ catch (java.lang.Exception jexception)
+ {
+ jexception.printStackTrace(System.out);
+ }
+ return "";
+ }
+
+ public boolean getTableResources()
+ {
+ sMsgWizardName = super.m_oResource.getResText(UIConsts.RID_TABLE + 1);
+ slblFields = m_oResource.getResText(UIConsts.RID_TABLE + 19);
+ slblSelFields = m_oResource.getResText(UIConsts.RID_TABLE + 25);
+ serrToManyFields = m_oResource.getResText(UIConsts.RID_TABLE + 47);
+ serrTableNameexists = m_oResource.getResText(UIConsts.RID_TABLE + 48);
+ sMsgColumnAlreadyExists = m_oResource.getResText(UIConsts.RID_TABLE + 51);
+ return true;
+ }
+
+ public boolean verifyfieldcount(int _icount)
+ {
+ try
+ {
+ int maxfieldcount = curTableDescriptor.getMaxColumnsInTable();
+ if (_icount >= (maxfieldcount - 1))
+ { // keep one column as reserve for the automaticcally created key
+ String smessage = serrToManyFields;
+ smessage = JavaTools.replaceSubString(smessage, String.valueOf(maxfieldcount), "%COUNT");
+ showMessageBox("ErrorBox", VclWindowPeerAttribute.OK, smessage);
+ return false;
+ }
+ }
+ catch (SQLException e)
+ {
+ e.printStackTrace(System.out);
+ }
+ return true;
+ }
+
+
+ /* (non-Javadoc)
+ * @see com.sun.star.awt.XTextListener#textChanged(com.sun.star.awt.TextEvent)
+ */
+ public void textChanged(TextEvent aTextEvent)
+ {
+ if (this.curTableDescriptor.isSQL92CheckEnabled())
+ {
+ Object otextcomponent = UnoDialog.getModel(aTextEvent.Source);
+ String sName = (String) Helper.getUnoPropertyValue(otextcomponent, "Text");
+ sName = Desktop.removeSpecialCharacters(curTableDescriptor.xMSF, Configuration.getOfficeLocale(curTableDescriptor.xMSF), sName);
+ Helper.setUnoPropertyValue(otextcomponent, "Text", sName);
+ }
+ }
+}
diff --git a/wizards/com/sun/star/wizards/table/makefile.mk b/wizards/com/sun/star/wizards/table/makefile.mk
new file mode 100644
index 000000000000..4343af99d45d
--- /dev/null
+++ b/wizards/com/sun/star/wizards/table/makefile.mk
@@ -0,0 +1,73 @@
+#*************************************************************************
+#
+# 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.
+#
+#*************************************************************************
+PRJ = ..$/..$/..$/..$/..
+PRJNAME = wizards
+TARGET = table
+PACKAGE = com$/sun$/star$/wizards$/table
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : settings.mk
+#.INCLUDE : $(PRJ)$/util$/makefile.pmk
+
+JARFILES= unoil.jar jurt.jar ridl.jar juh.jar java_uno.jar commonwizards.jar
+CUSTOMMANIFESTFILE= MANIFEST.MF
+
+JARCLASSDIRS = com$/sun$/star$/wizards$/table
+JARTARGET = $(TARGET).jar
+JARCLASSPATH = commonwizards.jar
+
+# --- Files --------------------------------------------------------
+#SRS2NAME = dbwizres
+#SRC2FILES= dbwizres.src
+#RESLIB2SRSFILES= $(SRS)$/dbwizres.srs
+#RESLIB2NAME= dbw
+
+JAVAFILES= \
+ CallTableWizard.java \
+ Finalizer.java \
+ FieldDescription.java \
+ CGCategory.java \
+ CGTable.java \
+ FieldFormatter.java \
+ PrimaryKeyHandler.java \
+ ScenarioSelector.java \
+ TableWizard.java \
+
+JAVACLASSFILES = $(foreach,i,$(JAVAFILES) $(CLASSDIR)$/$(PACKAGE)$/$(i:b).class)
+
+# --- Targets ------------------------------------------------------
+
+.INCLUDE : target.mk
+
+ALLTAR : $(MISC)/table.component
+
+$(MISC)/table.component .ERRREMOVE : $(SOLARENV)/bin/createcomponent.xslt \
+ table.component
+ $(XSLTPROC) --nonet --stringparam uri \
+ '$(COMPONENTPREFIX_BASIS_JAVA)$(JARTARGET)' -o $@ \
+ $(SOLARENV)/bin/createcomponent.xslt table.component
diff --git a/wizards/com/sun/star/wizards/table/table.component b/wizards/com/sun/star/wizards/table/table.component
new file mode 100644
index 000000000000..24cacd225181
--- /dev/null
+++ b/wizards/com/sun/star/wizards/table/table.component
@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--**********************************************************************
+*
+* 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.
+*
+**********************************************************************-->
+
+<component loader="com.sun.star.loader.Java2"
+ xmlns="http://openoffice.org/2010/uno-components">
+ <implementation name=
+ "com.sun.star.wizards.table.CallTableWizard$TableWizardImplementation">
+ <service name="com.sun.star.wizards.table.CallTableWizard"/>
+ </implementation>
+</component>