[jboss-svn-commits] JBL Code SVN: r35834 - in labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor: client/ruleeditor and 2 other directories.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Tue Nov 2 07:54:09 EDT 2010
Author: eaa
Date: 2010-11-02 07:54:08 -0400 (Tue, 02 Nov 2010)
New Revision: 35834
Modified:
labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/modeldriven/ui/RuleModeller.java
labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/ruleeditor/MultiViewEditor.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/server/GuidedEditorServlet.java
labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/server/StandaloneGuidedEditorServiceImplementation.java
Log:
GUVNOR-681: Create a new top component to display and run the Guided Editor (RuleModeller) and all the things it needs in a "standalone" way
- When opening Guided Editor as standalone, you can specify the visibility of LHS, RHS and Attributes of the rules in the editor.
Modified: labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/modeldriven/ui/RuleModeller.java
===================================================================
--- labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/modeldriven/ui/RuleModeller.java 2010-11-02 11:53:58 UTC (rev 35833)
+++ labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/modeldriven/ui/RuleModeller.java 2010-11-02 11:54:08 UTC (rev 35834)
@@ -35,7 +35,6 @@
import org.drools.guvnor.client.common.InfoPopup;
import org.drools.guvnor.client.common.LoadingPopup;
import org.drools.guvnor.client.common.SmallLabel;
-import org.drools.guvnor.client.explorer.ExplorerLayoutManager;
import org.drools.guvnor.client.messages.Constants;
import org.drools.guvnor.client.modeldriven.HumanReadable;
import org.drools.guvnor.client.packages.SuggestionCompletionCache;
@@ -143,34 +142,6 @@
setHeight( "100%" );
}
- private boolean isLock(String attr) {
-
- if ( this.asset.isreadonly ) {
- return true;
- }
-
- if ( this.model.metadataList.length == 0 ) {
- return false;
- }
-
- for ( RuleMetadata at : this.model.metadataList ) {
- if ( at.attributeName.equals( attr ) ) {
- return true;
- }
- }
- return false;
- }
-
- /** return true if we should not allow unfrozen editing of the RHS */
- public boolean lockRHS() {
- return isLock( RuleAttributeWidget.LOCK_RHS ); //NON-NLS
- }
-
- /** return true if we should not allow unfrozen editing of the LHS */
- public boolean lockLHS() {
- return isLock( RuleAttributeWidget.LOCK_LHS ); //NON-NLS
- }
-
/**
* This updates the widget to reflect the state of the model.
*/
@@ -194,42 +165,46 @@
"87%" );
layout.getColumnFormatter().setWidth( 2,
"5%" );
+
+ if (this.showLHS()){
+ layout.setWidget( currentLayoutRow,
+ 0,
+ new SmallLabel( "<b>" + constants.WHEN() + "</b>" ) );
- layout.setWidget( currentLayoutRow,
- 0,
- new SmallLabel( "<b>" + constants.WHEN() + "</b>" ) );
+ if ( !lockLHS() ) {
+ layout.setWidget( currentLayoutRow,
+ 2,
+ addPattern );
+ }
+ currentLayoutRow++;
- if ( !lockLHS() ) {
+ renderLhs( this.model );
+ }
+
+ if (this.showRHS()){
layout.setWidget( currentLayoutRow,
- 2,
- addPattern );
- }
- currentLayoutRow++;
-
- renderLhs( this.model );
-
- layout.setWidget( currentLayoutRow,
0,
new SmallLabel( "<b>" + constants.THEN() + "</b>" ) );
- Image addAction = new ImageButton( "images/new_item.gif" ); //NON-NLS
- addAction.setTitle( constants.AddAnActionToThisRule() );
- addAction.addClickHandler( new ClickHandler() {
+ Image addAction = new ImageButton( "images/new_item.gif" ); //NON-NLS
+ addAction.setTitle( constants.AddAnActionToThisRule() );
+ addAction.addClickHandler( new ClickHandler() {
- public void onClick(ClickEvent event) {
- showActionSelector( (Widget) event.getSource(),
- null );
+ public void onClick(ClickEvent event) {
+ showActionSelector( (Widget) event.getSource(),
+ null );
+ }
+ } );
+ if ( !lockRHS() ) {
+ layout.setWidget( currentLayoutRow,
+ 2,
+ addAction );
}
- } );
- if ( !lockRHS() ) {
- layout.setWidget( currentLayoutRow,
- 2,
- addAction );
+ currentLayoutRow++;
+
+ renderRhs( this.model );
}
- currentLayoutRow++;
-
- renderRhs( this.model );
-
+
if ( showAttributes() ) {
final int tmp1 = currentLayoutRow;
@@ -284,8 +259,69 @@
this.verifyRule( null );
}
+ private boolean isLock(String attr) {
+
+ if ( this.asset.isreadonly ) {
+ return true;
+ }
+
+ if ( this.model.metadataList.length == 0 ) {
+ return false;
+ }
+
+ for ( RuleMetadata at : this.model.metadataList ) {
+ if ( at.attributeName.equals( attr ) ) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ public boolean showRHS(){
+ for ( RuleMetadata at : this.model.metadataList ) {
+ if ( at.attributeName.equals( RuleMetadata.HIDE_RHS_IN_EDITOR ) ) {
+ if (at.value != null && Boolean.parseBoolean(at.value)){
+ return false;
+ }
+ }
+ }
+ return true;
+ }
+
+ /** return true if we should not allow unfrozen editing of the RHS */
+ public boolean lockRHS() {
+ return isLock( RuleAttributeWidget.LOCK_RHS ); //NON-NLS
+ }
+
+ public boolean showLHS(){
+ for ( RuleMetadata at : this.model.metadataList ) {
+ if ( at.attributeName.equals( RuleMetadata.HIDE_LHS_IN_EDITOR ) ) {
+ if (at.value != null && Boolean.parseBoolean(at.value)){
+ return false;
+ }
+ }
+ }
+ return true;
+ }
+
+ /** return true if we should not allow unfrozen editing of the LHS */
+ public boolean lockLHS() {
+ return isLock( RuleAttributeWidget.LOCK_LHS ); //NON-NLS
+ }
+
private boolean showAttributes() {
- return CapabilitiesManager.getInstance().shouldShow( Capabilities.SHOW_PACKAGE_VIEW );
+ if (!CapabilitiesManager.getInstance().shouldShow( Capabilities.SHOW_PACKAGE_VIEW )){
+ return false;
+ }
+
+ for ( RuleMetadata at : this.model.metadataList ) {
+ if ( at.attributeName.equals( RuleMetadata.HIDE_ATTRIBUTES_IN_EDITOR ) ) {
+ if (at.value != null && Boolean.parseBoolean(at.value)){
+ return false;
+ }
+ }
+ }
+ return true;
}
public void refreshWidget() {
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-11-02 11:53:58 UTC (rev 35833)
+++ labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/ruleeditor/MultiViewEditor.java 2010-11-02 11:54:08 UTC (rev 35834)
@@ -158,8 +158,6 @@
ruleViewer.setMetaVisible(showMetadata);
content.add(ruleViewer);
- OpenEvent.fire(null, content);
-
ruleViewer.setWidth("100%");
ruleViewer.setCloseCommand(new Command() {
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-11-02 11:53:58 UTC (rev 35833)
+++ labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/ruleeditor/toolbar/ActionToolbar.java 2010-11-02 11:54:08 UTC (rev 35834)
@@ -146,7 +146,7 @@
* Sets the visible status display.
*/
private void setState(String status) {
- state.setText(Format.format(constants.statusIs(),
+ state.setHTML(Format.format(constants.statusIs(),
status));
}
Modified: labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/server/GuidedEditorServlet.java
===================================================================
--- labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/server/GuidedEditorServlet.java 2010-11-02 11:53:58 UTC (rev 35833)
+++ labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/server/GuidedEditorServlet.java 2010-11-02 11:54:08 UTC (rev 35834)
@@ -28,20 +28,47 @@
public class GuidedEditorServlet extends HttpServlet {
- public static String GE_PACKAGE_PARAMETER_NAME = "packageName";
- public static String GE_CATEGORY_PARAMETER_NAME = "categoryName";
- public static String GE_BRL_PARAMETER_NAME = "brlSource";
+ public static enum GUIDED_EDITOR_SERVLET_PARAMETERS{
+ GE_PACKAGE_PARAMETER_NAME("packageName",false),
+ GE_CATEGORY_PARAMETER_NAME("categoryName",false),
+ GE_BRL_PARAMETER_NAME("brlSource",true),
+
+ GE_HIDE_RULE_LHS_PARAMETER_NAME("hideRuleLHS",false),
+ GE_HIDE_RULE_RHS_PARAMETER_NAME("hideRuleRHS",false),
+ GE_HIDE_RULE_ATTRIBUTES_PARAMETER_NAME("hideRuleAttributes",false);
+
+ private String parameterName;
+ private boolean multipleValues;
+
+ private GUIDED_EDITOR_SERVLET_PARAMETERS(String parameterName, boolean multipleValues){
+ this.parameterName = parameterName;
+ this.multipleValues = multipleValues;
+ }
+
+ public String getParameterName() {
+ return parameterName;
+ }
+
+ public boolean isMultipleValues() {
+ return multipleValues;
+ }
+
+ }
@Override
protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
HttpSession session = req.getSession(true);
- session.setAttribute(GE_PACKAGE_PARAMETER_NAME, req.getParameter(GE_PACKAGE_PARAMETER_NAME));
- session.setAttribute(GE_CATEGORY_PARAMETER_NAME, req.getParameter(GE_CATEGORY_PARAMETER_NAME));
- session.setAttribute(GE_BRL_PARAMETER_NAME, req.getParameterValues(GE_BRL_PARAMETER_NAME));
+ //copy each registered parameter from request to session
+ for (GUIDED_EDITOR_SERVLET_PARAMETERS parameter : GUIDED_EDITOR_SERVLET_PARAMETERS.values()) {
+ if (parameter.isMultipleValues()){
+ session.setAttribute(parameter.getParameterName(), req.getParameterValues(parameter.getParameterName()));
+ }else{
+ session.setAttribute(parameter.getParameterName(), req.getParameter(parameter.getParameterName()));
+ }
+ }
+
resp.sendRedirect("GuidedEditor.html?"+req.getQueryString());
- //RequestDispatcher requestDispatcher = req.getRequestDispatcher("GuidedEditor.html");
- //requestDispatcher.forward(req, resp);
}
Modified: labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/server/StandaloneGuidedEditorServiceImplementation.java
===================================================================
--- labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/server/StandaloneGuidedEditorServiceImplementation.java 2010-11-02 11:53:58 UTC (rev 35833)
+++ labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/server/StandaloneGuidedEditorServiceImplementation.java 2010-11-02 11:54:08 UTC (rev 35834)
@@ -24,6 +24,7 @@
import org.drools.guvnor.client.rpc.RuleAsset;
import org.drools.guvnor.client.rpc.StandaloneGuidedEditorService;
import org.drools.guvnor.server.util.LoggingHelper;
+import org.drools.ide.common.client.modeldriven.brl.RuleMetadata;
import org.drools.ide.common.client.modeldriven.brl.RuleModel;
import org.drools.repository.RulesRepository;
import org.jboss.seam.annotations.In;
@@ -56,10 +57,28 @@
HttpSession session = this.getThreadLocalRequest().getSession();
- String packageName = (String)session.getAttribute(GuidedEditorServlet.GE_PACKAGE_PARAMETER_NAME);
- String categoryName = (String)session.getAttribute(GuidedEditorServlet.GE_CATEGORY_PARAMETER_NAME);
- String[] initialBRL = (String[])session.getAttribute(GuidedEditorServlet.GE_BRL_PARAMETER_NAME);
+ String packageName = (String)session.getAttribute(GuidedEditorServlet.GUIDED_EDITOR_SERVLET_PARAMETERS.GE_PACKAGE_PARAMETER_NAME.getParameterName());
+ String categoryName = (String)session.getAttribute(GuidedEditorServlet.GUIDED_EDITOR_SERVLET_PARAMETERS.GE_CATEGORY_PARAMETER_NAME.getParameterName());
+ String[] initialBRL = (String[])session.getAttribute(GuidedEditorServlet.GUIDED_EDITOR_SERVLET_PARAMETERS.GE_BRL_PARAMETER_NAME.getParameterName());
+ boolean hideLHSInEditor = false;
+ Object attribute = session.getAttribute(GuidedEditorServlet.GUIDED_EDITOR_SERVLET_PARAMETERS.GE_HIDE_RULE_LHS_PARAMETER_NAME.getParameterName());
+ if (attribute != null){
+ hideLHSInEditor = Boolean.parseBoolean(attribute.toString());
+ }
+
+ boolean hideRHSInEditor = false;
+ attribute = session.getAttribute(GuidedEditorServlet.GUIDED_EDITOR_SERVLET_PARAMETERS.GE_HIDE_RULE_RHS_PARAMETER_NAME.getParameterName());
+ if (attribute != null){
+ hideRHSInEditor = Boolean.parseBoolean(attribute.toString());
+ }
+
+ boolean hideAttributesInEditor = false;
+ attribute = session.getAttribute(GuidedEditorServlet.GUIDED_EDITOR_SERVLET_PARAMETERS.GE_HIDE_RULE_ATTRIBUTES_PARAMETER_NAME.getParameterName());
+ if (attribute != null){
+ hideAttributesInEditor = Boolean.parseBoolean(attribute.toString());
+ }
+
List<RuleModel> models = new ArrayList<RuleModel>(initialBRL.length);
List<RuleAsset> assets = new ArrayList<RuleAsset>(initialBRL.length);
@@ -73,7 +92,7 @@
//no unmarshal errors, it's time to create the rules
try{
for (RuleModel ruleModel : models) {
- assets.add(this.createRuleAssetFromRuleModel(packageName, categoryName, ruleModel));
+ assets.add(this.createRuleAssetFromRuleModel(packageName, categoryName, ruleModel, hideLHSInEditor, hideRHSInEditor, hideAttributesInEditor));
}
} catch (Exception e){
//if something failed, delete the generated assets
@@ -92,7 +111,7 @@
}
- private RuleAsset createRuleAssetFromRuleModel(String packageName, String categoryName, RuleModel model) throws DetailedSerializationException {
+ private RuleAsset createRuleAssetFromRuleModel(String packageName, String categoryName, RuleModel model, Boolean hideLHSInEditor, Boolean hideRHSInEditor, Boolean hideAttributesInEditor) throws DetailedSerializationException {
try {
//creates a new empty rule with a unique name (this is because
@@ -101,6 +120,9 @@
RuleAsset newRule = this.getService().loadRuleAsset(ruleUUID);
//update its content and persist
+ model.addMetadata(new RuleMetadata(RuleMetadata.HIDE_LHS_IN_EDITOR, hideLHSInEditor.toString()));
+ model.addMetadata(new RuleMetadata(RuleMetadata.HIDE_RHS_IN_EDITOR, hideRHSInEditor.toString()));
+ model.addMetadata(new RuleMetadata(RuleMetadata.HIDE_ATTRIBUTES_IN_EDITOR, hideAttributesInEditor.toString()));
newRule.content = model;
ruleUUID = this.getService().checkinVersion(newRule);
More information about the jboss-svn-commits
mailing list