Update of /cvsroot/woproject/woproject/projects/wolips/plugins/org.objectstyle.wolips.ruleeditor/java/org/objectstyle/wolips/ruleeditor/model
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16818/java/org/objectstyle/wolips/ruleeditor/model
Modified Files:
AbstractD2WModelChild.java RightHandSide.java Rule.java
Qualifier.java LeftHandSide.java
Added Files:
AbstractQualifierElement.java
Log Message:
Moved editor to it's own package. Minor enhancements
--- NEW FILE: AbstractQualifierElement.java ---
/*
* ====================================================================
*
* The ObjectStyle Group Software License, Version 1.0
*
* Copyright (c) 2005 The ObjectStyle Group and individual authors of the
* software. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* 3. The end-user documentation included with the redistribution, if any, must
* include the following acknowlegement: "This product includes software
* developed by the ObjectStyle Group (http://objectstyle.org/)." Alternately,
* this acknowlegement may appear in the software itself, if and wherever such
* third-party acknowlegements normally appear.
*
* 4. The names "ObjectStyle Group" and "Cayenne" must not be used to endorse or
* promote products derived from this software without prior written permission.
* For written permission, please contact [email protected].
*
* 5. Products derived from this software may not be called "ObjectStyle" nor
* may "ObjectStyle" appear in their names without prior written permission of
* the ObjectStyle Group.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* OBJECTSTYLE GROUP OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many individuals on
* behalf of the ObjectStyle Group. For more information on the ObjectStyle
* Group, please see <http://objectstyle.org/>.
*
*/
package org.objectstyle.wolips.ruleeditor.model;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
public abstract class AbstractQualifierElement extends AbstractClassElement {
private static final String QUALIFIERS_KEY = "qualifiers";
private ArrayList qualifiers;
public AbstractQualifierElement(D2WModel model, Map map) {
super(model, map);
}
public List getQualifiers() {
if (qualifiers != null) {
return qualifiers;
}
List list = (List) this.getMap().get(QUALIFIERS_KEY);
if (list == null) {
return null;
}
qualifiers = new ArrayList(list.size());
for (int i = 0; i < list.size(); i++) {
Map map = (Map) list.get(i);
Qualifier qualifier = new Qualifier(this.getModel(), map);
qualifiers.add(i, qualifier);
}
return qualifiers;
}
public void appendToDisplayStringBuffer(StringBuffer stringBuffer,
String concatWith) {
if (this.getQualifiers() == null) {
return;
}
stringBuffer.append("(");
Iterator iterator = qualifiers.iterator();
while (iterator.hasNext()) {
AbstractQualifierElement abstractQualifierElement = (AbstractQualifierElement) iterator
.next();
abstractQualifierElement.appendToDisplayStringBuffer(stringBuffer,
this.getConcatWithString());
if (iterator.hasNext()) {
stringBuffer.append(" ");
stringBuffer.append(concatWith);
stringBuffer.append(" ");
}
}
stringBuffer.append(")");
}
public String getConcatWithString() {
String assignmentClassName = this.getAssignmentClassName();
if(assignmentClassName == null) {
return null;
}
if("com.webobjects.eocontrol.EOAndQualifier".equals(assignmentClassName)) {
return "and";
}
if("com.webobjects.eocontrol.EOOrQualifier".equals(assignmentClassName)) {
return "or";
}
if("com.webobjects.eocontrol.EONotQualifier".equals(assignmentClassName)) {
return "not";
}
return assignmentClassName;
}
}
Index: AbstractD2WModelChild.java
===================================================================
RCS file: /cvsroot/woproject/woproject/projects/wolips/plugins/org.objectstyle.wolips.ruleeditor/java/org/objectstyle/wolips/ruleeditor/model/AbstractD2WModelChild.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- AbstractD2WModelChild.java 13 Nov 2005 08:14:06 -0000 1.1
+++ AbstractD2WModelChild.java 30 Dec 2005 09:11:47 -0000 1.2
@@ -62,6 +62,12 @@
public AbstractD2WModelChild(D2WModel model, Map map) {
super();
+ if(model == null) {
+ throw new IllegalArgumentException();
+ }
+ if(map == null) {
+ throw new IllegalArgumentException();
+ }
this.map = map;
this.model = model;
}
Index: RightHandSide.java
===================================================================
RCS file: /cvsroot/woproject/woproject/projects/wolips/plugins/org.objectstyle.wolips.ruleeditor/java/org/objectstyle/wolips/ruleeditor/model/RightHandSide.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- RightHandSide.java 13 Nov 2005 08:14:06 -0000 1.1
+++ RightHandSide.java 30 Dec 2005 09:11:47 -0000 1.2
@@ -72,7 +72,11 @@
}
public String getValue() {
- return (String) this.getMap().get(VALUE_KEY);
+ Object value = this.getMap().get(VALUE_KEY);
+ if(value == null) {
+ return null;
+ }
+ return value.toString();
}
public void setValue(String value) {
Index: Rule.java
===================================================================
RCS file: /cvsroot/woproject/woproject/projects/wolips/plugins/org.objectstyle.wolips.ruleeditor/java/org/objectstyle/wolips/ruleeditor/model/Rule.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- Rule.java 13 Nov 2005 08:14:06 -0000 1.1
+++ Rule.java 30 Dec 2005 09:11:47 -0000 1.2
@@ -86,6 +86,9 @@
return leftHandSide;
}
Map map = (Map)this.getMap().get(LHS_KEY);
+ if(map == null) {
+ return null;
+ }
leftHandSide = new LeftHandSide(this.getModel(), map);
return leftHandSide;
}
@@ -95,11 +98,15 @@
this.getModel().setHasUnsavedChanges(true);
}
- public Integer getPriority() {
- return (Integer)this.getMap().get(AUTHOR_KEY);
+ public String getPriority() {
+ Object priority = this.getMap().get(AUTHOR_KEY);
+ if(priority == null) {
+ return null;
+ }
+ return priority.toString();
}
- public void setPriority(Integer priority) {
+ public void setPriority(String priority) {
this.getMap().put(AUTHOR_KEY, priority);
this.getModel().setHasUnsavedChanges(true);
}
Index: Qualifier.java
===================================================================
RCS file: /cvsroot/woproject/woproject/projects/wolips/plugins/org.objectstyle.wolips.ruleeditor/java/org/objectstyle/wolips/ruleeditor/model/Qualifier.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- Qualifier.java 13 Nov 2005 08:14:06 -0000 1.1
+++ Qualifier.java 30 Dec 2005 09:11:47 -0000 1.2
@@ -54,7 +54,7 @@
/**
* @author uli
*/
-public class Qualifier extends AbstractClassElement {
+public class Qualifier extends AbstractQualifierElement {
private static final String KEY_KEY = "key";
private static final String VALUE_KEY = "value";
private static final String SELECTOR_NAME_KEY = "selectorName";
@@ -89,4 +89,44 @@
this.getMap().put(SELECTOR_NAME_KEY, selectorName);
this.getModel().setHasUnsavedChanges(true);
}
+ public void appendToDisplayStringBuffer(StringBuffer stringBuffer,
+ String concatWith) {
+ if (this.getQualifiers() == null) {
+ stringBuffer.append(this.getKey());
+ stringBuffer.append(" ");
+ stringBuffer.append(this.getSelectorDisplayString());
+ stringBuffer.append(" ");
+ stringBuffer.append(this.getValue());
+ }
+ super.appendToDisplayStringBuffer(stringBuffer, concatWith);
+ }
+
+ private String getSelectorDisplayString() {
+ String selectorName = this.getSelectorName();
+ if(selectorName == null) {
+ return null;
+ }
+ if("isEqualTo".equals(selectorName)) {
+ return "=";
+ }
+ if("isNotEqualTo".equals(selectorName)) {
+ return "!=";
+ }
+ if("isLessThen".equals(selectorName)) {
+ return "<";
+ }
+ if("isLessThenOrEqualTo".equals(selectorName)) {
+ return "<=";
+ }
+ if("isGreaterThen".equals(selectorName)) {
+ return ">";
+ }
+ if("isGreaterThenOrEqualTo".equals(selectorName)) {
+ return ">=";
+ }
+ if("isLike".equals(selectorName)) {
+ return "=";
+ }
+ return selectorName;
+ }
}
Index: LeftHandSide.java
===================================================================
RCS file: /cvsroot/woproject/woproject/projects/wolips/plugins/org.objectstyle.wolips.ruleeditor/java/org/objectstyle/wolips/ruleeditor/model/LeftHandSide.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- LeftHandSide.java 13 Nov 2005 08:14:06 -0000 1.1
+++ LeftHandSide.java 30 Dec 2005 09:11:47 -0000 1.2
@@ -49,36 +49,19 @@
*/
package org.objectstyle.wolips.ruleeditor.model;
-import java.util.ArrayList;
-import java.util.List;
import java.util.Map;
/**
* @author uli
*/
-public class LeftHandSide extends AbstractClassElement {
- private static final String QUALIFIERS_KEY = "rhs";
-
- private ArrayList qualifiers;
-
+public class LeftHandSide extends AbstractQualifierElement {
public LeftHandSide(D2WModel model, Map map) {
super(model, map);
}
- public List getQualifiers() {
- if (qualifiers != null) {
- return qualifiers;
- }
- List list = (List) this.getMap().get(QUALIFIERS_KEY);
- if (list == null) {
- return null;
- }
- qualifiers = new ArrayList(list.size());
- for (int i = 0; i < list.size(); i++) {
- Map map = (Map) list.get(i);
- Qualifier qualifier = new Qualifier(this.getModel(), map);
- qualifiers.add(i, qualifier);
- }
- return qualifiers;
+ public String getDisplayString() {
+ StringBuffer stringBuffer = new StringBuffer();
+ this.appendToDisplayStringBuffer(stringBuffer, this.getConcatWithString());
+ return stringBuffer.toString();
}
}
-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems? Stop! Download the new AJAX search engine that makes
searching your log files as easy as surfing the web. DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click
lmpx.com only provides a reader for public news (NNTP) servers. It is not
affiliated with the servers or forums shown here and is not responsible for
the content of articles, which is written by their respective authors.