[archstudio-commits] svn commit: r7094 - in /archstudio4/branches/traceability/edu.uci.isr.archstudio4.comp.tracelink/src/edu/uci/isr/archstudio4/comp/tracelink: reports/ReportsView.java views/LocationButtons.java views/layouts/TracelinkSidebarViewPart.java

archstudio-commits-owner at uci.edu archstudio-commits-owner at uci.edu
Tue May 6 18:06:22 PDT 2008


Author: dpurpura
Date: Tue May  6 18:06:22 2008
New Revision: 7094

Log:
-Added Location Buttons (Note: may have resize window to paint buttons)
-Added Report generator code (no GUI, using default locations)

Added:
    archstudio4/branches/traceability/edu.uci.isr.archstudio4.comp.tracelin=
k/src/edu/uci/isr/archstudio4/comp/tracelink/views/LocationButtons.java
Modified:
    archstudio4/branches/traceability/edu.uci.isr.archstudio4.comp.tracelin=
k/src/edu/uci/isr/archstudio4/comp/tracelink/reports/ReportsView.java
    archstudio4/branches/traceability/edu.uci.isr.archstudio4.comp.tracelin=
k/src/edu/uci/isr/archstudio4/comp/tracelink/views/layouts/TracelinkSidebar=
ViewPart.java

Modified: archstudio4/branches/traceability/edu.uci.isr.archstudio4.comp.tr=
acelink/src/edu/uci/isr/archstudio4/comp/tracelink/reports/ReportsView.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/branches/traceability/edu.uci.isr.archstudio4.comp.tracelin=
k/src/edu/uci/isr/archstudio4/comp/tracelink/reports/ReportsView.java (orig=
inal)
+++ archstudio4/branches/traceability/edu.uci.isr.archstudio4.comp.tracelin=
k/src/edu/uci/isr/archstudio4/comp/tracelink/reports/ReportsView.java Tue M=
ay  6 18:06:22 2008
@@ -4,11 +4,20 @@
 package edu.uci.isr.archstudio4.comp.tracelink.reports;
 =

 //import edu.uci.isr.archstudio4.comp.tracelink.TracelinkController;
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.PrintStream;
+import java.io.PrintWriter;
+import java.util.Scanner;
+
 import edu.uci.isr.archstudio4.comp.tracelink.controllers.ITracelinkContro=
ller;
+import edu.uci.isr.archstudio4.comp.tracelink.models.ITableElement;
 import edu.uci.isr.myx.fw.AbstractMyxSimpleBrick;
 import edu.uci.isr.myx.fw.IMyxName;
 import edu.uci.isr.myx.fw.MyxRegistry;
 import edu.uci.isr.myx.fw.MyxUtils;
+import edu.uci.isr.xarch.tracelink.ITraceLink;
 =

 /**
  * @author Hazel
@@ -22,8 +31,14 @@
 	public static final IMyxName INTERFACE_NAME_IN_INVOKEREPORTVIEW =3D
 		MyxUtils.createName("invokereportview");
 	=

-	MyxRegistry myxr =3D MyxRegistry.getSharedInstance();
-	ITracelinkController tracelinkController;
+	=

+	private static final String PATH =3D "../../../../../../../../../res/repo=
rt/";
+	private static final String TEMPLATE_FILENAME =3D "G:/eclipse/edu.uci.isr=
.archstudio4.comp.tracelink/res/report/template.html";
+	=

+	protected MyxRegistry myxr =3D MyxRegistry.getSharedInstance();
+	protected ITracelinkController tracelinkController;
+	=

+	=

 	=

 	@Override
 	public void begin() {
@@ -49,10 +64,73 @@
 =

 	@Override
 	public void invokeReportView() {
-		// TODO Auto-generated method stub
 		System.out.println("ReportsView*******************");
 		System.out.println("connected to : " + tracelinkController.toString());
-		tracelinkController.readTraceLinks();
+		=

+		printReport();
 	}
-
+	=

+	public void printReport() {
+		File file =3D new File("G:/eclipse/edu.uci.isr.archstudio4.comp.tracelin=
k/res/report/report.html");
+		try {
+			System.err.println(file.getCanonicalPath());
+			file.createNewFile();
+			PrintWriter out =3D new PrintWriter(file);
+			printHead(out);
+			printBody(out);
+			out.println("</html>");
+			out.close();
+		}
+		catch (IOException e) {
+			e.printStackTrace();
+		}
+	}
+	=

+	private void printHead(PrintWriter out) {
+		try {
+			Scanner scanner =3D new Scanner(new File(TEMPLATE_FILENAME));
+			=

+			while (scanner.hasNext()) {
+				out.println(scanner.nextLine());
+			}
+			=

+		}
+		catch (FileNotFoundException e) {
+			e.printStackTrace();
+		}
+	}
+	=

+	private void printBody(PrintWriter out) {
+		out.println("<body>");
+		out.println("<table>");
+		=

+		out.println("<tr>");
+		//FIXME is this ok to do?
+		String[] keys =3D tracelinkController.getAttributeNames();
+		for (String key : keys) {
+			out.print("<th>" + key + "</th>");
+		}
+		out.println("</tr>");
+			=

+				=

+		for (ITableElement element : tracelinkController.readTraceLinks()) {
+			printITableElement(out, element);
+		}
+		=

+		out.println("</table>");
+		out.println("</body>");
+		=

+	}
+	=

+	private void printITableElement(PrintWriter out, ITableElement element) {
+		out.print("<tr id=3D'" + element.getID() + "'>");
+		for (String key : element.getKeys()) {
+			out.print("<td>");
+			out.print(element.getAttribute(key));
+			out.print("</td>");
+		}
+		out.println("</tr>");
+	}
+	=

+	=

 }

Added: archstudio4/branches/traceability/edu.uci.isr.archstudio4.comp.trace=
link/src/edu/uci/isr/archstudio4/comp/tracelink/views/LocationButtons.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/branches/traceability/edu.uci.isr.archstudio4.comp.tracelin=
k/src/edu/uci/isr/archstudio4/comp/tracelink/views/LocationButtons.java (ad=
ded)
+++ archstudio4/branches/traceability/edu.uci.isr.archstudio4.comp.tracelin=
k/src/edu/uci/isr/archstudio4/comp/tracelink/views/LocationButtons.java Tue=
 May  6 18:06:22 2008
@@ -0,0 +1,89 @@
+/**
+ * =

+ */
+package edu.uci.isr.archstudio4.comp.tracelink.views;
+
+import java.util.Vector;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.FillLayout;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Widget;
+
+import edu.uci.isr.archstudio4.comp.tracelink.controllers.ITracelinkContro=
ller;
+import edu.uci.isr.archstudio4.comp.tracelink.models.ITableElement;
+
+/**
+ * @author dpurpura
+ *
+ */
+public class LocationButtons implements IWidget {
+	=

+	private Composite composite;
+	private ITracelinkController controller;
+	=

+	int style;
+	int layoutStyle;
+	=

+	public LocationButtons(Composite parent, int style, int layoutStyle, ITra=
celinkController controller) {
+		this.composite =3D parent;
+		this.composite.setLayoutData(new GridData(layoutStyle));
+		=

+		=

+		this.style =3D style;
+		this.layoutStyle =3D layoutStyle;
+		this.controller =3D controller;
+		=

+		controller.registerView(this);
+		update();
+	}
+	=

+
+	/**
+	 * @see edu.uci.isr.archstudio4.comp.tracelink.views.IWidget#getWidget()
+	 */
+	@Override
+	public Widget getWidget() {
+		return composite;
+	}
+
+	/**
+	 * @see edu.uci.isr.archstudio4.comp.tracelink.views.IWidget#update()
+	 */
+	@Override
+	public void update() {
+		displayLocationButtons(composite, style, layoutStyle);
+	}
+	=

+	/**
+	 * @param style
+	 * @param parent
+	 */
+	private void displayLocationButtons(Composite parent, final int style, in=
t layoutStyle) {
+		Control[] controls =3D parent.getChildren();
+		for (Control control : controls)
+			control.dispose();
+		=

+		FillLayout layout =3D new FillLayout();
+		composite.setLayout(layout);
+		=

+		Vector<ITableElement> endpoints =3D controller.getFilteredElements();
+		Button button;
+		for (int i=3D0; i<endpoints.size(); i++) {
+			button =3D new Button(parent, style | SWT.PUSH);
+			button.setText(new Integer(i).toString());
+			=

+			//button.addSelectionListener(new SelectionListener());
+			/*
+			 * Hazel, you will want to uncomment and add your selection
+			 * listener above =

+			 */
+			=

+		}
+		=

+	}
+
+}

Modified: archstudio4/branches/traceability/edu.uci.isr.archstudio4.comp.tr=
acelink/src/edu/uci/isr/archstudio4/comp/tracelink/views/layouts/TracelinkS=
idebarViewPart.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/branches/traceability/edu.uci.isr.archstudio4.comp.tracelin=
k/src/edu/uci/isr/archstudio4/comp/tracelink/views/layouts/TracelinkSidebar=
ViewPart.java (original)
+++ archstudio4/branches/traceability/edu.uci.isr.archstudio4.comp.tracelin=
k/src/edu/uci/isr/archstudio4/comp/tracelink/views/layouts/TracelinkSidebar=
ViewPart.java Tue May  6 18:06:22 2008
@@ -44,13 +44,17 @@
 import edu.uci.isr.archstudio4.comp.tracelink.controllers.XADLFacade;
 import edu.uci.isr.archstudio4.comp.tracelink.models.ITableElement;
 import edu.uci.isr.archstudio4.comp.tracelink.models.TracelinkModel;
+import edu.uci.isr.archstudio4.comp.tracelink.reports.ReportsView;
 import edu.uci.isr.archstudio4.comp.tracelink.tests.TestLoader;
 import edu.uci.isr.archstudio4.comp.tracelink.views.LinkAttributeFilterBox=
View;
 import edu.uci.isr.archstudio4.comp.tracelink.views.LinkTableView;
+import edu.uci.isr.archstudio4.comp.tracelink.views.LocationButtons;
 import edu.uci.isr.archstudio4.comp.tracelink.views.TracelinkDescriptionVi=
ew;
 import edu.uci.isr.archstudio4.comp.xarchcs.explicitadt.IExplicitADT;
 import edu.uci.isr.archstudio4.comp.xarchcs.views.changesets.MyxViewPart;
+import edu.uci.isr.myx.fw.IMyxName;
 import edu.uci.isr.myx.fw.MyxRegistry;
+import edu.uci.isr.myx.fw.MyxUtils;
 import edu.uci.isr.xadlutils.XadlUtils;
 import edu.uci.isr.xarch.IXArch;
 import edu.uci.isr.xarch.IXArchImplementation;
@@ -75,7 +79,7 @@
 public class TracelinkSidebarViewPart extends MyxViewPart
 implements ISelectionListener, IPartListener {
 	=

-	protected TracelinkViewMyxComponent comp;
+	protected SimpleTracelinkController controller;
 	protected XArchFlatInterface xArchFlat;
 	protected IExplicitADT explicit;
 	protected Composite notificationComposite;
@@ -84,8 +88,7 @@
 	=

 	protected TableViewer tableviewer;
 	protected PageBook pagebook;
-	=

-	protected ITracelinkController controller;
+
 	=

 	//H
 	private Boolean recordOn;
@@ -103,22 +106,21 @@
 		=

 		ignoreEventsLock =3D new Object();
 		myxMapped =3D new ArrayList<Object>();
-		=

-		controller =3D new SimpleTracelinkController();
+
 	}
 	=

 =

 	protected void myxMap(Object o){
 		if(o !=3D null){
 			myxMapped.add(o);
-			MyxRegistry.getSharedInstance().map(comp, o);
+			MyxRegistry.getSharedInstance().map(controller, o);
 		}
 	}
 	=

 	//@override
 	public void createMyxPartControl(Composite parent){
-		comp =3D MyxRegistry.getSharedInstance().waitForBrick(TracelinkViewMyxCo=
mponent.class);
-		xArchFlat =3D comp.getXArchFlatInterface();
+		controller =3D MyxRegistry.getSharedInstance().waitForBrick(SimpleTracel=
inkController.class);
+		xArchFlat =3D controller.getXArchFlatInterface();
 		=

 		parent.setLayout(new GridLayout(1, false));
 		=

@@ -150,7 +152,7 @@
 	//@override
 	public void dispose(){
 		for(Object o: myxMapped){
-			MyxRegistry.getSharedInstance().unmap(comp, o);
+			MyxRegistry.getSharedInstance().unmap(controller, o);
 		}
 		=

 		getSite().getPage().removePartListener(this);
@@ -223,10 +225,10 @@
 		=

 		// =3D=3D EXPAND ITEM 2 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D
 		Composite bottomPanel =3D new Composite(parent, SWT.None);
-		layout =3D new GridLayout ();
-		layout.marginLeft =3D layout.marginTop =3D layout.marginRight =3D layout=
.marginBottom =3D 10;
-		layout.verticalSpacing =3D 10;
-		bottomPanel.setLayout(layout);
+		RowLayout rowLayout =3D new RowLayout();
+		rowLayout.justify =3D true;
+		bottomPanel.setLayout(rowLayout);
+		=

 		=

 		Button traceReportsButton =3D new Button(bottomPanel, SWT.None);
 		traceReportsButton.setText("Trace Reports");
@@ -251,7 +253,7 @@
 		layout.verticalSpacing =3D 10;
 		buttons.setLayout(layout);
 		=

-		displayLocationButtons(buttons, style, layoutStyle);
+		new LocationButtons(buttons, style, layoutStyle, controller);
 		=

 		ExpandItem item3 =3D new ExpandItem((ExpandBar)parent, SWT.NONE, 3);
 		item3.setText("Find Endpoint Location");
@@ -314,7 +316,7 @@
 		recoverButton.addSelectionListener(new RecoverButtonSelectionAdapter());
 		=

 		Button newLinkButton =3D new Button(parent, SWT.None);
-		newLinkButton.setText("New");
+		newLinkButton.setText("Manual");
 		newLinkButton.addSelectionListener(new NewLinkButtonSelectionAdapter());
 	}
 	=

@@ -342,32 +344,6 @@
 		=

 	}
 	=

-	/**
-	 * @param style
-	 * @param parent
-	 */
-	private void displayLocationButtons(Composite parent, final int style, in=
t layoutStyle) {
-		Composite composite =3D new Composite(parent, style);
-		composite.setLayoutData(new GridData(layoutStyle));
-		=

-		FillLayout layout =3D new FillLayout();
-		composite.setLayout(layout);
-		=

-		Vector<ITableElement> endpoints =3D controller.getFilteredElements();
-		Button button;
-		for (int i=3D0; i<endpoints.size(); i++) {
-			button =3D new Button(parent, style);
-			button.setText(new Integer(i).toString());
-			=

-			//button.addSelectionListener(new SelectionListener());
-			/*
-			 * Hazel, you will want to uncomment and add your selection
-			 * listener above =

-			 */
-			=

-		}
-		=

-	}
 	=

 	protected static GridData excludeGridData(){
 		GridData d =3D new GridData();
@@ -438,8 +414,17 @@
 	}
 	=

 	private class TraceReportsButtonSelectionAdapter extends SelectionAdapter=
 {
+		private MyxRegistry myxr =3D MyxRegistry.getSharedInstance();
+		private ReportsView reports;
+		=

+		public TraceReportsButtonSelectionAdapter() {
+			reports =3D myxr.waitForBrick(ReportsView.class);
+			=

+		}
+		=

 		public void widgetSelected(SelectionEvent e) {
 			System.out.println("Button Pushed: Trace Reports Button");
+			reports.invokeReportView();
 		}
 	}
 	=





More information about the archstudio-commits mailing list