[archstudio-commits] svn commit: r7062 - in /archstudio4/trunk/edu.uci.isr.archstudio4.comp.xarchcs/src/edu/uci/isr/archstudio4/comp/xarchcs/views/changesets: ChangeSetViewPart.java conversion/ conversion/CSConverter.java conversion/ComparableBooleanGuardConverter.java

archstudio-commits-owner at uci.edu archstudio-commits-owner at uci.edu
Thu May 1 20:04:04 PDT 2008


Author: shendric
Date: Thu May  1 20:04:03 2008
New Revision: 7062

Log:
Initial implementation of PLA to CS converter (supports only optional eleme=
nts so far)

Added:
    archstudio4/trunk/edu.uci.isr.archstudio4.comp.xarchcs/src/edu/uci/isr/=
archstudio4/comp/xarchcs/views/changesets/conversion/
    archstudio4/trunk/edu.uci.isr.archstudio4.comp.xarchcs/src/edu/uci/isr/=
archstudio4/comp/xarchcs/views/changesets/conversion/CSConverter.java   (wi=
th props)
    archstudio4/trunk/edu.uci.isr.archstudio4.comp.xarchcs/src/edu/uci/isr/=
archstudio4/comp/xarchcs/views/changesets/conversion/ComparableBooleanGuard=
Converter.java   (with props)
Modified:
    archstudio4/trunk/edu.uci.isr.archstudio4.comp.xarchcs/src/edu/uci/isr/=
archstudio4/comp/xarchcs/views/changesets/ChangeSetViewPart.java

Modified: archstudio4/trunk/edu.uci.isr.archstudio4.comp.xarchcs/src/edu/uc=
i/isr/archstudio4/comp/xarchcs/views/changesets/ChangeSetViewPart.java
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D
--- archstudio4/trunk/edu.uci.isr.archstudio4.comp.xarchcs/src/edu/uci/isr/=
archstudio4/comp/xarchcs/views/changesets/ChangeSetViewPart.java (original)
+++ archstudio4/trunk/edu.uci.isr.archstudio4.comp.xarchcs/src/edu/uci/isr/=
archstudio4/comp/xarchcs/views/changesets/ChangeSetViewPart.java Thu May  1=
 20:04:03 2008
@@ -1,5 +1,8 @@
 package edu.uci.isr.archstudio4.comp.xarchcs.views.changesets;
 =

+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.InputStream;
 import java.lang.reflect.InvocationTargetException;
 import java.util.ArrayList;
 import java.util.Arrays;
@@ -9,7 +12,15 @@
 import java.util.List;
 import java.util.Set;
 =

+import org.eclipse.core.resources.IContainer;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IWorkspace;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
 import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.OperationCanceledException;
+import org.eclipse.core.runtime.Path;
 import org.eclipse.core.runtime.SubProgressMonitor;
 import org.eclipse.jface.action.Action;
 import org.eclipse.jface.action.ActionContributionItem;
@@ -54,18 +65,23 @@
 import org.eclipse.swt.widgets.FileDialog;
 import org.eclipse.swt.widgets.Item;
 import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Shell;
 import org.eclipse.swt.widgets.Tree;
 import org.eclipse.swt.widgets.TreeColumn;
 import org.eclipse.ui.IEditorPart;
 import org.eclipse.ui.IFileEditorInput;
 import org.eclipse.ui.IPartListener;
 import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.actions.WorkspaceModifyOperation;
+import org.eclipse.ui.dialogs.ContainerGenerator;
+import org.eclipse.ui.dialogs.SaveAsDialog;
 =

 import edu.uci.isr.archstudio4.comp.xarchcs.XArchCSActivator;
 import edu.uci.isr.archstudio4.comp.xarchcs.actions.AddChangeSetAction;
 import edu.uci.isr.archstudio4.comp.xarchcs.actions.IHasXArchRef;
 import edu.uci.isr.archstudio4.comp.xarchcs.changesetsync.IChangeSetSync.I=
ChangeSetSyncMonitor;
 import edu.uci.isr.archstudio4.comp.xarchcs.explicitadt.IExplicitADT;
+import edu.uci.isr.archstudio4.comp.xarchcs.views.changesets.conversion.CS=
Converter;
 import edu.uci.isr.archstudio4.comp.xarchcs.xarchcs.XArchChangeSetEvent;
 import edu.uci.isr.archstudio4.comp.xarchcs.xarchcs.XArchChangeSetInterfac=
e;
 import edu.uci.isr.archstudio4.comp.xarchcs.xarchcs.XArchChangeSetListener;
@@ -484,6 +500,65 @@
 		//	}
 		//};
 		//menuManager.add(diffFromExternalFile);
+
+		IAction convertPLAtoCS =3D new Action("Convert PLA Guards to Change Sets=
"){
+
+			private String rename(String s){
+				if(s.endsWith(".xml")){
+					s =3D s.substring(0, s.length() - 4) + "-cs.xml";
+				}
+				return s;
+			}
+
+			@Override
+			public void run(){
+
+				final ObjRef oldXArchRef =3D (ObjRef)changeSetViewer.getInput();
+				final IWorkspace workspace =3D ResourcesPlugin.getWorkspace();
+				final IPath originalPath =3D new Path(rename(xarch.getXArchURI(oldXArc=
hRef)));
+				final IFile originalFile =3D workspace.getRoot().getFile(originalPath);
+
+				SaveAsDialog sad =3D new SaveAsDialog(changeSetViewer.getControl().get=
Shell());
+				sad.setOriginalFile(originalFile);
+				sad.open();
+
+				final IPath path =3D sad.getResult();
+
+				if(path !=3D null){
+					new Thread(new Runnable(){
+
+						public void run(){
+							try{
+								xarch.close(path.toString());
+							}
+							catch(Throwable t){
+							}
+							final ObjRef newXArchRef =3D xarch.createXArch(path.toString());
+							try{
+								CSConverter.convertPLAtoCS(xarch, oldXArchRef, newXArchRef);
+								SWTWidgetUtils.sync(changeSetViewer, new Runnable(){
+
+									public void run(){
+										String contents =3D xarch.serialize(newXArchRef);
+										InputStream is =3D new ByteArrayInputStream(contents.getBytes());
+										saveFile(changeSetViewer.getControl().getShell(), is, path);
+									}
+								});
+							}
+							catch(Throwable t){
+								t.printStackTrace();
+							}
+							finally{
+								if(newXArchRef !=3D null){
+									xarch.close(newXArchRef);
+								}
+							}
+						}
+					}).start();
+				}
+			}
+		};
+		menuManager.add(convertPLAtoCS);
 	}
 =

 	@Override
@@ -747,4 +822,56 @@
 			fireSelectionChangedEvent(new StructuredSelection(selectedRefs));
 		}
 	}
+
+	private static void saveFile(Shell shell, InputStream contents, IPath ini=
tialTargetPath){
+		final Shell fshell =3D shell;
+		final InputStream fcontents =3D contents;
+		final IPath targetPath =3D initialTargetPath;
+
+		final IWorkspace workspace =3D ResourcesPlugin.getWorkspace();
+		final IFile targetFile =3D workspace.getRoot().getFile(targetPath);
+
+		WorkspaceModifyOperation operation =3D new WorkspaceModifyOperation(){
+
+			@Override
+			protected void execute(IProgressMonitor monitor) throws CoreException, =
InvocationTargetException, InterruptedException{
+				IPath targetContainerPath =3D targetPath.removeLastSegments(1);
+				boolean createContainer =3D true;
+				if(workspace.getRoot().getContainerForLocation(targetContainerPath) !=
=3D null){
+					createContainer =3D false;
+				}
+				ContainerGenerator gen =3D new ContainerGenerator(targetContainerPath);
+				IContainer res =3D null;
+				try{
+					if(createContainer){
+						res =3D gen.generateContainer(monitor); // creates project A and fol=
der B if required
+					}
+					if(targetFile.exists()){
+						targetFile.delete(false, monitor);
+					}
+					targetFile.create(fcontents, false, monitor);
+					try{
+						fcontents.close();
+					}
+					catch(IOException ioe){
+					}
+				}
+				catch(CoreException e){
+					MessageDialog.openError(fshell, "Error", "Could not save file: " + e.=
getMessage());
+					return;
+				}
+				catch(OperationCanceledException e){
+					return;
+				}
+			}
+		};
+		try{
+			operation.run(null);
+		}
+		catch(InterruptedException e){
+		}
+		catch(InvocationTargetException ite){
+		}
+	}
+
 }

Added: archstudio4/trunk/edu.uci.isr.archstudio4.comp.xarchcs/src/edu/uci/i=
sr/archstudio4/comp/xarchcs/views/changesets/conversion/CSConverter.java
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D
--- archstudio4/trunk/edu.uci.isr.archstudio4.comp.xarchcs/src/edu/uci/isr/=
archstudio4/comp/xarchcs/views/changesets/conversion/CSConverter.java (adde=
d)
+++ archstudio4/trunk/edu.uci.isr.archstudio4.comp.xarchcs/src/edu/uci/isr/=
archstudio4/comp/xarchcs/views/changesets/conversion/CSConverter.java Thu M=
ay  1 20:04:03 2008
@@ -0,0 +1,141 @@
+package edu.uci.isr.archstudio4.comp.xarchcs.views.changesets.conversion;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import edu.uci.isr.archstudio4.comp.xarchcs.xarchcs.XArchChangeSetInterfac=
e;
+import edu.uci.isr.sysutils.UIDGenerator;
+import edu.uci.isr.xarchflat.IXArchPropertyMetadata;
+import edu.uci.isr.xarchflat.IXArchTypeMetadata;
+import edu.uci.isr.xarchflat.ObjRef;
+import edu.uci.isr.xarchflat.XArchFlatUtils;
+import edu.uci.isr.xarchflat.XArchMetadataUtils;
+
+public class CSConverter{
+
+	private static ObjRef newChangeSet(XArchChangeSetInterface xarch, ObjRef =
xArchRef, String description){
+
+		ObjRef changesetsContextRef =3D xarch.createContext(xArchRef, "changeset=
s");
+		ObjRef archChangeSetsRef =3D xarch.getElement(changesetsContextRef, "Arc=
hChangeSets", xArchRef);
+		ObjRef newChangeSetRef =3D xarch.create(changesetsContextRef, "ChangeSet=
");
+		xarch.set(newChangeSetRef, "id", UIDGenerator.generateUID("ChangeSet"));
+		XArchFlatUtils.setDescription(xarch, newChangeSetRef, "description", des=
cription);
+		xarch.add(archChangeSetsRef, "changeSet", newChangeSetRef);
+
+		List<ObjRef> appliedChangeSetRefs =3D new ArrayList<ObjRef>(Arrays.asLis=
t(xarch.getAppliedChangeSetRefs(xArchRef)));
+		appliedChangeSetRefs.add(newChangeSetRef);
+		xarch.setAppliedChangeSetRefs(xArchRef, appliedChangeSetRefs.toArray(new=
 ObjRef[appliedChangeSetRefs.size()]), null);
+
+		return newChangeSetRef;
+	}
+
+	private static ObjRef cloneTypeAndAttributes(XArchChangeSetInterface xarc=
h, ObjRef destXArchRef, ObjRef srcRef){
+		IXArchTypeMetadata srcType =3D xarch.getTypeMetadata(srcRef);
+		ObjRef destRef;
+		if(xarch.getXArch(srcRef).equals(xarch.getParent(srcRef))){
+			destRef =3D xarch.createElement(xarch.createContext(destXArchRef, XArch=
MetadataUtils.getTypeContext(srcType.getType())), XArchMetadataUtils.getTyp=
eName(srcType.getType()));
+		}
+		else{
+			destRef =3D xarch.create(xarch.createContext(destXArchRef, XArchMetadat=
aUtils.getTypeContext(srcType.getType())), XArchMetadataUtils.getTypeName(s=
rcType.getType()));
+		}
+
+		for(IXArchPropertyMetadata property: srcType.getProperties()){
+			// copy the attributes first so that the element can be resolved within=
 a change set
+			switch(property.getMetadataType()){
+
+			case IXArchPropertyMetadata.ATTRIBUTE:
+				String name =3D property.getName();
+				String value =3D (String)xarch.get(srcRef, name);
+				if(value !=3D null){
+					xarch.set(destRef, name, value);
+				}
+				break;
+
+			case IXArchPropertyMetadata.ELEMENT:
+				continue;
+
+			case IXArchPropertyMetadata.ELEMENT_MANY:
+				continue;
+			}
+		}
+
+		return destRef;
+	}
+
+	private static ObjRef selectChangeSetForGuard(XArchChangeSetInterface xar=
ch, ObjRef destXArchRef, Map<String, ObjRef> guardsToChangeSetRefs, ObjRef =
currentCSRef, ObjRef srcRef){
+		IXArchTypeMetadata srcType =3D xarch.getTypeMetadata(srcRef);
+		IXArchPropertyMetadata optionalProperty =3D srcType.getProperty("optiona=
l");
+		if(optionalProperty !=3D null && xarch.isAssignable("options#Optional", =
optionalProperty.getType())){
+			ObjRef optionalRef =3D (ObjRef)xarch.get(srcRef, "optional");
+			if(optionalRef !=3D null){
+				String guardString =3D ComparableBooleanGuardConverter.booleanGuardToS=
tring(xarch, optionalRef);
+				if(guardString !=3D null){
+					ObjRef newCSRef =3D guardsToChangeSetRefs.get(guardString);
+					if(newCSRef =3D=3D null){
+						guardsToChangeSetRefs.put(guardString, newCSRef =3D newChangeSet(xar=
ch, destXArchRef, guardString));
+					}
+					return newCSRef;
+				}
+			}
+		}
+
+		return currentCSRef;
+	}
+
+	private static void copyToCS(XArchChangeSetInterface xarch, ObjRef plaXAr=
chRef, ObjRef csXArchRef, Map<String, ObjRef> guardsToChangeSetRefs, ObjRef=
 toCSRef, ObjRef srcRef, ObjRef destRef){
+
+		IXArchTypeMetadata srcType =3D xarch.getTypeMetadata(srcRef);
+
+		for(IXArchPropertyMetadata property: srcType.getProperties()){
+			switch(property.getMetadataType()){
+			case IXArchPropertyMetadata.ATTRIBUTE:
+				// these were already copied by the parent in order to ensure that the=
 element was resolvable before copying its children
+				continue;
+
+			case IXArchPropertyMetadata.ELEMENT: {
+				ObjRef childSrcRef =3D (ObjRef)xarch.get(srcRef, property.getName());
+				if(childSrcRef !=3D null){
+					ObjRef childToCSRef =3D selectChangeSetForGuard(xarch, csXArchRef, gu=
ardsToChangeSetRefs, toCSRef, childSrcRef);
+					xarch.setActiveChangeSetRef(csXArchRef, childToCSRef);
+					ObjRef childDestRef =3D cloneTypeAndAttributes(xarch, csXArchRef, chi=
ldSrcRef);
+					xarch.set(destRef, property.getName(), childDestRef);
+					copyToCS(xarch, plaXArchRef, csXArchRef, guardsToChangeSetRefs, child=
ToCSRef, childSrcRef, childDestRef);
+				}
+			}
+				break;
+
+			case IXArchPropertyMetadata.ELEMENT_MANY: {
+				for(ObjRef childSrcRef: xarch.getAll(srcRef, property.getName())){
+					if(xarch.isInstanceOf(childSrcRef, "variants#VariantComponentType")){
+						continue;
+					}
+					if(xarch.isInstanceOf(childSrcRef, "variants#VariantComponentType")){
+						continue;
+					}
+					ObjRef childToCSRef =3D selectChangeSetForGuard(xarch, csXArchRef, gu=
ardsToChangeSetRefs, toCSRef, childSrcRef);
+					xarch.setActiveChangeSetRef(csXArchRef, childToCSRef);
+					ObjRef childDestRef =3D cloneTypeAndAttributes(xarch, csXArchRef, chi=
ldSrcRef);
+					xarch.add(destRef, property.getName(), childDestRef);
+					copyToCS(xarch, plaXArchRef, csXArchRef, guardsToChangeSetRefs, child=
ToCSRef, childSrcRef, childDestRef);
+				}
+			}
+				break;
+			}
+		}
+	}
+
+	public static void convertPLAtoCS(XArchChangeSetInterface xarch, ObjRef p=
laXArchRef, ObjRef csXArchRef){
+		xarch.enableChangeSets(csXArchRef, null);
+		ObjRef changesetsContextRef =3D xarch.createContext(csXArchRef, "changes=
ets");
+		ObjRef archChangeSetsRef =3D xarch.getElement(changesetsContextRef, "Arc=
hChangeSets", csXArchRef);
+		ObjRef baselineChangeSetRef =3D xarch.getAll(archChangeSetsRef, "ChangeS=
et")[0];
+
+		Map<String, ObjRef> guardsToChangeSetRefs =3D new HashMap<String, ObjRef=
>();
+		guardsToChangeSetRefs.put(null, baselineChangeSetRef);
+
+		copyToCS(xarch, plaXArchRef, csXArchRef, guardsToChangeSetRefs, baseline=
ChangeSetRef, plaXArchRef, csXArchRef);
+	}
+}

Propchange: archstudio4/trunk/edu.uci.isr.archstudio4.comp.xarchcs/src/edu/=
uci/isr/archstudio4/comp/xarchcs/views/changesets/conversion/CSConverter.ja=
va
---------------------------------------------------------------------------=
---
    svn:eol-style =3D native

Added: archstudio4/trunk/edu.uci.isr.archstudio4.comp.xarchcs/src/edu/uci/i=
sr/archstudio4/comp/xarchcs/views/changesets/conversion/ComparableBooleanGu=
ardConverter.java
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D
--- archstudio4/trunk/edu.uci.isr.archstudio4.comp.xarchcs/src/edu/uci/isr/=
archstudio4/comp/xarchcs/views/changesets/conversion/ComparableBooleanGuard=
Converter.java (added)
+++ archstudio4/trunk/edu.uci.isr.archstudio4.comp.xarchcs/src/edu/uci/isr/=
archstudio4/comp/xarchcs/views/changesets/conversion/ComparableBooleanGuard=
Converter.java Thu May  1 20:04:03 2008
@@ -0,0 +1,157 @@
+package edu.uci.isr.archstudio4.comp.xarchcs.views.changesets.conversion;
+
+import java.util.Arrays;
+
+import edu.uci.isr.xarchflat.ObjRef;
+import edu.uci.isr.xarchflat.XArchFlatInterface;
+
+public class ComparableBooleanGuardConverter{
+
+	public static String booleanGuardToString(XArchFlatInterface xarch, ObjRe=
f optionalRef){
+		ObjRef guardRef =3D (ObjRef)xarch.get(optionalRef, "guard");
+		if(guardRef !=3D null){
+			if(xarch.isInstanceOf(guardRef, "boolguard#BooleanGuard")){
+				ObjRef booleanExpRef =3D (ObjRef)xarch.get(guardRef, "BooleanExp");
+				if(booleanExpRef !=3D null){
+					return convertBooleanExpression(xarch, booleanExpRef);
+				}
+			}
+		}
+		return null;
+	}
+
+	private static String convertBooleanExpression(XArchFlatInterface xarch, =
ObjRef booleanExp){
+		ObjRef expression =3D null;
+
+		expression =3D (ObjRef)xarch.get(booleanExp, "And");
+		if(expression !=3D null){
+			ObjRef left =3D (ObjRef)xarch.get(expression, "BooleanExp1");
+			ObjRef right =3D (ObjRef)xarch.get(expression, "BooleanExp2");
+
+			String[] operands =3D new String[]{convertBooleanExpression(xarch, left=
), convertBooleanExpression(xarch, right)};
+			Arrays.sort(operands);
+
+			String ret =3D "(" + operands[0] + " && " + operands[1] + ")";
+
+			return ret;
+		}
+
+		expression =3D (ObjRef)xarch.get(booleanExp, "Or");
+		if(expression !=3D null){
+			ObjRef left =3D (ObjRef)xarch.get(expression, "BooleanExp1");
+			ObjRef right =3D (ObjRef)xarch.get(expression, "BooleanExp2");
+
+			String[] operands =3D new String[]{convertBooleanExpression(xarch, left=
), convertBooleanExpression(xarch, right)};
+			Arrays.sort(operands);
+
+			String ret =3D "(" + operands[0] + " || " + operands[1] + ")";
+
+			return ret;
+		}
+
+		expression =3D (ObjRef)xarch.get(booleanExp, "Not");
+		if(expression !=3D null){
+			ObjRef parameter =3D (ObjRef)xarch.get(expression, "BooleanExp");
+
+			String ret =3D "!(" + convertBooleanExpression(xarch, parameter) + ")";
+
+			return ret;
+		}
+
+		expression =3D (ObjRef)xarch.get(booleanExp, "Equals");
+		if(expression !=3D null){
+			return convertRelationalExpression(xarch, expression, "=3D=3D", "=3D=3D=
");
+		}
+
+		expression =3D (ObjRef)xarch.get(booleanExp, "NotEquals");
+		if(expression !=3D null){
+			return convertRelationalExpression(xarch, expression, "!=3D", "!=3D");
+		}
+
+		expression =3D (ObjRef)xarch.get(booleanExp, "GreaterThan");
+		if(expression !=3D null){
+			return convertRelationalExpression(xarch, expression, ">", "<");
+		}
+
+		expression =3D (ObjRef)xarch.get(booleanExp, "GreaterThanOrEquals");
+		if(expression !=3D null){
+			return convertRelationalExpression(xarch, expression, ">=3D", "<=3D");
+		}
+
+		expression =3D (ObjRef)xarch.get(booleanExp, "LessThan");
+		if(expression !=3D null){
+			return convertRelationalExpression(xarch, expression, "<", ">");
+		}
+
+		expression =3D (ObjRef)xarch.get(booleanExp, "LessThanOrEquals");
+		if(expression !=3D null){
+			return convertRelationalExpression(xarch, expression, "<=3D", ">=3D");
+		}
+
+		expression =3D (ObjRef)xarch.get(booleanExp, "InSet");
+		if(expression !=3D null){
+			ObjRef param =3D (ObjRef)xarch.get(expression, "Symbol");
+			String paramName =3D (String)xarch.get(param, "Value");
+
+			String ret =3D paramName + " @ {";
+			ObjRef[] values =3D xarch.getAll(expression, "Value");
+			String[] valueStrings =3D new String[values.length];
+			for(int i =3D 0; i !=3D values.length; ++i){
+				valueStrings[i] =3D (String)xarch.get(values[i], "Value");
+			}
+			Arrays.sort(valueStrings);
+			for(int i =3D 0; i !=3D values.length; ++i){
+				if(i > 0){
+					ret +=3D ", ";
+				}
+				ret +=3D valueStrings[i];
+			}
+			ret +=3D "}";
+
+			return ret;
+		}
+
+		expression =3D (ObjRef)xarch.get(booleanExp, "InRange");
+		if(expression !=3D null){
+			ObjRef param =3D (ObjRef)xarch.get(expression, "Symbol");
+			String paramName =3D (String)xarch.get(param, "Value");
+
+			String ret =3D paramName + " @ [";
+
+			ObjRef[] values =3D xarch.getAll(expression, "Value");
+			String value1 =3D (String)xarch.get(values[0], "Value");
+			String value2 =3D (String)xarch.get(values[1], "Value");
+
+			ret =3D ret + value1 + ", " + value2 + "]";
+			return ret;
+		}
+
+		return "";
+	}
+
+	private static String convertRelationalExpression(XArchFlatInterface xarc=
h, ObjRef expression, String symbol, String reverseSymbol){
+		ObjRef left;
+		ObjRef right;
+		String leftValue;
+		String rightValue;
+
+		left =3D (ObjRef)xarch.get(expression, "Symbol");
+		leftValue =3D (String)xarch.get(left, "Value");
+
+		right =3D (ObjRef)xarch.get(expression, "Symbol2");
+		if(right !=3D null){
+			rightValue =3D (String)xarch.get(right, "Value");
+		}
+		else{
+			right =3D (ObjRef)xarch.get(expression, "Value");
+			rightValue =3D (String)xarch.get(right, "Value");
+		}
+
+		String ret =3D leftValue + " " + symbol + " " + rightValue;
+		if(leftValue.compareTo(rightValue) > 0){
+			ret =3D leftValue + " " + reverseSymbol + " " + rightValue;
+		}
+		return ret;
+	}
+
+}

Propchange: archstudio4/trunk/edu.uci.isr.archstudio4.comp.xarchcs/src/edu/=
uci/isr/archstudio4/comp/xarchcs/views/changesets/conversion/ComparableBool=
eanGuardConverter.java
---------------------------------------------------------------------------=
---
    svn:eol-style =3D native




More information about the archstudio-commits mailing list