[jboss-svn-commits] JBL Code SVN: r21487 - in labs/jbossrules/trunk/drools-guvnor/src/main: java/org/drools/guvnor/client/common and 4 other directories.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Tue Aug 12 16:04:13 EDT 2008
Author: arhan
Date: 2008-08-12 16:04:13 -0400 (Tue, 12 Aug 2008)
New Revision: 21487
Added:
labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/ruleeditor/PropertiesHolder.java
labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/ruleeditor/PropertiesWidget.java
labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/ruleeditor/PropertyHolder.java
labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/server/contenthandler/PropertiesHandler.java
Modified:
labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/Guvnor.gwt.xml
labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/common/AssetFormats.java
labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/explorer/RulesNewMenu.java
labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/ruleeditor/EditorLauncher.java
labs/jbossrules/trunk/drools-guvnor/src/main/resources/contenthandler.properties
Log:
GSOC2008: properties editor
Modified: labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/Guvnor.gwt.xml
===================================================================
--- labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/Guvnor.gwt.xml 2008-08-12 18:36:45 UTC (rev 21486)
+++ labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/Guvnor.gwt.xml 2008-08-12 20:04:13 UTC (rev 21487)
@@ -3,6 +3,7 @@
<!-- Inherit the core Web Toolkit stuff. -->
<inherits name='com.google.gwt.user.User'/>
<inherits name="com.gwtext.GwtExt"/>
+ <inherits name="com.gwtext.Pagebus"/>
<!-- Specify the app entry point class. -->
<!-- <entry-point class='org.drools.guvnor.client.JBRMS'/> -->
Modified: labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/common/AssetFormats.java
===================================================================
--- labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/common/AssetFormats.java 2008-08-12 18:36:45 UTC (rev 21486)
+++ labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/common/AssetFormats.java 2008-08-12 20:04:13 UTC (rev 21487)
@@ -65,6 +65,10 @@
/** For fact models in drl. */
public static final String DRL_MODEL = "model.drl";
+
+ public static final String XML = "xml";
+
+ public static final String PROPERTIES = "properties";
/**
* The following group the assets together for lists, helpers etc...
Modified: labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/explorer/RulesNewMenu.java
===================================================================
--- labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/explorer/RulesNewMenu.java 2008-08-12 18:36:45 UTC (rev 21486)
+++ labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/explorer/RulesNewMenu.java 2008-08-12 20:04:13 UTC (rev 21487)
@@ -56,6 +56,18 @@
}
}, "images/test_manager.gif"));
+ /* m.addItem(new Item("New XML", new BaseItemListenerAdapter() {
+ public void onClick(BaseItem item, EventObject e) {
+ manager.launchWizard(AssetFormats.XML, "create XML", true);
+ }
+ }, "images/test_manager.gif"));*/
+
+ m.addItem(new Item("New Properties", new BaseItemListenerAdapter() {
+ public void onClick(BaseItem item, EventObject e) {
+ manager.launchWizard(AssetFormats.PROPERTIES, "New Properties", true);
+ }
+ }, "images/test_manager.gif")); //TODO: use a new icon
+
return m;
}
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 2008-08-12 18:36:45 UTC (rev 21486)
+++ labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/ruleeditor/EditorLauncher.java 2008-08-12 20:04:13 UTC (rev 21487)
@@ -48,7 +48,7 @@
public class EditorLauncher {
- public static final Map TYPE_IMAGES = getTypeImages();
+ public static final Map<String, String> TYPE_IMAGES = getTypeImages();
/**
* This will return the appropriate viewer for the asset.
@@ -79,6 +79,8 @@
return new RuleValidatorWrapper(new FactModelWidget(asset), asset);
} else if (asset.metaData.format.equals(AssetFormats.DSL)) {
return new RuleValidatorWrapper(new DefaultRuleContentWidget( asset ), asset);
+ } else if (asset.metaData.format.equals(AssetFormats.PROPERTIES)) {
+ return new PropertiesWidget( asset, viewer );
} else {
return new DefaultContentUploadEditor( asset, viewer );
}
@@ -86,8 +88,8 @@
}
- private static Map getTypeImages() {
- Map result = new HashMap();
+ private static Map<String, String> getTypeImages() {
+ Map<String, String> result = new HashMap<String, String>();
result.put( AssetFormats.DRL, "technical_rule_assets.gif" );
result.put( AssetFormats.DSL, "dsl.gif" );
Added: labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/ruleeditor/PropertiesHolder.java
===================================================================
--- labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/ruleeditor/PropertiesHolder.java (rev 0)
+++ labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/ruleeditor/PropertiesHolder.java 2008-08-12 20:04:13 UTC (rev 21487)
@@ -0,0 +1,37 @@
+package org.drools.guvnor.client.ruleeditor;
+/*
+ * Copyright 2005 JBoss Inc
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+import org.drools.guvnor.client.modeldriven.brl.PortableObject;
+
+import java.util.List;
+import java.util.ArrayList;
+import java.util.Date;
+
+
+/**
+ * Properties representation used for RPC data exchange
+ *
+ * @author Anton Arhipov
+ */
+public class PropertiesHolder implements PortableObject {
+
+ /**
+ * @gwt.typeArgs <org.drools.guvnor.client.ruleeditor.PropertyHolder>
+ */
+ public List<PropertyHolder> list = new ArrayList<PropertyHolder>();
+
+}
+
Added: labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/ruleeditor/PropertiesWidget.java
===================================================================
--- labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/ruleeditor/PropertiesWidget.java (rev 0)
+++ labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/ruleeditor/PropertiesWidget.java 2008-08-12 20:04:13 UTC (rev 21487)
@@ -0,0 +1,88 @@
+package org.drools.guvnor.client.ruleeditor;
+/*
+ * Copyright 2005 JBoss Inc
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+import com.gwtext.client.core.NameValuePair;
+import com.gwtext.client.widgets.grid.GridView;
+import com.gwtext.client.widgets.grid.PropertyGridPanel;
+import org.drools.guvnor.client.packages.AssetAttachmentFileWidget;
+import org.drools.guvnor.client.rpc.RuleAsset;
+
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * Properties (key/value pairs) editor with a file attachment.
+ *
+ * @author Anton Arhipov
+ */
+public class PropertiesWidget extends AssetAttachmentFileWidget implements SaveEventListener {
+
+ PropertiesHolder properties;
+
+ public PropertiesWidget(final RuleAsset asset, final RuleViewer viewer) {
+ super(asset, viewer);
+
+ if (asset.content == null) {
+ properties = new PropertiesHolder();
+ } else {
+ properties = (PropertiesHolder) asset.content;
+ }
+
+ PropertyGridPanel grid = new PropertyGridPanel();
+ grid.setId("props-grid");
+ grid.setNameText("Properties Grid");
+ grid.setWidth(300);
+ grid.setAutoHeight(true);
+ grid.setSorted(false);
+
+ GridView view = new GridView();
+ view.setForceFit(true);
+ view.setScrollOffset(2); // the grid will never have scrollbars
+ grid.setView(view);
+
+ Map<String, String> map = new HashMap<String, String>();
+
+ for (PropertyHolder holder : properties.list) {
+ map.put(holder.name, holder.value);
+ }
+
+ grid.setSource(map);
+
+ layout.addRow(grid);
+ }
+
+
+
+ public String getIcon() {
+ return "";
+ }
+
+ public String getOverallStyleName() {
+ return "";
+ }
+
+ public void onSave() {
+ asset.content = properties;
+ }
+
+ public void onAfterSave() {
+
+ }
+
+}
+
+
Added: labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/ruleeditor/PropertyHolder.java
===================================================================
--- labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/ruleeditor/PropertyHolder.java (rev 0)
+++ labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/ruleeditor/PropertyHolder.java 2008-08-12 20:04:13 UTC (rev 21487)
@@ -0,0 +1,35 @@
+package org.drools.guvnor.client.ruleeditor;
+/*
+ * Copyright 2005 JBoss Inc
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+import org.drools.guvnor.client.modeldriven.brl.PortableObject;
+
+/**
+ * key/value pair to be used as an exchange object for properties rule asset
+ *
+ * @author Anton Arhipov
+ */
+public class PropertyHolder implements PortableObject {
+ public String name;
+ public String value;
+
+ public PropertyHolder() {
+ }
+
+ public PropertyHolder(String name, String value) {
+ this.name = name;
+ this.value = value;
+ }
+}
\ No newline at end of file
Added: labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/server/contenthandler/PropertiesHandler.java
===================================================================
--- labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/server/contenthandler/PropertiesHandler.java (rev 0)
+++ labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/server/contenthandler/PropertiesHandler.java 2008-08-12 20:04:13 UTC (rev 21487)
@@ -0,0 +1,46 @@
+package org.drools.guvnor.server.contenthandler;
+/*
+ * Copyright 2005 JBoss Inc
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+import com.google.gwt.user.client.rpc.SerializableException;
+import org.drools.guvnor.client.rpc.RuleAsset;
+import org.drools.guvnor.client.ruleeditor.PropertiesHolder;
+import org.drools.guvnor.server.util.PropertiesPersistence;
+import org.drools.repository.AssetItem;
+import org.drools.repository.PackageItem;
+
+/**
+ * Handle *.properties file as a content for rule asset instead of a binary attachment
+ *
+ *
+ * @author Anton Arhipov
+ */
+public class PropertiesHandler extends ContentHandler {
+ public void retrieveAssetContent(RuleAsset asset, PackageItem pkg, AssetItem item)
+ throws SerializableException {
+ if (item.getContent() != null) {
+ asset.content = PropertiesPersistence.getInstance().unmarshal(item.getContent());
+ }
+ System.out.println("CONTENT: >>>>>>>>>>>>>>>>>>>>>> " + item.getContent());
+ }
+
+ public void storeAssetContent(RuleAsset asset, AssetItem repoAsset)
+ throws SerializableException {
+ PropertiesHolder holder = (PropertiesHolder) asset.content;
+ String toSave = PropertiesPersistence.getInstance().marshal(holder);
+ System.out.println("toSave = " + toSave);
+ repoAsset.updateContent(toSave);
+ }
+}
\ No newline at end of file
Modified: labs/jbossrules/trunk/drools-guvnor/src/main/resources/contenthandler.properties
===================================================================
--- labs/jbossrules/trunk/drools-guvnor/src/main/resources/contenthandler.properties 2008-08-12 18:36:45 UTC (rev 21486)
+++ labs/jbossrules/trunk/drools-guvnor/src/main/resources/contenthandler.properties 2008-08-12 20:04:13 UTC (rev 21487)
@@ -25,4 +25,8 @@
# for guided decision tables
gdst=org.drools.guvnor.server.contenthandler.GuidedDTContentHandler
# for models
-model.drl=org.drools.guvnor.server.contenthandler.FactModelContentHandler
\ No newline at end of file
+model.drl=org.drools.guvnor.server.contenthandler.FactModelContentHandler
+#properties attachment
+properties=org.drools.guvnor.server.contenthandler.PropertiesHandler
+#xml attachment
+xml=org.drools.guvnor.server.contenthandler.XmlFileHandler
More information about the jboss-svn-commits
mailing list