[jboss-svn-commits] JBL Code SVN: r36230 - in labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client: decisiontable and 10 other directories.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Tue Dec 7 07:19:55 EST 2010
Author: Rikkola
Date: 2010-12-07 07:19:52 -0500 (Tue, 07 Dec 2010)
New Revision: 36230
Added:
labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/ruleeditor/EditorWidget.java
labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/ruleeditor/MessageWidget.java
labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/ruleeditor/RuleViewer.ui.xml
labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/ruleeditor/toolbar/ActionToolbar.ui.xml
Modified:
labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/common/SmallLabel.java
labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/decisiontable/GuidedDecisionTableWidget.java
labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/factmodel/FactModelsWidget.java
labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/messages/Constants.java
labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/messages/Constants.properties
labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/modeldriven/ui/RuleModelEditor.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/ModelAttachmentFileWidget.java
labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/processeditor/BusinessProcessEditor.java
labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/qa/testscenarios/ScenarioWidget.java
labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/resources/images/corners/greyBottomLeftCorner.gif
labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/resources/images/corners/greyBottomRightCorner.gif
labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/resources/images/corners/greyTopLeftCorner.gif
labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/resources/images/corners/greyTopRightCorner.gif
labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/ruleeditor/BPELWrapper.java
labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/ruleeditor/DefaultRuleContentWidget.java
labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/ruleeditor/DrlEditor.java
labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/ruleeditor/EditorLauncher.java
labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/ruleeditor/FunctionEditor.java
labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/ruleeditor/GuvnorEditor.java
labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/ruleeditor/MetaDataWidget.java
labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/ruleeditor/MultiViewEditor.java
labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/ruleeditor/RuleDocumentWidget.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
labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/ruleeditor/WorkingSetEditor.java
labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/ruleeditor/toolbar/ActionToolbar.java
labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/ruleeditor/toolbar/DefaultActionToolbarButtonsConfigurationProvider.java
labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/rulelist/QuickFindWidget.java
Log:
GUVNOR-1105 : Add round corners
-ActionToolBar
Modified: labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/common/SmallLabel.java
===================================================================
--- labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/common/SmallLabel.java 2010-12-07 12:18:43 UTC (rev 36229)
+++ labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/common/SmallLabel.java 2010-12-07 12:19:52 UTC (rev 36230)
@@ -1,4 +1,4 @@
-/**
+/*
* Copyright 2010 JBoss Inc
*
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -16,22 +16,36 @@
package org.drools.guvnor.client.common;
+import com.google.gwt.core.client.GWT;
+import com.google.gwt.safehtml.client.SafeHtmlTemplates;
+import com.google.gwt.safehtml.shared.SafeHtml;
import com.google.gwt.user.client.ui.HTML;
public class SmallLabel extends HTML {
- public SmallLabel(String text) {
- //super("<small>" + text + "</small>");
- super("<div class='x-form-field'>" + text + "</div>");
- }
+ interface SmallLabelTemplate
+ extends
+ SafeHtmlTemplates {
- public SmallLabel() {
- super();
- }
+ @Template("<div class='x-form-field'>{0}</div>")
+ SafeHtml message(SafeHtml message);
+ }
- public void setText(String t) {
- //setHTML("<small>" + t + "</small>");
- setHTML("<div class='x-form-field'>" + t + "</div>");
- }
+ private static final SmallLabelTemplate TEMPLATE = GWT.create( SmallLabelTemplate.class );
+ public SmallLabel() {
+ }
+
+ public SmallLabel(String text) {
+ setText( text );
+ }
+
+ public void setText(final String text) {
+ setHTML( TEMPLATE.message( new SafeHtml() {
+
+ public String asString() {
+ return text;
+ }
+ } ) );
+ }
}
Modified: labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/decisiontable/GuidedDecisionTableWidget.java
===================================================================
--- labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/decisiontable/GuidedDecisionTableWidget.java 2010-12-07 12:18:43 UTC (rev 36229)
+++ labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/decisiontable/GuidedDecisionTableWidget.java 2010-12-07 12:19:52 UTC (rev 36230)
@@ -35,6 +35,7 @@
import org.drools.guvnor.client.packages.SuggestionCompletionCache;
import org.drools.guvnor.client.resources.Images;
import org.drools.guvnor.client.rpc.RuleAsset;
+import org.drools.guvnor.client.ruleeditor.EditorWidget;
import org.drools.guvnor.client.ruleeditor.RuleViewer;
import org.drools.guvnor.client.ruleeditor.SaveEventListener;
import org.drools.guvnor.client.util.AddButton;
@@ -110,7 +111,8 @@
*/
public class GuidedDecisionTableWidget extends Composite
implements
- SaveEventListener {
+ SaveEventListener,
+ EditorWidget {
private Constants constants = GWT.create( Constants.class );
private static Images images = GWT.create( Images.class );
Modified: labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/factmodel/FactModelsWidget.java
===================================================================
--- labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/factmodel/FactModelsWidget.java 2010-12-07 12:18:43 UTC (rev 36229)
+++ labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/factmodel/FactModelsWidget.java 2010-12-07 12:19:52 UTC (rev 36230)
@@ -22,6 +22,7 @@
import org.drools.guvnor.client.rpc.RuleAsset;
import org.drools.guvnor.client.rpc.RuleContentText;
import org.drools.guvnor.client.ruleeditor.DefaultRuleContentWidget;
+import org.drools.guvnor.client.ruleeditor.EditorWidget;
import org.drools.guvnor.client.ruleeditor.RuleViewer;
import org.drools.guvnor.client.ruleeditor.SaveEventListener;
@@ -37,13 +38,14 @@
*/
public class FactModelsWidget extends Composite
implements
- SaveEventListener {
+ SaveEventListener,
+ EditorWidget {
private RuleAsset asset;
private static Constants constants = ((Constants) GWT.create( Constants.class ));
public FactModelsWidget(RuleAsset asset,
- RuleViewer viewer) {
+ RuleViewer viewer) {
this( asset );
}
Modified: labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/messages/Constants.java
===================================================================
--- labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/messages/Constants.java 2010-12-07 12:18:43 UTC (rev 36229)
+++ labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/messages/Constants.java 2010-12-07 12:19:52 UTC (rev 36230)
@@ -2025,11 +2025,11 @@
String VerificationReport();
String CanNotSwitchToBasicView();
-
+
String CanNotSwitchToBasicViewRules();
-
+
String CanNotSwitchToBasicViewFunctions();
-
+
String CanNotSwitchToBasicViewDeclaredTypes();
String Causes();
@@ -2159,9 +2159,9 @@
String InvalidDateFormatMessage();
String NewColumn();
-
+
String NoRulesFound();
-
+
String Done();
String RemoveThisRuleFlowActivation();
@@ -2169,4 +2169,8 @@
String Constraints();
String ConstraintsParameters();
+
+ String File();
+
+ String Edit();
}
Modified: labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/messages/Constants.properties
===================================================================
--- labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/messages/Constants.properties 2010-12-07 12:18:43 UTC (rev 36229)
+++ labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/messages/Constants.properties 2010-12-07 12:19:52 UTC (rev 36230)
@@ -37,7 +37,7 @@
ChooseFact=Choose fact:
pleaseChooseABoundFactForThisColumn=(please choose a bound fact for this column)
setterLabel={0} value of {1}
-statusIs=<i>Status: [{0}]</i>
+statusIs=Status: [{0}]
SaveChanges=Save changes
CommitAnyChangesForThisAsset=Commit any changes for this asset.
Copy=Copy
@@ -1070,3 +1070,5 @@
RemoveThisRuleFlowActivation=Remove this rule flow activation.
Constraints=Constraints
ConstraintsParameters=Constraints Parameters
+File=File
+Edit=Edit
Modified: labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/modeldriven/ui/RuleModelEditor.java
===================================================================
--- labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/modeldriven/ui/RuleModelEditor.java 2010-12-07 12:18:43 UTC (rev 36229)
+++ labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/modeldriven/ui/RuleModelEditor.java 2010-12-07 12:19:52 UTC (rev 36230)
@@ -16,6 +16,10 @@
package org.drools.guvnor.client.modeldriven.ui;
-public interface RuleModelEditor {
- public RuleModeller getRuleModeller();
+import org.drools.guvnor.client.ruleeditor.EditorWidget;
+
+public interface RuleModelEditor
+ extends
+ EditorWidget {
+ public RuleModeller getRuleModeller();
}
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-12-07 12:18:43 UTC (rev 36229)
+++ labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/packages/AssetAttachmentFileWidget.java 2010-12-07 12:19:52 UTC (rev 36230)
@@ -20,10 +20,9 @@
import org.drools.guvnor.client.common.FormStyleLayout;
import org.drools.guvnor.client.common.HTMLFileManagerFields;
import org.drools.guvnor.client.common.LoadingPopup;
-import org.drools.guvnor.client.common.SmallLabel;
import org.drools.guvnor.client.messages.Constants;
-import org.drools.guvnor.client.resources.Images;
import org.drools.guvnor.client.rpc.RuleAsset;
+import org.drools.guvnor.client.ruleeditor.EditorWidget;
import org.drools.guvnor.client.ruleeditor.RuleViewer;
import com.google.gwt.core.client.GWT;
@@ -49,10 +48,11 @@
* @author Fernando Meyer
*/
-public abstract class AssetAttachmentFileWidget extends Composite {
+public abstract class AssetAttachmentFileWidget extends Composite
+ implements
+ EditorWidget {
private Constants constants = GWT.create( Constants.class );
- private Images images = GWT.create( Images.class );
private FormPanel form;
private Button ok;
@@ -142,7 +142,7 @@
}
if ( event.getResults().indexOf( "OK" ) > -1 ) {
- viewer.refreshDataAndView( new SmallLabel( "<div style=\"background-color: yellow;\" ><img src='" + images.greenTick() + "'/><i>" + constants.FileWasUploadedSuccessfully() + "</i></div>" ) );
+ viewer.showInfoMessage( constants.FileWasUploadedSuccessfully() );
} else {
ErrorPopup.showMessage( constants.UnableToUploadTheFile() );
}
Modified: labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/packages/ModelAttachmentFileWidget.java
===================================================================
--- labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/packages/ModelAttachmentFileWidget.java 2010-12-07 12:18:43 UTC (rev 36229)
+++ labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/packages/ModelAttachmentFileWidget.java 2010-12-07 12:19:52 UTC (rev 36230)
@@ -19,6 +19,7 @@
import org.drools.guvnor.client.common.LoadingPopup;
import org.drools.guvnor.client.resources.Images;
import org.drools.guvnor.client.rpc.RuleAsset;
+import org.drools.guvnor.client.ruleeditor.EditorWidget;
import org.drools.guvnor.client.ruleeditor.RuleViewer;
import org.drools.guvnor.client.ruleeditor.SaveEventListener;
import org.drools.guvnor.client.messages.Constants;
@@ -37,7 +38,8 @@
public class ModelAttachmentFileWidget extends AssetAttachmentFileWidget
implements
- SaveEventListener {
+ SaveEventListener,
+ EditorWidget {
private static Images images = GWT.create( Images.class );
Modified: labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/processeditor/BusinessProcessEditor.java
===================================================================
--- labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/processeditor/BusinessProcessEditor.java 2010-12-07 12:18:43 UTC (rev 36229)
+++ labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/processeditor/BusinessProcessEditor.java 2010-12-07 12:19:52 UTC (rev 36230)
@@ -23,6 +23,7 @@
import org.drools.guvnor.client.rpc.RuleAsset;
import org.drools.guvnor.client.rpc.RuleFlowContentModel;
import org.drools.guvnor.client.ruleeditor.EditorLauncher;
+import org.drools.guvnor.client.ruleeditor.EditorWidget;
import org.drools.guvnor.client.ruleeditor.SaveEventListener;
import com.google.gwt.dom.client.Document;
@@ -34,38 +35,42 @@
*
* @author <a href="mailto:atoulme at intalio.com">Antoine Toulme</a>
*/
-public class BusinessProcessEditor extends DirtyableComposite implements SaveEventListener {
+public class BusinessProcessEditor extends DirtyableComposite
+ implements
+ SaveEventListener,
+ EditorWidget {
- private String modelUUID;
+ private String modelUUID;
private RuleAsset asset;
- private Frame frame;
-
+ private Frame frame;
+
public BusinessProcessEditor(RuleAsset asset) {
this.asset = asset;
modelUUID = asset.uuid;
initWidgets();
}
-
+
private void initWidgets() {
- String name;
- if(EditorLauncher.HOSTED_MODE.booleanValue()) {
- // THIS IS A HACK TO GET DESIGNER WORKING ON HOSTED MODE
- // I will add ability to input where oryx designer is
- // available in the admin section soon
- name = "http://localhost:8080/designer/editor";
- } else {
- name = "/designer/editor";
- }
+ String name;
+ if ( EditorLauncher.HOSTED_MODE.booleanValue() ) {
+ // THIS IS A HACK TO GET DESIGNER WORKING ON HOSTED MODE
+ // I will add ability to input where oryx designer is
+ // available in the admin section soon
+ name = "http://localhost:8080/designer/editor";
+ } else {
+ name = "/designer/editor";
+ }
name += "?uuid=" + modelUUID;
- frame = new Frame(name);
- frame.getElement().setAttribute("domain", Document.get().getDomain());
- frame.setWidth("100%");
- frame.setHeight("100%");
- initWidget(frame);
- setWidth("100%");
- setHeight("100%");
+ frame = new Frame( name );
+ frame.getElement().setAttribute( "domain",
+ Document.get().getDomain() );
+ frame.setWidth( "100%" );
+ frame.setHeight( "100%" );
+ initWidget( frame );
+ setWidth( "100%" );
+ setHeight( "100%" );
}
-
+
private final native String callSave(Document frameDoc) /*-{
//console.log(frameDoc.defaultView.ORYX.EDITOR.getSerializedJSON());
return frameDoc.defaultView.ORYX.EDITOR.getSerializedJSON();
@@ -73,16 +78,14 @@
public void onSave() {
//we replace the model by the new model:
- String s = callSave(((IFrameElement)
- ((com.google.gwt.dom.client.Element)
- frame.getElement())).getContentDocument());
- if (asset.content == null) {
+ String s = callSave( ((IFrameElement) ((com.google.gwt.dom.client.Element) frame.getElement())).getContentDocument() );
+ if ( asset.content == null ) {
asset.content = new RuleFlowContentModel();
}
- ((RuleFlowContentModel) asset.content).setXml(null);
- ((RuleFlowContentModel) asset.content).setJson(s);
+ ((RuleFlowContentModel) asset.content).setXml( null );
+ ((RuleFlowContentModel) asset.content).setJson( s );
}
-
+
public void onAfterSave() {
}
Modified: labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/qa/testscenarios/ScenarioWidget.java
===================================================================
--- labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/qa/testscenarios/ScenarioWidget.java 2010-12-07 12:18:43 UTC (rev 36229)
+++ labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/qa/testscenarios/ScenarioWidget.java 2010-12-07 12:19:52 UTC (rev 36230)
@@ -29,6 +29,7 @@
import org.drools.guvnor.client.rpc.MetaData;
import org.drools.guvnor.client.rpc.RepositoryServiceFactory;
import org.drools.guvnor.client.rpc.RuleAsset;
+import org.drools.guvnor.client.ruleeditor.EditorWidget;
import org.drools.guvnor.client.ruleeditor.RuleViewer;
import org.drools.ide.common.client.modeldriven.SuggestionCompletionEngine;
import org.drools.ide.common.client.modeldriven.testing.CallFixtureMap;
@@ -61,7 +62,9 @@
import com.google.gwt.user.client.ui.VerticalPanel;
import com.google.gwt.user.client.ui.Widget;
-public class ScenarioWidget extends Composite {
+public class ScenarioWidget extends Composite
+ implements
+ EditorWidget {
private Constants constants = GWT.create( Constants.class );
private static Images images = GWT.create( Images.class );
Modified: labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/resources/images/corners/greyBottomLeftCorner.gif
===================================================================
(Binary files differ)
Modified: labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/resources/images/corners/greyBottomRightCorner.gif
===================================================================
(Binary files differ)
Modified: labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/resources/images/corners/greyTopLeftCorner.gif
===================================================================
(Binary files differ)
Modified: labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/resources/images/corners/greyTopRightCorner.gif
===================================================================
(Binary files differ)
Modified: labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/ruleeditor/BPELWrapper.java
===================================================================
--- labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/ruleeditor/BPELWrapper.java 2010-12-07 12:18:43 UTC (rev 36229)
+++ labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/ruleeditor/BPELWrapper.java 2010-12-07 12:19:52 UTC (rev 36230)
@@ -30,46 +30,48 @@
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.VerticalPanel;
+public class BPELWrapper extends Composite
+ implements
+ EditorWidget {
-public class BPELWrapper extends Composite {
+ private Constants constants = GWT.create( Constants.class );
- private Constants constants = GWT.create(Constants.class);
+ public BPELWrapper(RuleAsset asset,
+ RuleViewer viewer) {
- public BPELWrapper(RuleAsset asset, RuleViewer viewer) {
+ final String uuid = asset.uuid;
+ final String fileName = asset.metaData.name;
+ final String dirName = asset.metaData.packageName;
+ final String servletName = "workflowmanager";
+ final String isNew = (asset.content == null ? "true" : "false");
- final String uuid = asset.uuid;
- final String fileName = asset.metaData.name;
- final String dirName = asset.metaData.packageName;
- final String servletName = "workflowmanager";
- final String isNew = (asset.content == null ? "true" : "false");
+ AssetAttachmentFileWidget uploadWidget = new DefaultContentUploadEditor( asset,
+ viewer );
- AssetAttachmentFileWidget uploadWidget = new DefaultContentUploadEditor(
- asset, viewer);
+ VerticalPanel panel = new VerticalPanel();
+ panel.add( uploadWidget );
- VerticalPanel panel = new VerticalPanel();
- panel.add(uploadWidget);
+ Button viewSource = new Button();
+ viewSource.setText( constants.OpenEditorInNewWindow() );
- Button viewSource = new Button();
- viewSource.setText(constants.OpenEditorInNewWindow());
+ final String url = Format.format( "bpeleditor/BPELEditor.html?uuid={0}&fileName={1}&dirName={2}&servletName={3}&isNew={4}",
+ new String[]{uuid, fileName, dirName, servletName, isNew} );
+ viewSource.addClickHandler( new ClickHandler() {
+ public void onClick(ClickEvent arg0) {
+ Window.open( url,
+ "_" + fileName,
+ null );
+ }
+ } );
- final String url = Format
- .format(
- "bpeleditor/BPELEditor.html?uuid={0}&fileName={1}&dirName={2}&servletName={3}&isNew={4}",
- new String[] { uuid, fileName, dirName, servletName,
- isNew });
- viewSource.addClickHandler(new ClickHandler() {
- public void onClick(ClickEvent arg0) {
- Window.open(url, "_" + fileName, null); }
- });
+ panel.add( viewSource );
- panel.add(viewSource);
+ initWidget( panel );
- initWidget(panel);
+ this.setStyleName( getOverallStyleName() );
+ }
- this.setStyleName(getOverallStyleName());
- }
-
- public String getOverallStyleName() {
- return "decision-Table-upload";
- }
+ public String getOverallStyleName() {
+ return "decision-Table-upload";
+ }
}
Modified: labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/ruleeditor/DefaultRuleContentWidget.java
===================================================================
--- labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/ruleeditor/DefaultRuleContentWidget.java 2010-12-07 12:18:43 UTC (rev 36229)
+++ labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/ruleeditor/DefaultRuleContentWidget.java 2010-12-07 12:19:52 UTC (rev 36230)
@@ -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,71 +14,77 @@
* limitations under the License.
*/
+package org.drools.guvnor.client.ruleeditor;
+
import org.drools.guvnor.client.common.DirtyableComposite;
import org.drools.guvnor.client.rpc.RuleAsset;
import org.drools.guvnor.client.rpc.RuleContentText;
-import com.google.gwt.user.client.ui.ChangeListener;
-import com.google.gwt.user.client.ui.KeyboardListenerAdapter;
+import com.google.gwt.event.dom.client.ChangeEvent;
+import com.google.gwt.event.dom.client.ChangeHandler;
+import com.google.gwt.event.dom.client.KeyCodes;
+import com.google.gwt.event.dom.client.KeyDownEvent;
+import com.google.gwt.event.dom.client.KeyDownHandler;
import com.google.gwt.user.client.ui.TextArea;
-import com.google.gwt.user.client.ui.Widget;
/**
* This is the default rule editor widget (just text editor based) - more to come later.
* @author michael neale
*/
-public class DefaultRuleContentWidget extends DirtyableComposite {
+public class DefaultRuleContentWidget extends DirtyableComposite
+ implements
+ EditorWidget {
private TextArea text;
final private RuleContentText data;
final private RuleAsset asset;
- public DefaultRuleContentWidget(RuleAsset a, RuleViewer v) {
- this(a);
+ public DefaultRuleContentWidget(RuleAsset a,
+ RuleViewer v) {
+ this( a );
}
-
public DefaultRuleContentWidget(RuleAsset a) {
- this(a, -1);
+ this( a,
+ -1 );
}
- public DefaultRuleContentWidget(RuleAsset a, int visibleLines) {
+ public DefaultRuleContentWidget(RuleAsset a,
+ int visibleLines) {
asset = a;
data = (RuleContentText) asset.content;
- if (data.content == null) {
- data.content = "";
+ if ( data.content == null ) {
+ data.content = "";
}
-
text = new TextArea();
text.setWidth( "100%" );
- text.setVisibleLines((visibleLines == -1) ? 16 : visibleLines );
+ text.setVisibleLines( (visibleLines == -1) ? 16 : visibleLines );
text.setText( data.content );
- text.getElement().setAttribute("spellcheck", "false"); //NON-NLS
+ text.getElement().setAttribute( "spellcheck",
+ "false" ); //NON-NLS
text.setStyleName( "default-text-Area" ); //NON-NLS
- text.addChangeListener( new ChangeListener() {
- public void onChange(Widget w) {
+ text.addChangeHandler( new ChangeHandler() {
+ public void onChange(ChangeEvent event) {
data.content = text.getText();
makeDirty();
}
} );
- text.addKeyboardListener( new KeyboardListenerAdapter() {
- public void onKeyDown(Widget arg0,
- char arg1,
- int arg2) {
- System.err.println(arg1);
- if ( arg1 == KEY_TAB ) {
- int pos = text.getCursorPos();
+ text.addKeyDownHandler( new KeyDownHandler() {
+
+ public void onKeyDown(KeyDownEvent event) {
+ if ( event.getNativeKeyCode() == KeyCodes.KEY_TAB ) {
+ int pos = text.getCursorPos();
insertText( "\t" );
text.setCursorPos( pos + 1 );
text.cancelKey();
- text.setFocus(true);
+ text.setFocus( true );
}
}
} );
@@ -115,5 +103,4 @@
this.data.content = text.getText();
}
-
}
\ No newline at end of file
Modified: labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/ruleeditor/DrlEditor.java
===================================================================
--- labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/ruleeditor/DrlEditor.java 2010-12-07 12:18:43 UTC (rev 36229)
+++ labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/ruleeditor/DrlEditor.java 2010-12-07 12:19:52 UTC (rev 36230)
@@ -25,37 +25,53 @@
import com.google.gwt.user.client.ui.HasHorizontalAlignment;
import com.google.gwt.user.client.ui.HasVerticalAlignment;
-public class DrlEditor extends Composite {
+public class DrlEditor extends Composite
+ implements
+ EditorWidget {
- public DrlEditor(RuleAsset a, RuleViewer v){
- this(a);
+ public DrlEditor(RuleAsset a,
+ RuleViewer v) {
+ this( a );
}
public DrlEditor(RuleAsset a) {
- final DefaultRuleContentWidget ed = new DefaultRuleContentWidget(a, 26);
+ final DefaultRuleContentWidget ed = new DefaultRuleContentWidget( a,
+ 26 );
- ClickEvent ce = new FactTypeBrowser.ClickEvent() {
- public void selected(String text) {
- ed.insertText(text);
- }
- };
+ ClickEvent ce = new FactTypeBrowser.ClickEvent() {
+ public void selected(String text) {
+ ed.insertText( text );
+ }
+ };
- Grid layout = new Grid(1, 2);
+ Grid layout = new Grid( 1,
+ 2 );
+ FactTypeBrowser browser = new FactTypeBrowser( SuggestionCompletionCache.getInstance().getEngineFromCache( a.metaData.packageName ),
+ ce );
+ layout.setWidget( 0,
+ 0,
+ browser );
+ layout.setWidget( 0,
+ 1,
+ ed );
- FactTypeBrowser browser = new FactTypeBrowser(SuggestionCompletionCache.getInstance().getEngineFromCache(a.metaData.packageName), ce);
- layout.setWidget(0, 0, browser);
- layout.setWidget(0, 1, ed);
+ layout.getColumnFormatter().setWidth( 0,
+ "10%" );
+ layout.getColumnFormatter().setWidth( 1,
+ "90%" );
+ layout.getCellFormatter().setAlignment( 0,
+ 0,
+ HasHorizontalAlignment.ALIGN_LEFT,
+ HasVerticalAlignment.ALIGN_TOP );
+ layout.getCellFormatter().setAlignment( 0,
+ 1,
+ HasHorizontalAlignment.ALIGN_LEFT,
+ HasVerticalAlignment.ALIGN_TOP );
+ layout.setWidth( "100%" );
- layout.getColumnFormatter().setWidth(0, "10%");
- layout.getColumnFormatter().setWidth(1, "90%");
- layout.getCellFormatter().setAlignment(0, 0, HasHorizontalAlignment.ALIGN_LEFT, HasVerticalAlignment.ALIGN_TOP);
- layout.getCellFormatter().setAlignment(0, 1, HasHorizontalAlignment.ALIGN_LEFT, HasVerticalAlignment.ALIGN_TOP);
- layout.setWidth("100%");
+ initWidget( layout );
+ }
- initWidget(layout);
-
- }
-
}
Modified: labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/ruleeditor/EditorLauncher.java
===================================================================
--- labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/ruleeditor/EditorLauncher.java 2010-12-07 12:18:43 UTC (rev 36229)
+++ labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/ruleeditor/EditorLauncher.java 2010-12-07 12:19:52 UTC (rev 36230)
@@ -40,7 +40,6 @@
import org.drools.guvnor.client.rpc.RuleAsset;
import com.google.gwt.core.client.GWT;
-import com.google.gwt.user.client.ui.Widget;
/**
* This launches the appropriate editor for the asset type.
@@ -75,8 +74,8 @@
/**
* This will return the appropriate viewer for the asset.
*/
- public static Widget getEditorViewer(RuleAsset asset,
- RuleViewer viewer) {
+ public static EditorWidget getEditorViewer(RuleAsset asset,
+ RuleViewer viewer) {
RulePackageSelector.currentlySelectedPackage = asset.metaData.packageName;
//depending on the format, load the appropriate editor
if ( asset.metaData.format.equals( AssetFormats.BUSINESS_RULE ) ) {
Added: labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/ruleeditor/EditorWidget.java
===================================================================
--- labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/ruleeditor/EditorWidget.java (rev 0)
+++ labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/ruleeditor/EditorWidget.java 2010-12-07 12:19:52 UTC (rev 36230)
@@ -0,0 +1,29 @@
+/*
+ * 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;
+
+import com.google.gwt.user.client.ui.IsWidget;
+
+/**
+ *
+ * @author rikkola
+ *
+ */
+public interface EditorWidget
+ extends
+ IsWidget {
+
+}
Modified: labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/ruleeditor/FunctionEditor.java
===================================================================
--- labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/ruleeditor/FunctionEditor.java 2010-12-07 12:18:43 UTC (rev 36229)
+++ labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/ruleeditor/FunctionEditor.java 2010-12-07 12:19:52 UTC (rev 36230)
@@ -1,4 +1,4 @@
-/**
+/*
* Copyright 2010 JBoss Inc
*
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -20,17 +20,20 @@
import com.google.gwt.user.client.ui.Composite;
-public class FunctionEditor extends Composite {
+public class FunctionEditor extends Composite
+ implements
+ EditorWidget {
- public FunctionEditor(RuleAsset a, RuleViewer v){
- this(a);
+ public FunctionEditor(RuleAsset a,
+ RuleViewer v) {
+ this( a );
}
public FunctionEditor(RuleAsset a) {
- final DefaultRuleContentWidget ed = new DefaultRuleContentWidget(a);
+ final DefaultRuleContentWidget ed = new DefaultRuleContentWidget( a );
- initWidget(ed);
+ initWidget( ed );
- }
+ }
}
Modified: labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/ruleeditor/GuvnorEditor.java
===================================================================
--- labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/ruleeditor/GuvnorEditor.java 2010-12-07 12:18:43 UTC (rev 36229)
+++ labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/ruleeditor/GuvnorEditor.java 2010-12-07 12:19:52 UTC (rev 36230)
@@ -1,4 +1,4 @@
-/**
+/*
* Copyright 2010 JBoss Inc
*
* Licensed under the Apache License, Version 2.0 (the "License");
Added: labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/ruleeditor/MessageWidget.java
===================================================================
--- labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/ruleeditor/MessageWidget.java (rev 0)
+++ labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/ruleeditor/MessageWidget.java 2010-12-07 12:19:52 UTC (rev 36230)
@@ -0,0 +1,78 @@
+/*
+ * 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;
+
+import org.drools.guvnor.client.common.SmallLabel;
+import org.drools.guvnor.client.resources.Images;
+
+import com.google.gwt.core.client.GWT;
+import com.google.gwt.resources.client.ImageResource;
+import com.google.gwt.safehtml.client.SafeHtmlTemplates;
+import com.google.gwt.safehtml.shared.SafeHtml;
+import com.google.gwt.safehtml.shared.SafeHtmlUtils;
+import com.google.gwt.user.client.Timer;
+import com.google.gwt.user.client.ui.AbstractImagePrototype;
+import com.google.gwt.user.client.ui.Composite;
+
+/**
+ *
+ * @author rikkola
+ *
+ */
+public class MessageWidget extends Composite {
+
+ interface MessageTemplate
+ extends
+ SafeHtmlTemplates {
+
+ @Template("<div style=\"background-color: yellow;\" ><img src='{0}'/><i>{1}</i></div>")
+ SafeHtml message(SafeHtml image,
+ String message);
+ }
+
+ private Images images = GWT.create( Images.class );
+
+ private static final MessageTemplate TEMPLATE = GWT.create( MessageTemplate.class );
+
+ private final SmallLabel label = new SmallLabel();
+
+ public MessageWidget() {
+
+ label.setVisible( false );
+
+ initWidget( label );
+ }
+
+ public void showMessage(String message) {
+ showMessage( images.greenTick(),
+ message );
+ }
+
+ public void showMessage(ImageResource image,
+ String message) {
+
+ label.setVisible( true );
+ label.setHTML( TEMPLATE.message( SafeHtmlUtils.fromTrustedString( AbstractImagePrototype.create( image ).getHTML() ),
+ message ) );
+
+ Timer timer = new Timer() {
+ public void run() {
+ label.setVisible( false );
+ }
+ };
+ timer.schedule( 1500 );
+ }
+}
Modified: labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/ruleeditor/MetaDataWidget.java
===================================================================
--- labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/ruleeditor/MetaDataWidget.java 2010-12-07 12:18:43 UTC (rev 36229)
+++ labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/ruleeditor/MetaDataWidget.java 2010-12-07 12:19:52 UTC (rev 36230)
@@ -33,7 +33,6 @@
import org.drools.guvnor.client.security.CapabilitiesManager;
import org.drools.guvnor.client.util.DecoratedDisclosurePanel;
import org.drools.guvnor.client.util.Format;
-import org.drools.guvnor.client.util.LazyStackPanelHeader;
import com.google.gwt.core.client.GWT;
import com.google.gwt.event.dom.client.ChangeEvent;
@@ -46,7 +45,6 @@
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.CheckBox;
import com.google.gwt.user.client.ui.Composite;
-import com.google.gwt.user.client.ui.DisclosurePanel;
import com.google.gwt.user.client.ui.HorizontalPanel;
import com.google.gwt.user.client.ui.Image;
import com.google.gwt.user.client.ui.Label;
@@ -82,23 +80,23 @@
super();
+ this.uuid = uuid;
+ this.data = d;
+ this.readOnly = readOnly;
+
layout.setWidth( "100%" );
this.metaDataRefreshView = metaDataRefreshView;
this.fullRefreshView = fullRefreshView;
if ( d.format.equals( AssetFormats.DRL ) || d.format.equals( AssetFormats.FUNCTION ) || d.format.equals( AssetFormats.ENUMERATION ) ) {
- render( d,
- readOnly,
- uuid );
+ render();
} else {
Button show = new Button( constants.showMoreInfo() );
show.addClickHandler( new ClickHandler() {
public void onClick(ClickEvent sender) {
layout.clear();
- render( d,
- readOnly,
- uuid );
+ render();
}
} );
@@ -113,9 +111,7 @@
initWidget( layout );
}
- private void render(MetaData d,
- boolean readOnly,
- String uuid) {
+ private void render() {
if ( !readOnly ) {
Image edit = new ImageButton( images.edit(),
@@ -126,19 +122,15 @@
}
} );
addHeader( images.metadata(),
- d.name,
+ data.name,
edit );
} else {
addHeader( images.assetVersion(),
- d.name,
+ data.name,
null );
}
- this.uuid = uuid;
- this.data = d;
- this.readOnly = readOnly;
-
- loadData( d );
+ loadData();
}
private void addHeader(ImageResource img,
@@ -153,8 +145,7 @@
hp );
}
- private void loadData(MetaData d) {
- this.data = d;
+ private void loadData() {
addAttribute( constants.CategoriesMetaData(),
categories() );
@@ -473,4 +464,8 @@
return data;
}
+ public void refresh() {
+ render();
+ }
+
}
\ No newline at end of file
Modified: labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/ruleeditor/MultiViewEditor.java
===================================================================
--- labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/ruleeditor/MultiViewEditor.java 2010-12-07 12:18:43 UTC (rev 36229)
+++ labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/ruleeditor/MultiViewEditor.java 2010-12-07 12:19:52 UTC (rev 36230)
@@ -60,16 +60,16 @@
private ActionToolbarButtonsConfigurationProvider individualActionToolbarButtonsConfigurationProvider;
private Map<String, RuleAsset> assets = new HashMap<String, RuleAsset>();
-
- private MultiViewEditorMenuBarCreator menuBarCreator;
+ private MultiViewEditorMenuBarCreator menuBarCreator;
+
public MultiViewEditor(MultiViewRow[] rows,
EditItemEvent editItemEvent) {
this( rows,
editItemEvent,
null );
}
-
+
public MultiViewEditor(MultiViewRow[] rows,
EditItemEvent editItemEvent,
ActionToolbarButtonsConfigurationProvider individualActionToolbarButtonsConfigurationProvider) {
@@ -77,7 +77,7 @@
editItemEvent,
individualActionToolbarButtonsConfigurationProvider );
}
-
+
public MultiViewEditor(List<MultiViewRow> rows,
EditItemEvent editItemEvent,
ActionToolbarButtonsConfigurationProvider individualActionToolbarButtonsConfigurationProvider) {
@@ -87,16 +87,20 @@
init();
}
-
+
public MultiViewEditor(RuleAsset[] assets,
EditItemEvent editItemEvent,
ActionToolbarButtonsConfigurationProvider individualActionToolbarButtonsConfigurationProvider) {
- this(assets, editItemEvent, individualActionToolbarButtonsConfigurationProvider, null);
+ this( assets,
+ editItemEvent,
+ individualActionToolbarButtonsConfigurationProvider,
+ null );
}
public MultiViewEditor(RuleAsset[] assets,
EditItemEvent editItemEvent,
- ActionToolbarButtonsConfigurationProvider individualActionToolbarButtonsConfigurationProvider, MultiViewEditorMenuBarCreator menuBarCreator) {
+ ActionToolbarButtonsConfigurationProvider individualActionToolbarButtonsConfigurationProvider,
+ MultiViewEditorMenuBarCreator menuBarCreator) {
this.rows.addAll( createRows( assets ) );
this.editItemEvent = editItemEvent;
this.individualActionToolbarButtonsConfigurationProvider = individualActionToolbarButtonsConfigurationProvider;
@@ -104,7 +108,7 @@
addAssets( assets );
init();
}
-
+
private void addAssets(RuleAsset[] assets) {
for ( RuleAsset ruleAsset : assets ) {
this.assets.put( ruleAsset.uuid,
@@ -156,14 +160,14 @@
// toolbar.addItem( constants.Show(),
// layoutMenu );
private MenuBar createToolbar() {
-
+
//if no MultiViewEditorMenuBarCreator is set, then use the Default
//implementation.
- if (this.menuBarCreator == null){
+ if ( this.menuBarCreator == null ) {
this.menuBarCreator = new DefaultMultiViewEditorMenuBarCreator();
}
-
- return this.menuBarCreator.createMenuBar(this);
+
+ return this.menuBarCreator.createMenuBar( this );
}
private void doViews() {
@@ -280,7 +284,7 @@
public void execute() {
String comment = pop.getCheckinComment();
for ( RuleViewer ruleViewer : ruleViews.values() ) {
- ruleViewer.checkInCommand.doCheckin( comment );
+ ruleViewer.doCheckin( comment );
}
if ( closeAfter ) {
close();
Modified: labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/ruleeditor/RuleDocumentWidget.java
===================================================================
--- labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/ruleeditor/RuleDocumentWidget.java 2010-12-07 12:18:43 UTC (rev 36229)
+++ labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/ruleeditor/RuleDocumentWidget.java 2010-12-07 12:19:52 UTC (rev 36230)
@@ -21,7 +21,6 @@
import com.google.gwt.core.client.Scheduler;
import com.google.gwt.user.client.Command;
-import com.google.gwt.user.client.DeferredCommand;
import com.google.gwt.user.client.ui.VerticalPanel;
/**
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-12-07 12:18:43 UTC (rev 36229)
+++ labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/ruleeditor/RuleFlowWrapper.java 2010-12-07 12:19:52 UTC (rev 36230)
@@ -46,7 +46,8 @@
*/
public class RuleFlowWrapper extends Composite
implements
- SaveEventListener {
+ SaveEventListener,
+ EditorWidget {
private Constants constants = GWT.create( Constants.class );
private static Images images = GWT.create( Images.class );
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-12-07 12:18:43 UTC (rev 36229)
+++ labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/ruleeditor/RuleValidatorWrapper.java 2010-12-07 12:19:52 UTC (rev 36230)
@@ -24,7 +24,6 @@
import org.drools.guvnor.client.resources.Images;
import org.drools.guvnor.client.rpc.BuilderResult;
import org.drools.guvnor.client.rpc.BuilderResultLine;
-import org.drools.guvnor.client.rpc.RuleAsset;
import org.drools.guvnor.client.util.Format;
import com.google.gwt.core.client.GWT;
@@ -41,7 +40,8 @@
*/
public class RuleValidatorWrapper extends DirtyableComposite
implements
- SaveEventListener {
+ SaveEventListener,
+ EditorWidget {
private static Constants constants = GWT.create( Constants.class );
private static Images images = GWT.create( Images.class );
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-12-07 12:18:43 UTC (rev 36229)
+++ labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/ruleeditor/RuleViewer.java 2010-12-07 12:19:52 UTC (rev 36230)
@@ -16,6 +16,8 @@
package org.drools.guvnor.client.ruleeditor;
+import java.util.Set;
+
import org.drools.guvnor.client.common.AssetFormats;
import org.drools.guvnor.client.common.DirtyableComposite;
import org.drools.guvnor.client.common.ErrorPopup;
@@ -23,28 +25,41 @@
import org.drools.guvnor.client.common.GenericCallback;
import org.drools.guvnor.client.common.LoadingPopup;
import org.drools.guvnor.client.common.RulePackageSelector;
+import org.drools.guvnor.client.common.StatusChangePopup;
import org.drools.guvnor.client.messages.Constants;
+import org.drools.guvnor.client.modeldriven.ui.RuleModelEditor;
+import org.drools.guvnor.client.modeldriven.ui.RuleModeller;
+import org.drools.guvnor.client.packages.PackageBuilderWidget;
import org.drools.guvnor.client.packages.SuggestionCompletionCache;
+import org.drools.guvnor.client.packages.WorkingSetManager;
+import org.drools.guvnor.client.qa.VerifierResultWidget;
import org.drools.guvnor.client.resources.Images;
+import org.drools.guvnor.client.rpc.AnalysisReport;
+import org.drools.guvnor.client.rpc.BuilderResult;
import org.drools.guvnor.client.rpc.RepositoryServiceFactory;
import org.drools.guvnor.client.rpc.RuleAsset;
+import org.drools.guvnor.client.rpc.VerificationService;
+import org.drools.guvnor.client.rpc.VerificationServiceAsync;
+import org.drools.guvnor.client.ruleeditor.toolbar.ActionToolbar;
+import org.drools.guvnor.client.ruleeditor.toolbar.ActionToolbarButtonsConfigurationProvider;
+import org.drools.guvnor.client.ruleeditor.toolbar.DefaultActionToolbarButtonsConfigurationProvider;
import org.drools.guvnor.client.rulelist.EditItemEvent;
import org.drools.guvnor.client.util.Format;
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.uibinder.client.UiBinder;
+import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.user.client.Command;
import com.google.gwt.user.client.Window;
+import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.HTML;
-import com.google.gwt.user.client.ui.HasHorizontalAlignment;
import com.google.gwt.user.client.ui.HorizontalPanel;
+import com.google.gwt.user.client.ui.ScrollPanel;
import com.google.gwt.user.client.ui.TextBox;
-import com.google.gwt.user.client.ui.VerticalPanel;
import com.google.gwt.user.client.ui.Widget;
-import org.drools.guvnor.client.ruleeditor.toolbar.ActionToolbar;
-import org.drools.guvnor.client.ruleeditor.toolbar.ActionToolbarButtonsConfigurationProvider;
/**
* The main layout parent/controller the rule viewer.
@@ -53,26 +68,41 @@
*/
public class RuleViewer extends GuvnorEditor {
- private Constants constants = GWT.create( Constants.class );
- private static Images images = GWT.create( Images.class );
+ private Constants constants = GWT.create( Constants.class );
+ private static Images images = GWT.create( Images.class );
+ interface RuleViewerBinder
+ extends
+ UiBinder<Widget, RuleViewer> {
+ }
+
+ private static RuleViewerBinder uiBinder = GWT.create( RuleViewerBinder.class );
+
+ @UiField(provided = true)
+ final MetaDataWidget metaWidget;
+
+ @UiField(provided = true)
+ final RuleDocumentWidget ruleDocumentWidget;
+
+ @UiField(provided = true)
+ final EditorWidget editor;
+
+ @UiField(provided = true)
+ final ActionToolbar toolbar;
+
+ @UiField
+ MessageWidget messageWidget;
+
+ private Command afterCheckinEvent;
private Command closeCommand;
private Command archiveCommand;
public Command checkedInCommand;
- public ActionToolbar.CheckinAction checkInCommand;
protected RuleAsset asset;
private boolean readOnly;
private final RuleViewerSettings ruleViewerSettings;
- private MetaDataWidget metaWidget;
- private RuleDocumentWidget ruleDocumentWidget;
- private Widget editor;
- private ActionToolbar toolbar;
- private VerticalPanel layout;
- private HorizontalPanel hsp;
-
private long lastSaved = System.currentTimeMillis();
private final EditItemEvent editEvent;
@@ -124,34 +154,25 @@
this.ruleViewerSettings = ruleViewerSettings;
}
- this.layout = new VerticalPanel();
-
this.actionToolbarButtonsConfigurationProvider = actionToolbarButtonsConfigurationProvider;
- layout.setWidth( "100%" );
- layout.setHeight( "100%" );
+ ruleDocumentWidget = new RuleDocumentWidget( asset,
+ this.ruleViewerSettings.isDocoVisible() );
- this.checkInCommand = new ActionToolbar.CheckinAction() {
- public void doCheckin(String comment) {
- if ( editor instanceof SaveEventListener ) {
- ((SaveEventListener) editor).onSave();
- }
- performCheckIn( comment );
- if ( editor instanceof SaveEventListener ) {
- ((SaveEventListener) editor).onAfterSave();
- }
- if ( checkedInCommand != null ) {
- checkedInCommand.execute();
- }
- lastSaved = System.currentTimeMillis();
- resetDirty();
- }
- };
+ metaWidget = createMetaWidget();
- initWidget( layout );
+ metaWidget.setVisible( this.ruleViewerSettings.isMetaVisible() );
- doWidgets( null );
+ editor = EditorLauncher.getEditorViewer( asset,
+ this );
+ toolbar = new ActionToolbar( getConfiguration(),
+ asset.metaData.status );
+
+ initWidget( uiBinder.createAndBindUi( this ) );
+
+ doWidgets();
+
LoadingPopup.close();
}
@@ -170,109 +191,254 @@
return (System.currentTimeMillis() - lastSaved) > 3600000;
}
+ private ActionToolbarButtonsConfigurationProvider getConfiguration() {
+ if ( actionToolbarButtonsConfigurationProvider == null ) {
+ return new DefaultActionToolbarButtonsConfigurationProvider( asset,
+ this );
+ } else {
+ return actionToolbarButtonsConfigurationProvider;
+ }
+
+ }
+
/**
* This will actually load up the data (this is called by the callback)
* when we get the data back from the server,
* also determines what widgets to load up).
*/
- private void doWidgets(Widget messageWidget) {
- layout.clear();
+ private void doWidgets() {
- editor = EditorLauncher.getEditorViewer( asset,
- this );
-
//the action widgets (checkin/close etc).
- toolbar = new ActionToolbar( asset,
- readOnly,
- editor,
- actionToolbarButtonsConfigurationProvider,
- checkInCommand,
- new Command() {
- public void execute() {
- doArchive();
- }
- },
- new Command() {
- public void execute() {
- doDelete();
- }
- },
- new Command() {
- public void execute() {
- close();
- }
- },
- new Command() {
- public void execute() {
- doCopy();
- }
- },
- new Command() {
- public void execute() {
- doPromptToGlobal();
- }
- } );
+ if ( readOnly || asset.isreadonly ) {
+ toolbar.setVisible( false );
+ } else {
+ toolbar.setPromtToGlobalCommand( new Command() {
+ public void execute() {
+ doPromptToGlobal();
+ }
+ } );
+ toolbar.setDeleteCommand( new Command() {
+ public void execute() {
+ doDelete();
+ }
+ } );
+ toolbar.setCopyCommand( new Command() {
+ public void execute() {
+ doCopy();
+ }
+ } );
+ toolbar.setArciveCommand( new Command() {
+ public void execute() {
+ doArchive();
+ }
+ } );
+ this.afterCheckinEvent = new Command() {
+ public void execute() {
+ toolbar.setDeleteVisible( false );
+ toolbar.setArchiveVisible( true );
+ }
+ };
- //layout.add(toolbar, DockPanel.NORTH);
- layout.add( toolbar );
- layout.setCellHeight( toolbar,
- "30px" );
- layout.setCellHorizontalAlignment( toolbar,
- HasHorizontalAlignment.ALIGN_LEFT );
- layout.setCellWidth( toolbar,
- "100%" );
+ toolbar.setSelectWorkingSetsCommand( new Command() {
+ public void execute() {
+ showWorkingSetsSelection( ((RuleModelEditor) editor).getRuleModeller() );
+ }
+ } );
+ toolbar.setViewSourceCommand( new Command() {
+ public void execute() {
+ onSave();
+ LoadingPopup.showMessage( constants.CalculatingSource() );
+ RepositoryServiceFactory.getService().buildAssetSource( asset,
+ new GenericCallback<String>() {
- if ( messageWidget != null ) {
- layout.add( messageWidget );
+ public void onSuccess(String src) {
+ showSource( src );
+ }
+ } );
+
+ }
+ } );
+
+ toolbar.setVerifyCommand( new Command() {
+ public void execute() {
+ doVerify();
+ }
+ } );
+
+ toolbar.setValidateCommand( new Command() {
+ public void execute() {
+ onSave();
+ LoadingPopup.showMessage( constants.ValidatingItemPleaseWait() );
+ RepositoryServiceFactory.getService().buildAsset( asset,
+ new GenericCallback<BuilderResult>() {
+
+ public void onSuccess(BuilderResult results) {
+ RuleValidatorWrapper.showBuilderErrors( results );
+ }
+ } );
+
+ }
+ } );
+
+ toolbar.setSaveChangesCommand( new Command() {
+ public void execute() {
+ verifyAndDoCheckinConfirm( false );
+ }
+ } );
+
+ toolbar.setSaveChangesAndCloseCommand( new Command() {
+ public void execute() {
+ verifyAndDoCheckinConfirm( true );
+ }
+ } );
+
+ toolbar.setChangeStatusCommand( new Command() {
+ public void execute() {
+ showStatusChanger();
+ }
+ } );
}
+ }
- doMetaWidget();
+ /**
+ * Show the stats change popup.
+ */
+ private void showStatusChanger() {
+ final StatusChangePopup pop = new StatusChangePopup( asset.uuid,
+ false );
+ pop.setChangeStatusEvent( new Command() {
- hsp = new HorizontalPanel();
- hsp.setHeight( "100%" );
- hsp.setWidth( "100%" );
- layout.add( hsp );
- layout.setCellHeight( hsp,
- "100%" );
+ public void execute() {
+ toolbar.setState( pop.getState() );
+ }
+ } );
- //the document widget
- ruleDocumentWidget = new RuleDocumentWidget( asset,
- ruleViewerSettings.isDocoVisible() );
+ pop.show();
+ }
- VerticalPanel vert = new VerticalPanel();
- vert.setWidth( "100%" );
- vert.setHeight( "100%" );
+ protected void verifyAndDoCheckinConfirm(final boolean closeAfter) {
+ if ( editor instanceof RuleModeller ) {
+ ((RuleModeller) editor).verifyRule( new Command() {
- vert.add( editor );
- vert.setCellHeight( editor,
- "100%" );
- hsp.add( vert );
+ public void execute() {
+ if ( ((RuleModeller) editor).hasVerifierErrors() || ((RuleModeller) editor).hasVerifierWarnings() ) {
+ if ( !Window.confirm( constants.theRuleHasErrorsOrWarningsDotDoYouWantToContinue() ) ) {
+ return;
+ }
+ }
+ doCheckinConfirm( closeAfter );
+ }
+ } );
+ } else {
+ doCheckinConfirm( closeAfter );
+ }
+ }
- hsp.add( metaWidget );
+ /**
+ * Called when user wants to checkin.
+ * set closeAfter to true if it should close this whole thing after saving it.
+ */
+ protected void doCheckinConfirm(final boolean closeAfter) {
+ final CheckinPopup pop = new CheckinPopup( constants.CheckInChanges() );
+ pop.setCommand( new Command() {
- hsp.setCellWidth( metaWidget,
- "25%" );
+ public void execute() {
+ doCheckin( pop.getCheckinComment() );
+ if ( afterCheckinEvent != null ) {
+ afterCheckinEvent.execute();
+ }
+ if ( closeAfter ) {
+ close();
+ }
+ }
+ } );
+ pop.show();
+ }
- layout.add( ruleDocumentWidget );
+ public void doCheckin(String comment) {
+ if ( editor instanceof SaveEventListener ) {
+ ((SaveEventListener) editor).onSave();
+ }
+ performCheckIn( comment );
+ if ( editor instanceof SaveEventListener ) {
+ ((SaveEventListener) editor).onAfterSave();
+ }
+ if ( checkedInCommand != null ) {
+ checkedInCommand.execute();
+ }
+ lastSaved = System.currentTimeMillis();
+ resetDirty();
}
- private void doMetaWidget() {
- metaWidget = new MetaDataWidget( this.asset.metaData,
- readOnly,
- this.asset.uuid,
- new Command() {
- public void execute() {
- refreshMetaWidgetOnly();
+ private void doVerify() {
+ onSave();
+ LoadingPopup.showMessage( constants.VerifyingItemPleaseWait() );
+ Set<String> activeWorkingSets = null;
+ activeWorkingSets = WorkingSetManager.getInstance().getActiveAssetUUIDs( asset.metaData.packageName );
+
+ VerificationServiceAsync verificationService = GWT.create( VerificationService.class );
+
+ verificationService.verifyAsset( asset,
+ activeWorkingSets,
+ new AsyncCallback<AnalysisReport>() {
+
+ public void onSuccess(AnalysisReport report) {
+ LoadingPopup.close();
+ final FormStylePopup form = new FormStylePopup( images.ruleAsset(),
+ constants.VerificationReport() );
+ ScrollPanel scrollPanel = new ScrollPanel( new VerifierResultWidget( report,
+ false ) );
+ scrollPanel.setWidth( "100%" );
+ form.addRow( scrollPanel );
+
+ LoadingPopup.close();
+ form.show();
}
- },
- new Command() {
- public void execute() {
- refreshDataAndView();
+
+ public void onFailure(Throwable arg0) {
+ // TODO Auto-generated method stub
}
} );
- metaWidget.setVisible( ruleViewerSettings.isMetaVisible() );
+
}
+ private void showSource(String src) {
+ PackageBuilderWidget.showSource( src,
+ this.asset.metaData.name );
+ LoadingPopup.close();
+ }
+
+ private void onSave() {
+ if ( editor instanceof SaveEventListener ) {
+ SaveEventListener el = (SaveEventListener) editor;
+ el.onSave();
+ // TODO: Use info-area
+
+ }
+ }
+
+ protected void showWorkingSetsSelection(RuleModeller modeller) {
+ new WorkingSetSelectorPopup( modeller,
+ asset ).show();
+ }
+
+ private MetaDataWidget createMetaWidget() {
+ return new MetaDataWidget( this.asset.metaData,
+ readOnly,
+ this.asset.uuid,
+ new Command() {
+ public void execute() {
+ refreshMetaWidgetOnly();
+ }
+ },
+ new Command() {
+ public void execute() {
+ refreshDataAndView();
+ }
+ } );
+
+ }
+
protected boolean hasDirty() {
//not sure how to implement this now.
return false;
@@ -339,11 +505,15 @@
LoadingPopup.close();
saved[0] = true;
- toolbar.showSavedConfirmation();
+ showInfoMessage( constants.SavedOK() );
}
} );
}
+ public void showInfoMessage(String message) {
+ messageWidget.showMessage( message );
+ }
+
/**
* In some cases we will want to flush the package dependency stuff for suggestion completions.
* The user will still need to reload the asset editor though.
@@ -360,20 +530,13 @@
}
}
- /**
- * This will reload the contents from the database, and refresh the widgets.
- */
public void refreshDataAndView() {
- refreshDataAndView( null );
- }
-
- public void refreshDataAndView(final Widget messageWidget) {
LoadingPopup.showMessage( constants.RefreshingItem() );
RepositoryServiceFactory.getService().loadRuleAsset( asset.uuid,
new GenericCallback<RuleAsset>() {
public void onSuccess(RuleAsset asset_) {
asset = asset_;
- doWidgets( messageWidget );
+ doWidgets();
LoadingPopup.close();
}
} );
@@ -393,11 +556,7 @@
new GenericCallback<RuleAsset>() {
public void onSuccess(RuleAsset asset_) {
asset.metaData = asset_.metaData;
- hsp.remove( metaWidget );
- doMetaWidget();
- hsp.add( metaWidget );
- hsp.setCellWidth( metaWidget,
- "25%" );
+ metaWidget.refresh();
if ( showBusy ) LoadingPopup.close();
}
} );
@@ -441,7 +600,7 @@
dis.addClickHandler( new ClickHandler() {
public void onClick(ClickEvent arg0) {
- closeCommand.execute();
+ close();
pop.hide();
}
} );
Added: labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/ruleeditor/RuleViewer.ui.xml
===================================================================
--- labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/ruleeditor/RuleViewer.ui.xml (rev 0)
+++ labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/ruleeditor/RuleViewer.ui.xml 2010-12-07 12:19:52 UTC (rev 36230)
@@ -0,0 +1,40 @@
+<!--
+ 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.
+ -->
+<!DOCTYPE ui:UiBinder SYSTEM "http://dl.google.com/gwt/DTD/xhtml.ent">
+<ui:UiBinder xmlns:ui='urn:ui:com.google.gwt.uibinder'
+ xmlns:gwt='urn:import:com.google.gwt.user.client.ui'
+ xmlns:guvnor-ruleeditor='urn:import:org.drools.guvnor.client.ruleeditor'
+ xmlns:guvnor-toolbar='urn:import:org.drools.guvnor.client.ruleeditor.toolbar'>
+
+ <ui:with field='roundCornersResource' type='org.drools.guvnor.client.resources.RoundedCornersResource'/>
+
+ <ui:with field="i18n" type="org.drools.guvnor.client.messages.Constants" />
+
+
+
+ <gwt:HTMLPanel>
+ <gwt:VerticalPanel width="100%">
+ <guvnor-toolbar:ActionToolbar ui:field="toolbar"></guvnor-toolbar:ActionToolbar>
+ <guvnor-ruleeditor:MessageWidget ui:field="messageWidget"></guvnor-ruleeditor:MessageWidget>
+ <gwt:HorizontalPanel>
+ <guvnor-ruleeditor:EditorWidget ui:field="editor"></guvnor-ruleeditor:EditorWidget>
+ <guvnor-ruleeditor:MetaDataWidget ui:field="metaWidget"></guvnor-ruleeditor:MetaDataWidget>
+ </gwt:HorizontalPanel>
+ <guvnor-ruleeditor:RuleDocumentWidget ui:field="ruleDocumentWidget"></guvnor-ruleeditor:RuleDocumentWidget>
+ </gwt:VerticalPanel>
+ </gwt:HTMLPanel>
+
+</ui:UiBinder>
\ No newline at end of file
Modified: labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/ruleeditor/WorkingSetEditor.java
===================================================================
--- labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/ruleeditor/WorkingSetEditor.java 2010-12-07 12:18:43 UTC (rev 36229)
+++ labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/ruleeditor/WorkingSetEditor.java 2010-12-07 12:19:52 UTC (rev 36230)
@@ -1,4 +1,4 @@
-/**
+/*
* Copyright 2010 JBoss Inc
*
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -23,13 +23,13 @@
import java.util.Set;
import org.drools.factconstraints.client.helper.ConstraintsContainer;
+import org.drools.factconstraints.client.helper.CustomFormsContainer;
import org.drools.guvnor.client.common.AssetFormats;
import org.drools.guvnor.client.common.SmallLabel;
import org.drools.guvnor.client.packages.SuggestionCompletionCache;
import org.drools.guvnor.client.rpc.RuleAsset;
import org.drools.guvnor.client.rpc.WorkingSetConfigData;
import org.drools.ide.common.client.modeldriven.SuggestionCompletionEngine;
-import org.drools.factconstraints.client.helper.CustomFormsContainer;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
@@ -42,28 +42,29 @@
import com.google.gwt.user.client.ui.ScrollPanel;
import com.google.gwt.user.client.ui.TabPanel;
+public class WorkingSetEditor extends Composite
+ implements
+ EditorWidget {
-public class WorkingSetEditor extends Composite {
+ private RuleAsset workingSet;
+ private ListBox availFacts = new ListBox( true );
+ private ListBox validFacts = new ListBox( true );
+ private ConstraintsContainer cc;
+ private CustomFormsContainer cfc;
- private RuleAsset workingSet;
- private ListBox availFacts = new ListBox(true);
- private ListBox validFacts = new ListBox(true);
- private ConstraintsContainer cc;
- private CustomFormsContainer cfc;
-
private FactsConstraintsEditorPanel factsConstraintsgEditorPanel;
- private CustomFormsEditorPanel customFormsEditorPanel;
+ private CustomFormsEditorPanel customFormsEditorPanel;
public WorkingSetEditor(RuleAsset asset) {
- if (!AssetFormats.WORKING_SET.equals(asset.metaData.format)) {
- throw new IllegalArgumentException("asset must a be a workingset not a: " + asset.metaData.format);
+ if ( !AssetFormats.WORKING_SET.equals( asset.metaData.format ) ) {
+ throw new IllegalArgumentException( "asset must a be a workingset not a: " + asset.metaData.format );
}
workingSet = asset;
WorkingSetConfigData wsData = (WorkingSetConfigData) workingSet.content;
- cc = new ConstraintsContainer(wsData.constraints);
- cfc = new CustomFormsContainer(wsData.customForms);
+ cc = new ConstraintsContainer( wsData.constraints );
+ cfc = new CustomFormsContainer( wsData.customForms );
refreshWidgets();
- setWidth("100%");
+ setWidth( "100%" );
}
@@ -73,105 +74,132 @@
TabPanel tPanel = new TabPanel();
//tPanel.setWidth(800);
ScrollPanel pnl = new ScrollPanel();
-// pnl.setAutoWidth(true);
+ // pnl.setAutoWidth(true);
//pnl.setClosable(false);
- pnl.setTitle("WS Definition"); //TODO {bauna} i18n
-// pnl.setAutoHeight(true);
- pnl.add(buildDoubleList(wsData));
- tPanel.add(pnl, "WS Definition");
+ pnl.setTitle( "WS Definition" ); //TODO {bauna} i18n
+ // pnl.setAutoHeight(true);
+ pnl.add( buildDoubleList( wsData ) );
+ tPanel.add( pnl,
+ "WS Definition" );
pnl = new ScrollPanel();
-// pnl.setAutoWidth(true);
+ // pnl.setAutoWidth(true);
//pnl.setClosable(false);
//pnl.setTitle("WS Constraints"); //TODO {bauna} i18n
-// pnl.setAutoHeight(true);
- this.factsConstraintsgEditorPanel = new FactsConstraintsEditorPanel(this);
- pnl.add(this.factsConstraintsgEditorPanel);
- tPanel.add(pnl, "WS Constraints");
+ // pnl.setAutoHeight(true);
+ this.factsConstraintsgEditorPanel = new FactsConstraintsEditorPanel( this );
+ pnl.add( this.factsConstraintsgEditorPanel );
+ tPanel.add( pnl,
+ "WS Constraints" );
pnl = new ScrollPanel();
-// pnl.setAutoWidth(true);
+ // pnl.setAutoWidth(true);
//pnl.setClosable(false);
- pnl.setTitle("WS Custom Forms"); //TODO {bauna} i18n
-// pnl.setAutoHeight(true);
- this.customFormsEditorPanel = new CustomFormsEditorPanel(this);
- pnl.add(this.customFormsEditorPanel);
- tPanel.add(pnl, "WS Custom Forms");
- tPanel.addBeforeSelectionHandler(new BeforeSelectionHandler<java.lang.Integer>() {
+ pnl.setTitle( "WS Custom Forms" ); //TODO {bauna} i18n
+ // pnl.setAutoHeight(true);
+ this.customFormsEditorPanel = new CustomFormsEditorPanel( this );
+ pnl.add( this.customFormsEditorPanel );
+ tPanel.add( pnl,
+ "WS Custom Forms" );
+ tPanel.addBeforeSelectionHandler( new BeforeSelectionHandler<java.lang.Integer>() {
- public void onBeforeSelection(BeforeSelectionEvent<java.lang.Integer> arg0) {
+ public void onBeforeSelection(BeforeSelectionEvent<java.lang.Integer> arg0) {
factsConstraintsgEditorPanel.fillSelectedFacts();
customFormsEditorPanel.fillSelectedFacts();
}
-
- });
+ } );
- tPanel.selectTab(0);
- initWidget(tPanel);
+ tPanel.selectTab( 0 );
+ initWidget( tPanel );
}
private Grid buildDoubleList(WorkingSetConfigData wsData) {
- Grid grid = new Grid(2, 3);
+ Grid grid = new Grid( 2,
+ 3 );
- SuggestionCompletionEngine sce = SuggestionCompletionCache.getInstance().getEngineFromCache(workingSet.metaData.packageName);
+ SuggestionCompletionEngine sce = SuggestionCompletionCache.getInstance().getEngineFromCache( workingSet.metaData.packageName );
boolean filteringFact = sce.isFilteringFacts();
- sce.setFilteringFacts(false);
+ sce.setFilteringFacts( false );
try {
Set<String> elem = new HashSet<String>();
- availFacts.setVisibleItemCount(10);
- validFacts.setVisibleItemCount(10);
+ availFacts.setVisibleItemCount( 10 );
+ validFacts.setVisibleItemCount( 10 );
- if (wsData.validFacts != null) {
- elem.addAll(Arrays.asList(wsData.validFacts));
- for (String factName : wsData.validFacts) {
- validFacts.addItem(factName);
+ if ( wsData.validFacts != null ) {
+ elem.addAll( Arrays.asList( wsData.validFacts ) );
+ for ( String factName : wsData.validFacts ) {
+ validFacts.addItem( factName );
}
}
- for (String factName : sce.getFactTypes()) {
- if (!elem.contains(factName)) {
- availFacts.addItem(factName);
+ for ( String factName : sce.getFactTypes() ) {
+ if ( !elem.contains( factName ) ) {
+ availFacts.addItem( factName );
}
}
- Grid btnsPanel = new Grid(2, 1);
+ Grid btnsPanel = new Grid( 2,
+ 1 );
- btnsPanel.setWidget(0, 0, new Button(">", new ClickHandler() {
+ btnsPanel.setWidget( 0,
+ 0,
+ new Button( ">",
+ new ClickHandler() {
- public void onClick(ClickEvent sender) {
- copySelected(availFacts, validFacts);
- updateAsset(validFacts);
- factsConstraintsgEditorPanel.fillSelectedFacts();
- customFormsEditorPanel.fillSelectedFacts();
- }
- }));
+ public void onClick(ClickEvent sender) {
+ copySelected( availFacts,
+ validFacts );
+ updateAsset( validFacts );
+ factsConstraintsgEditorPanel.fillSelectedFacts();
+ customFormsEditorPanel.fillSelectedFacts();
+ }
+ } ) );
- btnsPanel.setWidget(1, 0, new Button("<", new ClickHandler() {
+ btnsPanel.setWidget( 1,
+ 0,
+ new Button( "<",
+ new ClickHandler() {
- public void onClick(ClickEvent sender) {
- copySelected(validFacts, availFacts);
- updateAsset(validFacts);
- factsConstraintsgEditorPanel.fillSelectedFacts();
- customFormsEditorPanel.fillSelectedFacts();
- }
- }));
+ public void onClick(ClickEvent sender) {
+ copySelected( validFacts,
+ availFacts );
+ updateAsset( validFacts );
+ factsConstraintsgEditorPanel.fillSelectedFacts();
+ customFormsEditorPanel.fillSelectedFacts();
+ }
+ } ) );
- grid.setWidget(0, 0, new SmallLabel("Available Facts")); //TODO i18n
- grid.setWidget(0, 1, new SmallLabel(""));
- grid.setWidget(0, 2, new SmallLabel("WorkingSet Facts")); //TODO i18n
- grid.setWidget(1, 0, availFacts);
- grid.setWidget(1, 1, btnsPanel);
- grid.setWidget(1, 2, validFacts);
+ grid.setWidget( 0,
+ 0,
+ new SmallLabel( "Available Facts" ) ); //TODO i18n
+ grid.setWidget( 0,
+ 1,
+ new SmallLabel( "" ) );
+ grid.setWidget( 0,
+ 2,
+ new SmallLabel( "WorkingSet Facts" ) ); //TODO i18n
+ grid.setWidget( 1,
+ 0,
+ availFacts );
+ grid.setWidget( 1,
+ 1,
+ btnsPanel );
+ grid.setWidget( 1,
+ 2,
+ validFacts );
- grid.getColumnFormatter().setWidth(0, "45%");
- grid.getColumnFormatter().setWidth(0, "10%");
- grid.getColumnFormatter().setWidth(0, "45%");
+ grid.getColumnFormatter().setWidth( 0,
+ "45%" );
+ grid.getColumnFormatter().setWidth( 0,
+ "10%" );
+ grid.getColumnFormatter().setWidth( 0,
+ "45%" );
return grid;
} finally {
- sce.setFilteringFacts(filteringFact);
+ sce.setFilteringFacts( filteringFact );
}
}
@@ -179,18 +207,19 @@
* This will get the save widgets.
*/
private void updateAsset(ListBox availFacts) {
- List<String> l = new ArrayList<String>(availFacts.getItemCount());
- for (int i = 0; i < availFacts.getItemCount(); i++) {
- l.add(availFacts.getItemText(i));
+ List<String> l = new ArrayList<String>( availFacts.getItemCount() );
+ for ( int i = 0; i < availFacts.getItemCount(); i++ ) {
+ l.add( availFacts.getItemText( i ) );
}
- ((WorkingSetConfigData) workingSet.content).validFacts = l.toArray(new String[l.size()]);
+ ((WorkingSetConfigData) workingSet.content).validFacts = l.toArray( new String[l.size()] );
}
- private void copySelected(final ListBox from, final ListBox to) {
+ private void copySelected(final ListBox from,
+ final ListBox to) {
int selected;
- while ((selected = from.getSelectedIndex()) != -1) {
- to.addItem(from.getItemText(selected));
- from.removeItem(selected);
+ while ( (selected = from.getSelectedIndex()) != -1 ) {
+ to.addItem( from.getItemText( selected ) );
+ from.removeItem( selected );
factsConstraintsgEditorPanel.notifyValidFactsChanged();
customFormsEditorPanel.notifyValidFactsChanged();
}
Modified: labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/ruleeditor/toolbar/ActionToolbar.java
===================================================================
--- labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/ruleeditor/toolbar/ActionToolbar.java 2010-12-07 12:18:43 UTC (rev 36229)
+++ labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/ruleeditor/toolbar/ActionToolbar.java 2010-12-07 12:19:52 UTC (rev 36230)
@@ -15,466 +15,173 @@
*/
package org.drools.guvnor.client.ruleeditor.toolbar;
-import java.util.Set;
+import org.drools.guvnor.client.messages.Constants;
+import org.drools.guvnor.client.util.Format;
import com.google.gwt.core.client.GWT;
+import com.google.gwt.uibinder.client.UiBinder;
+import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.user.client.Command;
-import com.google.gwt.user.client.Timer;
import com.google.gwt.user.client.Window;
-import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.ui.Composite;
-import com.google.gwt.user.client.ui.MenuBar;
+import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.MenuItem;
-import com.google.gwt.user.client.ui.ScrollPanel;
import com.google.gwt.user.client.ui.Widget;
-import org.drools.guvnor.client.common.*;
-import org.drools.guvnor.client.messages.Constants;
-import org.drools.guvnor.client.qa.VerifierResultWidget;
-import org.drools.guvnor.client.resources.Images;
-import org.drools.guvnor.client.rpc.AnalysisReport;
-import org.drools.guvnor.client.rpc.RepositoryServiceFactory;
-import org.drools.guvnor.client.rpc.RuleAsset;
-import org.drools.guvnor.client.rpc.BuilderResult;
-import org.drools.guvnor.client.rpc.VerificationService;
-import org.drools.guvnor.client.rpc.VerificationServiceAsync;
-import org.drools.guvnor.client.modeldriven.ui.RuleModelEditor;
-import org.drools.guvnor.client.modeldriven.ui.RuleModeller;
-import org.drools.guvnor.client.util.Format;
-import org.drools.guvnor.client.packages.PackageBuilderWidget;
-import org.drools.guvnor.client.packages.WorkingSetManager;
-import org.drools.guvnor.client.ruleeditor.CheckinPopup;
-import org.drools.guvnor.client.ruleeditor.RuleValidatorWrapper;
-import org.drools.guvnor.client.ruleeditor.SaveEventListener;
-import org.drools.guvnor.client.ruleeditor.WorkingSetSelectorPopup;
/**
* This contains the widgets used to action a rule asset
* (ie checkin, change state, close window)
+ *
* @author Michael Neale
*/
public class ActionToolbar extends Composite {
- private Constants constants = GWT.create( Constants.class );
- private static Images images = GWT.create( Images.class );
+ private Constants constants = GWT.create( Constants.class );
- private MenuBar toolbar = new MenuBar();
- private CheckinAction checkinAction;
- private Command archiveAction;
- private Command deleteAction;
- private MenuItem state = new MenuItem( constants.Status() + " ",
- new Command() {
-
- public void execute() {
- // Why can't there be a simple text menu item.
- }
- } );
- final private RuleAsset asset;
- private Command afterCheckinEvent;
- private MenuItem savedOK;
- private Widget editor;
- private Command closeCommand;
- private Command copyCommand;
- private Command promptCommand;
- private ActionToolbarButtonsConfigurationProvider actionToolbarButtonsConfigurationProvider;
-
- public ActionToolbar(final RuleAsset asset,
- boolean readOnly,
- Widget editor,
- final CheckinAction checkin,
- final Command archiv,
- final Command delete,
- Command closeCommand,
- Command copyCommand,
- Command promptCommand) {
- this( asset,
- readOnly,
- editor,
- null,
- checkin,
- archiv,
- delete,
- closeCommand,
- copyCommand,
- promptCommand );
+ interface ActionToolbarBinder
+ extends
+ UiBinder<Widget, ActionToolbar> {
}
- public ActionToolbar(final RuleAsset asset,
- boolean readOnly,
- Widget editor,
- ActionToolbarButtonsConfigurationProvider actionToolbarButtonsConfigurationProvider,
- final CheckinAction checkin,
- final Command archiv,
- final Command delete,
- Command closeCommand,
- Command copyCommand,
- Command promptCommand) {
+ private static ActionToolbarBinder uiBinder = GWT.create( ActionToolbarBinder.class );
- this.checkinAction = checkin;
- this.archiveAction = archiv;
- this.deleteAction = delete;
- this.asset = asset;
- this.editor = editor;
- this.closeCommand = closeCommand;
- this.copyCommand = copyCommand;
- this.promptCommand = promptCommand;
+ @UiField
+ MenuItem saveChanges;
- //By default ActionToolbar uses a DefaultActionToolbarButtonsConfigurationProvider
- if ( actionToolbarButtonsConfigurationProvider == null ) {
- this.actionToolbarButtonsConfigurationProvider = new DefaultActionToolbarButtonsConfigurationProvider( asset,
- editor );
- } else {
- this.actionToolbarButtonsConfigurationProvider = actionToolbarButtonsConfigurationProvider;
- }
+ @UiField
+ MenuItem saveChangesAndClose;
- String status = asset.metaData.status;
+ @UiField
+ MenuItem archive;
- setState( status );
+ @UiField
+ MenuItem delete;
- if ( !readOnly && !asset.isreadonly ) {
- controls();
- }
+ @UiField
+ MenuItem copy;
- if ( this.actionToolbarButtonsConfigurationProvider.showStateLabel() ) {
- toolbar.addItem( this.state );
- }
+ @UiField
+ MenuItem promoteToGlobal;
- initWidget( toolbar );
- }
+ @UiField
+ MenuItem selectWorkingSets;
- /**
- * Show the saved OK message for a little while *.
- */
- public void showSavedConfirmation() {
- savedOK.setVisible( true );
- Timer t = new Timer() {
+ @UiField
+ MenuItem validate;
- public void run() {
- savedOK.setVisible( false );
- }
- };
- t.schedule( 1500 );
- }
+ @UiField
+ MenuItem verify;
- /**
- * Sets the visible status display.
- */
- private void setState(String status) {
- state.setHTML( Format.format( constants.statusIs(),
- status ) );
- }
+ @UiField
+ MenuItem viewSource;
- private void controls() {
+ @UiField
+ MenuItem changeStatus;
- if ( actionToolbarButtonsConfigurationProvider.showSaveButton() ) {
- MenuItem save = new MenuItem( constants.SaveChanges(),
- new Command() {
+ @UiField
+ Label status;
- public void execute() {
- verifyAndDoCheckinConfirm( false );
- }
- } );
+ private ActionToolbarButtonsConfigurationProvider actionToolbarButtonsConfigurationProvider;
- save.setTitle( constants.CommitAnyChangesForThisAsset() );
- toolbar.addItem( save );
- }
+ public ActionToolbar(ActionToolbarButtonsConfigurationProvider actionToolbarButtonsConfigurationProvider,
+ String status) {
- if ( actionToolbarButtonsConfigurationProvider.showSaveAndCloseButton() ) {
- MenuItem saveAndClose = new MenuItem( constants.SaveAndClose(),
- new Command() {
+ initWidget( uiBinder.createAndBindUi( this ) );
- public void execute() {
- verifyAndDoCheckinConfirm( true );
- }
- } );
- saveAndClose.setTitle( constants.CommitAnyChangesForThisAsset() );
- toolbar.addItem( saveAndClose );
- }
+ this.actionToolbarButtonsConfigurationProvider = actionToolbarButtonsConfigurationProvider;
- savedOK = new MenuItem( constants.SavedOK(),
- new Command() {
+ setState( status );
- public void execute() {
- // Nothing here
- // TODO : MOVE THIS TEXT TO INFO AREA
- }
- } );
- savedOK.setVisible( false );
+ applyToolBarConfiguration();
- toolbar.addItem( savedOK );
+ this.status.setVisible( this.actionToolbarButtonsConfigurationProvider.showStateLabel() );
+ }
- toolbar.addSeparator();
+ /**
+ * Sets the visible status display.
+ */
+ public void setState(String newStatus) {
+ status.setText( Format.format( constants.statusIs(),
+ newStatus ) );
+ }
- //Select Working Sets button
- if ( actionToolbarButtonsConfigurationProvider.showSelectWorkingSetsButton() ) {
+ private void applyToolBarConfiguration() {
+ saveChanges.setVisible( actionToolbarButtonsConfigurationProvider.showSaveButton() );
+ saveChangesAndClose.setVisible( actionToolbarButtonsConfigurationProvider.showSaveAndCloseButton() );
+ validate.setVisible( actionToolbarButtonsConfigurationProvider.showValidateButton() );
+ verify.setVisible( actionToolbarButtonsConfigurationProvider.showValidateButton() );
+ viewSource.setVisible( actionToolbarButtonsConfigurationProvider.showViewSourceButton() );
+ copy.setVisible( actionToolbarButtonsConfigurationProvider.showCopyButton() );
+ promoteToGlobal.setVisible( actionToolbarButtonsConfigurationProvider.showPromoteToGlobalButton() );
+ archive.setVisible( actionToolbarButtonsConfigurationProvider.showArchiveButton() );
+ delete.setVisible( actionToolbarButtonsConfigurationProvider.showDeleteButton() );
+ changeStatus.setVisible( actionToolbarButtonsConfigurationProvider.showChangeStatusButton() );
+ selectWorkingSets.setVisible( actionToolbarButtonsConfigurationProvider.showSelectWorkingSetsButton() );
+ }
- if ( editor instanceof RuleModelEditor ) {
- toolbar.addItem( new MenuItem( constants.SelectWorkingSets(),
- new Command() {
+ public void setSelectWorkingSetsCommand(Command command) {
+ selectWorkingSets.setCommand( command );
+ }
- public void execute() {
- showWorkingSetsSelection( ((RuleModelEditor) editor).getRuleModeller() );
- }
- } ) );
- }
- }
-
- //Validate button
- if ( actionToolbarButtonsConfigurationProvider.showValidateButton() ) {
- toolbar.addItem( constants.Validate(),
- new Command() {
-
- public void execute() {
- doValidate();
- }
- } );
- }
-
- //Verify button
- if ( actionToolbarButtonsConfigurationProvider.showValidateButton() ) {
- toolbar.addItem( constants.Verify(),
- new Command() {
-
- public void execute() {
- doVerify();
- }
- } );
- }
-
- //View Source button
- if ( actionToolbarButtonsConfigurationProvider.showViewSourceButton() ) {
- toolbar.addItem( constants.ViewSource(),
- new Command() {
-
- public void execute() {
- doViewsource();
- }
- } );
- }
-
- //More.. menu
- MenuBar moreMenu = new MenuBar( true );
- boolean moreMenuHasChildren = false;
- //More -> Copy button
- if ( actionToolbarButtonsConfigurationProvider.showCopyButton() ) {
- moreMenu.addItem( constants.Copy(),
- new Command() {
-
- public void execute() {
- copyCommand.execute();
- }
- } );
- moreMenuHasChildren = true;
- }
-
- //More -> Promote To Global button
- if ( actionToolbarButtonsConfigurationProvider.showPromoteToGlobalButton() ) {
- moreMenu.addItem( constants.PromoteToGlobal(),
- new Command() {
-
- public void execute() {
- promptCommand.execute();
- }
- } );
- moreMenuHasChildren = true;
- }
-
- //More -> Archive button
- if ( actionToolbarButtonsConfigurationProvider.showArchiveButton() ) {
- moreMenu.addItem( constants.Archive(),
- new Command() {
-
- public void execute() {
- if ( Window.confirm( constants.AreYouSureYouWantToArchiveThisItem() + "\n" + constants.ArchiveThisAssetThisWillNotPermanentlyDeleteIt() ) ) {
- archiveAction.execute();
- }
- }
- } );
- moreMenuHasChildren = true;
- }
-
- //More -> Delete button
- if ( actionToolbarButtonsConfigurationProvider.showDeleteButton() ) {
- final MenuItem deleteItem = new MenuItem( constants.Delete(),
- new Command() {
-
- public void execute() {
- if ( Window.confirm( constants.DeleteAreYouSure() ) ) {
- deleteAction.execute();
- }
- }
- } );
-
- moreMenuHasChildren = true;
-
- moreMenu.addItem( deleteItem );
- deleteItem.setTitle( constants.DeleteAssetTooltip() );
-
- this.afterCheckinEvent = new Command() {
-
- public void execute() {
- deleteItem.setVisible( true );
- }
- };
-
- if ( !notCheckedInYet() ) {
- deleteItem.setVisible( true );
- }
- }
-
- //More -> Status Change button
- if ( actionToolbarButtonsConfigurationProvider.showChangeStatusButton() ) {
- moreMenu.addItem( constants.ChangeStatus(),
- new Command() {
-
- public void execute() {
- showStatusChanger();
- }
- } );
- moreMenuHasChildren = true;
- }
-
- //only add moreMenu if it contains at least one child
- if ( moreMenuHasChildren ) {
- toolbar.addItem( constants.MoreDotDot(),
- moreMenu );
- }
+ public void setViewSourceCommand(Command command) {
+ viewSource.setCommand( command );
}
- private void doViewsource() {
- onSave();
- LoadingPopup.showMessage( constants.CalculatingSource() );
- RepositoryServiceFactory.getService().buildAssetSource( this.asset,
- new GenericCallback<String>() {
-
- public void onSuccess(String src) {
- showSource( src );
- }
- } );
+ public void setVerifyCommand(Command command) {
+ verify.setCommand( command );
}
- private void showSource(String src) {
- PackageBuilderWidget.showSource( src,
- this.asset.metaData.name );
- LoadingPopup.close();
+ public void setValidateCommand(Command command) {
+ validate.setCommand( command );
}
- private void doVerify() {
- onSave();
- LoadingPopup.showMessage( constants.VerifyingItemPleaseWait() );
- Set<String> activeWorkingSets = null;
- activeWorkingSets = WorkingSetManager.getInstance().getActiveAssetUUIDs( asset.metaData.packageName );
-
- VerificationServiceAsync verificationService = GWT.create( VerificationService.class );
-
- verificationService.verifyAsset( asset,
- activeWorkingSets,
- new AsyncCallback<AnalysisReport>() {
-
- public void onSuccess(AnalysisReport report) {
- LoadingPopup.close();
- final FormStylePopup form = new FormStylePopup( images.ruleAsset(),
- constants.VerificationReport() );
- ScrollPanel scrollPanel = new ScrollPanel( new VerifierResultWidget( report,
- false ) );
- scrollPanel.setWidth( "100%" );
- form.addRow( scrollPanel );
-
- LoadingPopup.close();
- form.show();
- }
-
- public void onFailure(Throwable arg0) {
- // TODO Auto-generated method stub
- }
- } );
-
+ public void setSaveChangesCommand(Command command) {
+ saveChanges.setCommand( command );
}
- private void doValidate() {
- onSave();
- LoadingPopup.showMessage( constants.ValidatingItemPleaseWait() );
- RepositoryServiceFactory.getService().buildAsset( asset,
- new GenericCallback<BuilderResult>() {
-
- public void onSuccess(BuilderResult results) {
- RuleValidatorWrapper.showBuilderErrors( results );
- }
- } );
+ public void setSaveChangesAndCloseCommand(Command command) {
+ saveChangesAndClose.setCommand( command );
}
- public void onSave() {
- if ( editor instanceof SaveEventListener ) {
- SaveEventListener el = (SaveEventListener) editor;
- el.onSave();
- }
+ public void setChangeStatusCommand(Command command) {
+ changeStatus.setCommand( command );
}
- private boolean notCheckedInYet() {
- return asset.metaData.versionNumber == 0;
+ public void setDeleteVisible(boolean b) {
+ delete.setVisible( b );
}
- protected void verifyAndDoCheckinConfirm(final boolean closeAfter) {
- if ( editor instanceof RuleModeller ) {
- ((RuleModeller) editor).verifyRule( new Command() {
-
- public void execute() {
- if ( ((RuleModeller) editor).hasVerifierErrors() || ((RuleModeller) editor).hasVerifierWarnings() ) {
- if ( !Window.confirm( constants.theRuleHasErrorsOrWarningsDotDoYouWantToContinue() ) ) {
- return;
- }
- }
- doCheckinConfirm( closeAfter );
- }
- } );
- } else {
- doCheckinConfirm( closeAfter );
- }
+ public void setArchiveVisible(boolean b) {
+ archive.setVisible( b );
}
- /**
- * Called when user wants to checkin.
- * set closeAfter to true if it should close this whole thing after saving it.
- */
- protected void doCheckinConfirm(final boolean closeAfter) {
- final CheckinPopup pop = new CheckinPopup( constants.CheckInChanges() );
- pop.setCommand( new Command() {
+ public void setArciveCommand(final Command archiveCommand) {
+ archive.setCommand( new Command() {
public void execute() {
- checkinAction.doCheckin( pop.getCheckinComment() );
- if ( afterCheckinEvent != null ) {
- afterCheckinEvent.execute();
+ if ( Window.confirm( constants.AreYouSureYouWantToArchiveThisItem() + "\n" + constants.ArchiveThisAssetThisWillNotPermanentlyDeleteIt() ) ) {
+ archiveCommand.execute();
}
- if ( closeAfter ) {
- closeCommand.execute();
- }
}
} );
- pop.show();
}
- /**
- * Show the stats change popup.
- */
- private void showStatusChanger() {
- final StatusChangePopup pop = new StatusChangePopup( asset.uuid,
- false );
- pop.setChangeStatusEvent( new Command() {
+ public void setCopyCommand(Command command) {
+ copy.setCommand( command );
+ }
+ public void setDeleteCommand(final Command deleteCommand) {
+ delete.setCommand( new Command() {
+
public void execute() {
- setState( pop.getState() );
+ if ( Window.confirm( constants.DeleteAreYouSure() ) ) {
+ deleteCommand.execute();
+ }
}
} );
-
- pop.show();
}
- protected void showWorkingSetsSelection(RuleModeller modeller) {
- new WorkingSetSelectorPopup( modeller,
- asset ).show();
+ public void setPromtToGlobalCommand(Command command) {
+ promoteToGlobal.setCommand( command );
}
-
- public static interface CheckinAction {
-
- void doCheckin(String comment);
- }
}
Added: labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/ruleeditor/toolbar/ActionToolbar.ui.xml
===================================================================
--- labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/ruleeditor/toolbar/ActionToolbar.ui.xml (rev 0)
+++ labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/ruleeditor/toolbar/ActionToolbar.ui.xml 2010-12-07 12:19:52 UTC (rev 36230)
@@ -0,0 +1,101 @@
+<!--
+ 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.
+ -->
+<!DOCTYPE ui:UiBinder SYSTEM "http://dl.google.com/gwt/DTD/xhtml.ent">
+<ui:UiBinder xmlns:ui='urn:ui:com.google.gwt.uibinder'
+ xmlns:gwt='urn:import:com.google.gwt.user.client.ui' xmlns:guvnor='urn:import:org.drools.guvnor.client.common'>
+
+ <ui:with field='roundCornersResource' type='org.drools.guvnor.client.resources.RoundedCornersResource'/>
+
+ <ui:with field="i18n" type="org.drools.guvnor.client.messages.Constants" />
+
+ <ui:style>
+ .menu-bar {
+ cursor: default;
+ }
+
+ .menu-bar .menu-item {
+ cursor: pointer;
+ color: #666666;
+ font-weight: bold;
+ padding: 0 10px;
+ vertical-align: bottom;
+ }
+
+ .status-label {
+ color: #666666;
+ font-weight: bold;
+ font-style: italic;
+ padding: 0 10px;
+ vertical-align: bottom;
+ }
+ </ui:style>
+
+
+ <gwt:HTMLPanel>
+ <table style='width:100%; border-collapse:collapse;'>
+ <tr>
+ <td style='width:4px;'><div class='{roundCornersResource.roundCornersCss.greyTopLeftCornerClass}'></div></td>
+ <td><div class='{roundCornersResource.roundCornersCss.greyTopClass}'></div></td>
+ <td style='width:4px;'><div class='{roundCornersResource.roundCornersCss.greyTopRightCornerClass}'></div></td>
+ </tr>
+
+ <tr>
+ <td class='{roundCornersResource.roundCornersCss.greySideLeftClass}'></td>
+ <td class='{roundCornersResource.roundCornersCss.greyCenterClass}'>
+ <div style="float:left;">
+ <gwt:MenuBar styleName="{style.menu-bar}">
+ <gwt:MenuItem styleName="{style.menuItem}"><ui:text from="{i18n.File}" />
+ <gwt:MenuBar vertical="true">
+ <gwt:MenuItem ui:field="saveChanges" title="{i18n.CommitAnyChangesForThisAsset}"> <ui:text from="{i18n.SaveAllChanges}" /></gwt:MenuItem>
+ <gwt:MenuItem ui:field="saveChangesAndClose" title="{i18n.CommitAnyChangesForThisAsset}"> <ui:text from="{i18n.SaveAndClose}" /></gwt:MenuItem>
+ <gwt:MenuItem ui:field="archive"> <ui:text from="{i18n.Archive}" /></gwt:MenuItem>
+ <gwt:MenuItem ui:field="delete" title="i18n.DeleteAssetTooltip"> <ui:text from="{i18n.Delete}" /></gwt:MenuItem>
+ </gwt:MenuBar>
+ </gwt:MenuItem>
+ <gwt:MenuItem styleName="{style.menu-item}"><ui:text from="{i18n.Edit}" />
+ <gwt:MenuBar vertical="true">
+ <gwt:MenuItem ui:field="copy"><ui:text from="{i18n.Copy}" /></gwt:MenuItem>
+ <gwt:MenuItem ui:field="promoteToGlobal"><ui:text from="{i18n.PromoteToGlobal}" /></gwt:MenuItem>
+ <gwt:MenuItem ui:field="selectWorkingSets"><ui:text from="{i18n.SelectWorkingSets}" /></gwt:MenuItem>
+ <gwt:MenuItem ui:field="changeStatus"><ui:text from="{i18n.ChangeStatus}" /></gwt:MenuItem>
+ </gwt:MenuBar>
+ </gwt:MenuItem>
+ <gwt:MenuItem styleName="{style.menuItem}"><ui:text from="{i18n.Source}" />
+ <gwt:MenuBar vertical="true">
+ <gwt:MenuItem ui:field="validate"><ui:text from="{i18n.Validate}" /></gwt:MenuItem>
+ <gwt:MenuItem ui:field="verify"><ui:text from="{i18n.Verify}" /></gwt:MenuItem>
+ <gwt:MenuItem ui:field="viewSource"><ui:text from="{i18n.ViewSource}" /></gwt:MenuItem>
+ </gwt:MenuBar>
+ </gwt:MenuItem>
+ </gwt:MenuBar>
+ </div>
+ <div style="float:right;">
+ <gwt:Label ui:field="status" styleName="{style.status-label}"><ui:text from="{i18n.Status}" /></gwt:Label>
+ </div>
+ <div style="clear:both;"></div>
+ </td>
+ <td class='{roundCornersResource.roundCornersCss.greySideRightClass}'></td>
+ </tr>
+
+ <tr>
+ <td style='width:4px;'><div class='{roundCornersResource.roundCornersCss.greyBottomLeftCornerClass}'></div></td>
+ <td><div class='{roundCornersResource.roundCornersCss.greyBottomClass}'></div></td>
+ <td style='width:4px;'><div class='{roundCornersResource.roundCornersCss.greyBottomRightCornerClass}'></div></td>
+ </tr>
+ </table>
+ </gwt:HTMLPanel>
+
+</ui:UiBinder>
\ No newline at end of file
Modified: labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/ruleeditor/toolbar/DefaultActionToolbarButtonsConfigurationProvider.java
===================================================================
--- labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/ruleeditor/toolbar/DefaultActionToolbarButtonsConfigurationProvider.java 2010-12-07 12:18:43 UTC (rev 36229)
+++ labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/ruleeditor/toolbar/DefaultActionToolbarButtonsConfigurationProvider.java 2010-12-07 12:19:52 UTC (rev 36230)
@@ -27,19 +27,22 @@
*
* @author esteban.aliverti
*/
-public class DefaultActionToolbarButtonsConfigurationProvider implements ActionToolbarButtonsConfigurationProvider {
+public class DefaultActionToolbarButtonsConfigurationProvider
+ implements
+ ActionToolbarButtonsConfigurationProvider {
private static String[] VALIDATING_FORMATS = new String[]{BUSINESS_RULE, DSL_TEMPLATE_RULE, DECISION_SPREADSHEET_XLS, DRL, ENUMERATION, DECISION_TABLE_GUIDED, DRL_MODEL, DSL, FUNCTION, RULE_TEMPLATE};
- private static String[] VERIFY_FORMATS = new String[]{BUSINESS_RULE, DECISION_SPREADSHEET_XLS, DRL, DECISION_TABLE_GUIDED, DRL_MODEL, RULE_TEMPLATE};
-
- private RuleAsset asset;
- private Widget editor;
+ private static String[] VERIFY_FORMATS = new String[]{BUSINESS_RULE, DECISION_SPREADSHEET_XLS, DRL, DECISION_TABLE_GUIDED, DRL_MODEL, RULE_TEMPLATE};
- public DefaultActionToolbarButtonsConfigurationProvider(RuleAsset asset,Widget editor) {
+ private RuleAsset asset;
+ private Widget editor;
+
+ public DefaultActionToolbarButtonsConfigurationProvider(RuleAsset asset,
+ Widget editor) {
this.asset = asset;
this.editor = editor;
}
-
+
public boolean showSaveButton() {
return true;
}
@@ -57,11 +60,11 @@
}
public boolean showArchiveButton() {
- return true;
+ return asset.metaData.versionNumber != 0;
}
public boolean showDeleteButton() {
- return true;
+ return asset.metaData.versionNumber == 0;
}
public boolean showChangeStatusButton() {
@@ -83,15 +86,15 @@
public boolean showViewSourceButton() {
return shouldShowViewSource();
}
-
+
public boolean showStateLabel() {
return true;
}
-
+
private boolean isValidatorTypeAsset() {
String format = asset.metaData.format;
- for (String fmt : VALIDATING_FORMATS) {
- if (fmt.equals(format)) {
+ for ( String fmt : VALIDATING_FORMATS ) {
+ if ( fmt.equals( format ) ) {
return true;
}
}
@@ -100,17 +103,16 @@
private boolean isVerificationTypeAsset() {
String format = asset.metaData.format;
- for (String fmt : VERIFY_FORMATS) {
- if (fmt.equals(format)) {
+ for ( String fmt : VERIFY_FORMATS ) {
+ if ( fmt.equals( format ) ) {
return true;
}
}
return false;
}
-
+
private boolean shouldShowViewSource() {
- return CapabilitiesManager.getInstance().shouldShow(Capabilities.SHOW_PACKAGE_VIEW);
+ return CapabilitiesManager.getInstance().shouldShow( Capabilities.SHOW_PACKAGE_VIEW );
}
-
}
Modified: labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/rulelist/QuickFindWidget.java
===================================================================
--- labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/rulelist/QuickFindWidget.java 2010-12-07 12:18:43 UTC (rev 36229)
+++ labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/rulelist/QuickFindWidget.java 2010-12-07 12:19:52 UTC (rev 36230)
@@ -30,6 +30,7 @@
import org.drools.guvnor.client.rpc.TableDataResult;
import org.drools.guvnor.client.rpc.TableDataRow;
import org.drools.guvnor.client.ruleeditor.EditorLauncher;
+import org.drools.guvnor.client.ruleeditor.EditorWidget;
import com.google.gwt.core.client.GWT;
import com.google.gwt.event.dom.client.ClickEvent;
@@ -54,7 +55,6 @@
import com.google.gwt.user.client.ui.SuggestOracle.Callback;
import com.google.gwt.user.client.ui.SuggestOracle.Request;
import com.google.gwt.user.client.ui.VerticalPanel;
-import com.google.gwt.user.client.ui.Widget;
import com.gwtext.client.util.Format;
/**
@@ -178,16 +178,16 @@
SuggestionCompletionCache.getInstance().doAction( result.metaData.packageName,
new Command() {
public void execute() {
- final Widget last = EditorLauncher.getEditorViewer( result,
- null );
+ final EditorWidget last = EditorLauncher.getEditorViewer( result,
+ null );
vp.add( last );
panel.addScrollHandler( new ScrollHandler() {
- int i = 0;
- Widget end = last;
+ int i = 0;
+ EditorWidget end = last;
public void onScroll(ScrollEvent event) {
- int finalPos = end.getAbsoluteTop()
- + end.getOffsetHeight();
+ int finalPos = end.asWidget().getAbsoluteTop()
+ + end.asWidget().getOffsetHeight();
int panelPos = panel.getAbsoluteTop()
+ panel.getOffsetHeight();
System.err.println( panelPos + " "
@@ -256,4 +256,4 @@
}
-}
+}
\ No newline at end of file
More information about the jboss-svn-commits
mailing list