diff options
Diffstat (limited to 'wizards/com/sun/star/wizards/form/FieldLinker.java')
-rw-r--r-- | wizards/com/sun/star/wizards/form/FieldLinker.java | 220 |
1 files changed, 147 insertions, 73 deletions
diff --git a/wizards/com/sun/star/wizards/form/FieldLinker.java b/wizards/com/sun/star/wizards/form/FieldLinker.java index 2b0464f0f664..2bcee88c84d0 100644 --- a/wizards/com/sun/star/wizards/form/FieldLinker.java +++ b/wizards/com/sun/star/wizards/form/FieldLinker.java @@ -47,8 +47,9 @@ import com.sun.star.wizards.ui.WizardDialog; import com.sun.star.wizards.ui.UIConsts; import com.sun.star.wizards.ui.DBLimitedFieldSelection; +public class FieldLinker extends DBLimitedFieldSelection +{ -public class FieldLinker extends DBLimitedFieldSelection{ XFixedText[] lblSlaveFields; XFixedText[] lblMasterFields; XListBox[] lstSlaveFields; @@ -66,118 +67,183 @@ public class FieldLinker extends DBLimitedFieldSelection{ String sMasterHidString; Integer IListBoxPosX; - - - public FieldLinker(WizardDialog _CurUnoDialog, int iStep, int iCompPosX, int iCompPosY, int iCompWidth, int _firsthelpid) { + public FieldLinker(WizardDialog _CurUnoDialog, int iStep, int iCompPosX, int iCompPosY, int iCompWidth, int _firsthelpid) + { super(_CurUnoDialog, iStep, iCompPosX, iCompPosY, iCompWidth, _firsthelpid); } + protected void insertControlGroup(int i) + { + try + { + if (i == 0) + { + lblSlaveFields = new XFixedText[rowcount]; + lblMasterFields = new XFixedText[rowcount]; + lstSlaveFields = new XListBox[rowcount]; + lstMasterFields = new XListBox[rowcount]; + SOFIRSTLINKLST = 0; + SOSECLINKLST = 1; + SOTHIRDLINKLST = 2; + SOFOURTHLINKLST = 3; + IListBoxPosX = new Integer(iCompPosX + 6); + sSlaveListHeader = CurUnoDialog.m_oResource.getResArray(UIConsts.RID_FORM + 20, 4); //new String[rowcount];""; //CurUnoDialog.m_oResource.getResText(UIConsts.RID_FORM + 40); + sMasterListHeader = CurUnoDialog.m_oResource.getResArray(UIConsts.RID_FORM + 24, 4);// new String[rowcount];""; //CurUnoDialog.m_oResource.getResText(UIConsts.RID_FORM + 40); + SOLINKLST = new int[] + { + SOFIRSTLINKLST, SOSECLINKLST, SOTHIRDLINKLST, SOFOURTHLINKLST + }; + } + sSlaveHidString = "HID:" + Integer.toString(FirstHelpIndex + (i * 2)); + sMasterHidString = "HID:" + Integer.toString(FirstHelpIndex + (i * 2) + 1); + boolean bDoEnable = (i < 2); + lblSlaveFields[i] = CurUnoDialog.insertLabel("lblSlaveFieldLink" + new Integer(i + 1).toString(), + new String[] + { + "Enabled", "Height", "Label", "PositionX", "PositionY", "Step", "TabIndex", "Width" + }, + new Object[] + { + new Boolean(bDoEnable), new Integer(8), sSlaveListHeader[i], new Integer(97), new Integer(iCurPosY), IStep, new Short(curtabindex++), new Integer(97) + }); + lstSlaveFields[i] = CurUnoDialog.insertListBox("lstSlaveFieldLink" + new Integer(i + 1).toString(), SOLINKLST[i], null, new ItemListenerImpl(), + new String[] + { + "Dropdown", "Enabled", "Height", "HelpURL", "PositionX", "PositionY", "Step", "TabIndex", "Width" + }, + new Object[] + { + Boolean.TRUE, new Boolean(bDoEnable), UIConsts.INTEGER_12, sSlaveHidString, new Integer(97), new Integer(iCurPosY + 10), IStep, new Short(curtabindex++), new Integer(97) + }); + + lblMasterFields[i] = CurUnoDialog.insertLabel("lblMasterFieldLink" + new Integer(i + 1).toString(), + new String[] + { + "Enabled", "Height", "Label", "PositionX", "PositionY", "Step", "TabIndex", "Width" + }, + new Object[] + { + new Boolean(bDoEnable), new Integer(8), sMasterListHeader[i], new Integer(206), new Integer(iCurPosY), IStep, new Short(curtabindex++), new Integer(97) + }); - protected void insertControlGroup(int i){ - try { - if (i == 0){ - lblSlaveFields = new XFixedText[rowcount]; - lblMasterFields = new XFixedText[rowcount]; - lstSlaveFields = new XListBox[rowcount]; - lstMasterFields = new XListBox[rowcount]; - SOFIRSTLINKLST = 0; - SOSECLINKLST = 1; - SOTHIRDLINKLST = 2; - SOFOURTHLINKLST = 3; - IListBoxPosX = new Integer(iCompPosX + 6); - sSlaveListHeader = CurUnoDialog.m_oResource.getResArray(UIConsts.RID_FORM + 20, 4); //new String[rowcount];""; //CurUnoDialog.m_oResource.getResText(UIConsts.RID_FORM + 40); - sMasterListHeader = CurUnoDialog.m_oResource.getResArray(UIConsts.RID_FORM + 24, 4);// new String[rowcount];""; //CurUnoDialog.m_oResource.getResText(UIConsts.RID_FORM + 40); - SOLINKLST = new int[] { SOFIRSTLINKLST, SOSECLINKLST, SOTHIRDLINKLST, SOFOURTHLINKLST }; + lstMasterFields[i] = CurUnoDialog.insertListBox("lstMasterFieldLink" + new Integer(i + 1).toString(), SOLINKLST[i], null, new ItemListenerImpl(), + new String[] + { + "Dropdown", "Enabled", "Height", "HelpURL", "PositionX", "PositionY", "Step", "TabIndex", "Width" + }, + new Object[] + { + Boolean.TRUE, new Boolean(bDoEnable), UIConsts.INTEGER_12, sMasterHidString, new Integer(206), new Integer(iCurPosY + 10), IStep, new Short(curtabindex++), new Integer(97) + }); + iCurPosY = iCurPosY + 38; + } + catch (Exception e) + { + e.printStackTrace(System.out); } - sSlaveHidString = "HID:" + Integer.toString(FirstHelpIndex + (i * 2)); - sMasterHidString = "HID:" + Integer.toString(FirstHelpIndex + (i * 2) + 1); - boolean bDoEnable = (i < 2); - lblSlaveFields[i] = CurUnoDialog.insertLabel("lblSlaveFieldLink" + new Integer(i + 1).toString(), - new String[] {"Enabled", "Height", "Label", "PositionX", "PositionY", "Step", "TabIndex", "Width"}, - new Object[] {new Boolean(bDoEnable), new Integer(8), sSlaveListHeader[i], new Integer(97), new Integer(iCurPosY), IStep, new Short(curtabindex++), new Integer(97)} ); - lstSlaveFields[i] = CurUnoDialog.insertListBox("lstSlaveFieldLink" + new Integer(i + 1).toString(), SOLINKLST[i], null, new ItemListenerImpl(), - new String[] {"Dropdown", "Enabled", "Height", "HelpURL", "PositionX", "PositionY", "Step", "TabIndex", "Width"}, - new Object[] { Boolean.TRUE, new Boolean(bDoEnable), UIConsts.INTEGER_12, sSlaveHidString, new Integer(97), new Integer(iCurPosY+10), IStep, new Short(curtabindex++), new Integer(97)}); - - lblMasterFields[i] = CurUnoDialog.insertLabel("lblMasterFieldLink" + new Integer(i + 1).toString(), - new String[] {"Enabled", "Height", "Label", "PositionX", "PositionY", "Step", "TabIndex", "Width"}, - new Object[] {new Boolean(bDoEnable), new Integer(8),sMasterListHeader[i], new Integer(206), new Integer(iCurPosY), IStep, new Short(curtabindex++), new Integer(97)}); - - lstMasterFields[i] = CurUnoDialog.insertListBox("lstMasterFieldLink" + new Integer(i + 1).toString(), SOLINKLST[i], null, new ItemListenerImpl(), - new String[] {"Dropdown", "Enabled", "Height", "HelpURL", "PositionX", "PositionY", "Step", "TabIndex", "Width"}, - new Object[] { Boolean.TRUE, new Boolean(bDoEnable), UIConsts.INTEGER_12, sMasterHidString, new Integer(206), new Integer(iCurPosY+10), IStep, new Short(curtabindex++), new Integer(97)}); - iCurPosY = iCurPosY + 38; - } catch (Exception e) { - e.printStackTrace(System.out); - }} - - - protected void enableNextControlRow(int curindex) { + } + + protected void enableNextControlRow(int curindex) + { setMaxSelIndex(); boolean bDoEnable = ((lstSlaveFields[curindex].getSelectedItemPos() > 0) && (lstMasterFields[curindex].getSelectedItemPos() > 0)); if (!bDoEnable) + { moveupSelectedItems(curindex, bDoEnable); + } else + { toggleControlRow(curindex + 1, true); + } } - - protected void setMaxSelIndex(){ + protected void setMaxSelIndex() + { MaxSelIndex = -1; - for (int i = 0; i < rowcount; i++) { + for (int i = 0; i < rowcount; i++) + { if ((lstSlaveFields[i].getSelectedItemPos() > 0) && (lstMasterFields[i].getSelectedItemPos() > 0)) + { MaxSelIndex += 1; + } } } - - protected void toggleControlRow(int i, boolean bDoEnable){ - if (i < rowcount) { + protected void toggleControlRow(int i, boolean bDoEnable) + { + if (i < rowcount) + { Helper.setUnoPropertyValue(UnoDialog.getModel(lblSlaveFields[i]), "Enabled", new Boolean(bDoEnable)); Helper.setUnoPropertyValue(UnoDialog.getModel(lstSlaveFields[i]), "Enabled", new Boolean(bDoEnable)); Helper.setUnoPropertyValue(UnoDialog.getModel(lblMasterFields[i]), "Enabled", new Boolean(bDoEnable)); Helper.setUnoPropertyValue(UnoDialog.getModel(lstMasterFields[i]), "Enabled", new Boolean(bDoEnable)); - if (bDoEnable == false){ - Helper.setUnoPropertyValue(UnoDialog.getModel(lstSlaveFields[i]), "SelectedItems", new short[] {0}); - Helper.setUnoPropertyValue(UnoDialog.getModel(lstMasterFields[i]), "SelectedItems", new short[] {0}); + if (bDoEnable == false) + { + Helper.setUnoPropertyValue(UnoDialog.getModel(lstSlaveFields[i]), "SelectedItems", new short[] + { + 0 + }); + Helper.setUnoPropertyValue(UnoDialog.getModel(lstMasterFields[i]), "SelectedItems", new short[] + { + 0 + }); } } } - - protected void updateFromNextControlRow(int curindex){ + protected void updateFromNextControlRow(int curindex) + { short iNextMasterItemPos = lstMasterFields[curindex + 1].getSelectedItemPos(); short iNextSlaveItemPos = lstSlaveFields[curindex + 1].getSelectedItemPos(); - if ((iNextMasterItemPos != 0) && (iNextSlaveItemPos != 0)) { - Helper.setUnoPropertyValue(UnoDialog.getModel(lstMasterFields[curindex]), "SelectedItems", new short[] { iNextMasterItemPos }); - Helper.setUnoPropertyValue(UnoDialog.getModel(lstSlaveFields[curindex]), "SelectedItems", new short[] { iNextSlaveItemPos }); + if ((iNextMasterItemPos != 0) && (iNextSlaveItemPos != 0)) + { + Helper.setUnoPropertyValue(UnoDialog.getModel(lstMasterFields[curindex]), "SelectedItems", new short[] + { + iNextMasterItemPos + }); + Helper.setUnoPropertyValue(UnoDialog.getModel(lstSlaveFields[curindex]), "SelectedItems", new short[] + { + iNextSlaveItemPos + }); - Helper.setUnoPropertyValue(UnoDialog.getModel(lstMasterFields[curindex+1]), "SelectedItems", new short[] {0}); - Helper.setUnoPropertyValue(UnoDialog.getModel(lstSlaveFields[curindex+1]), "SelectedItems", new short[] {0}); + Helper.setUnoPropertyValue(UnoDialog.getModel(lstMasterFields[curindex + 1]), "SelectedItems", new short[] + { + 0 + }); + Helper.setUnoPropertyValue(UnoDialog.getModel(lstSlaveFields[curindex + 1]), "SelectedItems", new short[] + { + 0 + }); toggleControlRow(curindex, true); } } - - public void initialize(String[] _AllMasterFieldNames, String[] _AllSlaveFieldNames, String[][] _LinkFieldNames) { + public void initialize(String[] _AllMasterFieldNames, String[] _AllSlaveFieldNames, String[][] _LinkFieldNames) + { short[] MasterSelList = null; short[] SlaveSelList = null; String[] MasterLinkNames = JavaTools.ArrayOutOfMultiDimArray(_LinkFieldNames, SOMASTERINDEX); String[] SlaveLinkNames = JavaTools.ArrayOutOfMultiDimArray(_LinkFieldNames, SOSLAVEINDEX); String[] ViewMasterFieldNames = addNoneFieldItemToList(_AllMasterFieldNames); String[] ViewSlaveFieldNames = addNoneFieldItemToList(_AllSlaveFieldNames); - for (int i = 0; i < super.rowcount; i++) { + for (int i = 0; i < super.rowcount; i++) + { super.initializeListBox(lstMasterFields[i], ViewMasterFieldNames, MasterLinkNames, i); super.initializeListBox(lstSlaveFields[i], ViewSlaveFieldNames, SlaveLinkNames, i); if (_LinkFieldNames != null) + { toggleControlRow(i, (i <= _LinkFieldNames.length)); + } else + { toggleControlRow(i, i == 0); + } } } - public String[][] getLinkFieldNames(RelationController _oRelationController, String _sReferencedTableName){ + public String[][] getLinkFieldNames(RelationController _oRelationController, String _sReferencedTableName) + { return _oRelationController.getImportedKeyColumns(_sReferencedTableName); } @@ -186,16 +252,19 @@ public class FieldLinker extends DBLimitedFieldSelection{ * When Joins were assigned duplicate a null value is returned * */ - public String[][] getLinkFieldNames() { + public String[][] getLinkFieldNames() + { String sLinkFieldsAreDuplicate = CurUnoDialog.m_oResource.getResText(UIConsts.RID_FORM + 19); setMaxSelIndex(); String[][] LinkFieldNames = new String[2][MaxSelIndex + 1]; - for (int i = 0; i <= MaxSelIndex; i++) { + for (int i = 0; i <= MaxSelIndex; i++) + { LinkFieldNames[0][i] = lstSlaveFields[i].getSelectedItem(); LinkFieldNames[1][i] = lstMasterFields[i].getSelectedItem(); } int iduplicate = JavaTools.getDuplicateFieldIndex(LinkFieldNames); - if (iduplicate != -1) { + if (iduplicate != -1) + { String sLocLinkFieldsAreDuplicate = JavaTools.replaceSubString(sLinkFieldsAreDuplicate, LinkFieldNames[0][iduplicate], "<FIELDNAME1>"); sLocLinkFieldsAreDuplicate = JavaTools.replaceSubString(sLocLinkFieldsAreDuplicate, LinkFieldNames[1][iduplicate], "<FIELDNAME2>"); CurUnoDialog.setCurrentStep(FormWizard.SOFIELDLINKERPAGE); @@ -203,24 +272,29 @@ public class FieldLinker extends DBLimitedFieldSelection{ CurUnoDialog.showMessageBox("WarningBox", VclWindowPeerAttribute.OK, sLocLinkFieldsAreDuplicate); CurUnoDialog.setFocus("lstSlaveFieldLink" + (iduplicate + 1)); return null; - } else + } + else + { return LinkFieldNames; + } } - - - public void enable(boolean _bdoenable){ + public void enable(boolean _bdoenable) + { CurUnoDialog.setStepEnabled(IStep.intValue(), _bdoenable); } - class ItemListenerImpl implements com.sun.star.awt.XItemListener { + class ItemListenerImpl implements com.sun.star.awt.XItemListener + { - public void itemStateChanged(ItemEvent EventObject) { + public void itemStateChanged(ItemEvent EventObject) + { int ikey = CurUnoDialog.getControlKey(EventObject.Source, CurUnoDialog.ControlList); enableNextControlRow(ikey); } - public void disposing(com.sun.star.lang.EventObject eventObject) { + public void disposing(com.sun.star.lang.EventObject eventObject) + { } } } |