summaryrefslogtreecommitdiffstats
path: root/wizards/com/sun/star/wizards/table/TableWizard.java
diff options
context:
space:
mode:
Diffstat (limited to 'wizards/com/sun/star/wizards/table/TableWizard.java')
-rw-r--r--wizards/com/sun/star/wizards/table/TableWizard.java300
1 files changed, 187 insertions, 113 deletions
diff --git a/wizards/com/sun/star/wizards/table/TableWizard.java b/wizards/com/sun/star/wizards/table/TableWizard.java
index 302ff8dd221d..624eb0473074 100644
--- a/wizards/com/sun/star/wizards/table/TableWizard.java
+++ b/wizards/com/sun/star/wizards/table/TableWizard.java
@@ -1,5 +1,5 @@
/*************************************************************************
-*
+ *
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright 2008 by Sun Microsystems, Inc.
@@ -48,8 +48,8 @@ import com.sun.star.wizards.common.*;
import com.sun.star.wizards.db.TableDescriptor;
import com.sun.star.wizards.ui.*;
-
-public class TableWizard extends WizardDialog implements XTextListener, XCompletion{
+public class TableWizard extends WizardDialog implements XTextListener, XCompletion
+{
static String slblFields;
static String slblSelFields;
@@ -73,26 +73,35 @@ public class TableWizard extends WizardDialog implements XTextListener, XComplet
private String sMsgColumnAlreadyExists = "";
XComponent[] components = null;
XFrame CurFrame;
-
String WizardHeaderText[] = new String[8];
- public TableWizard(XMultiServiceFactory xMSF) {
+ public TableWizard(XMultiServiceFactory xMSF)
+ {
super(xMSF, 41200);
super.addResourceHandler("TableWizard", "dbw");
String sTitle = m_oResource.getResText(UIConsts.RID_TABLE + 1);
Helper.setUnoPropertyValues(xDialogModel,
- new String[] { "Height","Moveable","Name","PositionX","PositionY","Step","TabIndex","Title","Width"},
- new Object[] { new Integer(218),Boolean.TRUE, "DialogTable", new Integer(102),new Integer(41),new Integer(1), new Short((short)0), sTitle, new Integer(330)} );
+ new String[]
+ {
+ "Height", "Moveable", "Name", "PositionX", "PositionY", "Step", "TabIndex", "Title", "Width"
+ },
+ new Object[]
+ {
+ new Integer(218), Boolean.TRUE, "DialogTable", new Integer(102), new Integer(41), new Integer(1), new Short((short) 0), sTitle, new Integer(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){
+ protected void leaveStep(int nOldStep, int nNewStep)
+ {
+ switch (nOldStep)
+ {
case SOMAINPAGE:
curScenarioSelector.addColumnsToDescriptor();
break;
@@ -108,12 +117,13 @@ public class TableWizard extends WizardDialog implements XTextListener, XComplet
break;
default:
break;
- }
+ }
}
-
- protected void enterStep(int nOldStep, int nNewStep) {
- switch (nNewStep){
+ protected void enterStep(int nOldStep, int nNewStep)
+ {
+ switch (nNewStep)
+ {
case SOMAINPAGE:
break;
case SOFIELDSFORMATPAGE:
@@ -134,15 +144,19 @@ public class TableWizard extends WizardDialog implements XTextListener, XComplet
/* (non-Javadoc)
* @see com.sun.star.wizards.ui.XCompletion#iscompleted(int)
*/
- public boolean iscompleted(int _ndialogpage) {
- switch (_ndialogpage){
+ 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:
@@ -154,183 +168,236 @@ public class TableWizard extends WizardDialog implements XTextListener, XComplet
/* (non-Javadoc)
* @see com.sun.star.wizards.ui.XCompletion#setcompleted(int, boolean)
*/
- public void setcompleted(int _ndialogpage, boolean _biscompleted) {
+ 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){
+ }
+ 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){
+ }
+ if (bScenarioiscompleted)
+ {
super.setStepEnabled(SOFIELDSFORMATPAGE, true);
super.setStepEnabled(SOPRIMARYKEYPAGE, true);
- if (bPrimaryKeysiscompleted){
+ if (bPrimaryKeysiscompleted)
+ {
super.enablefromStep(SOFINALPAGE, true);
super.enableFinishButton(bFinalPageiscompleted);
}
- else{
+ else
+ {
super.enablefromStep(SOFINALPAGE, false);
enableNextButton(false);
}
}
+ else if (_ndialogpage == SOFIELDSFORMATPAGE)
+ {
+ super.enablefromStep(super.getCurrentStep() + 1, iscompleted(SOFIELDSFORMATPAGE));
+ }
else
- if (_ndialogpage == SOFIELDSFORMATPAGE)
- super.enablefromStep(super.getCurrentStep()+1, iscompleted(SOFIELDSFORMATPAGE));
- else
- super.enablefromStep(super.getCurrentStep()+1, false);
+ {
+ 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);
+ 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);
}
}
- catch(Exception exception){
- exception.printStackTrace(System.out);
- }}
-
- public void buildSteps(){
+ public void buildSteps()
+ {
curScenarioSelector = new ScenarioSelector(this, this.curTableDescriptor, slblFields, slblSelFields);
- curFieldFormatter = new FieldFormatter(this, curTableDescriptor );
+ curFieldFormatter = new FieldFormatter(this, curTableDescriptor);
if (this.curTableDescriptor.supportsCoreSQLGrammar())
+ {
curPrimaryKeyHandler = new PrimaryKeyHandler(this, curTableDescriptor);
+ }
curFinalizer = new Finalizer(this, curTableDescriptor);
enableNavigationButtons(false, false, false);
}
-
- public boolean createTable(){
+ public boolean createTable()
+ {
boolean bIsSuccessfull = true;
boolean bTableCreated = false;
String schemaname = curFinalizer.getSchemaName();
String catalogname = curFinalizer.getCatalogName();
- if (curTableDescriptor.supportsCoreSQLGrammar()){
+ if (curTableDescriptor.supportsCoreSQLGrammar())
+ {
String[] keyfieldnames = curPrimaryKeyHandler.getPrimaryKeyFields(curTableDescriptor);
- if (keyfieldnames != null){
- if (keyfieldnames.length > 0){
+ 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){
+ if (!bTableCreated)
+ {
bIsSuccessfull = curTableDescriptor.createTable(catalogname, schemaname, tablename, curScenarioSelector.getSelectedFieldNames());
}
- if ((!bIsSuccessfull) && (curPrimaryKeyHandler.isAutomaticMode())){
- curTableDescriptor.dropColumnbyName(curPrimaryKeyHandler.getAutomaticFieldName());
+ if ((!bIsSuccessfull) && (curPrimaryKeyHandler.isAutomaticMode()))
+ {
+ curTableDescriptor.dropColumnbyName(curPrimaryKeyHandler.getAutomaticFieldName());
}
return bIsSuccessfull;
}
-
- public void finishWizard(){
+ public void 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 != ""){
- if (!curTableDescriptor.hasTableByName(scomposedtablename)){
+ }
+ if (tablename != "")
+ {
+ if (!curTableDescriptor.hasTableByName(scomposedtablename))
+ {
wizardmode = curFinalizer.finish();
- if (createTable()){
+ if (createTable())
+ {
if (wizardmode == Finalizer.MODIFYTABLEMODE)
- components = curTableDescriptor.switchtoDesignmode(curTableDescriptor.getComposedTableName(), com.sun.star.sdb.CommandType.TABLE,CurFrame);
+ {
+ components = curTableDescriptor.switchtoDesignmode(curTableDescriptor.getComposedTableName(), com.sun.star.sdb.CommandType.TABLE, CurFrame);
+ }
else if (wizardmode == Finalizer.WORKWITHTABLEMODE)
- components = curTableDescriptor.switchtoDataViewmode(curTableDescriptor.getComposedTableName(), com.sun.star.sdb.CommandType.TABLE,CurFrame);
+ {
+ components = curTableDescriptor.switchtoDataViewmode(curTableDescriptor.getComposedTableName(), com.sun.star.sdb.CommandType.TABLE, CurFrame);
+ }
super.xDialog.endExecute();
}
}
- else{
+ else
+ {
String smessage = JavaTools.replaceSubString(serrTableNameexists, tablename, "%TABLENAME");
- super.showMessageBox("WarningBox", com.sun.star.awt.VclWindowPeerAttribute.OK, smessage );
+ super.showMessageBox("WarningBox", com.sun.star.awt.VclWindowPeerAttribute.OK, smessage);
curFinalizer.setFocusToTableNameControl();
}
}
}
+ private void callFormWizard()
+ {
+ try
+ {
+ Object oFormWizard = this.xMSF.createInstance("com.sun.star.wizards.form.CallFormWizard");
+ PropertyValue[] aProperties = new PropertyValue[4];
+ aProperties[0] = Properties.createProperty("ActiveConnection", curTableDescriptor.DBConnection);
+ aProperties[1] = Properties.createProperty("DataSource", curTableDescriptor.xDataSource);
+ aProperties[2] = Properties.createProperty("CommandType", new Integer(CommandType.TABLE));
+ aProperties[3] = Properties.createProperty("Command", scomposedtablename);
+ XInitialization xInitialization = (XInitialization) UnoRuntime.queryInterface(XInitialization.class, oFormWizard);
+ xInitialization.initialize(aProperties);
+ XJobExecutor xJobExecutor = (XJobExecutor) UnoRuntime.queryInterface(XJobExecutor.class, oFormWizard);
+ xJobExecutor.trigger("start");
+ XPropertySet prop = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xJobExecutor);
+ components[0] = (XComponent) prop.getPropertyValue("Document");
+ components[1] = (XComponent) prop.getPropertyValue("DocumentDefinition");
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace(System.out);
+ }
+ }
- private void callFormWizard(){
- try {
- Object oFormWizard = this.xMSF.createInstance("com.sun.star.wizards.form.CallFormWizard");
- PropertyValue[] aProperties = new PropertyValue[4];
- aProperties[0] = Properties.createProperty("ActiveConnection", curTableDescriptor.DBConnection);
- aProperties[1] = Properties.createProperty("DataSource", curTableDescriptor.xDataSource);
- aProperties[2] = Properties.createProperty("CommandType", new Integer(CommandType.TABLE));
- aProperties[3] = Properties.createProperty("Command", scomposedtablename);
- XInitialization xInitialization = (XInitialization) UnoRuntime.queryInterface(XInitialization.class, oFormWizard);
- xInitialization.initialize(aProperties);
- XJobExecutor xJobExecutor = (XJobExecutor) UnoRuntime.queryInterface(XJobExecutor.class, oFormWizard);
- xJobExecutor.trigger("start");
- XPropertySet prop = (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class,xJobExecutor);
- components[0] = (XComponent)prop.getPropertyValue("Document");
- components[1] = (XComponent)prop.getPropertyValue("DocumentDefinition");
- } catch (Exception e) {
- e.printStackTrace(System.out);
- }}
-
-
- public void cancelWizard() {
+ public void cancelWizard()
+ {
xDialog.endExecute();
}
-
- public void insertFormRelatedSteps(){
+ 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.supportsCoreSQLGrammar())
+ {
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
+ }
+ i = insertRoadmapItem(i, false, m_oResource.getResText(UIConsts.RID_TABLE + 5), SOFINALPAGE); // Orderby is always supported
setRoadmapInteractive(true);
setRoadmapComplete(true);
setCurrentRoadmapItemID((short) 1);
}
-
- public XComponent[] startTableWizard(XMultiServiceFactory _xMSF, PropertyValue[] CurPropertyValue){
- try{
+ public XComponent[] startTableWizard(XMultiServiceFactory _xMSF, PropertyValue[] CurPropertyValue)
+ {
+ try
+ {
curTableDescriptor = new TableDescriptor(xMSF, super.xWindow, this.sMsgColumnAlreadyExists);
- if (curTableDescriptor.getConnection(CurPropertyValue)){
+ if (curTableDescriptor.getConnection(CurPropertyValue))
+ {
if (Properties.hasPropertyValue(CurPropertyValue, "ParentFrame"))
- CurFrame = (XFrame) UnoRuntime.queryInterface(XFrame.class,Properties.getPropertyValue(CurPropertyValue, "ParentFrame"));
+ {
+ CurFrame = (XFrame) UnoRuntime.queryInterface(XFrame.class, Properties.getPropertyValue(CurPropertyValue, "ParentFrame"));
+ }
else
+ {
CurFrame = Desktop.getActiveFrame(xMSF);
+ }
buildSteps();
createWindowPeer();
curTableDescriptor.setWindowPeer(this.xControl.getPeer());
- // setAutoMnemonic("lblDialogHeader", false);
+ // setAutoMnemonic("lblDialogHeader", false);
insertFormRelatedSteps();
short RetValue = executeDialog();
xComponent.dispose();
- switch (RetValue){
+ switch (RetValue)
+ {
case 0: // via Cancelbutton or via sourceCode with "endExecute"
if (wizardmode == Finalizer.STARTFORMWIZARDMODE)
+ {
callFormWizard();
+ }
break;
case 1:
@@ -338,49 +405,56 @@ public class TableWizard extends WizardDialog implements XTextListener, XComplet
}
}
}
- catch(java.lang.Exception jexception ){
+ catch (java.lang.Exception jexception)
+ {
jexception.printStackTrace(System.out);
}
return components;
}
-
- public boolean getTableResources(){
- sMsgWizardName = super.m_oResource.getResText(UIConsts.RID_TABLE+1);
+ 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);
+ 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;
+ 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;
+ 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()){
+ 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);
}
}
-
}