[jboss-svn-commits] JBL Code SVN: r35376 - in labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client: categorynav and 6 other directories.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Fri Oct 1 03:40:29 EDT 2010
Author: Rikkola
Date: 2010-10-01 03:40:28 -0400 (Fri, 01 Oct 2010)
New Revision: 35376
Added:
labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/common/Popup.java
Modified:
labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/admin/BackupManager.java
labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/admin/StatusEditor.java
labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/categorynav/CategoryEditor.java
labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/common/ErrorPopup.java
labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/common/FormStylePopup.java
labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/explorer/AdministrationPanel.java
labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/explorer/AdministrationTree.java
labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/explorer/NewRepoDialog.java
labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/modeldriven/ui/DefaultLiteralEditor.java
labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/modeldriven/ui/ExpressionBuilder.java
labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/modeldriven/ui/RuleModeller.java
labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/modeldriven/ui/RuleTemplateEditor.java
labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/modeldriven/ui/factPattern/PopupCreator.java
labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/packages/AssetAttachmentFileWidget.java
labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/packages/PackageHeaderWidget.java
labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/packages/SuggestionCompletionCache.java
labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/ruleeditor/RuleFlowWrapper.java
labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/ruleeditor/RuleValidatorWrapper.java
labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/ruleeditor/RuleViewer.java
Log:
GUVNOR-599 : Replace gwtext codes used by Popup related widgets
- Error popups
Modified: labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/admin/BackupManager.java
===================================================================
--- labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/admin/BackupManager.java 2010-10-01 06:58:15 UTC (rev 35375)
+++ labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/admin/BackupManager.java 2010-10-01 07:40:28 UTC (rev 35376)
@@ -1,4 +1,4 @@
-/**
+/*
* Copyright 2010 JBoss Inc
*
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -16,22 +16,6 @@
package org.drools.guvnor.client.admin;
-/*
- * Copyright 2005 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.
- */
-
import org.drools.guvnor.client.common.ErrorPopup;
import org.drools.guvnor.client.common.HTMLFileManagerFields;
import org.drools.guvnor.client.common.ImageButton;
Modified: labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/admin/StatusEditor.java
===================================================================
--- labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/admin/StatusEditor.java 2010-10-01 06:58:15 UTC (rev 35375)
+++ labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/admin/StatusEditor.java 2010-10-01 07:40:28 UTC (rev 35376)
@@ -1,21 +1,3 @@
-/**
- * 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.admin;
-
/*
* Copyright 2005 JBoss Inc
*
@@ -32,6 +14,8 @@
* limitations under the License.
*/
+package org.drools.guvnor.client.admin;
+
import org.drools.guvnor.client.common.ErrorPopup;
import org.drools.guvnor.client.common.FormStylePopup;
import org.drools.guvnor.client.common.GenericCallback;
Modified: labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/categorynav/CategoryEditor.java
===================================================================
--- labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/categorynav/CategoryEditor.java 2010-10-01 06:58:15 UTC (rev 35375)
+++ labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/categorynav/CategoryEditor.java 2010-10-01 07:40:28 UTC (rev 35376)
@@ -1,20 +1,3 @@
-/**
- * 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.categorynav;
/*
* Copyright 2005 JBoss Inc
*
@@ -31,6 +14,7 @@
* limitations under the License.
*/
+package org.drools.guvnor.client.categorynav;
import org.drools.guvnor.client.common.ErrorPopup;
Modified: labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/common/ErrorPopup.java
===================================================================
--- labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/common/ErrorPopup.java 2010-10-01 06:58:15 UTC (rev 35375)
+++ labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/common/ErrorPopup.java 2010-10-01 07:40:28 UTC (rev 35376)
@@ -20,23 +20,24 @@
import org.drools.guvnor.client.rpc.DetailedSerializationException;
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.event.logical.shared.CloseEvent;
+import com.google.gwt.event.logical.shared.CloseHandler;
+import com.google.gwt.user.client.ui.Button;
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.Label;
+import com.google.gwt.user.client.ui.PopupPanel;
import com.google.gwt.user.client.ui.SimplePanel;
import com.google.gwt.user.client.ui.VerticalPanel;
-import com.gwtext.client.core.EventObject;
-import com.gwtext.client.widgets.Button;
-import com.gwtext.client.widgets.Window;
-import com.gwtext.client.widgets.event.ButtonListenerAdapter;
-import com.gwtext.client.widgets.event.WindowListenerAdapter;
-import com.gwtext.client.widgets.layout.VerticalLayout;
+import com.google.gwt.user.client.ui.Widget;
/**
* Generic error dialog popup.
*/
-public class ErrorPopup {
+public class ErrorPopup extends Popup {
public static ErrorPopup instance = null;
private Constants constants = ((Constants) GWT.create( Constants.class ));
@@ -45,36 +46,35 @@
private ErrorPopup(String message,
String longMessage) {
- Window w = new Window();
- w.setTitle( constants.Error() );
- w.setWidth( 400 );
- w.setModal( true );
- w.setShadow( true );
- w.setClosable( true );
- w.setPlain( true );
+ setTitle( constants.Error() );
+ setWidth( 400 + "px" );
+ setModal( true );
- w.setLayout( new VerticalLayout() );
body = new VerticalPanel();
addMessage( message,
longMessage );
body.setWidth( "100%" );
- w.add( body );
- w.show();
+ show();
- w.addListener( new WindowListenerAdapter() {
- @Override
- public void onDeactivate(Window window) {
+ addCloseHandler( new CloseHandler<PopupPanel>() {
+
+ public void onClose(CloseEvent<PopupPanel> event) {
instance = null;
}
} );
+ }
+ @Override
+ public Widget getContent() {
+ return body;
}
- private void addMessage(String message, String longMessage) {
- if (message!=null && message.contains("ItemExistsException")) { //NON-NLS
+ private void addMessage(String message,
+ String longMessage) {
+ if ( message != null && message.contains( "ItemExistsException" ) ) { //NON-NLS
longMessage = message;
message = constants.SorryAnItemOfThatNameAlreadyExistsInTheRepositoryPleaseChooseAnother();
@@ -92,9 +92,9 @@
final SimplePanel detailPanel = new SimplePanel();
if ( longMessage != null && !"".equals( longMessage ) ) {
Button showD = new Button( constants.ShowDetail() );
- showD.addListener( new ButtonListenerAdapter() {
- public void onClick(Button button,
- EventObject e) {
+ showD.addClickHandler( new ClickHandler() {
+
+ public void onClick(ClickEvent event) {
detailPanel.clear();
VerticalPanel vp = new VerticalPanel();
vp.add( new HTML( "<hr/>" ) );
Modified: labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/common/FormStylePopup.java
===================================================================
--- labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/common/FormStylePopup.java 2010-10-01 06:58:15 UTC (rev 35375)
+++ labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/common/FormStylePopup.java 2010-10-01 07:40:28 UTC (rev 35376)
@@ -16,19 +16,6 @@
package org.drools.guvnor.client.common;
-import com.google.gwt.event.dom.client.ClickEvent;
-import com.google.gwt.event.dom.client.ClickHandler;
-import com.google.gwt.event.dom.client.MouseDownEvent;
-import com.google.gwt.event.dom.client.MouseDownHandler;
-import com.google.gwt.event.dom.client.MouseMoveEvent;
-import com.google.gwt.event.dom.client.MouseMoveHandler;
-import com.google.gwt.event.dom.client.MouseUpEvent;
-import com.google.gwt.event.dom.client.MouseUpHandler;
-import com.google.gwt.user.client.Command;
-import com.google.gwt.user.client.DOM;
-import com.google.gwt.user.client.Window;
-import com.google.gwt.user.client.ui.PopupPanel;
-import com.google.gwt.user.client.ui.VerticalPanel;
import com.google.gwt.user.client.ui.Widget;
/**
@@ -37,30 +24,17 @@
*
* @author Michael Neale
*/
-public class FormStylePopup {
+public class FormStylePopup extends Popup {
private FormStyleLayout form;
- private Popup dialog;
- private String title;
- private Integer width;
- private Integer height;
- private boolean modal = true;
- private int popLeft = -1;
- private int popTop;
- private Command afterShowEvent;
-
- private boolean dragged = false;
- private int dragStartX;
- private int dragStartY;
-
public FormStylePopup(String image,
final String title) {
form = new FormStyleLayout( image,
title );
- this.title = title;
+ setTitle( title );
}
@@ -73,9 +47,14 @@
Integer width) {
this( image,
title );
- this.width = width;
+ setWidth( width + "px" );
}
+ @Override
+ public Widget getContent() {
+ return form;
+ }
+
public void clear() {
this.form.clear();
}
@@ -90,139 +69,4 @@
form.addRow( wid );
}
- public void hide() {
- if ( dialog != null ) {
- this.dialog.hide();
- }
- }
-
- public void setPopupPosition(int left,
- int top) {
- this.popLeft = left;
- this.popTop = top;
- }
-
- public void setAfterShow(Command c) {
- this.afterShowEvent = c;
- }
-
- public void show() {
-
- dialog = new Popup();
-
- if ( title != null ) {
- dialog.setTitle( title );
- }
- dialog.setModal( modal );
- if ( width == null ) {
- dialog.setWidth( 430 + "px" );
- } else if ( width != -1 ) {
- dialog.setWidth( width + "px" );
- }
-
- VerticalPanel p = new VerticalPanel();
- p.setHorizontalAlignment( VerticalPanel.ALIGN_RIGHT );
-
- final PopupTitleBar titleBar = new PopupTitleBar( this.title );
-
- titleBar.closeButton.addClickHandler( new ClickHandler() {
- public void onClick(ClickEvent event) {
- dialog.hide();
- }
- } );
- titleBar.addMouseDownHandler( new MouseDownHandler() {
-
- public void onMouseDown(MouseDownEvent event) {
- dragged = true;
- dragStartX = event.getRelativeX( dialog.getElement() );
- dragStartY = event.getRelativeY( dialog.getElement() );
- DOM.setCapture( titleBar.getElement() );
- }
- } );
- titleBar.addMouseMoveHandler( new MouseMoveHandler() {
-
- public void onMouseMove(MouseMoveEvent event) {
- if ( dragged ) {
- dialog.setPopupPosition( event.getClientX() - dragStartX,
- event.getClientY() - dragStartY );
- }
- }
- } );
- titleBar.addMouseUpHandler( new MouseUpHandler() {
-
- public void onMouseUp(MouseUpEvent event) {
- dragged = false;
- DOM.releaseCapture( titleBar.getElement() );
- }
- } );
-
- p.add( titleBar );
-
- p.add( form );
- dialog.add( p );
-
- if ( getHeight() != null ) {
- this.dialog.setHeight( getHeight() + "px" );
- }
-
- if ( popLeft > -1 ) {
- dialog.setPopupPosition( popLeft,
- popTop );
- this.dialog.show();
- } else {
- dialog.setPopupPosition( 100,
- 100 );
- this.dialog.show();
-
- dialog.center();
-
- int left = (Window.getClientWidth() - dialog.getOffsetWidth()) >> 1;
- int top = (Window.getClientHeight() - dialog.getOffsetHeight()) >> 1;
- setPopupPosition( Math.max( Window.getScrollLeft() + left,
- 0 ),
- Math.max( Window.getScrollTop() + top,
- 0 ) );
- }
-
- }
-
- public boolean isVisible() {
- if ( dialog == null ) return false;
- else return dialog.isVisible();
- }
-
- public void setModal(boolean m) {
- this.modal = m;
- }
-
- public void setTitle(String t) {
- this.title = t;
- }
-
- public void setWidth(int i) {
- this.width = new Integer( i );
- }
-
- public Integer getHeight() {
- return height;
- }
-
- public void setHeight(Integer height) {
- this.height = height;
- }
-
- class Popup extends PopupPanel {
-
- @Override
- public void show() {
- super.show();
-
- if ( afterShowEvent != null ) {
- afterShowEvent.execute();
- }
-
- }
-
- }
-
}
\ No newline at end of file
Added: labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/common/Popup.java
===================================================================
--- labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/common/Popup.java (rev 0)
+++ labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/common/Popup.java 2010-10-01 07:40:28 UTC (rev 35376)
@@ -0,0 +1,122 @@
+/*
+ * 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.common;
+
+import com.google.gwt.event.dom.client.ClickEvent;
+import com.google.gwt.event.dom.client.ClickHandler;
+import com.google.gwt.event.dom.client.MouseDownEvent;
+import com.google.gwt.event.dom.client.MouseDownHandler;
+import com.google.gwt.event.dom.client.MouseMoveEvent;
+import com.google.gwt.event.dom.client.MouseMoveHandler;
+import com.google.gwt.event.dom.client.MouseUpEvent;
+import com.google.gwt.event.dom.client.MouseUpHandler;
+import com.google.gwt.user.client.Command;
+import com.google.gwt.user.client.DOM;
+import com.google.gwt.user.client.ui.PopupPanel;
+import com.google.gwt.user.client.ui.VerticalPanel;
+import com.google.gwt.user.client.ui.Widget;
+
+/**
+ *
+ * @author rikkola
+ *
+ */
+public abstract class Popup extends PopupPanel {
+
+ private boolean dragged = false;
+ private int dragStartX;
+ private int dragStartY;
+
+ private Command afterShowEvent;
+ private boolean fixedLocation = false;
+
+ public Popup() {
+ setWidth( 430 + "px" );
+ }
+
+ public void setAfterShow(Command afterShowEvent) {
+ this.afterShowEvent = afterShowEvent;
+ }
+
+ @Override
+ public void show() {
+
+ if ( afterShowEvent != null ) {
+ afterShowEvent.execute();
+ }
+
+ VerticalPanel p = new VerticalPanel();
+ p.setHorizontalAlignment( VerticalPanel.ALIGN_RIGHT );
+
+ final PopupTitleBar titleBar = new PopupTitleBar( getTitle() );
+
+ titleBar.closeButton.addClickHandler( new ClickHandler() {
+ public void onClick(ClickEvent event) {
+ hide();
+ }
+ } );
+ titleBar.addMouseDownHandler( new MouseDownHandler() {
+
+ public void onMouseDown(MouseDownEvent event) {
+ dragged = true;
+ dragStartX = event.getRelativeX( getElement() );
+ dragStartY = event.getRelativeY( getElement() );
+ DOM.setCapture( titleBar.getElement() );
+ }
+ } );
+ titleBar.addMouseMoveHandler( new MouseMoveHandler() {
+
+ public void onMouseMove(MouseMoveEvent event) {
+ if ( dragged ) {
+ setPopupPosition( event.getClientX() - dragStartX,
+ event.getClientY() - dragStartY );
+ }
+ }
+ } );
+ titleBar.addMouseUpHandler( new MouseUpHandler() {
+
+ public void onMouseUp(MouseUpEvent event) {
+ dragged = false;
+ DOM.releaseCapture( titleBar.getElement() );
+ }
+ } );
+
+ p.add( titleBar );
+
+ p.add( getContent() );
+ add( p );
+
+ super.show();
+
+ if ( !fixedLocation ) {
+ center();
+ }
+ }
+
+ @Override
+ public void setPopupPosition(int left,
+ int top) {
+ super.setPopupPosition( left,
+ top );
+
+ if ( left != 0 && top != 0 ) {
+ fixedLocation = true;
+ }
+ }
+
+ abstract public Widget getContent();
+
+}
\ No newline at end of file
Modified: labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/explorer/AdministrationPanel.java
===================================================================
--- labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/explorer/AdministrationPanel.java 2010-10-01 06:58:15 UTC (rev 35375)
+++ labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/explorer/AdministrationPanel.java 2010-10-01 07:40:28 UTC (rev 35376)
@@ -40,84 +40,89 @@
* @author Anton Arhipov
*/
public class AdministrationPanel extends GenericPanel {
- private static Constants constants = GWT.create(Constants.class);
+ private static Constants constants = GWT.create( Constants.class );
public AdministrationPanel(ExplorerViewCenterPanel tabbedPanel) {
- super(constants.Administration(), tabbedPanel);
- setIconCls("nav-admin"); //NON-NLS
+ super( constants.Administration(),
+ tabbedPanel );
+ setIconCls( "nav-admin" ); //NON-NLS
- TreePanel adminTree = basicTreeStructure(/*ExplorerNodeConfig
- .getAdminStructure()*/ new TreeNode(), new TreePanelListenerAdapter() {
- public void onClick(TreeNode self, EventObject e) {
+ TreePanel adminTree = basicTreeStructure( /*ExplorerNodeConfig
+ .getAdminStructure()*/new TreeNode(),
+ new TreePanelListenerAdapter() {
+ public void onClick(TreeNode self,
+ EventObject e) {
- int id = Integer.parseInt(self.getAttribute("id"));
- switch (id) {
- case 0:
- if (!centertabbedPanel.showIfOpen("catman")) //NON-NLS
- centertabbedPanel.addTab(constants.CategoryManager(),
- new CategoryManager(), "catman"); //NON-NLS
- break;
- case 1:
- if (!centertabbedPanel.showIfOpen("archman")) //NON-NLS
- centertabbedPanel.addTab(constants.ArchivedManager(),
- new ArchivedAssetManager(centertabbedPanel),
- "archman"); //NON-NLS
- break;
+ int id = Integer.parseInt( self.getAttribute( "id" ) );
+ switch ( id ) {
+ case 0 :
+ if ( !centertabbedPanel.showIfOpen( "catman" ) ) //NON-NLS
+ centertabbedPanel.addTab( constants.CategoryManager(),
+ new CategoryManager(),
+ "catman" ); //NON-NLS
+ break;
+ case 1 :
+ if ( !centertabbedPanel.showIfOpen( "archman" ) ) //NON-NLS
+ centertabbedPanel.addTab( constants.ArchivedManager(),
+ new ArchivedAssetManager( centertabbedPanel ),
+ "archman" ); //NON-NLS
+ break;
- case 2:
- if (!centertabbedPanel.showIfOpen("stateman")) //NON-NLS
- centertabbedPanel.addTab(constants.StateManager(),
- new StateManager(), "stateman");
- break;
- case 3:
- if (!centertabbedPanel.showIfOpen("bakman"))
- centertabbedPanel.addTab(constants.ImportExport(),
- new BackupManager(), "bakman");
- break;
+ case 2 :
+ if ( !centertabbedPanel.showIfOpen( "stateman" ) ) //NON-NLS
+ centertabbedPanel.addTab( constants.StateManager(),
+ new StateManager(),
+ "stateman" );
+ break;
+ case 3 :
+ if ( !centertabbedPanel.showIfOpen( "bakman" ) ) centertabbedPanel.addTab( constants.ImportExport(),
+ new BackupManager(),
+ "bakman" );
+ break;
- case 4:
- if (!centertabbedPanel.showIfOpen("errorLog"))
- centertabbedPanel.addTab(constants.EventLog(),
- new LogViewer(), "errorLog");
- break;
- case 5:
- if (!centertabbedPanel.showIfOpen("securityPermissions"))
- centertabbedPanel.addTab(constants.UserPermissionMappings(),
- new PermissionViewer(),
- "securityPermissions");
- break;
- case 6:
- Frame aboutFrame = new Frame("version.txt"); //NON-NLS
+ case 4 :
+ if ( !centertabbedPanel.showIfOpen( "errorLog" ) ) centertabbedPanel.addTab( constants.EventLog(),
+ new LogViewer(),
+ "errorLog" );
+ break;
+ case 5 :
+ if ( !centertabbedPanel.showIfOpen( "securityPermissions" ) ) centertabbedPanel.addTab( constants.UserPermissionMappings(),
+ new PermissionViewer(),
+ "securityPermissions" );
+ break;
+ case 6 :
+ Frame aboutFrame = new Frame( "version.txt" ); //NON-NLS
- FormStylePopup aboutPop = new FormStylePopup();
- aboutPop.setWidth(600);
- aboutPop.setTitle(constants.About());
- String hhurl = GWT.getModuleBaseURL() + "webdav";
- aboutPop.addAttribute(constants.WebDAVURL(), new SmallLabel("<b>"
- + hhurl + "</b>"));
- aboutPop.addAttribute(constants.Version() + ":", aboutFrame);
- aboutPop.show();
- break;
- case 7:
- if (!centertabbedPanel.showIfOpen("ruleVerifierManager"))
- centertabbedPanel.addTab(constants.RulesVerificationManager(),
- new RuleVerifierManager(),
- "ruleVerifierManager");
- break;
- case 8:
- if (!centertabbedPanel.showIfOpen("repoconfig")) //NON-NLS
- centertabbedPanel.addTab(constants.RepositoryConfig(),
- new RepoConfigManager(), "repoconfig");
- break;
- }
- }
- });
- adminTree.setRootVisible(false);
+ FormStylePopup aboutPop = new FormStylePopup();
+ aboutPop.setWidth( 600 + "px" );
+ aboutPop.setTitle( constants.About() );
+ String hhurl = GWT.getModuleBaseURL() + "webdav";
+ aboutPop.addAttribute( constants.WebDAVURL(),
+ new SmallLabel( "<b>" + hhurl + "</b>" ) );
+ aboutPop.addAttribute( constants.Version() + ":",
+ aboutFrame );
+ aboutPop.show();
+ break;
+ case 7 :
+ if ( !centertabbedPanel.showIfOpen( "ruleVerifierManager" ) ) centertabbedPanel.addTab( constants.RulesVerificationManager(),
+ new RuleVerifierManager(),
+ "ruleVerifierManager" );
+ break;
+ case 8 :
+ if ( !centertabbedPanel.showIfOpen( "repoconfig" ) ) //NON-NLS
+ centertabbedPanel.addTab( constants.RepositoryConfig(),
+ new RepoConfigManager(),
+ "repoconfig" );
+ break;
+ }
+ }
+ } );
+ adminTree.setRootVisible( false );
- VerticalPanel adminPanel = new VerticalPanel();
- adminPanel.add(adminTree);
- adminPanel.setWidth("100%");
- add(adminPanel);
- }
+ VerticalPanel adminPanel = new VerticalPanel();
+ adminPanel.add( adminTree );
+ adminPanel.setWidth( "100%" );
+ add( adminPanel );
+ }
}
Modified: labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/explorer/AdministrationTree.java
===================================================================
--- labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/explorer/AdministrationTree.java 2010-10-01 06:58:15 UTC (rev 35375)
+++ labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/explorer/AdministrationTree.java 2010-10-01 07:40:28 UTC (rev 35376)
@@ -38,90 +38,89 @@
import org.drools.guvnor.client.admin.RuleVerifierManager;
-
public class AdministrationTree extends AbstractTree {
- private static Constants constants = GWT.create(Constants.class);
- private static Images images = (Images) GWT.create(Images.class);
+ private static Constants constants = GWT.create( Constants.class );
+ private static Images images = (Images) GWT.create( Images.class );
private Map<TreeItem, String> itemWidgets = new HashMap<TreeItem, String>();
public AdministrationTree(ExplorerViewCenterPanel tabbedPanel) {
- super(tabbedPanel);
+ super( tabbedPanel );
this.name = constants.Administration();
this.image = images.rules();
-
- mainTree = ExplorerNodeConfig.getAdminStructure(itemWidgets);
+ mainTree = ExplorerNodeConfig.getAdminStructure( itemWidgets );
+
//Add Selection listener
- mainTree.addSelectionHandler(this);
- }
-
+ mainTree.addSelectionHandler( this );
+ }
+
// Show the associated widget in the deck panel
public void onSelection(SelectionEvent<TreeItem> event) {
TreeItem item = event.getSelectedItem();
- String widgetID = itemWidgets.get(item);
-
- int id = Integer.parseInt(widgetID);
- switch (id) {
- case 0:
- if (!centertabbedPanel.showIfOpen("catman"))
- centertabbedPanel.addTab(constants.CategoryManager(),
- new CategoryManager(), "catman");
- break;
- case 1:
- if (!centertabbedPanel.showIfOpen("archman"))
- centertabbedPanel.addTab(constants.ArchivedManager(),
- new ArchivedAssetManager(centertabbedPanel),
- "archman");
- break;
+ String widgetID = itemWidgets.get( item );
- case 2:
- if (!centertabbedPanel.showIfOpen("stateman"))
- centertabbedPanel.addTab(constants.StateManager(),
- new StateManager(), "stateman");
- break;
- case 3:
- if (!centertabbedPanel.showIfOpen("bakman"))
- centertabbedPanel.addTab(constants.ImportExport(),
- new BackupManager(), "bakman");
- break;
+ int id = Integer.parseInt( widgetID );
+ switch ( id ) {
+ case 0 :
+ if ( !centertabbedPanel.showIfOpen( "catman" ) ) centertabbedPanel.addTab( constants.CategoryManager(),
+ new CategoryManager(),
+ "catman" );
+ break;
+ case 1 :
+ if ( !centertabbedPanel.showIfOpen( "archman" ) ) centertabbedPanel.addTab( constants.ArchivedManager(),
+ new ArchivedAssetManager( centertabbedPanel ),
+ "archman" );
+ break;
- case 4:
- if (!centertabbedPanel.showIfOpen("errorLog"))
- centertabbedPanel.addTab(constants.EventLog(),
- new LogViewer(), "errorLog");
- break;
- case 5:
- if (!centertabbedPanel.showIfOpen("securityPermissions"))
- centertabbedPanel.addTab(constants.UserPermissionMappings(),
- new PermissionViewer(),
- "securityPermissions");
- break;
- case 6:
- Frame aboutFrame = new Frame("version.txt"); //NON-NLS
+ case 2 :
+ if ( !centertabbedPanel.showIfOpen( "stateman" ) ) centertabbedPanel.addTab( constants.StateManager(),
+ new StateManager(),
+ "stateman" );
+ break;
+ case 3 :
+ if ( !centertabbedPanel.showIfOpen( "bakman" ) ) centertabbedPanel.addTab( constants.ImportExport(),
+ new BackupManager(),
+ "bakman" );
+ break;
- FormStylePopup aboutPop = new FormStylePopup();
- aboutPop.setWidth(600);
- aboutPop.setTitle(constants.About());
- String hhurl = GWT.getModuleBaseURL() + "webdav";
- aboutPop.addAttribute(constants.WebDAVURL(), new SmallLabel("<b>"
- + hhurl + "</b>"));
- aboutPop.addAttribute(constants.Version() + ":", aboutFrame);
- aboutPop.show();
- break;
-
- case 7:
- if (!centertabbedPanel.showIfOpen("ruleVerifierManager")) {
- centertabbedPanel.addTab(constants.RulesVerificationManager(),
- new RuleVerifierManager(),
- "ruleVerifierManager");
- }
- break;
- case 8:
- if (!centertabbedPanel.showIfOpen("repoconfig")) //NON-NLS
- centertabbedPanel.addTab(constants.RepositoryConfig(),
- new RepoConfigManager(), "repoconfig");
- break;
- }
+ case 4 :
+ if ( !centertabbedPanel.showIfOpen( "errorLog" ) ) centertabbedPanel.addTab( constants.EventLog(),
+ new LogViewer(),
+ "errorLog" );
+ break;
+ case 5 :
+ if ( !centertabbedPanel.showIfOpen( "securityPermissions" ) ) centertabbedPanel.addTab( constants.UserPermissionMappings(),
+ new PermissionViewer(),
+ "securityPermissions" );
+ break;
+ case 6 :
+ Frame aboutFrame = new Frame( "version.txt" ); //NON-NLS
+
+ FormStylePopup aboutPop = new FormStylePopup();
+ aboutPop.setWidth( 600 + "px" );
+ aboutPop.setTitle( constants.About() );
+ String hhurl = GWT.getModuleBaseURL() + "webdav";
+ aboutPop.addAttribute( constants.WebDAVURL(),
+ new SmallLabel( "<b>" + hhurl + "</b>" ) );
+ aboutPop.addAttribute( constants.Version() + ":",
+ aboutFrame );
+ aboutPop.show();
+ break;
+
+ case 7 :
+ if ( !centertabbedPanel.showIfOpen( "ruleVerifierManager" ) ) {
+ centertabbedPanel.addTab( constants.RulesVerificationManager(),
+ new RuleVerifierManager(),
+ "ruleVerifierManager" );
+ }
+ break;
+ case 8 :
+ if ( !centertabbedPanel.showIfOpen( "repoconfig" ) ) //NON-NLS
+ centertabbedPanel.addTab( constants.RepositoryConfig(),
+ new RepoConfigManager(),
+ "repoconfig" );
+ break;
+ }
}
}
Modified: labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/explorer/NewRepoDialog.java
===================================================================
--- labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/explorer/NewRepoDialog.java 2010-10-01 06:58:15 UTC (rev 35375)
+++ labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/explorer/NewRepoDialog.java 2010-10-01 07:40:28 UTC (rev 35376)
@@ -41,41 +41,43 @@
private Constants constants;
public NewRepoDialog() {
- //super("images/new_wiz.gif", "Welcome to Guvnor !");
- setTitle(((Constants) GWT.create(Constants.class)).WelcomeToGuvnor());
- setWidth(300);
+ //super("images/new_wiz.gif", "Welcome to Guvnor !");
+ setTitle( ((Constants) GWT.create( Constants.class )).WelcomeToGuvnor() );
+ setWidth( 300 + "px" );
- constants = ((Constants) GWT.create(Constants.class));
- addAttribute("", new HTML("<div class='highlight'>" + constants.BrandNewRepositoryNote() + "</div>")); //NON-NLS
+ constants = ((Constants) GWT.create( Constants.class ));
+ addAttribute( "",
+ new HTML( "<div class='highlight'>" + constants.BrandNewRepositoryNote() + "</div>" ) ); //NON-NLS
- HorizontalPanel hp = new HorizontalPanel();
+ HorizontalPanel hp = new HorizontalPanel();
- Button ins = new Button(constants.YesPleaseInstallSamples());
- hp.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
- hp.add(ins);
- Button no = new Button(constants.NoThanks());
- hp.add(no);
+ Button ins = new Button( constants.YesPleaseInstallSamples() );
+ hp.setHorizontalAlignment( HasHorizontalAlignment.ALIGN_CENTER );
+ hp.add( ins );
+ Button no = new Button( constants.NoThanks() );
+ hp.add( no );
- addAttribute("", hp);
- ins.addClickListener(new ClickListener() {
- public void onClick(Widget w) {
- if (!Window.confirm(constants.AboutToInstallSampleRepositoryAreYouSure())) return;
- LoadingPopup.showMessage(constants.ImportingAndProcessing());
- RepositoryServiceFactory.getService().installSampleRepository(new GenericCallback() {
- public void onSuccess(Object a) {
- Window.alert(constants.RepositoryInstalledSuccessfully());
- hide();
- Window.Location.reload();
- }
- });
- }
- });
- no.addClickListener(new ClickListener() {
- public void onClick(Widget w) {
- hide();
- }
- });
+ addAttribute( "",
+ hp );
+ ins.addClickListener( new ClickListener() {
+ public void onClick(Widget w) {
+ if ( !Window.confirm( constants.AboutToInstallSampleRepositoryAreYouSure() ) ) return;
+ LoadingPopup.showMessage( constants.ImportingAndProcessing() );
+ RepositoryServiceFactory.getService().installSampleRepository( new GenericCallback() {
+ public void onSuccess(Object a) {
+ Window.alert( constants.RepositoryInstalledSuccessfully() );
+ hide();
+ Window.Location.reload();
+ }
+ } );
+ }
+ } );
+ no.addClickListener( new ClickListener() {
+ public void onClick(Widget w) {
+ hide();
+ }
+ } );
- }
+ }
}
Modified: labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/modeldriven/ui/DefaultLiteralEditor.java
===================================================================
--- labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/modeldriven/ui/DefaultLiteralEditor.java 2010-10-01 06:58:15 UTC (rev 35375)
+++ labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/modeldriven/ui/DefaultLiteralEditor.java 2010-10-01 07:40:28 UTC (rev 35376)
@@ -1,4 +1,4 @@
-/**
+/*
* Copyright 2010 JBoss Inc
*
* Licensed under the Apache License, Version 2.0 (the "License");
Modified: labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/modeldriven/ui/ExpressionBuilder.java
===================================================================
--- labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/modeldriven/ui/ExpressionBuilder.java 2010-10-01 06:58:15 UTC (rev 35375)
+++ labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/modeldriven/ui/ExpressionBuilder.java 2010-10-01 07:40:28 UTC (rev 35376)
@@ -56,385 +56,432 @@
import com.google.gwt.user.client.ui.TextBox;
import com.google.gwt.user.client.ui.Widget;
-public class ExpressionBuilder extends RuleModellerWidget implements HasExpressionTypeChangeHandlers, HasExpressionChangeHandlers {
+public class ExpressionBuilder extends RuleModellerWidget
+ implements
+ HasExpressionTypeChangeHandlers,
+ HasExpressionChangeHandlers {
- private static final String DELETE_VALUE = "_delete_";
- private static final String FIElD_VALUE_PREFIX = "fl";
- private static final String VARIABLE_VALUE_PREFIX = "va";
- // private static final String GLOBAL_COLLECTION_VALUE_PREFIX = "gc";
- private static final String GLOBAL_VARIABLE_VALUE_PREFIX = "gv";
- private static final String METHOD_VALUE_PREFIX = "mt";
- private final SmallLabelClickHandler slch = new SmallLabelClickHandler();
- private Constants constants = ((Constants) GWT.create(Constants.class));
- // private FlowPanel panel = new FlowPanel();
- private HorizontalPanel panel = new HorizontalPanel();
- private ExpressionFormLine expression;
- private boolean readOnly;
+ private static final String DELETE_VALUE = "_delete_";
+ private static final String FIElD_VALUE_PREFIX = "fl";
+ private static final String VARIABLE_VALUE_PREFIX = "va";
+ // private static final String GLOBAL_COLLECTION_VALUE_PREFIX = "gc";
+ private static final String GLOBAL_VARIABLE_VALUE_PREFIX = "gv";
+ private static final String METHOD_VALUE_PREFIX = "mt";
+ private final SmallLabelClickHandler slch = new SmallLabelClickHandler();
+ private Constants constants = ((Constants) GWT.create( Constants.class ));
+ // private FlowPanel panel = new FlowPanel();
+ private HorizontalPanel panel = new HorizontalPanel();
+ private ExpressionFormLine expression;
+ private boolean readOnly;
- public ExpressionBuilder(RuleModeller modeller, ExpressionFormLine expression) {
- this(modeller, expression, false);
- }
+ public ExpressionBuilder(RuleModeller modeller,
+ ExpressionFormLine expression) {
+ this( modeller,
+ expression,
+ false );
+ }
- public ExpressionBuilder(RuleModeller modeller, ExpressionFormLine expression, Boolean readOnly) {
- super(modeller);
+ public ExpressionBuilder(RuleModeller modeller,
+ ExpressionFormLine expression,
+ Boolean readOnly) {
+ super( modeller );
- if (readOnly == null) {
- this.readOnly = !modeller.getSuggestionCompletions().containsFactType(
- modeller.getSuggestionCompletions().getFactNameFromType(
- this.expression.getRootExpression().getClassType()));
- } else {
- this.readOnly = readOnly;
- }
+ if ( readOnly == null ) {
+ this.readOnly = !modeller.getSuggestionCompletions().containsFactType( modeller.getSuggestionCompletions().getFactNameFromType( this.expression.getRootExpression().getClassType() ) );
+ } else {
+ this.readOnly = readOnly;
+ }
- panel.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
+ panel.setVerticalAlignment( HasVerticalAlignment.ALIGN_MIDDLE );
- this.expression = expression;
- if (expression == null || expression.isEmpty()) {
- if (this.readOnly) {
- panel.add(new SmallLabel("<b>-</b>"));
- } else {
- panel.add(createStartPointWidget());
- }
- } else {
- if (this.readOnly) {
- panel.add(createWidgetForExpression("<b>" + getBoundText() + expression.getText(false) + "</b>"));
- } else {
- panel.add(createWidgetForExpression("<b>" + getBoundText() + expression.getText(false) + ".</b>"));
- panel.add(getWidgetForCurrentType());
- }
- }
- initWidget(panel);
- }
-
- private String getBoundText() {
- if (expression.isBound()) {
- return "[" + expression.getBinding() + "] ";
- }
- return "";
- }
+ this.expression = expression;
+ if ( expression == null || expression.isEmpty() ) {
+ if ( this.readOnly ) {
+ panel.add( new SmallLabel( "<b>-</b>" ) );
+ } else {
+ panel.add( createStartPointWidget() );
+ }
+ } else {
+ if ( this.readOnly ) {
+ panel.add( createWidgetForExpression( "<b>" + getBoundText() + expression.getText( false ) + "</b>" ) );
+ } else {
+ panel.add( createWidgetForExpression( "<b>" + getBoundText() + expression.getText( false ) + ".</b>" ) );
+ panel.add( getWidgetForCurrentType() );
+ }
+ }
+ initWidget( panel );
+ }
- private Widget createStartPointWidget() {
- ListBox startPoint = new ListBox();
- panel.add(startPoint);
+ private String getBoundText() {
+ if ( expression.isBound() ) {
+ return "[" + expression.getBinding() + "] ";
+ }
+ return "";
+ }
- startPoint.addItem(constants.ChooseDotDotDot(), "");
+ private Widget createStartPointWidget() {
+ ListBox startPoint = new ListBox();
+ panel.add( startPoint );
- // TODO {baunax} uncomment when global collections is implemented.
- // for (String gc : getCompletionEngine().getGlobalCollections()) {
- // startPoint.addItem(gc, GLOBAL_COLLECTION_VALUE_PREFIX + "." + gc);
- // }
+ startPoint.addItem( constants.ChooseDotDotDot(),
+ "" );
- for (String gv : getCompletionEngine().getGlobalVariables()) {
- startPoint.addItem(gv, GLOBAL_VARIABLE_VALUE_PREFIX + "." + gv);
- }
+ // TODO {baunax} uncomment when global collections is implemented.
+ // for (String gc : getCompletionEngine().getGlobalCollections()) {
+ // startPoint.addItem(gc, GLOBAL_COLLECTION_VALUE_PREFIX + "." + gc);
+ // }
- for (String v : getRuleModel().getBoundFacts()) {
- startPoint.addItem(v, VARIABLE_VALUE_PREFIX + "." + v);
- }
+ for ( String gv : getCompletionEngine().getGlobalVariables() ) {
+ startPoint.addItem( gv,
+ GLOBAL_VARIABLE_VALUE_PREFIX + "." + gv );
+ }
- startPoint.setVisibleItemCount(1);
- startPoint.addChangeHandler(new ChangeHandler() {
+ for ( String v : getRuleModel().getBoundFacts() ) {
+ startPoint.addItem( v,
+ VARIABLE_VALUE_PREFIX + "." + v );
+ }
- public void onChange(ChangeEvent event) {
- ListBox lb = (ListBox) event.getSource();
- int index = lb.getSelectedIndex();
- if (index > 0) {
- ExpressionBuilder.this.makeDirty();
- startPointChange(lb.getValue(index));
- }
- }
- });
- return startPoint;
- }
+ startPoint.setVisibleItemCount( 1 );
+ startPoint.addChangeHandler( new ChangeHandler() {
- @Override
- public void makeDirty() {
- super.makeDirty();
- setModified(true);
- }
+ public void onChange(ChangeEvent event) {
+ ListBox lb = (ListBox) event.getSource();
+ int index = lb.getSelectedIndex();
+ if ( index > 0 ) {
+ ExpressionBuilder.this.makeDirty();
+ startPointChange( lb.getValue( index ) );
+ }
+ }
+ } );
+ return startPoint;
+ }
- private void startPointChange(String value) {
- setModified(true);
- panel.clear();
- Widget w;
- int dotPos = value.indexOf('.');
- String prefix = value.substring(0, dotPos);
- String attrib = value.substring(dotPos + 1);
- if (prefix.equals(VARIABLE_VALUE_PREFIX)) {
- FactPattern fact = getRuleModel().getBoundFact(attrib);
- ExpressionPart variable;
- if (fact != null) {
- variable = new ExpressionVariable(fact);
- } else {
- //TODO {baunax} fix it!!! to make recursive
- variable = new ExpressionFieldVariable(attrib);
- }
- expression.appendPart(variable);
+ @Override
+ public void makeDirty() {
+ super.makeDirty();
+ setModified( true );
+ }
- } else if (prefix.equals(GLOBAL_VARIABLE_VALUE_PREFIX)) {
- expression.appendPart(getExpressionPartForGlobalVariable(getCompletionEngine(), attrib));
- }
- w = getWidgetForCurrentType();
+ private void startPointChange(String value) {
+ setModified( true );
+ panel.clear();
+ Widget w;
+ int dotPos = value.indexOf( '.' );
+ String prefix = value.substring( 0,
+ dotPos );
+ String attrib = value.substring( dotPos + 1 );
+ if ( prefix.equals( VARIABLE_VALUE_PREFIX ) ) {
+ FactPattern fact = getRuleModel().getBoundFact( attrib );
+ ExpressionPart variable;
+ if ( fact != null ) {
+ variable = new ExpressionVariable( fact );
+ } else {
+ //TODO {baunax} fix it!!! to make recursive
+ variable = new ExpressionFieldVariable( attrib );
+ }
+ expression.appendPart( variable );
- if (!expression.isEmpty()) {
- panel.add(createWidgetForExpression("<b>" + expression.getText() + ".</b>"));
- }
- if (w != null) {
- panel.add(w);
- }
- fireExpressionChangeEvent();
- fireExpressionTypeChangeEvent();
- }
+ } else if ( prefix.equals( GLOBAL_VARIABLE_VALUE_PREFIX ) ) {
+ expression.appendPart( getExpressionPartForGlobalVariable( getCompletionEngine(),
+ attrib ) );
+ }
+ w = getWidgetForCurrentType();
- private Widget getWidgetForCurrentType() {
- if (expression.isEmpty()) {
- return createStartPointWidget();
- }
-
- ChangeHandler ch = new ChangeHandler() {
- public void onChange(ChangeEvent event) {
- ListBox box = (ListBox) event.getSource();
- panel.remove(box);
- if (box.getSelectedIndex() > 0) {
- onChangeSelection(box.getValue(box.getSelectedIndex()));
- }
- }
- };
-
- ListBox lb = new ListBox();
- lb.setVisibleItemCount(1);
- lb.addItem(constants.ChooseDotDotDot(), "");
- lb.addItem("<==" + constants.DeleteItem(), DELETE_VALUE);
- for (Map.Entry<String, String> entry : getCompletionsForCurrentType().entrySet()) {
- lb.addItem(entry.getKey(), entry.getValue());
- }
- lb.addChangeHandler(ch);
- return lb;
- }
+ if ( !expression.isEmpty() ) {
+ panel.add( createWidgetForExpression( "<b>" + expression.getText() + ".</b>" ) );
+ }
+ if ( w != null ) {
+ panel.add( w );
+ }
+ fireExpressionChangeEvent();
+ fireExpressionTypeChangeEvent();
+ }
- private void onCollectionChange(String value) {
- if ("size".contains(value)) {
- expression.appendPart(new ExpressionMethod("size", "int", SuggestionCompletionEngine.TYPE_NUMERIC));
- } else if ("isEmpty".equals(value)) {
- expression.appendPart(new ExpressionMethod("isEmpty", "boolean", SuggestionCompletionEngine.TYPE_BOOLEAN));
- } else {
- ExpressionCollectionIndex collectionIndex;
- String factName = getCompletionEngine().getFactNameFromType(getCurrentParametricType());
- if (getCurrentParametricType() != null && factName != null) {
- collectionIndex = new ExpressionCollectionIndex("get", getCurrentParametricType(), factName);
- } else {
- collectionIndex = new ExpressionCollectionIndex("get", "java.lang.Object",
- SuggestionCompletionEngine.TYPE_OBJECT);
- }
- if ("first".equals(value)) {
- collectionIndex.putParam("index", new ExpressionFormLine(new ExpressionText("0")));
- expression.appendPart(collectionIndex);
- } else if ("last".equals(value)) {
- ExpressionFormLine index = new ExpressionFormLine(expression);
- index.appendPart(new ExpressionMethod("size", "int", SuggestionCompletionEngine.TYPE_NUMERIC));
- index.appendPart(new ExpressionText("-1"));
+ private Widget getWidgetForCurrentType() {
+ if ( expression.isEmpty() ) {
+ return createStartPointWidget();
+ }
- collectionIndex.putParam("index", index);
- expression.appendPart(collectionIndex);
- }
- }
- }
+ ChangeHandler ch = new ChangeHandler() {
+ public void onChange(ChangeEvent event) {
+ ListBox box = (ListBox) event.getSource();
+ panel.remove( box );
+ if ( box.getSelectedIndex() > 0 ) {
+ onChangeSelection( box.getValue( box.getSelectedIndex() ) );
+ }
+ }
+ };
- private void onChangeSelection(String value) {
- setModified(true);
- String oldType = getCurrentGenericType();
- String prevFactName = null;
- if (DELETE_VALUE.equals(value)) {
- expression.removeLast();
- } else if (SuggestionCompletionEngine.TYPE_COLLECTION.equals(getCurrentGenericType())) {
- onCollectionChange(value);
- } else if (SuggestionCompletionEngine.TYPE_STRING.equals(getCurrentGenericType())) {
- if ("size".equals(value)) {
- expression.appendPart(new ExpressionMethod("size", "int", SuggestionCompletionEngine.TYPE_NUMERIC));
- } else if ("isEmpty".equals(value)) {
- expression.appendPart(new ExpressionText(".size() == 0", "", SuggestionCompletionEngine.TYPE_NUMERIC));
- }
- } else {
- int dotPos = value.indexOf('.');
- String prefix = value.substring(0, dotPos);
- String attrib = value.substring(dotPos + 1);
+ ListBox lb = new ListBox();
+ lb.setVisibleItemCount( 1 );
+ lb.addItem( constants.ChooseDotDotDot(),
+ "" );
+ lb.addItem( "<==" + constants.DeleteItem(),
+ DELETE_VALUE );
+ for ( Map.Entry<String, String> entry : getCompletionsForCurrentType().entrySet() ) {
+ lb.addItem( entry.getKey(),
+ entry.getValue() );
+ }
+ lb.addChangeHandler( ch );
+ return lb;
+ }
- prevFactName = getCompletionEngine().getFactNameFromType(getCurrentClassType());
- // String genericType = SuggestionCompletionEngine.TYPE_OBJECT;
- if (FIElD_VALUE_PREFIX.equals(prefix)) {
- expression.appendPart(getExpressionPartForField(getCompletionEngine(), prevFactName, attrib));
- } else if (METHOD_VALUE_PREFIX.equals(prefix)) {
- expression.appendPart(getExpressionPartForMethod(getCompletionEngine(), prevFactName, attrib));
- }
- }
- Widget w = getWidgetForCurrentType();
+ private void onCollectionChange(String value) {
+ if ( "size".contains( value ) ) {
+ expression.appendPart( new ExpressionMethod( "size",
+ "int",
+ SuggestionCompletionEngine.TYPE_NUMERIC ) );
+ } else if ( "isEmpty".equals( value ) ) {
+ expression.appendPart( new ExpressionMethod( "isEmpty",
+ "boolean",
+ SuggestionCompletionEngine.TYPE_BOOLEAN ) );
+ } else {
+ ExpressionCollectionIndex collectionIndex;
+ String factName = getCompletionEngine().getFactNameFromType( getCurrentParametricType() );
+ if ( getCurrentParametricType() != null && factName != null ) {
+ collectionIndex = new ExpressionCollectionIndex( "get",
+ getCurrentParametricType(),
+ factName );
+ } else {
+ collectionIndex = new ExpressionCollectionIndex( "get",
+ "java.lang.Object",
+ SuggestionCompletionEngine.TYPE_OBJECT );
+ }
+ if ( "first".equals( value ) ) {
+ collectionIndex.putParam( "index",
+ new ExpressionFormLine( new ExpressionText( "0" ) ) );
+ expression.appendPart( collectionIndex );
+ } else if ( "last".equals( value ) ) {
+ ExpressionFormLine index = new ExpressionFormLine( expression );
+ index.appendPart( new ExpressionMethod( "size",
+ "int",
+ SuggestionCompletionEngine.TYPE_NUMERIC ) );
+ index.appendPart( new ExpressionText( "-1" ) );
- panel.clear();
- if (!expression.isEmpty()) {
- panel.add(createWidgetForExpression("<b>" + expression.getText() + ".</b>"));
- }
- if (w != null) {
- panel.add(w);
- }
- fireExpressionChangeEvent();
- fireExpressionTypeChangeEvent(oldType);
- }
+ collectionIndex.putParam( "index",
+ index );
+ expression.appendPart( collectionIndex );
+ }
+ }
+ }
- private Map<String, String> getCompletionsForCurrentType() {
- Map<String, String> completions = new LinkedHashMap<String, String>();
+ private void onChangeSelection(String value) {
+ setModified( true );
+ String oldType = getCurrentGenericType();
+ String prevFactName = null;
+ if ( DELETE_VALUE.equals( value ) ) {
+ expression.removeLast();
+ } else if ( SuggestionCompletionEngine.TYPE_COLLECTION.equals( getCurrentGenericType() ) ) {
+ onCollectionChange( value );
+ } else if ( SuggestionCompletionEngine.TYPE_STRING.equals( getCurrentGenericType() ) ) {
+ if ( "size".equals( value ) ) {
+ expression.appendPart( new ExpressionMethod( "size",
+ "int",
+ SuggestionCompletionEngine.TYPE_NUMERIC ) );
+ } else if ( "isEmpty".equals( value ) ) {
+ expression.appendPart( new ExpressionText( ".size() == 0",
+ "",
+ SuggestionCompletionEngine.TYPE_NUMERIC ) );
+ }
+ } else {
+ int dotPos = value.indexOf( '.' );
+ String prefix = value.substring( 0,
+ dotPos );
+ String attrib = value.substring( dotPos + 1 );
- if (SuggestionCompletionEngine.TYPE_FINAL_OBJECT.equals(getCurrentGenericType())) {
- return completions;
- }
+ prevFactName = getCompletionEngine().getFactNameFromType( getCurrentClassType() );
+ // String genericType = SuggestionCompletionEngine.TYPE_OBJECT;
+ if ( FIElD_VALUE_PREFIX.equals( prefix ) ) {
+ expression.appendPart( getExpressionPartForField( getCompletionEngine(),
+ prevFactName,
+ attrib ) );
+ } else if ( METHOD_VALUE_PREFIX.equals( prefix ) ) {
+ expression.appendPart( getExpressionPartForMethod( getCompletionEngine(),
+ prevFactName,
+ attrib ) );
+ }
+ }
+ Widget w = getWidgetForCurrentType();
- if (SuggestionCompletionEngine.TYPE_COLLECTION.equals(getCurrentGenericType())) {
- completions.put("size()", "size");
- completions.put("first()", "first");
- completions.put("last()", "last");
- completions.put("isEmpty()", "isEmpty");
- return completions;
- }
+ panel.clear();
+ if ( !expression.isEmpty() ) {
+ panel.add( createWidgetForExpression( "<b>" + expression.getText() + ".</b>" ) );
+ }
+ if ( w != null ) {
+ panel.add( w );
+ }
+ fireExpressionChangeEvent();
+ fireExpressionTypeChangeEvent( oldType );
+ }
- if (SuggestionCompletionEngine.TYPE_STRING.equals(getCurrentGenericType())) {
- completions.put("size()", "size");
- completions.put("isEmpty()", "isEmpty");
- return completions;
- }
+ private Map<String, String> getCompletionsForCurrentType() {
+ Map<String, String> completions = new LinkedHashMap<String, String>();
- if (SuggestionCompletionEngine.TYPE_BOOLEAN.equals(getCurrentGenericType())
- || SuggestionCompletionEngine.TYPE_NUMERIC.equals(getCurrentGenericType())
- || SuggestionCompletionEngine.TYPE_DATE.equals(getCurrentGenericType())
- || SuggestionCompletionEngine.TYPE_OBJECT.equals(getCurrentGenericType())) {
- return completions;
- }
+ if ( SuggestionCompletionEngine.TYPE_FINAL_OBJECT.equals( getCurrentGenericType() ) ) {
+ return completions;
+ }
- String factName = getCompletionEngine().getFactNameFromType(getCurrentClassType());
- if (factName != null) {
- // we currently only support 0 param method calls
- List<String> methodNames = getCompletionEngine().getMethodFullNames(factName, 0);
+ if ( SuggestionCompletionEngine.TYPE_COLLECTION.equals( getCurrentGenericType() ) ) {
+ completions.put( "size()",
+ "size" );
+ completions.put( "first()",
+ "first" );
+ completions.put( "last()",
+ "last" );
+ completions.put( "isEmpty()",
+ "isEmpty" );
+ return completions;
+ }
- for (String field : getCompletionEngine().getFieldCompletions(factName)) {
- boolean changed = false;
- for (Iterator<String> i = methodNames.iterator(); i.hasNext();) {
- String method = i.next();
- if (method.startsWith(field)) {
- completions.put(method, METHOD_VALUE_PREFIX + "." + method);
- i.remove();
- changed = true;
- }
- }
- if (!changed) {
- completions.put(field, FIElD_VALUE_PREFIX + "." + field);
- }
- }
- }
- // else {We don't know anything about this type, so return empty map}
- return completions;
- }
+ if ( SuggestionCompletionEngine.TYPE_STRING.equals( getCurrentGenericType() ) ) {
+ completions.put( "size()",
+ "size" );
+ completions.put( "isEmpty()",
+ "isEmpty" );
+ return completions;
+ }
- // private String getCurrentPartName() {
- // return expression.getCurrentName();
- // }
+ if ( SuggestionCompletionEngine.TYPE_BOOLEAN.equals( getCurrentGenericType() ) || SuggestionCompletionEngine.TYPE_NUMERIC.equals( getCurrentGenericType() ) || SuggestionCompletionEngine.TYPE_DATE.equals( getCurrentGenericType() )
+ || SuggestionCompletionEngine.TYPE_OBJECT.equals( getCurrentGenericType() ) ) {
+ return completions;
+ }
- private RuleModel getRuleModel() {
- return this.getModeller().getModel();
- }
+ String factName = getCompletionEngine().getFactNameFromType( getCurrentClassType() );
+ if ( factName != null ) {
+ // we currently only support 0 param method calls
+ List<String> methodNames = getCompletionEngine().getMethodFullNames( factName,
+ 0 );
- private SuggestionCompletionEngine getCompletionEngine() {
- return this.getModeller().getSuggestionCompletions();
- }
+ for ( String field : getCompletionEngine().getFieldCompletions( factName ) ) {
+ boolean changed = false;
+ for ( Iterator<String> i = methodNames.iterator(); i.hasNext(); ) {
+ String method = i.next();
+ if ( method.startsWith( field ) ) {
+ completions.put( method,
+ METHOD_VALUE_PREFIX + "." + method );
+ i.remove();
+ changed = true;
+ }
+ }
+ if ( !changed ) {
+ completions.put( field,
+ FIElD_VALUE_PREFIX + "." + field );
+ }
+ }
+ }
+ // else {We don't know anything about this type, so return empty map}
+ return completions;
+ }
- private String getCurrentClassType() {
- return expression.getClassType();
- }
+ // private String getCurrentPartName() {
+ // return expression.getCurrentName();
+ // }
- private String getCurrentGenericType() {
- return expression.getGenericType();
- }
+ private RuleModel getRuleModel() {
+ return this.getModeller().getModel();
+ }
- private String getPreviousGenericType() {
- return expression.getPreviousGenericType();
- }
+ private SuggestionCompletionEngine getCompletionEngine() {
+ return this.getModeller().getSuggestionCompletions();
+ }
- private String getCurrentParametricType() {
- return expression.getParametricType();
- }
+ private String getCurrentClassType() {
+ return expression.getClassType();
+ }
- // private String getPreviousClassType() {
- // return expression.getPreviousType();
- // }
- //
- // private ExpressionPart getRootExpression() {
- // return expression.getRootExpression();
- // }
+ private String getCurrentGenericType() {
+ return expression.getGenericType();
+ }
- @Override
- public boolean isReadOnly() {
- return this.readOnly;
- }
+ private String getPreviousGenericType() {
+ return expression.getPreviousGenericType();
+ }
- /**
- * @see org.drools.guvnor.client.modeldriven.ui.HasExpressionTypeChangeHandlers#addExpressionTypeChangeHandler(org.drools.guvnor.client.modeldriven.ui.ExpressionTypeChangeHandler)
- */
- public HandlerRegistration addExpressionTypeChangeHandler(ExpressionTypeChangeHandler handler) {
- return addHandler(handler, ExpressionTypeChangeEvent.getType());
- }
+ private String getCurrentParametricType() {
+ return expression.getParametricType();
+ }
- private void fireExpressionChangeEvent() {
- fireEvent(new ExpressionChangeEvent());
- }
-
- private void fireExpressionTypeChangeEvent() {
- fireExpressionTypeChangeEvent(getPreviousGenericType());
- }
+ // private String getPreviousClassType() {
+ // return expression.getPreviousType();
+ // }
+ //
+ // private ExpressionPart getRootExpression() {
+ // return expression.getRootExpression();
+ // }
- private void fireExpressionTypeChangeEvent(String previousGenericType) {
- String currentGenericType = getCurrentGenericType();
- if ((previousGenericType == null || !previousGenericType.equals(currentGenericType))
- || currentGenericType != null) {
- fireEvent(new ExpressionTypeChangeEvent(previousGenericType, currentGenericType));
- }
- }
+ @Override
+ public boolean isReadOnly() {
+ return this.readOnly;
+ }
- public HandlerRegistration addExpressionChangeHandler(ExpressionChangeHandler handler) {
- return addHandler(handler, ExpressionChangeEvent.getType());
- }
-
- private void showBindingPopUp() {
- final FormStylePopup popup = new FormStylePopup();
- popup.setWidth(500);
- HorizontalPanel vn = new HorizontalPanel();
- final TextBox varName = new TextBox();
- Button ok = new Button(constants.Set());
- vn.add(new Label(constants.BindTheExpressionToAVariable()));
- vn.add(varName);
- vn.add(ok);
+ /**
+ * @see org.drools.guvnor.client.modeldriven.ui.HasExpressionTypeChangeHandlers#addExpressionTypeChangeHandler(org.drools.guvnor.client.modeldriven.ui.ExpressionTypeChangeHandler)
+ */
+ public HandlerRegistration addExpressionTypeChangeHandler(ExpressionTypeChangeHandler handler) {
+ return addHandler( handler,
+ ExpressionTypeChangeEvent.getType() );
+ }
- ok.addClickHandler(new ClickHandler() {
- public void onClick(ClickEvent event) {
- String var = varName.getText();
- if (getModeller().isVariableNameUsed(var)) {
- Window.alert(Format.format(constants.TheVariableName0IsAlreadyTaken(), var));
- return;
- }
- expression.setBinding(var);
- getModeller().refreshWidget();
- popup.hide();
- }
- });
+ private void fireExpressionChangeEvent() {
+ fireEvent( new ExpressionChangeEvent() );
+ }
- popup.addRow(vn);
- popup.show();
- }
-
- private class SmallLabelClickHandler implements ClickHandler {
- public void onClick(ClickEvent event) {
- showBindingPopUp();
- }
- }
-
- private ClickableLabel createWidgetForExpression(String text) {
- ClickableLabel label = new ClickableLabel(text, slch);
- return label;
- }
+ private void fireExpressionTypeChangeEvent() {
+ fireExpressionTypeChangeEvent( getPreviousGenericType() );
+ }
+
+ private void fireExpressionTypeChangeEvent(String previousGenericType) {
+ String currentGenericType = getCurrentGenericType();
+ if ( (previousGenericType == null || !previousGenericType.equals( currentGenericType )) || currentGenericType != null ) {
+ fireEvent( new ExpressionTypeChangeEvent( previousGenericType,
+ currentGenericType ) );
+ }
+ }
+
+ public HandlerRegistration addExpressionChangeHandler(ExpressionChangeHandler handler) {
+ return addHandler( handler,
+ ExpressionChangeEvent.getType() );
+ }
+
+ private void showBindingPopUp() {
+ final FormStylePopup popup = new FormStylePopup();
+ popup.setWidth( 500 + "px" );
+ HorizontalPanel vn = new HorizontalPanel();
+ final TextBox varName = new TextBox();
+ Button ok = new Button( constants.Set() );
+ vn.add( new Label( constants.BindTheExpressionToAVariable() ) );
+ vn.add( varName );
+ vn.add( ok );
+
+ ok.addClickHandler( new ClickHandler() {
+ public void onClick(ClickEvent event) {
+ String var = varName.getText();
+ if ( getModeller().isVariableNameUsed( var ) ) {
+ Window.alert( Format.format( constants.TheVariableName0IsAlreadyTaken(),
+ var ) );
+ return;
+ }
+ expression.setBinding( var );
+ getModeller().refreshWidget();
+ popup.hide();
+ }
+ } );
+
+ popup.addRow( vn );
+ popup.show();
+ }
+
+ private class SmallLabelClickHandler
+ implements
+ ClickHandler {
+ public void onClick(ClickEvent event) {
+ showBindingPopUp();
+ }
+ }
+
+ private ClickableLabel createWidgetForExpression(String text) {
+ ClickableLabel label = new ClickableLabel( text,
+ slch );
+ return label;
+ }
}
Modified: labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/modeldriven/ui/RuleModeller.java
===================================================================
--- labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/modeldriven/ui/RuleModeller.java 2010-10-01 06:58:15 UTC (rev 35375)
+++ labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/modeldriven/ui/RuleModeller.java 2010-10-01 07:40:28 UTC (rev 35376)
@@ -100,79 +100,85 @@
* @author Michael Neale
*
*/
-public class RuleModeller extends DirtyableComposite implements RuleModelEditor {
+public class RuleModeller extends DirtyableComposite
+ implements
+ RuleModelEditor {
- private DirtyableFlexTable layout;
- private RuleModel model;
- private Constants constants = ((Constants) GWT.create(Constants.class));
- private boolean showingOptions = false;
- private int currentLayoutRow = 0;
- private String packageName;
- private RuleAsset asset;
- private ModellerWidgetFactory widgetFactory;
+ private DirtyableFlexTable layout;
+ private RuleModel model;
+ private Constants constants = ((Constants) GWT.create( Constants.class ));
+ private boolean showingOptions = false;
+ private int currentLayoutRow = 0;
+ private String packageName;
+ private RuleAsset asset;
+ private ModellerWidgetFactory widgetFactory;
- private List<RuleModellerWidget> lhsWidgets = new ArrayList<RuleModellerWidget>();
- private List<RuleModellerWidget> rhsWidgets = new ArrayList<RuleModellerWidget>();
+ private List<RuleModellerWidget> lhsWidgets = new ArrayList<RuleModellerWidget>();
+ private List<RuleModellerWidget> rhsWidgets = new ArrayList<RuleModellerWidget>();
- private boolean hasModifiedWidgets;
+ private boolean hasModifiedWidgets;
- private final Command onWidgetModifiedCommand = new Command() {
+ private final Command onWidgetModifiedCommand = new Command() {
- public void execute() {
- //GWT.log("Widget Modified!");
- hasModifiedWidgets = true;
- }
- };
+ public void execute() {
+ //GWT.log("Widget Modified!");
+ hasModifiedWidgets = true;
+ }
+ };
- public RuleModeller(RuleAsset asset, RuleViewer viewer, ModellerWidgetFactory widgetFactory) {
- this(asset, widgetFactory);
+ public RuleModeller(RuleAsset asset,
+ RuleViewer viewer,
+ ModellerWidgetFactory widgetFactory) {
+ this( asset,
+ widgetFactory );
}
- public RuleModeller(RuleAsset asset, ModellerWidgetFactory widgetFactory) {
- this.asset = asset;
+ public RuleModeller(RuleAsset asset,
+ ModellerWidgetFactory widgetFactory) {
+ this.asset = asset;
this.model = (RuleModel) asset.content;
this.packageName = asset.metaData.packageName;
this.widgetFactory = widgetFactory;
-
+
layout = new DirtyableFlexTable();
initWidget();
- layout.setStyleName("model-builder-Background");
- initWidget(layout);
- setWidth("100%");
- setHeight("100%");
+ layout.setStyleName( "model-builder-Background" );
+ initWidget( layout );
+ setWidth( "100%" );
+ setHeight( "100%" );
}
private boolean isLock(String attr) {
//UNCOMMENT THIS WHEN READY !
//if (ExplorerLayoutManager.shouldShow(Capabilities.SHOW_CREATE_NEW_PACKAGE)) return true;
- if (this.asset.isreadonly){
+ if ( this.asset.isreadonly ) {
return true;
}
- if (this.model.metadataList.length == 0) {
+ if ( this.model.metadataList.length == 0 ) {
return false;
}
- for (RuleMetadata at : this.model.metadataList) {
- if (at.attributeName.equals(attr)) {
- return true;
- }
+ for ( RuleMetadata at : this.model.metadataList ) {
+ if ( at.attributeName.equals( attr ) ) {
+ return true;
+ }
}
return false;
}
/** return true if we should not allow unfrozen editing of the RHS */
public boolean lockRHS() {
- return isLock(RuleAttributeWidget.LOCK_RHS); //NON-NLS
+ return isLock( RuleAttributeWidget.LOCK_RHS ); //NON-NLS
}
/** return true if we should not allow unfrozen editing of the LHS */
public boolean lockLHS() {
- return isLock(RuleAttributeWidget.LOCK_LHS); //NON-NLS
+ return isLock( RuleAttributeWidget.LOCK_LHS ); //NON-NLS
}
/**
@@ -182,86 +188,117 @@
layout.clear();
this.currentLayoutRow = 0;
- Image addPattern = new ImageButton("images/new_item.gif");
- addPattern.setTitle(constants.AddAConditionToThisRule());
- addPattern.addClickHandler(new ClickHandler() {
-
- public void onClick(ClickEvent event) {
- showConditionSelector((Widget) event.getSource(), null);
+ Image addPattern = new ImageButton( "images/new_item.gif" );
+ addPattern.setTitle( constants.AddAConditionToThisRule() );
+ addPattern.addClickHandler( new ClickHandler() {
+
+ public void onClick(ClickEvent event) {
+ showConditionSelector( (Widget) event.getSource(),
+ null );
}
- });
+ } );
- layout.getColumnFormatter().setWidth(0, "8%");
- layout.getColumnFormatter().setWidth(1, "87%");
- layout.getColumnFormatter().setWidth(2, "5%");
+ layout.getColumnFormatter().setWidth( 0,
+ "8%" );
+ layout.getColumnFormatter().setWidth( 1,
+ "87%" );
+ layout.getColumnFormatter().setWidth( 2,
+ "5%" );
//layout.setBorderWidth(2);
- layout.setWidget(currentLayoutRow, 0, new SmallLabel("<b>" + constants.WHEN() + "</b>"));
+ layout.setWidget( currentLayoutRow,
+ 0,
+ new SmallLabel( "<b>" + constants.WHEN() + "</b>" ) );
- if (!lockLHS()) {
- layout.setWidget(currentLayoutRow, 2, addPattern);
+ if ( !lockLHS() ) {
+ layout.setWidget( currentLayoutRow,
+ 2,
+ addPattern );
}
currentLayoutRow++;
- renderLhs(this.model);
+ renderLhs( this.model );
+ layout.setWidget( currentLayoutRow,
+ 0,
+ new SmallLabel( "<b>" + constants.THEN() + "</b>" ) );
- layout.setWidget(currentLayoutRow, 0, new SmallLabel("<b>" + constants.THEN() + "</b>"));
+ Image addAction = new ImageButton( "images/new_item.gif" ); //NON-NLS
+ addAction.setTitle( constants.AddAnActionToThisRule() );
+ addAction.addClickHandler( new ClickHandler() {
- Image addAction = new ImageButton("images/new_item.gif"); //NON-NLS
- addAction.setTitle(constants.AddAnActionToThisRule());
- addAction.addClickHandler(new ClickHandler() {
-
- public void onClick(ClickEvent event) {
- showActionSelector((Widget) event.getSource(), null);
+ public void onClick(ClickEvent event) {
+ showActionSelector( (Widget) event.getSource(),
+ null );
}
- });
- if (!lockRHS()) {
- layout.setWidget(currentLayoutRow, 2, addAction);
+ } );
+ if ( !lockRHS() ) {
+ layout.setWidget( currentLayoutRow,
+ 2,
+ addAction );
}
currentLayoutRow++;
- renderRhs(this.model);
+ renderRhs( this.model );
- if (showAttributes()) {
+ if ( showAttributes() ) {
final int tmp1 = currentLayoutRow;
final int tmp2 = currentLayoutRow + 1;
final RuleModeller self = this;
- if (!this.showingOptions) {
- ClickableLabel showMoreOptions = new ClickableLabel("(show options...)", new ClickHandler() {
-
- public void onClick(ClickEvent event) {
- showingOptions = true;
- layout.setWidget(tmp1, 0, new SmallLabel(constants.optionsRuleModeller()));
- layout.setWidget(tmp1, 2, getAddAttribute());
- layout.setWidget(tmp2, 1, new RuleAttributeWidget(self, self.model));
- }
- });
- layout.setWidget(tmp1, 0, showMoreOptions);
+ if ( !this.showingOptions ) {
+ ClickableLabel showMoreOptions = new ClickableLabel( "(show options...)",
+ new ClickHandler() {
+
+ public void onClick(ClickEvent event) {
+ showingOptions = true;
+ layout.setWidget( tmp1,
+ 0,
+ new SmallLabel( constants.optionsRuleModeller() ) );
+ layout.setWidget( tmp1,
+ 2,
+ getAddAttribute() );
+ layout.setWidget( tmp2,
+ 1,
+ new RuleAttributeWidget( self,
+ self.model ) );
+ }
+ } );
+ layout.setWidget( tmp1,
+ 0,
+ showMoreOptions );
} else {
- layout.setWidget(tmp1, 0, new SmallLabel(constants.optionsRuleModeller()));
- layout.setWidget(tmp1, 2, getAddAttribute());
- layout.setWidget(tmp2, 1, new RuleAttributeWidget(self, self.model));
+ layout.setWidget( tmp1,
+ 0,
+ new SmallLabel( constants.optionsRuleModeller() ) );
+ layout.setWidget( tmp1,
+ 2,
+ getAddAttribute() );
+ layout.setWidget( tmp2,
+ 1,
+ new RuleAttributeWidget( self,
+ self.model ) );
}
-
}
currentLayoutRow++;
- layout.setWidget(currentLayoutRow + 1, 1, spacerWidget());
- layout.getCellFormatter().setHeight(currentLayoutRow + 1, 1, "100%");
+ layout.setWidget( currentLayoutRow + 1,
+ 1,
+ spacerWidget() );
+ layout.getCellFormatter().setHeight( currentLayoutRow + 1,
+ 1,
+ "100%" );
-
- this.verifyRule(null);
+ this.verifyRule( null );
}
private boolean showAttributes() {
//return false;
- return ExplorerLayoutManager.shouldShow(Capabilities.SHOW_PACKAGE_VIEW);
+ return ExplorerLayoutManager.shouldShow( Capabilities.SHOW_PACKAGE_VIEW );
}
public void refreshWidget() {
@@ -271,98 +308,100 @@
}
private Widget getAddAttribute() {
- Image add = new ImageButton("images/new_item.gif"); //NON-NLS
- add.setTitle(constants.AddAnOptionToTheRuleToModifyItsBehaviorWhenEvaluatedOrExecuted());
+ Image add = new ImageButton( "images/new_item.gif" ); //NON-NLS
+ add.setTitle( constants.AddAnOptionToTheRuleToModifyItsBehaviorWhenEvaluatedOrExecuted() );
- add.addClickHandler(new ClickHandler() {
-
- public void onClick(ClickEvent event) {
- showAttributeSelector((Widget) event.getSource());
+ add.addClickHandler( new ClickHandler() {
+
+ public void onClick(ClickEvent event) {
+ showAttributeSelector( (Widget) event.getSource() );
}
- });
+ } );
return add;
}
protected void showAttributeSelector(Widget w) {
- final FormStylePopup pop = new FormStylePopup("images/config.png", constants.AddAnOptionToTheRule()); //NON-NLS
+ final FormStylePopup pop = new FormStylePopup( "images/config.png",
+ constants.AddAnOptionToTheRule() ); //NON-NLS
final ListBox list = RuleAttributeWidget.getAttributeList();
- final Image addbutton = new ImageButton("images/new_item.gif"); //NON-NLS
+ final Image addbutton = new ImageButton( "images/new_item.gif" ); //NON-NLS
final TextBox box = new TextBox();
+ list.setSelectedIndex( 0 );
- list.setSelectedIndex(0);
-
- list.addChangeHandler( new ChangeHandler() {
+ list.addChangeHandler( new ChangeHandler() {
public void onChange(ChangeEvent event) {
- String attr = list.getItemText(list.getSelectedIndex());
- if (attr.equals(RuleAttributeWidget.LOCK_LHS) || attr.equals(RuleAttributeWidget.LOCK_RHS)) {
- model.addMetadata(new RuleMetadata(attr, "true"));
+ String attr = list.getItemText( list.getSelectedIndex() );
+ if ( attr.equals( RuleAttributeWidget.LOCK_LHS ) || attr.equals( RuleAttributeWidget.LOCK_RHS ) ) {
+ model.addMetadata( new RuleMetadata( attr,
+ "true" ) );
} else {
- model.addAttribute(new RuleAttribute(attr, ""));
+ model.addAttribute( new RuleAttribute( attr,
+ "" ) );
}
refreshWidget();
pop.hide();
}
- });
- box.setVisibleLength(15);
+ } );
+ box.setVisibleLength( 15 );
- addbutton.setTitle(constants.AddMetadataToTheRule());
+ addbutton.setTitle( constants.AddMetadataToTheRule() );
- addbutton.addClickHandler(new ClickHandler() {
-
- public void onClick(ClickEvent event) {
+ addbutton.addClickHandler( new ClickHandler() {
- model.addMetadata(new RuleMetadata(box.getText(), ""));
+ public void onClick(ClickEvent event) {
+
+ model.addMetadata( new RuleMetadata( box.getText(),
+ "" ) );
refreshWidget();
pop.hide();
}
- });
+ } );
DirtyableHorizontalPane horiz = new DirtyableHorizontalPane();
- horiz.add(box);
- horiz.add(addbutton);
+ horiz.add( box );
+ horiz.add( addbutton );
+ pop.addAttribute( constants.Metadata3(),
+ horiz );
+ pop.addAttribute( constants.Attribute1(),
+ list );
+ Button freezeConditions = new Button( constants.Conditions() );
+ freezeConditions.addClickHandler( new ClickHandler() {
-
-
- pop.addAttribute(constants.Metadata3(), horiz);
- pop.addAttribute(constants.Attribute1(), list);
-
- Button freezeConditions = new Button(constants.Conditions());
- freezeConditions.addClickHandler(new ClickHandler() {
-
- public void onClick(ClickEvent event) {
- model.addMetadata(new RuleMetadata(RuleAttributeWidget.LOCK_LHS, "true"));
+ public void onClick(ClickEvent event) {
+ model.addMetadata( new RuleMetadata( RuleAttributeWidget.LOCK_LHS,
+ "true" ) );
refreshWidget();
pop.hide();
}
- });
- Button freezeActions = new Button(constants.Actions());
- freezeActions.addClickHandler(new ClickHandler() {
-
- public void onClick(ClickEvent event) {
- model.addMetadata(new RuleMetadata(RuleAttributeWidget.LOCK_RHS, "true"));
+ } );
+ Button freezeActions = new Button( constants.Actions() );
+ freezeActions.addClickHandler( new ClickHandler() {
+
+ public void onClick(ClickEvent event) {
+ model.addMetadata( new RuleMetadata( RuleAttributeWidget.LOCK_RHS,
+ "true" ) );
refreshWidget();
pop.hide();
}
- });
+ } );
HorizontalPanel hz = new HorizontalPanel();
- if (!lockLHS()) {
- hz.add(freezeConditions);
+ if ( !lockLHS() ) {
+ hz.add( freezeConditions );
}
- if (!lockRHS()) {
- hz.add(freezeActions);
+ if ( !lockRHS() ) {
+ hz.add( freezeActions );
}
- hz.add(new InfoPopup(constants.FrozenAreas(), constants.FrozenExplanation()));
+ hz.add( new InfoPopup( constants.FrozenAreas(),
+ constants.FrozenExplanation() ) );
- if (hz.getWidgetCount() > 1) {
- pop.addAttribute(constants.FreezeAreasForEditing(), hz);
+ if ( hz.getWidgetCount() > 1 ) {
+ pop.addAttribute( constants.FreezeAreasForEditing(),
+ hz );
}
-
-
-
pop.show();
}
@@ -371,88 +410,102 @@
*/
private void renderRhs(final RuleModel model) {
- for (int i = 0; i < model.rhs.length; i++) {
+ for ( int i = 0; i < model.rhs.length; i++ ) {
DirtyableVerticalPane widget = new DirtyableVerticalPane();
- widget.setWidth("100%");
+ widget.setWidth( "100%" );
IAction action = model.rhs[i];
//if lockRHS() set the widget RO, otherwise let them decide.
- Boolean readOnly = this.lockRHS()?true:null;
+ Boolean readOnly = this.lockRHS() ? true : null;
- RuleModellerWidget w = getWidgetFactory().getWidget(this, action, readOnly);
- w.addOnModifiedCommand(this.onWidgetModifiedCommand);
+ RuleModellerWidget w = getWidgetFactory().getWidget( this,
+ action,
+ readOnly );
+ w.addOnModifiedCommand( this.onWidgetModifiedCommand );
w.setWidth( "100%" );
- widget.add(spacerWidget());
+ widget.add( spacerWidget() );
DirtyableHorizontalPane horiz = new DirtyableHorizontalPane();
- horiz.setWidth("100%");
+ horiz.setWidth( "100%" );
//horiz.setBorderWidth(2);
- Image remove = new ImageButton("images/delete_item_small.gif"); //NON-NLS
- remove.setTitle(constants.RemoveThisAction());
+ Image remove = new ImageButton( "images/delete_item_small.gif" ); //NON-NLS
+ remove.setTitle( constants.RemoveThisAction() );
final int idx = i;
- remove.addClickHandler(new ClickHandler() {
-
- public void onClick(ClickEvent event) {
- if (Window.confirm(constants.RemoveThisItem())) {
- model.removeRhsItem(idx);
+ remove.addClickHandler( new ClickHandler() {
+
+ public void onClick(ClickEvent event) {
+ if ( Window.confirm( constants.RemoveThisItem() ) ) {
+ model.removeRhsItem( idx );
refreshWidget();
}
}
- });
- horiz.add(w);
- if (!(w instanceof ActionRetractFactWidget)) {
- w.setWidth("100%"); //NON-NLS
- horiz.setWidth("100%");
+ } );
+ horiz.add( w );
+ if ( !(w instanceof ActionRetractFactWidget) ) {
+ w.setWidth( "100%" ); //NON-NLS
+ horiz.setWidth( "100%" );
}
- if (!(this.lockRHS() || w.isReadOnly())) {
- horiz.add(remove);
+ if ( !(this.lockRHS() || w.isReadOnly()) ) {
+ horiz.add( remove );
}
+ widget.add( horiz );
- widget.add(horiz);
+ layout.setHTML( currentLayoutRow,
+ 0,
+ "<div class='x-form-field'>" + (i + 1) + ".</div>" );
+ layout.getFlexCellFormatter().setHorizontalAlignment( currentLayoutRow,
+ 0,
+ HasHorizontalAlignment.ALIGN_CENTER );
+ layout.getFlexCellFormatter().setVerticalAlignment( currentLayoutRow,
+ 0,
+ HasVerticalAlignment.ALIGN_MIDDLE );
+ layout.setWidget( currentLayoutRow,
+ 1,
+ widget );
+ layout.getFlexCellFormatter().setHorizontalAlignment( currentLayoutRow,
+ 1,
+ HasHorizontalAlignment.ALIGN_LEFT );
+ layout.getFlexCellFormatter().setVerticalAlignment( currentLayoutRow,
+ 1,
+ HasVerticalAlignment.ALIGN_TOP );
+ layout.getFlexCellFormatter().setWidth( currentLayoutRow,
+ 1,
+ "100%" );
-
- layout.setHTML(currentLayoutRow, 0, "<div class='x-form-field'>" + (i + 1) + ".</div>");
- layout.getFlexCellFormatter().setHorizontalAlignment(currentLayoutRow, 0, HasHorizontalAlignment.ALIGN_CENTER);
- layout.getFlexCellFormatter().setVerticalAlignment(currentLayoutRow, 0, HasVerticalAlignment.ALIGN_MIDDLE);
-
-
- layout.setWidget(currentLayoutRow, 1, widget);
- layout.getFlexCellFormatter().setHorizontalAlignment(currentLayoutRow, 1, HasHorizontalAlignment.ALIGN_LEFT);
- layout.getFlexCellFormatter().setVerticalAlignment(currentLayoutRow, 1, HasVerticalAlignment.ALIGN_TOP);
- layout.getFlexCellFormatter().setWidth(currentLayoutRow, 1, "100%");
-
final int index = i;
- if (!(this.lockRHS() || w.isReadOnly())) {
- this.addActionsButtonsToLayout(constants.AddAnActionBelow(), new ClickListener() {
+ if ( !(this.lockRHS() || w.isReadOnly()) ) {
+ this.addActionsButtonsToLayout( constants.AddAnActionBelow(),
+ new ClickListener() {
- public void onClick(Widget w) {
- showActionSelector(w, index + 1);
- }
- },new ClickListener() {
+ public void onClick(Widget w) {
+ showActionSelector( w,
+ index + 1 );
+ }
+ },
+ new ClickListener() {
- public void onClick(Widget sender) {
- model.moveRhsItemDown(index);
- refreshWidget();
- }
- },new ClickListener() {
+ public void onClick(Widget sender) {
+ model.moveRhsItemDown( index );
+ refreshWidget();
+ }
+ },
+ new ClickListener() {
- public void onClick(Widget sender) {
- model.moveRhsItemUp(index);
- refreshWidget();
- }
- });
+ public void onClick(Widget sender) {
+ model.moveRhsItemUp( index );
+ refreshWidget();
+ }
+ } );
}
-
- this.rhsWidgets.add(w);
+ this.rhsWidgets.add( w );
currentLayoutRow++;
-
}
}
@@ -460,48 +513,53 @@
/**
* Pops up the fact selector.
*/
- protected void showConditionSelector(final Widget w, Integer position) {
+ protected void showConditionSelector(final Widget w,
+ Integer position) {
//XXX {bauna} add actions for LHS
final FormStylePopup popup = new FormStylePopup();
- popup.setWidth(-1);
- popup.setTitle(constants.AddAConditionToTheRule());
+ popup.setTitle( constants.AddAConditionToTheRule() );
final Map<String, Command> cmds = new HashMap<String, Command>();
final ListBox positionCbo = new ListBox();
- if (position == null) {
- positionCbo.addItem(constants.Bottom(), String.valueOf(this.model.lhs.length));
- positionCbo.addItem(constants.Top(), "0");
- for (int i = 1; i < model.lhs.length; i++) {
- positionCbo.addItem(Format.format(constants.Line0(), i), String.valueOf(i));
+ if ( position == null ) {
+ positionCbo.addItem( constants.Bottom(),
+ String.valueOf( this.model.lhs.length ) );
+ positionCbo.addItem( constants.Top(),
+ "0" );
+ for ( int i = 1; i < model.lhs.length; i++ ) {
+ positionCbo.addItem( Format.format( constants.Line0(),
+ i ),
+ String.valueOf( i ) );
}
} else {
//if position is fixed, we just add one element to the drop down.
- positionCbo.addItem(String.valueOf(position));
- positionCbo.setSelectedIndex(0);
+ positionCbo.addItem( String.valueOf( position ) );
+ positionCbo.setSelectedIndex( 0 );
}
+ final ListBox choices = new ListBox( true );
-
- final ListBox choices = new ListBox(true);
-
//
// The list of DSL sentences
//
- SuggestionCompletionEngine completions = SuggestionCompletionCache.getInstance().getEngineFromCache(packageName);
- if (completions.getDSLConditions().length > 0) {
- for (int i = 0; i < completions.getDSLConditions().length; i++) {
+ SuggestionCompletionEngine completions = SuggestionCompletionCache.getInstance().getEngineFromCache( packageName );
+ if ( completions.getDSLConditions().length > 0 ) {
+ for ( int i = 0; i < completions.getDSLConditions().length; i++ ) {
final DSLSentence sen = completions.getDSLConditions()[i];
String key = "DSL" + i;
- choices.addItem(sen.toString(), key);
- cmds.put(key, new Command() {
+ choices.addItem( sen.toString(),
+ key );
+ cmds.put( key,
+ new Command() {
- public void execute() {
- addNewDSLLhs(sen, Integer.parseInt(positionCbo.getValue(positionCbo.getSelectedIndex())));
- popup.hide();
- }
- });
+ public void execute() {
+ addNewDSLLhs( sen,
+ Integer.parseInt( positionCbo.getValue( positionCbo.getSelectedIndex() ) ) );
+ popup.hide();
+ }
+ } );
}
}
@@ -509,21 +567,24 @@
// The list of facts
//
final String[] facts = completions.getFactTypes();
- if (facts.length > 0) {
- choices.addItem("..................");
+ if ( facts.length > 0 ) {
+ choices.addItem( ".................." );
- for (int i = 0; i < facts.length; i++) {
+ for ( int i = 0; i < facts.length; i++ ) {
final String f = facts[i];
String key = "NF" + f;
- choices.addItem(f + " ...", key);
- cmds.put(key, new Command() {
+ choices.addItem( f + " ...",
+ key );
+ cmds.put( key,
+ new Command() {
- public void execute() {
- addNewFact(f, Integer.parseInt(positionCbo.getValue(positionCbo.getSelectedIndex())));
- popup.hide();
- }
- });
+ public void execute() {
+ addNewFact( f,
+ Integer.parseInt( positionCbo.getValue( positionCbo.getSelectedIndex() ) ) );
+ popup.hide();
+ }
+ } );
}
}
@@ -532,353 +593,413 @@
//
String ces[] = HumanReadable.CONDITIONAL_ELEMENTS;
- choices.addItem("..................");
- for (int i = 0; i < ces.length; i++) {
+ choices.addItem( ".................." );
+ for ( int i = 0; i < ces.length; i++ ) {
final String ce = ces[i];
String key = "CE" + ce;
- choices.addItem(HumanReadable.getCEDisplayName(ce) + " ...", key);
- cmds.put(key, new Command() {
+ choices.addItem( HumanReadable.getCEDisplayName( ce ) + " ...",
+ key );
+ cmds.put( key,
+ new Command() {
- public void execute() {
- addNewCE(ce, Integer.parseInt(positionCbo.getValue(positionCbo.getSelectedIndex())));
- popup.hide();
- }
- });
+ public void execute() {
+ addNewCE( ce,
+ Integer.parseInt( positionCbo.getValue( positionCbo.getSelectedIndex() ) ) );
+ popup.hide();
+ }
+ } );
}
String fces[] = HumanReadable.FROM_CONDITIONAL_ELEMENTS;
- choices.addItem("..................");
- for (int i = 0; i < fces.length; i++) {
+ choices.addItem( ".................." );
+ for ( int i = 0; i < fces.length; i++ ) {
final String ce = fces[i];
String key = "FCE" + ce;
- choices.addItem(HumanReadable.getCEDisplayName(ce) + " ...", key);
- cmds.put(key, new Command() {
+ choices.addItem( HumanReadable.getCEDisplayName( ce ) + " ...",
+ key );
+ cmds.put( key,
+ new Command() {
- public void execute() {
- addNewFCE(ce, Integer.parseInt(positionCbo.getValue(positionCbo.getSelectedIndex())));
- popup.hide();
- }
- });
+ public void execute() {
+ addNewFCE( ce,
+ Integer.parseInt( positionCbo.getValue( positionCbo.getSelectedIndex() ) ) );
+ popup.hide();
+ }
+ } );
}
- if (ExplorerLayoutManager.shouldShow(Capabilities.SHOW_PACKAGE_VIEW)) {
- choices.addItem("..................");
- choices.addItem(constants.FreeFormDrl(), "FF");
- cmds.put("FF", new Command() {
+ if ( ExplorerLayoutManager.shouldShow( Capabilities.SHOW_PACKAGE_VIEW ) ) {
+ choices.addItem( ".................." );
+ choices.addItem( constants.FreeFormDrl(),
+ "FF" );
+ cmds.put( "FF",
+ new Command() {
- public void execute() {
- model.addLhsItem(new FreeFormLine(), Integer.parseInt(positionCbo.getValue(positionCbo.getSelectedIndex())));
- refreshWidget();
- popup.hide();
- }
- });
+ public void execute() {
+ model.addLhsItem( new FreeFormLine(),
+ Integer.parseInt( positionCbo.getValue( positionCbo.getSelectedIndex() ) ) );
+ refreshWidget();
+ popup.hide();
+ }
+ } );
//XXX used to test
-// choices.addItem("..................");
-// choices.addItem(constants.ExpressionEditor(), "EE");
-// cmds.put("EE", new Command() {
-//
-// public void execute() {
-// model.addLhsItem(new ExpressionFormLine(), Integer.parseInt(positionCbo.getValue(positionCbo.getSelectedIndex())));
-// refreshWidget();
-// popup.hide();
-// }
-// });
+ // choices.addItem("..................");
+ // choices.addItem(constants.ExpressionEditor(), "EE");
+ // cmds.put("EE", new Command() {
+ //
+ // public void execute() {
+ // model.addLhsItem(new ExpressionFormLine(), Integer.parseInt(positionCbo.getValue(positionCbo.getSelectedIndex())));
+ // refreshWidget();
+ // popup.hide();
+ // }
+ // });
}
- if (completions.getDSLConditions().length == 0 && facts.length == 0) {
- popup.addRow(new HTML("<div class='highlight'>" + constants.NoModelTip() + "</div>")); //NON-NLS
+ if ( completions.getDSLConditions().length == 0 && facts.length == 0 ) {
+ popup.addRow( new HTML( "<div class='highlight'>" + constants.NoModelTip() + "</div>" ) ); //NON-NLS
}
final ChangeListener cl = new ChangeListener() {
public void onChange(Widget sender) {
int sel = choices.getSelectedIndex();
- if (sel != -1) {
- Command cmd = cmds.get(choices.getValue(choices.getSelectedIndex()));
- if (cmd != null) {
+ if ( sel != -1 ) {
+ Command cmd = cmds.get( choices.getValue( choices.getSelectedIndex() ) );
+ if ( cmd != null ) {
cmd.execute();
}
- verifyRule(null);
+ verifyRule( null );
}
}
};
//choices.addChangeListener(cl);
- choices.addKeyboardListener(new KeyboardListenerAdapter() {
+ choices.addKeyboardListener( new KeyboardListenerAdapter() {
@Override
- public void onKeyUp(final Widget sender, char keyCode, int modifiers) {
- if (keyCode == KeyboardListener.KEY_ENTER) {
- cl.onChange(sender);
+ public void onKeyUp(final Widget sender,
+ char keyCode,
+ int modifiers) {
+ if ( keyCode == KeyboardListener.KEY_ENTER ) {
+ cl.onChange( sender );
}
}
- });
+ } );
//only show the drop down if we are not using fixed position.
- if (position == null) {
+ if ( position == null ) {
HorizontalPanel hp0 = new HorizontalPanel();
- hp0.add(new HTML(constants.PositionColon()));
- hp0.add(positionCbo);
- hp0.add(new InfoPopup(constants.PositionColon(), constants.ConditionPositionExplanation()));
- popup.addRow(hp0);
+ hp0.add( new HTML( constants.PositionColon() ) );
+ hp0.add( positionCbo );
+ hp0.add( new InfoPopup( constants.PositionColon(),
+ constants.ConditionPositionExplanation() ) );
+ popup.addRow( hp0 );
}
HorizontalPanel hp = new HorizontalPanel();
- hp.add(choices);
- Button b = new Button(constants.OK());
- hp.add(b);
- b.addClickListener(new ClickListener() {
-
- public void onClick(Widget sender) {
- cl.onChange(sender);
+ hp.add( choices );
+ Button b = new Button( constants.OK() );
+ hp.add( b );
+ b.addClickListener( new ClickListener() {
+
+ public void onClick(Widget sender) {
+ cl.onChange( sender );
}
- });
- popup.addRow(hp);
+ } );
+ popup.addRow( hp );
popup.show();
- choices.setFocus(true);
+ choices.setFocus( true );
- popup.setAfterShow(new Command() {
+ popup.setAfterShow( new Command() {
public void execute() {
- choices.setFocus(true);
+ choices.setFocus( true );
}
- });
+ } );
}
- protected void addNewDSLLhs(DSLSentence sentence, int position) {
- model.addLhsItem(sentence.copy(), position);
+ protected void addNewDSLLhs(DSLSentence sentence,
+ int position) {
+ model.addLhsItem( sentence.copy(),
+ position );
refreshWidget();
}
- protected void showActionSelector(Widget w, Integer position) {
+ protected void showActionSelector(Widget w,
+ Integer position) {
final FormStylePopup popup = new FormStylePopup();
- popup.setWidth(-1);
- popup.setTitle(constants.AddANewAction());
+ popup.setTitle( constants.AddANewAction() );
final ListBox positionCbo = new ListBox();
- if (position == null) {
- positionCbo.addItem(constants.Bottom(), String.valueOf(this.model.rhs.length));
- positionCbo.addItem(constants.Top(), "0");
- for (int i = 1; i < model.rhs.length; i++) {
- positionCbo.addItem(Format.format(constants.Line0(), i), String.valueOf(i));
+ if ( position == null ) {
+ positionCbo.addItem( constants.Bottom(),
+ String.valueOf( this.model.rhs.length ) );
+ positionCbo.addItem( constants.Top(),
+ "0" );
+ for ( int i = 1; i < model.rhs.length; i++ ) {
+ positionCbo.addItem( Format.format( constants.Line0(),
+ i ),
+ String.valueOf( i ) );
}
} else {
//if position is fixed, we just add one element to the drop down.
- positionCbo.addItem(String.valueOf(position));
- positionCbo.setSelectedIndex(0);
+ positionCbo.addItem( String.valueOf( position ) );
+ positionCbo.setSelectedIndex( 0 );
}
- final ListBox choices = new ListBox(true);
+ final ListBox choices = new ListBox( true );
final Map<String, Command> cmds = new HashMap<String, Command>();
//
// First load up the stuff to do with bound variables or globals
//
- SuggestionCompletionEngine completions = SuggestionCompletionCache.getInstance().getEngineFromCache(packageName);
+ SuggestionCompletionEngine completions = SuggestionCompletionCache.getInstance().getEngineFromCache( packageName );
List<String> vars = model.getBoundFacts();
List<String> vars2 = model.getRhsBoundFacts();
String[] globals = completions.getGlobalVariables();
-
//
// The list of DSL sentences
//
- if (completions.getDSLActions().length > 0) {
+ if ( completions.getDSLActions().length > 0 ) {
- for (int i = 0; i < completions.getDSLActions().length; i++) {
+ for ( int i = 0; i < completions.getDSLActions().length; i++ ) {
final DSLSentence sen = completions.getDSLActions()[i];
- if (sen != null) {
+ if ( sen != null ) {
String sentence = sen.toString();
- choices.addItem(sentence, "DSL" + sentence); //NON-NLS
- cmds.put("DSL" + sentence, new Command() { //NON-NLS
+ choices.addItem( sentence,
+ "DSL" + sentence ); //NON-NLS
+ cmds.put( "DSL" + sentence,
+ new Command() { //NON-NLS
- public void execute() {
- addNewDSLRhs(sen, Integer.parseInt(positionCbo.getValue(positionCbo.getSelectedIndex())));
- popup.hide();
- }
- });
+ public void execute() {
+ addNewDSLRhs( sen,
+ Integer.parseInt( positionCbo.getValue( positionCbo.getSelectedIndex() ) ) );
+ popup.hide();
+ }
+ } );
}
}
- choices.addItem("................");
+ choices.addItem( "................" );
}
-
//Do Set field (NOT modify)
- for (Iterator<String> iter = vars.iterator(); iter.hasNext();) {
+ for ( Iterator<String> iter = vars.iterator(); iter.hasNext(); ) {
final String v = iter.next();
//varBox.addItem( v );
- choices.addItem(Format.format(constants.ChangeFieldValuesOf0(), v), "VAR" + v); //NON-NLS
- cmds.put("VAR" + v, new Command() { //NON-NLS
+ choices.addItem( Format.format( constants.ChangeFieldValuesOf0(),
+ v ),
+ "VAR" + v ); //NON-NLS
+ cmds.put( "VAR" + v,
+ new Command() { //NON-NLS
- public void execute() {
- addActionSetField(v, Integer.parseInt(positionCbo.getValue(positionCbo.getSelectedIndex())));
- popup.hide();
- }
- });
+ public void execute() {
+ addActionSetField( v,
+ Integer.parseInt( positionCbo.getValue( positionCbo.getSelectedIndex() ) ) );
+ popup.hide();
+ }
+ } );
-
}
- for (int i = 0; i < globals.length; i++) { //we also do globals here...
+ for ( int i = 0; i < globals.length; i++ ) { //we also do globals here...
final String v = globals[i];
- choices.addItem(Format.format(constants.ChangeFieldValuesOf0(), v), "GLOBVAR" + v); //NON-NLS
- cmds.put("GLOBVAR" + v, new Command() { //NON-NLS
+ choices.addItem( Format.format( constants.ChangeFieldValuesOf0(),
+ v ),
+ "GLOBVAR" + v ); //NON-NLS
+ cmds.put( "GLOBVAR" + v,
+ new Command() { //NON-NLS
- public void execute() {
- addActionSetField(v, Integer.parseInt(positionCbo.getValue(positionCbo.getSelectedIndex())));
- popup.hide();
- }
- });
+ public void execute() {
+ addActionSetField( v,
+ Integer.parseInt( positionCbo.getValue( positionCbo.getSelectedIndex() ) ) );
+ popup.hide();
+ }
+ } );
}
-
//RETRACT
- for (Iterator<String> iter = vars.iterator(); iter.hasNext();) {
+ for ( Iterator<String> iter = vars.iterator(); iter.hasNext(); ) {
final String v = iter.next();
//retractBox.addItem( v );
- choices.addItem(Format.format(constants.Retract0(), v), "RET" + v); //NON-NLS
- cmds.put("RET" + v, new Command() { //NON-NLS
+ choices.addItem( Format.format( constants.Retract0(),
+ v ),
+ "RET" + v ); //NON-NLS
+ cmds.put( "RET" + v,
+ new Command() { //NON-NLS
- public void execute() {
- addRetract(v, Integer.parseInt(positionCbo.getValue(positionCbo.getSelectedIndex())));
- popup.hide();
- }
- });
+ public void execute() {
+ addRetract( v,
+ Integer.parseInt( positionCbo.getValue( positionCbo.getSelectedIndex() ) ) );
+ popup.hide();
+ }
+ } );
}
//MODIFY
- for (Iterator<String> iter = vars.iterator(); iter.hasNext();) {
+ for ( Iterator<String> iter = vars.iterator(); iter.hasNext(); ) {
final String v = iter.next();
// modifyBox.addItem( v );
- choices.addItem(Format.format(constants.Modify0(), v), "MOD" + v); //NON-NLS
- cmds.put("MOD" + v, new Command() { //NON-NLS
+ choices.addItem( Format.format( constants.Modify0(),
+ v ),
+ "MOD" + v ); //NON-NLS
+ cmds.put( "MOD" + v,
+ new Command() { //NON-NLS
- public void execute() {
- addModify(v, Integer.parseInt(positionCbo.getValue(positionCbo.getSelectedIndex())));
- popup.hide();
- }
- });
+ public void execute() {
+ addModify( v,
+ Integer.parseInt( positionCbo.getValue( positionCbo.getSelectedIndex() ) ) );
+ popup.hide();
+ }
+ } );
}
- choices.addItem("................");
+ choices.addItem( "................" );
-
//Now inserts:
- for (int i = 0; i < completions.getFactTypes().length; i++) {
+ for ( int i = 0; i < completions.getFactTypes().length; i++ ) {
final String item = completions.getFactTypes()[i];
- choices.addItem(Format.format(constants.InsertFact0(), item), "INS" + item); //NON-NLS
- cmds.put("INS" + item, new Command() { //NON-NLS
+ choices.addItem( Format.format( constants.InsertFact0(),
+ item ),
+ "INS" + item ); //NON-NLS
+ cmds.put( "INS" + item,
+ new Command() { //NON-NLS
- public void execute() {
- model.addRhsItem(new ActionInsertFact(item), Integer.parseInt(positionCbo.getValue(positionCbo.getSelectedIndex())));
- refreshWidget();
- popup.hide();
- }
- });
+ public void execute() {
+ model.addRhsItem( new ActionInsertFact( item ),
+ Integer.parseInt( positionCbo.getValue( positionCbo.getSelectedIndex() ) ) );
+ refreshWidget();
+ popup.hide();
+ }
+ } );
}
- for (int i = 0; i < completions.getFactTypes().length; i++) {
+ for ( int i = 0; i < completions.getFactTypes().length; i++ ) {
final String item = completions.getFactTypes()[i];
- choices.addItem(Format.format(constants.LogicallyInsertFact0(), item), "LINS" + item); //NON-NLS
- cmds.put("LINS" + item, new Command() { //NON-NLS
+ choices.addItem( Format.format( constants.LogicallyInsertFact0(),
+ item ),
+ "LINS" + item ); //NON-NLS
+ cmds.put( "LINS" + item,
+ new Command() { //NON-NLS
- public void execute() {
- model.addRhsItem(new ActionInsertLogicalFact(item), Integer.parseInt(positionCbo.getValue(positionCbo.getSelectedIndex())));
- refreshWidget();
- popup.hide();
- }
- });
+ public void execute() {
+ model.addRhsItem( new ActionInsertLogicalFact( item ),
+ Integer.parseInt( positionCbo.getValue( positionCbo.getSelectedIndex() ) ) );
+ refreshWidget();
+ popup.hide();
+ }
+ } );
}
- choices.addItem("................");
+ choices.addItem( "................" );
//now global collections
- if (completions.getGlobalCollections().length > 0 && vars.size() > 0) {
- for (String bf : vars) {
- for (int i = 0; i < completions.getGlobalCollections().length; i++) {
+ if ( completions.getGlobalCollections().length > 0 && vars.size() > 0 ) {
+ for ( String bf : vars ) {
+ for ( int i = 0; i < completions.getGlobalCollections().length; i++ ) {
final String glob = completions.getGlobalCollections()[i];
final String var = bf;
- choices.addItem(Format.format(constants.Append0ToList1(), var, glob), "GLOBCOL" + glob + var); //NON-NLS
- cmds.put("GLOBCOL" + glob + var, new Command() { //NON-NLS
+ choices.addItem( Format.format( constants.Append0ToList1(),
+ var,
+ glob ),
+ "GLOBCOL" + glob + var ); //NON-NLS
+ cmds.put( "GLOBCOL" + glob + var,
+ new Command() { //NON-NLS
- public void execute() {
- ActionGlobalCollectionAdd gca = new ActionGlobalCollectionAdd();
- gca.globalName = glob;
- gca.factName = var;
- model.addRhsItem(gca, Integer.parseInt(positionCbo.getValue(positionCbo.getSelectedIndex())));
- refreshWidget();
- popup.hide();
- }
- });
+ public void execute() {
+ ActionGlobalCollectionAdd gca = new ActionGlobalCollectionAdd();
+ gca.globalName = glob;
+ gca.factName = var;
+ model.addRhsItem( gca,
+ Integer.parseInt( positionCbo.getValue( positionCbo.getSelectedIndex() ) ) );
+ refreshWidget();
+ popup.hide();
+ }
+ } );
}
}
}
- if (ExplorerLayoutManager.shouldShow(Capabilities.SHOW_PACKAGE_VIEW)) {
- choices.addItem(constants.AddFreeFormDrl(), "FF"); //NON-NLS
- cmds.put("FF", new Command() { //NON-NLS
+ if ( ExplorerLayoutManager.shouldShow( Capabilities.SHOW_PACKAGE_VIEW ) ) {
+ choices.addItem( constants.AddFreeFormDrl(),
+ "FF" ); //NON-NLS
+ cmds.put( "FF",
+ new Command() { //NON-NLS
- public void execute() {
- model.addRhsItem(new FreeFormLine(), Integer.parseInt(positionCbo.getValue(positionCbo.getSelectedIndex())));
- refreshWidget();
- popup.hide();
- }
- });
- for (int i = 0; i < globals.length; i++) { //we also do globals here...
+ public void execute() {
+ model.addRhsItem( new FreeFormLine(),
+ Integer.parseInt( positionCbo.getValue( positionCbo.getSelectedIndex() ) ) );
+ refreshWidget();
+ popup.hide();
+ }
+ } );
+ for ( int i = 0; i < globals.length; i++ ) { //we also do globals here...
final String v = globals[i];
- choices.addItem(Format.format(constants.CallMethodOn0(), v), "GLOBCALL" + v); //NON-NLS
- cmds.put("GLOBCALL" + v, new Command() { //NON-NLS
+ choices.addItem( Format.format( constants.CallMethodOn0(),
+ v ),
+ "GLOBCALL" + v ); //NON-NLS
+ cmds.put( "GLOBCALL" + v,
+ new Command() { //NON-NLS
- public void execute() {
- addCallMethod(v, Integer.parseInt(positionCbo.getValue(positionCbo.getSelectedIndex())));
- popup.hide();
- }
- });
+ public void execute() {
+ addCallMethod( v,
+ Integer.parseInt( positionCbo.getValue( positionCbo.getSelectedIndex() ) ) );
+ popup.hide();
+ }
+ } );
}
//CALL methods
- for (Iterator<String> iter = vars.iterator(); iter.hasNext();) {
+ for ( Iterator<String> iter = vars.iterator(); iter.hasNext(); ) {
final String v = iter.next();
- choices.addItem(Format.format(constants.CallMethodOn0(), v), "CALL" + v); //NON-NLS
- cmds.put("CALL" + v, new Command() { //NON-NLS
+ choices.addItem( Format.format( constants.CallMethodOn0(),
+ v ),
+ "CALL" + v ); //NON-NLS
+ cmds.put( "CALL" + v,
+ new Command() { //NON-NLS
- public void execute() {
- addCallMethod(v, Integer.parseInt(positionCbo.getValue(positionCbo.getSelectedIndex())));
- popup.hide();
- }
- });
+ public void execute() {
+ addCallMethod( v,
+ Integer.parseInt( positionCbo.getValue( positionCbo.getSelectedIndex() ) ) );
+ popup.hide();
+ }
+ } );
}
//Do Set field (NOT modify)
- for (Iterator<String> iter = vars2.iterator(); iter.hasNext();) {
+ for ( Iterator<String> iter = vars2.iterator(); iter.hasNext(); ) {
final String v = iter.next();
- choices.addItem(Format.format(constants.CallMethodOn0(), v), "CALL" + v); //NON-NLS
- cmds.put("CALL" + v, new Command() { //NON-NLS
+ choices.addItem( Format.format( constants.CallMethodOn0(),
+ v ),
+ "CALL" + v ); //NON-NLS
+ cmds.put( "CALL" + v,
+ new Command() { //NON-NLS
- public void execute() {
- addCallMethod(v, Integer.parseInt(positionCbo.getValue(positionCbo.getSelectedIndex())));
- popup.hide();
- }
- });
+ public void execute() {
+ addCallMethod( v,
+ Integer.parseInt( positionCbo.getValue( positionCbo.getSelectedIndex() ) ) );
+ popup.hide();
+ }
+ } );
}
}
-
//only show the drop down if we are not using fixed position.
- if (position == null) {
+ if ( position == null ) {
HorizontalPanel hp0 = new HorizontalPanel();
- hp0.add(new HTML(constants.PositionColon()));
- hp0.add(positionCbo);
- hp0.add(new InfoPopup(constants.PositionColon(), constants.ActionPositionExplanation()));
- popup.addRow(hp0);
+ hp0.add( new HTML( constants.PositionColon() ) );
+ hp0.add( positionCbo );
+ hp0.add( new InfoPopup( constants.PositionColon(),
+ constants.ActionPositionExplanation() ) );
+ popup.addRow( hp0 );
}
HorizontalPanel hp = new HorizontalPanel();
@@ -886,81 +1007,99 @@
public void onClick(Widget sender) {
int sel = choices.getSelectedIndex();
- if (sel != -1) {
- cmds.get(choices.getValue(sel)).execute();
+ if ( sel != -1 ) {
+ cmds.get( choices.getValue( sel ) ).execute();
}
}
};
- choices.addKeyboardListener(new KeyboardListenerAdapter() {
+ choices.addKeyboardListener( new KeyboardListenerAdapter() {
@Override
- public void onKeyUp(Widget sender, char keyCode, int modifiers) {
- if (keyCode == KeyboardListener.KEY_ENTER) {
- cl.onClick(sender);
+ public void onKeyUp(Widget sender,
+ char keyCode,
+ int modifiers) {
+ if ( keyCode == KeyboardListener.KEY_ENTER ) {
+ cl.onClick( sender );
}
}
- });
+ } );
- Button ok = new Button(constants.OK());
- ok.addClickListener(cl);
- hp.add(choices);
- hp.add(ok);
- popup.addRow(hp);
+ Button ok = new Button( constants.OK() );
+ ok.addClickListener( cl );
+ hp.add( choices );
+ hp.add( ok );
+ popup.addRow( hp );
popup.show();
- choices.setFocus(true);
+ choices.setFocus( true );
}
- protected void addModify(String itemText, int position) {
- this.model.addRhsItem(new ActionUpdateField(itemText), position);
+ protected void addModify(String itemText,
+ int position) {
+ this.model.addRhsItem( new ActionUpdateField( itemText ),
+ position );
refreshWidget();
}
- protected void addNewDSLRhs(DSLSentence sentence, int position) {
- this.model.addRhsItem(sentence.copy(), position);
+ protected void addNewDSLRhs(DSLSentence sentence,
+ int position) {
+ this.model.addRhsItem( sentence.copy(),
+ position );
refreshWidget();
}
- protected void addRetract(String var, int position) {
- this.model.addRhsItem(new ActionRetractFact(var), position);
+ protected void addRetract(String var,
+ int position) {
+ this.model.addRhsItem( new ActionRetractFact( var ),
+ position );
refreshWidget();
}
- protected void addActionSetField(String itemText, int position) {
- this.model.addRhsItem(new ActionSetField(itemText), position);
+ protected void addActionSetField(String itemText,
+ int position) {
+ this.model.addRhsItem( new ActionSetField( itemText ),
+ position );
refreshWidget();
}
- protected void addCallMethod(String itemText, int position) {
- this.model.addRhsItem(new ActionCallMethod(itemText), position);
+ protected void addCallMethod(String itemText,
+ int position) {
+ this.model.addRhsItem( new ActionCallMethod( itemText ),
+ position );
refreshWidget();
}
- protected void addNewCE(String s, int position) {
- this.model.addLhsItem(new CompositeFactPattern(s), position);
+ protected void addNewCE(String s,
+ int position) {
+ this.model.addLhsItem( new CompositeFactPattern( s ),
+ position );
refreshWidget();
}
- protected void addNewFCE(String type, int position) {
+ protected void addNewFCE(String type,
+ int position) {
FromCompositeFactPattern p = null;
- if (type.equals("from")) {
+ if ( type.equals( "from" ) ) {
p = new FromCompositeFactPattern();
- } else if (type.equals("from accumulate")) {
+ } else if ( type.equals( "from accumulate" ) ) {
p = new FromAccumulateCompositeFactPattern();
- } else if (type.equals("from collect")) {
+ } else if ( type.equals( "from collect" ) ) {
p = new FromCollectCompositeFactPattern();
}
- this.model.addLhsItem(p, position);
+ this.model.addLhsItem( p,
+ position );
refreshWidget();
}
/**
* Adds a fact to the model, and then refreshes the display.
*/
- protected void addNewFact(String itemText, int position) {
- this.model.addLhsItem(new FactPattern(itemText), position);
+ protected void addNewFact(String itemText,
+ int position) {
+ this.model.addLhsItem( new FactPattern( itemText ),
+ position );
refreshWidget();
}
@@ -969,64 +1108,84 @@
*/
private void renderLhs(final RuleModel model) {
-
- for (int i = 0; i < model.lhs.length; i++) {
+ for ( int i = 0; i < model.lhs.length; i++ ) {
DirtyableVerticalPane vert = new DirtyableVerticalPane();
- vert.setWidth("100%");
+ vert.setWidth( "100%" );
//if lockLHS() set the widget RO, otherwise let them decide.
- Boolean readOnly = this.lockLHS()?true:null;
+ Boolean readOnly = this.lockLHS() ? true : null;
IPattern pattern = model.lhs[i];
-
- RuleModellerWidget w = getWidgetFactory().getWidget(this, pattern, readOnly);
- w.addOnModifiedCommand(this.onWidgetModifiedCommand);
- vert.add(wrapLHSWidget(model, i, w));
- vert.add(spacerWidget());
+ RuleModellerWidget w = getWidgetFactory().getWidget( this,
+ pattern,
+ readOnly );
+ w.addOnModifiedCommand( this.onWidgetModifiedCommand );
+ vert.add( wrapLHSWidget( model,
+ i,
+ w ) );
+ vert.add( spacerWidget() );
- layout.setWidget(currentLayoutRow, 0, this.wrapLineNumber(i+1, true));
- layout.getFlexCellFormatter().setHorizontalAlignment(currentLayoutRow, 0, HasHorizontalAlignment.ALIGN_CENTER);
- layout.getFlexCellFormatter().setVerticalAlignment(currentLayoutRow, 0, HasVerticalAlignment.ALIGN_MIDDLE);
+ layout.setWidget( currentLayoutRow,
+ 0,
+ this.wrapLineNumber( i + 1,
+ true ) );
+ layout.getFlexCellFormatter().setHorizontalAlignment( currentLayoutRow,
+ 0,
+ HasHorizontalAlignment.ALIGN_CENTER );
+ layout.getFlexCellFormatter().setVerticalAlignment( currentLayoutRow,
+ 0,
+ HasVerticalAlignment.ALIGN_MIDDLE );
- layout.setWidget(currentLayoutRow, 1, vert);
- layout.getFlexCellFormatter().setHorizontalAlignment(currentLayoutRow, 1, HasHorizontalAlignment.ALIGN_LEFT);
- layout.getFlexCellFormatter().setVerticalAlignment(currentLayoutRow, 1, HasVerticalAlignment.ALIGN_TOP);
- layout.getFlexCellFormatter().setWidth(currentLayoutRow, 1, "100%");
+ layout.setWidget( currentLayoutRow,
+ 1,
+ vert );
+ layout.getFlexCellFormatter().setHorizontalAlignment( currentLayoutRow,
+ 1,
+ HasHorizontalAlignment.ALIGN_LEFT );
+ layout.getFlexCellFormatter().setVerticalAlignment( currentLayoutRow,
+ 1,
+ HasVerticalAlignment.ALIGN_TOP );
+ layout.getFlexCellFormatter().setWidth( currentLayoutRow,
+ 1,
+ "100%" );
final int index = i;
- if (!(this.lockLHS() || w.isReadOnly())) {
- this.addActionsButtonsToLayout(constants.AddAConditionBelow(), new ClickListener() {
+ if ( !(this.lockLHS() || w.isReadOnly()) ) {
+ this.addActionsButtonsToLayout( constants.AddAConditionBelow(),
+ new ClickListener() {
- public void onClick(Widget w) {
- showConditionSelector(w, index + 1);
- }
- },new ClickListener() {
+ public void onClick(Widget w) {
+ showConditionSelector( w,
+ index + 1 );
+ }
+ },
+ new ClickListener() {
- public void onClick(Widget sender) {
- model.moveLhsItemDown(index);
- refreshWidget();
- }
- },new ClickListener() {
+ public void onClick(Widget sender) {
+ model.moveLhsItemDown( index );
+ refreshWidget();
+ }
+ },
+ new ClickListener() {
- public void onClick(Widget sender) {
- model.moveLhsItemUp(index);
- refreshWidget();
- }
- });
+ public void onClick(Widget sender) {
+ model.moveLhsItemUp( index );
+ refreshWidget();
+ }
+ } );
}
-
- this.lhsWidgets.add(w);
+ this.lhsWidgets.add( w );
currentLayoutRow++;
}
}
private HTML spacerWidget() {
- HTML h = new HTML(" "); //NON-NLS
- h.setHeight("2px"); //NON-NLS
+ HTML h = new HTML( " " ); //NON-NLS
+ h.setHeight( "2px" ); //NON-NLS
return h;
}
@@ -1034,125 +1193,139 @@
* This adds the widget to the UI, also adding the remove icon.
*/
private Widget wrapLHSWidget(final RuleModel model,
- int i,
- RuleModellerWidget w) {
+ int i,
+ RuleModellerWidget w) {
DirtyableHorizontalPane horiz = new DirtyableHorizontalPane();
- final Image remove = new ImageButton("images/delete_item_small.gif"); //NON-NLS
- remove.setTitle(constants.RemoveThisENTIREConditionAndAllTheFieldConstraintsThatBelongToIt());
+ final Image remove = new ImageButton( "images/delete_item_small.gif" ); //NON-NLS
+ remove.setTitle( constants.RemoveThisENTIREConditionAndAllTheFieldConstraintsThatBelongToIt() );
final int idx = i;
- remove.addClickHandler(new ClickHandler() {
-
- public void onClick(ClickEvent event) {
- if (Window.confirm(constants.RemoveThisEntireConditionQ())) {
- if (model.removeLhsItem(idx)) {
+ remove.addClickHandler( new ClickHandler() {
+
+ public void onClick(ClickEvent event) {
+ if ( Window.confirm( constants.RemoveThisEntireConditionQ() ) ) {
+ if ( model.removeLhsItem( idx ) ) {
refreshWidget();
} else {
- ErrorPopup.showMessage(constants.CanTRemoveThatItemAsItIsUsedInTheActionPartOfTheRule());
+ ErrorPopup.showMessage( constants.CanTRemoveThatItemAsItIsUsedInTheActionPartOfTheRule() );
}
}
}
- });
+ } );
- horiz.setWidth("100%");
- w.setWidth("100%");
+ horiz.setWidth( "100%" );
+ w.setWidth( "100%" );
- horiz.add(w);
- if (!(this.lockLHS() || w.isReadOnly())) {
- horiz.add(remove);
+ horiz.add( w );
+ if ( !(this.lockLHS() || w.isReadOnly()) ) {
+ horiz.add( remove );
}
return horiz;
}
- private Widget wrapLineNumber(int number, boolean isLHSLine){
+ private Widget wrapLineNumber(int number,
+ boolean isLHSLine) {
String id = "rhsLine";
- if (isLHSLine){
- id="lhsLine";
+ if ( isLHSLine ) {
+ id = "lhsLine";
}
- id+=number;
+ id += number;
DirtyableHorizontalPane horiz = new DirtyableHorizontalPane();
- horiz.add(new HTML("<div class='x-form-field' id='"+id+"'>" + number + ".</div>"));
+ horiz.add( new HTML( "<div class='x-form-field' id='" + id + "'>" + number + ".</div>" ) );
return horiz;
}
- private void addLineIcon(int row, String img, String title){
- Widget widget = layout.getWidget(row, 0);
- if (widget instanceof DirtyableHorizontalPane){
- DirtyableHorizontalPane horiz = (DirtyableHorizontalPane)widget;
- final Image icon = new ImageButton(img);
- icon.setTitle(title);
- horiz.add(icon);
+ private void addLineIcon(int row,
+ String img,
+ String title) {
+ Widget widget = layout.getWidget( row,
+ 0 );
+ if ( widget instanceof DirtyableHorizontalPane ) {
+ DirtyableHorizontalPane horiz = (DirtyableHorizontalPane) widget;
+ final Image icon = new ImageButton( img );
+ icon.setTitle( title );
+ horiz.add( icon );
}
}
- private void clearLineIcons(int row){
- if (layout.getCellCount(row)<=0){
+ private void clearLineIcons(int row) {
+ if ( layout.getCellCount( row ) <= 0 ) {
return;
}
- Widget widget = layout.getWidget(row, 0);
- if (widget instanceof DirtyableHorizontalPane){
- DirtyableHorizontalPane horiz = (DirtyableHorizontalPane)widget;
- while (horiz.getWidgetCount() > 1){
- horiz.remove(horiz.getWidgetCount()-1);
+ Widget widget = layout.getWidget( row,
+ 0 );
+ if ( widget instanceof DirtyableHorizontalPane ) {
+ DirtyableHorizontalPane horiz = (DirtyableHorizontalPane) widget;
+ while ( horiz.getWidgetCount() > 1 ) {
+ horiz.remove( horiz.getWidgetCount() - 1 );
}
}
}
- private void clearLinesIcons(){
- for (int i = 0; i < layout.getRowCount(); i++) {
- this.clearLineIcons(i);
+ private void clearLinesIcons() {
+ for ( int i = 0; i < layout.getRowCount(); i++ ) {
+ this.clearLineIcons( i );
}
}
- private void addActionsButtonsToLayout(String title, ClickListener addBelowListener, ClickListener moveDownListener, ClickListener moveUpListener) {
+ private void addActionsButtonsToLayout(String title,
+ ClickListener addBelowListener,
+ ClickListener moveDownListener,
+ ClickListener moveUpListener) {
DirtyableHorizontalPane hp = new DirtyableHorizontalPane();
- Image addPattern = new ImageButton("images/new_item_below.png");
- addPattern.setTitle(title);
- addPattern.addClickListener(addBelowListener);
+ Image addPattern = new ImageButton( "images/new_item_below.png" );
+ addPattern.setTitle( title );
+ addPattern.addClickListener( addBelowListener );
- Image moveDown = new ImageButton("images/shuffle_down.gif");
- moveDown.setTitle(constants.MoveDown());
- moveDown.addClickListener(moveDownListener);
+ Image moveDown = new ImageButton( "images/shuffle_down.gif" );
+ moveDown.setTitle( constants.MoveDown() );
+ moveDown.addClickListener( moveDownListener );
- Image moveUp = new ImageButton("images/shuffle_up.gif");
- moveUp.setTitle(constants.MoveUp());
- moveUp.addClickListener(moveUpListener);
-
- hp.add(addPattern);
- hp.add(moveDown);
- hp.add(moveUp);
+ Image moveUp = new ImageButton( "images/shuffle_up.gif" );
+ moveUp.setTitle( constants.MoveUp() );
+ moveUp.addClickListener( moveUpListener );
+ hp.add( addPattern );
+ hp.add( moveDown );
+ hp.add( moveUp );
+ final ExtElement e = new ExtElement( hp.getElement() );
+ e.setOpacity( 0.1f,
+ false );
- final ExtElement e = new ExtElement(hp.getElement());
- e.setOpacity(0.1f, false);
+ FocusPanel actionPanel = new FocusPanel( hp );
- FocusPanel actionPanel = new FocusPanel(hp);
-
MouseListenerAdapter mouseListenerAdapter = new MouseListenerAdapter() {
@Override
public void onMouseEnter(Widget sender) {
- e.setOpacity(1, false);
+ e.setOpacity( 1,
+ false );
}
@Override
public void onMouseLeave(Widget sender) {
- e.setOpacity(0.1f, false);
+ e.setOpacity( 0.1f,
+ false );
}
};
+ actionPanel.addMouseListener( mouseListenerAdapter );
- actionPanel.addMouseListener(mouseListenerAdapter);
-
- layout.setWidget(currentLayoutRow, 2, actionPanel);
- layout.getFlexCellFormatter().setHorizontalAlignment(currentLayoutRow, 2, HasHorizontalAlignment.ALIGN_CENTER);
- layout.getFlexCellFormatter().setVerticalAlignment(currentLayoutRow, 2, HasVerticalAlignment.ALIGN_MIDDLE);
+ layout.setWidget( currentLayoutRow,
+ 2,
+ actionPanel );
+ layout.getFlexCellFormatter().setHorizontalAlignment( currentLayoutRow,
+ 2,
+ HasHorizontalAlignment.ALIGN_CENTER );
+ layout.getFlexCellFormatter().setVerticalAlignment( currentLayoutRow,
+ 2,
+ HasVerticalAlignment.ALIGN_MIDDLE );
}
public RuleModel getModel() {
@@ -1164,8 +1337,8 @@
* either by the rule, or as a global.
*/
public boolean isVariableNameUsed(String name) {
- SuggestionCompletionEngine completions = SuggestionCompletionCache.getInstance().getEngineFromCache(packageName);
- return model.isVariableNameUsed(name) || completions.isGlobalVariable(name);
+ SuggestionCompletionEngine completions = SuggestionCompletionCache.getInstance().getEngineFromCache( packageName );
+ return model.isVariableNameUsed( name ) || completions.isGlobalVariable( name );
}
@Override
@@ -1174,118 +1347,122 @@
}
public SuggestionCompletionEngine getSuggestionCompletions() {
- return SuggestionCompletionCache.getInstance().getEngineFromCache(packageName);
+ return SuggestionCompletionCache.getInstance().getEngineFromCache( packageName );
}
-
private List<AnalysisReportLine> errors;
private List<AnalysisReportLine> warnings;
- public void verifyRule(final Command cmd){
- this.verifyRule(cmd, false);
+ public void verifyRule(final Command cmd) {
+ this.verifyRule( cmd,
+ false );
}
- public void verifyRule(final Command cmd, boolean forceVerification){
+ public void verifyRule(final Command cmd,
+ boolean forceVerification) {
errors = new ArrayList<AnalysisReportLine>();
warnings = new ArrayList<AnalysisReportLine>();
-
+
//if AutoVerifierEnabled is off or there are not modified widgets,
//just execute cmd and return.
- if (!forceVerification && (!WorkingSetManager.getInstance().isAutoVerifierEnabled() || !this.hasModifiedWidgets)){
- if (cmd != null){
+ if ( !forceVerification && (!WorkingSetManager.getInstance().isAutoVerifierEnabled() || !this.hasModifiedWidgets) ) {
+ if ( cmd != null ) {
cmd.execute();
}
return;
}
- LoadingPopup.showMessage(constants.VerifyingItemPleaseWait());
- Set<String> activeWorkingSets = WorkingSetManager.getInstance().getActiveAssetUUIDs(asset.metaData.packageName);
-
+ LoadingPopup.showMessage( constants.VerifyingItemPleaseWait() );
+ Set<String> activeWorkingSets = WorkingSetManager.getInstance().getActiveAssetUUIDs( asset.metaData.packageName );
+
VerificationServiceAsync verificationService = GWT.create( VerificationService.class );
-
- verificationService.verifyAssetWithoutVerifiersRules(this.asset, activeWorkingSets,
- new AsyncCallback<AnalysisReport>() {
- public void onSuccess(AnalysisReport report) {
- LoadingPopup.close();
-
- errors = Arrays.asList(report.errors);
- warnings = Arrays.asList(report.warnings);
+ verificationService.verifyAssetWithoutVerifiersRules( this.asset,
+ activeWorkingSets,
+ new AsyncCallback<AnalysisReport>() {
- processWarningsAndErrors();
+ public void onSuccess(AnalysisReport report) {
+ LoadingPopup.close();
+ errors = Arrays.asList( report.errors );
+ warnings = Arrays.asList( report.warnings );
- hasModifiedWidgets = false;
- if (cmd != null) {
- cmd.execute();
- }
- }
+ processWarningsAndErrors();
- public void onFailure(Throwable arg0) {
- LoadingPopup.close();
- }
- });
+ hasModifiedWidgets = false;
+ if ( cmd != null ) {
+ cmd.execute();
+ }
+ }
+ public void onFailure(Throwable arg0) {
+ LoadingPopup.close();
+ }
+ } );
+
}
- private void processWarningsAndErrors(){
-
- if (this.warnings.isEmpty() && this.errors.isEmpty()){
- for (RuleModellerWidget ruleModellerWidget : this.lhsWidgets) {
- ruleModellerWidget.setModified(false);
+ private void processWarningsAndErrors() {
+
+ if ( this.warnings.isEmpty() && this.errors.isEmpty() ) {
+ for ( RuleModellerWidget ruleModellerWidget : this.lhsWidgets ) {
+ ruleModellerWidget.setModified( false );
}
- for (RuleModellerWidget ruleModellerWidget : this.rhsWidgets) {
- ruleModellerWidget.setModified(false);
+ for ( RuleModellerWidget ruleModellerWidget : this.rhsWidgets ) {
+ ruleModellerWidget.setModified( false );
}
}
showWarningsAndErrors();
}
- private void showWarningsAndErrors(){
+ private void showWarningsAndErrors() {
this.clearLinesIcons();
- if (this.warnings != null){
- for (AnalysisReportLine warning : this.warnings) {
- if (warning.patternOrderNumber != null){
- this.addLineIcon(warning.patternOrderNumber+1, "images/warning.gif", warning.description);
+ if ( this.warnings != null ) {
+ for ( AnalysisReportLine warning : this.warnings ) {
+ if ( warning.patternOrderNumber != null ) {
+ this.addLineIcon( warning.patternOrderNumber + 1,
+ "images/warning.gif",
+ warning.description );
}
}
}
- if (this.errors != null){
- for (AnalysisReportLine error : this.errors) {
- if (error.patternOrderNumber != null){
- this.addLineIcon(error.patternOrderNumber+1, "images/error.gif", error.description);
+ if ( this.errors != null ) {
+ for ( AnalysisReportLine error : this.errors ) {
+ if ( error.patternOrderNumber != null ) {
+ this.addLineIcon( error.patternOrderNumber + 1,
+ "images/error.gif",
+ error.description );
}
}
}
}
- public boolean hasVerifierErrors(){
+ public boolean hasVerifierErrors() {
return this.errors != null && this.errors.size() > 0;
}
- public boolean hasVerifierWarnings(){
+ public boolean hasVerifierWarnings() {
return this.warnings != null && this.warnings.size() > 0;
}
- public ModellerWidgetFactory getWidgetFactory() {
- return widgetFactory;
- }
+ public ModellerWidgetFactory getWidgetFactory() {
+ return widgetFactory;
+ }
- public void setWidgetFactory(ModellerWidgetFactory widgetFactory) {
- this.widgetFactory = widgetFactory;
- }
+ public void setWidgetFactory(ModellerWidgetFactory widgetFactory) {
+ this.widgetFactory = widgetFactory;
+ }
- public RuleModeller getRuleModeller() {
- return this;
- }
+ public RuleModeller getRuleModeller() {
+ return this;
+ }
- public boolean isTemplate() {
- return widgetFactory.isTemplate();
- }
+ public boolean isTemplate() {
+ return widgetFactory.isTemplate();
+ }
public RuleAsset getAsset() {
return asset;
}
-
}
Modified: labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/modeldriven/ui/RuleTemplateEditor.java
===================================================================
--- labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/modeldriven/ui/RuleTemplateEditor.java 2010-10-01 06:58:15 UTC (rev 35375)
+++ labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/modeldriven/ui/RuleTemplateEditor.java 2010-10-01 07:40:28 UTC (rev 35376)
@@ -57,163 +57,188 @@
import com.gwtext.client.widgets.menu.Menu;
import com.gwtext.client.widgets.menu.event.BaseItemListenerAdapter;
-public class RuleTemplateEditor extends DirtyableComposite implements RuleModelEditor {
+public class RuleTemplateEditor extends DirtyableComposite
+ implements
+ RuleModelEditor {
- private TemplateModel model;
- private GroupingStore store = null;
- private EditorGridPanel grid = null;
- private RuleModeller ruleModeller;
- private Constants constants = ((Constants) GWT.create(Constants.class));
-
- public RuleTemplateEditor(RuleAsset asset) {
- model = (TemplateModel) asset.content;
+ private TemplateModel model;
+ private GroupingStore store = null;
+ private EditorGridPanel grid = null;
+ private RuleModeller ruleModeller;
+ private Constants constants = ((Constants) GWT.create( Constants.class ));
- final VerticalPanel tPanel = new VerticalPanel();
- tPanel.setWidth("100%");
- ruleModeller = new RuleModeller(asset, new TemplateModellerWidgetFactory());
-
- tPanel.add(new Button(constants.LoadTemplateData(), new ClickHandler() {
-
- public void onClick(ClickEvent event) {
- final FormStylePopup popUp = new FormStylePopup(null, constants.TemplateData(), (int) (Window.getClientWidth() * 0.8) );
- popUp.setHeight((int) (Window.getClientHeight() * 0.8));
- popUp.addAttribute("", buildTemplateTable());
- Button close = new Button(constants.Close(), new ClickHandler() {
- public void onClick(ClickEvent event) {
- popUp.hide();
- }
- });
- HorizontalPanel pnlClose = new HorizontalPanel();
- pnlClose.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_RIGHT);
- pnlClose.add(close);
- popUp.addAttribute("", pnlClose);
-
- popUp.show();
- }
- }));
- tPanel.add(ruleModeller);
- initWidget(tPanel);
- }
+ public RuleTemplateEditor(RuleAsset asset) {
+ model = (TemplateModel) asset.content;
- private Widget buildTemplateTable() {
+ final VerticalPanel tPanel = new VerticalPanel();
+ tPanel.setWidth( "100%" );
+ ruleModeller = new RuleModeller( asset,
+ new TemplateModellerWidgetFactory() );
- String[] vars = model.getInterpolationVariablesList();
- if (vars.length == 0) {
- return new Label("");
- }
+ tPanel.add( new Button( constants.LoadTemplateData(),
+ new ClickHandler() {
- FieldDef[] fds = new FieldDef[vars.length];
- ColumnConfig[] cols = new ColumnConfig[fds.length];
+ public void onClick(ClickEvent event) {
+ final FormStylePopup popUp = new FormStylePopup( null,
+ constants.TemplateData(),
+ (int) (Window.getClientWidth() * 0.8) );
+ popUp.setHeight( ((int) (Window.getClientHeight() * 0.8)) + "px" );
+ popUp.addAttribute( "",
+ buildTemplateTable() );
+ Button close = new Button( constants.Close(),
+ new ClickHandler() {
+ public void onClick(ClickEvent event) {
+ popUp.hide();
+ }
+ } );
+ HorizontalPanel pnlClose = new HorizontalPanel();
+ pnlClose.setHorizontalAlignment( HasHorizontalAlignment.ALIGN_RIGHT );
+ pnlClose.add( close );
+ popUp.addAttribute( "",
+ pnlClose );
- int idx = 0;
- for (String var: vars) {
- cols[idx] = new ColumnConfig();
- cols[idx].setHeader(var);
- cols[idx].setDataIndex(var);
- cols[idx].setSortable(false);
- cols[idx].setWidth(50);
- cols[idx].setResizable(true);
- cols[idx].setEditor(new GridEditor(new TextField()));
- fds[idx] = new StringFieldDef(var);
- idx++;
- }
- final RecordDef recordDef = new RecordDef(fds);
- ArrayReader reader = new ArrayReader(recordDef);
-
- MemoryProxy proxy = new MemoryProxy(model.getTableAsArray());
+ popUp.show();
+ }
+ } ) );
+ tPanel.add( ruleModeller );
+ initWidget( tPanel );
+ }
- ColumnModel cm = new ColumnModel(cols);
-
- for (int i = 0; i < cm.getColumnCount(); i++) {
- cm.setEditable(i, true);
- }
- store = new GroupingStore(proxy, reader);
- store.load();
- grid = new EditorGridPanel(store, cm);
- grid.setStripeRows(true);
+ private Widget buildTemplateTable() {
-// GroupingView gv = new GroupingView();
- GridView gv = new GridView();
+ String[] vars = model.getInterpolationVariablesList();
+ if ( vars.length == 0 ) {
+ return new Label( "" );
+ }
- // to stretch it out
- gv.setForceFit(true);
-// gv.setGroupTextTpl("{text} ({[values.rs.length]} {[values.rs.length > 1 ? \"" // NON-NLS
-// + constants.Items() + "\" : \"" + constants.Item() + "\"]})");
+ FieldDef[] fds = new FieldDef[vars.length];
+ ColumnConfig[] cols = new ColumnConfig[fds.length];
- grid.setView(gv);
+ int idx = 0;
+ for ( String var : vars ) {
+ cols[idx] = new ColumnConfig();
+ cols[idx].setHeader( var );
+ cols[idx].setDataIndex( var );
+ cols[idx].setSortable( false );
+ cols[idx].setWidth( 50 );
+ cols[idx].setResizable( true );
+ cols[idx].setEditor( new GridEditor( new TextField() ) );
+ fds[idx] = new StringFieldDef( var );
+ idx++;
+ }
+ final RecordDef recordDef = new RecordDef( fds );
+ ArrayReader reader = new ArrayReader( recordDef );
- grid.setStore(store);
- grid.setAutoWidth(true);
- grid.setAutoHeight(true);
+ MemoryProxy proxy = new MemoryProxy( model.getTableAsArray() );
- Toolbar tb = new Toolbar();
- Menu menu = new Menu();
+ ColumnModel cm = new ColumnModel( cols );
- menu.addItem(new Item(constants.AddRow(), new BaseItemListenerAdapter() {
- public void onClick(BaseItem item, EventObject e) {
- String[] rowData = new String[recordDef.getFields().length];
- for (int i = 0; i < rowData.length; i++) {
- rowData[i] = "";
- }
- Record newRecord = recordDef.createRecord(rowData);
- store.add(newRecord);
- model.addRow(newRecord.getId(), rowData);
- }
- }));
-
- menu.addItem(new Item(constants.RemoveSelectedRowS(), new BaseItemListenerAdapter() {
- public void onClick(BaseItem item, EventObject e) {
- removeSelectedRows(grid);
- }
- }));
-
- grid.addGridListener(new GridListenerAdapter() {
-
- public void onKeyPress(EventObject e) {
- int k = e.getKey();
- if (k == KeyCodes.KEY_DELETE || k == KeyCodes.KEY_BACKSPACE) {
- removeSelectedRows(grid);
- }
- else if (k == KeyCodes.KEY_ENTER) {
- int[] selectedCell = grid.getCellSelectionModel().getSelectedCell();
- grid.startEditing(selectedCell[0], selectedCell[1]);
- }
- }
- });
-// grid.setSelectionModel(new RowSelectionModel(false));
- ToolbarMenuButton tbb = new ToolbarMenuButton(constants.Modify(), menu);
- tb.addButton(tbb);
- grid.add(tb);
-
- grid.addEditorGridListener(new EditorGridListenerAdapter() {
- @Override
- public void onAfterEdit(GridPanel grid, Record record, String field, Object newValue, Object oldValue,
- int rowIndex, int colIndex) {
- model.setValue(field, rowIndex, (String) newValue);
- }
- });
- grid.setWidth((int) (Window.getClientWidth() * 0.75));
- return grid;
- }
-
- private void removeSelectedRows(EditorGridPanel grid) {
- if (com.google.gwt.user.client.Window.confirm(constants.AreYouSureYouWantToDeleteTheSelectedRowS())) {
- int row = grid.getCellSelectionModel().getSelectedCell()[0];
- Record rec = store.getAt(row);
- model.removeRowById(rec.getId());
- store.remove(rec);
- }
- }
-
- @Override
- public void resetDirty() {
- super.resetDirty();
- if (store != null) {
- store.commitChanges();
- }
- }
+ for ( int i = 0; i < cm.getColumnCount(); i++ ) {
+ cm.setEditable( i,
+ true );
+ }
+ store = new GroupingStore( proxy,
+ reader );
+ store.load();
+ grid = new EditorGridPanel( store,
+ cm );
+ grid.setStripeRows( true );
- public RuleModeller getRuleModeller() {
- return ruleModeller;
- }
+ // GroupingView gv = new GroupingView();
+ GridView gv = new GridView();
+
+ // to stretch it out
+ gv.setForceFit( true );
+ // gv.setGroupTextTpl("{text} ({[values.rs.length]} {[values.rs.length > 1 ? \"" // NON-NLS
+ // + constants.Items() + "\" : \"" + constants.Item() + "\"]})");
+
+ grid.setView( gv );
+
+ grid.setStore( store );
+ grid.setAutoWidth( true );
+ grid.setAutoHeight( true );
+
+ Toolbar tb = new Toolbar();
+ Menu menu = new Menu();
+
+ menu.addItem( new Item( constants.AddRow(),
+ new BaseItemListenerAdapter() {
+ public void onClick(BaseItem item,
+ EventObject e) {
+ String[] rowData = new String[recordDef.getFields().length];
+ for ( int i = 0; i < rowData.length; i++ ) {
+ rowData[i] = "";
+ }
+ Record newRecord = recordDef.createRecord( rowData );
+ store.add( newRecord );
+ model.addRow( newRecord.getId(),
+ rowData );
+ }
+ } ) );
+
+ menu.addItem( new Item( constants.RemoveSelectedRowS(),
+ new BaseItemListenerAdapter() {
+ public void onClick(BaseItem item,
+ EventObject e) {
+ removeSelectedRows( grid );
+ }
+ } ) );
+
+ grid.addGridListener( new GridListenerAdapter() {
+
+ public void onKeyPress(EventObject e) {
+ int k = e.getKey();
+ if ( k == KeyCodes.KEY_DELETE || k == KeyCodes.KEY_BACKSPACE ) {
+ removeSelectedRows( grid );
+ } else if ( k == KeyCodes.KEY_ENTER ) {
+ int[] selectedCell = grid.getCellSelectionModel().getSelectedCell();
+ grid.startEditing( selectedCell[0],
+ selectedCell[1] );
+ }
+ }
+ } );
+ // grid.setSelectionModel(new RowSelectionModel(false));
+ ToolbarMenuButton tbb = new ToolbarMenuButton( constants.Modify(),
+ menu );
+ tb.addButton( tbb );
+ grid.add( tb );
+
+ grid.addEditorGridListener( new EditorGridListenerAdapter() {
+ @Override
+ public void onAfterEdit(GridPanel grid,
+ Record record,
+ String field,
+ Object newValue,
+ Object oldValue,
+ int rowIndex,
+ int colIndex) {
+ model.setValue( field,
+ rowIndex,
+ (String) newValue );
+ }
+ } );
+ grid.setWidth( (int) (Window.getClientWidth() * 0.75) );
+ return grid;
+ }
+
+ private void removeSelectedRows(EditorGridPanel grid) {
+ if ( com.google.gwt.user.client.Window.confirm( constants.AreYouSureYouWantToDeleteTheSelectedRowS() ) ) {
+ int row = grid.getCellSelectionModel().getSelectedCell()[0];
+ Record rec = store.getAt( row );
+ model.removeRowById( rec.getId() );
+ store.remove( rec );
+ }
+ }
+
+ @Override
+ public void resetDirty() {
+ super.resetDirty();
+ if ( store != null ) {
+ store.commitChanges();
+ }
+ }
+
+ public RuleModeller getRuleModeller() {
+ return ruleModeller;
+ }
}
Modified: labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/modeldriven/ui/factPattern/PopupCreator.java
===================================================================
--- labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/modeldriven/ui/factPattern/PopupCreator.java 2010-10-01 06:58:15 UTC (rev 35375)
+++ labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/modeldriven/ui/factPattern/PopupCreator.java 2010-10-01 07:40:28 UTC (rev 35376)
@@ -116,7 +116,7 @@
String[] fields,
final PopupCreator popupCreator) {
final FormStylePopup popup = new FormStylePopup();
- popup.setWidth( 500 );
+ popup.setWidth( 500 + "px" );
final HorizontalPanel vn = new HorizontalPanel();
final TextBox varName = new TextBox();
final Button ok = new Button( constants.Set() );
@@ -240,8 +240,8 @@
box.addClickHandler( new ClickHandler() {
public void onClick(ClickEvent event) {
String fieldName = box.getItemText( box.getSelectedIndex() );
- if ("...".equals(fieldName)) {
- return;
+ if ( "...".equals( fieldName ) ) {
+ return;
}
String qualifiedName = factType + "." + fieldName;
String fieldType = completions.getFieldType( qualifiedName );
Modified: labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/packages/AssetAttachmentFileWidget.java
===================================================================
--- labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/packages/AssetAttachmentFileWidget.java 2010-10-01 06:58:15 UTC (rev 35375)
+++ labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/packages/AssetAttachmentFileWidget.java 2010-10-01 07:40:28 UTC (rev 35376)
@@ -1,4 +1,4 @@
-/**
+/*
* Copyright 2010 JBoss Inc
*
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -16,22 +16,6 @@
package org.drools.guvnor.client.packages;
-/*
- * Copyright 2005 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.
- */
-
import org.drools.guvnor.client.common.ErrorPopup;
import org.drools.guvnor.client.common.FormStyleLayout;
import org.drools.guvnor.client.common.HTMLFileManagerFields;
Modified: labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/packages/PackageHeaderWidget.java
===================================================================
--- labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/packages/PackageHeaderWidget.java 2010-10-01 06:58:15 UTC (rev 35375)
+++ labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/packages/PackageHeaderWidget.java 2010-10-01 07:40:28 UTC (rev 35376)
@@ -49,279 +49,291 @@
* @author Michael Neale
*/
public class PackageHeaderWidget extends Composite {
- private PackageConfigData conf;
- private SimplePanel layout;
- private ListBox importList;
- private ListBox globalList;
- private Constants constants = ((Constants) GWT.create(Constants.class));
+ private PackageConfigData conf;
+ private SimplePanel layout;
+ private ListBox importList;
+ private ListBox globalList;
+ private Constants constants = ((Constants) GWT.create( Constants.class ));
-
public PackageHeaderWidget(PackageConfigData conf) {
- this.conf = conf;
- layout = new SimplePanel();
- render();
+ this.conf = conf;
+ layout = new SimplePanel();
+ render();
- initWidget(layout);
- }
+ initWidget( layout );
+ }
- private void render() {
- final Types t = PackageHeaderHelper.parseHeader(conf.header);
- if (t == null) {
- textEditorVersion();
- } else {
- basicEditorVersion(t);
- }
- }
-
- private void basicEditorVersion(final Types t) {
- layout.clear();
- HorizontalPanel main = new HorizontalPanel();
+ private void render() {
+ final Types t = PackageHeaderHelper.parseHeader( conf.header );
+ if ( t == null ) {
+ textEditorVersion();
+ } else {
+ basicEditorVersion( t );
+ }
+ }
- VerticalPanel imports = new VerticalPanel();
- imports.add(new Label(constants.ImportedTypes()));
- importList = new ListBox(true);
+ private void basicEditorVersion(final Types t) {
+ layout.clear();
+ HorizontalPanel main = new HorizontalPanel();
- doImports(t);
- HorizontalPanel importCols = new HorizontalPanel();
- importCols.add(importList);
- VerticalPanel importActions = new VerticalPanel();
- importActions.add(new ImageButton("images/new_item.gif") { //NON-NLS
- {
- addClickListener(new ClickListener() {
- public void onClick(Widget w) {
- showTypeQuestion(w, t, false, constants.FactTypesJarTip());
- }
- });
- }
- });
- importActions.add(new ImageButton("images/trash.gif") { //NON-NLS
- {
- addClickListener(new ClickListener() {
- public void onClick(Widget w) {
- if (Window.confirm(constants.AreYouSureYouWantToRemoveThisFactType())) {
- int i = importList.getSelectedIndex();
- importList.removeItem(i);
- t.imports.remove(i);
- updateHeader(t);
- }
- }
- });
- }
- });
+ VerticalPanel imports = new VerticalPanel();
+ imports.add( new Label( constants.ImportedTypes() ) );
+ importList = new ListBox( true );
- importCols.add(importActions);
- imports.add(importCols);
+ doImports( t );
+ HorizontalPanel importCols = new HorizontalPanel();
+ importCols.add( importList );
+ VerticalPanel importActions = new VerticalPanel();
+ importActions.add( new ImageButton( "images/new_item.gif" ) { //NON-NLS
+ {
+ addClickListener( new ClickListener() {
+ public void onClick(Widget w) {
+ showTypeQuestion( w,
+ t,
+ false,
+ constants.FactTypesJarTip() );
+ }
+ } );
+ }
+ } );
+ importActions.add( new ImageButton( "images/trash.gif" ) { //NON-NLS
+ {
+ addClickListener( new ClickListener() {
+ public void onClick(Widget w) {
+ if ( Window.confirm( constants.AreYouSureYouWantToRemoveThisFactType() ) ) {
+ int i = importList.getSelectedIndex();
+ importList.removeItem( i );
+ t.imports.remove( i );
+ updateHeader( t );
+ }
+ }
+ } );
+ }
+ } );
+ importCols.add( importActions );
+ imports.add( importCols );
- VerticalPanel globals = new VerticalPanel();
- globals.add(new Label(constants.Globals()));
- globalList = new ListBox(true);
- doGlobals(t);
- HorizontalPanel globalCols = new HorizontalPanel();
- globalCols.add(globalList);
- VerticalPanel globalActions = new VerticalPanel();
- globalActions.add(new ImageButton("images/new_item.gif") { //NON-NLS
- {
- addClickListener(new ClickListener() {
- public void onClick(Widget w) {
- showTypeQuestion(w, t, true, constants.GlobalTypesAreClassesFromJarFilesThatHaveBeenUploadedToTheCurrentPackage());
- }
- });
- }
- });
- globalActions.add(new ImageButton("images/trash.gif") { //NON-NLS
- {
- addClickListener(new ClickListener() {
- public void onClick(Widget w) {
- if (Window.confirm(constants.AreYouSureYouWantToRemoveThisGlobal())) {
- int i = globalList.getSelectedIndex();
- globalList.removeItem(i);
- t.globals.remove(i);
- updateHeader(t);
- }
- }
- });
- }
- });
- globalCols.add(globalActions);
- globals.add(globalCols);
+ VerticalPanel globals = new VerticalPanel();
+ globals.add( new Label( constants.Globals() ) );
+ globalList = new ListBox( true );
+ doGlobals( t );
+ HorizontalPanel globalCols = new HorizontalPanel();
+ globalCols.add( globalList );
+ VerticalPanel globalActions = new VerticalPanel();
+ globalActions.add( new ImageButton( "images/new_item.gif" ) { //NON-NLS
+ {
+ addClickListener( new ClickListener() {
+ public void onClick(Widget w) {
+ showTypeQuestion( w,
+ t,
+ true,
+ constants.GlobalTypesAreClassesFromJarFilesThatHaveBeenUploadedToTheCurrentPackage() );
+ }
+ } );
+ }
+ } );
+ globalActions.add( new ImageButton( "images/trash.gif" ) { //NON-NLS
+ {
+ addClickListener( new ClickListener() {
+ public void onClick(Widget w) {
+ if ( Window.confirm( constants.AreYouSureYouWantToRemoveThisGlobal() ) ) {
+ int i = globalList.getSelectedIndex();
+ globalList.removeItem( i );
+ t.globals.remove( i );
+ updateHeader( t );
+ }
+ }
+ } );
+ }
+ } );
+ globalCols.add( globalActions );
+ globals.add( globalCols );
- main.add(imports);
- main.add(new HTML(" ")); //NON-NLS
- main.add(globals);
+ main.add( imports );
+ main.add( new HTML( " " ) ); //NON-NLS
+ main.add( globals );
- Button advanced = new Button() {
- {
- setText(constants.AdvancedView());
- setTitle(constants.SwitchToTextModeEditing());
- addClickListener(new ClickListener() {
- public void onClick(Widget w) {
- if (Window.confirm(constants.SwitchToAdvancedTextModeForPackageEditing())) {
- textEditorVersion();
- }
- }
- });
- }
- };
- main.add(advanced);
+ Button advanced = new Button() {
+ {
+ setText( constants.AdvancedView() );
+ setTitle( constants.SwitchToTextModeEditing() );
+ addClickListener( new ClickListener() {
+ public void onClick(Widget w) {
+ if ( Window.confirm( constants.SwitchToAdvancedTextModeForPackageEditing() ) ) {
+ textEditorVersion();
+ }
+ }
+ } );
+ }
+ };
+ main.add( advanced );
- layout.add(main);
- }
+ layout.add( main );
+ }
- private void textEditorVersion() {
- layout.clear();
-
+ private void textEditorVersion() {
+ layout.clear();
+
VerticalPanel main = new VerticalPanel();
-
- final TextArea area = new TextArea();
- area.setWidth( "100%" );
- area.setVisibleLines( 8 );
- area.setCharacterWidth( 100 );
+ final TextArea area = new TextArea();
+ area.setWidth( "100%" );
+ area.setVisibleLines( 8 );
- area.setText( this.conf.header );
- area.addChangeListener( new ChangeListener() {
- public void onChange(Widget w) {
- conf.header = area.getText();
- }
- });
+ area.setCharacterWidth( 100 );
+ area.setText( this.conf.header );
+ area.addChangeListener( new ChangeListener() {
+ public void onChange(Widget w) {
+ conf.header = area.getText();
+ }
+ } );
+
main.add( area );
-
+
Button basicMode = new Button() {
{
- setText(constants.BasicView());
- setTitle(constants.SwitchToGuidedModeEditing());
- addClickListener(new ClickListener() {
+ setText( constants.BasicView() );
+ setTitle( constants.SwitchToGuidedModeEditing() );
+ addClickListener( new ClickListener() {
public void onClick(Widget w) {
conf.header = area.getText();
- final Types t = PackageHeaderHelper.parseHeader(conf.header);
- if (t == null) {
- Window.alert(constants.CanNotSwitchToBasicView());
- } else {
- if (Window.confirm(constants.SwitchToGuidedModeForPackageEditing())) {
- basicEditorVersion(t);
- }
- }
+ final Types t = PackageHeaderHelper.parseHeader( conf.header );
+ if ( t == null ) {
+ Window.alert( constants.CanNotSwitchToBasicView() );
+ } else {
+ if ( Window.confirm( constants.SwitchToGuidedModeForPackageEditing() ) ) {
+ basicEditorVersion( t );
+ }
+ }
}
- });
+ } );
}
};
main.add( basicMode );
-
- layout.add(main);
- }
- private void showTypeQuestion(Widget w, final Types t, final boolean global, String headerMessage) {
- final FormStylePopup pop = new FormStylePopup("images/home_icon.gif", constants.ChooseAFactType()); //NON-NLS
- pop.setWidth(-1);
- pop.addRow(new HTML("<small><i>" + headerMessage + " </i></small>")); //NON-NLS
- final ListBox factList = new ListBox();
- factList.addItem(constants.loadingList());
+ layout.add( main );
+ }
- RepositoryServiceFactory.getService().listTypesInPackage(this.conf.uuid, new GenericCallback<String[]>() {
- public void onSuccess(String[] list) {
- factList.clear();
- for (int i = 0; i < list.length; i++) {
- if (global) {
- factList.addItem(list[i]);
- } else {
- if (list[i].indexOf('.') > -1) {
- factList.addItem(list[i]);
- }
- }
- }
- }
- });
+ private void showTypeQuestion(Widget w,
+ final Types t,
+ final boolean global,
+ String headerMessage) {
+ final FormStylePopup pop = new FormStylePopup( "images/home_icon.gif",
+ constants.ChooseAFactType() ); //NON-NLS
+ pop.addRow( new HTML( "<small><i>" + headerMessage + " </i></small>" ) ); //NON-NLS
+ final ListBox factList = new ListBox();
+ factList.addItem( constants.loadingList() );
- InfoPopup info = new InfoPopup(constants.TypesInThePackage(), constants.IfNoTypesTip());
- HorizontalPanel h = new HorizontalPanel();
- h.add(factList);
- h.add(info);
- pop.addAttribute(constants.ChooseClassType(), h);
- final TextBox globalName = new TextBox();
- if (global) {
- pop.addAttribute(constants.GlobalName(), globalName);
- }
- final TextBox className = new TextBox();
- InfoPopup infoClass = new InfoPopup(constants.EnteringATypeClassName(), constants.EnterTypeNameTip());
- h = new HorizontalPanel();
- h.add(className);
- h.add(infoClass);
- pop.addAttribute(constants.advancedClassName(), h);
+ RepositoryServiceFactory.getService().listTypesInPackage( this.conf.uuid,
+ new GenericCallback<String[]>() {
+ public void onSuccess(String[] list) {
+ factList.clear();
+ for ( int i = 0; i < list.length; i++ ) {
+ if ( global ) {
+ factList.addItem( list[i] );
+ } else {
+ if ( list[i].indexOf( '.' ) > -1 ) {
+ factList.addItem( list[i] );
+ }
+ }
+ }
+ }
+ } );
- Button ok = new Button(constants.OK()) {
- {
- addClickListener(new ClickListener() {
- public void onClick(Widget w) {
- String type = (!"".equals(className.getText())) ? className.getText() : factList.getItemText(factList.getSelectedIndex());
- if (!global) {
- t.imports.add(new Import(type));
- doImports(t);
- } else {
- if ("".equals(globalName.getText())) {
- Window.alert(constants.YouMustEnterAGlobalVariableName());
- return;
- }
- t.globals.add(new Global(type, globalName.getText()));
- doGlobals(t);
- }
- updateHeader(t);
- pop.hide();
- }
- });
- }
- };
- pop.addAttribute("", ok);
+ InfoPopup info = new InfoPopup( constants.TypesInThePackage(),
+ constants.IfNoTypesTip() );
+ HorizontalPanel h = new HorizontalPanel();
+ h.add( factList );
+ h.add( info );
+ pop.addAttribute( constants.ChooseClassType(),
+ h );
+ final TextBox globalName = new TextBox();
+ if ( global ) {
+ pop.addAttribute( constants.GlobalName(),
+ globalName );
+ }
+ final TextBox className = new TextBox();
+ InfoPopup infoClass = new InfoPopup( constants.EnteringATypeClassName(),
+ constants.EnterTypeNameTip() );
+ h = new HorizontalPanel();
+ h.add( className );
+ h.add( infoClass );
+ pop.addAttribute( constants.advancedClassName(),
+ h );
- pop.show();
- }
+ Button ok = new Button( constants.OK() ) {
+ {
+ addClickListener( new ClickListener() {
+ public void onClick(Widget w) {
+ String type = (!"".equals( className.getText() )) ? className.getText() : factList.getItemText( factList.getSelectedIndex() );
+ if ( !global ) {
+ t.imports.add( new Import( type ) );
+ doImports( t );
+ } else {
+ if ( "".equals( globalName.getText() ) ) {
+ Window.alert( constants.YouMustEnterAGlobalVariableName() );
+ return;
+ }
+ t.globals.add( new Global( type,
+ globalName.getText() ) );
+ doGlobals( t );
+ }
+ updateHeader( t );
+ pop.hide();
+ }
+ } );
+ }
+ };
+ pop.addAttribute( "",
+ ok );
- private void updateHeader(Types t) {
- this.conf.header = PackageHeaderHelper.renderTypes(t);
- }
+ pop.show();
+ }
- private void doGlobals(Types t) {
- globalList.clear();
- for (Iterator it = t.globals.iterator(); it.hasNext();) {
- Global g = (Global) it.next();
- globalList.addItem(g.type + " [" + g.name + "]");
- }
- }
+ private void updateHeader(Types t) {
+ this.conf.header = PackageHeaderHelper.renderTypes( t );
+ }
- private void doImports(Types t) {
- importList.clear();
- for (Iterator it = t.imports.iterator(); it.hasNext();) {
- Import i = (Import) it.next();
- importList.addItem(i.type);
- }
- }
+ private void doGlobals(Types t) {
+ globalList.clear();
+ for ( Iterator it = t.globals.iterator(); it.hasNext(); ) {
+ Global g = (Global) it.next();
+ globalList.addItem( g.type + " [" + g.name + "]" );
+ }
+ }
- static class Types {
- List imports = new ArrayList();
- List globals = new ArrayList();
- }
+ private void doImports(Types t) {
+ importList.clear();
+ for ( Iterator it = t.imports.iterator(); it.hasNext(); ) {
+ Import i = (Import) it.next();
+ importList.addItem( i.type );
+ }
+ }
- static class Import {
- String type;
+ static class Types {
+ List imports = new ArrayList();
+ List globals = new ArrayList();
+ }
- Import(String t) {
- this.type = t;
- }
- }
+ static class Import {
+ String type;
- static class Global {
- String type;
- String name;
+ Import(String t) {
+ this.type = t;
+ }
+ }
- Global(String type, String name) {
- this.type = type;
- this.name = name;
- }
- }
+ static class Global {
+ String type;
+ String name;
+ Global(String type,
+ String name) {
+ this.type = type;
+ this.name = name;
+ }
+ }
+
}
-
-
-
-
Modified: labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/packages/SuggestionCompletionCache.java
===================================================================
--- labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/packages/SuggestionCompletionCache.java 2010-10-01 06:58:15 UTC (rev 35375)
+++ labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/packages/SuggestionCompletionCache.java 2010-10-01 07:40:28 UTC (rev 35376)
@@ -1,5 +1,5 @@
/*
- * Copyright 2010 JBoss Inc
+ * Copyright 2005 JBoss Inc
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,21 +15,6 @@
*/
package org.drools.guvnor.client.packages;
-/*
- * Copyright 2005 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.
- */
Modified: labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/ruleeditor/RuleFlowWrapper.java
===================================================================
--- labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/ruleeditor/RuleFlowWrapper.java 2010-10-01 06:58:15 UTC (rev 35375)
+++ labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/ruleeditor/RuleFlowWrapper.java 2010-10-01 07:40:28 UTC (rev 35376)
@@ -1,4 +1,4 @@
-/**
+/*
* Copyright 2010 JBoss Inc
*
* Licensed under the Apache License, Version 2.0 (the "License");
Modified: labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/ruleeditor/RuleValidatorWrapper.java
===================================================================
--- labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/ruleeditor/RuleValidatorWrapper.java 2010-10-01 06:58:15 UTC (rev 35375)
+++ labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/ruleeditor/RuleValidatorWrapper.java 2010-10-01 07:40:28 UTC (rev 35376)
@@ -15,6 +15,7 @@
*/
package org.drools.guvnor.client.ruleeditor;
+
/*
* Copyright 2005 JBoss Inc
*
@@ -52,122 +53,130 @@
* This widget wraps a rule asset widget, and provides actions to validate and view source.
* @author Michael Neale
*/
-public class RuleValidatorWrapper extends DirtyableComposite implements SaveEventListener {
+public class RuleValidatorWrapper extends DirtyableComposite
+ implements
+ SaveEventListener {
- private RuleAsset asset;
- private VerticalPanel layout = new VerticalPanel();
- private Widget editor;
-
- private static Constants constants = ((Constants) GWT.create(Constants.class));
+ private RuleAsset asset;
+ private VerticalPanel layout = new VerticalPanel();
+ private Widget editor;
- public RuleValidatorWrapper(Widget editor, RuleAsset asset) {
+ private static Constants constants = ((Constants) GWT.create( Constants.class ));
+
+ public RuleValidatorWrapper(Widget editor,
+ RuleAsset asset) {
this.asset = asset;
this.editor = editor;
- layout.add(editor);
-/* if (!asset.isreadonly) {
- validatorActions();
- }*/
+ layout.add( editor );
+ /* if (!asset.isreadonly) {
+ validatorActions();
+ }*/
- layout.setWidth("100%");
+ layout.setWidth( "100%" );
layout.setHeight( "100%" );
initWidget( layout );
}
-
-
-//This is duplicate to ActionToolbar
-/* private void validatorActions() {
- Toolbar tb = new Toolbar();
- layout.setCellHeight(editor, "95%");
- layout.add(tb);
+ //This is duplicate to ActionToolbar
+ /* private void validatorActions() {
+ Toolbar tb = new Toolbar();
- ToolbarButton viewSource = new ToolbarButton();
- viewSource.setText(constants.ViewSource());
- viewSource.addListener(new ButtonListenerAdapter() {
- public void onClick(
- com.gwtext.client.widgets.Button button,
- EventObject e) {
- doViewsource();
- }
- });
+ layout.setCellHeight(editor, "95%");
+ layout.add(tb);
- //only show this for advanced users
- if (ExplorerLayoutManager.shouldShow(Capabilities.SHOW_PACKAGE_VIEW)) {
- tb.addButton(viewSource);
- tb.addSeparator();
- }
+ ToolbarButton viewSource = new ToolbarButton();
+ viewSource.setText(constants.ViewSource());
+ viewSource.addListener(new ButtonListenerAdapter() {
+ public void onClick(
+ com.gwtext.client.widgets.Button button,
+ EventObject e) {
+ doViewsource();
+ }
+ });
- ToolbarButton validate = new ToolbarButton();
- validate.setText(constants.Validate());
- validate.addListener(new ButtonListenerAdapter() {
- public void onClick(
- com.gwtext.client.widgets.Button button,
- EventObject e) {
- doValidate();
- }
- });
- tb.addButton(validate);
+ //only show this for advanced users
+ if (ExplorerLayoutManager.shouldShow(Capabilities.SHOW_PACKAGE_VIEW)) {
+ tb.addButton(viewSource);
+ tb.addSeparator();
+ }
+ ToolbarButton validate = new ToolbarButton();
+ validate.setText(constants.Validate());
+ validate.addListener(new ButtonListenerAdapter() {
+ public void onClick(
+ com.gwtext.client.widgets.Button button,
+ EventObject e) {
+ doValidate();
+ }
+ });
+ tb.addButton(validate);
- }
- private void doValidate() {
- onSave();
- LoadingPopup.showMessage(constants.ValidatingItemPleaseWait());
- RepositoryServiceFactory.getService().buildAsset( asset, new GenericCallback<BuilderResult>() {
- public void onSuccess(BuilderResult result) {showBuilderErrors(result);}
- });
+ }
- }
+ private void doValidate() {
+ onSave();
+ LoadingPopup.showMessage(constants.ValidatingItemPleaseWait());
+ RepositoryServiceFactory.getService().buildAsset( asset, new GenericCallback<BuilderResult>() {
+ public void onSuccess(BuilderResult result) {showBuilderErrors(result);}
+ });
- private void doViewsource() {
- onSave();
- LoadingPopup.showMessage(constants.CalculatingSource());
- RepositoryServiceFactory.getService().buildAssetSource( this.asset, new GenericCallback<String>() {
- public void onSuccess(String src) { showSource(src);}
- });
+ }
- }
+ private void doViewsource() {
+ onSave();
+ LoadingPopup.showMessage(constants.CalculatingSource());
+ RepositoryServiceFactory.getService().buildAssetSource( this.asset, new GenericCallback<String>() {
+ public void onSuccess(String src) { showSource(src);}
+ });
- private void showSource(String src) {
- PackageBuilderWidget.showSource( src, this.asset.metaData.name );
- LoadingPopup.close();
- }
- */
-
+ }
+
+ private void showSource(String src) {
+ PackageBuilderWidget.showSource( src, this.asset.metaData.name );
+ LoadingPopup.close();
+ }
+ */
+
/**
* This will show a popup of error messages in compilation.
*/
public static void showBuilderErrors(BuilderResult result) {
- if (result == null || result.lines == null || result.lines.length == 0) {
- FormStylePopup pop = new FormStylePopup();
- pop.setWidth(200);
- pop.setTitle(constants.ValidationResultsDotDot());
- HorizontalPanel h = new HorizontalPanel();
- h.add(new SmallLabel("<img src='images/tick_green.gif'/><i>" + constants.ItemValidatedSuccessfully() + "</i>")); //NON-NLS
+ if ( result == null || result.lines == null || result.lines.length == 0 ) {
+ FormStylePopup pop = new FormStylePopup();
+ pop.setWidth( 200 + "px" );
+ pop.setTitle( constants.ValidationResultsDotDot() );
+ HorizontalPanel h = new HorizontalPanel();
+ h.add( new SmallLabel( "<img src='images/tick_green.gif'/><i>" + constants.ItemValidatedSuccessfully() + "</i>" ) ); //NON-NLS
-
pop.addRow( h );
pop.show();
} else {
- FormStylePopup pop = new FormStylePopup("images/package_builder.png", constants.ValidationResults()); //NON-NLS
+ FormStylePopup pop = new FormStylePopup( "images/package_builder.png",
+ constants.ValidationResults() ); //NON-NLS
FlexTable errTable = new FlexTable();
errTable.setStyleName( "build-Results" ); //NON-NLS
for ( int i = 0; i < result.lines.length; i++ ) {
int row = i;
final BuilderResultLine res = result.lines[i];
- errTable.setWidget( row, 0, new Image("images/error.gif")); //NON-NLS
- if( res.assetFormat.equals( "package" )) {
- errTable.setText( row, 1, constants.packageConfigurationProblem() + res.message );
+ errTable.setWidget( row,
+ 0,
+ new Image( "images/error.gif" ) ); //NON-NLS
+ if ( res.assetFormat.equals( "package" ) ) {
+ errTable.setText( row,
+ 1,
+ constants.packageConfigurationProblem() + res.message );
} else {
- errTable.setText( row, 1, "[" + res.assetName + "] " + res.message );
+ errTable.setText( row,
+ 1,
+ "[" + res.assetName + "] " + res.message );
}
}
- ScrollPanel scroll = new ScrollPanel(errTable);
+ ScrollPanel scroll = new ScrollPanel( errTable );
scroll.setWidth( "100%" );
pop.addRow( scroll );
pop.show();
@@ -176,17 +185,17 @@
LoadingPopup.close();
}
- public void onSave() {
- if (editor instanceof SaveEventListener) {
- SaveEventListener el = (SaveEventListener) editor;
- el.onSave();
- }
- }
+ public void onSave() {
+ if ( editor instanceof SaveEventListener ) {
+ SaveEventListener el = (SaveEventListener) editor;
+ el.onSave();
+ }
+ }
- public void onAfterSave() {
- if (editor instanceof SaveEventListener) {
- SaveEventListener el = (SaveEventListener) editor;
- el.onAfterSave();
- }
- }
+ public void onAfterSave() {
+ if ( editor instanceof SaveEventListener ) {
+ SaveEventListener el = (SaveEventListener) editor;
+ el.onAfterSave();
+ }
+ }
}
\ No newline at end of file
Modified: labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/ruleeditor/RuleViewer.java
===================================================================
--- labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/ruleeditor/RuleViewer.java 2010-10-01 06:58:15 UTC (rev 35375)
+++ labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/ruleeditor/RuleViewer.java 2010-10-01 07:40:28 UTC (rev 35376)
@@ -1,21 +1,3 @@
-/**
- * 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.ruleeditor;
-
/*
* Copyright 2005 JBoss Inc
*
@@ -32,6 +14,8 @@
* limitations under the License.
*/
+package org.drools.guvnor.client.ruleeditor;
+
import org.drools.guvnor.client.common.AssetFormats;
import org.drools.guvnor.client.common.DirtyableComposite;
import org.drools.guvnor.client.common.ErrorPopup;
More information about the jboss-svn-commits
mailing list