[jboss-svn-commits] JBL Code SVN: r35594 - in labs/jbossrules/trunk/drools-guvnor/src: main/java/org/drools/guvnor/client/messages and 4 other directories.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Wed Oct 20 07:58:33 EDT 2010
Author: Rikkola
Date: 2010-10-20 07:58:32 -0400 (Wed, 20 Oct 2010)
New Revision: 35594
Added:
labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/decisiontable/GroupingsPanel.java
Modified:
labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/decisiontable/ActionInsertColumn.java
labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/decisiontable/ActionSetColumn.java
labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/decisiontable/DecisionTableHandler.java
labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/decisiontable/GuidedDTColumnConfig.java
labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/decisiontable/GuidedDecisionTableWidget.java
labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/messages/Constants.java
labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/messages/Constants.properties
labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/modeldriven/SetFactTypeFilter.java
labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/server/contenthandler/GuidedDTContentHandler.java
labs/jbossrules/trunk/drools-guvnor/src/test/java/org/drools/guvnor/client/decisiontable/DecisionTableHandlerTest.java
labs/jbossrules/trunk/drools-guvnor/src/test/java/org/drools/guvnor/server/ServiceImplementationTest.java
Log:
[#GUVNOR-678] Web decision table: 'Group by column' select box content doesn't update as columns are added/removed
Modified: labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/decisiontable/ActionInsertColumn.java
===================================================================
--- labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/decisiontable/ActionInsertColumn.java 2010-10-20 11:57:47 UTC (rev 35593)
+++ labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/decisiontable/ActionInsertColumn.java 2010-10-20 11:58:32 UTC (rev 35594)
@@ -67,14 +67,14 @@
this.dt = dt;
this.sce = sce;
this.editingCol = new ActionInsertFactCol();
- editingCol.boundName = col.boundName;
- editingCol.type = col.type;
- editingCol.factField = col.factField;
- editingCol.factType = col.factType;
- editingCol.header = col.header;
- editingCol.valueList = col.valueList;
- editingCol.defaultValue = col.defaultValue;
- editingCol.hideColumn = col.hideColumn;
+ editingCol.setBoundName( col.getBoundName() );
+ editingCol.setType( col.getType() );
+ editingCol.setFactField( col.getFactField() );
+ editingCol.setFactType( col.getFactType() );
+ editingCol.setHeader( col.getHeader() );
+ editingCol.setValueList( col.getValueList() );
+ editingCol.setDefaultValue( col.getDefaultValue() );
+ editingCol.setHideColumn( col.isHideColumn() );
setTitle( constants.ActionColumnConfigurationInsertingANewFact() );
@@ -108,10 +108,10 @@
doFieldLabel();
final TextBox valueList = new TextBox();
- valueList.setText( editingCol.valueList );
+ valueList.setText( editingCol.getValueList() );
valueList.addChangeListener( new ChangeListener() {
public void onChange(Widget w) {
- editingCol.valueList = valueList.getText();
+ editingCol.setValueList( valueList.getText() );
}
} );
HorizontalPanel vl = new HorizontalPanel();
@@ -122,10 +122,10 @@
vl );
final TextBox header = new TextBox();
- header.setText( col.header );
+ header.setText( col.getHeader() );
header.addChangeListener( new ChangeListener() {
public void onChange(Widget w) {
- editingCol.header = header.getText();
+ editingCol.setHeader( header.getText() );
}
} );
addAttribute( constants.ColumnHeaderDescription(),
@@ -137,31 +137,31 @@
Button apply = new Button( constants.ApplyChanges() );
apply.addClickHandler( new ClickHandler() {
public void onClick(ClickEvent w) {
- if ( null == editingCol.header || "".equals( editingCol.header ) ) {
+ if ( null == editingCol.getHeader() || "".equals( editingCol.getHeader() ) ) {
Window.alert( constants.YouMustEnterAColumnHeaderValueDescription() );
return;
}
if ( isNew ) {
- if ( !unique( editingCol.header ) ) {
+ if ( !unique( editingCol.getHeader() ) ) {
Window.alert( constants.ThatColumnNameIsAlreadyInUsePleasePickAnother() );
return;
}
- dt.actionCols.add( editingCol );
+ dt.getActionCols().add( editingCol );
} else {
- if ( !col.header.equals( editingCol.header ) ) {
- if ( !unique( editingCol.header ) ) {
+ if ( !col.getHeader().equals( editingCol.getHeader() ) ) {
+ if ( !unique( editingCol.getHeader() ) ) {
Window.alert( constants.ThatColumnNameIsAlreadyInUsePleasePickAnother() );
return;
}
}
- col.boundName = editingCol.boundName;
- col.type = editingCol.type;
- col.factField = editingCol.factField;
- col.factType = editingCol.factType;
- col.header = editingCol.header;
- col.valueList = editingCol.valueList;
- col.defaultValue = editingCol.defaultValue;
- col.hideColumn = editingCol.hideColumn;
+ col.setBoundName( editingCol.getBoundName() );
+ col.setType( editingCol.getType() );
+ col.setFactField( editingCol.getFactField() );
+ col.setFactType( editingCol.getFactType() );
+ col.setHeader( editingCol.getHeader() );
+ col.setValueList( editingCol.getValueList() );
+ col.setDefaultValue( editingCol.getDefaultValue() );
+ col.setHideColumn( editingCol.isHideColumn() );
}
refreshGrid.execute();
hide();
@@ -173,8 +173,8 @@
}
private boolean unique(String header) {
- for ( ActionCol o : dt.actionCols ) {
- if ( o.header.equals( header ) ) return false;
+ for ( ActionCol o : dt.getActionCols() ) {
+ if ( o.getHeader().equals( header ) ) return false;
}
return true;
}
@@ -183,7 +183,7 @@
final TextBox box = new TextBox();
box.addChangeListener( new ChangeListener() {
public void onChange(Widget w) {
- editingCol.factField = box.getText();
+ editingCol.setFactField( box.getText() );
}
} );
return box;
@@ -193,7 +193,7 @@
final FormStylePopup pop = new FormStylePopup();
pop.setModal( false );
String[] fields = this.sce.getFieldCompletions( FieldAccessorsAndMutators.MUTATOR,
- this.editingCol.factType );
+ this.editingCol.getFactType() );
final ListBox box = new ListBox();
for ( int i = 0; i < fields.length; i++ ) {
box.addItem( fields[i] );
@@ -205,9 +205,9 @@
b );
b.addClickHandler( new ClickHandler() {
public void onClick(ClickEvent w) {
- editingCol.factField = box.getItemText( box.getSelectedIndex() );
- editingCol.type = sce.getFieldType( editingCol.factType,
- editingCol.factField );
+ editingCol.setFactField( box.getItemText( box.getSelectedIndex() ) );
+ editingCol.setType( sce.getFieldType( editingCol.getFactType(),
+ editingCol.getFactField() ) );
doFieldLabel();
pop.hide();
}
@@ -217,10 +217,10 @@
}
private void doFieldLabel() {
- if ( nil( this.editingCol.factField ) ) {
+ if ( nil( this.editingCol.getFactField() ) ) {
fieldLabel.setText( constants.pleaseChooseFactType() );
} else {
- fieldLabel.setText( editingCol.factField );
+ fieldLabel.setText( editingCol.getFactField() );
}
}
@@ -230,8 +230,8 @@
}
private void doPatternLabel() {
- if ( this.editingCol.factType != null ) {
- this.patternLabel.setText( this.editingCol.factType + " [" + editingCol.boundName + "]" );
+ if ( this.editingCol.getFactType() != null ) {
+ this.patternLabel.setText( this.editingCol.getFactType() + " [" + editingCol.getBoundName() + "]" );
}
}
@@ -266,8 +266,8 @@
ok.addClickHandler( new ClickHandler() {
public void onClick(ClickEvent w) {
String[] val = pats.getValue( pats.getSelectedIndex() ).split( "\\s" ); //NON-NLS
- editingCol.factType = val[0];
- editingCol.boundName = val[1];
+ editingCol.setFactType( val[0] );
+ editingCol.setBoundName( val[1] );
doPatternLabel();
pop.hide();
}
@@ -292,8 +292,8 @@
Button ok = new Button( constants.OK() );
ok.addClickHandler( new ClickHandler() {
public void onClick(ClickEvent w) {
- editingCol.boundName = binding.getText();
- editingCol.factType = types.getItemText( types.getSelectedIndex() );
+ editingCol.setBoundName( binding.getText() );
+ editingCol.setFactType( types.getItemText( types.getSelectedIndex() ) );
doPatternLabel();
pop.hide();
}
@@ -308,14 +308,14 @@
Set vars = new HashSet();
ListBox patterns = new ListBox();
- for ( Object o : dt.actionCols ) {
+ for ( Object o : dt.getActionCols() ) {
ActionCol col = (ActionCol) o;
if ( col instanceof ActionInsertFactCol ) {
ActionInsertFactCol c = (ActionInsertFactCol) col;
- if ( !vars.contains( c.boundName ) ) {
- patterns.addItem( c.factType + " [" + c.boundName + "]",
- c.factType + " " + c.boundName );
- vars.add( c.boundName );
+ if ( !vars.contains( c.getBoundName() ) ) {
+ patterns.addItem( c.getFactType() + " [" + c.getBoundName() + "]",
+ c.getFactType() + " " + c.getBoundName() );
+ vars.add( c.getBoundName() );
}
}
Modified: labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/decisiontable/ActionSetColumn.java
===================================================================
--- labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/decisiontable/ActionSetColumn.java 2010-10-20 11:57:47 UTC (rev 35593)
+++ labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/decisiontable/ActionSetColumn.java 2010-10-20 11:58:32 UTC (rev 35594)
@@ -1,4 +1,4 @@
-/**
+/*
* Copyright 2010 JBoss Inc
*
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -31,19 +31,20 @@
import org.drools.ide.common.client.modeldriven.dt.ConditionCol;
import org.drools.ide.common.client.modeldriven.dt.GuidedDecisionTable;
+import com.google.gwt.core.client.GWT;
+import com.google.gwt.event.dom.client.ChangeEvent;
+import com.google.gwt.event.dom.client.ChangeHandler;
+import com.google.gwt.event.dom.client.ClickEvent;
+import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.user.client.Command;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.ui.Button;
-import com.google.gwt.user.client.ui.ChangeListener;
import com.google.gwt.user.client.ui.CheckBox;
import com.google.gwt.user.client.ui.HorizontalPanel;
import com.google.gwt.user.client.ui.Image;
import com.google.gwt.user.client.ui.ListBox;
import com.google.gwt.user.client.ui.TextBox;
import com.google.gwt.user.client.ui.Widget;
-import com.google.gwt.core.client.GWT;
-import com.google.gwt.event.dom.client.ClickEvent;
-import com.google.gwt.event.dom.client.ClickHandler;
public class ActionSetColumn extends FormStylePopup {
@@ -63,14 +64,14 @@
this.dt = dt;
this.sce = sce;
- editingCol.boundName = col.boundName;
- editingCol.factField = col.factField;
- editingCol.header = col.header;
- editingCol.type = col.type;
- editingCol.valueList = col.valueList;
- editingCol.update = col.update;
- editingCol.defaultValue = col.defaultValue;
- editingCol.hideColumn = col.hideColumn;
+ editingCol.setBoundName( col.getBoundName() );
+ editingCol.setFactField( col.getFactField() );
+ editingCol.setHeader( col.getHeader() );
+ editingCol.setType( col.getType() );
+ editingCol.setValueList( col.getValueList() );
+ editingCol.setUpdate( col.isUpdate() );
+ editingCol.setDefaultValue( col.getDefaultValue() );
+ editingCol.setHideColumn( col.isHideColumn() );
super.setModal( false );
setTitle( constants.ColumnConfigurationSetAFieldOnAFact() );
@@ -105,10 +106,10 @@
doFieldLabel();
final TextBox valueList = new TextBox();
- valueList.setText( editingCol.valueList );
- valueList.addChangeListener( new ChangeListener() {
- public void onChange(Widget w) {
- editingCol.valueList = valueList.getText();
+ valueList.setText( editingCol.getValueList() );
+ valueList.addChangeHandler( new ChangeHandler() {
+ public void onChange(ChangeEvent event) {
+ editingCol.setValueList( valueList.getText() );
}
} );
HorizontalPanel vl = new HorizontalPanel();
@@ -119,10 +120,10 @@
vl );
final TextBox header = new TextBox();
- header.setText( col.header );
- header.addChangeListener( new ChangeListener() {
- public void onChange(Widget w) {
- editingCol.header = header.getText();
+ header.setText( col.getHeader() );
+ header.addChangeHandler( new ChangeHandler() {
+ public void onChange(ChangeEvent event) {
+ editingCol.setHeader( header.getText() );
}
} );
addAttribute( constants.ColumnHeaderDescription(),
@@ -137,33 +138,33 @@
Button apply = new Button( constants.ApplyChanges() );
apply.addClickHandler( new ClickHandler() {
public void onClick(ClickEvent w) {
- if ( null == editingCol.header || "".equals( editingCol.header ) ) {
+ if ( null == editingCol.getHeader() || "".equals( editingCol.getHeader() ) ) {
Window.alert( constants.YouMustEnterAColumnHeaderValueDescription() );
return;
}
if ( isNew ) {
- if ( !unique( editingCol.header ) ) {
+ if ( !unique( editingCol.getHeader() ) ) {
Window.alert( constants.ThatColumnNameIsAlreadyInUsePleasePickAnother() );
return;
}
- dt.actionCols.add( editingCol );
+ dt.getActionCols().add( editingCol );
} else {
- if ( !col.header.equals( editingCol.header ) ) {
- if ( !unique( editingCol.header ) ) {
+ if ( !col.getHeader().equals( editingCol.getHeader() ) ) {
+ if ( !unique( editingCol.getHeader() ) ) {
Window.alert( constants.ThatColumnNameIsAlreadyInUsePleasePickAnother() );
return;
}
}
- col.boundName = editingCol.boundName;
- col.factField = editingCol.factField;
- col.header = editingCol.header;
- col.type = editingCol.type;
- col.valueList = editingCol.valueList;
- col.update = editingCol.update;
- col.defaultValue = editingCol.defaultValue;
- col.hideColumn = editingCol.hideColumn;
+ col.setBoundName( editingCol.getBoundName() );
+ col.setFactField( editingCol.getFactField() );
+ col.setHeader( editingCol.getHeader() );
+ col.setType( editingCol.getType() );
+ col.setValueList( editingCol.getValueList() );
+ col.setUpdate( editingCol.isUpdate() );
+ col.setDefaultValue( editingCol.getDefaultValue() );
+ col.setHideColumn( editingCol.isHideColumn() );
}
refreshGrid.execute();
hide();
@@ -176,8 +177,8 @@
}
private boolean unique(String header) {
- for ( ActionCol o : dt.actionCols ) {
- if ( o.header.equals( header ) ) return false;
+ for ( ActionCol o : dt.getActionCols() ) {
+ if ( o.getHeader().equals( header ) ) return false;
}
return true;
}
@@ -186,15 +187,15 @@
HorizontalPanel hp = new HorizontalPanel();
final CheckBox cb = new CheckBox();
- cb.setEnabled( editingCol.update );
+ cb.setEnabled( editingCol.isUpdate() );
cb.setText( "" );
cb.addClickHandler( new ClickHandler() {
public void onClick(ClickEvent arg0) {
- if ( sce.isGlobalVariable( editingCol.boundName ) ) {
+ if ( sce.isGlobalVariable( editingCol.getBoundName() ) ) {
cb.setEnabled( false );
- editingCol.update = false;
+ editingCol.setUpdate( false );
} else {
- editingCol.update = cb.isEnabled();
+ editingCol.setUpdate( cb.isEnabled() );
}
}
} );
@@ -206,9 +207,9 @@
private TextBox getFieldLabel() {
final TextBox box = new TextBox();
- box.addChangeListener( new ChangeListener() {
- public void onChange(Widget w) {
- editingCol.factField = box.getText();
+ box.addChangeHandler( new ChangeHandler() {
+ public void onChange(ChangeEvent event) {
+ editingCol.setFactField( box.getText() );
}
} );
return box;
@@ -231,9 +232,9 @@
b );
b.addClickHandler( new ClickHandler() {
public void onClick(ClickEvent w) {
- editingCol.factField = box.getItemText( box.getSelectedIndex() );
- editingCol.type = sce.getFieldType( factType,
- editingCol.factField );
+ editingCol.setFactField( box.getItemText( box.getSelectedIndex() ) );
+ editingCol.setType( sce.getFieldType( factType,
+ editingCol.getFactField() ) );
doFieldLabel();
pop.hide();
}
@@ -243,25 +244,25 @@
}
private String getFactType() {
- if ( sce.isGlobalVariable( editingCol.boundName ) ) {
- return sce.getGlobalVariable( editingCol.boundName );
+ if ( sce.isGlobalVariable( editingCol.getBoundName() ) ) {
+ return sce.getGlobalVariable( editingCol.getBoundName() );
}
- return getFactType( this.editingCol.boundName );
+ return getFactType( this.editingCol.getBoundName() );
}
private void doFieldLabel() {
- if ( this.editingCol.factField != null ) {
- this.fieldLabel.setText( this.editingCol.factField );
+ if ( this.editingCol.getFactField() != null ) {
+ this.fieldLabel.setText( this.editingCol.getFactField() );
} else {
this.fieldLabel.setText( constants.pleaseChooseAFactPatternFirst() );
}
}
private String getFactType(String boundName) {
- for ( Iterator<ConditionCol> iterator = dt.conditionCols.iterator(); iterator.hasNext(); ) {
+ for ( Iterator<ConditionCol> iterator = dt.getConditionCols().iterator(); iterator.hasNext(); ) {
ConditionCol col = (ConditionCol) iterator.next();
- if ( col.boundName.equals( boundName ) ) {
- return col.factType;
+ if ( col.getBoundName().equals( boundName ) ) {
+ return col.getFactField();
}
}
return "";
@@ -280,7 +281,7 @@
ok.addClickHandler( new ClickHandler() {
public void onClick(ClickEvent w) {
String val = pats.getValue( pats.getSelectedIndex() );
- editingCol.boundName = val;
+ editingCol.setBoundName( val );
doBindingLabel();
pop.hide();
}
@@ -291,10 +292,10 @@
}
private ListBox loadBoundFacts() {
- Set facts = new HashSet();
- for ( int i = 0; i < this.dt.conditionCols.size(); i++ ) {
- ConditionCol c = (ConditionCol) dt.conditionCols.get( i );
- facts.add( c.boundName );
+ Set<String> facts = new HashSet<String>();
+ for ( int i = 0; i < this.dt.getConditionCols().size(); i++ ) {
+ ConditionCol c = (ConditionCol) dt.getConditionCols().get( i );
+ facts.add( c.getBoundName() );
}
ListBox box = new ListBox();
@@ -312,8 +313,8 @@
}
private void doBindingLabel() {
- if ( this.editingCol.boundName != null ) {
- this.bindingLabel.setText( "" + this.editingCol.boundName );
+ if ( this.editingCol.getBoundName() != null ) {
+ this.bindingLabel.setText( "" + this.editingCol.getBoundName() );
} else {
this.bindingLabel.setText( constants.pleaseChooseABoundFactForThisColumn() );
}
Modified: labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/decisiontable/DecisionTableHandler.java
===================================================================
--- labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/decisiontable/DecisionTableHandler.java 2010-10-20 11:57:47 UTC (rev 35593)
+++ labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/decisiontable/DecisionTableHandler.java 2010-10-20 11:58:32 UTC (rev 35594)
@@ -92,22 +92,22 @@
break;
case ATTRIBUTE :
add = COUNTER_AND_DESCRIPTION + dt.getMetadataCols().size();
- dt.attributeCols = moveColumnHeader( dt.attributeCols,
+ dt.setAttributeCols( moveColumnHeader( dt.getAttributeCols(),
oldIndex - add,
- newIndex - add );
+ newIndex - add ) );
break;
case CONDITION :
- add = COUNTER_AND_DESCRIPTION + dt.getMetadataCols().size() + dt.attributeCols.size();
- dt.conditionCols = moveColumnHeader( dt.conditionCols,
+ add = COUNTER_AND_DESCRIPTION + dt.getMetadataCols().size() + dt.getAttributeCols().size();
+ dt.setConditionCols( moveColumnHeader( dt.getConditionCols(),
oldIndex - add,
- newIndex - add );
+ newIndex - add ) );
break;
case ACTION :
// +1 as we have an arrow between conditions and actions.
- add = COUNTER_AND_DESCRIPTION + dt.getMetadataCols().size() + dt.attributeCols.size() + ARROW + dt.conditionCols.size();
- dt.actionCols = moveColumnHeader( dt.actionCols,
+ add = COUNTER_AND_DESCRIPTION + dt.getMetadataCols().size() + dt.getAttributeCols().size() + ARROW + dt.getConditionCols().size();
+ dt.setActionCols( moveColumnHeader( dt.getActionCols(),
oldIndex - add,
- newIndex - add );
+ newIndex - add ) );
break;
default :
break;
@@ -117,12 +117,12 @@
switch ( type ) {
case ACTION :
// If we are moving action parts we need to jump over the arrow separator.
- moveData( dt.data,
+ moveData( dt.getData(),
oldIndex - 1,
newIndex - 1 );
break;
default :
- moveData( dt.data,
+ moveData( dt.getData(),
oldIndex,
newIndex );
break;
@@ -135,9 +135,9 @@
if ( index < (COUNTER_AND_DESCRIPTION + dt.getMetadataCols().size()) ) {
return DTColumnConfigType.METADATA;
- } else if ( index < (COUNTER_AND_DESCRIPTION + dt.getMetadataCols().size() + dt.attributeCols.size()) ) {
+ } else if ( index < (COUNTER_AND_DESCRIPTION + dt.getMetadataCols().size() + dt.getAttributeCols().size()) ) {
return DTColumnConfigType.ATTRIBUTE;
- } else if ( index < (COUNTER_AND_DESCRIPTION + dt.getMetadataCols().size() + dt.attributeCols.size() + dt.conditionCols.size() + ARROW) ) {
+ } else if ( index < (COUNTER_AND_DESCRIPTION + dt.getMetadataCols().size() + dt.getAttributeCols().size() + dt.getConditionCols().size() + ARROW) ) {
return DTColumnConfigType.CONDITION;
} else {
return DTColumnConfigType.ACTION;
Added: labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/decisiontable/GroupingsPanel.java
===================================================================
--- labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/decisiontable/GroupingsPanel.java (rev 0)
+++ labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/decisiontable/GroupingsPanel.java 2010-10-20 11:58:32 UTC (rev 35594)
@@ -0,0 +1,139 @@
+/*
+ * Copyright 2010 JBoss Inc
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.drools.guvnor.client.decisiontable;
+
+import org.drools.guvnor.client.common.SmallLabel;
+import org.drools.guvnor.client.messages.Constants;
+import org.drools.ide.common.client.modeldriven.dt.ActionCol;
+import org.drools.ide.common.client.modeldriven.dt.AttributeCol;
+import org.drools.ide.common.client.modeldriven.dt.ConditionCol;
+import org.drools.ide.common.client.modeldriven.dt.GuidedDecisionTable;
+import org.drools.ide.common.client.modeldriven.dt.MetadataCol;
+
+import com.google.gwt.core.client.GWT;
+import com.google.gwt.event.dom.client.ClickEvent;
+import com.google.gwt.event.dom.client.ClickHandler;
+import com.google.gwt.user.client.Command;
+import com.google.gwt.user.client.ui.Button;
+import com.google.gwt.user.client.ui.HorizontalPanel;
+import com.google.gwt.user.client.ui.ListBox;
+
+/**
+ *
+ * @author rikkola
+ *
+ */
+public class GroupingsPanel extends HorizontalPanel {
+
+ private Constants constants = ((Constants) GWT.create( Constants.class ));
+
+ private final ListBox columnsListBox = new ListBox();
+ private final GuidedDecisionTable guidedDecisionTable;
+ private final Command refreshCommand;
+
+ public GroupingsPanel(final GuidedDecisionTable guidedDecisionTable,
+ final Command refreshCommand) {
+ this.guidedDecisionTable = guidedDecisionTable;
+ this.refreshCommand = refreshCommand;
+
+ initColumnsListBox();
+
+ add( new SmallLabel( constants.GroupByColumn() ) );
+ add( columnsListBox );
+
+ add( getOkButton() );
+ }
+
+ private void initColumnsListBox() {
+ columnsListBox.addItem( constants.Description(),
+ "desc" ); //NON-NLS
+
+ addListItems();
+
+ if ( guidedDecisionTable.getGroupField() == null ) {
+ columnsListBox.setSelectedIndex( columnsListBox.getItemCount() - 1 );
+ }
+ }
+
+ private Button getOkButton() {
+ Button ok = new Button( constants.Apply() );
+ ok.addClickHandler( new ClickHandler() {
+ public void onClick(ClickEvent w) {
+ guidedDecisionTable.setGroupField( columnsListBox.getValue( columnsListBox.getSelectedIndex() ) );
+ refreshCommand.execute();
+ }
+ } );
+ return ok;
+ }
+
+ private void addListItems() {
+ addMetaDataColumns();
+ addAttributeColumns();
+ addConditionColumns();
+ addActionColumns();
+ addNone();
+ }
+
+ private void addNone() {
+ columnsListBox.addItem( constants.none(),
+ "" );
+ }
+
+ private void addActionColumns() {
+ for ( ActionCol c : guidedDecisionTable.getActionCols() ) {
+ columnsListBox.addItem( c.getHeader(),
+ c.getHeader() );
+ if ( c.getHeader().equals( guidedDecisionTable.getGroupField() ) ) {
+ columnsListBox.setSelectedIndex( columnsListBox.getItemCount() - 1 );
+ }
+ }
+ }
+
+ private void addConditionColumns() {
+ for ( ConditionCol c : guidedDecisionTable.getConditionCols() ) {
+ columnsListBox.addItem( c.getHeader(),
+ c.getHeader() );
+ if ( c.getHeader().equals( guidedDecisionTable.getGroupField() ) ) {
+ columnsListBox.setSelectedIndex( columnsListBox.getItemCount() - 1 );
+ }
+ }
+ }
+
+ private void addAttributeColumns() {
+ for ( AttributeCol c : guidedDecisionTable.getAttributeCols() ) {
+ columnsListBox.addItem( c.attr,
+ c.attr );
+ if ( c.attr.equals( guidedDecisionTable.getGroupField() ) ) {
+ columnsListBox.setSelectedIndex( columnsListBox.getItemCount() - 1 );
+ }
+ }
+ }
+
+ private void addMetaDataColumns() {
+ for ( MetadataCol c : guidedDecisionTable.getMetadataCols() ) {
+ columnsListBox.addItem( c.attr,
+ c.attr );
+ if ( c.attr.equals( guidedDecisionTable.getGroupField() ) ) {
+ columnsListBox.setSelectedIndex( columnsListBox.getItemCount() - 1 );
+ }
+ }
+ }
+
+ public void refresh() {
+ columnsListBox.clear();
+ addListItems();
+ }
+}
Modified: labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/decisiontable/GuidedDTColumnConfig.java
===================================================================
--- labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/decisiontable/GuidedDTColumnConfig.java 2010-10-20 11:57:47 UTC (rev 35593)
+++ labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/decisiontable/GuidedDTColumnConfig.java 2010-10-20 11:58:32 UTC (rev 35594)
@@ -1,4 +1,4 @@
-/**
+/*
* Copyright 2010 JBoss Inc
*
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -34,21 +34,20 @@
import org.drools.ide.common.client.modeldriven.dt.GuidedDecisionTable;
import com.google.gwt.core.client.GWT;
+import com.google.gwt.event.dom.client.ChangeEvent;
+import com.google.gwt.event.dom.client.ChangeHandler;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.user.client.Command;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.ui.Button;
-import com.google.gwt.user.client.ui.ChangeListener;
import com.google.gwt.user.client.ui.CheckBox;
-import com.google.gwt.user.client.ui.ClickListener;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.HorizontalPanel;
import com.google.gwt.user.client.ui.Image;
import com.google.gwt.user.client.ui.ListBox;
import com.google.gwt.user.client.ui.RadioButton;
import com.google.gwt.user.client.ui.TextBox;
-import com.google.gwt.user.client.ui.Widget;
/**
* This is a configuration editor for a column in a the guided decision table.
@@ -84,15 +83,15 @@
this.dt = dt;
this.sce = sce;
this.editingCol = new ConditionCol();
- editingCol.boundName = col.boundName;
- editingCol.constraintValueType = col.constraintValueType;
- editingCol.factField = col.factField;
- editingCol.factType = col.factType;
- editingCol.header = col.header;
- editingCol.operator = col.operator;
- editingCol.valueList = col.valueList;
- editingCol.defaultValue = col.defaultValue;
- editingCol.hideColumn = col.hideColumn;
+ editingCol.setBoundName( col.getBoundName() );
+ editingCol.setConstraintValueType( col.getConstraintValueType() );
+ editingCol.setFactField( col.getFactField() );
+ editingCol.setFactType( col.getFactType() );
+ editingCol.setHeader( col.getHeader() );
+ editingCol.setOperator( col.getOperator() );
+ editingCol.setValueList( col.getValueList() );
+ editingCol.setDefaultValue( col.getDefaultValue() );
+ editingCol.setHideColumn( col.isHideColumn() );
setTitle( constants.ConditionColumnConfiguration() );
@@ -127,7 +126,7 @@
addAttribute( constants.CalculationType(),
valueTypes );
- switch ( editingCol.constraintValueType ) {
+ switch ( editingCol.getConstraintValueType() ) {
case BaseSingleFieldConstraint.TYPE_LITERAL :
literal.setEnabled( true );
break;
@@ -185,10 +184,10 @@
doOperatorLabel();
final TextBox valueList = new TextBox();
- valueList.setText( editingCol.valueList );
- valueList.addChangeListener( new ChangeListener() {
- public void onChange(Widget w) {
- editingCol.valueList = valueList.getText();
+ valueList.setText( editingCol.getValueList() );
+ valueList.addChangeHandler( new ChangeHandler() {
+ public void onChange(ChangeEvent event) {
+ editingCol.setValueList( valueList.getText() );
}
} );
HorizontalPanel vl = new HorizontalPanel();
@@ -199,10 +198,10 @@
vl );
final TextBox header = new TextBox();
- header.setText( col.header );
- header.addChangeListener( new ChangeListener() {
- public void onChange(Widget w) {
- editingCol.header = header.getText();
+ header.setText( col.getHeader() );
+ header.addChangeHandler( new ChangeHandler() {
+ public void onChange(ChangeEvent event) {
+ editingCol.setHeader( header.getText() );
}
} );
addAttribute( constants.ColumnHeaderDescription(),
@@ -214,44 +213,44 @@
Button apply = new Button( constants.ApplyChanges() );
apply.addClickHandler( new ClickHandler() {
public void onClick(ClickEvent w) {
- if ( null == editingCol.header || "".equals( editingCol.header ) ) {
+ if ( null == editingCol.getHeader() || "".equals( editingCol.getHeader() ) ) {
Window.alert( constants.YouMustEnterAColumnHeaderValueDescription() );
return;
}
- if ( editingCol.constraintValueType != BaseSingleFieldConstraint.TYPE_PREDICATE ) {
- if ( null == editingCol.factField || "".equals( editingCol.factField ) ) {
- Window.alert(constants.PleaseSelectOrEnterField());
- return;
+ if ( editingCol.getConstraintValueType() != BaseSingleFieldConstraint.TYPE_PREDICATE ) {
+ if ( null == editingCol.getFactField() || "".equals( editingCol.getFactField() ) ) {
+ Window.alert( constants.PleaseSelectOrEnterField() );
+ return;
}
- if ( null == editingCol.operator || "".equals( editingCol.operator ) ) {
- // Operator field optional
+ if ( null == editingCol.getOperator() || "".equals( editingCol.getOperator() ) ) {
+ // Operator field optional
Window.alert( constants.NotifyNoSelectedOperator() );
}
}
if ( isNew ) {
- if ( !unique( editingCol.header ) ) {
+ if ( !unique( editingCol.getHeader() ) ) {
Window.alert( constants.ThatColumnNameIsAlreadyInUsePleasePickAnother() );
return;
}
- dt.conditionCols.add( editingCol );
+ dt.getConditionCols().add( editingCol );
} else {
- if ( !col.header.equals( editingCol.header ) ) {
- if ( !unique( editingCol.header ) ) {
+ if ( !col.getHeader().equals( editingCol.getHeader() ) ) {
+ if ( !unique( editingCol.getHeader() ) ) {
Window.alert( constants.ThatColumnNameIsAlreadyInUsePleasePickAnother() );
return;
}
}
- col.boundName = editingCol.boundName;
- col.constraintValueType = editingCol.constraintValueType;
- col.factField = editingCol.factField;
- col.factType = editingCol.factType;
+ col.setBoundName( editingCol.getBoundName() );
+ col.setConstraintValueType( editingCol.getConstraintValueType() );
+ col.setFactField( editingCol.getFactField() );
+ col.setFactType( editingCol.getFactType() );
- col.header = editingCol.header;
- col.operator = editingCol.operator;
- col.valueList = editingCol.valueList;
- col.defaultValue = editingCol.defaultValue;
- col.hideColumn = editingCol.hideColumn;
+ col.setHeader( editingCol.getHeader() );
+ col.setOperator( editingCol.getOperator() );
+ col.setValueList( editingCol.getValueList() );
+ col.setDefaultValue( editingCol.getDefaultValue() );
+ col.setHideColumn( editingCol.isHideColumn() );
}
refreshGrid.execute();
hide();
@@ -268,17 +267,18 @@
*/
public static HorizontalPanel getDefaultEditor(final DTColumnConfig editingCol) {
final TextBox defaultValue = new TextBox();
- defaultValue.setText( editingCol.defaultValue );
+ defaultValue.setText( editingCol.getDefaultValue() );
final CheckBox hide = new CheckBox( ((Constants) GWT.create( Constants.class )).HideThisColumn() );
- hide.setEnabled(editingCol.hideColumn );
+ hide.setEnabled( editingCol.isHideColumn() );
hide.addClickHandler( new ClickHandler() {
public void onClick(ClickEvent sender) {
- editingCol.hideColumn = hide.isEnabled();
+ editingCol.setHideColumn( hide.isEnabled() );
}
} );
- defaultValue.addChangeListener( new ChangeListener() {
- public void onChange(Widget sender) {
- editingCol.defaultValue = defaultValue.getText();
+ defaultValue.addChangeHandler( new ChangeHandler() {
+
+ public void onChange(ChangeEvent event) {
+ editingCol.setDefaultValue( defaultValue.getText() );
}
} );
HorizontalPanel hp = new HorizontalPanel();
@@ -288,39 +288,39 @@
}
private boolean unique(String header) {
- for ( ConditionCol o : dt.conditionCols ) {
- if ( o.header.equals( header ) ) return false;
+ for ( ConditionCol o : dt.getConditionCols() ) {
+ if ( o.getHeader().equals( header ) ) return false;
}
return true;
}
private TextBox getFieldLabel() {
final TextBox box = new TextBox();
- box.addChangeListener( new ChangeListener() {
- public void onChange(Widget w) {
- editingCol.factField = box.getText();
+ box.addChangeHandler( new ChangeHandler() {
+ public void onChange(ChangeEvent event) {
+ editingCol.setFactField( box.getText() );
}
} );
return box;
}
private void applyConsTypeChange(int newType) {
- editingCol.constraintValueType = newType;
+ editingCol.setConstraintValueType( newType );
doFieldLabel();
doOperatorLabel();
}
private void doOperatorLabel() {
- if ( editingCol.constraintValueType == BaseSingleFieldConstraint.TYPE_PREDICATE ) {
+ if ( editingCol.getConstraintValueType() == BaseSingleFieldConstraint.TYPE_PREDICATE ) {
operatorLabel.setText( constants.notNeededForPredicate() );
- } else if ( nil( editingCol.factType ) ) {
+ } else if ( nil( editingCol.getFactType() ) ) {
operatorLabel.setText( constants.pleaseSelectAPatternFirst() );
- } else if ( nil( editingCol.factField ) ) {
+ } else if ( nil( editingCol.getFactField() ) ) {
operatorLabel.setText( constants.pleaseChooseAFieldFirst() );
- } else if ( nil( editingCol.operator ) ) {
+ } else if ( nil( editingCol.getOperator() ) ) {
operatorLabel.setText( constants.pleaseSelectAField() );
} else {
- operatorLabel.setText( HumanReadable.getOperatorDisplayName( editingCol.operator ) );
+ operatorLabel.setText( HumanReadable.getOperatorDisplayName( editingCol.getOperator() ) );
}
}
@@ -328,15 +328,15 @@
final FormStylePopup pop = new FormStylePopup();
pop.setTitle( constants.SetTheOperator() );
pop.setModal( false );
- String[] ops = this.sce.getOperatorCompletions( editingCol.factType,
- editingCol.factField );
+ String[] ops = this.sce.getOperatorCompletions( editingCol.getFactType(),
+ editingCol.getFactField() );
final ListBox box = new ListBox();
for ( int i = 0; i < ops.length; i++ ) {
box.addItem( HumanReadable.getOperatorDisplayName( ops[i] ),
ops[i] );
}
- if ( BaseSingleFieldConstraint.TYPE_LITERAL == this.editingCol.constraintValueType ) {
+ if ( BaseSingleFieldConstraint.TYPE_LITERAL == this.editingCol.getConstraintValueType() ) {
box.addItem( HumanReadable.getOperatorDisplayName( "in" ),
"in" );
}
@@ -350,7 +350,7 @@
b );
b.addClickHandler( new ClickHandler() {
public void onClick(ClickEvent w) {
- editingCol.operator = box.getValue( box.getSelectedIndex() );
+ editingCol.setOperator( box.getValue( box.getSelectedIndex() ) );
doOperatorLabel();
pop.hide();
}
@@ -360,17 +360,17 @@
}
private void doFieldLabel() {
- if ( editingCol.constraintValueType == BaseSingleFieldConstraint.TYPE_PREDICATE ) {
+ if ( editingCol.getConstraintValueType() == BaseSingleFieldConstraint.TYPE_PREDICATE ) {
fieldLabel.setText( constants.notNeededForPredicate() );
fieldLabelInterpolationInfo.setVisible( true );
- } else if ( nil( editingCol.factType ) ) {
+ } else if ( nil( editingCol.getFactType() ) ) {
fieldLabel.setText( constants.pleaseSelectAPatternFirst() );
fieldLabelInterpolationInfo.setVisible( false );
- } else if ( nil( editingCol.factField ) ) {
+ } else if ( nil( editingCol.getFactField() ) ) {
fieldLabel.setText( constants.pleaseSelectAField() );
fieldLabelInterpolationInfo.setVisible( false );
} else {
- fieldLabel.setText( this.editingCol.factField );
+ fieldLabel.setText( this.editingCol.getFactField() );
}
}
@@ -382,8 +382,8 @@
final FormStylePopup pop = new FormStylePopup();
pop.setModal( false );
String[] fields = this.sce.getFieldCompletions( FieldAccessorsAndMutators.ACCESSOR,
- this.editingCol.factType );
-
+ this.editingCol.getFactType() );
+
final ListBox box = new ListBox();
for ( int i = 0; i < fields.length; i++ ) {
box.addItem( fields[i] );
@@ -395,7 +395,7 @@
b );
b.addClickHandler( new ClickHandler() {
public void onClick(ClickEvent w) {
- editingCol.factField = box.getItemText( box.getSelectedIndex() );
+ editingCol.setFactField( box.getItemText( box.getSelectedIndex() ) );
doFieldLabel();
doOperatorLabel();
pop.hide();
@@ -405,8 +405,8 @@
}
private void doPatternLabel() {
- if ( this.editingCol.factType != null ) {
- this.patternLabel.setText( this.editingCol.factType + " [" + editingCol.boundName + "]" );
+ if ( this.editingCol.getFactType() != null ) {
+ this.patternLabel.setText( this.editingCol.getFactType() + " [" + editingCol.getBoundName() + "]" );
}
doFieldLabel();
doOperatorLabel();
@@ -444,8 +444,8 @@
ok.addClickHandler( new ClickHandler() {
public void onClick(ClickEvent w) {
String[] val = pats.getValue( pats.getSelectedIndex() ).split( "\\s" );
- editingCol.factType = val[0];
- editingCol.boundName = val[1];
+ editingCol.setFactType( val[0] );
+ editingCol.setBoundName( val[1] );
doPatternLabel();
pop.hide();
}
@@ -464,8 +464,8 @@
pop.addAttribute( constants.FactType(),
types );
final TextBox binding = new TextBox();
- binding.addChangeListener( new ChangeListener() {
- public void onChange(Widget sender) {
+ binding.addChangeHandler( new ChangeHandler() {
+ public void onChange(ChangeEvent event) {
binding.setText( binding.getText().replace( " ",
"" ) );
}
@@ -486,12 +486,12 @@
Window.alert( constants.PleaseEnterANameThatIsNotTheSameAsTheFactType() );
return;
} else if ( !checkUnique( fn,
- dt.conditionCols ) ) {
+ dt.getConditionCols() ) ) {
Window.alert( constants.PleaseEnterANameThatIsNotAlreadyUsedByAnotherPattern() );
return;
}
- editingCol.boundName = fn;
- editingCol.factType = ft;
+ editingCol.setBoundName( fn );
+ editingCol.setFactType( ft );
doPatternLabel();
pop.hide();
}
@@ -506,20 +506,20 @@
private boolean checkUnique(String fn,
List<ConditionCol> conditionCols) {
for ( ConditionCol c : conditionCols ) {
- if ( c.boundName.equals( fn ) ) return false;
+ if ( c.getBoundName().equals( fn ) ) return false;
}
return true;
}
private ListBox loadPatterns() {
- Set vars = new HashSet();
+ Set<String> vars = new HashSet<String>();
ListBox patterns = new ListBox();
- for ( int i = 0; i < dt.conditionCols.size(); i++ ) {
- ConditionCol c = dt.conditionCols.get( i );
- if ( !vars.contains( c.boundName ) ) {
- patterns.addItem( c.factType + " [" + c.boundName + "]",
- c.factType + " " + c.boundName );
- vars.add( c.boundName );
+ for ( int i = 0; i < dt.getConditionCols().size(); i++ ) {
+ ConditionCol c = dt.getConditionCols().get( i );
+ if ( !vars.contains( c.getBoundName() ) ) {
+ patterns.addItem( c.getFactType() + " [" + c.getBoundName() + "]",
+ c.getFactType() + " " + c.getBoundName() );
+ vars.add( c.getBoundName() );
}
}
Modified: labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/decisiontable/GuidedDecisionTableWidget.java
===================================================================
--- labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/decisiontable/GuidedDecisionTableWidget.java 2010-10-20 11:57:47 UTC (rev 35593)
+++ labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/decisiontable/GuidedDecisionTableWidget.java 2010-10-20 11:58:32 UTC (rev 35594)
@@ -16,7 +16,6 @@
package org.drools.guvnor.client.decisiontable;
-import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
@@ -37,6 +36,7 @@
import org.drools.guvnor.client.rpc.RuleAsset;
import org.drools.guvnor.client.ruleeditor.RuleViewer;
import org.drools.guvnor.client.ruleeditor.SaveEventListener;
+import org.drools.guvnor.client.util.AddButton;
import org.drools.guvnor.client.util.Format;
import org.drools.guvnor.client.util.NumbericFilterKeyPressHandler;
import org.drools.ide.common.client.modeldriven.SuggestionCompletionEngine;
@@ -111,7 +111,9 @@
implements
SaveEventListener {
- private GuidedDecisionTable dt;
+ private Constants constants = ((Constants) GWT.create( Constants.class ));
+
+ private GuidedDecisionTable guidedDecisionTable;
private VerticalPanel layout;
private PrettyFormLayout configureColumnsNote;
private GridPanel grid;
@@ -123,8 +125,8 @@
private Map<String, DTColumnConfig> colMap;
private SuggestionCompletionEngine sce;
private GroupingStore store;
- private Constants constants = ((Constants) GWT.create( Constants.class ));
private RecordDef recordDef;
+ private GroupingsPanel groupingsPanel = null;
public GuidedDecisionTableWidget(RuleAsset asset,
RuleViewer viewer) {
@@ -133,9 +135,9 @@
public GuidedDecisionTableWidget(RuleAsset asset) {
- this.dt = (GuidedDecisionTable) asset.content;
+ this.guidedDecisionTable = (GuidedDecisionTable) asset.content;
this.packageName = asset.metaData.packageName;
- this.dt.tableName = asset.metaData.name;
+ this.guidedDecisionTable.setTableName( asset.metaData.name );
layout = new VerticalPanel();
@@ -182,64 +184,16 @@
}
private Widget getGrouping() {
- final ListBox list = new ListBox();
- list.addItem( constants.Description(),
- "desc" ); //NON-NLS
- if ( dt.getMetadataCols() == null ) {
- dt.setMetadataCols( new ArrayList<MetadataCol>() );
- }
- for ( MetadataCol c : dt.getMetadataCols() ) {
- list.addItem( c.attr,
- c.attr );
- if ( c.attr.equals( dt.groupField ) ) {
- list.setSelectedIndex( list.getItemCount() - 1 );
- }
- }
- for ( AttributeCol c : dt.attributeCols ) {
- list.addItem( c.attr,
- c.attr );
- if ( c.attr.equals( dt.groupField ) ) {
- list.setSelectedIndex( list.getItemCount() - 1 );
- }
- }
- for ( ConditionCol c : dt.conditionCols ) {
- list.addItem( c.header,
- c.header );
- if ( c.header.equals( dt.groupField ) ) {
- list.setSelectedIndex( list.getItemCount() - 1 );
- }
- }
- for ( ActionCol c : dt.actionCols ) {
- list.addItem( c.header,
- c.header );
- if ( c.header.equals( dt.groupField ) ) {
- list.setSelectedIndex( list.getItemCount() - 1 );
- }
- }
+ this.groupingsPanel = new GroupingsPanel( guidedDecisionTable,
+ new Command() {
- list.addItem( constants.none(),
- "" );
- if ( dt.groupField == null ) {
- list.setSelectedIndex( list.getItemCount() - 1 );
- }
-
- HorizontalPanel h = new HorizontalPanel();
- h.add( new SmallLabel( constants.GroupByColumn() ) );
- h.add( list );
-
- Button ok = new Button( constants.Apply() );
- ok.addClickHandler( new ClickHandler() {
- public void onClick(ClickEvent w) {
- dt.groupField = list.getValue( list.getSelectedIndex() );
- scrapeData( -1 );
- refreshGrid();
- }
- } );
-
- h.add( ok );
-
- return h;
+ public void execute() {
+ scrapeData( -1 );
+ refreshGrid();
+ }
+ } );
+ return groupingsPanel;
}
private Widget getActions() {
@@ -250,11 +204,11 @@
private void refreshActionsWidget() {
this.actionsConfigWidget.clear();
- for ( ActionCol c : dt.actionCols ) {
+ for ( ActionCol c : guidedDecisionTable.getActionCols() ) {
HorizontalPanel hp = new HorizontalPanel();
hp.add( removeAction( c ) );
hp.add( editAction( c ) );
- hp.add( new SmallLabel( c.header ) );
+ hp.add( new SmallLabel( c.getHeader() ) );
actionsConfigWidget.add( hp );
}
actionsConfigWidget.add( newAction() );
@@ -268,12 +222,13 @@
if ( c instanceof ActionSetFieldCol ) {
ActionSetFieldCol asf = (ActionSetFieldCol) c;
ActionSetColumn ed = new ActionSetColumn( getSCE(),
- dt,
+ guidedDecisionTable,
new Command() {
public void execute() {
scrapeData( -1 );
refreshGrid();
refreshActionsWidget();
+ refreshGroupingsPanel();
}
},
asf,
@@ -282,12 +237,13 @@
} else if ( c instanceof ActionInsertFactCol ) {
ActionInsertFactCol asf = (ActionInsertFactCol) c;
ActionInsertColumn ed = new ActionInsertColumn( getSCE(),
- dt,
+ guidedDecisionTable,
new Command() {
public void execute() {
scrapeData( -1 );
refreshGrid();
refreshActionsWidget();
+ refreshGroupingsPanel();
}
},
asf,
@@ -301,73 +257,76 @@
}
private Widget newAction() {
- return new ImageButton( "images/new_item.gif",
- constants.CreateANewActionColumn(),
- new ClickHandler() { //NON-NLS
- public void onClick(ClickEvent w) {
- final FormStylePopup pop = new FormStylePopup();
- pop.setModal( false );
+ AddButton addButton = new AddButton();
+ addButton.setText( constants.NewColumn() );
+ addButton.setTitle( constants.CreateANewActionColumn() );
- final ListBox choice = new ListBox();
- choice.addItem( constants.SetTheValueOfAField(),
- "set" );
- choice.addItem( constants.SetTheValueOfAFieldOnANewFact(),
- "insert" );
- Button ok = new Button( "OK" );
- ok.addClickHandler( new ClickHandler() {
- public void onClick(ClickEvent w) {
- String s = choice.getValue( choice.getSelectedIndex() );
- if ( s.equals( "set" ) ) {
- showSet();
- } else if ( s.equals( "insert" ) ) {
- showInsert();
- }
- pop.hide();
- }
+ addButton.addClickHandler( new ClickHandler() { //NON-NLS
+ public void onClick(ClickEvent w) {
+ final FormStylePopup pop = new FormStylePopup();
+ pop.setModal( false );
- private void showInsert() {
- ActionInsertColumn ins = new ActionInsertColumn( getSCE(),
- dt,
- new Command() {
- public void execute() {
- newActionAdded();
- }
- },
- new ActionInsertFactCol(),
- true );
- ins.show();
- }
+ final ListBox choice = new ListBox();
+ choice.addItem( constants.SetTheValueOfAField(),
+ "set" );
+ choice.addItem( constants.SetTheValueOfAFieldOnANewFact(),
+ "insert" );
+ Button ok = new Button( "OK" );
+ ok.addClickHandler( new ClickHandler() {
+ public void onClick(ClickEvent w) {
+ String s = choice.getValue( choice.getSelectedIndex() );
+ if ( s.equals( "set" ) ) {
+ showSet();
+ } else if ( s.equals( "insert" ) ) {
+ showInsert();
+ }
+ pop.hide();
+ }
- private void showSet() {
- ActionSetColumn set = new ActionSetColumn( getSCE(),
- dt,
- new Command() {
- public void execute() {
- newActionAdded();
- }
- },
- new ActionSetFieldCol(),
- true );
- set.show();
- }
+ private void showInsert() {
+ ActionInsertColumn ins = new ActionInsertColumn( getSCE(),
+ guidedDecisionTable,
+ new Command() {
+ public void execute() {
+ newActionAdded();
+ }
+ },
+ new ActionInsertFactCol(),
+ true );
+ ins.show();
+ }
- private void newActionAdded() {
- //want to add in a blank row into the data
- scrapeData( dt.getMetadataCols().size() + dt.attributeCols.size() + dt.conditionCols.size() + dt.actionCols.size() + 1 );
- refreshGrid();
- refreshActionsWidget();
+ private void showSet() {
+ ActionSetColumn set = new ActionSetColumn( getSCE(),
+ guidedDecisionTable,
+ new Command() {
+ public void execute() {
+ newActionAdded();
+ }
+ },
+ new ActionSetFieldCol(),
+ true );
+ set.show();
+ }
- }
- } );
- pop.addAttribute( constants.TypeOfActionColumn(),
- choice );
- pop.addAttribute( "",
- ok );
- pop.show();
- }
+ private void newActionAdded() {
+ //want to add in a blank row into the data
+ scrapeData( guidedDecisionTable.getMetadataCols().size() + guidedDecisionTable.getAttributeCols().size() + guidedDecisionTable.getConditionCols().size() + guidedDecisionTable.getActionCols().size() + 1 );
+ refreshGrid();
+ refreshActionsWidget();
- } );
+ }
+ } );
+ pop.addAttribute( constants.TypeOfActionColumn(),
+ choice );
+ pop.addAttribute( "",
+ ok );
+ pop.show();
+ }
+ } );
+
+ return addButton;
}
private Widget removeAction(final ActionCol c) {
@@ -376,10 +335,10 @@
new ClickHandler() { //NON-NLS
public void onClick(ClickEvent w) {
String cm = Format.format( constants.DeleteActionColumnWarning(),
- c.header );
+ c.getHeader() );
if ( com.google.gwt.user.client.Window.confirm( cm ) ) {
- dt.actionCols.remove( c );
- removeField( c.header );
+ guidedDecisionTable.getActionCols().remove( c );
+ removeField( c.getHeader() );
scrapeData( -1 );
refreshGrid();
refreshActionsWidget();
@@ -398,12 +357,12 @@
private void refreshConditionsWidget() {
this.conditionsConfigWidget.clear();
- for ( int i = 0; i < dt.conditionCols.size(); i++ ) {
- ConditionCol c = dt.conditionCols.get( i );
+ for ( int i = 0; i < guidedDecisionTable.getConditionCols().size(); i++ ) {
+ ConditionCol c = guidedDecisionTable.getConditionCols().get( i );
HorizontalPanel hp = new HorizontalPanel();
hp.add( removeCondition( c ) );
hp.add( editCondition( c ) );
- hp.add( new SmallLabel( c.header ) );
+ hp.add( new SmallLabel( c.getHeader() ) );
conditionsConfigWidget.add( hp );
}
conditionsConfigWidget.add( newCondition() );
@@ -412,26 +371,29 @@
private Widget newCondition() {
final ConditionCol newCol = new ConditionCol();
- newCol.constraintValueType = BaseSingleFieldConstraint.TYPE_LITERAL;
- return new ImageButton( "images/new_item.gif",
- constants.AddANewConditionColumn(),
- new ClickHandler() { //NON-NLS
- public void onClick(ClickEvent w) {
- GuidedDTColumnConfig dialog = new GuidedDTColumnConfig( getSCE(),
- dt,
- new Command() {
- public void execute() {
- //want to add in a blank row into the data
- scrapeData( dt.getMetadataCols().size() + dt.attributeCols.size() + dt.conditionCols.size() + 1 );
- refreshGrid();
- refreshConditionsWidget();
- }
- },
- newCol,
- true );
- dialog.show();
- }
- } );
+ newCol.setConstraintValueType( BaseSingleFieldConstraint.TYPE_LITERAL );
+ AddButton addButton = new AddButton();
+ addButton.setText( constants.NewColumn() );
+ addButton.setTitle( constants.AddANewConditionColumn() );
+ addButton.addClickHandler( new ClickHandler() { //NON-NLS
+ public void onClick(ClickEvent w) {
+ GuidedDTColumnConfig dialog = new GuidedDTColumnConfig( getSCE(),
+ guidedDecisionTable,
+ new Command() {
+ public void execute() {
+ //want to add in a blank row into the data
+ scrapeData( guidedDecisionTable.getMetadataCols().size() + guidedDecisionTable.getAttributeCols().size() + guidedDecisionTable.getConditionCols().size() + 1 );
+ refreshGrid();
+ refreshConditionsWidget();
+ refreshGroupingsPanel();
+ }
+ },
+ newCol,
+ true );
+ dialog.show();
+ }
+ } );
+ return addButton;
}
private Widget editCondition(final ConditionCol c) {
@@ -440,7 +402,7 @@
new ClickHandler() { //NON-NLS
public void onClick(ClickEvent w) {
GuidedDTColumnConfig dialog = new GuidedDTColumnConfig( getSCE(),
- dt,
+ guidedDecisionTable,
new Command() {
public void execute() {
scrapeData( -1 );
@@ -468,10 +430,10 @@
new ClickHandler() { //NON-NLS
public void onClick(ClickEvent w) {
String cm = Format.format( constants.DeleteConditionColumnWarning(),
- c.header );
+ c.getHeader() );
if ( com.google.gwt.user.client.Window.confirm( cm ) ) {
- dt.conditionCols.remove( c );
- removeField( c.header );
+ guidedDecisionTable.getConditionCols().remove( c );
+ removeField( c.getHeader() );
scrapeData( -1 );
refreshGrid();
refreshConditionsWidget();
@@ -491,27 +453,27 @@
private void refreshAttributeWidget() {
this.attributeConfigWidget.clear();
attributeConfigWidget.add( newAttr() );
- if ( dt.getMetadataCols().size() > 0 ) {
+ if ( guidedDecisionTable.getMetadataCols().size() > 0 ) {
HorizontalPanel hp = new HorizontalPanel();
hp.add( new HTML( " " ) ); //NON-NLS
hp.add( new SmallLabel( constants.Metadata() ) );
attributeConfigWidget.add( hp );
}
- for ( MetadataCol at : dt.getMetadataCols() ) {
+ for ( MetadataCol at : guidedDecisionTable.getMetadataCols() ) {
HorizontalPanel hp = new HorizontalPanel();
hp.add( new HTML( " " ) ); //NON-NLS
hp.add( removeMeta( at ) );
hp.add( new SmallLabel( at.attr ) );
attributeConfigWidget.add( hp );
}
- if ( dt.attributeCols.size() > 0 ) {
+ if ( guidedDecisionTable.getAttributeCols().size() > 0 ) {
HorizontalPanel hp = new HorizontalPanel();
hp.add( new HTML( " " ) ); //NON-NLS
hp.add( new SmallLabel( constants.Attributes() ) );
attributeConfigWidget.add( hp );
}
- for ( AttributeCol atc : dt.attributeCols ) {
+ for ( AttributeCol atc : guidedDecisionTable.getAttributeCols() ) {
final AttributeCol at = atc;
HorizontalPanel hp = new HorizontalPanel();
@@ -519,30 +481,30 @@
hp.add( removeAttr( at ) );
final TextBox defaultValue = new TextBox();
- defaultValue.setText( at.defaultValue );
+ defaultValue.setText( at.getDefaultValue() );
defaultValue.addChangeHandler( new ChangeHandler() {
public void onChange(ChangeEvent event) {
- at.defaultValue = defaultValue.getText();
+ at.setDefaultValue( defaultValue.getText() );
}
} );
if ( at.attr.equals( RuleAttributeWidget.SALIENCE_ATTR ) ) {
hp.add( new HTML( " " ) );
final CheckBox useRowNumber = new CheckBox();
- useRowNumber.setEnabled( at.useRowNumber );
+ useRowNumber.setEnabled( at.isUseRowNumber() );
useRowNumber.addClickHandler( new ClickHandler() {
public void onClick(ClickEvent sender) {
- at.useRowNumber = useRowNumber.isEnabled();
+ at.setUseRowNumber( useRowNumber.isEnabled() );
}
} );
hp.add( useRowNumber );
hp.add( new SmallLabel( constants.UseRowNumber() ) );
hp.add( new SmallLabel( "(" ) );
final CheckBox reverseOrder = new CheckBox();
- reverseOrder.setEnabled( at.reverseOrder );
+ reverseOrder.setEnabled( at.isReverseOrder() );
reverseOrder.addClickHandler( new ClickHandler() {
public void onClick(ClickEvent sender) {
- at.reverseOrder = reverseOrder.isEnabled();
+ at.setReverseOrder( reverseOrder.isEnabled() );
}
} );
hp.add( reverseOrder );
@@ -554,10 +516,10 @@
hp.add( defaultValue );
final CheckBox hide = new CheckBox();
- hide.setEnabled( at.hideColumn );
+ hide.setEnabled( at.isHideColumn() );
hide.addClickHandler( new ClickHandler() {
public void onClick(ClickEvent sender) {
- at.hideColumn = hide.isEnabled();
+ at.setHideColumn( hide.isEnabled() );
}
} );
hp.add( hide );
@@ -588,8 +550,8 @@
AttributeCol attr = new AttributeCol();
attr.attr = list.getItemText( list.getSelectedIndex() );
- dt.attributeCols.add( attr );
- scrapeData( dt.getMetadataCols().size() + dt.attributeCols.size() + 1 );
+ guidedDecisionTable.getAttributeCols().add( attr );
+ scrapeData( guidedDecisionTable.getMetadataCols().size() + guidedDecisionTable.getAttributeCols().size() + 1 );
refreshGrid();
refreshAttributeWidget();
pop.hide();
@@ -602,8 +564,8 @@
public void onClick(ClickEvent w) {
MetadataCol met = new MetadataCol();
met.attr = box.getText();
- dt.getMetadataCols().add( met );
- scrapeData( dt.getMetadataCols().size() + 1 );
+ guidedDecisionTable.getMetadataCols().add( met );
+ scrapeData( guidedDecisionTable.getMetadataCols().size() + 1 );
refreshGrid();
refreshAttributeWidget();
pop.hide();
@@ -635,7 +597,7 @@
String ms = Format.format( constants.DeleteActionColumnWarning(),
at.attr );
if ( com.google.gwt.user.client.Window.confirm( ms ) ) {
- dt.attributeCols.remove( at );
+ guidedDecisionTable.getAttributeCols().remove( at );
removeField( at.attr );
scrapeData( -1 );
refreshGrid();
@@ -655,7 +617,7 @@
String ms = Format.format( constants.DeleteActionColumnWarning(),
md.attr );
if ( com.google.gwt.user.client.Window.confirm( ms ) ) {
- dt.getMetadataCols().remove( md );
+ guidedDecisionTable.getMetadataCols().remove( md );
removeField( md.attr );
scrapeData( -1 );
refreshGrid();
@@ -674,18 +636,18 @@
*/
private void scrapeData(int insertCol) {
Record[] recs = grid.getStore().getRecords();
- dt.data = new String[recs.length][];
+ guidedDecisionTable.setData( new String[recs.length][] );
for ( int i = 0; i < recs.length; i++ ) {
Record r = recs[i];
if ( insertCol == -1 ) {
String[] row = new String[fds.length];
- dt.data[i] = row;
+ guidedDecisionTable.getData()[i] = row;
for ( int j = 0; j < fds.length; j++ ) {
row[j] = r.getAsString( fds[j].getName() );
}
} else {
String[] row = new String[fds.length + 1];
- dt.data[i] = row;
+ guidedDecisionTable.getData()[i] = row;
for ( int j = 0; j < fds.length; j++ ) {
if ( j < insertCol ) {
row[j] = r.getAsString( fds[j].getName() );
@@ -713,10 +675,17 @@
}
this.fds = fds_;
+ refreshGroupingsPanel();
}
+ private void refreshGroupingsPanel() {
+ if ( groupingsPanel != null ) {
+ groupingsPanel.refresh();
+ }
+ }
+
private void refreshGrid() {
- configureColumnsNote.setVisible( dt.actionCols.size() == 0 && dt.conditionCols.size() == 0 && dt.actionCols.size() == 0 );
+ configureColumnsNote.setVisible( guidedDecisionTable.getActionCols().size() == 0 && guidedDecisionTable.getConditionCols().size() == 0 && guidedDecisionTable.getActionCols().size() == 0 );
if ( layout.getWidgetIndex( grid ) >= 0 ) {
layout.remove( grid );
@@ -727,7 +696,7 @@
private GridPanel doGrid() {
- fds = new FieldDef[dt.getMetadataCols().size() + dt.attributeCols.size() + dt.actionCols.size() + dt.conditionCols.size() + 2]; //its +2 as we have counter and description data
+ fds = new FieldDef[guidedDecisionTable.getMetadataCols().size() + guidedDecisionTable.getAttributeCols().size() + guidedDecisionTable.getActionCols().size() + guidedDecisionTable.getConditionCols().size() + 2]; //its +2 as we have counter and description data
colMap = new HashMap<String, DTColumnConfig>();
@@ -761,26 +730,26 @@
setDataIndex( "desc" ); //NON-NLS
setSortable( true );
setHeader( constants.Description() );
- if ( dt.descriptionWidth != -1 ) {
- setWidth( dt.descriptionWidth );
+ if ( guidedDecisionTable.getDescriptionWidth() != -1 ) {
+ setWidth( guidedDecisionTable.getDescriptionWidth() );
}
}
};
colCount++;
//now to metadata
- for ( int i = 0; i < dt.getMetadataCols().size(); i++ ) {
- final MetadataCol attr = dt.getMetadataCols().get( i );
+ for ( int i = 0; i < guidedDecisionTable.getMetadataCols().size(); i++ ) {
+ final MetadataCol attr = guidedDecisionTable.getMetadataCols().get( i );
fds[colCount] = new StringFieldDef( attr.attr );
cols[colCount] = new ColumnConfig() {
{
setHeader( attr.attr );
setDataIndex( attr.attr );
setSortable( true );
- if ( attr.width != -1 ) {
- setWidth( attr.width );
+ if ( attr.getWidth() != -1 ) {
+ setWidth( attr.getWidth() );
}
- if ( attr.hideColumn ) {
+ if ( attr.isHideColumn() ) {
setHidden( true );
}
@@ -792,19 +761,19 @@
}
//now to attributes
- for ( int i = 0; i < dt.attributeCols.size(); i++ ) {
- final AttributeCol attr = dt.attributeCols.get( i );
+ for ( int i = 0; i < guidedDecisionTable.getAttributeCols().size(); i++ ) {
+ final AttributeCol attr = guidedDecisionTable.getAttributeCols().get( i );
fds[colCount] = new StringFieldDef( attr.attr );
cols[colCount] = new ColumnConfig() {
{
setHeader( attr.attr );
setDataIndex( attr.attr );
setSortable( true );
- if ( attr.width != -1 ) {
- setWidth( attr.width );
+ if ( attr.getWidth() != -1 ) {
+ setWidth( attr.getWidth() );
}
- if ( attr.hideColumn ) {
+ if ( attr.isHideColumn() ) {
setHidden( true );
}
@@ -816,57 +785,57 @@
}
//do all the condition cols
- for ( int i = 0; i < dt.conditionCols.size(); i++ ) {
+ for ( int i = 0; i < guidedDecisionTable.getConditionCols().size(); i++ ) {
//here we could also deal with numeric type?
- final ConditionCol c = dt.conditionCols.get( i );
- fds[colCount] = new StringFieldDef( c.header );
+ final ConditionCol c = guidedDecisionTable.getConditionCols().get( i );
+ fds[colCount] = new StringFieldDef( c.getHeader() );
cols[colCount] = new ColumnConfig() {
{
- setHeader( c.header );
- setDataIndex( c.header );
+ setHeader( c.getHeader() );
+ setDataIndex( c.getHeader() );
setSortable( true );
- if ( c.width != -1 ) {
- setWidth( c.width );
+ if ( c.getWidth() != -1 ) {
+ setWidth( c.getWidth() );
}
- if ( c.hideColumn ) {
+ if ( c.isHideColumn() ) {
setHidden( true );
}
}
};
- colMap.put( c.header,
+ colMap.put( c.getHeader(),
c );
colCount++;
}
- for ( int i = 0; i < dt.actionCols.size(); i++ ) {
+ for ( int i = 0; i < guidedDecisionTable.getActionCols().size(); i++ ) {
//here we could also deal with numeric type?
- final ActionCol c = dt.actionCols.get( i );
- fds[colCount] = new StringFieldDef( c.header );
+ final ActionCol c = guidedDecisionTable.getActionCols().get( i );
+ fds[colCount] = new StringFieldDef( c.getHeader() );
cols[colCount] = new ColumnConfig() {
{
- setHeader( c.header );
- setDataIndex( c.header );
+ setHeader( c.getHeader() );
+ setDataIndex( c.getHeader() );
//and here we do the appropriate editor
setSortable( true );
- if ( c.width != -1 ) {
- setWidth( c.width );
+ if ( c.getWidth() != -1 ) {
+ setWidth( c.getWidth() );
}
- if ( c.hideColumn ) {
+ if ( c.isHideColumn() ) {
setHidden( true );
}
}
};
- colMap.put( c.header,
+ colMap.put( c.getHeader(),
c );
colCount++;
}
recordDef = new RecordDef( fds );
ArrayReader reader = new ArrayReader( recordDef );
- MemoryProxy proxy = new MemoryProxy( dt.data );
+ MemoryProxy proxy = new MemoryProxy( guidedDecisionTable.getData() );
ColumnModel cm = new ColumnModel( cols );
store = new GroupingStore();
@@ -874,8 +843,8 @@
store.setDataProxy( proxy );
store.setSortInfo( new SortState( "num",
SortDir.ASC ) ); //NON-NLS
- if ( this.dt.groupField != null ) {
- store.setGroupField( dt.groupField );
+ if ( this.guidedDecisionTable.getGroupField() != null ) {
+ store.setGroupField( guidedDecisionTable.getGroupField() );
}
cm.addListener( new ColumnModelListenerAdapter() {
public void onHiddenChange(ColumnModel cm,
@@ -884,7 +853,7 @@
final String dta = cm.getDataIndex( colIndex );
if ( colMap.containsKey( dta ) ) {
DTColumnConfig col = colMap.get( dta );
- col.hideColumn = hidden;
+ col.setHideColumn( hidden );
}
}
} );
@@ -900,14 +869,14 @@
int oldIndex,
int newIndex) {
- if ( DecisionTableHandler.validateMove( dt,
+ if ( DecisionTableHandler.validateMove( guidedDecisionTable,
oldIndex,
newIndex ) ) {
// Save any changes to the dt.data.
scrapeData( -1 );
- DecisionTableHandler.moveColumn( dt,
+ DecisionTableHandler.moveColumn( guidedDecisionTable,
oldIndex,
newIndex );
@@ -956,8 +925,8 @@
final Record r = store.getAt( rowIndex );
String val = r.getAsString( dataIdx );
DTColumnConfig colConf = colMap.get( dataIdx );
- String[] vals = dt.getValueList( colConf,
- getSCE() );
+ String[] vals = guidedDecisionTable.getValueList( colConf,
+ getSCE() );
if ( vals.length == 0 ) {
showTextEditor( e,
dataIdx,
@@ -982,11 +951,11 @@
int newSize) {
final String dta = grid.getColumnModel().getDataIndex( colIndex );
if ( dta.equals( "desc" ) ) { //NON-NLS
- dt.descriptionWidth = newSize;
+ guidedDecisionTable.setDescriptionWidth( newSize );
} else {
if ( colMap.containsKey( dta ) ) {
DTColumnConfig col = colMap.get( dta );
- col.width = newSize;
+ col.setWidth( newSize );
}
}
}
@@ -1156,14 +1125,14 @@
}
private void renumberSalience(Record[] rs) {
- List<AttributeCol> attcols = dt.attributeCols;
+ List<AttributeCol> attcols = guidedDecisionTable.getAttributeCols();
for ( AttributeCol ac : attcols ) {
- if ( ac.useRowNumber ) {
+ if ( ac.isUseRowNumber() ) {
for ( int i = 0; i < rs.length; i++ ) {
Record nextrecord = rs[i];
List<String> allFields = Arrays.asList( nextrecord.getFields() );
if ( allFields.contains( "salience" ) ) {
- if ( ac.reverseOrder ) {
+ if ( ac.isReverseOrder() ) {
rs[i].set( "salience",
"" + (rs.length - i) ); //NON-NLS
} else {
@@ -1192,8 +1161,8 @@
w.setBodyBorder( false );
w.setTitle( dta );
- String typeDescription = dt.getType( colConf,
- getSCE() );
+ String typeDescription = guidedDecisionTable.getType( colConf,
+ getSCE() );
Panel p = new Panel();
if ( typeDescription != null && typeDescription.equals( SuggestionCompletionEngine.TYPE_DATE ) ) {
@@ -1241,8 +1210,8 @@
}
} );
- if ( dt.isNumeric( colConf,
- getSCE() ) ) {
+ if ( guidedDecisionTable.isNumeric( colConf,
+ getSCE() ) ) {
box.addKeyPressHandler( new NumbericFilterKeyPressHandler( box ) );
}
Modified: labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/messages/Constants.java
===================================================================
--- labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/messages/Constants.java 2010-10-20 11:57:47 UTC (rev 35593)
+++ labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/messages/Constants.java 2010-10-20 11:58:32 UTC (rev 35594)
@@ -613,11 +613,11 @@
String AddAnOptionToTheRule();
String AddMetadataToTheRule();
-
+
String UseRowNumber();
-
+
String ReverseOrder();
-
+
String Metadata1();
String Attribute();
@@ -1507,15 +1507,15 @@
String ModifyAnExistingFactScenario();
String RetractAnExistingFactScenario();
-
+
String CallAMethodOnAFactScenario();
-
+
String CALL();
String RemoveCallMethod();
-
+
String AreYouSureToRemoveCallMethod();
-
+
String AddANewExpectation();
String NewExpectation();
@@ -1761,11 +1761,11 @@
String HideThisColumn();
String PleaseSelectOrEnterField();
-
+
String NotifyNoSelectedOrEnteredField();
String PleaseSelectAnOperator();
-
+
String NotifyNoSelectedOperator();
String January();
@@ -2099,50 +2099,52 @@
String ActivateRuleFlowGroup();
String CantRemoveThisBlockAsOneOfTheNamesIsBeingUsed();
-
+
String FillInColumnWithValue();
-
+
String LoadTemplateData();
-
+
String RepositoryConfiguration();
-
+
String RepositoryConfig();
-
+
String ManageRepositoryConfig();
-
+
String ManageRepositoryConfigDesc();
-
+
String SelectRdbmsType();
-
+
String UseJndi();
-
+
String PleaseSelectRdbmsType();
-
+
String PleaseEnterDriver();
-
+
String PleaseEnterUrl();
-
+
String PleaseEnterUserName();
-
+
String PleaseEnterPassword();
-
+
String PleaseEnterJndiName();
-
+
String GenerateRepositoryConfiguration();
-
+
String RepositoryXml();
-
+
String UnableToProcessRepositoryConfiguration();
-
+
String SaveRepo();
-
+
String SaveTheRepositoryConfig();
-
+
String SaveRepoInfo();
String Inbox();
-
+
String GlobalArea();
-
+
String InvalidDateFormatMessage();
+
+ String NewColumn();
}
Modified: labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/messages/Constants.properties
===================================================================
--- labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/messages/Constants.properties 2010-10-20 11:57:47 UTC (rev 35593)
+++ labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/messages/Constants.properties 2010-10-20 11:58:32 UTC (rev 35594)
@@ -1058,3 +1058,4 @@
Inbox=Inbox
GlobalArea=Global Area
InvalidDateFormatMessage=Date format is invalid. Please follow the correct date format: dd-MMM-yyyy
+NewColumn=New column
\ No newline at end of file
Modified: labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/modeldriven/SetFactTypeFilter.java
===================================================================
--- labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/modeldriven/SetFactTypeFilter.java 2010-10-20 11:57:47 UTC (rev 35593)
+++ labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/modeldriven/SetFactTypeFilter.java 2010-10-20 11:58:32 UTC (rev 35594)
@@ -1,4 +1,4 @@
-/**
+/*
* Copyright 2010 JBoss Inc
*
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -14,9 +14,6 @@
* limitations under the License.
*/
-/**
- *
- */
package org.drools.guvnor.client.modeldriven;
import java.util.Collections;
@@ -26,7 +23,7 @@
public class SetFactTypeFilter implements FactTypeFilter {
- private static final long serialVersionUID = 501l;
+ private static final long serialVersionUID = 510l;
private final Set<String> validFacts;
public SetFactTypeFilter() {
Modified: labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/server/contenthandler/GuidedDTContentHandler.java
===================================================================
--- labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/server/contenthandler/GuidedDTContentHandler.java 2010-10-20 11:57:47 UTC (rev 35593)
+++ labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/server/contenthandler/GuidedDTContentHandler.java 2010-10-20 11:58:32 UTC (rev 35594)
@@ -69,13 +69,13 @@
public void storeAssetContent(RuleAsset asset,
AssetItem repoAsset) throws SerializationException {
GuidedDecisionTable data = (GuidedDecisionTable) asset.content;
- if ( data.tableName == null ) {
- data.tableName = repoAsset.getName();
+ if ( data.getTableName() == null ) {
+ data.setTableName( repoAsset.getName() );
}
// Change the row numbers so they are in the same order as the rows.
- for ( int i = 0; i < data.data.length; i++ ) {
- data.data[i][0] = String.valueOf( i + 1 );
+ for ( int i = 0; i < data.getData().length; i++ ) {
+ data.getData()[i][0] = String.valueOf( i + 1 );
}
repoAsset.updateContent( GuidedDTXMLPersistence.getInstance().marshal( data ) );
@@ -99,9 +99,9 @@
public String getRawDRL(AssetItem asset) {
GuidedDecisionTable model = GuidedDTXMLPersistence.getInstance().unmarshal( asset.getContent() );
- model.tableName = asset.getName();
- model.parentName = this.parentNameFromCategory( asset,
- model.parentName );
+ model.setTableName( asset.getName() );
+ model.setParentName( this.parentNameFromCategory( asset,
+ model.getParentName() ) );
return GuidedDTDRLPersistence.getInstance().marshal( model );
}
Modified: labs/jbossrules/trunk/drools-guvnor/src/test/java/org/drools/guvnor/client/decisiontable/DecisionTableHandlerTest.java
===================================================================
--- labs/jbossrules/trunk/drools-guvnor/src/test/java/org/drools/guvnor/client/decisiontable/DecisionTableHandlerTest.java 2010-10-20 11:57:47 UTC (rev 35593)
+++ labs/jbossrules/trunk/drools-guvnor/src/test/java/org/drools/guvnor/client/decisiontable/DecisionTableHandlerTest.java 2010-10-20 11:58:32 UTC (rev 35594)
@@ -32,25 +32,25 @@
GuidedDecisionTable dt = new GuidedDecisionTable();
- dt.attributeCols.add( TestData.newAttributeCol( "date-effective" ) );
- dt.attributeCols.add( TestData.newAttributeCol( "date-expires" ) );
- dt.conditionCols.add( TestData.newConditionCol( "amount max" ) );
- dt.conditionCols.add( TestData.newConditionCol( "amount min" ) );
- dt.conditionCols.add( TestData.newConditionCol( "period" ) );
- dt.actionCols.add( TestData.newActionCol( "LMI1" ) );
- dt.actionCols.add( TestData.newActionCol( "LMI2" ) );
- dt.actionCols.add( TestData.newActionCol( "LMI3" ) );
- dt.data = TestData.newData( dt.attributeCols.size(),
- dt.conditionCols.size(),
- dt.actionCols.size() );
+ dt.getAttributeCols().add( TestData.newAttributeCol( "date-effective" ) );
+ dt.getAttributeCols().add( TestData.newAttributeCol( "date-expires" ) );
+ dt.getConditionCols().add( TestData.newConditionCol( "amount max" ) );
+ dt.getConditionCols().add( TestData.newConditionCol( "amount min" ) );
+ dt.getConditionCols().add( TestData.newConditionCol( "period" ) );
+ dt.getActionCols().add( TestData.newActionCol( "LMI1" ) );
+ dt.getActionCols().add( TestData.newActionCol( "LMI2" ) );
+ dt.getActionCols().add( TestData.newActionCol( "LMI3" ) );
+ dt.setData( TestData.newData( dt.getAttributeCols().size(),
+ dt.getConditionCols().size(),
+ dt.getActionCols().size() ) );
- Order.assertAttributeOrder( dt.attributeCols,
+ Order.assertAttributeOrder( dt.getAttributeCols(),
new String[]{"date-effective", "date-expires"} );
- Order.assertConditionOrder( dt.conditionCols,
+ Order.assertConditionOrder( dt.getConditionCols(),
new String[]{"amount max", "amount min", "period"} );
- Order.assertActionOrder( dt.actionCols,
+ Order.assertActionOrder( dt.getActionCols(),
new String[]{"LMI1", "LMI2", "LMI3"} );
- Order.assertDataOrder( dt.data,
+ Order.assertDataOrder( dt.getData(),
new String[][]{
new String[]{"0.0", "0.1", "0.2", "0.3", "0.4", "0.5", "0.6", "0.7", "0.8", "0.9" },
new String[]{"1.0", "1.1", "1.2", "1.3", "1.4", "1.5", "1.6", "1.7", "1.8", "1.9" },
@@ -64,14 +64,14 @@
oldIndex,
newIndex );
- Order.assertAttributeOrder( dt.attributeCols,
+ Order.assertAttributeOrder( dt.getAttributeCols(),
new String[]{"date-expires", "date-effective"} );
- Order.assertConditionOrder( dt.conditionCols,
+ Order.assertConditionOrder( dt.getConditionCols(),
new String[]{"amount max", "amount min", "period"} );
- Order.assertActionOrder( dt.actionCols,
+ Order.assertActionOrder( dt.getActionCols(),
new String[]{"LMI1", "LMI2", "LMI3"} );
- Order.assertDataOrder( dt.data,
+ Order.assertDataOrder( dt.getData(),
new String[][]{
new String[]{"0.0", "0.1", "0.3", "0.2", "0.4", "0.5", "0.6", "0.7", "0.8", "0.9" },
new String[]{"1.0", "1.1", "1.3", "1.2", "1.4", "1.5", "1.6", "1.7", "1.8", "1.9" },
@@ -85,11 +85,11 @@
oldIndex,
newIndex );
- Order.assertAttributeOrder( dt.attributeCols,
+ Order.assertAttributeOrder( dt.getAttributeCols(),
new String[]{"date-effective", "date-expires"} );
- Order.assertConditionOrder( dt.conditionCols,
+ Order.assertConditionOrder( dt.getConditionCols(),
new String[]{"amount max", "amount min", "period"} );
- Order.assertDataOrder( dt.data,
+ Order.assertDataOrder( dt.getData(),
new String[][]{
new String[]{"0.0", "0.1", "0.2", "0.3", "0.4", "0.5", "0.6", "0.7", "0.8", "0.9" },
new String[]{"1.0", "1.1", "1.2", "1.3", "1.4", "1.5", "1.6", "1.7", "1.8", "1.9" },
@@ -101,25 +101,25 @@
GuidedDecisionTable dt = new GuidedDecisionTable();
- dt.attributeCols.add( TestData.newAttributeCol( "date-effective" ) );
- dt.attributeCols.add( TestData.newAttributeCol( "date-expires" ) );
- dt.conditionCols.add( TestData.newConditionCol( "amount max" ) );
- dt.conditionCols.add( TestData.newConditionCol( "amount min" ) );
- dt.conditionCols.add( TestData.newConditionCol( "period" ) );
- dt.actionCols.add( TestData.newActionCol( "LMI1" ) );
- dt.actionCols.add( TestData.newActionCol( "LMI2" ) );
- dt.actionCols.add( TestData.newActionCol( "LMI3" ) );
- dt.data = TestData.newData( dt.attributeCols.size(),
- dt.conditionCols.size(),
- dt.actionCols.size() );
+ dt.getAttributeCols().add( TestData.newAttributeCol( "date-effective" ) );
+ dt.getAttributeCols().add( TestData.newAttributeCol( "date-expires" ) );
+ dt.getConditionCols().add( TestData.newConditionCol( "amount max" ) );
+ dt.getConditionCols().add( TestData.newConditionCol( "amount min" ) );
+ dt.getConditionCols().add( TestData.newConditionCol( "period" ) );
+ dt.getActionCols().add( TestData.newActionCol( "LMI1" ) );
+ dt.getActionCols().add( TestData.newActionCol( "LMI2" ) );
+ dt.getActionCols().add( TestData.newActionCol( "LMI3" ) );
+ dt.setData( TestData.newData( dt.getAttributeCols().size(),
+ dt.getConditionCols().size(),
+ dt.getActionCols().size() ) );
- Order.assertAttributeOrder( dt.attributeCols,
+ Order.assertAttributeOrder( dt.getAttributeCols(),
new String[]{"date-effective", "date-expires"} );
- Order.assertConditionOrder( dt.conditionCols,
+ Order.assertConditionOrder( dt.getConditionCols(),
new String[]{"amount max", "amount min", "period"} );
- Order.assertActionOrder( dt.actionCols,
+ Order.assertActionOrder( dt.getActionCols(),
new String[]{"LMI1", "LMI2", "LMI3"} );
- Order.assertDataOrder( dt.data,
+ Order.assertDataOrder( dt.getData(),
new String[][]{
new String[]{"0.0", "0.1", "0.2", "0.3", "0.4", "0.5", "0.6", "0.7", "0.8", "0.9" },
new String[]{"1.0", "1.1", "1.2", "1.3", "1.4", "1.5", "1.6", "1.7", "1.8", "1.9" },
@@ -133,13 +133,13 @@
oldIndex,
newIndex );
- Order.assertAttributeOrder( dt.attributeCols,
+ Order.assertAttributeOrder( dt.getAttributeCols(),
new String[]{"date-effective", "date-expires"} );
- Order.assertConditionOrder( dt.conditionCols,
+ Order.assertConditionOrder( dt.getConditionCols(),
new String[]{"amount min", "period", "amount max"} );
- Order.assertActionOrder( dt.actionCols,
+ Order.assertActionOrder( dt.getActionCols(),
new String[]{"LMI1", "LMI2", "LMI3"} );
- Order.assertDataOrder( dt.data,
+ Order.assertDataOrder( dt.getData(),
new String[][]{
new String[]{"0.0", "0.1", "0.2", "0.3", "0.5", "0.6", "0.4", "0.7", "0.8", "0.9" },
new String[]{"1.0", "1.1", "1.2", "1.3", "1.5", "1.6", "1.4", "1.7", "1.8", "1.9" },
@@ -153,14 +153,14 @@
oldIndex,
newIndex );
- Order.assertAttributeOrder( dt.attributeCols,
+ Order.assertAttributeOrder( dt.getAttributeCols(),
new String[]{"date-effective", "date-expires"} );
- Order.assertConditionOrder( dt.conditionCols,
+ Order.assertConditionOrder( dt.getConditionCols(),
new String[]{"amount min", "amount max", "period"} );
- Order.assertActionOrder( dt.actionCols,
+ Order.assertActionOrder( dt.getActionCols(),
new String[]{"LMI1", "LMI2", "LMI3"} );
- Order.assertDataOrder( dt.data,
+ Order.assertDataOrder( dt.getData(),
new String[][]{
new String[]{"0.0", "0.1", "0.2", "0.3", "0.5", "0.4", "0.6", "0.7", "0.8", "0.9" },
new String[]{"1.0", "1.1", "1.2", "1.3", "1.5", "1.4", "1.6", "1.7", "1.8", "1.9" },
@@ -172,25 +172,25 @@
GuidedDecisionTable dt = new GuidedDecisionTable();
- dt.attributeCols.add( TestData.newAttributeCol( "date-effective" ) );
- dt.attributeCols.add( TestData.newAttributeCol( "date-expires" ) );
- dt.conditionCols.add( TestData.newConditionCol( "amount max" ) );
- dt.conditionCols.add( TestData.newConditionCol( "amount min" ) );
- dt.conditionCols.add( TestData.newConditionCol( "period" ) );
- dt.actionCols.add( TestData.newActionCol( "LMI1" ) );
- dt.actionCols.add( TestData.newActionCol( "LMI2" ) );
- dt.actionCols.add( TestData.newActionCol( "LMI3" ) );
- dt.data = TestData.newData( dt.attributeCols.size(),
- dt.conditionCols.size(),
- dt.actionCols.size() );
+ dt.getAttributeCols().add( TestData.newAttributeCol( "date-effective" ) );
+ dt.getAttributeCols().add( TestData.newAttributeCol( "date-expires" ) );
+ dt.getConditionCols().add( TestData.newConditionCol( "amount max" ) );
+ dt.getConditionCols().add( TestData.newConditionCol( "amount min" ) );
+ dt.getConditionCols().add( TestData.newConditionCol( "period" ) );
+ dt.getActionCols().add( TestData.newActionCol( "LMI1" ) );
+ dt.getActionCols().add( TestData.newActionCol( "LMI2" ) );
+ dt.getActionCols().add( TestData.newActionCol( "LMI3" ) );
+ dt.setData( TestData.newData( dt.getAttributeCols().size(),
+ dt.getConditionCols().size(),
+ dt.getActionCols().size() ) );
- Order.assertAttributeOrder( dt.attributeCols,
+ Order.assertAttributeOrder( dt.getAttributeCols(),
new String[]{"date-effective", "date-expires"} );
- Order.assertConditionOrder( dt.conditionCols,
+ Order.assertConditionOrder( dt.getConditionCols(),
new String[]{"amount max", "amount min", "period"} );
- Order.assertActionOrder( dt.actionCols,
+ Order.assertActionOrder( dt.getActionCols(),
new String[]{"LMI1", "LMI2", "LMI3"} );
- Order.assertDataOrder( dt.data,
+ Order.assertDataOrder( dt.getData(),
new String[][]{
new String[]{"0.0", "0.1", "0.2", "0.3", "0.4", "0.5", "0.6", "0.7", "0.8", "0.9" },
new String[]{"1.0", "1.1", "1.2", "1.3", "1.4", "1.5", "1.6", "1.7", "1.8", "1.9" },
@@ -202,13 +202,13 @@
oldIndex,
newIndex );
- Order.assertAttributeOrder( dt.attributeCols,
+ Order.assertAttributeOrder( dt.getAttributeCols(),
new String[]{"date-effective", "date-expires"} );
- Order.assertConditionOrder( dt.conditionCols,
+ Order.assertConditionOrder( dt.getConditionCols(),
new String[]{"amount max", "amount min", "period"} );
- Order.assertActionOrder( dt.actionCols,
+ Order.assertActionOrder( dt.getActionCols(),
new String[]{"LMI1", "LMI3", "LMI2"} );
- Order.assertDataOrder( dt.data,
+ Order.assertDataOrder( dt.getData(),
new String[][]{
new String[]{"0.0", "0.1", "0.2", "0.3", "0.4", "0.5", "0.6", "0.7", "0.9", "0.8" },
new String[]{"1.0", "1.1", "1.2", "1.3", "1.4", "1.5", "1.6", "1.7", "1.9", "1.8" },
@@ -220,13 +220,13 @@
oldIndex,
newIndex );
- Order.assertAttributeOrder( dt.attributeCols,
+ Order.assertAttributeOrder( dt.getAttributeCols(),
new String[]{"date-effective", "date-expires"} );
- Order.assertConditionOrder( dt.conditionCols,
+ Order.assertConditionOrder( dt.getConditionCols(),
new String[]{"amount max", "amount min", "period"} );
- Order.assertActionOrder( dt.actionCols,
+ Order.assertActionOrder( dt.getActionCols(),
new String[]{"LMI2", "LMI1", "LMI3"} );
- Order.assertDataOrder( dt.data,
+ Order.assertDataOrder( dt.getData(),
new String[][]{
new String[]{"0.0", "0.1", "0.2", "0.3", "0.4", "0.5", "0.6", "0.8", "0.7", "0.9" },
new String[]{"1.0", "1.1", "1.2", "1.3", "1.4", "1.5", "1.6", "1.8", "1.7", "1.9" },
@@ -261,7 +261,7 @@
static ConditionCol newConditionCol(String header) {
ConditionCol c = new ConditionCol();
- c.header = header;
+ c.setHeader( header );
return c;
}
@@ -269,7 +269,7 @@
static ActionCol newActionCol(String header) {
ActionCol a = new ActionCol();
- a.header = header;
+ a.setHeader( header );
return a;
}
@@ -285,7 +285,7 @@
cols.size() );
for ( int i = 0; i < list.length; i++ ) {
- Assert.assertEquals( cols.get( i ).header,
+ Assert.assertEquals( cols.get( i ).getHeader(),
list[i] );
}
}
@@ -334,7 +334,7 @@
cols.size() );
for ( int i = 0; i < list.length; i++ ) {
- Assert.assertEquals( cols.get( i ).header,
+ Assert.assertEquals( cols.get( i ).getHeader(),
list[i] );
}
}
Modified: labs/jbossrules/trunk/drools-guvnor/src/test/java/org/drools/guvnor/server/ServiceImplementationTest.java
===================================================================
--- labs/jbossrules/trunk/drools-guvnor/src/test/java/org/drools/guvnor/server/ServiceImplementationTest.java 2010-10-20 11:57:47 UTC (rev 35593)
+++ labs/jbossrules/trunk/drools-guvnor/src/test/java/org/drools/guvnor/server/ServiceImplementationTest.java 2010-10-20 11:58:32 UTC (rev 35594)
@@ -3536,20 +3536,20 @@
GuidedDecisionTable dt = new GuidedDecisionTable();
ConditionCol col = new ConditionCol();
- col.boundName = "p";
- col.constraintValueType = BaseSingleFieldConstraint.TYPE_LITERAL;
- col.factField = "hair";
- col.factType = "Person";
- col.operator = "==";
- dt.conditionCols.add( col );
+ col.setBoundName( "p" );
+ col.setConstraintValueType( BaseSingleFieldConstraint.TYPE_LITERAL );
+ col.setFactField( "hair" );
+ col.setFactType( "Person" );
+ col.setOperator( "==" );
+ dt.getConditionCols().add( col );
ActionSetFieldCol ac = new ActionSetFieldCol();
- ac.boundName = "p";
- ac.factField = "likes";
- ac.type = SuggestionCompletionEngine.TYPE_STRING;
- dt.actionCols.add( ac );
+ ac.setBoundName( "p" );
+ ac.setFactField( "likes" );
+ ac.setType( SuggestionCompletionEngine.TYPE_STRING );
+ dt.getActionCols().add( ac );
- dt.data = new String[][]{new String[]{"1", "descrip", "pink", "cheese"}};
+ dt.setData( new String[][]{new String[]{"1", "descrip", "pink", "cheese"}} );
String uid = impl.createNewRule( "decTable",
"",
More information about the jboss-svn-commits
mailing list