diff options
Diffstat (limited to 'wizards/com/sun/star/wizards/ui/FilterComponent.java')
-rw-r--r-- | wizards/com/sun/star/wizards/ui/FilterComponent.java | 191 |
1 files changed, 101 insertions, 90 deletions
diff --git a/wizards/com/sun/star/wizards/ui/FilterComponent.java b/wizards/com/sun/star/wizards/ui/FilterComponent.java index e53f0792e268..8dfc12e21fb3 100644 --- a/wizards/com/sun/star/wizards/ui/FilterComponent.java +++ b/wizards/com/sun/star/wizards/ui/FilterComponent.java @@ -52,6 +52,7 @@ import com.sun.star.wizards.common.NumberFormatter; import com.sun.star.wizards.common.Helper; import com.sun.star.wizards.common.HelpIds; import com.sun.star.wizards.common.JavaTools; +import com.sun.star.wizards.common.PropertyNames; import com.sun.star.wizards.db.FieldColumn; import com.sun.star.wizards.db.QueryMetaData; import com.sun.star.wizards.db.SQLQueryComposer; @@ -111,6 +112,7 @@ public class FilterComponent final int SO_THIRDBOOLFIELDNAME = 256 + 3; final int SO_FOURTHBOOLFIELDNAME = 256 + 4; int SO_BOOLEANLIST[] = + { SO_FIRSTBOOLFIELDNAME, SO_SECONDBOOLFIELDNAME, SO_THIRDBOOLFIELDNAME, SO_FOURTHBOOLFIELDNAME }; @@ -121,6 +123,7 @@ public class FilterComponent class ItemListenerImpl implements com.sun.star.awt.XItemListener { + public void itemStateChanged(com.sun.star.awt.ItemEvent EventObject) { int iKey = CurUnoDialog.getControlKey(EventObject.Source, CurUnoDialog.ControlList); @@ -221,7 +224,7 @@ public class FilterComponent { XControl xControl = (XControl) UnoRuntime.queryInterface(XControl.class, _oSourceevent); XPropertySet xPSet = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xControl.getModel()); - final String sName = AnyConverter.toString(xPSet.getPropertyValue("Name")); + final String sName = AnyConverter.toString(xPSet.getPropertyValue(PropertyNames.PROPERTY_NAME)); return sName; } catch (Exception e) @@ -245,11 +248,11 @@ public class FilterComponent final XPropertyContainer column = (XPropertyContainer) UnoRuntime.queryInterface(XPropertyContainer.class, oQueryMetaData.xMSF.createInstance(serviceName)); column.addProperty("Type", PropertyAttribute.BOUND, DataType.VARCHAR); - column.addProperty("Name", PropertyAttribute.BOUND, ""); - column.addProperty("Value", (short)( PropertyAttribute.MAYBEVOID | PropertyAttribute.REMOVABLE ), null ); + column.addProperty(PropertyNames.PROPERTY_NAME, PropertyAttribute.BOUND, ""); + column.addProperty("Value", (short) (PropertyAttribute.MAYBEVOID | PropertyAttribute.REMOVABLE), null); final XPropertySet columnSet = UnoRuntime.queryInterface(XPropertySet.class, column); - if ( composer.getQuery().length() == 0) + if (composer.getQuery().length() == 0) { final String fromClause = composer.getFromClause(); StringBuilder sql = new StringBuilder(); @@ -258,7 +261,9 @@ public class FilterComponent sql.append(fromClause); composer.getQueryComposer().setElementaryQuery(sql.toString()); } - composer.getQueryComposer().setStructuredFilter( new PropertyValue[][] {} ); + composer.getQueryComposer().setStructuredFilter(new PropertyValue[][] + { + }); for (int i = 0; i < RowCount; i++) { ControlRow currentControlRow = oControlRows[i]; @@ -269,30 +274,31 @@ public class FilterComponent String sFieldName = currentControlRow.getSelectedFieldName(); int nOperator = (int) currentControlRow.getSelectedOperator(); FieldColumn aFieldColumn = oQueryMetaData.getFieldColumnByDisplayName(sFieldName); - columnSet.setPropertyValue("Name", aFieldColumn.getFieldName()); + columnSet.setPropertyValue(PropertyNames.PROPERTY_NAME, aFieldColumn.getFieldName()); columnSet.setPropertyValue("Type", aFieldColumn.getXColumnPropertySet().getPropertyValue("Type")); Object value = currentControlRow.getValue(); - switch(aFieldColumn.getFieldType()) + switch (aFieldColumn.getFieldType()) { case DataType.TIMESTAMP: case DataType.DATE: - value = ((Double)value) - oQueryMetaData.getNullDateCorrection(); + value = ((Double) value) - oQueryMetaData.getNullDateCorrection(); break; } - column.removeProperty( "Value" ); + column.removeProperty("Value"); final short operator = currentControlRow.getSelectedOperator(); - if ( ( operator == SQLFilterOperator.SQLNULL ) - || ( operator == SQLFilterOperator.NOT_SQLNULL ) - || AnyConverter.isVoid( value ) - ) + if ((operator == SQLFilterOperator.SQLNULL) + || (operator == SQLFilterOperator.NOT_SQLNULL) + || AnyConverter.isVoid(value)) { - column.addProperty("Value", (short)( PropertyAttribute.MAYBEVOID | PropertyAttribute.REMOVABLE ), new String() ); - value = new Any( new Type( TypeClass.VOID ), null ); + column.addProperty("Value", (short) (PropertyAttribute.MAYBEVOID | PropertyAttribute.REMOVABLE), new String()); + value = new Any(new Type(TypeClass.VOID), null); } else - column.addProperty("Value", (short)( PropertyAttribute.MAYBEVOID | PropertyAttribute.REMOVABLE ), value ); + { + column.addProperty("Value", (short) (PropertyAttribute.MAYBEVOID | PropertyAttribute.REMOVABLE), value); + } columnSet.setPropertyValue("Value", value); - composer.getQueryComposer().appendFilterByColumn(columnSet, getfilterstate() == this.SOI_MATCHALL,nOperator); + composer.getQueryComposer().appendFilterByColumn(columnSet, getfilterstate() == this.SOI_MATCHALL, nOperator); } } } @@ -304,7 +310,9 @@ public class FilterComponent String smsgDuplicateCondition = getDisplayCondition(sDuplicateCondition, aduplicatecondition, null); CurUnoDialog.showMessageBox("WarningBox", VclWindowPeerAttribute.OK, smsgDuplicateCondition); CurUnoDialog.vetoableChange(new java.beans.PropertyChangeEvent(CurUnoDialog, "Steps", Integer.valueOf(1), Integer.valueOf(2))); - return new PropertyValue[][]{}; + return new PropertyValue[][] + { + }; } } catch (Exception ex) @@ -334,10 +342,12 @@ public class FilterComponent FieldName = _filtercondition.Name; } String sreturn = JavaTools.replaceSubString(_BaseString, FieldName, "<FIELDNAME>"); - String soperator = sLogicOperators[_filtercondition.Handle - 1]; + String soperator = sLogicOperators[_filtercondition.Handle-1]; sreturn = JavaTools.replaceSubString(sreturn, soperator, "<LOGICOPERATOR>"); String sDisplayValue = ""; - if (!AnyConverter.isVoid(_filtercondition.Value)) + if ((_filtercondition.Handle != SQLFilterOperator.SQLNULL) + && (_filtercondition.Handle != SQLFilterOperator.NOT_SQLNULL) + && !AnyConverter.isVoid(_filtercondition.Value)) { sDisplayValue = AnyConverter.toString(_filtercondition.Value); } @@ -419,15 +429,15 @@ public class FilterComponent CurUnoDialog.insertRadioButton("optMatchAll" + sIncSuffix, SOOPTANDMODE, new ItemListenerImpl(), new String[] { - "Height", - "HelpURL", - "Label", - "PositionX", - "PositionY", - "State", - "Step", - "TabIndex", - "Width" + 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[] { @@ -444,14 +454,14 @@ public class FilterComponent optMatchAny = CurUnoDialog.insertRadioButton("optMatchAny" + sIncSuffix, SOOPTORMODE, new ItemListenerImpl(), new String[] { - "Height", - "HelpURL", - "Label", - "PositionX", - "PositionY", - "Step", - "TabIndex", - "Width" + 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[] { @@ -531,6 +541,7 @@ public class FilterComponent // ------------------------------------------------------------------------- final class ControlRow { + private final static int SOLSTFIELDNAME = 3; private final static int SOLSTOPERATOR = 4; private final static int SOTXTVALUE = 5; @@ -558,14 +569,14 @@ public class FilterComponent ControlElements[0] = (XInterface) CurUnoDialog.insertLabel("lblFieldNames" + sCompSuffix, new String[] { - "Enabled", - "Height", - "Label", - "PositionX", - "PositionY", - "Step", - "TabIndex", - "Width" + 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[] { @@ -583,14 +594,14 @@ public class FilterComponent ControlElements[1] = (XInterface) CurUnoDialog.insertLabel("lblOperators" + sCompSuffix, new String[] { - "Enabled", - "Height", - "Label", - "PositionX", - "PositionY", - "Step", - "TabIndex", - "Width" + 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[] { @@ -608,14 +619,14 @@ public class FilterComponent ControlElements[2] = (XInterface) CurUnoDialog.insertLabel("lblValue" + sCompSuffix, new String[] { - "Enabled", - "Height", - "Label", - "PositionX", - "PositionY", - "Step", - "TabIndex", - "Width" + 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[] { @@ -633,16 +644,16 @@ public class FilterComponent ControlElements[SOLSTFIELDNAME] = (XInterface) CurUnoDialog.insertListBox("lstFieldName" + sCompSuffix, SO_FIELDNAMELIST[Index], null, new ItemListenerImpl(), new String[] { - "Enabled", + PropertyNames.PROPERTY_ENABLED, "Dropdown", - "Height", - "HelpURL", + PropertyNames.PROPERTY_HEIGHT, + PropertyNames.PROPERTY_HELPURL, "LineCount", - "PositionX", - "PositionY", - "Step", - "TabIndex", - "Width" + PropertyNames.PROPERTY_POSITION_X, + PropertyNames.PROPERTY_POSITION_Y, + PropertyNames.PROPERTY_STEP, + PropertyNames.PROPERTY_TABINDEX, + PropertyNames.PROPERTY_WIDTH }, new Object[] { @@ -662,17 +673,17 @@ public class FilterComponent ControlElements[SOLSTOPERATOR] = (XInterface) CurUnoDialog.insertListBox("lstOperator" + sCompSuffix, SO_CONDITIONLIST[Index], null, new ItemListenerImpl(), new String[] { - "Enabled", + PropertyNames.PROPERTY_ENABLED, "Dropdown", - "Height", - "HelpURL", + PropertyNames.PROPERTY_HEIGHT, + PropertyNames.PROPERTY_HELPURL, "LineCount", - "PositionX", - "PositionY", - "Step", + PropertyNames.PROPERTY_POSITION_X, + PropertyNames.PROPERTY_POSITION_Y, + PropertyNames.PROPERTY_STEP, "StringItemList", - "TabIndex", - "Width" + PropertyNames.PROPERTY_TABINDEX, + PropertyNames.PROPERTY_WIDTH }, new Object[] { @@ -691,14 +702,14 @@ public class FilterComponent ControlElements[SOTXTVALUE] = (XInterface) CurUnoDialog.insertFormattedField("txtValue" + sCompSuffix, SO_TEXTFIELDLIST[Index], new TextListenerImpl(), new String[] { - "Enabled", - "Height", - "HelpURL", - "PositionX", - "PositionY", - "Step", - "TabIndex", - "Width" + PropertyNames.PROPERTY_ENABLED, + 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[] { @@ -736,16 +747,16 @@ public class FilterComponent { // disable value field - Helper.setUnoPropertyValue(UnoDialog.getModel(ControlElements[2]), "Enabled", Boolean.FALSE); - Helper.setUnoPropertyValue(UnoDialog.getModel(ControlElements[SOTXTVALUE]), "Enabled", Boolean.FALSE); + Helper.setUnoPropertyValue(UnoDialog.getModel(ControlElements[2]), PropertyNames.PROPERTY_ENABLED, Boolean.FALSE); + Helper.setUnoPropertyValue(UnoDialog.getModel(ControlElements[SOTXTVALUE]), PropertyNames.PROPERTY_ENABLED, Boolean.FALSE); return true; } else { // enable value field - Helper.setUnoPropertyValue(UnoDialog.getModel(ControlElements[2]), "Enabled", Boolean.TRUE); - Helper.setUnoPropertyValue(UnoDialog.getModel(ControlElements[SOTXTVALUE]), "Enabled", Boolean.TRUE); + Helper.setUnoPropertyValue(UnoDialog.getModel(ControlElements[2]), PropertyNames.PROPERTY_ENABLED, Boolean.TRUE); + Helper.setUnoPropertyValue(UnoDialog.getModel(ControlElements[SOTXTVALUE]), PropertyNames.PROPERTY_ENABLED, Boolean.TRUE); } if (nSelOperator != -1) { @@ -849,7 +860,7 @@ public class FilterComponent // enable all Controls Fieldname, operator, value for (int i = 0; i < ControlElements.length; i++) { - Helper.setUnoPropertyValue(UnoDialog.getModel(ControlElements[i]), "Enabled", Boolean.valueOf(_bEnabled)); + Helper.setUnoPropertyValue(UnoDialog.getModel(ControlElements[i]), PropertyNames.PROPERTY_ENABLED, Boolean.valueOf(_bEnabled)); } m_bEnabled = _bEnabled; if (isEnabled()) |