JAL-2316 Added UrlProvider factories. Tidied up labelling.
[jalview.git] / src / jalview / urls / UrlLinkDisplay.java
index 9afe6d3..6a49f9e 100644 (file)
 
 package jalview.urls;
 
+import jalview.util.MessageManager;
+
+import java.util.ArrayList;
+import java.util.List;
 
 /**
  * UrlLink table row definition
@@ -42,7 +46,20 @@ public class UrlLinkDisplay
 
   private boolean isSelected;
 
-  public final static int ID = 4;
+  // Headers for columns in table
+  private final static List<String> colNames = new ArrayList<String>()
+  {
+    {
+      add(MessageManager.formatMessage("label.name"));
+      add(MessageManager.formatMessage("label.url"));
+      add(MessageManager.formatMessage("label.inmenu"));
+      add(MessageManager.formatMessage("label.default"));
+      add(MessageManager.formatMessage("label.id"));
+    }
+  };
+
+  // column positions
+  public final static int NAME = 0;
 
   public final static int URL = 1;
 
@@ -50,7 +67,7 @@ public class UrlLinkDisplay
 
   public final static int DEFAULT = 3;
 
-  public final static int NAME = 0;
+  public final static int ID = 4;
 
   public UrlLinkDisplay(String rowId, String rowName, String rowUrl,
           boolean rowSelected, boolean rowDefault)
@@ -62,6 +79,7 @@ public class UrlLinkDisplay
     isSelected = rowSelected;
   }
 
+  // getters/setters
   public String getId()
   {
     return id;
@@ -117,7 +135,7 @@ public class UrlLinkDisplay
     case NAME:
       return name;
     default:
-      return null; // TODO
+      return null;
     }
   }
 
@@ -141,12 +159,30 @@ public class UrlLinkDisplay
       name = (String) value;
       break;
     default:
-      // TODO
+      // do nothing
     }
   }
 
+  /**
+   * Identify editable columns
+   * 
+   * @param index
+   *          index of column
+   * @return whether column can be edited in table
+   */
   public boolean isEditable(int index)
   {
     return ((index == DEFAULT) || (index == SELECTED));
   }
+
+  /**
+   * Get list of column names to display in UI
+   * 
+   * @return column names
+   */
+  public static List<String> getDisplayColumnNames()
+  {
+    // Display names between NAME and ID (excludes ID)
+    return colNames.subList(NAME, ID);
+  }
 }