[MOBY-guts] biomoby commit

Paul Gordon gordonp at dev.open-bio.org
Thu May 13 16:05:22 UTC 2010


gordonp
Thu May 13 12:05:22 EDT 2010
Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui
In directory dev.open-bio.org:/tmp/cvs-serv28987/src/main/ca/ucalgary/seahawk/gui

Modified Files:
	MobyDataObjectWidget.java 
Log Message:
Better widget labels, support namespaces properly
moby-live/Java/src/main/ca/ucalgary/seahawk/gui MobyDataObjectWidget.java,1.4,1.5
===================================================================
RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/MobyDataObjectWidget.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/MobyDataObjectWidget.java	2010/04/11 02:22:06	1.4
+++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/MobyDataObjectWidget.java	2010/05/13 16:05:22	1.5
@@ -4,6 +4,7 @@
 import ca.ucalgary.seahawk.util.HTMLUtils;
 import org.biomoby.shared.*;
 import org.biomoby.shared.data.*;
+import org.biomoby.shared.parser.MobyTags;
 
 import java.awt.*;
 import java.awt.event.*;
@@ -55,7 +56,7 @@
 	
 	// Are we going to allow new dropped data to supplant the current data?
 	if(editable){
-	    System.err.println("Registering handler for the data");
+	    //System.err.println("Registering handler for the data");
 	    setTransferHandler(MobyObjectTransferHandler.getHandler(client));
 	}	
 
@@ -100,14 +101,16 @@
 
     public MobyDataObjectWidget(String articleName, MobyClient client, 
 				MobyPrimaryData data) throws IllegalArgumentException{
-	this(articleName, client, data.getDataType(), (data instanceof MobyPrimaryDataSet));
+	this(articleName, client, data.getDataType(), data.getNamespaces(),
+	     (data instanceof MobyPrimaryDataSet));
     }
 
     /**
      * C-tor for uninstantiated data.
      */
     public MobyDataObjectWidget(String articleName, MobyClient client, 
-				MobyDataType dataType, boolean isaCollection) throws IllegalArgumentException{
+				MobyDataType dataType, MobyNamespace[] nss, 
+				boolean isaCollection) throws IllegalArgumentException{
 	super("", SwingConstants.CENTER);
 	name = articleName;
 	listeners = new Vector<ActionListener>();
@@ -122,6 +125,9 @@
 	    simple.setDataType(dataType);
 	    targetData = simple;		
 	}
+	if(nss != null){
+	    targetData.setNamespaces(nss);
+	}
 
 	setLabelByData();
 	setForeground(UNINSTANTIATED_FG_COLOUR);
@@ -131,16 +137,30 @@
 	setTransferHandler(MobyObjectTransferHandler.getHandler(client));
     }
 
+    private String getTypeLabel(MobyPrimaryData data){
+	String expected = data.getDataType().getName();
+	if(MobyTags.MOBYOBJECT.equals(expected)){
+	    MobyNamespace[] nss = data.getNamespaces();
+	    if(nss != null && nss.length > 0){
+		expected = nss[0].getName();
+		for(int i = 1; i < nss.length; i++){
+		    expected += " or " + nss[i].getName();
+		}
+	    }
+	}
+	return expected;
+    }
+
     protected void setLabelByData(){
 	String labelText = "[Uninitialized Object]";
 	String tipText = "[No tip is currently available for this data]";
 	if(actualData == null){
 	    MobyDataType dataType = targetData.getDataType();
 	    if(targetData instanceof MobyPrimaryDataSet){
-		labelText = name+": awaiting Collection("+dataType.getName()+"), drop data here to continue";
+		labelText = name+": awaiting Collection("+getTypeLabel(targetData)+"), drop data here to continue";
 	    }
 	    else{
-		labelText = name+": awaiting "+dataType.getName()+", drop data here to continue";
+		labelText = name+": awaiting "+getTypeLabel(targetData)+", drop data here to continue";
 	    }
 	    tipText = "Please drop data of type "+dataType.getName()+
 		" onto here: "+dataType.getDescription();
@@ -148,17 +168,22 @@
 	else{
 	    MobyDataType dataType = actualData.getDataType();
 	    if(targetData instanceof MobyPrimaryDataSet){
-		labelText = name+": Collection("+dataType.getName()+") -- "+actualData.getName();
+		labelText = name+": Collection("+getTypeLabel(actualData)+") -- "+actualData.getName();
 	    }
 	    else{
 		String display = actualData.getName();
 		if(display == null || display.trim().length() == 0){
-		    display = ((MobyDataInstance) actualData).getObject().toString();
+		    if(MobyTags.MOBYOBJECT.equals(actualData.getDataType().getName())){
+			display = actualData.getId();
+		    }
+		    else{
+			display = ((MobyDataInstance) actualData).getObject().toString();
+		    }
 		}
 		if(display.length() > MAX_DATA_DESC){
 		    display = display.substring(0, MAX_DATA_DESC-3)+"...";
 		}
-		labelText = name+": "+dataType.getName()+" -- "+display;
+		labelText = name+": "+getTypeLabel(actualData)+" -- "+display;
 	    }
 	    tipText = dataType.getDescription();
 	    if(tipText == null || tipText.length() == 0){
@@ -206,7 +231,7 @@
      * too to change the value of the data.
      */
     public void consumeMobyObject(String incomingName, MobyDataInstance incomingData){
-	System.err.println("Received data "+incomingData);
+	//System.err.println("Received data "+incomingData);
 	if(!(incomingData instanceof MobyPrimaryData)){
 	    System.err.println("MobyDataObjectWidget received a data class it could " +
 			       "not consume (ignoring): " + actualData.getClass().getName());




More information about the MOBY-guts mailing list